forked from ligolang/contract-catalogue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_asset.impl.mligo
83 lines (67 loc) · 2.19 KB
/
multi_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
#import "../common/assertions.jsligo" "Assertions"
#import "../common/errors.mligo" "Errors"
#import "../common/tzip12.datatypes.jsligo" "TZIP12"
#import "../common/tzip12.interfaces.jsligo" "TZIP12Interface"
#import "../common/tzip16.datatypes.jsligo" "TZIP16"
#import "./extendable_multi_asset.impl.mligo" "MultiAssetExtendable"
type ledger = MultiAssetExtendable.ledger
type operator = MultiAssetExtendable.operator
type operators = MultiAssetExtendable.operators
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 MultiAssetExtendable.storage =
{
extension = ();
ledger = s.ledger;
operators = s.operators;
token_metadata = s.token_metadata;
metadata = s.metadata
}
[@inline]
let unlift (ret : operation list * unit MultiAssetExtendable.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 (MultiAssetExtendable.transfer t (lift s))
[@entry]
let balance_of (b : TZIP12.balance_of) (s : storage) : ret =
unlift (MultiAssetExtendable.balance_of b (lift s))
[@entry]
let update_operators (updates : TZIP12.update_operators) (s : storage) : ret =
unlift (MultiAssetExtendable.update_operators updates (lift s))
[@view]
let get_balance (p : (address * nat)) (s : storage) : nat =
MultiAssetExtendable.get_balance p (lift s)
[@view]
let total_supply (token_id : nat) (s : storage) : nat =
MultiAssetExtendable.total_supply token_id (lift s)
[@view]
let all_tokens (_ : unit) (s : storage) : nat set =
MultiAssetExtendable.all_tokens () (lift s)
[@view]
let is_operator (op : TZIP12.operator) (s : storage) : bool =
MultiAssetExtendable.is_operator op (lift s)
[@view]
let token_metadata (p : nat) (s : storage) : TZIP12.tokenMetadataData =
MultiAssetExtendable.token_metadata p (lift s)