forked from cardano-foundation/CIPs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_2.cddl
103 lines (84 loc) · 3.05 KB
/
version_2.cddl
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
metadata = { "86" => action }
; =========================================================================
; CIP-86 actions
; When version 2 mode is enabled for a CIP-86 action, all `policy_id` and
; `asset_name` values are interpreted as `bytes_64`, similar to CIP-25v2.
action =
{
version = 2,
? assign_metadata_oracle : action_oracle,
? simple_metadata_update : action_simple,
? tabular_metadata_update : action_tabular
}
; Regex updates are disallowed in version 2, because it is unclear
; how to apply regular expressions to non-UTF-8 bytestrings (or their
; corresponding hex encodings).
action_oracle = { * policy_id => oracle_assignment }
oracle_assignment =
{
? main_address : address,
? update_address : address
}
action_simple = { * policy_id => { * asset_name => metadata_details } }
action_tabular = { * policy_id => tabular_metadata }
; Technically, both policy IDs and asset names should be 32 bytes long.
; However, this isn't enforced for asset names, and CIP-25v2 already treats
; these as `bytes_64`, so we don't enforce the more narrow `bytes_32` type
; here.
policy_id = bytes_64
asset_name = bytes_64
; =========================================================================
; Backwards compatibility with CIP-25 (simple and regex metadata updates)
; Definitions for the following fields in `metadata_details` should follow
; the same schema as in CIP-25, except that `name` and `image` are optional.
; Other fields can have arbitrary `transaction_metadatum` values.
metadata_details =
{
? name : text_64,
? image : text_extendable,
? mediaType : text_64,
? description : text_extendable,
? files : [* files_details],
* ( label_64 => transaction_metadatum )
}
files_details =
{
name : text_64,
mediaType : text_64,
src : text_extendable
}
; =========================================================================
; Tabular format
; The length of `token_names` must be equal to the length of the outer
; array of `values`, and the length of `field_paths` must be equal to
; the length of each inner array of `values`.
tabular_metadata =
{
field_paths: [ * field_path],
token_names: [ * asset_name],
values: [ * [ * transaction_metadatum ] ]
}
; Each field path is a dot-separated list of field names (text_64 values).
; E.g. "images.background.sunset.url"
field_path = text_64
; =========================================================================
; Imported from cardano-ledger/.../babbage.cddl
transaction_metadatum =
{ * transaction_metadatum => transaction_metadatum }
/ [ * transaction_metadatum ]
/ int
/ bytes_64
/ text_64
address = bytes
; =========================================================================
; Convenient type aliases
; Fixed-size text and bytes
label_32 = bytes_32 / text_32
bytes_32 = bytes .size (0..32)
text_32 = text .size (0..32)
label_64 = bytes_64 / text_64
bytes_64 = bytes .size (0..64)
text_64 = text .size (0..64)
; Extendable text and bytes
text_extendable = text_64 / [ * text_64 ]
bytes_extendable = bytes_64 / [ * bytes 64 ]