tx · 858Zc2iC4MYwYNvoTskD1obKbKAp2GdUkRBFVoN57zj5 3ND7UBeLXURPCyk2YE4hw5ZSdf1s57ESV5w: -0.05000000 Waves 2023.05.15 20:53 [2579409] smart account 3ND7UBeLXURPCyk2YE4hw5ZSdf1s57ESV5w > SELF 0.00000000 Waves
{ "type": 13, "id": "858Zc2iC4MYwYNvoTskD1obKbKAp2GdUkRBFVoN57zj5", "fee": 5000000, "feeAssetId": null, "timestamp": 1684173307306, "version": 2, "chainId": 84, "sender": "3ND7UBeLXURPCyk2YE4hw5ZSdf1s57ESV5w", "senderPublicKey": "AFRE539bYXBjHK1VKPamkLoKRy1cVSUKwZFSKkYH1qvb", "proofs": [ "3UsHfqH6LXVxmwmveZkbLFzvdcWZrGaUEBbVHwvNYSxBirf3RSPm8T8793bC9abUd9wsLRBr3mGK79dJckRZ7bVs" ], "script": "base64:BgK7BAgCEgMKAQgSAwoBARIDCgEIEgMKAQgiA1NFUCIEam9pbiICYXIiDmtleUluaXRpYWxpemVkIhVrZXlDb29yZGluYXRvckFkZHJlc3MiEmtleVZlcmlmaWVyQWRkcmVzcyIMa2V5RWFzdEFzc2V0IglrZXlTaWduZWQiCF9hZGRyZXNzIgVfdHhJZCIRa2V5UHJvdG9jb2xBY3RpdmUiDWlzSW5pdGlhbGl6ZWQiD211c3RJbml0aWFsaXplZCISbXVzdE5vdEluaXRpYWxpemVkIghtdXN0U2VsZiIBaSILY29vcmRpbmF0b3IiCHZlcmlmaWVyIgckbWF0Y2gwIgFzIg9nZXRFYXN0QXNzZXRTdHIiDGdldEVhc3RBc3NldCIIaXNBY3RpdmUiCm11c3RBY3RpdmUiDGNoZWNrQWRkcmVzcyIHYWRkcmVzcyIKQVNTRVRfTkFNRSILREVTQ1JJUFRJT04iEWtleUFsbG93ZWRBZGRyZXNzIhBpc0FkZHJlc3NFbmFibGVkIhJtdXN0QWxsb3dlZEFkZHJlc3MiEGNhbGxlckFkZHJlc3NTdHIiCWlzRW5hYmxlZCITY2h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Zi4BAVABAVEABAFzCQEBcgADCQABAgUBcwIGU3RyaW5nBAF6BQFzCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFAXoJAQFoAgkApQgBBQR0aGlzCQDYBAEIBQFQAmlkBwkA9AMDCAUBUAlib2R5Qnl0ZXMJAJEDAggFAVAGcHJvb2ZzAAAIBQFQD3NlbmRlclB1YmxpY0tleSxM6eI=", "height": 2579409, "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 keyEastAsset () = join(["%s", "eastAsset"]) | |
19 | + | ||
20 | + | ||
21 | + | func keySigned (_address,_txId) = join(["%s%s%s", "signed", _address, _txId]) | |
22 | + | ||
23 | + | ||
24 | + | func keyProtocolActive () = join(["%s", "protocolActive"]) | |
25 | + | ||
26 | + | ||
27 | + | func isInitialized () = valueOrElse(getBoolean(this, keyInitialized()), false) | |
28 | + | ||
29 | + | ||
30 | + | func mustInitialized () = if (!(isInitialized())) | |
31 | + | then throw("Not initialized") | |
32 | + | else unit | |
33 | + | ||
34 | + | ||
35 | + | func mustNotInitialized () = if (isInitialized()) | |
36 | + | then throw("Already initialized") | |
37 | + | else unit | |
38 | + | ||
39 | + | ||
40 | + | func mustSelf (i) = if ((i.caller != this)) | |
41 | + | then throw("Only self invocation allowed.") | |
42 | + | else unit | |
43 | + | ||
44 | + | ||
45 | + | func coordinator () = addressFromStringValue(valueOrErrorMessage(getString(keyCoordinatorAddress()), "Coordinator is not set")) | |
46 | + | ||
47 | + | ||
48 | + | func verifier () = match getString(keyCoordinatorAddress()) { | |
49 | + | case s: String => | |
50 | + | getString(addressFromStringValue(s), keyVerifierAddress()) | |
51 | + | case _: Unit => | |
52 | + | unit | |
53 | + | case _ => | |
54 | + | throw("Match error") | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | func getEastAssetStr () = valueOrErrorMessage(getString(coordinator(), keyEastAsset()), "East asset is not set") | |
59 | + | ||
60 | + | ||
61 | + | func getEastAsset () = fromBase58String(getEastAssetStr()) | |
62 | + | ||
63 | + | ||
64 | + | func isActive () = valueOrElse(getBoolean(coordinator(), keyProtocolActive()), false) | |
65 | + | ||
66 | + | ||
67 | + | func mustActive () = if (if (!(isActive())) | |
68 | + | then true | |
69 | + | else !(isInitialized())) | |
70 | + | then throw("Protocol is disabled. Please contact support.") | |
71 | + | else unit | |
72 | + | ||
73 | + | ||
74 | + | func checkAddress (_address) = match addressFromString(_address) { | |
75 | + | case address: Address => | |
76 | + | true | |
77 | + | case _: Unit => | |
78 | + | throw("Invalid address") | |
79 | + | case _ => | |
80 | + | throw("Match error") | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | let ASSET_NAME = "EAST" | |
85 | + | ||
86 | + | let DESCRIPTION = "EAST — Enterprise Algorithmic Stable Token built on the Waves Enterprise and Waves mainnet. Ensured both by significant overcollateralization and well-defined liquidation mechanisms. https://east.finance/" | |
87 | + | ||
88 | + | func keyAllowedAddress (_address) = join(["%s%s", "allowedAddress", _address]) | |
89 | + | ||
90 | + | ||
91 | + | func isAddressEnabled (_address) = valueOrElse(getBoolean(this, keyAllowedAddress(_address)), false) | |
92 | + | ||
93 | + | ||
94 | + | func mustAllowedAddress (i) = { | |
95 | + | let callerAddressStr = toBase58String(i.caller.bytes) | |
96 | + | let isEnabled = isAddressEnabled(callerAddressStr) | |
97 | + | if (isEnabled) | |
98 | + | then unit | |
99 | + | else throw(((("Unknown caller address. " + toString(i.caller)) + " ") + toBase58String(i.caller.bytes))) | |
100 | + | } | |
101 | + | ||
102 | + | ||
103 | + | func checkAddressEnabled (_address) = if (isAddressEnabled(_address)) | |
104 | + | then unit | |
105 | + | else throw("Address already disabled") | |
106 | + | ||
107 | + | ||
108 | + | func checkAddressDisabled (_address) = if (isAddressEnabled(_address)) | |
109 | + | then throw("Address already enabled") | |
110 | + | else unit | |
111 | + | ||
112 | + | ||
113 | + | @Callable(i) | |
114 | + | func initialize (_coordinatorAddress) = { | |
115 | + | let checks = [mustNotInitialized(), checkAddress(_coordinatorAddress)] | |
116 | + | if ((checks == checks)) | |
117 | + | then { | |
118 | + | let east = Issue(ASSET_NAME, DESCRIPTION, 0, 6, true, unit, 0) | |
119 | + | let eastAssetId = calculateAssetId(east) | |
120 | + | [StringEntry(keyCoordinatorAddress(), _coordinatorAddress), StringEntry(keyEastAsset(), toBase58String(eastAssetId)), BooleanEntry(keyInitialized(), true), east] | |
121 | + | } | |
122 | + | else throw("Strict value is not equal to itself.") | |
123 | + | } | |
124 | + | ||
125 | + | ||
126 | + | ||
127 | + | @Callable(i) | |
128 | + | func issue (_eastAmount) = { | |
129 | + | let checks = [mustActive(), mustAllowedAddress(i)] | |
130 | + | if ((checks == checks)) | |
131 | + | then { | |
132 | + | let eastAsset = getEastAsset() | |
133 | + | [Reissue(eastAsset, _eastAmount, true), ScriptTransfer(i.caller, _eastAmount, eastAsset)] | |
134 | + | } | |
135 | + | else throw("Strict value is not equal to itself.") | |
136 | + | } | |
137 | + | ||
138 | + | ||
139 | + | ||
140 | + | @Callable(i) | |
141 | + | func addAddress (_address) = { | |
142 | + | let checks = [mustInitialized(), mustSelf(i), checkAddress(_address), checkAddressDisabled(_address)] | |
143 | + | if ((checks == checks)) | |
144 | + | then [BooleanEntry(keyAllowedAddress(_address), true)] | |
145 | + | else throw("Strict value is not equal to itself.") | |
146 | + | } | |
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | @Callable(i) | |
151 | + | func removeAddress (_address) = { | |
152 | + | let checks = [mustInitialized(), mustSelf(i), checkAddress(_address), checkAddressEnabled(_address)] | |
153 | + | if ((checks == checks)) | |
154 | + | then [BooleanEntry(keyAllowedAddress(_address), false)] | |
155 | + | else throw("Strict value is not equal to itself.") | |
156 | + | } | |
157 | + | ||
158 | + | ||
159 | + | @Verifier(tx) | |
160 | + | func verify () = match verifier() { | |
161 | + | case address: String => | |
162 | + | valueOrElse(getBoolean(addressFromStringValue(address), keySigned(toString(this), toBase58String(tx.id))), false) | |
163 | + | case _ => | |
164 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
165 | + | } | |
166 | + |
github/deemru/w8io/169f3d6 27.10 ms ◑