From f418320a540985c051b3d3000169ec0cf3326623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren?= Date: Sun, 21 Jul 2024 23:38:49 +0200 Subject: [PATCH] Fix ErrorHandler to correctly handle missing keys for Polygon signing 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. --- src/views/ErrorHandler.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/views/ErrorHandler.vue b/src/views/ErrorHandler.vue index c9c125ff..45fbf232 100644 --- a/src/views/ErrorHandler.vue +++ b/src/views/ErrorHandler.vue @@ -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; @@ -108,11 +109,10 @@ export default class ErrorHandler extends Vue { } private async getWalletForThisRequest(): Promise { - 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; @@ -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