Skip to content

Commit

Permalink
Fix ErrorHandler to correctly handle missing keys for Polygon signing…
Browse files Browse the repository at this point in the history
… requests

The method did not handle sign-polygon-transaction requests, which have their account-identifying address in another field than all the other request types.

Additionally simplify (or rather make more canonical) the conditions for checking for request fields.
  • Loading branch information
sisou committed Jul 21, 2024
1 parent 28eba60 commit f418320
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/views/ErrorHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class ErrorHandler extends Vue {
@Getter private findWalletByAddress!: (address: string, includeContracts: boolean) => WalletInfo | undefined;
@Getter private findWalletByKeyId!: (keyId: string) => WalletInfo | undefined;
@Getter private findWalletByPolygonAddress!: (address: string) => WalletInfo | undefined;
public async created() {
if (!(this.keyguardResult instanceof Error)) return;
Expand Down Expand Up @@ -108,11 +109,10 @@ export default class ErrorHandler extends Vue {
}
private async getWalletForThisRequest(): Promise<WalletInfo | undefined | null> {
if ((this.request as ParsedSimpleRequest).walletId) {
if ('walletId' in this.request) {
// The walletId is already in the Hub request
return WalletStore.Instance.get((this.request as ParsedSimpleRequest).walletId);
} else if ((this.request as ParsedSignTransactionRequest).sender
|| (this.request as ParsedSignMessageRequest).signer) {
return WalletStore.Instance.get(this.request.walletId);
} else if ('sender' in this.request || 'signer' in this.request) {
// Hub request was SignTransaction/Checkout/SignMessage.
// The wallet can be found by the (optional) sender/signer address in the Hub request
const messageSigner = (this.request as ParsedSignMessageRequest).signer;
Expand All @@ -125,6 +125,8 @@ export default class ErrorHandler extends Vue {
|| this.request.kind === RequestType.SIGN_MESSAGE) {
// The keyId of the selected address is in the keyguardRequest
return this.findWalletByKeyId((this.keyguardRequest as KeyguardClient.SignMessageRequest).keyId);
} else if ('request' in this.request) {
return this.findWalletByPolygonAddress(this.request.request.from);
} else {
// This really should not happen.
// Executing this code would mean i.e. a CreateRequest fired KEY_NOT_FOUND which it does not throw
Expand Down

0 comments on commit f418320

Please sign in to comment.