-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathfa2_interface.mligo
127 lines (106 loc) · 2.19 KB
/
fa2_interface.mligo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#if ! FA2_INTERFACE
#define FA2_INTERFACE
type token_id = nat
type transfer_destination =
[@layout:comb]
{
to_ : address;
token_id : token_id;
amount : nat;
}
type transfer =
[@layout:comb]
{
from_ : address;
txs : transfer_destination list;
}
type balance_of_request =
[@layout:comb]
{
owner : address;
token_id : token_id;
}
type balance_of_response =
[@layout:comb]
{
request : balance_of_request;
balance : nat;
}
type balance_of_param =
[@layout:comb]
{
requests : balance_of_request list;
callback : (balance_of_response list) contract;
}
type operator_param =
[@layout:comb]
{
owner : address;
operator : address;
token_id: token_id;
}
type update_operator =
[@layout:comb]
| Add_operator of operator_param
| Remove_operator of operator_param
type token_metadata =
[@layout:comb]
{
token_id : token_id;
token_info : (string, bytes) map;
}
(*
One of the options to make token metadata discoverable is to declare
`token_metadata : token_metadata_storage` field inside the FA2 contract storage
*)
type token_metadata_storage = (token_id, token_metadata) big_map
(**
Optional type to define view entry point to expose token_metadata on chain or
as an external view
*)
type token_metadata_param =
[@layout:comb]
{
token_ids : token_id list;
handler : (token_metadata list) -> unit;
}
type fa2_entry_points =
| Transfer of transfer list
| Balance_of of balance_of_param
| Update_operators of update_operator list
(*
TZIP-16 contract metadata storage field type.
The contract storage MUST have a field
`metadata : contract_metadata`
*)
type contract_metadata = (string, bytes) big_map
(* FA2 hooks interface *)
type transfer_destination_descriptor =
[@layout:comb]
{
to_ : address option;
token_id : token_id;
amount : nat;
}
type transfer_descriptor =
[@layout:comb]
{
from_ : address option;
txs : transfer_destination_descriptor list
}
type transfer_descriptor_param =
[@layout:comb]
{
batch : transfer_descriptor list;
operator : address;
}
(*
Entrypoints for sender/receiver hooks
type fa2_token_receiver =
...
| Tokens_received of transfer_descriptor_param
type fa2_token_sender =
...
| Tokens_sent of transfer_descriptor_param
*)
#endif