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