igrc777.gno

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