igrc777.gno
5.06 Kb ยท 171 lines
1package grc777
2
3// TODO: use big.Int or a custom int64 instead of int64
4
5type IGRC777 interface {
6 // Returns the name of the token.
7 GetName() string
8
9 // Returns the symbol of the token, usually a shorter version of the
10 // name.
11 GetSymbol() string
12
13 // Returns the decimals places of the token.
14 GetDecimals() int
15
16 // Returns the smallest part of the token that is not divisible. This
17 // means all token operations (creation, movement and destruction) must
18 // have amounts that are a multiple of this number.
19 //
20 // For most token contracts, this value will equal 1.
21 Granularity() (granularity int64)
22
23 // Returns the amount of tokens in existence.
24 TotalSupply() (supply int64)
25
26 // Returns the amount of tokens owned by an account (`owner`).
27 BalanceOf(address_XXX address) int64
28
29 // Moves `amount` tokens from the caller's account to `recipient`.
30 //
31 // If send or receive hooks are registered for the caller and `recipient`,
32 // the corresponding functions will be called with `data` and empty
33 // `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
34 //
35 // Emits a {Sent} event.
36 //
37 // Requirements
38 //
39 // - the caller must have at least `amount` tokens.
40 // - `recipient` cannot be the zero address.
41 // - if `recipient` is a contract, it must implement the {IERC777Recipient}
42 // interface.
43 Send(recipient address, amount int64, data []byte)
44
45 // Destroys `amount` tokens from the caller's account, reducing the
46 // total supply.
47 //
48 // If a send hook is registered for the caller, the corresponding function
49 // will be called with `data` and empty `operatorData`. See {IERC777Sender}.
50 //
51 // Emits a {Burned} event.
52 //
53 // Requirements
54 //
55 // - the caller must have at least `amount` tokens.
56 Burn(amount int64, data []byte)
57
58 // Returns true if an account is an operator of `tokenHolder`.
59 // Operators can send and burn tokens on behalf of their owners. All
60 // accounts are their own operator.
61 //
62 // See {operatorSend} and {operatorBurn}.
63 IsOperatorFor(operator, tokenHolder address) bool
64
65 // Make an account an operator of the caller.
66 //
67 // See {isOperatorFor}.
68 //
69 // Emits an {AuthorizedOperator} event.
70 //
71 // Requirements
72 //
73 // - `operator` cannot be calling address.
74 AuthorizeOperator(operator address)
75
76 // Revoke an account's operator status for the caller.
77 //
78 // See {isOperatorFor} and {defaultOperators}.
79 //
80 // Emits a {RevokedOperator} event.
81 //
82 // Requirements
83 //
84 // - `operator` cannot be calling address.
85 RevokeOperator(operators address)
86
87 // Returns the list of default operators. These accounts are operators
88 // for all token holders, even if {authorizeOperator} was never called on
89 // them.
90 //
91 // This list is immutable, but individual holders may revoke these via
92 // {revokeOperator}, in which case {isOperatorFor} will return false.
93 DefaultOperators() []address
94
95 // Moves `amount` tokens from `sender` to `recipient`. The caller must
96 // be an operator of `sender`.
97 //
98 // If send or receive hooks are registered for `sender` and `recipient`,
99 // the corresponding functions will be called with `data` and
100 // `operatorData`. See {IERC777Sender} and {IERC777Recipient}.
101 //
102 // Emits a {Sent} event.
103 //
104 // Requirements
105 //
106 // - `sender` cannot be the zero address.
107 // - `sender` must have at least `amount` tokens.
108 // - the caller must be an operator for `sender`.
109 // - `recipient` cannot be the zero address.
110 // - if `recipient` is a contract, it must implement the {IERC777Recipient}
111 // interface.
112 OperatorSend(sender, recipient address, amount int64, data, operatorData []byte)
113
114 // Destroys `amount` tokens from `account`, reducing the total supply.
115 // The caller must be an operator of `account`.
116 //
117 // If a send hook is registered for `account`, the corresponding function
118 // will be called with `data` and `operatorData`. See {IERC777Sender}.
119 //
120 // Emits a {Burned} event.
121 //
122 // Requirements
123 //
124 // - `account` cannot be the zero address.
125 // - `account` must have at least `amount` tokens.
126 // - the caller must be an operator for `account`.
127 OperatorBurn(account address, amount int64, data, operatorData []byte)
128}
129
130// Emitted when `amount` tokens are created by `operator` and assigned to `to`.
131//
132// Note that some additional user `data` and `operatorData` can be logged in the event.
133type MintedEvent struct {
134 Operator address
135 To address
136 Amount int64
137 Data []byte
138 OperatorData []byte
139}
140
141// Emitted when `operator` destroys `amount` tokens from `account`.
142//
143// Note that some additional user `data` and `operatorData` can be logged in the event.
144type BurnedEvent struct {
145 Operator address
146 From address
147 Amount int64
148 Data []byte
149 OperatorData []byte
150}
151
152// Emitted when `operator` is made operator for `tokenHolder`
153type AuthorizedOperatorEvent struct {
154 Operator address
155 TokenHolder address
156}
157
158// Emitted when `operator` is revoked its operator status for `tokenHolder`.
159type RevokedOperatorEvent struct {
160 Operator address
161 TokenHolder address
162}
163
164type SentEvent struct {
165 Operator address
166 From address
167 To address
168 Amount int64
169 Data []byte
170 OperatorData []byte
171}