tx · GF7ZjKbMbMU39ckahaE9wLTz4tGNaFMAoUnMnbS7LuLB 3Mr7HCJPTazuYjJbfbbpRMvZX8xrNTjT1Kx: -0.01000000 Waves 2023.03.06 18:28 [2478409] smart account 3Mr7HCJPTazuYjJbfbbpRMvZX8xrNTjT1Kx > SELF 0.00000000 Waves
{ "type": 13, "id": "GF7ZjKbMbMU39ckahaE9wLTz4tGNaFMAoUnMnbS7LuLB", "fee": 1000000, "feeAssetId": null, "timestamp": 1678116498722, "version": 2, "chainId": 84, "sender": "3Mr7HCJPTazuYjJbfbbpRMvZX8xrNTjT1Kx", "senderPublicKey": "D35PGQCSSdrp9pvujggj7b2DaCK1BhcU3kho7tikKJYs", "proofs": [ "44UsYtaursimsUpSo5YMa52zw2sCsMvxeXq1iu1uTxpj7XutjQDzmKoMQA22CncBmLjRzeNC8YQUCGHFdB5RG3wd" ], "script": "base64:BgIgCAISBAoCAQESABIDCgEBEgQKAhgREgQKAggIEgMKAQgCAAxvcHRpb25zX2FkZHIJAQdBZGRyZXNzAQEaAVRBW/gr9hfqKqHLxIrx+8e7siBhMf6HIMEABHRVU0QBIKskSmq2Qkbr0vzjebBhusOuaVdNUnrKRRynQB0RsCkOBgFpAQlpc3N1ZUJpbGwCCXByb3ZpZGluZwRzaXplBApjdXJyZW50S2V5CQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMEDWN1cnJlbnRBbW91bnQEByRtYXRjaDAJAJoIAgUEdGhpcwUKY3VycmVudEtleQMJAAECBQckbWF0Y2gwAgNJbnQEAWEFByRtYXRjaDAFAWEAAAQRbWluQmlsbERlcG9zaXRTdHIEByRtYXRjaDAJAJ0IAgUMb3B0aW9uc19hZGRyAhBtaW5fYmlsbF9kZXBvc2l0AwkAAQIFByRtYXRjaDACBFVuaXQCATADCQABAgUHJG1hdGNoMAIGU3RyaW5nBAF4BQckbWF0Y2gwBQF4CQACAQILTWF0Y2ggZXJyb3IED2V4Y2hhbmdlUmF0ZVN0cgQHJG1hdGNoMAk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BBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXnKqYXj", "height": 2478409, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EJ9nG6iQZ9g1JgfTRFP9AVoNorczwu833p6D7DCChgLh Next: ENSaAqFBmZqcNXXLwV2rq6MohGAmVMqK6AkD7gtm8RFo Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let tUSD = base58'CX4p6XcuSBUvv44r1avCqYka5PYAVzBK5hSXaT7maU85' | |
7 | 7 | ||
8 | 8 | @Callable(i) | |
9 | - | func issueBill (providing) = { | |
9 | + | func issueBill (providing,size) = { | |
10 | 10 | let currentKey = toBase58String(i.caller.bytes) | |
11 | 11 | let currentAmount = match getInteger(this, currentKey) { | |
12 | 12 | case a: Int => | |
22 | 22 | case _ => | |
23 | 23 | throw("Match error") | |
24 | 24 | } | |
25 | + | let exchangeRateStr = match getString(options_addr, "exchange_rate") { | |
26 | + | case _: Unit => | |
27 | + | "0" | |
28 | + | case x: String => | |
29 | + | x | |
30 | + | case _ => | |
31 | + | throw("Match error") | |
32 | + | } | |
25 | 33 | let minBillDeposit = match parseInt(split(minBillDepositStr, ".")[0]) { | |
34 | + | case _: Unit => | |
35 | + | 0 | |
36 | + | case t: Int => | |
37 | + | t | |
38 | + | case _ => | |
39 | + | throw("Match error") | |
40 | + | } | |
41 | + | let exchangeRate = match parseInt(split(exchangeRateStr, ".")[0]) { | |
26 | 42 | case _: Unit => | |
27 | 43 | 0 | |
28 | 44 | case t: Int => | |
35 | 51 | then throw((((("The security deposit must be more than " + minBillDepositStr) + ". You set the size: ") + toString((providing / 100))) + ".00")) | |
36 | 52 | else if ((0 > newAmount)) | |
37 | 53 | then throw("Not enough balance") | |
38 | - | else { | |
39 | - | let issue = Issue(("bill for:" + toString((providing / 100))), currentKey, 1, 0, false) | |
40 | - | let id = calculateAssetId(issue) | |
41 | - | $Tuple2([IntegerEntry(currentKey, newAmount), issue, ScriptTransfer(i.caller, 1, id), IntegerEntry(("l_u_" + toBase58String(id)), providing)], unit) | |
42 | - | } | |
54 | + | else if ((size > (currentAmount * exchangeRate))) | |
55 | + | then throw((("The nominal value of the promissory bill exceeds the collateral minimum (" + minBillDepositStr) + ")")) | |
56 | + | else { | |
57 | + | let issue = Issue(("bill for:" + toString((providing / 100))), ((currentKey + ":") + toString(size)), 1, 0, false) | |
58 | + | let id = calculateAssetId(issue) | |
59 | + | $Tuple2([IntegerEntry(currentKey, newAmount), issue, ScriptTransfer(i.caller, 1, id), IntegerEntry(("l_u_" + toBase58String(id)), providing)], unit) | |
60 | + | } | |
43 | 61 | } | |
44 | 62 | ||
45 | 63 | ||
117 | 135 | throw("Match error") | |
118 | 136 | } | |
119 | 137 | func addStringEntry (accum,nextValue) = { | |
120 | - | let $ | |
121 | - | let result = $ | |
122 | - | let j = $ | |
138 | + | let $t052975320 = accum | |
139 | + | let result = $t052975320._1 | |
140 | + | let j = $t052975320._2 | |
123 | 141 | $Tuple2((result :+ IntegerEntry(opts[j], nextValue)), (j + 1)) | |
124 | 142 | } | |
125 | 143 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let options_addr = Address(base58'3MusfsY6PqDh1YnF7YyTi5ffVT16Dm2bqf6') | |
5 | 5 | ||
6 | 6 | let tUSD = base58'CX4p6XcuSBUvv44r1avCqYka5PYAVzBK5hSXaT7maU85' | |
7 | 7 | ||
8 | 8 | @Callable(i) | |
9 | - | func issueBill (providing) = { | |
9 | + | func issueBill (providing,size) = { | |
10 | 10 | let currentKey = toBase58String(i.caller.bytes) | |
11 | 11 | let currentAmount = match getInteger(this, currentKey) { | |
12 | 12 | case a: Int => | |
13 | 13 | a | |
14 | 14 | case _ => | |
15 | 15 | 0 | |
16 | 16 | } | |
17 | 17 | let minBillDepositStr = match getString(options_addr, "min_bill_deposit") { | |
18 | 18 | case _: Unit => | |
19 | 19 | "0" | |
20 | 20 | case x: String => | |
21 | 21 | x | |
22 | 22 | case _ => | |
23 | 23 | throw("Match error") | |
24 | 24 | } | |
25 | + | let exchangeRateStr = match getString(options_addr, "exchange_rate") { | |
26 | + | case _: Unit => | |
27 | + | "0" | |
28 | + | case x: String => | |
29 | + | x | |
30 | + | case _ => | |
31 | + | throw("Match error") | |
32 | + | } | |
25 | 33 | let minBillDeposit = match parseInt(split(minBillDepositStr, ".")[0]) { | |
34 | + | case _: Unit => | |
35 | + | 0 | |
36 | + | case t: Int => | |
37 | + | t | |
38 | + | case _ => | |
39 | + | throw("Match error") | |
40 | + | } | |
41 | + | let exchangeRate = match parseInt(split(exchangeRateStr, ".")[0]) { | |
26 | 42 | case _: Unit => | |
27 | 43 | 0 | |
28 | 44 | case t: Int => | |
29 | 45 | t | |
30 | 46 | case _ => | |
31 | 47 | throw("Match error") | |
32 | 48 | } | |
33 | 49 | let newAmount = (currentAmount - providing) | |
34 | 50 | if (((minBillDeposit * 100) > providing)) | |
35 | 51 | then throw((((("The security deposit must be more than " + minBillDepositStr) + ". You set the size: ") + toString((providing / 100))) + ".00")) | |
36 | 52 | else if ((0 > newAmount)) | |
37 | 53 | then throw("Not enough balance") | |
38 | - | else { | |
39 | - | let issue = Issue(("bill for:" + toString((providing / 100))), currentKey, 1, 0, false) | |
40 | - | let id = calculateAssetId(issue) | |
41 | - | $Tuple2([IntegerEntry(currentKey, newAmount), issue, ScriptTransfer(i.caller, 1, id), IntegerEntry(("l_u_" + toBase58String(id)), providing)], unit) | |
42 | - | } | |
54 | + | else if ((size > (currentAmount * exchangeRate))) | |
55 | + | then throw((("The nominal value of the promissory bill exceeds the collateral minimum (" + minBillDepositStr) + ")")) | |
56 | + | else { | |
57 | + | let issue = Issue(("bill for:" + toString((providing / 100))), ((currentKey + ":") + toString(size)), 1, 0, false) | |
58 | + | let id = calculateAssetId(issue) | |
59 | + | $Tuple2([IntegerEntry(currentKey, newAmount), issue, ScriptTransfer(i.caller, 1, id), IntegerEntry(("l_u_" + toBase58String(id)), providing)], unit) | |
60 | + | } | |
43 | 61 | } | |
44 | 62 | ||
45 | 63 | ||
46 | 64 | ||
47 | 65 | @Callable(i) | |
48 | 66 | func deposit () = if ((size(i.payments) == 0)) | |
49 | 67 | then throw("Payment not attached") | |
50 | 68 | else { | |
51 | 69 | let pmt = value(i.payments)[0] | |
52 | 70 | let minDepositStr = match getString(options_addr, "min_deposit") { | |
53 | 71 | case _: Unit => | |
54 | 72 | "0" | |
55 | 73 | case x: String => | |
56 | 74 | x | |
57 | 75 | case _ => | |
58 | 76 | throw("Match error") | |
59 | 77 | } | |
60 | 78 | let minDeposit = match parseInt(split(minDepositStr, ".")[0]) { | |
61 | 79 | case _: Unit => | |
62 | 80 | 0 | |
63 | 81 | case t: Int => | |
64 | 82 | t | |
65 | 83 | case _ => | |
66 | 84 | throw("Match error") | |
67 | 85 | } | |
68 | 86 | if ((pmt.assetId != tUSD)) | |
69 | 87 | then throw("holded payment not tUSD") | |
70 | 88 | else if (((minDeposit * 100) > pmt.amount)) | |
71 | 89 | then throw((((("You have set the deposit amount to " + toString((pmt.amount / 100))) + ".00, which is less than the minimum (") + minDepositStr) + ")")) | |
72 | 90 | else { | |
73 | 91 | let currentKey = toBase58String(i.caller.bytes) | |
74 | 92 | let currentAmount = match getInteger(this, currentKey) { | |
75 | 93 | case a: Int => | |
76 | 94 | a | |
77 | 95 | case _ => | |
78 | 96 | 0 | |
79 | 97 | } | |
80 | 98 | let newAmount = (currentAmount + pmt.amount) | |
81 | 99 | [IntegerEntry(currentKey, newAmount)] | |
82 | 100 | } | |
83 | 101 | } | |
84 | 102 | ||
85 | 103 | ||
86 | 104 | ||
87 | 105 | @Callable(i) | |
88 | 106 | func withdraw (amount) = { | |
89 | 107 | let currentKey = toBase58String(i.caller.bytes) | |
90 | 108 | let currentAmount = match getInteger(this, currentKey) { | |
91 | 109 | case a: Int => | |
92 | 110 | a | |
93 | 111 | case _ => | |
94 | 112 | 0 | |
95 | 113 | } | |
96 | 114 | let newAmount = (currentAmount - amount) | |
97 | 115 | if ((0 > amount)) | |
98 | 116 | then throw("Can't withdraw negative amount") | |
99 | 117 | else if ((0 > newAmount)) | |
100 | 118 | then throw("Not enough balance") | |
101 | 119 | else $Tuple2([IntegerEntry(currentKey, newAmount), ScriptTransfer(i.caller, amount, tUSD)], unit) | |
102 | 120 | } | |
103 | 121 | ||
104 | 122 | ||
105 | 123 | ||
106 | 124 | @Callable(i) | |
107 | 125 | func setOptions (opts,vals) = { | |
108 | 126 | let opt_size = size(opts) | |
109 | 127 | if ((100 >= opt_size)) | |
110 | 128 | then { | |
111 | 129 | let adminList = match getString(options_addr, "admin_list") { | |
112 | 130 | case _: Unit => | |
113 | 131 | "unset" | |
114 | 132 | case x: String => | |
115 | 133 | x | |
116 | 134 | case _ => | |
117 | 135 | throw("Match error") | |
118 | 136 | } | |
119 | 137 | func addStringEntry (accum,nextValue) = { | |
120 | - | let $ | |
121 | - | let result = $ | |
122 | - | let j = $ | |
138 | + | let $t052975320 = accum | |
139 | + | let result = $t052975320._1 | |
140 | + | let j = $t052975320._2 | |
123 | 141 | $Tuple2((result :+ IntegerEntry(opts[j], nextValue)), (j + 1)) | |
124 | 142 | } | |
125 | 143 | ||
126 | 144 | let r = { | |
127 | 145 | let $l = vals | |
128 | 146 | let $s = size($l) | |
129 | 147 | let $acc0 = $Tuple2(nil, 0) | |
130 | 148 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
131 | 149 | then $a | |
132 | 150 | else addStringEntry($a, $l[$i]) | |
133 | 151 | ||
134 | 152 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
135 | 153 | then $a | |
136 | 154 | else throw("List size exceeds 100") | |
137 | 155 | ||
138 | 156 | $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) | |
139 | 157 | } | |
140 | 158 | let callerAddressStr = toString(i.caller) | |
141 | 159 | if ((adminList != "unset")) | |
142 | 160 | then { | |
143 | 161 | let test = getString(addressFromStringValue(adminList), callerAddressStr) | |
144 | 162 | let isAdmin = match test { | |
145 | 163 | case x: String => | |
146 | 164 | x | |
147 | 165 | case _: Unit => | |
148 | 166 | "no admin" | |
149 | 167 | case _ => | |
150 | 168 | throw("Match error") | |
151 | 169 | } | |
152 | 170 | func add_elm (options) = { | |
153 | 171 | let opt = split(options, "|") | |
154 | 172 | StringEntry(opt[0], opt[1]) | |
155 | 173 | } | |
156 | 174 | ||
157 | 175 | if ((isAdmin != "no admin")) | |
158 | 176 | then r | |
159 | 177 | else throw((((((("You not admin: " + adminList) + ", isAdmin: ") + isAdmin) + ", callerAddressStr: ") + callerAddressStr) + ", ")) | |
160 | 178 | } | |
161 | 179 | else throw("Unset admin list") | |
162 | 180 | } | |
163 | 181 | else throw("The number of list elements must not exceed 100") | |
164 | 182 | } | |
165 | 183 | ||
166 | 184 | ||
167 | 185 | ||
168 | 186 | @Callable(i) | |
169 | 187 | func setOption (variable,value) = { | |
170 | 188 | let adminList = match getString(options_addr, "admin_list") { | |
171 | 189 | case _: Unit => | |
172 | 190 | "unset" | |
173 | 191 | case x: String => | |
174 | 192 | x | |
175 | 193 | case _ => | |
176 | 194 | throw("Match error") | |
177 | 195 | } | |
178 | 196 | let callerAddressStr = toString(i.caller) | |
179 | 197 | if ((adminList != "unset")) | |
180 | 198 | then { | |
181 | 199 | let test = getString(addressFromStringValue(adminList), callerAddressStr) | |
182 | 200 | let isAdmin = match test { | |
183 | 201 | case x: String => | |
184 | 202 | x | |
185 | 203 | case _: Unit => | |
186 | 204 | "no admin" | |
187 | 205 | case _ => | |
188 | 206 | throw("Match error") | |
189 | 207 | } | |
190 | 208 | if ((isAdmin != "no admin")) | |
191 | 209 | then $Tuple2([StringEntry(variable, value)], unit) | |
192 | 210 | else throw((((((("You not admin: " + adminList) + ", isAdmin: ") + isAdmin) + ", callerAddressStr: ") + callerAddressStr) + ", ")) | |
193 | 211 | } | |
194 | 212 | else throw("Unset admin list") | |
195 | 213 | } | |
196 | 214 | ||
197 | 215 | ||
198 | 216 | ||
199 | 217 | @Callable(i) | |
200 | 218 | func delOption (variable) = { | |
201 | 219 | let adminList = match getString(options_addr, "admin_list") { | |
202 | 220 | case _: Unit => | |
203 | 221 | "unset" | |
204 | 222 | case x: String => | |
205 | 223 | x | |
206 | 224 | case _ => | |
207 | 225 | throw("Match error") | |
208 | 226 | } | |
209 | 227 | let callerAddressStr = toString(i.caller) | |
210 | 228 | if ((adminList != "unset")) | |
211 | 229 | then { | |
212 | 230 | let test = getString(addressFromStringValue(adminList), callerAddressStr) | |
213 | 231 | let isAdmin = match test { | |
214 | 232 | case x: String => | |
215 | 233 | x | |
216 | 234 | case _: Unit => | |
217 | 235 | "no admin" | |
218 | 236 | case _ => | |
219 | 237 | throw("Match error") | |
220 | 238 | } | |
221 | 239 | if ((isAdmin != "no admin")) | |
222 | 240 | then $Tuple2([DeleteEntry(variable)], unit) | |
223 | 241 | else throw((((((("You not admin: " + adminList) + ", isAdmin: ") + isAdmin) + ", callerAddressStr: ") + callerAddressStr) + ", ")) | |
224 | 242 | } | |
225 | 243 | else throw("Unset admin list") | |
226 | 244 | } | |
227 | 245 | ||
228 | 246 | ||
229 | 247 | @Verifier(tx) | |
230 | 248 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
231 | 249 |
github/deemru/w8io/169f3d6 48.79 ms ◑