-
Notifications
You must be signed in to change notification settings - Fork 12
/
single_asset.impl.mligo
85 lines (68 loc) · 2.31 KB
/
single_asset.impl.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
[@public] #import "../common/assertions.jsligo" "Assertions"
[@public] #import "../common/errors.mligo" "Errors"
[@public] #import "../common/tzip12.datatypes.jsligo" "TZIP12"
[@public] #import "../common/tzip12.interfaces.jsligo" "TZIP12Interface"
[@public] #import "../common/tzip16.datatypes.jsligo" "TZIP16"
#import "./extendable_single_asset.impl.mligo" "SingleAssetExtendable"
type ledger = SingleAssetExtendable.ledger
type operator = SingleAssetExtendable.operator
type operators = SingleAssetExtendable.operators
type storage = unit SingleAssetExtendable.storage
type storage =
{
ledger : ledger;
operators : operators;
token_metadata : TZIP12.tokenMetadata;
metadata : TZIP16.metadata
}
type ret = operation list * storage
let empty_storage : storage =
{
ledger = Big_map.empty;
operators = Big_map.empty;
token_metadata = Big_map.empty;
metadata = Big_map.empty
}
[@inline]
let lift (s : storage) : unit SingleAssetExtendable.storage =
{
extension = ();
ledger = s.ledger;
operators = s.operators;
token_metadata = s.token_metadata;
metadata = s.metadata
}
[@inline]
let unlift (ret : operation list * unit SingleAssetExtendable.storage) : ret =
let ops, s = ret in
ops,
{
ledger = s.ledger;
operators = s.operators;
token_metadata = s.token_metadata;
metadata = s.metadata
}
[@entry]
let transfer (t : TZIP12.transfer) (s : storage) : ret =
unlift (SingleAssetExtendable.transfer t (lift s))
[@entry]
let balance_of (b : TZIP12.balance_of) (s : storage) : ret =
unlift (SingleAssetExtendable.balance_of b (lift s))
[@entry]
let update_operators (updates : TZIP12.update_operators) (s : storage) : ret =
unlift (SingleAssetExtendable.update_operators updates (lift s))
[@view]
let get_balance (p : (address * nat)) (s : storage) : nat =
SingleAssetExtendable.get_balance p (lift s)
[@view]
let total_supply (token_id : nat) (s : storage) : nat =
SingleAssetExtendable.total_supply token_id (lift s)
[@view]
let all_tokens (_ : unit) (s : storage) : nat set =
SingleAssetExtendable.all_tokens () (lift s)
[@view]
let is_operator (op : TZIP12.operator) (s : storage) : bool =
SingleAssetExtendable.is_operator op (lift s)
[@view]
let token_metadata (p : nat) (s : storage) : TZIP12.tokenMetadataData =
SingleAssetExtendable.token_metadata p (lift s)