Documentation ¶
Index ¶
- Constants
- func CheckAllowanceArgs(args []interface{}) (common.Address, common.Address, string, error)
- func CheckApprovalArgs(args []interface{}, denom string) (common.Address, *sdk.Coin, []string, error)
- func CheckAuthzAndAllowanceForGranter(ctx sdk.Context, authzKeeper authzkeeper.Keeper, ...) (*stakingtypes.StakeAuthorization, *time.Time, error)
- func CheckAuthzExists(ctx sdk.Context, authzKeeper authzkeeper.Keeper, ...) (authz.Authorization, *time.Time, error)
- func CheckRevokeArgs(args []interface{}) (common.Address, []string, error)
- func EmitIBCTransferAuthorizationEvent(event abi.Event, ctx sdk.Context, stateDB vm.StateDB, ...) error
- func EmitRevocationEvent(args cmn.EmitEventArgs) error
- type EventAllowanceChange
- type EventApproval
- type EventRevocation
Constants ¶
const ( // ErrAuthzDoesNotExistOrExpired is raised when the authorization does not exist. ErrAuthzDoesNotExistOrExpired = "authorization to %s for address %s does not exist or is expired" // ErrEmptyMethods is raised when the given methods array is empty. ErrEmptyMethods = "no methods defined; expected at least one message type url" // ErrEmptyStringInMethods is raised when the given methods array contains an empty string. ErrEmptyStringInMethods = "empty string found in methods array; expected no empty strings to be passed; got: %v" // ErrExceededAllowance is raised when the amount exceeds the set allowance. ErrExceededAllowance = "amount %s greater than allowed limit %s" // ErrInvalidGranter is raised when the granter address is not valid. ErrInvalidGranter = "invalid granter address: %v" // ErrInvalidGrantee is raised when the grantee address is not valid. ErrInvalidGrantee = "invalid grantee address: %v" // ErrInvalidMethods is raised when the given methods cannot be unpacked. ErrInvalidMethods = "invalid methods defined; expected an array of strings; got: %v" // ErrInvalidMethod is raised when the given method cannot be unpacked. ErrInvalidMethod = "invalid method defined; expected a string; got: %v" // ErrAuthzNotAccepted is raised when the authorization is not accepted. ErrAuthzNotAccepted = "authorization to %s for address %s is not accepted" )
const ( // ApproveMethod defines the ABI method name for the authorization Approve transaction. ApproveMethod = "approve" // RevokeMethod defines the ABI method name for the authorization Revoke transaction. RevokeMethod = "revoke" // DecreaseAllowanceMethod defines the ABI method name for the DecreaseAllowance transaction. DecreaseAllowanceMethod = "decreaseAllowance" // IncreaseAllowanceMethod defines the ABI method name for the IncreaseAllowance transaction. IncreaseAllowanceMethod = "increaseAllowance" // AllowanceMethod defines the ABI method name for the Allowance query. AllowanceMethod = "allowance" // EventTypeApproval defines the event type for the distribution Approve transaction. EventTypeApproval = "Approval" // EventTypeRevocation defines the event type for the distribution Revoke transaction. EventTypeRevocation = "Revocation" // EventTypeAllowanceChange defines the event type for the staking IncreaseAllowance or // DecreaseAllowance transactions. EventTypeAllowanceChange = "AllowanceChange" )
const ( // EventTypeIBCTransferAuthorization defines the event type for the ICS20 TransferAuthorization transaction. EventTypeIBCTransferAuthorization = "IBCTransferAuthorization" //#nosec G101 -- no hardcoded credentials here )
Variables ¶
This section is empty.
Functions ¶
func CheckAllowanceArgs ¶
CheckAllowanceArgs checks the arguments for the Allowance function.
func CheckApprovalArgs ¶
func CheckApprovalArgs(args []interface{}, denom string) (common.Address, *sdk.Coin, []string, error)
CheckApprovalArgs checks the arguments passed to the approve function as well as the functions to change the allowance. This is refactored into one function as they all take in the same arguments.
func CheckAuthzAndAllowanceForGranter ¶
func CheckAuthzAndAllowanceForGranter( ctx sdk.Context, authzKeeper authzkeeper.Keeper, grantee, granter common.Address, amount *sdk.Coin, msgURL string, ) (*stakingtypes.StakeAuthorization, *time.Time, error)
CheckAuthzAndAllowanceForGranter checks if the authorization exists and is not expired for the given spender and the allowance is not exceeded. If the authorization has a limit, checks that the provided amount does not exceed the current limit. Returns an error if the authorization does not exist is expired or the allowance is exceeded.
func CheckAuthzExists ¶
func CheckAuthzExists( ctx sdk.Context, authzKeeper authzkeeper.Keeper, grantee, granter common.Address, msgURL string, ) (authz.Authorization, *time.Time, error)
CheckAuthzExists checks if the authorization exists for the given granter and returns the authorization and its expiration time.
NOTE: It's not necessary to check for expiration of the authorization, because that is already handled by the GetAuthorization method. If a grant is expired, it will return nil.
func CheckRevokeArgs ¶
CheckRevokeArgs checks the arguments passed to the revoke function.
func EmitIBCTransferAuthorizationEvent ¶
func EmitIBCTransferAuthorizationEvent( event abi.Event, ctx sdk.Context, stateDB vm.StateDB, precompileAddr, granteeAddr, granterAddr common.Address, allocations []cmn.ICS20Allocation, ) error
EmitIBCTransferAuthorizationEvent creates a new IBC transfer authorization event emitted on a TransferAuthorization transaction.
func EmitRevocationEvent ¶
func EmitRevocationEvent(args cmn.EmitEventArgs) error
EmitRevocationEvent creates a new approval event emitted on a Revoke transaction.
Types ¶
type EventAllowanceChange ¶
type EventAllowanceChange struct { Grantee common.Address Granter common.Address Values []*big.Int Methods []string }
EventAllowanceChange is the event emitted on successful IncreaseAllowance or DecreaseAllowance transactions.