ProjectLibertyLabs/gateway

Correct error handling for blockchain-service when an expected event is not found.

Closed this issue · 0 comments

Context

Currently it doesn't looks like we are handling the scenario that the expected event might not exist on chain.

example code

  public handlePublishKeyTxResult(event: Event): PublicKeyValues {
    const publicKeyValues: Partial<PublicKeyValues> = {};

    // Grab the event data
    if (event && this.api.events.msa.PublicKeyAdded.is(event)) {
      publicKeyValues.msaId = event.data.msaId.toString();
      publicKeyValues.newPublicKey = event.data.key.toString();
      publicKeyValues.debugMsg = `Public Key: ${publicKeyValues.newPublicKey} Added for msaId: ${publicKeyValues.msaId}`;
    }

    return publicKeyValues as PublicKeyValues;
  }

In the above case and other ones existing in that file if the event does not exist we will have an unhandled edge case.