Skip to content

Commit 86bc80e

Browse files
committed
storage fix temp
1 parent aca488e commit 86bc80e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/web/src/stores/nft-staking-store.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Token, Transaction } from "@near/ts";
88
import type { WalletSelector } from "@near-wallet-selector/core";
99
import { utils } from "near-api-js";
1010
import Big from "big.js";
11+
import { viewMethod } from "@/helper/near";
1112

1213
export 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

Comments
 (0)