From 959bd265fd97e0f4af94c41723f357f1e79ddfce Mon Sep 17 00:00:00 2001 From: yomarion Date: Thu, 28 Sep 2023 21:40:19 +0200 Subject: [PATCH] fix: storage check for USDC on Near is custom --- packages/payment-processor/src/payment/utils-near.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/payment-processor/src/payment/utils-near.ts b/packages/payment-processor/src/payment/utils-near.ts index aa5da329e0..d41d87b777 100644 --- a/packages/payment-processor/src/payment/utils-near.ts +++ b/packages/payment-processor/src/payment/utils-near.ts @@ -243,11 +243,17 @@ export const isReceiverReady = async ( tokenAddress: string, paymentAddress: string, ): Promise => { + const storageCheckMethod = + tokenAddress === '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1' + ? // USDC + 'check_registration' + : // Near Fungible Token standard + 'storage_balance_of'; const fungibleContract = new Contract(walletConnection.account(), tokenAddress, { changeMethods: [], - viewMethods: ['storage_balance_of'], + viewMethods: [storageCheckMethod], }) as any; - const storage = (await fungibleContract.storage_balance_of({ + const storage = (await fungibleContract[storageCheckMethod]({ account_id: paymentAddress, })) as StorageBalance | null; return !!storage && BigNumber.from(storage?.total).gte(MIN_STORAGE_FOR_FUNGIBLE);