alucao / decon

Decentralized forum with on-chain storage on cardano blockchain
https://decon.app
2 stars 3 forks source link

show wallet balance #2

Open ralyodio opened 8 months ago

ralyodio commented 8 months ago

is it possible to show wallet balance?

alucao commented 8 months ago

Is it is possible after the user connects its wallet, using cip30 api. It should be something like:

const cborBalance = await api.getBalance()
const balance = Cardano.Value.from_bytes(Buffer.from(cborBalance, "hex")).coin().to_str()
ralyodio commented 8 months ago

ok cool. maybe i'll work on that.

ralyodio commented 8 months ago

Neither Cardano nor api are exposed in the wallet button component.

alucao commented 8 months ago

There are many ways to go around it, one could be adding a method that calculates the balance to cardano.tsx then in App.tsx when the wallet is updated (updateWallet) calculate the balance and store it in the App.tsx state. Then pass that state to the wallet component.