Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: TotalCoin implementation #2670

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion gno.land/pkg/sdk/vm/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@
}

func (bnk *SDKBanker) TotalCoin(denom string) int64 {
panic("not yet implemented")
var total int64 = 0

Check warning on line 40 in gno.land/pkg/sdk/vm/builtins.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/builtins.go#L40

Added line #L40 was not covered by tests

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

Check warning on line 46 in gno.land/pkg/sdk/vm/builtins.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/builtins.go#L42-L46

Added lines #L42 - L46 were not covered by tests
}
}
return false

Check warning on line 49 in gno.land/pkg/sdk/vm/builtins.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/builtins.go#L49

Added line #L49 was not covered by tests
})
return total

Check warning on line 51 in gno.land/pkg/sdk/vm/builtins.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/sdk/vm/builtins.go#L51

Added line #L51 was not covered by tests
}

func (bnk *SDKBanker) IssueCoin(b32addr crypto.Bech32Address, denom string, amount int64) {
Expand Down
Loading