tx · E3cD8Fi9AHwT2FJKuVwYNgBzuf35EJxrbkpJUXo3FYXG 3N3VAa6qsUMLQSe8tj4ERnzGeD5WaTx2x8P: -0.05000000 Waves 2023.07.12 15:24 [2662676] smart account 3N3VAa6qsUMLQSe8tj4ERnzGeD5WaTx2x8P > SELF 0.00000000 Waves
{ "type": 13, "id": "E3cD8Fi9AHwT2FJKuVwYNgBzuf35EJxrbkpJUXo3FYXG", "fee": 5000000, "feeAssetId": null, "timestamp": 1689164702981, "version": 2, "chainId": 84, "sender": "3N3VAa6qsUMLQSe8tj4ERnzGeD5WaTx2x8P", "senderPublicKey": "AN4eDeEgqx5GZE5mQtJeYEzomfYXDaUqx4CukaodPxF1", "proofs": [ "qSv83pWY8hisGTrKFMyNfZJF3Uw35kJ8yDPFmdywG3VqFUTCMQgrwrJR4WBLsRi2hLoUFiZ6dbPSawJctPyxYCM" ], "script": "base64:BgKdAwgCEgQKAggIEgQKAggIIgNTRVAiBGpvaW4iAmFyIg5rZXlJbml0aWFsaXplZCIVa2V5Q29vcmRpbmF0b3JBZGRyZXNzIhJrZXlWZXJpZmllckFkZHJlc3MiCWtleVNpZ25lZCIIX2FkZHJlc3MiBV90eElkIg1pc0luaXRpYWxpemVkIhJtdXN0Tm90SW5pdGlhbGl6ZWQiCG11c3RTZWxmIgFpIgh2ZXJpZmllciIHJG1hdGNoMCIBcyIMY2hlY2tBZGRyZXNzIgdhZGRyZXNzIgljaGVja1R4SWQiA19pZCIJa2V5QWRtaW5zIgprZXlBcHByb3ZlIgxfY29vcmRpbmF0b3IiB19hZG1pbnMiBmNoZWNrcyIGYWRtaW5zIgRmb2xkIgh2ZXJpZmllZCIFYWRtaW4iAiRsIgIkcyIFJGFjYzAiBSRmMF8xIgIkYSICJGkiBSRmMF8yIgphZG1pbnNMaXN0IgdhcHByb3ZlIgxhcHByb3ZlQ291bnQiCWFwcHJvdmVCeSIGc3RhdHVzIgJ0eCIGdmVyaWZ5DgABYQICX18BAWIBAWMJALkJAgUB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QCsAgIFAUwFAWEFAUMEAU8DCQBmAgUBTQkAaQIJAJADAQUBSwACBgcJAMwIAgkBC1N0cmluZ0VudHJ5AgkBAXYCBQFoBQFpBQFOCQDMCAIJAQxCb29sZWFuRW50cnkCCQEBZwIFAWgFAWkFAU8FA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgEBUAEBUQAEAW8JAQFuAAMJAAECBQFvAgZTdHJpbmcEAXIFAW8JAQt2YWx1ZU9yRWxzZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQUBcgkBAWcCCQClCAEFBHRoaXMJANgEAQgFAVACaWQHCQD0AwMIBQFQCWJvZHlCeXRlcwkAkQMCCAUBUAZwcm9vZnMAAAgFAVAPc2VuZGVyUHVibGljS2V5En0tTw==", "height": 2662676, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | func join (ar) = makeString(ar, SEP) | |
7 | + | ||
8 | + | ||
9 | + | func keyInitialized () = join(["%s", "initialized"]) | |
10 | + | ||
11 | + | ||
12 | + | func keyCoordinatorAddress () = join(["%s", "coordinatorAddress"]) | |
13 | + | ||
14 | + | ||
15 | + | func keyVerifierAddress () = join(["%s", "verifierAddress"]) | |
16 | + | ||
17 | + | ||
18 | + | func keySigned (_address,_txId) = join(["%s%s%s", "signed", _address, _txId]) | |
19 | + | ||
20 | + | ||
21 | + | func isInitialized () = valueOrElse(getBoolean(this, keyInitialized()), false) | |
22 | + | ||
23 | + | ||
24 | + | func mustNotInitialized () = if (isInitialized()) | |
25 | + | then throw("Already initialized") | |
26 | + | else unit | |
27 | + | ||
28 | + | ||
29 | + | func mustSelf (i) = if ((i.caller != this)) | |
30 | + | then throw("Only self invocation allowed.") | |
31 | + | else unit | |
32 | + | ||
33 | + | ||
34 | + | func verifier () = match getString(keyCoordinatorAddress()) { | |
35 | + | case s: String => | |
36 | + | getString(addressFromStringValue(s), keyVerifierAddress()) | |
37 | + | case _: Unit => | |
38 | + | unit | |
39 | + | case _ => | |
40 | + | throw("Match error") | |
41 | + | } | |
42 | + | ||
43 | + | ||
44 | + | func checkAddress (_address) = match addressFromString(_address) { | |
45 | + | case address: Address => | |
46 | + | true | |
47 | + | case _: Unit => | |
48 | + | throw("Invalid address") | |
49 | + | case _ => | |
50 | + | throw("Match error") | |
51 | + | } | |
52 | + | ||
53 | + | ||
54 | + | func checkTxId (_id) = (size(fromBase58String(_id)) == 32) | |
55 | + | ||
56 | + | ||
57 | + | func keyAdmins () = join(["%s", "admins"]) | |
58 | + | ||
59 | + | ||
60 | + | func keyApprove (_address,_txId) = join(["%s%s%s", "approve", _address, _txId]) | |
61 | + | ||
62 | + | ||
63 | + | @Callable(i) | |
64 | + | func initialize (_coordinator,_admins) = { | |
65 | + | let checks = [mustNotInitialized(), mustSelf(i)] | |
66 | + | if ((checks == checks)) | |
67 | + | then { | |
68 | + | let admins = split(_admins, ",") | |
69 | + | if ((size(admins) > 10)) | |
70 | + | then throw("Too many admins") | |
71 | + | else if ((1 > size(admins))) | |
72 | + | then throw("At least 1 admin needed") | |
73 | + | else { | |
74 | + | func fold (verified,admin) = if (!(verified)) | |
75 | + | then verified | |
76 | + | else if (checkAddress(admin)) | |
77 | + | then (admin != toString(this)) | |
78 | + | else false | |
79 | + | ||
80 | + | if (({ | |
81 | + | let $l = admins | |
82 | + | let $s = size($l) | |
83 | + | let $acc0 = true | |
84 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
85 | + | then $a | |
86 | + | else fold($a, $l[$i]) | |
87 | + | ||
88 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
89 | + | then $a | |
90 | + | else throw("List size exceeds 10") | |
91 | + | ||
92 | + | $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) | |
93 | + | } == false)) | |
94 | + | then throw(("Admin cannot be this dapp " + toString(this))) | |
95 | + | else [StringEntry(keyVerifierAddress(), toString(this)), StringEntry(keyAdmins(), join(admins)), BooleanEntry(keyInitialized(), true)] | |
96 | + | } | |
97 | + | } | |
98 | + | else throw("Strict value is not equal to itself.") | |
99 | + | } | |
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | @Callable(i) | |
104 | + | func approve (_address,_txId) = { | |
105 | + | let admin = toString(i.caller) | |
106 | + | let admins = getStringValue(keyAdmins()) | |
107 | + | let adminsList = split(admins, SEP) | |
108 | + | if (!(contains(admins, admin))) | |
109 | + | then throw("Not allowed") | |
110 | + | else { | |
111 | + | let checks = [checkAddress(_address), checkTxId(_txId)] | |
112 | + | if ((checks == checks)) | |
113 | + | then { | |
114 | + | let approve = valueOrElse(getString(keyApprove(_address, _txId)), "") | |
115 | + | if (contains(approve, admin)) | |
116 | + | then throw(("Already approved by " + admin)) | |
117 | + | else { | |
118 | + | let approveCount = (1 + (if ((approve == "")) | |
119 | + | then 0 | |
120 | + | else size(split(approve, SEP)))) | |
121 | + | let approveBy = if ((approve == "")) | |
122 | + | then admin | |
123 | + | else ((approve + SEP) + admin) | |
124 | + | let status = if ((approveCount > (size(adminsList) / 2))) | |
125 | + | then true | |
126 | + | else false | |
127 | + | [StringEntry(keyApprove(_address, _txId), approveBy), BooleanEntry(keySigned(_address, _txId), status)] | |
128 | + | } | |
129 | + | } | |
130 | + | else throw("Strict value is not equal to itself.") | |
131 | + | } | |
132 | + | } | |
133 | + | ||
134 | + | ||
135 | + | @Verifier(tx) | |
136 | + | func verify () = match verifier() { | |
137 | + | case address: String => | |
138 | + | valueOrElse(getBoolean(addressFromStringValue(address), keySigned(toString(this), toBase58String(tx.id))), false) | |
139 | + | case _ => | |
140 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
141 | + | } | |
142 | + |
github/deemru/w8io/026f985 16.37 ms ◑