From bc8a374974ad211163e2416fb26caa3677bd2970 Mon Sep 17 00:00:00 2001 From: genaroibc Date: Tue, 22 Oct 2024 21:51:43 -0300 Subject: [PATCH 1/3] fix: catch error getting token symbol --- src/handlers/evm/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/handlers/evm/utils.ts b/src/handlers/evm/utils.ts index 0e9ac8c..acd8731 100644 --- a/src/handlers/evm/utils.ts +++ b/src/handlers/evm/utils.ts @@ -46,11 +46,17 @@ export class Utils { throw new Error(`Insufficient funds for account: ${sender} on chain ${fromChain.chainId}`); } + let tokenSymbol; + + try { + tokenSymbol = await (fromTokenContract as Contract).symbol(); + } catch (error) { + console.error("failed to get token symbol"); + } + return { isApproved: true, - message: `User has the expected balance ${amount} of ${await ( - fromTokenContract as Contract - ).symbol()}`, + message: `User has the expected balance ${amount} of ${tokenSymbol}`, }; } From 7ccfb43df7d989673a7b7841756baa085ac92fe7 Mon Sep 17 00:00:00 2001 From: genaroibc Date: Tue, 22 Oct 2024 21:54:01 -0300 Subject: [PATCH 2/3] chore: improve message --- src/handlers/evm/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/handlers/evm/utils.ts b/src/handlers/evm/utils.ts index acd8731..bf642f6 100644 --- a/src/handlers/evm/utils.ts +++ b/src/handlers/evm/utils.ts @@ -56,7 +56,10 @@ export class Utils { return { isApproved: true, - message: `User has the expected balance ${amount} of ${tokenSymbol}`, + message: + tokenSymbol != null + ? `User has the expected balance ${amount}` + : `User has the expected balance ${amount} of ${tokenSymbol}`, }; } From 2a3dad8a8928480420db330156920990e42a92e7 Mon Sep 17 00:00:00 2001 From: genaroibc Date: Tue, 22 Oct 2024 21:55:58 -0300 Subject: [PATCH 3/3] chore: fix comparison --- src/handlers/evm/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/evm/utils.ts b/src/handlers/evm/utils.ts index bf642f6..ca6e3c2 100644 --- a/src/handlers/evm/utils.ts +++ b/src/handlers/evm/utils.ts @@ -57,7 +57,7 @@ export class Utils { return { isApproved: true, message: - tokenSymbol != null + tokenSymbol == null ? `User has the expected balance ${amount}` : `User has the expected balance ${amount} of ${tokenSymbol}`, };