From abb6ea5f302c0664835a52e5d684442d4944a186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Riquelme=20Guzm=C3=A1n?= Date: Mon, 13 May 2024 22:12:55 -0400 Subject: [PATCH 1/2] fix: re order of if clauses to fix invalid address format --- .../transfers/fungible-token-transfer.ts | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts index 7c978847..71b8933d 100644 --- a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts +++ b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts @@ -323,21 +323,6 @@ export class FungibleTokenTransferController implements ReactiveController { }; getTransferState(): FungibleTransferState { - if (this.transferTransactionId) { - return FungibleTransferState.COMPLETED; - } - if (this.waitingUserConfirmation) { - return FungibleTransferState.WAITING_USER_CONFIRMATION; - } - if (this.waitingTxExecution) { - return FungibleTransferState.WAITING_TX_EXECUTION; - } - if (this.pendingEvmApprovalTransactions.length > 0) { - return FungibleTransferState.PENDING_APPROVALS; - } - if (this.pendingTransferTransaction) { - return FungibleTransferState.PENDING_TRANSFER; - } if (!this.sourceNetwork) { return FungibleTransferState.MISSING_SOURCE_NETWORK; } @@ -347,11 +332,9 @@ export class FungibleTokenTransferController implements ReactiveController { if (!this.selectedResource) { return FungibleTransferState.MISSING_RESOURCE; } - - if (this.destinationAddress === '') { - return FungibleTransferState.MISSING_DESTINATION_ADDRESS; + if (this.resourceAmount.eq(0)) { + return FungibleTransferState.MISSING_RESOURCE_AMOUNT; } - if ( this.destinationAddress === null || this.destinationAddress === undefined || @@ -359,13 +342,24 @@ export class FungibleTokenTransferController implements ReactiveController { ) { return FungibleTransferState.INVALID_DESTINATION_ADDRESS; } - - if (this.resourceAmount.eq(0)) { - return FungibleTransferState.MISSING_RESOURCE_AMOUNT; - } if (this.destinationAddress === '') { return FungibleTransferState.MISSING_DESTINATION_ADDRESS; } + if (this.transferTransactionId) { + return FungibleTransferState.COMPLETED; + } + if (this.waitingUserConfirmation) { + return FungibleTransferState.WAITING_USER_CONFIRMATION; + } + if (this.waitingTxExecution) { + return FungibleTransferState.WAITING_TX_EXECUTION; + } + if (this.pendingEvmApprovalTransactions.length > 0) { + return FungibleTransferState.PENDING_APPROVALS; + } + if (this.pendingTransferTransaction) { + return FungibleTransferState.PENDING_TRANSFER; + } if ( !this.walletContext.value?.evmWallet && !this.walletContext.value?.substrateWallet From f102647acd42d922eb4c9baf4c065cea2237fe12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Riquelme=20Guzm=C3=A1n?= Date: Tue, 14 May 2024 21:47:48 -0400 Subject: [PATCH 2/2] fix: fix test and small re-order on if clause --- .../src/controllers/transfers/fungible-token-transfer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts index 71b8933d..21dbb008 100644 --- a/packages/widget/src/controllers/transfers/fungible-token-transfer.ts +++ b/packages/widget/src/controllers/transfers/fungible-token-transfer.ts @@ -323,6 +323,9 @@ export class FungibleTokenTransferController implements ReactiveController { }; getTransferState(): FungibleTransferState { + if (this.transferTransactionId) { + return FungibleTransferState.COMPLETED; + } if (!this.sourceNetwork) { return FungibleTransferState.MISSING_SOURCE_NETWORK; } @@ -345,9 +348,6 @@ export class FungibleTokenTransferController implements ReactiveController { if (this.destinationAddress === '') { return FungibleTransferState.MISSING_DESTINATION_ADDRESS; } - if (this.transferTransactionId) { - return FungibleTransferState.COMPLETED; - } if (this.waitingUserConfirmation) { return FungibleTransferState.WAITING_USER_CONFIRMATION; }