Skip to content

Commit

Permalink
fix: storage check for USDC on Near is custom (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
yomarion committed Sep 29, 2023
1 parent 89d60f4 commit be9a2c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/payment-processor/src/payment/utils-near.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,17 @@ export const isReceiverReady = async (
tokenAddress: string,
paymentAddress: string,
): Promise<boolean> => {
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);
Expand Down

0 comments on commit be9a2c4

Please sign in to comment.