func Allowance
ActionAllowance returns the token allowance from owner to spender.
Parameters:
- tokenKey: GRC20 registry key
- owner: address of the token owner
- spender: address of the spender
Returns the allowance amount as int64.
Package common provides shared realm utilities for GnoSwap protocol contracts.
Package common provides shared realm utilities for GnoSwap protocol contracts.
The common package contains helpers that must keep a realm boundary, including GRC20 token operations and native coin validation.
The write helpers are crossing adapters and should be called as
common.Transfer(cross(cur), ...), common.SafeGRC20Transfer(cross(cur), ...),
and so on. They intentionally keep cur realm as the first parameter so the
helper runs in common's crossing frame, then forward that live cur to
grc20.Teller as Transfer(0, cur, ...). Because GetTokenTeller returns a
CallerTeller, the token actor is derived from cur.Previous(), which is the
realm that crossed into common. Do not convert these helpers to
_ int, rlm realm; that would remove the common crossing boundary and change
which realm CallerTeller treats as the actor.
Token Operations:
Token Queries:
Token Transfers:
Coin Validation:
Package common provides shared realm utilities for GnoSwap protocol contracts.
The package contains helpers that must keep a realm boundary, including GRC20 token operations and native coin validation. AMM math lives in gno.land/p/gnoswap/gnsmath.
Key components: - GRC20 Registry Helpers: convenient wrappers for GRC20 token operations - Coin Utilities: native coin handling and validation - Assertion Utilities: input validation and authorization checks
Allowance returns the token allowance from owner to spender.
Parameters:
Returns the allowance amount as int64.
Approve crosses into common before forwarding to grc20.Teller.Approve. CallerTeller uses cur.Previous() as the approver, so this helper must remain a crossing adapter called with cross(cur).
Parameters:
Returns an error if the approval fails, nil otherwise.
AssertIsNotHandleNativeCoin validates that no native coins were sent with the transaction. Panics with errNotHandleNativeCoin if any native coins were sent.
Use this when a function should only work with GRC20 tokens and not accept native coins.
BalanceOf returns the token balance for the specified address.
Parameters:
Returns the token balance as int64.
GetToken returns a grc20.Token instance for the specified tokenKey, panicking if not registered.
Parameters:
Returns a pointer to the grc20.Token instance.
Panics if the token is not registered in grc20reg.
GetTokenTeller returns a CallerTeller for the specified tokenKey, panicking if not registered.
Parameters:
Returns a grc20.Teller whose write methods derive the actor from the caller realm.
Panics if the token is not registered in grc20reg.
IsRegistered checks if a token is registered in grc20reg, returning nil if registered or error if not.
Parameters:
Returns nil if the token is registered, or an error describing the issue.
MustRegistered checks if all provided tokens are registered, panicking if any is not registered.
Parameters:
Panics if any of the provided tokens is not registered in grc20reg.
SafeGRC20Approve crosses into common, approves tokens, and panics if it fails. CallerTeller uses cur.Previous() as the approver, so this helper must remain a crossing adapter called with cross(cur).
Parameters:
Panics if the approval fails.
SafeGRC20Transfer crosses into common, transfers tokens, and panics if it fails. CallerTeller uses cur.Previous() as the token actor, so this helper must remain a crossing adapter called with cross(cur).
Parameters:
Panics if the transfer fails.
SafeGRC20TransferFrom crosses into common, transfers tokens, and panics if it fails. CallerTeller uses cur.Previous() as the spender, so this helper must remain a crossing adapter called with cross(cur).
Parameters:
Panics if the transfer fails.
TotalSupply returns the total supply of the specified token.
Parameters:
Returns the total supply of the token as int64.
Transfer crosses into common before forwarding to grc20.Teller.Transfer. CallerTeller uses cur.Previous() as the token actor, so this helper must remain a crossing adapter called with cross(cur).
Parameters:
Returns an error if the transfer fails, nil otherwise.
TransferFrom crosses into common before forwarding to grc20.Teller.TransferFrom. CallerTeller uses cur.Previous() as the spender, so this helper must remain a crossing adapter called with cross(cur).
Parameters:
Returns an error if the transfer fails, nil otherwise.