tx · EZgPb8KCpRZtm4dGCcEtvqRJknDuJZxoDL8MhrRGtWvD 3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7: -0.01200000 Waves 2023.03.23 16:57 [2502738] smart account 3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7 > SELF 0.00000000 Waves
{ "type": 13, "id": "EZgPb8KCpRZtm4dGCcEtvqRJknDuJZxoDL8MhrRGtWvD", "fee": 1200000, "feeAssetId": null, "timestamp": 1679579842001, "version": 2, "chainId": 84, "sender": "3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7", "senderPublicKey": "CrHxACS7bWTh8cgmgqstvybmgMqR9KtDryGFt5svZhBW", "proofs": [ "53Qt7ZD9Eq5BovsrP7nv23U5LCfRFDBBSQAFceHmSMPubhgFYpeGTm27izZcp3zTHCvSThJzuu1AwnyDqdUCKzMR" ], "script": "base64:BgIkCAISBwoFGBgBAQgSBAoCGBgSBQoDCBgYEgQKAggIEgQKAggIGAAIa0pzb25SZXMCB2pzb25SZXMABXF1b3RlCQCwCQEBASIBCW1ha2VGaWVsZAEJbmV4dFZhbHVlCQCsAgIJAKwCAgkArAICCQCsAgIJAKwCAgkArAICCQCsAgIFBXF1b3RlCAUJbmV4dFZhbHVlAl8xBQVxdW90ZQIBOgUFcXVvdGUIBQluZXh0VmFsdWUCXzIFBXF1b3RlAgEsAQ9yZWR1Y2VyTWFrZUpTT04CBWFjY3VtCW5leHRWYWx1ZQkArAICBQVhY2N1bQkBCW1ha2VGaWVsZAEFCW5leHRWYWx1ZQEPaXRlcmF0ZU1ha2VKU09OAwZwYXJhbXMDcmVzBmxlbmd0aAMJAAACBQZsZW5ndGgAAAkAAgECDUVtcHR5ICBwYXJhbXMDCQAAAgUGbGVuZ3RoAAEKAAIkbAUGcGFyYW1zCgACJHMJAJADAQUCJGwKAAUkYWNjMAUDcmVzCgEFJGYwXzECAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAQ9yZWR1Y2VyTWFrZUp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QRqc29uBQNrZXkEEWRlbGV0ZWRWYWx1ZUJ5S2V5CAUNJHQwMTY1OTAxNjk0OQJfMQQHbmV3SnNvbggFDSR0MDE2NTkwMTY5NDkCXzIJAJQKAgkAzAgCCQELU3RyaW5nRW50cnkCAgxkZWxldGVkVmFsdWUFEWRlbGV0ZWRWYWx1ZUJ5S2V5CQDMCAIJAQtTdHJpbmdFbnRyeQIFCGtKc29uUmVzBQduZXdKc29uBQNuaWwJAJQKAgURZGVsZXRlZFZhbHVlQnlLZXkFB25ld0pzb24AvS1yXA==", "height": 2502738, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GVzumzxbxdikRJYB68uyHyN3siPN3dfYnKNS3iugUsdx Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let kJsonRes = "jsonRes" | |
5 | 5 | ||
6 | - | let | |
6 | + | let quote = toUtf8String(base58'b') | |
7 | 7 | ||
8 | - | let description = getStringValue("description") | |
9 | - | ||
10 | - | let totalAmount = getIntegerValue("totalAmount") | |
11 | - | ||
12 | - | let baseURI = getStringValue("baseURI") | |
13 | - | ||
14 | - | let dAppJson = Address(fromBase58String("3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7")) | |
15 | - | ||
16 | - | let tokenPayment = getBinaryValue("tokenPayment") | |
17 | - | ||
18 | - | let tokenPaymentAsset = valueOrErrorMessage(assetInfo(getBinaryValue("tokenPayment")), "token payment asset doesn't connect") | |
19 | - | ||
20 | - | let lendCount = getIntegerValue("lendCount") | |
21 | - | ||
22 | - | let lendCurrentCount = getIntegerValue("lendCurrentCount") | |
23 | - | ||
24 | - | let hundredList = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] | |
25 | - | ||
26 | - | func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id") | |
8 | + | func makeField (nextValue) = (((((((quote + nextValue._1) + quote) + ":") + quote) + nextValue._2) + quote) + ",") | |
27 | 9 | ||
28 | 10 | ||
29 | - | func transferOrNot (to,amount,assetId) = if ((to == this)) | |
30 | - | then StringEntry("smth", "smth") | |
31 | - | else ScriptTransfer(to, amount, assetId) | |
11 | + | func reducerMakeJSON (accum,nextValue) = (accum + makeField(nextValue)) | |
32 | 12 | ||
33 | 13 | ||
34 | - | func getLendJson (lendId) = { | |
35 | - | let lendIdString = toString(lendId) | |
36 | - | getStringValue(("lend-" + lendIdString)) | |
37 | - | } | |
14 | + | func iterateMakeJSON (params,res,length) = if ((length == 0)) | |
15 | + | then throw("Empty params") | |
16 | + | else if ((length == 1)) | |
17 | + | then { | |
18 | + | let $l = params | |
19 | + | let $s = size($l) | |
20 | + | let $acc0 = res | |
21 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
22 | + | then $a | |
23 | + | else reducerMakeJSON($a, $l[$i]) | |
24 | + | ||
25 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
26 | + | then $a | |
27 | + | else throw("List size exceeds 1") | |
28 | + | ||
29 | + | $f0_2($f0_1($acc0, 0), 1) | |
30 | + | } | |
31 | + | else if ((length == 2)) | |
32 | + | then { | |
33 | + | let $l = params | |
34 | + | let $s = size($l) | |
35 | + | let $acc0 = res | |
36 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
37 | + | then $a | |
38 | + | else reducerMakeJSON($a, $l[$i]) | |
39 | + | ||
40 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
41 | + | then $a | |
42 | + | else throw("List size exceeds 2") | |
43 | + | ||
44 | + | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
45 | + | } | |
46 | + | else if ((length == 3)) | |
47 | + | then { | |
48 | + | let $l = params | |
49 | + | let $s = size($l) | |
50 | + | let $acc0 = res | |
51 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
52 | + | then $a | |
53 | + | else reducerMakeJSON($a, $l[$i]) | |
54 | + | ||
55 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
56 | + | then $a | |
57 | + | else throw("List size exceeds 3") | |
58 | + | ||
59 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
60 | + | } | |
61 | + | else if ((length == 4)) | |
62 | + | then { | |
63 | + | let $l = params | |
64 | + | let $s = size($l) | |
65 | + | let $acc0 = res | |
66 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
67 | + | then $a | |
68 | + | else reducerMakeJSON($a, $l[$i]) | |
69 | + | ||
70 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
71 | + | then $a | |
72 | + | else throw("List size exceeds 4") | |
73 | + | ||
74 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
75 | + | } | |
76 | + | else if ((length == 5)) | |
77 | + | then { | |
78 | + | let $l = params | |
79 | + | let $s = size($l) | |
80 | + | let $acc0 = res | |
81 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
82 | + | then $a | |
83 | + | else reducerMakeJSON($a, $l[$i]) | |
84 | + | ||
85 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
86 | + | then $a | |
87 | + | else throw("List size exceeds 5") | |
88 | + | ||
89 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
90 | + | } | |
91 | + | else if ((length == 6)) | |
92 | + | then { | |
93 | + | let $l = params | |
94 | + | let $s = size($l) | |
95 | + | let $acc0 = res | |
96 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | + | then $a | |
98 | + | else reducerMakeJSON($a, $l[$i]) | |
99 | + | ||
100 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | + | then $a | |
102 | + | else throw("List size exceeds 6") | |
103 | + | ||
104 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
105 | + | } | |
106 | + | else if ((length == 7)) | |
107 | + | then { | |
108 | + | let $l = params | |
109 | + | let $s = size($l) | |
110 | + | let $acc0 = res | |
111 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
112 | + | then $a | |
113 | + | else reducerMakeJSON($a, $l[$i]) | |
114 | + | ||
115 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
116 | + | then $a | |
117 | + | else throw("List size exceeds 7") | |
118 | + | ||
119 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
120 | + | } | |
121 | + | else if ((length == 8)) | |
122 | + | then { | |
123 | + | let $l = params | |
124 | + | let $s = size($l) | |
125 | + | let $acc0 = res | |
126 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
127 | + | then $a | |
128 | + | else reducerMakeJSON($a, $l[$i]) | |
129 | + | ||
130 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
131 | + | then $a | |
132 | + | else throw("List size exceeds 8") | |
133 | + | ||
134 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8) | |
135 | + | } | |
136 | + | else if ((length == 9)) | |
137 | + | then { | |
138 | + | let $l = params | |
139 | + | let $s = size($l) | |
140 | + | let $acc0 = res | |
141 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
142 | + | then $a | |
143 | + | else reducerMakeJSON($a, $l[$i]) | |
144 | + | ||
145 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
146 | + | then $a | |
147 | + | else throw("List size exceeds 9") | |
148 | + | ||
149 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9) | |
150 | + | } | |
151 | + | else if ((length == 10)) | |
152 | + | then { | |
153 | + | let $l = params | |
154 | + | let $s = size($l) | |
155 | + | let $acc0 = res | |
156 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
157 | + | then $a | |
158 | + | else reducerMakeJSON($a, $l[$i]) | |
159 | + | ||
160 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
161 | + | then $a | |
162 | + | else throw("List size exceeds 10") | |
163 | + | ||
164 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
165 | + | } | |
166 | + | else throw("The max number of parameters exceeded") | |
38 | 167 | ||
39 | 168 | ||
40 | - | func getKey (lendJson,key) = { | |
41 | - | let timeUnitSeconds = { | |
42 | - | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, key], nil) | |
43 | - | if ($isInstanceOf(@, "String")) | |
44 | - | then @ | |
45 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
46 | - | } | |
47 | - | if ((timeUnitSeconds == timeUnitSeconds)) | |
48 | - | then timeUnitSeconds | |
49 | - | else throw("Strict value is not equal to itself.") | |
169 | + | func getPartAndTail (arr) = { | |
170 | + | let el0 = arr[0] | |
171 | + | let el1 = arr[1] | |
172 | + | let el2 = arr[2] | |
173 | + | let el3 = arr[3] | |
174 | + | let el4 = arr[4] | |
175 | + | let el5 = arr[5] | |
176 | + | let el6 = arr[6] | |
177 | + | let el7 = arr[7] | |
178 | + | let el8 = arr[8] | |
179 | + | let el9 = arr[9] | |
180 | + | let arr0 = removeByIndex(arr, 0) | |
181 | + | let arr1 = removeByIndex(arr0, 0) | |
182 | + | let arr2 = removeByIndex(arr1, 0) | |
183 | + | let arr3 = removeByIndex(arr2, 0) | |
184 | + | let arr4 = removeByIndex(arr3, 0) | |
185 | + | let arr5 = removeByIndex(arr4, 0) | |
186 | + | let arr6 = removeByIndex(arr5, 0) | |
187 | + | let arr7 = removeByIndex(arr6, 0) | |
188 | + | let arr8 = removeByIndex(arr7, 0) | |
189 | + | let arr9 = removeByIndex(arr8, 0) | |
190 | + | $Tuple2([el0, el1, el2, el3, el4, el5, el6, el7, el8, el9], arr9) | |
50 | 191 | } | |
51 | - | ||
52 | - | ||
53 | - | func getRentCount (lendId) = { | |
54 | - | let lendIdString = toString(lendId) | |
55 | - | getIntegerValue(("lend-rentCount-" + lendIdString)) | |
56 | - | } | |
57 | - | ||
58 | - | ||
59 | - | func calcLendCost (lendId,timeUnitSeconds) = { | |
60 | - | let lendJson = getLendJson(lendId) | |
61 | - | let timeUnitPriceString = getKey(lendJson, "timeUnitPrice") | |
62 | - | if ((timeUnitPriceString == timeUnitPriceString)) | |
63 | - | then { | |
64 | - | let timeUnitPrice = parseIntValue(timeUnitPriceString) | |
65 | - | (timeUnitSeconds * timeUnitPrice) | |
66 | - | } | |
67 | - | else throw("Strict value is not equal to itself.") | |
68 | - | } | |
69 | - | ||
70 | - | ||
71 | - | func getLendCost (lendId) = valueOrElse(getInteger(("lend-cost-" + toString(lendId))), 0) | |
72 | 192 | ||
73 | 193 | ||
74 | 194 | func onlyInternal (caller) = if ((caller == this)) | |
76 | 196 | else throw("Only internal call") | |
77 | 197 | ||
78 | 198 | ||
79 | - | func reducerGetDeleteEntry (accum,next) = { | |
80 | - | let $t025422592 = accum | |
81 | - | let deletions = $t025422592._1 | |
82 | - | let current = $t025422592._2 | |
83 | - | let maxCount = $t025422592._3 | |
84 | - | let lendId = $t025422592._4 | |
85 | - | if ((maxCount > current)) | |
86 | - | then $Tuple4((deletions :+ DeleteEntry(((("lend-rent-" + lendId) + "-") + toString(current)))), (current + 1), maxCount, lendId) | |
199 | + | func prepare_1 (arr,arr2) = [$Tuple2(arr[0], arr2[0])] | |
200 | + | ||
201 | + | ||
202 | + | func prepare_2 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1])] | |
203 | + | ||
204 | + | ||
205 | + | func prepare_3 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2])] | |
206 | + | ||
207 | + | ||
208 | + | func prepare_4 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3])] | |
209 | + | ||
210 | + | ||
211 | + | func prepare_5 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4])] | |
212 | + | ||
213 | + | ||
214 | + | func prepare_6 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5])] | |
215 | + | ||
216 | + | ||
217 | + | func prepare_7 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6])] | |
218 | + | ||
219 | + | ||
220 | + | func prepare_8 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6]), $Tuple2(arr[7], arr2[7])] | |
221 | + | ||
222 | + | ||
223 | + | func prepare_9 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6]), $Tuple2(arr[7], arr2[7]), $Tuple2(arr[8], arr2[8])] | |
224 | + | ||
225 | + | ||
226 | + | func prepare_10 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6]), $Tuple2(arr[7], arr2[7]), $Tuple2(arr[8], arr2[8]), $Tuple2(arr[9], arr2[9])] | |
227 | + | ||
228 | + | ||
229 | + | func prepareParams (currentArrPartKeys,currentArrPartValues,length) = if ((length == 0)) | |
230 | + | then throw("Empty params") | |
231 | + | else if ((length == 1)) | |
232 | + | then prepare_1(currentArrPartKeys, currentArrPartValues) | |
233 | + | else if ((length == 2)) | |
234 | + | then prepare_2(currentArrPartKeys, currentArrPartValues) | |
235 | + | else if ((length == 3)) | |
236 | + | then prepare_3(currentArrPartKeys, currentArrPartValues) | |
237 | + | else if ((length == 4)) | |
238 | + | then prepare_4(currentArrPartKeys, currentArrPartValues) | |
239 | + | else if ((length == 5)) | |
240 | + | then prepare_5(currentArrPartKeys, currentArrPartValues) | |
241 | + | else if ((length == 6)) | |
242 | + | then prepare_6(currentArrPartKeys, currentArrPartValues) | |
243 | + | else if ((length == 7)) | |
244 | + | then prepare_7(currentArrPartKeys, currentArrPartValues) | |
245 | + | else if ((length == 8)) | |
246 | + | then prepare_8(currentArrPartKeys, currentArrPartValues) | |
247 | + | else if ((length == 9)) | |
248 | + | then prepare_9(currentArrPartKeys, currentArrPartValues) | |
249 | + | else if ((length == 10)) | |
250 | + | then prepare_10(currentArrPartKeys, currentArrPartValues) | |
251 | + | else throw("Max number of parameters exceeded") | |
252 | + | ||
253 | + | ||
254 | + | func getStartAndEndIndexes (json,key) = { | |
255 | + | let keyLen = size(key) | |
256 | + | let startIndex = value(indexOf(json, key)) | |
257 | + | let endIndex = valueOrElse(indexOf(json, ",", startIndex), value(indexOf(json, "}", startIndex))) | |
258 | + | $Tuple3(keyLen, startIndex, endIndex) | |
259 | + | } | |
260 | + | ||
261 | + | ||
262 | + | func reducerFindObjcetByKey (accum,next) = { | |
263 | + | let $t064646786 = accum | |
264 | + | let key = $t064646786._1 | |
265 | + | let levelOn = $t064646786._2 | |
266 | + | let currentLevelOn = $t064646786._3 | |
267 | + | let startIndex = $t064646786._4 | |
268 | + | let endIndex = $t064646786._5 | |
269 | + | let currentIndex = $t064646786._6 | |
270 | + | let end = $t064646786._7 | |
271 | + | if (!(end)) | |
272 | + | then { | |
273 | + | let keyValueList = split(next, ":") | |
274 | + | let leftBraceCount = (size(split(next, "{")) - 1) | |
275 | + | let rightBraceCount = (size(split(next, "}")) - 1) | |
276 | + | let nextCurrentCount = (leftBraceCount - rightBraceCount) | |
277 | + | let $t070397239 = if (if ((levelOn == currentLevelOn)) | |
278 | + | then (keyValueList[0] == key) | |
279 | + | else false) | |
280 | + | then $Tuple2(currentIndex, true) | |
281 | + | else $Tuple2(0, false) | |
282 | + | let foundedStartIndex = $t070397239._1 | |
283 | + | let foundedStart = $t070397239._2 | |
284 | + | let $t072497445 = if (if ((levelOn == currentLevelOn)) | |
285 | + | then (keyValueList[0] == key) | |
286 | + | else false) | |
287 | + | then $Tuple2(currentIndex, true) | |
288 | + | else $Tuple2(0, false) | |
289 | + | let foundedEndIndex = $t072497445._1 | |
290 | + | let foundedEnd = $t072497445._2 | |
291 | + | $Tuple7(key, levelOn, (currentLevelOn + nextCurrentCount), if (foundedStart) | |
292 | + | then foundedStartIndex | |
293 | + | else startIndex, if (foundedEnd) | |
294 | + | then foundedEndIndex | |
295 | + | else endIndex, (currentIndex + 1), if (foundedEnd) | |
296 | + | then foundedEnd | |
297 | + | else end) | |
298 | + | } | |
87 | 299 | else accum | |
88 | 300 | } | |
89 | 301 | ||
90 | 302 | ||
91 | - | func | |
92 | - | ||
93 | - | ||
94 | - | ||
95 | - | ||
96 | - | ||
97 | - | ||
98 | - | ||
99 | - | ||
100 | - | ||
101 | - | | |
102 | - | | |
103 | - | | |
104 | - | | |
105 | - | let | |
106 | - | | |
107 | - | | |
108 | - | else | |
303 | + | func reducerConcatList (accum,next) = { | |
304 | + | let $t078917952 = accum | |
305 | + | let result = $t078917952._1 | |
306 | + | let currentIndex = $t078917952._2 | |
307 | + | let startIndex = $t078917952._3 | |
308 | + | let endIndex = $t078917952._4 | |
309 | + | let end = $t078917952._5 | |
310 | + | if (!(end)) | |
311 | + | then { | |
312 | + | let newResult = if (if ((currentIndex >= startIndex)) | |
313 | + | then (endIndex >= currentIndex) | |
314 | + | else false) | |
315 | + | then ((result + ",") + next) | |
316 | + | else result | |
317 | + | let newEnd = (currentIndex > endIndex) | |
318 | + | $Tuple5(newResult, (currentIndex + 1), startIndex, endIndex, newEnd) | |
319 | + | } | |
320 | + | else accum | |
109 | 321 | } | |
110 | 322 | ||
111 | 323 | ||
112 | - | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
113 | - | then unit | |
114 | - | else throw("Only asset owner") | |
324 | + | func reducerTakeObject (accum,next) = { | |
325 | + | let $t083908450 = accum | |
326 | + | let result = $t083908450._1 | |
327 | + | let leftCount = $t083908450._2 | |
328 | + | let rightCount = $t083908450._3 | |
329 | + | let i = $t083908450._4 | |
330 | + | let iCount = $t083908450._5 | |
331 | + | let end = $t083908450._6 | |
332 | + | if (if (!(end)) | |
333 | + | then true | |
334 | + | else (iCount > i)) | |
335 | + | then { | |
336 | + | let $t084889245 = if (contains(next, "{")) | |
337 | + | then { | |
338 | + | let _nextLeftCount = (size(split(next, "{")) - 1) | |
339 | + | $Tuple2(_nextLeftCount, 0) | |
340 | + | } | |
341 | + | else if (contains(next, "}")) | |
342 | + | then { | |
343 | + | let _nextRightCount = (size(split(next, "}")) - 1) | |
344 | + | $Tuple2(0, _nextRightCount) | |
345 | + | } | |
346 | + | else $Tuple2(0, 0) | |
347 | + | let nextLeftCount = $t084889245._1 | |
348 | + | let nextRightCount = $t084889245._2 | |
349 | + | let curentLeftCount = (leftCount + nextLeftCount) | |
350 | + | let currentRightCount = (rightCount + nextRightCount) | |
351 | + | if ((curentLeftCount == currentRightCount)) | |
352 | + | then $Tuple6(result, curentLeftCount, currentRightCount, (i + 1), iCount, true) | |
353 | + | else $Tuple6(((result + ",") + next), curentLeftCount, currentRightCount, (i + 1), iCount, false) | |
354 | + | } | |
355 | + | else accum | |
356 | + | } | |
115 | 357 | ||
116 | 358 | ||
117 | - | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
118 | - | then unit | |
119 | - | else throw("amount less then need") | |
359 | + | func readByKeyInternal (json,key) = { | |
360 | + | let $t097799895 = getStartAndEndIndexes(json, key) | |
361 | + | let keyLen = $t097799895._1 | |
362 | + | let startIndex = $t097799895._2 | |
363 | + | let endIndex = $t097799895._3 | |
364 | + | drop(take(json, (endIndex - 1)), ((startIndex + keyLen) + 3)) | |
365 | + | } | |
120 | 366 | ||
121 | 367 | ||
122 | - | func checkAssetExists (assetId) = if (valueOrElse(getBoolean(assetId), false)) | |
123 | - | then throw("this token already use") | |
124 | - | else unit | |
125 | - | ||
126 | - | ||
127 | - | func checkLendOwner (caller,lendId) = if ((getKey(getLendJson(lendId), "owner") != toString(caller))) | |
128 | - | then throw("you haven't perms") | |
129 | - | else unit | |
368 | + | func deleteByKeyInternal (json,key) = { | |
369 | + | let $t01017610244 = getStartAndEndIndexes(json, key) | |
370 | + | let keyLen = $t01017610244._1 | |
371 | + | let startIndex = $t01017610244._2 | |
372 | + | let endIndex = $t01017610244._3 | |
373 | + | let deletedValue = drop(take(json, (endIndex - 1)), ((startIndex + keyLen) + 3)) | |
374 | + | let newJson = if (((size(json) - endIndex) == 1)) | |
375 | + | then (take(json, (startIndex - 2)) + drop(json, endIndex)) | |
376 | + | else (take(json, (startIndex - 1)) + drop(json, (endIndex + 1))) | |
377 | + | $Tuple2(deletedValue, newJson) | |
378 | + | } | |
130 | 379 | ||
131 | 380 | ||
132 | 381 | @Callable(i) | |
133 | - | func setString (_key,_value) = valueOrElse(onlyInternal(i.caller), [StringEntry(_key, _value)]) | |
382 | + | func makeJSONInternal (arrKeys,arrValues,iterationsCount,lastIterationLen,res) = valueOrElse(onlyInternal(i.caller), if ((iterationsCount > 0)) | |
383 | + | then { | |
384 | + | let $t01188212047 = getPartAndTail(arrKeys) | |
385 | + | let currentArrPartKeys = $t01188212047._1 | |
386 | + | let arrTailKeys = $t01188212047._2 | |
387 | + | let $t01205612174 = getPartAndTail(arrValues) | |
388 | + | let currentArrPartValues = $t01205612174._1 | |
389 | + | let arrTailValues = $t01205612174._2 | |
390 | + | let params = prepareParams(currentArrPartKeys, currentArrPartValues, 10) | |
391 | + | let newString = iterateMakeJSON(params, res, 10) | |
392 | + | let result = invoke(this, "makeJSONInternal", [arrTailKeys, arrTailValues, (iterationsCount - 1), lastIterationLen, newString], nil) | |
393 | + | if ((result == result)) | |
394 | + | then $Tuple2(nil, result) | |
395 | + | else throw("Strict value is not equal to itself.") | |
396 | + | } | |
397 | + | else if ((lastIterationLen != 0)) | |
398 | + | then { | |
399 | + | let params = prepareParams(arrKeys, arrValues, lastIterationLen) | |
400 | + | let newString = iterateMakeJSON(params, res, lastIterationLen) | |
401 | + | $Tuple2(nil, (("{" + dropRight(newString, 1)) + "}")) | |
402 | + | } | |
403 | + | else $Tuple2(nil, (("{" + dropRight(res, 1)) + "}"))) | |
134 | 404 | ||
135 | 405 | ||
136 | 406 | ||
137 | 407 | @Callable(i) | |
138 | - | func setInt (_key,_value) = valueOrElse(onlyInternal(i.caller), [IntegerEntry(_key, _value)]) | |
408 | + | func makeJSON (arrKeys,arrValues) = if ((size(arrKeys) != size(arrValues))) | |
409 | + | then throw("ArrayKeys and ArrayValues length must be equal") | |
410 | + | else { | |
411 | + | let len = size(arrKeys) | |
412 | + | let iterationsCount = fraction(1, len, 10) | |
413 | + | let lastIterationLen = (len % 10) | |
414 | + | let res = invoke(this, "makeJSONInternal", [arrKeys, arrValues, iterationsCount, lastIterationLen, ""], nil) | |
415 | + | if ((res == res)) | |
416 | + | then $Tuple2(nil, res) | |
417 | + | else throw("Strict value is not equal to itself.") | |
418 | + | } | |
139 | 419 | ||
140 | 420 | ||
141 | 421 | ||
142 | 422 | @Callable(i) | |
143 | - | func deleteEntry (_key) = valueOrElse(onlyInternal(i.caller), [DeleteEntry(_key)]) | |
423 | + | func addToJSON (json,arrKeys,arrValues) = if ((size(arrKeys) != size(arrValues))) | |
424 | + | then throw("ArrayKeys and ArrayValues length must be equal") | |
425 | + | else { | |
426 | + | let len = size(arrKeys) | |
427 | + | let iterationsCount = fraction(1, len, 10) | |
428 | + | let lastIterationLen = (len % 10) | |
429 | + | let res = invoke(this, "makeJSONInternal", [arrKeys, arrValues, iterationsCount, lastIterationLen, (drop(dropRight(json, 1), 1) + ",")], nil) | |
430 | + | if ((res == res)) | |
431 | + | then $Tuple2(nil, res) | |
432 | + | else throw("Strict value is not equal to itself.") | |
433 | + | } | |
144 | 434 | ||
145 | 435 | ||
146 | 436 | ||
147 | 437 | @Callable(i) | |
148 | - | func init (_collectionName,_symbol,_description,_baseURI) = valueOrElse(onlyInternal(i.caller), [StringEntry("collectionName", _collectionName), StringEntry("symbol", _symbol), StringEntry("description", _description), IntegerEntry("totalAmount", 0), StringEntry("baseURI", _baseURI)]) | |
149 | - | ||
150 | - | ||
151 | - | ||
152 | - | @Callable(i) | |
153 | - | func setUser (assetId,user,expires) = { | |
154 | - | let res = invoke(dAppJson, "makeJSON", [["user", "expires"], [user, expires]], nil) | |
155 | - | if ((res == res)) | |
156 | - | then $Tuple2([StringEntry(("userOf-" + assetId), { | |
157 | - | let @ = res | |
158 | - | if ($isInstanceOf(@, "String")) | |
159 | - | then @ | |
160 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
161 | - | })], res) | |
162 | - | else throw("Strict value is not equal to itself.") | |
438 | + | func readByJSONKey (json,key) = { | |
439 | + | let valueByKey = readByKeyInternal(json, key) | |
440 | + | $Tuple2([StringEntry("valueByKey", valueByKey)], valueByKey) | |
163 | 441 | } | |
164 | 442 | ||
165 | 443 | ||
166 | 444 | ||
167 | 445 | @Callable(i) | |
168 | - | func setTokenPayment (assetBinary) = valueOrElse(onlyInternal(i.caller), [BinaryEntry("tokenPayment", assetBinary)]) | |
169 | - | ||
170 | - | ||
171 | - | ||
172 | - | @Callable(i) | |
173 | - | func mintTokens (to,amount) = { | |
174 | - | let reisue = Reissue(tokenPayment, amount, true) | |
175 | - | let toAddress = Address(fromBase58String(to)) | |
176 | - | let transfer = transferOrNot(toAddress, amount, tokenPayment) | |
177 | - | if ((transfer == transfer)) | |
178 | - | then [transfer, reisue] | |
179 | - | else throw("Strict value is not equal to itself.") | |
180 | - | } | |
181 | - | ||
182 | - | ||
183 | - | ||
184 | - | @Callable(i) | |
185 | - | func mintNFT (to) = { | |
186 | - | let tokenId = (totalAmount + 1) | |
187 | - | let tokenIdString = toString(tokenId) | |
188 | - | let preName = ((symbol + "#") + tokenIdString) | |
189 | - | let name = if ((16 >= size(preName))) | |
190 | - | then preName | |
191 | - | else tokenIdString | |
192 | - | let tokenURI = (baseURI + tokenIdString) | |
193 | - | let json = { | |
194 | - | let @ = invoke(dAppJson, "makeJSON", [["tokenURI"], [tokenURI]], nil) | |
195 | - | if ($isInstanceOf(@, "String")) | |
196 | - | then @ | |
197 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
198 | - | } | |
199 | - | let asset = Issue(name, json, 1, 0, false, unit, height) | |
200 | - | let assetId = calculateAssetId(asset) | |
201 | - | let toAddress = Address(fromBase58String(to)) | |
202 | - | let transfer = transferOrNot(toAddress, 1, assetId) | |
203 | - | if ((transfer == transfer)) | |
204 | - | then [asset, transfer, IntegerEntry("totalAmount", tokenId), StringEntry(name, tokenURI)] | |
205 | - | else throw("Strict value is not equal to itself.") | |
206 | - | } | |
207 | - | ||
208 | - | ||
209 | - | ||
210 | - | @Callable(i) | |
211 | - | func initLend (assetId,timeUnitSeconds,timeUnitPrice,timeUnitCount) = valueOrElse(checkAssetOwner(i.caller, assetId), valueOrElse(checkAssetExists(assetId), { | |
212 | - | let asset = parseIdtoAsset(assetId) | |
213 | - | let tokenURI = { | |
214 | - | let @ = invoke(dAppJson, "readByJSONKey", [asset.description, "tokenURI"], nil) | |
215 | - | if ($isInstanceOf(@, "String")) | |
216 | - | then @ | |
217 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
218 | - | } | |
219 | - | if ((tokenURI == tokenURI)) | |
220 | - | then { | |
221 | - | let lendJson = { | |
222 | - | let @ = invoke(dAppJson, "makeJSON", [["supportedInterface", "assetdId", "tokenURI", "owner", "timeUnitSeconds", "timeUnitPrice", "timeUnitCount", "startTimestamp", "endTimestamp", "deposit", "claimed"], ["0", assetId, tokenURI, toString(i.caller), toString(timeUnitSeconds), toString(timeUnitPrice), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSeconds * timeUnitCount))), "0", "0"]], nil) | |
223 | - | if ($isInstanceOf(@, "String")) | |
224 | - | then @ | |
225 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
226 | - | } | |
227 | - | if ((lendJson == lendJson)) | |
228 | - | then { | |
229 | - | let lendIdString = toString(lendCount) | |
230 | - | [IntegerEntry("lendCount", (lendCount + 1)), IntegerEntry("lendCurrentCount", (lendCurrentCount + 1)), IntegerEntry(("lend-rentCount-" + lendIdString), 0), StringEntry(("lend-" + lendIdString), lendJson), BooleanEntry(assetId, true)] | |
231 | - | } | |
232 | - | else throw("Strict value is not equal to itself.") | |
233 | - | } | |
234 | - | else throw("Strict value is not equal to itself.") | |
235 | - | })) | |
236 | - | ||
237 | - | ||
238 | - | ||
239 | - | @Callable(i) | |
240 | - | func initRent (lendId,timeUnitCount) = valueOrElse(checkPayment(i.payments, calcLendCost(lendId, timeUnitCount)), { | |
241 | - | let lendIdString = toString(lendId) | |
242 | - | let lendJson = getStringValue(("lend-" + lendIdString)) | |
243 | - | let rentId = getRentCount(lendId) | |
244 | - | let rentIdString = toString(rentId) | |
245 | - | let timeUnitSeconds = { | |
246 | - | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, "timeUnitSeconds"], nil) | |
247 | - | if ($isInstanceOf(@, "String")) | |
248 | - | then @ | |
249 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
250 | - | } | |
251 | - | if ((timeUnitSeconds == timeUnitSeconds)) | |
252 | - | then { | |
253 | - | let timeUnitSecondsInt = parseIntValue(timeUnitSeconds) | |
254 | - | if ((timeUnitSecondsInt == timeUnitSecondsInt)) | |
255 | - | then { | |
256 | - | let rentJson = { | |
257 | - | let @ = invoke(dAppJson, "makeJSON", [["customer", "timeUnitCount", "startTimestamp", "endTimestamp", "closed"], [toString(i.caller), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSecondsInt * timeUnitCount))), "0"]], nil) | |
258 | - | if ($isInstanceOf(@, "String")) | |
259 | - | then @ | |
260 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
261 | - | } | |
262 | - | if ((rentJson == rentJson)) | |
263 | - | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson), IntegerEntry(("lend-cost-" + lendIdString), (calcLendCost(lendId, timeUnitCount) + getLendCost(lendId)))] | |
264 | - | else throw("Strict value is not equal to itself.") | |
265 | - | } | |
266 | - | else throw("Strict value is not equal to itself.") | |
267 | - | } | |
268 | - | else throw("Strict value is not equal to itself.") | |
269 | - | }) | |
270 | - | ||
271 | - | ||
272 | - | ||
273 | - | @Callable(i) | |
274 | - | func closeLend (lendId) = valueOrElse(checkLendOwner(i.caller, lendId), { | |
275 | - | let lendIdString = toString(lendId) | |
276 | - | let rentCount = getIntegerValue(("lend-rentCount-" + lendIdString)) | |
277 | - | let deleteEntryList = ( let $l = hundredList | |
278 | - | let $s = size($l) | |
279 | - | let $acc0 = $Tuple4(nil, 0, rentCount, lendIdString) | |
280 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
281 | - | then $a | |
282 | - | else reducerGetDeleteEntry($a, $l[$i]) | |
283 | - | ||
284 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
285 | - | then $a | |
286 | - | else throw("List size exceeds 100") | |
287 | - | ||
288 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 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))._1 | |
289 | - | let assetId = valueOrElse(getKey(getLendJson(lendId), "assetdId"), "") | |
290 | - | let txListRaw = [BooleanEntry(assetId, false), DeleteEntry(("lend-" + lendIdString)), DeleteEntry(("lend-rentCount-" + lendIdString)), DeleteEntry(("lend-cost-" + lendIdString)), IntegerEntry("lendCurrentCount", (lendCurrentCount - 1)), ScriptTransfer(i.caller, getLendCost(lendId), tokenPayment)] | |
291 | - | let txList = { | |
292 | - | let $l = txListRaw | |
293 | - | let $s = size($l) | |
294 | - | let $acc0 = deleteEntryList | |
295 | - | func $f1_1 ($a,$i) = if (($i >= $s)) | |
296 | - | then $a | |
297 | - | else reducerConcatLists($a, $l[$i]) | |
298 | - | ||
299 | - | func $f1_2 ($a,$i) = if (($i >= $s)) | |
300 | - | then $a | |
301 | - | else throw("List size exceeds 100") | |
302 | - | ||
303 | - | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 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) | |
304 | - | } | |
305 | - | txList | |
306 | - | }) | |
307 | - | ||
308 | - | ||
309 | - | ||
310 | - | @Callable(i) | |
311 | - | func test () = { | |
312 | - | let data = ["1", "2", "3"] | |
313 | - | let list = ( let $l = hundredList | |
314 | - | let $s = size($l) | |
315 | - | let $acc0 = $Tuple4(data, 0, 5, "5") | |
316 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
317 | - | then $a | |
318 | - | else reducerTest($a, $l[$i]) | |
319 | - | ||
320 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
321 | - | then $a | |
322 | - | else throw("List size exceeds 100") | |
323 | - | ||
324 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 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))._1 | |
325 | - | [StringEntry("Debug", { | |
326 | - | let $l = list | |
327 | - | let $s = size($l) | |
328 | - | let $acc0 = "" | |
329 | - | func $f1_1 ($a,$i) = if (($i >= $s)) | |
330 | - | then $a | |
331 | - | else reducerListToString($a, $l[$i]) | |
332 | - | ||
333 | - | func $f1_2 ($a,$i) = if (($i >= $s)) | |
334 | - | then $a | |
335 | - | else throw("List size exceeds 100") | |
336 | - | ||
337 | - | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 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) | |
338 | - | })] | |
446 | + | func deleteByJSONKey (json,key) = { | |
447 | + | let $t01659016949 = deleteByKeyInternal(json, key) | |
448 | + | let deletedValueByKey = $t01659016949._1 | |
449 | + | let newJson = $t01659016949._2 | |
450 | + | $Tuple2([StringEntry("deletedValue", deletedValueByKey), StringEntry(kJsonRes, newJson)], $Tuple2(deletedValueByKey, newJson)) | |
339 | 451 | } | |
340 | 452 | ||
341 | 453 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let kJsonRes = "jsonRes" | |
5 | 5 | ||
6 | - | let | |
6 | + | let quote = toUtf8String(base58'b') | |
7 | 7 | ||
8 | - | let description = getStringValue("description") | |
9 | - | ||
10 | - | let totalAmount = getIntegerValue("totalAmount") | |
11 | - | ||
12 | - | let baseURI = getStringValue("baseURI") | |
13 | - | ||
14 | - | let dAppJson = Address(fromBase58String("3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7")) | |
15 | - | ||
16 | - | let tokenPayment = getBinaryValue("tokenPayment") | |
17 | - | ||
18 | - | let tokenPaymentAsset = valueOrErrorMessage(assetInfo(getBinaryValue("tokenPayment")), "token payment asset doesn't connect") | |
19 | - | ||
20 | - | let lendCount = getIntegerValue("lendCount") | |
21 | - | ||
22 | - | let lendCurrentCount = getIntegerValue("lendCurrentCount") | |
23 | - | ||
24 | - | let hundredList = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] | |
25 | - | ||
26 | - | func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id") | |
8 | + | func makeField (nextValue) = (((((((quote + nextValue._1) + quote) + ":") + quote) + nextValue._2) + quote) + ",") | |
27 | 9 | ||
28 | 10 | ||
29 | - | func transferOrNot (to,amount,assetId) = if ((to == this)) | |
30 | - | then StringEntry("smth", "smth") | |
31 | - | else ScriptTransfer(to, amount, assetId) | |
11 | + | func reducerMakeJSON (accum,nextValue) = (accum + makeField(nextValue)) | |
32 | 12 | ||
33 | 13 | ||
34 | - | func getLendJson (lendId) = { | |
35 | - | let lendIdString = toString(lendId) | |
36 | - | getStringValue(("lend-" + lendIdString)) | |
37 | - | } | |
14 | + | func iterateMakeJSON (params,res,length) = if ((length == 0)) | |
15 | + | then throw("Empty params") | |
16 | + | else if ((length == 1)) | |
17 | + | then { | |
18 | + | let $l = params | |
19 | + | let $s = size($l) | |
20 | + | let $acc0 = res | |
21 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
22 | + | then $a | |
23 | + | else reducerMakeJSON($a, $l[$i]) | |
24 | + | ||
25 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
26 | + | then $a | |
27 | + | else throw("List size exceeds 1") | |
28 | + | ||
29 | + | $f0_2($f0_1($acc0, 0), 1) | |
30 | + | } | |
31 | + | else if ((length == 2)) | |
32 | + | then { | |
33 | + | let $l = params | |
34 | + | let $s = size($l) | |
35 | + | let $acc0 = res | |
36 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
37 | + | then $a | |
38 | + | else reducerMakeJSON($a, $l[$i]) | |
39 | + | ||
40 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
41 | + | then $a | |
42 | + | else throw("List size exceeds 2") | |
43 | + | ||
44 | + | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
45 | + | } | |
46 | + | else if ((length == 3)) | |
47 | + | then { | |
48 | + | let $l = params | |
49 | + | let $s = size($l) | |
50 | + | let $acc0 = res | |
51 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
52 | + | then $a | |
53 | + | else reducerMakeJSON($a, $l[$i]) | |
54 | + | ||
55 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
56 | + | then $a | |
57 | + | else throw("List size exceeds 3") | |
58 | + | ||
59 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
60 | + | } | |
61 | + | else if ((length == 4)) | |
62 | + | then { | |
63 | + | let $l = params | |
64 | + | let $s = size($l) | |
65 | + | let $acc0 = res | |
66 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
67 | + | then $a | |
68 | + | else reducerMakeJSON($a, $l[$i]) | |
69 | + | ||
70 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
71 | + | then $a | |
72 | + | else throw("List size exceeds 4") | |
73 | + | ||
74 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
75 | + | } | |
76 | + | else if ((length == 5)) | |
77 | + | then { | |
78 | + | let $l = params | |
79 | + | let $s = size($l) | |
80 | + | let $acc0 = res | |
81 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
82 | + | then $a | |
83 | + | else reducerMakeJSON($a, $l[$i]) | |
84 | + | ||
85 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
86 | + | then $a | |
87 | + | else throw("List size exceeds 5") | |
88 | + | ||
89 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
90 | + | } | |
91 | + | else if ((length == 6)) | |
92 | + | then { | |
93 | + | let $l = params | |
94 | + | let $s = size($l) | |
95 | + | let $acc0 = res | |
96 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | + | then $a | |
98 | + | else reducerMakeJSON($a, $l[$i]) | |
99 | + | ||
100 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | + | then $a | |
102 | + | else throw("List size exceeds 6") | |
103 | + | ||
104 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
105 | + | } | |
106 | + | else if ((length == 7)) | |
107 | + | then { | |
108 | + | let $l = params | |
109 | + | let $s = size($l) | |
110 | + | let $acc0 = res | |
111 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
112 | + | then $a | |
113 | + | else reducerMakeJSON($a, $l[$i]) | |
114 | + | ||
115 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
116 | + | then $a | |
117 | + | else throw("List size exceeds 7") | |
118 | + | ||
119 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
120 | + | } | |
121 | + | else if ((length == 8)) | |
122 | + | then { | |
123 | + | let $l = params | |
124 | + | let $s = size($l) | |
125 | + | let $acc0 = res | |
126 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
127 | + | then $a | |
128 | + | else reducerMakeJSON($a, $l[$i]) | |
129 | + | ||
130 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
131 | + | then $a | |
132 | + | else throw("List size exceeds 8") | |
133 | + | ||
134 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8) | |
135 | + | } | |
136 | + | else if ((length == 9)) | |
137 | + | then { | |
138 | + | let $l = params | |
139 | + | let $s = size($l) | |
140 | + | let $acc0 = res | |
141 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
142 | + | then $a | |
143 | + | else reducerMakeJSON($a, $l[$i]) | |
144 | + | ||
145 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
146 | + | then $a | |
147 | + | else throw("List size exceeds 9") | |
148 | + | ||
149 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9) | |
150 | + | } | |
151 | + | else if ((length == 10)) | |
152 | + | then { | |
153 | + | let $l = params | |
154 | + | let $s = size($l) | |
155 | + | let $acc0 = res | |
156 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
157 | + | then $a | |
158 | + | else reducerMakeJSON($a, $l[$i]) | |
159 | + | ||
160 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
161 | + | then $a | |
162 | + | else throw("List size exceeds 10") | |
163 | + | ||
164 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
165 | + | } | |
166 | + | else throw("The max number of parameters exceeded") | |
38 | 167 | ||
39 | 168 | ||
40 | - | func getKey (lendJson,key) = { | |
41 | - | let timeUnitSeconds = { | |
42 | - | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, key], nil) | |
43 | - | if ($isInstanceOf(@, "String")) | |
44 | - | then @ | |
45 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
46 | - | } | |
47 | - | if ((timeUnitSeconds == timeUnitSeconds)) | |
48 | - | then timeUnitSeconds | |
49 | - | else throw("Strict value is not equal to itself.") | |
169 | + | func getPartAndTail (arr) = { | |
170 | + | let el0 = arr[0] | |
171 | + | let el1 = arr[1] | |
172 | + | let el2 = arr[2] | |
173 | + | let el3 = arr[3] | |
174 | + | let el4 = arr[4] | |
175 | + | let el5 = arr[5] | |
176 | + | let el6 = arr[6] | |
177 | + | let el7 = arr[7] | |
178 | + | let el8 = arr[8] | |
179 | + | let el9 = arr[9] | |
180 | + | let arr0 = removeByIndex(arr, 0) | |
181 | + | let arr1 = removeByIndex(arr0, 0) | |
182 | + | let arr2 = removeByIndex(arr1, 0) | |
183 | + | let arr3 = removeByIndex(arr2, 0) | |
184 | + | let arr4 = removeByIndex(arr3, 0) | |
185 | + | let arr5 = removeByIndex(arr4, 0) | |
186 | + | let arr6 = removeByIndex(arr5, 0) | |
187 | + | let arr7 = removeByIndex(arr6, 0) | |
188 | + | let arr8 = removeByIndex(arr7, 0) | |
189 | + | let arr9 = removeByIndex(arr8, 0) | |
190 | + | $Tuple2([el0, el1, el2, el3, el4, el5, el6, el7, el8, el9], arr9) | |
50 | 191 | } | |
51 | - | ||
52 | - | ||
53 | - | func getRentCount (lendId) = { | |
54 | - | let lendIdString = toString(lendId) | |
55 | - | getIntegerValue(("lend-rentCount-" + lendIdString)) | |
56 | - | } | |
57 | - | ||
58 | - | ||
59 | - | func calcLendCost (lendId,timeUnitSeconds) = { | |
60 | - | let lendJson = getLendJson(lendId) | |
61 | - | let timeUnitPriceString = getKey(lendJson, "timeUnitPrice") | |
62 | - | if ((timeUnitPriceString == timeUnitPriceString)) | |
63 | - | then { | |
64 | - | let timeUnitPrice = parseIntValue(timeUnitPriceString) | |
65 | - | (timeUnitSeconds * timeUnitPrice) | |
66 | - | } | |
67 | - | else throw("Strict value is not equal to itself.") | |
68 | - | } | |
69 | - | ||
70 | - | ||
71 | - | func getLendCost (lendId) = valueOrElse(getInteger(("lend-cost-" + toString(lendId))), 0) | |
72 | 192 | ||
73 | 193 | ||
74 | 194 | func onlyInternal (caller) = if ((caller == this)) | |
75 | 195 | then unit | |
76 | 196 | else throw("Only internal call") | |
77 | 197 | ||
78 | 198 | ||
79 | - | func reducerGetDeleteEntry (accum,next) = { | |
80 | - | let $t025422592 = accum | |
81 | - | let deletions = $t025422592._1 | |
82 | - | let current = $t025422592._2 | |
83 | - | let maxCount = $t025422592._3 | |
84 | - | let lendId = $t025422592._4 | |
85 | - | if ((maxCount > current)) | |
86 | - | then $Tuple4((deletions :+ DeleteEntry(((("lend-rent-" + lendId) + "-") + toString(current)))), (current + 1), maxCount, lendId) | |
199 | + | func prepare_1 (arr,arr2) = [$Tuple2(arr[0], arr2[0])] | |
200 | + | ||
201 | + | ||
202 | + | func prepare_2 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1])] | |
203 | + | ||
204 | + | ||
205 | + | func prepare_3 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2])] | |
206 | + | ||
207 | + | ||
208 | + | func prepare_4 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3])] | |
209 | + | ||
210 | + | ||
211 | + | func prepare_5 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4])] | |
212 | + | ||
213 | + | ||
214 | + | func prepare_6 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5])] | |
215 | + | ||
216 | + | ||
217 | + | func prepare_7 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6])] | |
218 | + | ||
219 | + | ||
220 | + | func prepare_8 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6]), $Tuple2(arr[7], arr2[7])] | |
221 | + | ||
222 | + | ||
223 | + | func prepare_9 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6]), $Tuple2(arr[7], arr2[7]), $Tuple2(arr[8], arr2[8])] | |
224 | + | ||
225 | + | ||
226 | + | func prepare_10 (arr,arr2) = [$Tuple2(arr[0], arr2[0]), $Tuple2(arr[1], arr2[1]), $Tuple2(arr[2], arr2[2]), $Tuple2(arr[3], arr2[3]), $Tuple2(arr[4], arr2[4]), $Tuple2(arr[5], arr2[5]), $Tuple2(arr[6], arr2[6]), $Tuple2(arr[7], arr2[7]), $Tuple2(arr[8], arr2[8]), $Tuple2(arr[9], arr2[9])] | |
227 | + | ||
228 | + | ||
229 | + | func prepareParams (currentArrPartKeys,currentArrPartValues,length) = if ((length == 0)) | |
230 | + | then throw("Empty params") | |
231 | + | else if ((length == 1)) | |
232 | + | then prepare_1(currentArrPartKeys, currentArrPartValues) | |
233 | + | else if ((length == 2)) | |
234 | + | then prepare_2(currentArrPartKeys, currentArrPartValues) | |
235 | + | else if ((length == 3)) | |
236 | + | then prepare_3(currentArrPartKeys, currentArrPartValues) | |
237 | + | else if ((length == 4)) | |
238 | + | then prepare_4(currentArrPartKeys, currentArrPartValues) | |
239 | + | else if ((length == 5)) | |
240 | + | then prepare_5(currentArrPartKeys, currentArrPartValues) | |
241 | + | else if ((length == 6)) | |
242 | + | then prepare_6(currentArrPartKeys, currentArrPartValues) | |
243 | + | else if ((length == 7)) | |
244 | + | then prepare_7(currentArrPartKeys, currentArrPartValues) | |
245 | + | else if ((length == 8)) | |
246 | + | then prepare_8(currentArrPartKeys, currentArrPartValues) | |
247 | + | else if ((length == 9)) | |
248 | + | then prepare_9(currentArrPartKeys, currentArrPartValues) | |
249 | + | else if ((length == 10)) | |
250 | + | then prepare_10(currentArrPartKeys, currentArrPartValues) | |
251 | + | else throw("Max number of parameters exceeded") | |
252 | + | ||
253 | + | ||
254 | + | func getStartAndEndIndexes (json,key) = { | |
255 | + | let keyLen = size(key) | |
256 | + | let startIndex = value(indexOf(json, key)) | |
257 | + | let endIndex = valueOrElse(indexOf(json, ",", startIndex), value(indexOf(json, "}", startIndex))) | |
258 | + | $Tuple3(keyLen, startIndex, endIndex) | |
259 | + | } | |
260 | + | ||
261 | + | ||
262 | + | func reducerFindObjcetByKey (accum,next) = { | |
263 | + | let $t064646786 = accum | |
264 | + | let key = $t064646786._1 | |
265 | + | let levelOn = $t064646786._2 | |
266 | + | let currentLevelOn = $t064646786._3 | |
267 | + | let startIndex = $t064646786._4 | |
268 | + | let endIndex = $t064646786._5 | |
269 | + | let currentIndex = $t064646786._6 | |
270 | + | let end = $t064646786._7 | |
271 | + | if (!(end)) | |
272 | + | then { | |
273 | + | let keyValueList = split(next, ":") | |
274 | + | let leftBraceCount = (size(split(next, "{")) - 1) | |
275 | + | let rightBraceCount = (size(split(next, "}")) - 1) | |
276 | + | let nextCurrentCount = (leftBraceCount - rightBraceCount) | |
277 | + | let $t070397239 = if (if ((levelOn == currentLevelOn)) | |
278 | + | then (keyValueList[0] == key) | |
279 | + | else false) | |
280 | + | then $Tuple2(currentIndex, true) | |
281 | + | else $Tuple2(0, false) | |
282 | + | let foundedStartIndex = $t070397239._1 | |
283 | + | let foundedStart = $t070397239._2 | |
284 | + | let $t072497445 = if (if ((levelOn == currentLevelOn)) | |
285 | + | then (keyValueList[0] == key) | |
286 | + | else false) | |
287 | + | then $Tuple2(currentIndex, true) | |
288 | + | else $Tuple2(0, false) | |
289 | + | let foundedEndIndex = $t072497445._1 | |
290 | + | let foundedEnd = $t072497445._2 | |
291 | + | $Tuple7(key, levelOn, (currentLevelOn + nextCurrentCount), if (foundedStart) | |
292 | + | then foundedStartIndex | |
293 | + | else startIndex, if (foundedEnd) | |
294 | + | then foundedEndIndex | |
295 | + | else endIndex, (currentIndex + 1), if (foundedEnd) | |
296 | + | then foundedEnd | |
297 | + | else end) | |
298 | + | } | |
87 | 299 | else accum | |
88 | 300 | } | |
89 | 301 | ||
90 | 302 | ||
91 | - | func | |
92 | - | ||
93 | - | ||
94 | - | ||
95 | - | ||
96 | - | ||
97 | - | ||
98 | - | ||
99 | - | ||
100 | - | ||
101 | - | | |
102 | - | | |
103 | - | | |
104 | - | | |
105 | - | let | |
106 | - | | |
107 | - | | |
108 | - | else | |
303 | + | func reducerConcatList (accum,next) = { | |
304 | + | let $t078917952 = accum | |
305 | + | let result = $t078917952._1 | |
306 | + | let currentIndex = $t078917952._2 | |
307 | + | let startIndex = $t078917952._3 | |
308 | + | let endIndex = $t078917952._4 | |
309 | + | let end = $t078917952._5 | |
310 | + | if (!(end)) | |
311 | + | then { | |
312 | + | let newResult = if (if ((currentIndex >= startIndex)) | |
313 | + | then (endIndex >= currentIndex) | |
314 | + | else false) | |
315 | + | then ((result + ",") + next) | |
316 | + | else result | |
317 | + | let newEnd = (currentIndex > endIndex) | |
318 | + | $Tuple5(newResult, (currentIndex + 1), startIndex, endIndex, newEnd) | |
319 | + | } | |
320 | + | else accum | |
109 | 321 | } | |
110 | 322 | ||
111 | 323 | ||
112 | - | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
113 | - | then unit | |
114 | - | else throw("Only asset owner") | |
324 | + | func reducerTakeObject (accum,next) = { | |
325 | + | let $t083908450 = accum | |
326 | + | let result = $t083908450._1 | |
327 | + | let leftCount = $t083908450._2 | |
328 | + | let rightCount = $t083908450._3 | |
329 | + | let i = $t083908450._4 | |
330 | + | let iCount = $t083908450._5 | |
331 | + | let end = $t083908450._6 | |
332 | + | if (if (!(end)) | |
333 | + | then true | |
334 | + | else (iCount > i)) | |
335 | + | then { | |
336 | + | let $t084889245 = if (contains(next, "{")) | |
337 | + | then { | |
338 | + | let _nextLeftCount = (size(split(next, "{")) - 1) | |
339 | + | $Tuple2(_nextLeftCount, 0) | |
340 | + | } | |
341 | + | else if (contains(next, "}")) | |
342 | + | then { | |
343 | + | let _nextRightCount = (size(split(next, "}")) - 1) | |
344 | + | $Tuple2(0, _nextRightCount) | |
345 | + | } | |
346 | + | else $Tuple2(0, 0) | |
347 | + | let nextLeftCount = $t084889245._1 | |
348 | + | let nextRightCount = $t084889245._2 | |
349 | + | let curentLeftCount = (leftCount + nextLeftCount) | |
350 | + | let currentRightCount = (rightCount + nextRightCount) | |
351 | + | if ((curentLeftCount == currentRightCount)) | |
352 | + | then $Tuple6(result, curentLeftCount, currentRightCount, (i + 1), iCount, true) | |
353 | + | else $Tuple6(((result + ",") + next), curentLeftCount, currentRightCount, (i + 1), iCount, false) | |
354 | + | } | |
355 | + | else accum | |
356 | + | } | |
115 | 357 | ||
116 | 358 | ||
117 | - | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
118 | - | then unit | |
119 | - | else throw("amount less then need") | |
359 | + | func readByKeyInternal (json,key) = { | |
360 | + | let $t097799895 = getStartAndEndIndexes(json, key) | |
361 | + | let keyLen = $t097799895._1 | |
362 | + | let startIndex = $t097799895._2 | |
363 | + | let endIndex = $t097799895._3 | |
364 | + | drop(take(json, (endIndex - 1)), ((startIndex + keyLen) + 3)) | |
365 | + | } | |
120 | 366 | ||
121 | 367 | ||
122 | - | func checkAssetExists (assetId) = if (valueOrElse(getBoolean(assetId), false)) | |
123 | - | then throw("this token already use") | |
124 | - | else unit | |
125 | - | ||
126 | - | ||
127 | - | func checkLendOwner (caller,lendId) = if ((getKey(getLendJson(lendId), "owner") != toString(caller))) | |
128 | - | then throw("you haven't perms") | |
129 | - | else unit | |
368 | + | func deleteByKeyInternal (json,key) = { | |
369 | + | let $t01017610244 = getStartAndEndIndexes(json, key) | |
370 | + | let keyLen = $t01017610244._1 | |
371 | + | let startIndex = $t01017610244._2 | |
372 | + | let endIndex = $t01017610244._3 | |
373 | + | let deletedValue = drop(take(json, (endIndex - 1)), ((startIndex + keyLen) + 3)) | |
374 | + | let newJson = if (((size(json) - endIndex) == 1)) | |
375 | + | then (take(json, (startIndex - 2)) + drop(json, endIndex)) | |
376 | + | else (take(json, (startIndex - 1)) + drop(json, (endIndex + 1))) | |
377 | + | $Tuple2(deletedValue, newJson) | |
378 | + | } | |
130 | 379 | ||
131 | 380 | ||
132 | 381 | @Callable(i) | |
133 | - | func setString (_key,_value) = valueOrElse(onlyInternal(i.caller), [StringEntry(_key, _value)]) | |
382 | + | func makeJSONInternal (arrKeys,arrValues,iterationsCount,lastIterationLen,res) = valueOrElse(onlyInternal(i.caller), if ((iterationsCount > 0)) | |
383 | + | then { | |
384 | + | let $t01188212047 = getPartAndTail(arrKeys) | |
385 | + | let currentArrPartKeys = $t01188212047._1 | |
386 | + | let arrTailKeys = $t01188212047._2 | |
387 | + | let $t01205612174 = getPartAndTail(arrValues) | |
388 | + | let currentArrPartValues = $t01205612174._1 | |
389 | + | let arrTailValues = $t01205612174._2 | |
390 | + | let params = prepareParams(currentArrPartKeys, currentArrPartValues, 10) | |
391 | + | let newString = iterateMakeJSON(params, res, 10) | |
392 | + | let result = invoke(this, "makeJSONInternal", [arrTailKeys, arrTailValues, (iterationsCount - 1), lastIterationLen, newString], nil) | |
393 | + | if ((result == result)) | |
394 | + | then $Tuple2(nil, result) | |
395 | + | else throw("Strict value is not equal to itself.") | |
396 | + | } | |
397 | + | else if ((lastIterationLen != 0)) | |
398 | + | then { | |
399 | + | let params = prepareParams(arrKeys, arrValues, lastIterationLen) | |
400 | + | let newString = iterateMakeJSON(params, res, lastIterationLen) | |
401 | + | $Tuple2(nil, (("{" + dropRight(newString, 1)) + "}")) | |
402 | + | } | |
403 | + | else $Tuple2(nil, (("{" + dropRight(res, 1)) + "}"))) | |
134 | 404 | ||
135 | 405 | ||
136 | 406 | ||
137 | 407 | @Callable(i) | |
138 | - | func setInt (_key,_value) = valueOrElse(onlyInternal(i.caller), [IntegerEntry(_key, _value)]) | |
408 | + | func makeJSON (arrKeys,arrValues) = if ((size(arrKeys) != size(arrValues))) | |
409 | + | then throw("ArrayKeys and ArrayValues length must be equal") | |
410 | + | else { | |
411 | + | let len = size(arrKeys) | |
412 | + | let iterationsCount = fraction(1, len, 10) | |
413 | + | let lastIterationLen = (len % 10) | |
414 | + | let res = invoke(this, "makeJSONInternal", [arrKeys, arrValues, iterationsCount, lastIterationLen, ""], nil) | |
415 | + | if ((res == res)) | |
416 | + | then $Tuple2(nil, res) | |
417 | + | else throw("Strict value is not equal to itself.") | |
418 | + | } | |
139 | 419 | ||
140 | 420 | ||
141 | 421 | ||
142 | 422 | @Callable(i) | |
143 | - | func deleteEntry (_key) = valueOrElse(onlyInternal(i.caller), [DeleteEntry(_key)]) | |
423 | + | func addToJSON (json,arrKeys,arrValues) = if ((size(arrKeys) != size(arrValues))) | |
424 | + | then throw("ArrayKeys and ArrayValues length must be equal") | |
425 | + | else { | |
426 | + | let len = size(arrKeys) | |
427 | + | let iterationsCount = fraction(1, len, 10) | |
428 | + | let lastIterationLen = (len % 10) | |
429 | + | let res = invoke(this, "makeJSONInternal", [arrKeys, arrValues, iterationsCount, lastIterationLen, (drop(dropRight(json, 1), 1) + ",")], nil) | |
430 | + | if ((res == res)) | |
431 | + | then $Tuple2(nil, res) | |
432 | + | else throw("Strict value is not equal to itself.") | |
433 | + | } | |
144 | 434 | ||
145 | 435 | ||
146 | 436 | ||
147 | 437 | @Callable(i) | |
148 | - | func init (_collectionName,_symbol,_description,_baseURI) = valueOrElse(onlyInternal(i.caller), [StringEntry("collectionName", _collectionName), StringEntry("symbol", _symbol), StringEntry("description", _description), IntegerEntry("totalAmount", 0), StringEntry("baseURI", _baseURI)]) | |
149 | - | ||
150 | - | ||
151 | - | ||
152 | - | @Callable(i) | |
153 | - | func setUser (assetId,user,expires) = { | |
154 | - | let res = invoke(dAppJson, "makeJSON", [["user", "expires"], [user, expires]], nil) | |
155 | - | if ((res == res)) | |
156 | - | then $Tuple2([StringEntry(("userOf-" + assetId), { | |
157 | - | let @ = res | |
158 | - | if ($isInstanceOf(@, "String")) | |
159 | - | then @ | |
160 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
161 | - | })], res) | |
162 | - | else throw("Strict value is not equal to itself.") | |
438 | + | func readByJSONKey (json,key) = { | |
439 | + | let valueByKey = readByKeyInternal(json, key) | |
440 | + | $Tuple2([StringEntry("valueByKey", valueByKey)], valueByKey) | |
163 | 441 | } | |
164 | 442 | ||
165 | 443 | ||
166 | 444 | ||
167 | 445 | @Callable(i) | |
168 | - | func setTokenPayment (assetBinary) = valueOrElse(onlyInternal(i.caller), [BinaryEntry("tokenPayment", assetBinary)]) | |
169 | - | ||
170 | - | ||
171 | - | ||
172 | - | @Callable(i) | |
173 | - | func mintTokens (to,amount) = { | |
174 | - | let reisue = Reissue(tokenPayment, amount, true) | |
175 | - | let toAddress = Address(fromBase58String(to)) | |
176 | - | let transfer = transferOrNot(toAddress, amount, tokenPayment) | |
177 | - | if ((transfer == transfer)) | |
178 | - | then [transfer, reisue] | |
179 | - | else throw("Strict value is not equal to itself.") | |
180 | - | } | |
181 | - | ||
182 | - | ||
183 | - | ||
184 | - | @Callable(i) | |
185 | - | func mintNFT (to) = { | |
186 | - | let tokenId = (totalAmount + 1) | |
187 | - | let tokenIdString = toString(tokenId) | |
188 | - | let preName = ((symbol + "#") + tokenIdString) | |
189 | - | let name = if ((16 >= size(preName))) | |
190 | - | then preName | |
191 | - | else tokenIdString | |
192 | - | let tokenURI = (baseURI + tokenIdString) | |
193 | - | let json = { | |
194 | - | let @ = invoke(dAppJson, "makeJSON", [["tokenURI"], [tokenURI]], nil) | |
195 | - | if ($isInstanceOf(@, "String")) | |
196 | - | then @ | |
197 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
198 | - | } | |
199 | - | let asset = Issue(name, json, 1, 0, false, unit, height) | |
200 | - | let assetId = calculateAssetId(asset) | |
201 | - | let toAddress = Address(fromBase58String(to)) | |
202 | - | let transfer = transferOrNot(toAddress, 1, assetId) | |
203 | - | if ((transfer == transfer)) | |
204 | - | then [asset, transfer, IntegerEntry("totalAmount", tokenId), StringEntry(name, tokenURI)] | |
205 | - | else throw("Strict value is not equal to itself.") | |
206 | - | } | |
207 | - | ||
208 | - | ||
209 | - | ||
210 | - | @Callable(i) | |
211 | - | func initLend (assetId,timeUnitSeconds,timeUnitPrice,timeUnitCount) = valueOrElse(checkAssetOwner(i.caller, assetId), valueOrElse(checkAssetExists(assetId), { | |
212 | - | let asset = parseIdtoAsset(assetId) | |
213 | - | let tokenURI = { | |
214 | - | let @ = invoke(dAppJson, "readByJSONKey", [asset.description, "tokenURI"], nil) | |
215 | - | if ($isInstanceOf(@, "String")) | |
216 | - | then @ | |
217 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
218 | - | } | |
219 | - | if ((tokenURI == tokenURI)) | |
220 | - | then { | |
221 | - | let lendJson = { | |
222 | - | let @ = invoke(dAppJson, "makeJSON", [["supportedInterface", "assetdId", "tokenURI", "owner", "timeUnitSeconds", "timeUnitPrice", "timeUnitCount", "startTimestamp", "endTimestamp", "deposit", "claimed"], ["0", assetId, tokenURI, toString(i.caller), toString(timeUnitSeconds), toString(timeUnitPrice), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSeconds * timeUnitCount))), "0", "0"]], nil) | |
223 | - | if ($isInstanceOf(@, "String")) | |
224 | - | then @ | |
225 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
226 | - | } | |
227 | - | if ((lendJson == lendJson)) | |
228 | - | then { | |
229 | - | let lendIdString = toString(lendCount) | |
230 | - | [IntegerEntry("lendCount", (lendCount + 1)), IntegerEntry("lendCurrentCount", (lendCurrentCount + 1)), IntegerEntry(("lend-rentCount-" + lendIdString), 0), StringEntry(("lend-" + lendIdString), lendJson), BooleanEntry(assetId, true)] | |
231 | - | } | |
232 | - | else throw("Strict value is not equal to itself.") | |
233 | - | } | |
234 | - | else throw("Strict value is not equal to itself.") | |
235 | - | })) | |
236 | - | ||
237 | - | ||
238 | - | ||
239 | - | @Callable(i) | |
240 | - | func initRent (lendId,timeUnitCount) = valueOrElse(checkPayment(i.payments, calcLendCost(lendId, timeUnitCount)), { | |
241 | - | let lendIdString = toString(lendId) | |
242 | - | let lendJson = getStringValue(("lend-" + lendIdString)) | |
243 | - | let rentId = getRentCount(lendId) | |
244 | - | let rentIdString = toString(rentId) | |
245 | - | let timeUnitSeconds = { | |
246 | - | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, "timeUnitSeconds"], nil) | |
247 | - | if ($isInstanceOf(@, "String")) | |
248 | - | then @ | |
249 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
250 | - | } | |
251 | - | if ((timeUnitSeconds == timeUnitSeconds)) | |
252 | - | then { | |
253 | - | let timeUnitSecondsInt = parseIntValue(timeUnitSeconds) | |
254 | - | if ((timeUnitSecondsInt == timeUnitSecondsInt)) | |
255 | - | then { | |
256 | - | let rentJson = { | |
257 | - | let @ = invoke(dAppJson, "makeJSON", [["customer", "timeUnitCount", "startTimestamp", "endTimestamp", "closed"], [toString(i.caller), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSecondsInt * timeUnitCount))), "0"]], nil) | |
258 | - | if ($isInstanceOf(@, "String")) | |
259 | - | then @ | |
260 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
261 | - | } | |
262 | - | if ((rentJson == rentJson)) | |
263 | - | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson), IntegerEntry(("lend-cost-" + lendIdString), (calcLendCost(lendId, timeUnitCount) + getLendCost(lendId)))] | |
264 | - | else throw("Strict value is not equal to itself.") | |
265 | - | } | |
266 | - | else throw("Strict value is not equal to itself.") | |
267 | - | } | |
268 | - | else throw("Strict value is not equal to itself.") | |
269 | - | }) | |
270 | - | ||
271 | - | ||
272 | - | ||
273 | - | @Callable(i) | |
274 | - | func closeLend (lendId) = valueOrElse(checkLendOwner(i.caller, lendId), { | |
275 | - | let lendIdString = toString(lendId) | |
276 | - | let rentCount = getIntegerValue(("lend-rentCount-" + lendIdString)) | |
277 | - | let deleteEntryList = ( let $l = hundredList | |
278 | - | let $s = size($l) | |
279 | - | let $acc0 = $Tuple4(nil, 0, rentCount, lendIdString) | |
280 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
281 | - | then $a | |
282 | - | else reducerGetDeleteEntry($a, $l[$i]) | |
283 | - | ||
284 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
285 | - | then $a | |
286 | - | else throw("List size exceeds 100") | |
287 | - | ||
288 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 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))._1 | |
289 | - | let assetId = valueOrElse(getKey(getLendJson(lendId), "assetdId"), "") | |
290 | - | let txListRaw = [BooleanEntry(assetId, false), DeleteEntry(("lend-" + lendIdString)), DeleteEntry(("lend-rentCount-" + lendIdString)), DeleteEntry(("lend-cost-" + lendIdString)), IntegerEntry("lendCurrentCount", (lendCurrentCount - 1)), ScriptTransfer(i.caller, getLendCost(lendId), tokenPayment)] | |
291 | - | let txList = { | |
292 | - | let $l = txListRaw | |
293 | - | let $s = size($l) | |
294 | - | let $acc0 = deleteEntryList | |
295 | - | func $f1_1 ($a,$i) = if (($i >= $s)) | |
296 | - | then $a | |
297 | - | else reducerConcatLists($a, $l[$i]) | |
298 | - | ||
299 | - | func $f1_2 ($a,$i) = if (($i >= $s)) | |
300 | - | then $a | |
301 | - | else throw("List size exceeds 100") | |
302 | - | ||
303 | - | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 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) | |
304 | - | } | |
305 | - | txList | |
306 | - | }) | |
307 | - | ||
308 | - | ||
309 | - | ||
310 | - | @Callable(i) | |
311 | - | func test () = { | |
312 | - | let data = ["1", "2", "3"] | |
313 | - | let list = ( let $l = hundredList | |
314 | - | let $s = size($l) | |
315 | - | let $acc0 = $Tuple4(data, 0, 5, "5") | |
316 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
317 | - | then $a | |
318 | - | else reducerTest($a, $l[$i]) | |
319 | - | ||
320 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
321 | - | then $a | |
322 | - | else throw("List size exceeds 100") | |
323 | - | ||
324 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 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))._1 | |
325 | - | [StringEntry("Debug", { | |
326 | - | let $l = list | |
327 | - | let $s = size($l) | |
328 | - | let $acc0 = "" | |
329 | - | func $f1_1 ($a,$i) = if (($i >= $s)) | |
330 | - | then $a | |
331 | - | else reducerListToString($a, $l[$i]) | |
332 | - | ||
333 | - | func $f1_2 ($a,$i) = if (($i >= $s)) | |
334 | - | then $a | |
335 | - | else throw("List size exceeds 100") | |
336 | - | ||
337 | - | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 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) | |
338 | - | })] | |
446 | + | func deleteByJSONKey (json,key) = { | |
447 | + | let $t01659016949 = deleteByKeyInternal(json, key) | |
448 | + | let deletedValueByKey = $t01659016949._1 | |
449 | + | let newJson = $t01659016949._2 | |
450 | + | $Tuple2([StringEntry("deletedValue", deletedValueByKey), StringEntry(kJsonRes, newJson)], $Tuple2(deletedValueByKey, newJson)) | |
339 | 451 | } | |
340 | 452 | ||
341 | 453 |
github/deemru/w8io/169f3d6 69.59 ms ◑