@@ -8,6 +8,7 @@ import { Token, Transaction } from "@near/ts";
88import type { WalletSelector } from "@near-wallet-selector/core" ;
99import { utils } from "near-api-js" ;
1010import Big from "big.js" ;
11+ import { viewMethod } from "@/helper/near" ;
1112
1213export const useNftStaking = create < {
1314 loading : boolean ;
@@ -265,6 +266,37 @@ export const useNftStaking = create<{
265266
266267 const transactions : any = [ ] ;
267268
269+ console . log ( "Claiming" , tokens . length , "rewards" ) ;
270+ const remainStorage : {
271+ total : string ;
272+ available : string ;
273+ } | null = await viewMethod (
274+ import . meta. env . VITE_NFT_STAKING_CONTRACT ,
275+ "storage_balance_of" ,
276+ {
277+ account_id : account ,
278+ }
279+ ) ;
280+ console . log ( remainStorage ?. available ) ;
281+ //TODO: Temporary fix for claim deposit
282+ if (
283+ remainStorage != null &&
284+ new Big ( remainStorage ?. available ) . lte ( "50000000000000000000000" )
285+ ) {
286+ transactions . push (
287+ getTransaction (
288+ account ,
289+ import . meta. env . VITE_NFT_STAKING_CONTRACT ,
290+ "storage_deposit" ,
291+ {
292+ account_id : account ,
293+ registration_only : false ,
294+ } ,
295+ "0.0023"
296+ )
297+ ) ;
298+ }
299+
268300 tokens . forEach ( ( { token_id } ) => {
269301 transactions . push (
270302 getTransaction (
@@ -303,6 +335,7 @@ export const useNftStaking = create<{
303335 for ( const key of balances ) {
304336 const storage = await get ( ) . getTokenStorage ( connection , account , key ) ;
305337 const storageMin = await get ( ) . getMinStorageCost ( connection , key ) ;
338+ console . log ( storageMin ) ;
306339 const nearStorageCost = utils . format . formatNearAmount ( storageMin ?. min ) ;
307340
308341 if ( ! storage ) {
0 commit comments