Skip to content

fix the wallet balance display#326

Open
omsant02 wants to merge 7 commits into
developfrom
wallet-balance
Open

fix the wallet balance display#326
omsant02 wants to merge 7 commits into
developfrom
wallet-balance

Conversation

@omsant02
Copy link
Copy Markdown
Contributor

@omsant02 omsant02 commented Apr 2, 2025

Removed the hardcoded wallet balance and displaying the actual wallet balance with proper decimal logic for integer and float
image
image

closes #318

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starknet-remix-plugin ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 21, 2025 5:11pm

Comment thread plugin/src/components/Wallet/index.tsx Outdated
if (status === "connected" && address !== undefined && address !== null) {
try {
const customProvider = new RpcProvider({
nodeUrl: "https://free-rpc.nethermind.io/sepolia-juno/v0_7"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only for sepolia, but we need to also support mainnet

selectedAccount.address != null
? getShortenedHash(selectedAccount.address, 6, 4)
: "No account selected";
console.log("sdfdfd", selectedAccount.balance);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment thread plugin/src/components/Wallet/index.tsx Outdated
import { useSetAtom } from "jotai";
import { atom, useAtom, useSetAtom } from "jotai";
import { RpcProvider, Contract } from "starknet";
// import { formatEther } from "ethers/lib/utils";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment thread plugin/src/components/Wallet/index.tsx Outdated

export const walletBalanceAtom = atom<string | null>(null);

const ETH_TOKEN_ADDRESS = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the right place for this? I think we can move it into utils/consts

Comment thread plugin/src/components/Wallet/index.tsx Outdated
const setDeclTxHash = useSetAtom(declTxHashAtom);
const setDeployTxHash = useSetAtom(deployTxHashAtom);
const setInvokeTxHash = useSetAtom(invokeTxHashAtom);
console.log(balance
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment thread plugin/src/components/Wallet/index.tsx Outdated
}
};

if (status === "connected" && address !== undefined && address !== null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this check here? fetchBalance function is doing the same

const walletAccount = useAtomValue(account);
// const walletProvider = useAtomValue(provider)
const walletBalance = useAtomValue(walletBalanceAtom);
console.log("walletBalance", walletBalance);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@varex83 varex83 requested a review from Copilot April 4, 2025 09:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread plugin/src/components/Wallet/index.tsx Outdated
import { RpcProvider, Contract } from "starknet";
// import { formatEther } from "ethers/lib/utils";

export const walletBalanceAtom = atom<string | null>(null);
Copy link

Copilot AI Apr 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The walletBalanceAtom is typed as string | null but is later used as a BigNumberish value when formatting the balance. Consider using a type that reflects the returned value from balanceOf (e.g., BigNumberish | null) or consistently convert the fetched balance to a string.

Copilot uses AI. Check for mistakes.
@omsant02
Copy link
Copy Markdown
Contributor Author

omsant02 commented Apr 4, 2025

hey @varex83 , that was not the code i meant to push, that was just for testing(the console logs, etc), while solving merge conflict i think i made the mistake, no worries i'll fix this

Comment thread plugin/src/components/Wallet/index.tsx Outdated
type: "function"
}
];
export const walletBalanceAtom = atom<string | bigint | null>(null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to store atom here, we have atoms directory for this purpose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

actual wallet balance is not being shown

3 participants