44 | | - | func deposit () = if ((genesisHeight > height)) |
---|
45 | | - | then throw("ERROR: Deposits frozen") |
---|
46 | | - | else if ((this == i.caller)) |
---|
47 | | - | then throw("ERROR: Self-invoke is forbidden") |
---|
48 | | - | else if ((size(i.payments) != 1)) |
---|
49 | | - | then throw("ERROR: Attached Payment != 1") |
---|
50 | | - | else if (if ((1 > i.payments[0].amount)) |
---|
51 | | - | then true |
---|
52 | | - | else (i.payments[0].amount > maxInt)) |
---|
53 | | - | then throw("ERROR: Payment amount") |
---|
54 | | - | else { |
---|
55 | | - | let contractAssetId = match i.payments[0].assetId { |
---|
56 | | - | case isByteVector: ByteVector => |
---|
57 | | - | match assetInfo(isByteVector) { |
---|
58 | | - | case isAsset: Asset => |
---|
59 | | - | toBase58String(isAsset.id) |
---|
60 | | - | case _ => |
---|
61 | | - | throw("ERROR: Asset not found") |
---|
62 | | - | } |
---|
63 | | - | case isWaves: Unit => |
---|
64 | | - | wavesId |
---|
65 | | - | case _ => |
---|
66 | | - | throw("ERROR: Unknown Asset type") |
---|
67 | | - | } |
---|
68 | | - | let nonce = generateNonce() |
---|
69 | | - | let contractList = [contractText, toString(height), toString(i.caller), contractAssetId, toString(i.payments[0].amount)] |
---|
70 | | - | if (({ |
---|
71 | | - | let $list24072462 = contractList |
---|
72 | | - | let $size24072462 = size($list24072462) |
---|
73 | | - | let $acc024072462 = false |
---|
74 | | - | if (($size24072462 == 0)) |
---|
75 | | - | then $acc024072462 |
---|
76 | | - | else { |
---|
77 | | - | let $acc124072462 = findSeparatorInListString($acc024072462, $list24072462[0]) |
---|
78 | | - | if (($size24072462 == 1)) |
---|
79 | | - | then $acc124072462 |
---|
80 | | - | else { |
---|
81 | | - | let $acc224072462 = findSeparatorInListString($acc124072462, $list24072462[1]) |
---|
82 | | - | if (($size24072462 == 2)) |
---|
83 | | - | then $acc224072462 |
---|
84 | | - | else { |
---|
85 | | - | let $acc324072462 = findSeparatorInListString($acc224072462, $list24072462[2]) |
---|
86 | | - | if (($size24072462 == 3)) |
---|
87 | | - | then $acc324072462 |
---|
88 | | - | else { |
---|
89 | | - | let $acc424072462 = findSeparatorInListString($acc324072462, $list24072462[3]) |
---|
90 | | - | if (($size24072462 == 4)) |
---|
91 | | - | then $acc424072462 |
---|
92 | | - | else { |
---|
93 | | - | let $acc524072462 = findSeparatorInListString($acc424072462, $list24072462[4]) |
---|
94 | | - | if (($size24072462 == 5)) |
---|
95 | | - | then $acc524072462 |
---|
96 | | - | else { |
---|
97 | | - | let $acc624072462 = findSeparatorInListString($acc524072462, $list24072462[5]) |
---|
98 | | - | throw("List size exceed 5") |
---|
99 | | - | } |
---|
100 | | - | } |
---|
101 | | - | } |
---|
102 | | - | } |
---|
103 | | - | } |
---|
104 | | - | } |
---|
105 | | - | } == true)) |
---|
106 | | - | then throw("ERROR: Found separator in string") |
---|
107 | | - | else { |
---|
108 | | - | let contractDescription = makeString(contractList, separator) |
---|
109 | | - | if ((size(toBytes(contractDescription)) > maxDescriptionBytes)) |
---|
110 | | - | then throw("ERROR: Too long contract") |
---|
111 | | - | else { |
---|
112 | | - | let contractIssue = Issue(contractName, contractDescription, 1, 0, false, unit, nonce) |
---|
113 | | - | let contractId = calculateAssetId(contractIssue) |
---|
114 | | - | [IntegerEntry(keyNonceCount, nonce), contractIssue, ScriptTransfer(i.caller, contractIssue.quantity, contractId)] |
---|
115 | | - | } |
---|
116 | | - | } |
---|
117 | | - | } |
---|
118 | | - | |
---|
119 | | - | |
---|
120 | | - | |
---|
121 | | - | @Callable(i) |
---|
122 | | - | func withdraw () = if ((this == i.caller)) |
---|
123 | | - | then throw("ERROR: Self-invoke is forbidden") |
---|
124 | | - | else if ((size(i.payments) != 1)) |
---|
125 | | - | then throw("ERROR: Attached Payment != 1") |
---|
126 | | - | else if ((i.payments[0].amount != 1)) |
---|
127 | | - | then throw("ERROR: Payment amount != 1") |
---|
128 | | - | else { |
---|
129 | | - | let contractIdByteVector = match i.payments[0].assetId { |
---|
130 | | - | case isByteVector: ByteVector => |
---|
131 | | - | isByteVector |
---|
132 | | - | case _ => |
---|
133 | | - | throw("ERROR: Contract type") |
---|
134 | | - | } |
---|
135 | | - | let contractInfo = match assetInfo(contractIdByteVector) { |
---|
136 | | - | case isAsset: Asset => |
---|
137 | | - | isAsset |
---|
138 | | - | case _ => |
---|
139 | | - | throw("ERROR: Unknown Contract") |
---|
140 | | - | } |
---|
141 | | - | let contractList = split(contractInfo.description, separator) |
---|
142 | | - | if ((contractInfo.issuer != this)) |
---|
143 | | - | then throw("ERROR: Contract Issuer") |
---|
144 | | - | else if ((size(contractList) != contractListSize)) |
---|
145 | | - | then throw("ERROR: Contract list") |
---|
146 | | - | else if ((contractInfo.name != contractName)) |
---|
147 | | - | then throw("ERROR: Contract name") |
---|
148 | | - | else if (if (if (if ((contractInfo.decimals != 0)) |
---|
149 | | - | then true |
---|
150 | | - | else (contractInfo.quantity != 1)) |
---|
151 | | - | then true |
---|
152 | | - | else (contractInfo.reissuable != false)) |
---|
153 | | - | then true |
---|
154 | | - | else (contractInfo.scripted != false)) |
---|
155 | | - | then throw("ERROR: Contract not NFT") |
---|
156 | | - | else { |
---|
157 | | - | let contractHeight = parseIntValue(contractList[1]) |
---|
158 | | - | let contractCaller = contractList[2] |
---|
159 | | - | let contractAssetId = contractList[3] |
---|
160 | | - | let contractAssetQuantity = parseIntValue(contractList[4]) |
---|
161 | | - | let contractCallerAddress = match addressFromString(contractCaller) { |
---|
162 | | - | case isAddress: Address => |
---|
163 | | - | isAddress |
---|
164 | | - | case _ => |
---|
165 | | - | throw("ERROR: Caller Address") |
---|
166 | | - | } |
---|
167 | | - | let contractAssetInfo = match assetInfo(fromBase58String(contractAssetId)) { |
---|
168 | | - | case isAsset: Asset => |
---|
169 | | - | isAsset |
---|
170 | | - | case _ => |
---|
171 | | - | throw("ERROR: Unknown Asset") |
---|
172 | | - | } |
---|
173 | | - | if (if ((genesisHeight >= contractHeight)) |
---|
174 | | - | then true |
---|
175 | | - | else (contractHeight >= height)) |
---|
176 | | - | then throw("ERROR: Height") |
---|
177 | | - | else if (if (if ((1 > contractAssetQuantity)) |
---|
178 | | - | then true |
---|
179 | | - | else (contractAssetQuantity > contractAssetInfo.quantity)) |
---|
180 | | - | then true |
---|
181 | | - | else (contractAssetQuantity > maxInt)) |
---|
182 | | - | then throw("ERROR: Asset quantity") |
---|
183 | | - | else if ((contractAssetQuantity > assetBalance(this, contractAssetInfo.id))) |
---|
184 | | - | then throw("ERROR: Vault balance") |
---|
185 | | - | else { |
---|
186 | | - | let nonce = generateNonce() |
---|
187 | | - | let receiptList = [receiptText, toString(contractHeight), toString(height), toBase58String(contractIdByteVector), contractCaller, toString(i.caller), contractAssetId, toString(contractAssetQuantity)] |
---|
188 | | - | if (({ |
---|
189 | | - | let $list61286182 = receiptList |
---|
190 | | - | let $size61286182 = size($list61286182) |
---|
191 | | - | let $acc061286182 = false |
---|
192 | | - | if (($size61286182 == 0)) |
---|
193 | | - | then $acc061286182 |
---|
194 | | - | else { |
---|
195 | | - | let $acc161286182 = findSeparatorInListString($acc061286182, $list61286182[0]) |
---|
196 | | - | if (($size61286182 == 1)) |
---|
197 | | - | then $acc161286182 |
---|
198 | | - | else { |
---|
199 | | - | let $acc261286182 = findSeparatorInListString($acc161286182, $list61286182[1]) |
---|
200 | | - | if (($size61286182 == 2)) |
---|
201 | | - | then $acc261286182 |
---|
202 | | - | else { |
---|
203 | | - | let $acc361286182 = findSeparatorInListString($acc261286182, $list61286182[2]) |
---|
204 | | - | if (($size61286182 == 3)) |
---|
205 | | - | then $acc361286182 |
---|
206 | | - | else { |
---|
207 | | - | let $acc461286182 = findSeparatorInListString($acc361286182, $list61286182[3]) |
---|
208 | | - | if (($size61286182 == 4)) |
---|
209 | | - | then $acc461286182 |
---|
210 | | - | else { |
---|
211 | | - | let $acc561286182 = findSeparatorInListString($acc461286182, $list61286182[4]) |
---|
212 | | - | if (($size61286182 == 5)) |
---|
213 | | - | then $acc561286182 |
---|
214 | | - | else { |
---|
215 | | - | let $acc661286182 = findSeparatorInListString($acc561286182, $list61286182[5]) |
---|
216 | | - | if (($size61286182 == 6)) |
---|
217 | | - | then $acc661286182 |
---|
218 | | - | else { |
---|
219 | | - | let $acc761286182 = findSeparatorInListString($acc661286182, $list61286182[6]) |
---|
220 | | - | if (($size61286182 == 7)) |
---|
221 | | - | then $acc761286182 |
---|
222 | | - | else { |
---|
223 | | - | let $acc861286182 = findSeparatorInListString($acc761286182, $list61286182[7]) |
---|
224 | | - | if (($size61286182 == 8)) |
---|
225 | | - | then $acc861286182 |
---|
226 | | - | else { |
---|
227 | | - | let $acc961286182 = findSeparatorInListString($acc861286182, $list61286182[8]) |
---|
228 | | - | throw("List size exceed 8") |
---|
229 | | - | } |
---|
230 | | - | } |
---|
231 | | - | } |
---|
232 | | - | } |
---|
233 | | - | } |
---|
234 | | - | } |
---|
235 | | - | } |
---|
236 | | - | } |
---|
237 | | - | } |
---|
238 | | - | } == true)) |
---|
239 | | - | then throw("ERROR: Found separator in string") |
---|
240 | | - | else { |
---|
241 | | - | let receiptDescription = makeString(receiptList, separator) |
---|
242 | | - | let receiptIssue = Issue(receiptName, receiptDescription, 1, 0, false, unit, nonce) |
---|
243 | | - | let receiptId = calculateAssetId(receiptIssue) |
---|
244 | | - | [IntegerEntry(keyNonceCount, nonce), Burn(contractIdByteVector, 1), receiptIssue, ScriptTransfer(i.caller, receiptIssue.quantity, receiptId), ScriptTransfer(i.caller, contractAssetQuantity, contractAssetInfo.id)] |
---|
245 | | - | } |
---|
246 | | - | } |
---|
247 | | - | } |
---|
248 | | - | } |
---|
| 7 | + | func call () = { |
---|
| 8 | + | let asset = Issue("Asset", "", 1, 0, true, unit, 0) |
---|
| 9 | + | let assetId = calculateAssetId(asset) |
---|
| 10 | + | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)] |
---|
| 11 | + | } |
---|