Skip to content

Commit 386db41

Browse files
committed
use provider instead of wallet provider
1 parent 9e23c83 commit 386db41

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

packages/keychain/src/components/Funding.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,14 @@ function useTokens() {
324324
const checkFunds = useCallback(async () => {
325325
setIsFetching(true);
326326

327-
const checked = await updateBalance(tokens, controller.account as Account);
327+
const checked = await updateBalance(tokens, controller.account.rpc, controller.address );
328328
setTokens(checked);
329329

330330
setIsFetching(false);
331331
if (!isChecked) {
332332
setIsChecked(true);
333333
}
334-
}, [tokens, controller.account, isChecked]);
334+
}, [tokens, controller, isChecked]);
335335

336336
useInterval(checkFunds, 3000);
337337

packages/keychain/src/components/connect/SignupArgent.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import {
2424
useAccount,
2525
useConnect,
2626
useInjectedConnectors,
27+
useProvider,
2728
voyager,
2829
} from "@starknet-react/core";
2930
import {
30-
Account,
3131
CallData,
3232
RpcProvider,
3333
cairo,
@@ -365,6 +365,7 @@ function ExternalWalletProvider({ children }: PropsWithChildren) {
365365

366366
function useTokens() {
367367
const { account: extAccount } = useAccount();
368+
const { provider } = useProvider();
368369
const { controller, prefunds } = useConnection();
369370
const [tokens, setTokens] = useState<TokenInfo[]>([]);
370371
const [isChecked, setIsChecked] = useState(false);
@@ -379,14 +380,14 @@ function useTokens() {
379380
const checkFunds = useCallback(async () => {
380381
setIsFetching(true);
381382

382-
const checked = await updateBalance(tokens, extAccount as Account);
383+
const checked = await updateBalance(tokens, provider, extAccount?.address);
383384
setTokens(checked);
384385

385386
setIsFetching(false);
386387
if (!isChecked) {
387388
setIsChecked(true);
388389
}
389-
}, [tokens, controller, isChecked, extAccount]);
390+
}, [tokens, controller, isChecked, extAccount?.address]);
390391

391392
useInterval(checkFunds, 3000);
392393

packages/keychain/src/utils/token.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EthereumIcon } from "@cartridge/ui";
33
import { Image } from "@chakra-ui/react";
44
import { formatEther } from "viem";
55
import { formatAddress } from "./contracts";
6-
import { Account, uint256 } from "starknet";
6+
import { ProviderInterface, uint256 } from "starknet";
77

88
export const ETH_CONTRACT_ADDRESS =
99
"0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
@@ -65,16 +65,17 @@ export async function fetchTokenInfo(prefunds: Prefund[]) {
6565
return tokens;
6666
}
6767

68-
export async function updateBalance(tokens: TokenInfo[], account: Account) {
69-
if (!account) return tokens;
68+
export async function updateBalance(tokens: TokenInfo[], provider: ProviderInterface, address: string) {
69+
if (!provider) return tokens;
7070

7171
const res = await Promise.allSettled(
7272
tokens.map(async (t) => {
7373
try {
74-
let balance = await account.callContract({
74+
75+
let balance = await provider.callContract({
7576
contractAddress: t.address,
7677
entrypoint: "balanceOf",
77-
calldata: [account.address],
78+
calldata: [address],
7879
});
7980

8081
/* @ts-ignore */

0 commit comments

Comments
 (0)