tx · 7bpWDhjCWCfPPE3ABFxMTJ2nGJZiKhmBH82UGDeox8W5 3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5: -0.01300000 Waves 2023.05.02 09:53 [2559809] smart account 3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5 > SELF 0.00000000 Waves
{ "type": 13, "id": "7bpWDhjCWCfPPE3ABFxMTJ2nGJZiKhmBH82UGDeox8W5", "fee": 1300000, "feeAssetId": null, "timestamp": 1683010447109, "version": 2, "chainId": 84, "sender": "3MvXnAcEtL9x3i499UcvTQZPufrT5ZZUEd5", "senderPublicKey": "GSAhb4fdky75LiCZ4p4DDK4rmWpmsgGBg1ZVdtPfmRES", "proofs": [ "2vEab2pS58SPtGHCqSateRHLiWuT3Jmf5huhWGDAxyTtxkFUC1yfF9Qkv6buTLkFwH3NNWexW6jzjtdPxUVhE3o5" ], "script": "base64:BgKuBwgCEgoKCAgIAQEBAQEBEgMKAQgSAwoBCBIFCgMICAESBAoCCAgiA1NFUCITa2V5TWFuYWdlclB1YmxpY0tleSIWa2V5TWFuYWdlclZhdWx0QWRkcmVzcyIXZ2V0TWFuYWdlckFkZHJlc3NPckZhaWwiEGtleVdpdGhkcmF3RGVsYXkiBmFzc2V0QSIGYXNzZXRCIhVrZXlEZXBvc2l0RmVlUGVybWlsbGUiFmtleVdpdGhkcmF3RmVlUGVybWlsbGUiE2tleU1pbkFtb3VudERlcG9zaXQiE2tleUFzc2V0c1BhaXJTdGF0dXMiFGtleU1pbkFtb3VudFdpdGhkcmF3IgprZXlCYWxhbmNlIgt1c2VyQWRkcmVzcyIba2V5VG90YWxGZWVDb2xsZWN0ZWREZXBvc2l0IhRrZXlQcm9jZXNzSW5Qcm9ncmVzcyILaGVpZ2h0SW5LZXkiDmtleVByb2Nlc3NEb25lIhZtYW5hZ2VyUHVibGljS2V5T3JVbml0IhNtYW5hZ2VyVmF1bHRBZGRyZXNzIgckbWF0Y2gwIgFzIgttdXN0TWFuYWdlciIBaSICcGQ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pcHRUcmFuc2ZlcgMIBQF4BmNhbGxlcgUCYWEFAVIFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgF4AQt3aXRoZHJhd0ZlZQIBZgFnBAFKCQEBdwEFAXgDCQAAAgUBSgUBSgQCYWUJAQt2YWx1ZU9yRWxzZQIJAJ8IAQkBAW8CBQFmBQFnAAAEAmFmCQDZBAEJAQV2YWx1ZQEFAWYJAMwIAgkBDEludGVnZXJFbnRyeQIJAQFvAgUBZgUBZwAACQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQF4BmNhbGxlcgUCYWUFAmFmBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAmFnAQJhaAAEAmFpBAF1CQEBcwADCQABAgUBdQIKQnl0ZVZlY3RvcgQBegUBdQUBegMJAAECBQF1AgRVbml0CAUCYWcPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAmFnCWJvZHlCeXRlcwkAkQMCCAUCYWcGcHJvb2ZzAAAFAmFp2xPD2g==", "height": 2559809, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 84gnY6HC6ERQjGTitcx2UbHM8DgAh1LMJJ85xiRB2b6t Next: none Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
7 | 7 | ||
8 | 8 | ||
9 | - | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
9 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
10 | + | ||
11 | + | ||
12 | + | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
10 | 13 | ||
11 | 14 | ||
12 | 15 | func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP) | |
39 | 42 | func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
40 | 43 | ||
41 | 44 | ||
42 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
43 | - | case s: String => | |
44 | - | fromBase58String(s) | |
45 | - | case _: Unit => | |
46 | - | unit | |
47 | - | case _ => | |
48 | - | throw("Match error") | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
53 | - | case s: String => | |
54 | - | fromBase58String(s) | |
55 | - | case _: Unit => | |
56 | - | unit | |
57 | - | case _ => | |
58 | - | throw("Match error") | |
59 | - | } | |
45 | + | func managerPublicKeyOrUnit () = { | |
46 | + | let managerVaultAddress = getManagerAddressOrFail() | |
47 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
48 | + | case s: String => | |
49 | + | fromBase58String(s) | |
50 | + | case _: Unit => | |
51 | + | unit | |
52 | + | case _ => | |
53 | + | throw("Match error") | |
54 | + | } | |
55 | + | } | |
60 | 56 | ||
61 | 57 | ||
62 | 58 | func mustManager (i) = { | |
204 | 200 | } | |
205 | 201 | ||
206 | 202 | ||
207 | - | ||
208 | - | @Callable(i) | |
209 | - | func setManager (pendingManagerPublicKey) = { | |
210 | - | let checkCaller = mustManager(i) | |
211 | - | if ((checkCaller == checkCaller)) | |
212 | - | then { | |
213 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
214 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
215 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
216 | - | else throw("Strict value is not equal to itself.") | |
217 | - | } | |
218 | - | else throw("Strict value is not equal to itself.") | |
219 | - | } | |
220 | - | ||
221 | - | ||
222 | - | ||
223 | - | @Callable(i) | |
224 | - | func confirmManager () = { | |
225 | - | let pm = pendingManagerPublicKeyOrUnit() | |
226 | - | let hasPM = if (isDefined(pm)) | |
227 | - | then true | |
228 | - | else throwErr("No pending manager.") | |
229 | - | if ((hasPM == hasPM)) | |
230 | - | then { | |
231 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
232 | - | then true | |
233 | - | else throwErr("You are not pending manager.") | |
234 | - | if ((checkPM == checkPM)) | |
235 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
236 | - | else throw("Strict value is not equal to itself.") | |
237 | - | } | |
238 | - | else throw("Strict value is not equal to itself.") | |
239 | - | } | |
240 | - | ||
241 | - | ||
242 | 203 | @Verifier(tx) | |
243 | 204 | func verify () = { | |
244 | 205 | let targetPublicKey = match managerPublicKeyOrUnit() { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
7 | 7 | ||
8 | 8 | ||
9 | - | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
9 | + | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
10 | + | ||
11 | + | ||
12 | + | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
10 | 13 | ||
11 | 14 | ||
12 | 15 | func keyWithdrawDelay (assetA,assetB) = makeString(["%s%s%s", "withdrawDelay", assetA, assetB], SEP) | |
13 | 16 | ||
14 | 17 | ||
15 | 18 | func keyDepositFeePermille (assetA,assetB) = makeString(["%s%s%s", "depositFeePermille", assetA, assetB], SEP) | |
16 | 19 | ||
17 | 20 | ||
18 | 21 | func keyWithdrawFeePermille (assetA,assetB) = makeString(["%s%s%s", "withdrawFeePermille", assetA, assetB], SEP) | |
19 | 22 | ||
20 | 23 | ||
21 | 24 | func keyMinAmountDeposit (assetA,assetB) = makeString(["%s%s%s", "minAmountDeposit", assetA, assetB], SEP) | |
22 | 25 | ||
23 | 26 | ||
24 | 27 | func keyAssetsPairStatus (assetA,assetB) = makeString(["%s%s%s", "assetsPairStatus", assetA, assetB], SEP) | |
25 | 28 | ||
26 | 29 | ||
27 | 30 | func keyMinAmountWithdraw (assetA,assetB) = makeString(["%s%s%s", "minAmountWithdraw", assetA, assetB], SEP) | |
28 | 31 | ||
29 | 32 | ||
30 | 33 | func keyBalance (assetA,assetB,userAddress) = makeString(["%s%s%s%s", "balance", assetA, assetB, userAddress], SEP) | |
31 | 34 | ||
32 | 35 | ||
33 | 36 | func keyTotalFeeCollectedDeposit (assetA,assetB) = makeString(["%s%s%s%s", "totalFeeCollected", "deposit", assetA, assetB], SEP) | |
34 | 37 | ||
35 | 38 | ||
36 | 39 | func keyProcessInProgress (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "inProgress", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
37 | 40 | ||
38 | 41 | ||
39 | 42 | func keyProcessDone (userAddress,assetA,assetB,heightInKey) = makeString(["%s%s%s%s%s%d", "withdrawProcess", "done", userAddress, assetA, assetB, toString(heightInKey)], SEP) | |
40 | 43 | ||
41 | 44 | ||
42 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
43 | - | case s: String => | |
44 | - | fromBase58String(s) | |
45 | - | case _: Unit => | |
46 | - | unit | |
47 | - | case _ => | |
48 | - | throw("Match error") | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
53 | - | case s: String => | |
54 | - | fromBase58String(s) | |
55 | - | case _: Unit => | |
56 | - | unit | |
57 | - | case _ => | |
58 | - | throw("Match error") | |
59 | - | } | |
45 | + | func managerPublicKeyOrUnit () = { | |
46 | + | let managerVaultAddress = getManagerAddressOrFail() | |
47 | + | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
48 | + | case s: String => | |
49 | + | fromBase58String(s) | |
50 | + | case _: Unit => | |
51 | + | unit | |
52 | + | case _ => | |
53 | + | throw("Match error") | |
54 | + | } | |
55 | + | } | |
60 | 56 | ||
61 | 57 | ||
62 | 58 | func mustManager (i) = { | |
63 | 59 | let pd = throw("Permission denied.") | |
64 | 60 | match managerPublicKeyOrUnit() { | |
65 | 61 | case pk: ByteVector => | |
66 | 62 | if ((i.callerPublicKey == pk)) | |
67 | 63 | then true | |
68 | 64 | else pd | |
69 | 65 | case _: Unit => | |
70 | 66 | if ((i.caller == this)) | |
71 | 67 | then true | |
72 | 68 | else pd | |
73 | 69 | case _ => | |
74 | 70 | throw("Match error") | |
75 | 71 | } | |
76 | 72 | } | |
77 | 73 | ||
78 | 74 | ||
79 | 75 | func fmtErr (msg) = makeString(["otc_multiasset.ride:", msg], " ") | |
80 | 76 | ||
81 | 77 | ||
82 | 78 | func throwErr (msg) = throw(fmtErr(msg)) | |
83 | 79 | ||
84 | 80 | ||
85 | 81 | @Callable(i) | |
86 | 82 | func registerAsset (assetA,assetB,withdrawDelay,depositFee,withdrawFee,minAmountDeposit,minAmountWithdraw,pairStatus) = { | |
87 | 83 | let checkCaller = mustManager(i) | |
88 | 84 | if ((checkCaller == checkCaller)) | |
89 | 85 | then { | |
90 | 86 | let withdrawDelayKey = keyWithdrawDelay(assetA, assetB) | |
91 | 87 | let depositFeePermilleKey = keyDepositFeePermille(assetA, assetB) | |
92 | 88 | let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB) | |
93 | 89 | let minAmountDepositKey = keyMinAmountDeposit(assetA, assetB) | |
94 | 90 | let minAmountWithdrawKey = keyMinAmountWithdraw(assetA, assetB) | |
95 | 91 | let pairStatusKey = keyAssetsPairStatus(assetA, assetB) | |
96 | 92 | [IntegerEntry(withdrawDelayKey, withdrawDelay), IntegerEntry(depositFeePermilleKey, depositFee), IntegerEntry(withdrawFeePermilleKey, withdrawFee), IntegerEntry(minAmountDepositKey, minAmountDeposit), IntegerEntry(minAmountWithdrawKey, minAmountWithdraw), IntegerEntry(pairStatusKey, pairStatus)] | |
97 | 93 | } | |
98 | 94 | else throw("Strict value is not equal to itself.") | |
99 | 95 | } | |
100 | 96 | ||
101 | 97 | ||
102 | 98 | ||
103 | 99 | @Callable(i) | |
104 | 100 | func swapAssetsAToB (assetB) = { | |
105 | 101 | let payment = value(i.payments[0]) | |
106 | 102 | let assetA = toBase58String(value(payment.assetId)) | |
107 | 103 | let asset = fromBase58String(value(assetB)) | |
108 | 104 | let userAddress = toString(i.caller) | |
109 | 105 | let minAmountDeposit = valueOrErrorMessage(getInteger(keyMinAmountDeposit(assetA, assetB)), fmtErr("This asset pair does not exist.")) | |
110 | 106 | let toDeposit = payment.amount | |
111 | 107 | let depositFee = valueOrErrorMessage(getInteger(keyDepositFeePermille(assetA, assetB)), fmtErr("The deposit fee for this pair of assets is not set.")) | |
112 | 108 | let fee = ((toDeposit / 1000) * depositFee) | |
113 | 109 | let currentUserBalance = valueOrElse(getInteger(keyBalance(assetA, assetB, userAddress)), 0) | |
114 | 110 | let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
115 | 111 | let pairStatus = valueOrErrorMessage(getInteger(keyAssetsPairStatus(assetA, assetB)), fmtErr("The asset pair status for this pair of assets is not set.")) | |
116 | 112 | let checkPairStatus = if ((pairStatus == 0)) | |
117 | 113 | then true | |
118 | 114 | else throwErr("The couple's deposit is blocked.") | |
119 | 115 | if ((checkPairStatus == checkPairStatus)) | |
120 | 116 | then { | |
121 | 117 | let checkPayment = if ((toDeposit >= minAmountDeposit)) | |
122 | 118 | then true | |
123 | 119 | else throwErr("The deposit amount is less than the minimum.") | |
124 | 120 | if ((checkPayment == checkPayment)) | |
125 | 121 | then { | |
126 | 122 | let newBalance = ((currentUserBalance + toDeposit) - fee) | |
127 | 123 | let checkBalance = if ((newBalance > 0)) | |
128 | 124 | then true | |
129 | 125 | else throwErr("The final balance is less than or equal to 0.") | |
130 | 126 | if ((checkBalance == checkBalance)) | |
131 | 127 | then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee)), ScriptTransfer(i.caller, (toDeposit - fee), asset)] | |
132 | 128 | else throw("Strict value is not equal to itself.") | |
133 | 129 | } | |
134 | 130 | else throw("Strict value is not equal to itself.") | |
135 | 131 | } | |
136 | 132 | else throw("Strict value is not equal to itself.") | |
137 | 133 | } | |
138 | 134 | ||
139 | 135 | ||
140 | 136 | ||
141 | 137 | @Callable(i) | |
142 | 138 | func initializationSwapAssetsBToA (assetA) = { | |
143 | 139 | let payment = value(i.payments[0]) | |
144 | 140 | let toWithdraw = payment.amount | |
145 | 141 | let assetB = toBase58String(value(payment.assetId)) | |
146 | 142 | let userAddress = toString(i.caller) | |
147 | 143 | let minAmountWithdraw = valueOrErrorMessage(getInteger(keyMinAmountWithdraw(assetA, assetB)), fmtErr("The minimum withdrawal amount for this pair of assets is not set.")) | |
148 | 144 | let assetLockHeight = (height + valueOrErrorMessage(getInteger(keyWithdrawDelay(assetA, assetB)), fmtErr("Withdrawal delay is not set for the specified pair."))) | |
149 | 145 | let currentUserBalance = valueOrErrorMessage(getInteger(keyBalance(assetA, assetB, userAddress)), fmtErr("This user balance does not exist.")) | |
150 | 146 | let totalCommissions = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
151 | 147 | let withdrawFeePermilleKey = keyWithdrawFeePermille(assetA, assetB) | |
152 | 148 | let withdrawFee = valueOrErrorMessage(getInteger(withdrawFeePermilleKey), fmtErr("The withdrawal fee for this pair of assets is not set.")) | |
153 | 149 | let fee = ((toWithdraw / 1000) * withdrawFee) | |
154 | 150 | let newBalance = (currentUserBalance - toWithdraw) | |
155 | 151 | let checkBalance = if ((newBalance >= 0)) | |
156 | 152 | then true | |
157 | 153 | else throwErr("Swap amount fail, amount is to small.") | |
158 | 154 | if ((checkBalance == checkBalance)) | |
159 | 155 | then { | |
160 | 156 | let checkPayment = if ((toWithdraw >= minAmountWithdraw)) | |
161 | 157 | then true | |
162 | 158 | else throwErr("The withdraw amount is less than the minimum.") | |
163 | 159 | if ((checkPayment == checkPayment)) | |
164 | 160 | then { | |
165 | 161 | let checkProcessInProgress = if ((getInteger(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight)) == unit)) | |
166 | 162 | then true | |
167 | 163 | else throwErr("At this height, there is already an exchange of this pair.") | |
168 | 164 | if ((checkProcessInProgress == checkProcessInProgress)) | |
169 | 165 | then [IntegerEntry(keyBalance(assetA, assetB, userAddress), newBalance), IntegerEntry(keyProcessInProgress(userAddress, assetA, assetB, assetLockHeight), (toWithdraw - fee)), IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), (totalCommissions + fee))] | |
170 | 166 | else throw("Strict value is not equal to itself.") | |
171 | 167 | } | |
172 | 168 | else throw("Strict value is not equal to itself.") | |
173 | 169 | } | |
174 | 170 | else throw("Strict value is not equal to itself.") | |
175 | 171 | } | |
176 | 172 | ||
177 | 173 | ||
178 | 174 | ||
179 | 175 | @Callable(i) | |
180 | 176 | func withdrawAsset (assetA,assetB,heightInKey) = { | |
181 | 177 | let userAddress = toString(i.caller) | |
182 | 178 | let toWithdraw = valueOrErrorMessage(getInteger(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), fmtErr("At this height, withdraw was not initialized with this pair of assets.")) | |
183 | 179 | let asset = fromBase58String(value(assetA)) | |
184 | 180 | let checkHeight = if ((height >= heightInKey)) | |
185 | 181 | then true | |
186 | 182 | else throwErr((("Withdrawal is possible after " + toString(heightInKey)) + " height or you have already withdrawn.")) | |
187 | 183 | if ((checkHeight == checkHeight)) | |
188 | 184 | then [DeleteEntry(keyProcessInProgress(userAddress, assetA, assetB, heightInKey)), IntegerEntry(keyProcessDone(userAddress, assetA, assetB, heightInKey), toWithdraw), ScriptTransfer(i.caller, toWithdraw, asset)] | |
189 | 185 | else throw("Strict value is not equal to itself.") | |
190 | 186 | } | |
191 | 187 | ||
192 | 188 | ||
193 | 189 | ||
194 | 190 | @Callable(i) | |
195 | 191 | func withdrawFee (assetA,assetB) = { | |
196 | 192 | let checkCaller = mustManager(i) | |
197 | 193 | if ((checkCaller == checkCaller)) | |
198 | 194 | then { | |
199 | 195 | let toWithdrawA = valueOrElse(getInteger(keyTotalFeeCollectedDeposit(assetA, assetB)), 0) | |
200 | 196 | let withdrawAssetA = fromBase58String(value(assetA)) | |
201 | 197 | [IntegerEntry(keyTotalFeeCollectedDeposit(assetA, assetB), 0), ScriptTransfer(i.caller, toWithdrawA, withdrawAssetA)] | |
202 | 198 | } | |
203 | 199 | else throw("Strict value is not equal to itself.") | |
204 | 200 | } | |
205 | 201 | ||
206 | 202 | ||
207 | - | ||
208 | - | @Callable(i) | |
209 | - | func setManager (pendingManagerPublicKey) = { | |
210 | - | let checkCaller = mustManager(i) | |
211 | - | if ((checkCaller == checkCaller)) | |
212 | - | then { | |
213 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
214 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
215 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
216 | - | else throw("Strict value is not equal to itself.") | |
217 | - | } | |
218 | - | else throw("Strict value is not equal to itself.") | |
219 | - | } | |
220 | - | ||
221 | - | ||
222 | - | ||
223 | - | @Callable(i) | |
224 | - | func confirmManager () = { | |
225 | - | let pm = pendingManagerPublicKeyOrUnit() | |
226 | - | let hasPM = if (isDefined(pm)) | |
227 | - | then true | |
228 | - | else throwErr("No pending manager.") | |
229 | - | if ((hasPM == hasPM)) | |
230 | - | then { | |
231 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
232 | - | then true | |
233 | - | else throwErr("You are not pending manager.") | |
234 | - | if ((checkPM == checkPM)) | |
235 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
236 | - | else throw("Strict value is not equal to itself.") | |
237 | - | } | |
238 | - | else throw("Strict value is not equal to itself.") | |
239 | - | } | |
240 | - | ||
241 | - | ||
242 | 203 | @Verifier(tx) | |
243 | 204 | func verify () = { | |
244 | 205 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
245 | 206 | case pk: ByteVector => | |
246 | 207 | pk | |
247 | 208 | case _: Unit => | |
248 | 209 | tx.senderPublicKey | |
249 | 210 | case _ => | |
250 | 211 | throw("Match error") | |
251 | 212 | } | |
252 | 213 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
253 | 214 | } | |
254 | 215 |
github/deemru/w8io/169f3d6 59.49 ms ◑