tx · 6DjdRzKT3J9zzwgU9hnQ7MgKTVUbUnzUiKUTEQqeBaLT

3Myt92JAGj5wUjb7hTStuhuENUzJrNU944o:  -0.05000000 Waves

2023.07.12 15:24 [2662676] smart account 3Myt92JAGj5wUjb7hTStuhuENUzJrNU944o > SELF 0.00000000 Waves

{ "type": 13, "id": "6DjdRzKT3J9zzwgU9hnQ7MgKTVUbUnzUiKUTEQqeBaLT", "fee": 5000000, "feeAssetId": null, "timestamp": 1689164703031, "version": 2, "chainId": 84, "sender": "3Myt92JAGj5wUjb7hTStuhuENUzJrNU944o", "senderPublicKey": "BHixQkDWX7RRP7YVsZDgeKjhLBtqar6uUSQCRnyLZ6z1", "proofs": [ "2Cr26Lo6cbHDaWK9G51m6b1Tbm5RVzZqeTQKFncV2Vn2y3XoYiZiXyJiHcdrhwdU6mDejFskFErL2ybe7RDt1DMc" ], "script": "base64:BgKvBAgCEgQKAggIEgAiA1NFUCIEam9pbiICYXIiDmtleUluaXRpYWxpemVkIhVrZXlDb29yZGluYXRvckFkZHJlc3MiEmtleVZlcmlmaWVyQWRkcmVzcyIMa2V5RWFzdEFzc2V0IglrZXlTaWduZWQiCF9hZGRyZXNzIgVfdHhJZCIRa2V5UHJvdG9jb2xBY3RpdmUiDWlzSW5pdGlhbGl6ZWQiEm11c3ROb3RJbml0aWFsaXplZCIIbXVzdFNlbGYiAWkiC2Nvb3JkaW5hdG9yIgh2ZXJpZmllciIHJG1hdGNoMCIBcyIPZ2V0RWFzdEFzc2V0U3RyIgxnZXRFYXN0QXNzZXQiCGlzQWN0aXZlIgptdXN0QWN0aXZlIhJtdXN0SGF2ZU9uZVBheW1lbnQiFGdldEFzc2V0SWRGcm9tU3RyaW5nIgdhc3NldElkIgdpc0Fzc2V0IgFwIg1jaGVja2luZ0Fzc2V0IgJidiIEbmFtZSIHJG1hdGNoMSIFYXNzZXQiA2VyciIMcGF5bWVudEFzc2V0IgxjaGVja0FkZHJlc3MiB2FkZHJlc3MiD2tleU9sZEVhc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AAQIFAXICBFVuaXQJAAIBAg9JbnZhbGlkIGFkZHJlc3MJAAIBAgtNYXRjaCBlcnJvcgEBTAAJAQFiAQkAzAgCAgIlcwkAzAgCAgxvbGRFYXN0QXNzZXQFA25pbAEBTQAJANkEAQkBEUBleHRyTmF0aXZlKDEwNTgpAQkBAUwAAgFvAQppbml0aWFsaXplAgFOAU8EAVAJAMwIAgkBAW4BBQFvCQDMCAIJAQFtAAkAzAgCCQEBSgEFAU4FA25pbAMJAAACBQFQBQFQCQDMCAIJAQtTdHJpbmdFbnRyeQIJAQFlAAUBTgkAzAgCCQELU3RyaW5nRW50cnkCCQEBTAAFAU8JAMwIAgkBDEJvb2xlYW5FbnRyeQIJAQFkAAYFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFvAQhleGNoYW5nZQAEAVEJAQF1AAQBUgkBAU0ABAFTCQCRAwIIBQFvCHBheW1lbnRzAAAEAVAJAMwIAgkBAXcACQDMCAIJAQF4AQUBbwkAzAgCCQEBQQIFAVMFAVIFA25pbAMJAAACBQFQBQFQBAFUCQBpAggFAVMGYW1vdW50AGQJAMwIAgkBBEJ1cm4CBQFSCAUBUwZhbW91bnQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAW8GY2FsbGVyBQFUBQFRBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAVUBAVYABAFyCQEBcQADCQABAgUBcgIGU3RyaW5nBAFLBQFyCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFAUsJAQFoAgkApQgBBQR0aGlzCQDYBAEIBQFVAmlkBwkA9AMDCAUBVQlib2R5Qnl0ZXMJAJEDAggFAVUGcHJvb2ZzAAAIBQFVD3NlbmRlclB1YmxpY0tleWta1f8=", "height": 2662676, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
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 mustNotInitialized () = if (isInitialized())
31+ then throw("Already initialized")
32+ else unit
33+
34+
35+func mustSelf (i) = if ((i.caller != this))
36+ then throw("Only self invocation allowed.")
37+ else unit
38+
39+
40+func coordinator () = addressFromStringValue(valueOrErrorMessage(getString(keyCoordinatorAddress()), "Coordinator is not set"))
41+
42+
43+func verifier () = match getString(keyCoordinatorAddress()) {
44+ case s: String =>
45+ getString(addressFromStringValue(s), keyVerifierAddress())
46+ case _: Unit =>
47+ unit
48+ case _ =>
49+ throw("Match error")
50+}
51+
52+
53+func getEastAssetStr () = valueOrErrorMessage(getString(coordinator(), keyEastAsset()), "East asset is not set")
54+
55+
56+func getEastAsset () = fromBase58String(getEastAssetStr())
57+
58+
59+func isActive () = valueOrElse(getBoolean(coordinator(), keyProtocolActive()), false)
60+
61+
62+func mustActive () = if (if (!(isActive()))
63+ then true
64+ else !(isInitialized()))
65+ then throw("Protocol is disabled. Please contact support.")
66+ else unit
67+
68+
69+func mustHaveOnePayment (i) = if ((size(i.payments) != 1))
70+ then throw("Must have one payment.")
71+ else unit
72+
73+
74+func getAssetIdFromString (assetId) = if ((assetId == "WAVES"))
75+ then unit
76+ else fromBase58String(assetId)
77+
78+
79+func isAsset (p,checkingAsset) = {
80+ let assetId = match checkingAsset {
81+ case bv: ByteVector =>
82+ bv
83+ case s: String =>
84+ getAssetIdFromString(s)
85+ case _: Unit =>
86+ unit
87+ case _ =>
88+ throw("Match error")
89+ }
90+ match assetId {
91+ case bv: ByteVector =>
92+ let name = match assetInfo(bv) {
93+ case asset: Asset =>
94+ asset.name
95+ case _: Unit =>
96+ throw(("Can't find asset " + toBase58String(bv)))
97+ case _ =>
98+ throw("Match error")
99+ }
100+ let err = throw(("Attached payment asset is not " + name))
101+ match p.assetId {
102+ case paymentAsset: ByteVector =>
103+ if ((paymentAsset != assetId))
104+ then err
105+ else unit
106+ case _: Unit =>
107+ err
108+ case _ =>
109+ throw("Match error")
110+ }
111+ case _: Unit =>
112+ if ((p.assetId != unit))
113+ then throw("Attached payment asset is not WAVES")
114+ else unit
115+ case _ =>
116+ throw("Match error")
117+ }
118+ }
119+
120+
121+func checkAddress (_address) = match addressFromString(_address) {
122+ case address: Address =>
123+ true
124+ case _: Unit =>
125+ throw("Invalid address")
126+ case _ =>
127+ throw("Match error")
128+}
129+
130+
131+func keyOldEastAsset () = join(["%s", "oldEastAsset"])
132+
133+
134+func getOldEastAsset () = fromBase58String(getStringValue(keyOldEastAsset()))
135+
136+
137+@Callable(i)
138+func initialize (_coordinatorAddress,_oldEastAsset) = {
139+ let checks = [mustSelf(i), mustNotInitialized(), checkAddress(_coordinatorAddress)]
140+ if ((checks == checks))
141+ then [StringEntry(keyCoordinatorAddress(), _coordinatorAddress), StringEntry(keyOldEastAsset(), _oldEastAsset), BooleanEntry(keyInitialized(), true)]
142+ else throw("Strict value is not equal to itself.")
143+ }
144+
145+
146+
147+@Callable(i)
148+func exchange () = {
149+ let eastAsset = getEastAsset()
150+ let oldEastAsset = getOldEastAsset()
151+ let payment = i.payments[0]
152+ let checks = [mustActive(), mustHaveOnePayment(i), isAsset(payment, oldEastAsset)]
153+ if ((checks == checks))
154+ then {
155+ let amount = (payment.amount / 100)
156+[Burn(oldEastAsset, payment.amount), ScriptTransfer(i.caller, amount, eastAsset)]
157+ }
158+ else throw("Strict value is not equal to itself.")
159+ }
160+
161+
162+@Verifier(tx)
163+func verify () = match verifier() {
164+ case address: String =>
165+ valueOrElse(getBoolean(addressFromStringValue(address), keySigned(toString(this), toBase58String(tx.id))), false)
166+ case _ =>
167+ sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
168+}
169+

github/deemru/w8io/026f985 
17.36 ms