types.gno
3.92 Kb · 98 lines
1package common
2
3type ICommon interface {
4 // ValidateNotHandleNativeCoin rejects a call carrying native coins.
5 //
6 // Returns:
7 // - error: non-nil when the transaction includes native coins; nil when no native coins are attached
8 ValidateNotHandleNativeCoin() error
9
10 // IsRegistered checks whether tokenKey identifies a registered token.
11 //
12 // Parameters:
13 // - tokenKey: token registry key to validate and look up
14 //
15 // Returns:
16 // - error: nil when tokenKey is valid and registered; non-nil for an invalid or unregistered key
17 IsRegistered(tokenKey string) error
18
19 // ValidateRegistered checks each token key in order.
20 //
21 // Parameters:
22 // - tokenKeys: token registry keys that must all be valid and registered
23 //
24 // Returns:
25 // - error: nil when every key is registered; otherwise the first registration failure in input order
26 ValidateRegistered(tokenKeys ...string) error
27
28 // TotalSupply returns the total supply of a registered token.
29 //
30 // Parameters:
31 // - tokenKey: token registry key whose supply is queried
32 //
33 // Returns:
34 // - totalSupply: token's total supply; panics if tokenKey is invalid or unregistered
35 TotalSupply(tokenKey string) int64
36
37 // BalanceOf returns a registered token's balance for an address.
38 //
39 // Parameters:
40 // - tokenKey: token registry key whose balance is queried
41 // - addr: account address whose token balance is queried
42 //
43 // Returns:
44 // - balance: token units held by addr; panics if tokenKey is invalid or unregistered
45 BalanceOf(tokenKey string, addr address) int64
46
47 // Allowance returns the approved spendable amount for an owner/spender pair.
48 //
49 // Parameters:
50 // - tokenKey: token registry key whose allowance is queried
51 // - owner: account that granted spending approval
52 // - spender: account allowed to spend owner's tokens
53 //
54 // Returns:
55 // - allowance: token units owner has approved for spender; panics if tokenKey is invalid or unregistered
56 Allowance(tokenKey string, owner, spender address) int64
57
58 // Transfer asks the token teller bound to rlm to move tokens to to.
59 //
60 // Parameters:
61 // - _: leading token-call discriminator; callers pass 0
62 // - rlm: propagated realm context used to bind the token teller and invoke the transfer
63 // - tokenKey: token registry key whose tokens are transferred
64 // - to: recipient account address
65 // - amount: number of token units to transfer
66 //
67 // Returns:
68 // - error: nil when the teller completes the transfer; non-nil when token validation or transfer rules reject it
69 Transfer(_ int, rlm realm, tokenKey string, to address, amount int64) error
70
71 // TransferFrom asks the token teller bound to rlm to transfer tokens from one account to another.
72 //
73 // Parameters:
74 // - _: leading token-call discriminator; callers pass 0
75 // - rlm: propagated realm context used to bind the token teller and invoke the transfer
76 // - tokenKey: token registry key whose tokens are transferred
77 // - from: account whose token balance is debited
78 // - to: recipient account address
79 // - amount: number of token units to transfer
80 //
81 // Returns:
82 // - error: nil when the teller completes the transfer; non-nil when token validation, allowance, or balance rules reject it
83 TransferFrom(_ int, rlm realm, tokenKey string, from, to address, amount int64) error
84
85 // Approve asks the token teller bound to rlm to set spender's allowance.
86 //
87 // Parameters:
88 // - _: leading token-call discriminator; callers pass 0
89 // - rlm: propagated realm context used to bind the token teller and invoke approval
90 // - tokenKey: token registry key whose tokens are approved
91 // - spender: account receiving permission to spend the caller's tokens
92 // - amount: number of token units to authorize
93 //
94 // Returns:
95 // - error: nil when the teller records the allowance; non-nil when token validation or approval rules reject it
96 Approve(_ int, rlm realm, tokenKey string, spender address, amount int64) error
97 Render(path string) string
98}