1package community_pool23import (4 "chain"5 "strconv"67 prbac "gno.land/p/gnoswap/rbac/v1"89 "gno.land/r/gnoswap/access/v1"10 "gno.land/r/gnoswap/common"11 "gno.land/r/gnoswap/halt/v1"12)1314// GetBalanceOf returns the community pool's balance for a registered token.15//16// Parameters:17// - tokenPath: registry key/path of the token contract whose balance is queried18//19// Returns:20// - balance: token units held by the configured community-pool address, or 0 when validation fails21// - err: nil when tokenPath is valid and registered; non-nil for an invalid or unregistered tokenPath22func GetBalanceOf(tokenPath string) (int64, error) {23 communityPoolAddr := access.MustGetAddress(prbac.ROLE_COMMUNITY_POOL.String())2425 if err := common.IsRegistered(tokenPath); err != nil {26 return 0, err27 }2829 return common.BalanceOf(tokenPath, communityPoolAddr), nil30}3132// TransferToken transfers token units from the community pool to an address.33//34// Parameters:35// - cur: current realm context; callers use cross(cur) when crossing into this realm36// - tokenPath: registry key/path of the registered token to transfer37// - to: recipient address for the token units38// - amount: number of token units to transfer; transfer failure panics through the safe wrapper39//40// Only callable by admin or governance while withdrawals are not halted.41// Governance is the recommended normal route. While governance is not yet42// mature, admin access is retained for emergency-only use as an operational43// policy, not a contract-enforced condition. Admin calls do not require an44// approved proposal; emergency status is not checked and admin access does45// not expire automatically.46func TransferToken(cur realm, tokenPath string, to address, amount int64) {47 halt.AssertIsNotHaltedWithdraw()4849 prevRealm := cur.Previous()50 caller := prevRealm.Address()51 access.AssertIsAdminOrGovernance(caller)5253 common.SafeGRC20Transfer(0, cur, tokenPath, to, amount)5455 chain.Emit(56 "TransferToken",57 "prevAddr", caller.String(),58 "prevRealm", prevRealm.PkgPath(),59 "tokenPath", tokenPath,60 "to", to.String(),61 "amount", strconv.FormatInt(amount, 10),62 )63}64GetBalanceOf(tokenPath string) (int64, interface {Error func() string})
Render(path string) string
TransferToken(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, tokenPath string, to string, amount int64)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.