This repository has been archived by the owner on Apr 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
collteralstable.rs
217 lines (217 loc) · 9.48 KB
/
collteralstable.rs
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
Schema {
rgb_features: none!(),
root_id: none!(),
genesis: GenesisSchema {
metadata: type_map! {
FieldType::Ticker => CBT,
FieldType::Name => Collateral,
FieldType::ContractText => NoneOrOnce,
FieldType::Precision => Once,
FieldType::Timestamp => 2,
FieldType::IssuedSupply => 2000000
},
owned_rights: type_map! {
OwnedRightsType::Inflation => NoneOrMore,
OwnedRightsType::Epoch => NoneOrOnce,
OwnedRightsType::Assets => NoneOrMore,
OwnedRightsType::Renomination => Once
},
public_rights: none!(),
abi: none!(),
},
extensions: none!(),
transitions: type_map! {
TransitionType::Issue => TransitionSchema {
metadata: type_map! {
FieldType::IssuedSupply => Once
},
closes: type_map! {
OwnedRightsType::Inflation => Once
},
owned_rights: type_map! {
OwnedRightsType::Inflation => NoneOrMore,
OwnedRightsType::Epoch => NoneOrOnce,
OwnedRightsType::Assets => NoneOrMore
},
public_rights: none!(),
abi: bmap! {
// sum(in(inflation)) >= sum(out(inflation), out(assets))
TransitionAction::Validate => Procedure::Embedded(StandardProcedure::FungibleInflation)
}
},
TransitionType::Transfer => TransitionSchema {
metadata: type_map! {},
closes: type_map! {
OwnedRightsType::Assets => NoneOrMore
},
owned_rights: type_map! {
OwnedRightsType::Assets => NoneOrMore
},
public_rights: none!(),
abi: none!()
},
TransitionType::Epoch => TransitionSchema {
metadata: none!(),
closes: type_map! {
OwnedRightsType::Epoch => Once
},
owned_rights: type_map! {
OwnedRightsType::Epoch => NoneOrOnce,
OwnedRightsType::BurnReplace => NoneOrOnce
},
public_rights: none!(),
abi: none!()
},
TransitionType::Burn => TransitionSchema {
metadata: type_map! {
FieldType::BurnedSupply => Once,
// Normally issuer should aggregate burned assets into a
// single UTXO; however if burn happens as a result of
// mistake this will be impossible, so we allow to have
// multiple burned UTXOs as a part of a single operation
FieldType::BurnUtxo => OnceTo(None),
FieldType::HistoryProofFormat => Once,
FieldType::HistoryProof => NoneOrMore,
},
closes: type_map! {
OwnedRightsType::BurnReplace => Once
},
owned_rights: type_map! {
OwnedRightsType::BurnReplace => NoneOrOnce
},
public_rights: none!(),
abi: bmap! {
TransitionAction::Validate => Procedure::Embedded(StandardProcedure::ProofOfBurn)
}
},
TransitionType::BurnAndReplace => TransitionSchema {
metadata: type_map! {
FieldType::BurnedSupply => Once,
// Normally issuer should aggregate burned assets into a
// single UTXO; however if burn happens as a result of
// mistake this will be impossible, so we allow to have
// multiple burned UTXOs as a part of a single operation
FieldType::BurnUtxo => OnceOrMore,
FieldType::HistoryProofFormat => Once,
FieldType::HistoryProof => NoneOrMore,
FieldType::HistoryProof=>OneOrTwo
},
closes: type_map! {
OwnedRightsType::BurnReplace => Once
},
owned_rights: type_map! {
OwnedRightsType::BurnReplace => NoneOrOnce,
OwnedRightsType::Assets => OnceOrMore
},
public_rights: none!(),
abi: bmap! {
TransitionAction::Validate => Procedure::Embedded(StandardProcedure::ProofOfBurn)
}
},
TransitionType::Renomination => TransitionSchema {
metadata: type_map! {
FieldType::Ticker => NoneOrOnce,
FieldType::Name => NoneOrOnce,
FieldType::ContractText => NoneOrOnce,
FieldType::Precision => NoneOrOnce
},
closes: type_map! {
OwnedRightsType::Renomination => Once
},
owned_rights: type_map! {
OwnedRightsType::Renomination => NoneOrOnce
},
public_rights: none!(),
abi: none!()
},
// Allows split of rights if they were occasionally allocated to the
// same UTXO, for instance both assets and issuance right. Without
// this type of transition either assets or inflation rights will be
// lost.
TransitionType::RightsSplit => TransitionSchema {
metadata: none!(),
closes: type_map! {
OwnedRightsType::Inflation => NoneOrMore,
OwnedRightsType::Assets => NoneOrMore,
OwnedRightsType::Epoch => NoneOrOnce,
OwnedRightsType::BurnReplace => NoneOrOnce,
OwnedRightsType::Renomination => NoneOrOnce
},
owned_rights: type_map! {
OwnedRightsType::Inflation => NoneOrMore,
OwnedRightsType::Assets => NoneOrMore,
OwnedRightsType::Epoch => NoneOrOnce,
OwnedRightsType::BurnReplace => NoneOrOnce,
OwnedRightsType::Renomination => NoneOrOnce
},
public_rights: none!(),
abi: bmap! {
// We must allocate exactly one or none rights per each
// right used as input (i.e. closed seal); plus we need to
// control that sum of inputs is equal to the sum of outputs
// for each of state types having assigned confidential
// amounts
TransitionAction::Validate => Procedure::Embedded(StandardProcedure::RightsSplit)
}
}
},
field_types: type_map! {
// Rational: if we will use just 26 letters of English alphabet (and
// we are not limited by them), we will have 26^8 possible tickers,
// i.e. > 208 trillions, which is sufficient amount
FieldType::Ticker => DataFormat::String(8),
FieldType::Name => DataFormat::String(256),
// Contract text may contain URL, text or text representation of
// Ricardian contract, up to 64kb. If the contract doesn't fit, a
// double SHA256 hash and URL should be used instead, pointing to
// the full contract text, where hash must be represented by a
// hexadecimal string, optionally followed by `\n` and text URL
FieldType::ContractText => DataFormat::String(core::u16::MAX),
FieldType::Precision => DataFormat::Unsigned(Bits::Bit8, 0, 18u128),
// We need this b/c allocated amounts are hidden behind Pedersen
// commitments
FieldType::IssuedSupply => DataFormat::Unsigned(Bits::Bit64, 0, core::u64::MAX as u128),
// Supply in either burn or burn-and-replace procedure
FieldType::BurnedSupply => DataFormat::Unsigned(Bits::Bit64, 0, core::u64::MAX as u128),
// While UNIX timestamps allow negative numbers; in context of RGB
// Schema, assets can't be issued in the past before RGB or Bitcoin
// even existed; so we prohibit all the dates before RGB release
// This timestamp is equal to 10/10/2020 @ 2:37pm (UTC)
FieldType::Timestamp => DataFormat::Integer(Bits::Bit64, 1602340666, core::i64::MAX as i128),
FieldType::HistoryProof => DataFormat::Bytes(core::u16::MAX),
FieldType::HistoryProofFormat => DataFormat::Enum(HistoryProofFormat::all()),
FieldType::BurnUtxo => DataFormat::TxOutPoint
},
owned_right_types: type_map! {
OwnedRightsType::Inflation => StateSchema {
// How much issuer can issue tokens on this path. If there is no
// limit, than `core::u64::MAX` / sum(inflation_assignments)
// must be used, as this will be a de-facto limit to the
// issuance
format: StateFormat::CustomData(DataFormat::Unsigned(Bits::Bit64, 0, core::u64::MAX as u128)),
// Validation involves other state data, so it is performed
// at the level of `issue` state transition
abi: none!()
},
OwnedRightsType::Assets => StateSchema {
format: StateFormat::DiscreteFiniteField(DiscreteFiniteFieldFormat::Unsigned64bit),
abi: bmap! {
// sum(inputs) == sum(outputs)
AssignmentAction::Validate => Procedure::Embedded(StandardProcedure::NoInflationBySum)
}
},
OwnedRightsType::Epoch => StateSchema {
format: StateFormat::Declarative,
abi: none!()
},
OwnedRightsType::BurnReplace => StateSchema {
format: StateFormat::Declarative,
abi: none!()
},
OwnedRightsType::Renomination => StateSchema {
format: StateFormat::Declarative,
abi: none!()
}
},
public_right_types: none!(),
}