const shrinkToken = (value, decimals) => { return new Big(value).div(new Big(10).pow(decimals)); }; const { onLoad } = props; let accountId = context.accountId; if (!accountId) { return <Widget src="juaner.near/widget/ref_account-signin" />; } const account = fetch("https://rpc.mainnet.near.org", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ jsonrpc: "2.0", id: "dontcare", method: "query", params: { request_type: "view_account", finality: "final", account_id: accountId, }, }), }); if (account) { const b = account.body.result.amount; const nearBalance = shrinkToken(b || "0", 24).toFixed(); onLoad && onLoad({ nearBalance, }); } return <></>;