tx · FnMUnCPyUqRxPNPnDYcfYUiJmo8j6oYcqEtz8kDvQsxK 3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33: -0.01300000 Waves 2023.05.02 09:51 [2559807] smart account 3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33 > SELF 0.00000000 Waves
{ "type": 13, "id": "FnMUnCPyUqRxPNPnDYcfYUiJmo8j6oYcqEtz8kDvQsxK", "fee": 1300000, "feeAssetId": null, "timestamp": 1683010344938, "version": 2, "chainId": 84, "sender": "3N65ziw5oaWWQHthPW5jzsh9VxjYxHwpv33", "senderPublicKey": "5yoY2Atq5TS6YzXkDHGig1DJdaYnWskuGToqK61rQWQd", "proofs": [ "4zMP83QWgQxacfZRAY3mp3ezL6hHViGGtrMVTugwT56YNPdcSYyCbeLBM6RZNQVFbd6fMA6A2qcZkQLi6V2tVYux" ], "script": "base64:BgIECAISAA0BE2tleUludmVzdFd4WHRuRGVsYXkAAhMlX19pbnZlc3RXeFh0bkRlbGF5ARdrZXlJbnZlc3RXeFh0bkFtb3VudFh0bgACFyVfX2ludmVzdFd4WHRuQW1vdW50WHRuAQxrZXlXeFh0blBvb2wAAgwlX193eFh0blBvb2wBDWtleVh0bkFzc2V0SWQAAg0lX194dG5Bc3NldElkAQprZXlXeFh0bkxwAAIKJV9fd3hYdG5McAEOa2V5THBUb0FkZHJlc3MAAg4lX19scFRvQWRkcmVzcwETa2V5TWFuYWdlclB1YmxpY0tleQACFCVzX19tYW5hZ2VyUHVibGljS2V5ARZrZXlNYW5hZ2VyVmF1bHRBZGRyZXNzAAIXJXNfX21hbmFnZXJWYXVsdEFkZHJlc3MBGGtleUludmVzdFd4WHRuTGFzdEhlaWdodAACGCVfX2ludmVzdFd4WHRuTGFzdEhlaWdodAEXZ2V0TWFuYWdlckFkZHJlc3NPckZhaWwACQERQGV4dHJOYXRpdmUoMTA2MikBCQERQGV4dHJOYXRpdmUoMTA1OCkBCQEWa2V5TWFuYWdlclZhdWx0QWRkcmVzcw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pY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABA90YXJnZXRQdWJsaWNLZXkEByRtYXRjaDAJARZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJwawUHJG1hdGNoMAUCcGsDCQABAgUHJG1hdGNoMAIEVW5pdAgFAnR4D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXkoqmr3", "height": 2559807, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6wRM5vehNqyUqgQ2gVcQSKTgMW3bJymqw4xiyiuh49w2 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
22 | 22 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
23 | 23 | ||
24 | 24 | ||
25 | - | func | |
25 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func keyInvestWxXtnLastHeight () = "%__investWxXtnLastHeight" | |
29 | 29 | ||
30 | 30 | ||
31 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
32 | - | case s: String => | |
33 | - | fromBase58String(s) | |
34 | - | case _: Unit => | |
35 | - | unit | |
36 | - | case _ => | |
37 | - | throw("Match error") | |
38 | - | } | |
31 | + | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
39 | 32 | ||
40 | 33 | ||
41 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
42 | - | case s: String => | |
43 | - | fromBase58String(s) | |
44 | - | case _: Unit => | |
45 | - | unit | |
46 | - | case _ => | |
47 | - | throw("Match error") | |
48 | - | } | |
34 | + | func managerPublicKeyOrUnit () = { | |
35 | + | let managerVaultAddress = getManagerAddressOrFail() | |
36 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
37 | + | case s: String => | |
38 | + | fromBase58String(s) | |
39 | + | case _: Unit => | |
40 | + | unit | |
41 | + | case _ => | |
42 | + | throw("Match error") | |
43 | + | } | |
44 | + | } | |
49 | 45 | ||
50 | 46 | ||
51 | 47 | func throwErr (msg) = throw(makeString(["investor.ride:", msg], " ")) | |
110 | 106 | } | |
111 | 107 | ||
112 | 108 | ||
113 | - | ||
114 | - | @Callable(i) | |
115 | - | func setManager (pendingManagerPublicKey) = { | |
116 | - | let checkCaller = mustManager(i) | |
117 | - | if ((checkCaller == checkCaller)) | |
118 | - | then { | |
119 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
120 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
121 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
122 | - | else throw("Strict value is not equal to itself.") | |
123 | - | } | |
124 | - | else throw("Strict value is not equal to itself.") | |
125 | - | } | |
126 | - | ||
127 | - | ||
128 | - | ||
129 | - | @Callable(i) | |
130 | - | func confirmManager () = { | |
131 | - | let pm = pendingManagerPublicKeyOrUnit() | |
132 | - | let hasPM = if (isDefined(pm)) | |
133 | - | then true | |
134 | - | else throw("No pending manager") | |
135 | - | if ((hasPM == hasPM)) | |
136 | - | then { | |
137 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
138 | - | then true | |
139 | - | else throw("You are not pending manager") | |
140 | - | if ((checkPM == checkPM)) | |
141 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
142 | - | else throw("Strict value is not equal to itself.") | |
143 | - | } | |
144 | - | else throw("Strict value is not equal to itself.") | |
145 | - | } | |
146 | - | ||
147 | - | ||
148 | 109 | @Verifier(tx) | |
149 | 110 | func verify () = { | |
150 | 111 | let targetPublicKey = match managerPublicKeyOrUnit() { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func keyInvestWxXtnDelay () = "%__investWxXtnDelay" | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func keyInvestWxXtnAmountXtn () = "%__investWxXtnAmountXtn" | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func keyWxXtnPool () = "%__wxXtnPool" | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyXtnAssetId () = "%__xtnAssetId" | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyWxXtnLp () = "%__wxXtnLp" | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func keyLpToAddress () = "%__lpToAddress" | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
23 | 23 | ||
24 | 24 | ||
25 | - | func | |
25 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func keyInvestWxXtnLastHeight () = "%__investWxXtnLastHeight" | |
29 | 29 | ||
30 | 30 | ||
31 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
32 | - | case s: String => | |
33 | - | fromBase58String(s) | |
34 | - | case _: Unit => | |
35 | - | unit | |
36 | - | case _ => | |
37 | - | throw("Match error") | |
38 | - | } | |
31 | + | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
39 | 32 | ||
40 | 33 | ||
41 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
42 | - | case s: String => | |
43 | - | fromBase58String(s) | |
44 | - | case _: Unit => | |
45 | - | unit | |
46 | - | case _ => | |
47 | - | throw("Match error") | |
48 | - | } | |
34 | + | func managerPublicKeyOrUnit () = { | |
35 | + | let managerVaultAddress = getManagerAddressOrFail() | |
36 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
37 | + | case s: String => | |
38 | + | fromBase58String(s) | |
39 | + | case _: Unit => | |
40 | + | unit | |
41 | + | case _ => | |
42 | + | throw("Match error") | |
43 | + | } | |
44 | + | } | |
49 | 45 | ||
50 | 46 | ||
51 | 47 | func throwErr (msg) = throw(makeString(["investor.ride:", msg], " ")) | |
52 | 48 | ||
53 | 49 | ||
54 | 50 | func mustManager (i) = { | |
55 | 51 | let pd = throwErr("permission denied") | |
56 | 52 | match managerPublicKeyOrUnit() { | |
57 | 53 | case pk: ByteVector => | |
58 | 54 | if ((i.callerPublicKey == pk)) | |
59 | 55 | then true | |
60 | 56 | else pd | |
61 | 57 | case _: Unit => | |
62 | 58 | if ((i.caller == this)) | |
63 | 59 | then true | |
64 | 60 | else pd | |
65 | 61 | case _ => | |
66 | 62 | throw("Match error") | |
67 | 63 | } | |
68 | 64 | } | |
69 | 65 | ||
70 | 66 | ||
71 | 67 | @Callable(i) | |
72 | 68 | func investWxXtn () = { | |
73 | 69 | let checkCaller = mustManager(i) | |
74 | 70 | if ((checkCaller == checkCaller)) | |
75 | 71 | then { | |
76 | 72 | let lastCall = valueOrElse(getInteger(keyInvestWxXtnLastHeight()), 0) | |
77 | 73 | let delay = getIntegerValue(keyInvestWxXtnDelay()) | |
78 | 74 | let checks = [if ((height > (lastCall + delay))) | |
79 | 75 | then true | |
80 | 76 | else throwErr("wait to invest")] | |
81 | 77 | if ((checks == checks)) | |
82 | 78 | then { | |
83 | 79 | let lpAssetId = fromBase58String(getStringValue(keyWxXtnLp())) | |
84 | 80 | let lpBefore = assetBalance(this, lpAssetId) | |
85 | 81 | if ((lpBefore == lpBefore)) | |
86 | 82 | then { | |
87 | 83 | let inv = invoke(addressFromStringValue(getStringValue(keyWxXtnPool())), "putOneTkn", [0, false], [AttachedPayment(fromBase58String(getStringValue(keyXtnAssetId())), getIntegerValue(keyInvestWxXtnAmountXtn()))]) | |
88 | 84 | if ((inv == inv)) | |
89 | 85 | then { | |
90 | 86 | let lpAfter = assetBalance(this, lpAssetId) | |
91 | 87 | if ((lpAfter == lpAfter)) | |
92 | 88 | then { | |
93 | 89 | let lpGot = (lpAfter - lpBefore) | |
94 | 90 | let notZeroLp = if ((lpGot == 0)) | |
95 | 91 | then throwErr("lp to get is zero") | |
96 | 92 | else unit | |
97 | 93 | if ((notZeroLp == notZeroLp)) | |
98 | 94 | then [IntegerEntry(keyInvestWxXtnLastHeight(), height), ScriptTransfer(addressFromStringValue(getStringValue(keyLpToAddress())), lpGot, lpAssetId)] | |
99 | 95 | else throw("Strict value is not equal to itself.") | |
100 | 96 | } | |
101 | 97 | else throw("Strict value is not equal to itself.") | |
102 | 98 | } | |
103 | 99 | else throw("Strict value is not equal to itself.") | |
104 | 100 | } | |
105 | 101 | else throw("Strict value is not equal to itself.") | |
106 | 102 | } | |
107 | 103 | else throw("Strict value is not equal to itself.") | |
108 | 104 | } | |
109 | 105 | else throw("Strict value is not equal to itself.") | |
110 | 106 | } | |
111 | 107 | ||
112 | 108 | ||
113 | - | ||
114 | - | @Callable(i) | |
115 | - | func setManager (pendingManagerPublicKey) = { | |
116 | - | let checkCaller = mustManager(i) | |
117 | - | if ((checkCaller == checkCaller)) | |
118 | - | then { | |
119 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
120 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
121 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
122 | - | else throw("Strict value is not equal to itself.") | |
123 | - | } | |
124 | - | else throw("Strict value is not equal to itself.") | |
125 | - | } | |
126 | - | ||
127 | - | ||
128 | - | ||
129 | - | @Callable(i) | |
130 | - | func confirmManager () = { | |
131 | - | let pm = pendingManagerPublicKeyOrUnit() | |
132 | - | let hasPM = if (isDefined(pm)) | |
133 | - | then true | |
134 | - | else throw("No pending manager") | |
135 | - | if ((hasPM == hasPM)) | |
136 | - | then { | |
137 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
138 | - | then true | |
139 | - | else throw("You are not pending manager") | |
140 | - | if ((checkPM == checkPM)) | |
141 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
142 | - | else throw("Strict value is not equal to itself.") | |
143 | - | } | |
144 | - | else throw("Strict value is not equal to itself.") | |
145 | - | } | |
146 | - | ||
147 | - | ||
148 | 109 | @Verifier(tx) | |
149 | 110 | func verify () = { | |
150 | 111 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
151 | 112 | case pk: ByteVector => | |
152 | 113 | pk | |
153 | 114 | case _: Unit => | |
154 | 115 | tx.senderPublicKey | |
155 | 116 | case _ => | |
156 | 117 | throw("Match error") | |
157 | 118 | } | |
158 | 119 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
159 | 120 | } | |
160 | 121 |
github/deemru/w8io/169f3d6 27.87 ms ◑