From 6e9287dcaaaae0229e439d9f513d40200bbca668 Mon Sep 17 00:00:00 2001 From: DIGIX666 Date: Thu, 8 Aug 2024 23:17:48 +0200 Subject: [PATCH] add implementation to TotalCoin --- gno.land/pkg/sdk/vm/builtins.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gno.land/pkg/sdk/vm/builtins.go b/gno.land/pkg/sdk/vm/builtins.go index de58cd3e8ae..d96ffcd3195 100644 --- a/gno.land/pkg/sdk/vm/builtins.go +++ b/gno.land/pkg/sdk/vm/builtins.go @@ -37,7 +37,18 @@ func (bnk *SDKBanker) SendCoins(b32from, b32to crypto.Bech32Address, amt std.Coi } func (bnk *SDKBanker) TotalCoin(denom string) int64 { - panic("not yet implemented") + var total int64 = 0 + + bnk.vmk.acck.IterateAccounts(bnk.ctx, func(acc std.Account) bool { + coins := bnk.vmk.bank.GetCoins(bnk.ctx, acc.GetAddress()) + for _, coin := range coins { + if coin.Denom == denom { + total += coin.Amount + } + } + return false + }) + return total } func (bnk *SDKBanker) IssueCoin(b32addr crypto.Bech32Address, denom string, amount int64) {