tx · 9LA7qr8ZwkVPtVgErL9XCej1ZuCqeWCi6btZbdQZHBVY 3Muw1aRbeKgLqAS264AakECyQAvDsnweHLu: -0.01600000 Waves 2022.06.08 18:49 [2087595] smart account 3Muw1aRbeKgLqAS264AakECyQAvDsnweHLu > SELF 0.00000000 Waves
{ "type": 13, "id": "9LA7qr8ZwkVPtVgErL9XCej1ZuCqeWCi6btZbdQZHBVY", "fee": 1600000, "feeAssetId": null, "timestamp": 1654703360582, "version": 1, "sender": "3Muw1aRbeKgLqAS264AakECyQAvDsnweHLu", "senderPublicKey": "668WwQVaWxezbvLEK3FccCSTbjst4zYAJDPrfLFRj9b9", "proofs": [ "4hsgM3Akmx741dLPuQugqLdgTq8v83VbxLGFrPzsAjZTMwZPij8ach5zNkGFsAXPmwnhAro6KGhH2fZB4T7aFkcL" ], "script": "base64:AAIFAAAAAAAAACsIAhIDCgEIEgASABIFCgMICAgSCAoGCAgICAEIEgASBAoCCAESAwoBCBIAAAAAFQAAAAADU0VQAgAAAAJfXwAAAAAFRU1QVFkCAAAAAAAAAAAIY29udHJhY3QCAAAAD2xwX3N0YWtpbmdfdjI6IAEAAAATa2V5TWFuYWdlclB1YmxpY0tleQAAAAAJAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAABBtYW5hZ2VyUHVibGljS2V5BQAAAANuaWwFAAAAA1NFUAEAAAAaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAACQAEuQAAAAIJAARMAAAAAgIAAAACJXMJAARMAAAAAgIAAAAXcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkFAAAAA25pbAUAAAADU0VQAQAAAAZrZXlUVkwAAAABAAAAB2Fzc2V0SWQJAAS5AAAAAgkABEwAAAACAgAAAAQlcyVzCQAETAAAAAICAAAAA3R2bAkABEwAAAACBQAAAAdhc3NldElkBQAAAANuaWwFAAAAA1NFUAEAAAANa2V5VFZMSGlzdG9yeQAAAAIAAAAHYXNzZXRJZAAAAAZoZWln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8gaXRzZWxmLgAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAD3RhcmdldFB1YmxpY0tleQQAAAAHJG1hdGNoMAkBAAAAFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAJwawUAAAAHJG1hdGNoMAUAAAACcGsDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA90YXJnZXRQdWJsaWNLZXmu21fz", "chainId": 84, "height": 2087595, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DXU1Wep861RcHzPLEFFrxaLi2q8fmXH4sEZCByogS1cg Next: J78Pt3YfBwHAVf6ptMvBLvzAyznFXL4h1rHqAdNS74Dh Diff:
Old | New | Differences | |
---|---|---|---|
35 | 35 | ||
36 | 36 | ||
37 | 37 | func keyProxyAddress (assetId) = makeString(["%s%s", "proxyAddress", assetId], SEP) | |
38 | + | ||
39 | + | ||
40 | + | func keyMappingsUserToWithdrawal (assetId,userAddress,txId) = makeString(["%s%s%s%s", "userWithdrawalAmount", assetId, userAddress, txId], SEP) | |
38 | 41 | ||
39 | 42 | ||
40 | 43 | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) | |
107 | 110 | ||
108 | 111 | ||
109 | 112 | @Callable(i) | |
110 | - | func put () = nil | |
113 | + | func put () = { | |
114 | + | let pmt = value(i.payments[0]) | |
115 | + | let asset = value(pmt.assetId) | |
116 | + | let assetId = toBase58String(asset) | |
117 | + | let checks = [if ((size(i.payments) == 1)) | |
118 | + | then true | |
119 | + | else throwErr("only one payment must be attached"), if (valueOrElse(getBoolean(keyCreated(assetId)), false)) | |
120 | + | then true | |
121 | + | else throwErr("attached payment asset must be registered in the contract"), if ((pmt.amount > 0)) | |
122 | + | then true | |
123 | + | else throwErr("positive amount required")] | |
124 | + | if ((checks == checks)) | |
125 | + | then { | |
126 | + | let tvl = valueOrElse(getInteger(keyTVL(assetId)), 0) | |
127 | + | let lpId = value(getString(keyAssetIdToLPId(assetId))) | |
128 | + | let lpInfo = value(assetInfo(fromBase58String(assetId))) | |
129 | + | let sharesAmount = if ((tvl > 0)) | |
130 | + | then ((pmt.amount * lpInfo.quantity) / tvl) | |
131 | + | else pmt.amount | |
132 | + | [Reissue(lpInfo.id, sharesAmount, true), ScriptTransfer(i.caller, sharesAmount, lpInfo.id)] | |
133 | + | } | |
134 | + | else throw("Strict value is not equal to itself.") | |
135 | + | } | |
111 | 136 | ||
112 | 137 | ||
113 | 138 | ||
114 | 139 | @Callable(i) | |
115 | - | func submitGetRequest () = nil | |
140 | + | func submitGetRequest () = { | |
141 | + | let pmt = value(i.payments[0]) | |
142 | + | let lp = value(pmt.assetId) | |
143 | + | let lpId = toBase58String(lp) | |
144 | + | let userAddress = toString(i.caller) | |
145 | + | let baseAssetId = value(getString(keyLPIdToAssetId(lpId))) | |
146 | + | let shares = pmt.amount | |
147 | + | let checks = [if ((size(i.payments) == 1)) | |
148 | + | then true | |
149 | + | else throwErr("only one payment must be attached"), if (valueOrElse(getBoolean(keyCreated(baseAssetId)), false)) | |
150 | + | then true | |
151 | + | else throwErr("attached payment asset must be registered in the contract"), if ((shares > 0)) | |
152 | + | then true | |
153 | + | else throwErr("positive amount to withdrawal required")] | |
154 | + | if ((checks == checks)) | |
155 | + | then { | |
156 | + | let pendingWithdrawals = valueOrElse(getInteger(keyPendingWithdrawals(baseAssetId)), 0) | |
157 | + | let tvl = valueOrElse(getInteger(keyTVL(baseAssetId)), 0) | |
158 | + | let lpInfo = value(assetInfo(lp)) | |
159 | + | let decimals = lpInfo.decimals | |
160 | + | let withdrawalAmount = ((shares * tvl) / lpInfo.quantity) | |
161 | + | [Burn(lp, shares), IntegerEntry(keyPendingWithdrawals(baseAssetId), (pendingWithdrawals + withdrawalAmount)), IntegerEntry(keyMappingsUserToWithdrawal(baseAssetId, userAddress, toBase58String(i.transactionId)), withdrawalAmount)] | |
162 | + | } | |
163 | + | else throw("Strict value is not equal to itself.") | |
164 | + | } | |
116 | 165 | ||
117 | 166 | ||
118 | 167 | ||
119 | 168 | @Callable(i) | |
120 | - | func executeGetRequest (assetId,userAddress,submitTxId) = nil | |
169 | + | func executeGetRequest (assetId,userAddress,submitTxId) = { | |
170 | + | let withdrawalAmount = valueOrElse(getInteger(keyMappingsUserToWithdrawal(assetId, userAddress, submitTxId)), 0) | |
171 | + | let checks = [if (valueOrElse(getBoolean(keyCreated(assetId)), false)) | |
172 | + | then true | |
173 | + | else throwErr("asset must be registered in the contract"), if ((withdrawalAmount > 0)) | |
174 | + | then true | |
175 | + | else throwErr("no corresponding withdrawal request")] | |
176 | + | if ((checks == checks)) | |
177 | + | then { | |
178 | + | let pendingWithdrawals = valueOrElse(getInteger(keyPendingWithdrawals(assetId)), 0) | |
179 | + | [ScriptTransfer(addressFromStringValue(userAddress), withdrawalAmount, fromBase58String(assetId)), DeleteEntry(keyMappingsUserToWithdrawal(assetId, userAddress, submitTxId)), IntegerEntry(keyPendingWithdrawals(assetId), (pendingWithdrawals - withdrawalAmount))] | |
180 | + | } | |
181 | + | else throw("Strict value is not equal to itself.") | |
182 | + | } | |
121 | 183 | ||
122 | 184 | ||
123 | 185 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let EMPTY = "" | |
7 | 7 | ||
8 | 8 | let contract = "lp_staking_v2: " | |
9 | 9 | ||
10 | 10 | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyTVL (assetId) = makeString(["%s%s", "tvl", assetId], SEP) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func keyTVLHistory (assetId,height) = makeString(["%s%s%d", "tvlHistory", assetId, toString(height)], SEP) | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func keyPendingWithdrawals (assetId) = makeString(["%s%s", "pendingWithdrawals", assetId], SEP) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func keyDelayInBlocks (assetId) = makeString(["%s%s", "delayInBlocks", assetId], SEP) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func keyCreated (assetId) = makeString(["%s%s", "created", assetId], SEP) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func keyAssetIdToLPId (assetId) = makeString(["%s%s", "assetIdToLPId", assetId], SEP) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func keyLPIdToAssetId (lpId) = makeString(["%s%s", "lpIdToAssetId", lpId], SEP) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func keyProxyAddress (assetId) = makeString(["%s%s", "proxyAddress", assetId], SEP) | |
38 | + | ||
39 | + | ||
40 | + | func keyMappingsUserToWithdrawal (assetId,userAddress,txId) = makeString(["%s%s%s%s", "userWithdrawalAmount", assetId, userAddress, txId], SEP) | |
38 | 41 | ||
39 | 42 | ||
40 | 43 | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) | |
41 | 44 | ||
42 | 45 | ||
43 | 46 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
44 | 47 | case s: String => | |
45 | 48 | fromBase58String(s) | |
46 | 49 | case _: Unit => | |
47 | 50 | unit | |
48 | 51 | case _ => | |
49 | 52 | throw("Match error") | |
50 | 53 | } | |
51 | 54 | ||
52 | 55 | ||
53 | 56 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
54 | 57 | case s: String => | |
55 | 58 | fromBase58String(s) | |
56 | 59 | case _: Unit => | |
57 | 60 | unit | |
58 | 61 | case _ => | |
59 | 62 | throw("Match error") | |
60 | 63 | } | |
61 | 64 | ||
62 | 65 | ||
63 | 66 | func throwErr (msg) = throw((contract + msg)) | |
64 | 67 | ||
65 | 68 | ||
66 | 69 | func mustManager (i) = { | |
67 | 70 | let pd = throwErr("permission denied") | |
68 | 71 | match managerPublicKeyOrUnit() { | |
69 | 72 | case pk: ByteVector => | |
70 | 73 | if ((i.callerPublicKey == pk)) | |
71 | 74 | then true | |
72 | 75 | else pd | |
73 | 76 | case _: Unit => | |
74 | 77 | if ((i.caller == this)) | |
75 | 78 | then true | |
76 | 79 | else pd | |
77 | 80 | case _ => | |
78 | 81 | throw("Match error") | |
79 | 82 | } | |
80 | 83 | } | |
81 | 84 | ||
82 | 85 | ||
83 | 86 | func assetsStoreContract () = addressFromStringValue(value(getString(keyAssetsStoreContract()))) | |
84 | 87 | ||
85 | 88 | ||
86 | 89 | func mustProxyAddress (i,assetId) = { | |
87 | 90 | let isProxy = (toString(i.caller) == valueOrElse(getString(keyProxyAddress(assetId)), EMPTY)) | |
88 | 91 | if (isProxy) | |
89 | 92 | then true | |
90 | 93 | else { | |
91 | 94 | let checkCaller = mustManager(i) | |
92 | 95 | if ((checkCaller == checkCaller)) | |
93 | 96 | then true | |
94 | 97 | else throw("Strict value is not equal to itself.") | |
95 | 98 | } | |
96 | 99 | } | |
97 | 100 | ||
98 | 101 | ||
99 | 102 | @Callable(i) | |
100 | 103 | func constructor (assetsStoreContract) = { | |
101 | 104 | let checkCaller = mustManager(i) | |
102 | 105 | if ((checkCaller == checkCaller)) | |
103 | 106 | then [StringEntry(keyAssetsStoreContract(), assetsStoreContract)] | |
104 | 107 | else throw("Strict value is not equal to itself.") | |
105 | 108 | } | |
106 | 109 | ||
107 | 110 | ||
108 | 111 | ||
109 | 112 | @Callable(i) | |
110 | - | func put () = nil | |
113 | + | func put () = { | |
114 | + | let pmt = value(i.payments[0]) | |
115 | + | let asset = value(pmt.assetId) | |
116 | + | let assetId = toBase58String(asset) | |
117 | + | let checks = [if ((size(i.payments) == 1)) | |
118 | + | then true | |
119 | + | else throwErr("only one payment must be attached"), if (valueOrElse(getBoolean(keyCreated(assetId)), false)) | |
120 | + | then true | |
121 | + | else throwErr("attached payment asset must be registered in the contract"), if ((pmt.amount > 0)) | |
122 | + | then true | |
123 | + | else throwErr("positive amount required")] | |
124 | + | if ((checks == checks)) | |
125 | + | then { | |
126 | + | let tvl = valueOrElse(getInteger(keyTVL(assetId)), 0) | |
127 | + | let lpId = value(getString(keyAssetIdToLPId(assetId))) | |
128 | + | let lpInfo = value(assetInfo(fromBase58String(assetId))) | |
129 | + | let sharesAmount = if ((tvl > 0)) | |
130 | + | then ((pmt.amount * lpInfo.quantity) / tvl) | |
131 | + | else pmt.amount | |
132 | + | [Reissue(lpInfo.id, sharesAmount, true), ScriptTransfer(i.caller, sharesAmount, lpInfo.id)] | |
133 | + | } | |
134 | + | else throw("Strict value is not equal to itself.") | |
135 | + | } | |
111 | 136 | ||
112 | 137 | ||
113 | 138 | ||
114 | 139 | @Callable(i) | |
115 | - | func submitGetRequest () = nil | |
140 | + | func submitGetRequest () = { | |
141 | + | let pmt = value(i.payments[0]) | |
142 | + | let lp = value(pmt.assetId) | |
143 | + | let lpId = toBase58String(lp) | |
144 | + | let userAddress = toString(i.caller) | |
145 | + | let baseAssetId = value(getString(keyLPIdToAssetId(lpId))) | |
146 | + | let shares = pmt.amount | |
147 | + | let checks = [if ((size(i.payments) == 1)) | |
148 | + | then true | |
149 | + | else throwErr("only one payment must be attached"), if (valueOrElse(getBoolean(keyCreated(baseAssetId)), false)) | |
150 | + | then true | |
151 | + | else throwErr("attached payment asset must be registered in the contract"), if ((shares > 0)) | |
152 | + | then true | |
153 | + | else throwErr("positive amount to withdrawal required")] | |
154 | + | if ((checks == checks)) | |
155 | + | then { | |
156 | + | let pendingWithdrawals = valueOrElse(getInteger(keyPendingWithdrawals(baseAssetId)), 0) | |
157 | + | let tvl = valueOrElse(getInteger(keyTVL(baseAssetId)), 0) | |
158 | + | let lpInfo = value(assetInfo(lp)) | |
159 | + | let decimals = lpInfo.decimals | |
160 | + | let withdrawalAmount = ((shares * tvl) / lpInfo.quantity) | |
161 | + | [Burn(lp, shares), IntegerEntry(keyPendingWithdrawals(baseAssetId), (pendingWithdrawals + withdrawalAmount)), IntegerEntry(keyMappingsUserToWithdrawal(baseAssetId, userAddress, toBase58String(i.transactionId)), withdrawalAmount)] | |
162 | + | } | |
163 | + | else throw("Strict value is not equal to itself.") | |
164 | + | } | |
116 | 165 | ||
117 | 166 | ||
118 | 167 | ||
119 | 168 | @Callable(i) | |
120 | - | func executeGetRequest (assetId,userAddress,submitTxId) = nil | |
169 | + | func executeGetRequest (assetId,userAddress,submitTxId) = { | |
170 | + | let withdrawalAmount = valueOrElse(getInteger(keyMappingsUserToWithdrawal(assetId, userAddress, submitTxId)), 0) | |
171 | + | let checks = [if (valueOrElse(getBoolean(keyCreated(assetId)), false)) | |
172 | + | then true | |
173 | + | else throwErr("asset must be registered in the contract"), if ((withdrawalAmount > 0)) | |
174 | + | then true | |
175 | + | else throwErr("no corresponding withdrawal request")] | |
176 | + | if ((checks == checks)) | |
177 | + | then { | |
178 | + | let pendingWithdrawals = valueOrElse(getInteger(keyPendingWithdrawals(assetId)), 0) | |
179 | + | [ScriptTransfer(addressFromStringValue(userAddress), withdrawalAmount, fromBase58String(assetId)), DeleteEntry(keyMappingsUserToWithdrawal(assetId, userAddress, submitTxId)), IntegerEntry(keyPendingWithdrawals(assetId), (pendingWithdrawals - withdrawalAmount))] | |
180 | + | } | |
181 | + | else throw("Strict value is not equal to itself.") | |
182 | + | } | |
121 | 183 | ||
122 | 184 | ||
123 | 185 | ||
124 | 186 | @Callable(i) | |
125 | 187 | func registerAsset (assetId,lpName,lpDescription,lpLogo,delayInBlocks,proxyAddress) = { | |
126 | 188 | let checks = [mustManager(i), if ((delayInBlocks >= 0)) | |
127 | 189 | then true | |
128 | 190 | else throwErr("invalid delayInBlocks"), if ((addressFromString(proxyAddress) != unit)) | |
129 | 191 | then true | |
130 | 192 | else throwErr("invalid proxyAddress"), if ((valueOrElse(getBoolean(keyCreated(assetId)), false) == false)) | |
131 | 193 | then true | |
132 | 194 | else throwErr("asset already registered")] | |
133 | 195 | if ((checks == checks)) | |
134 | 196 | then { | |
135 | 197 | let decimals = value(assetInfo(fromBase58String(assetId))).decimals | |
136 | 198 | let lpIssue = Issue(lpName, lpDescription, 1, decimals, true) | |
137 | 199 | let lp = calculateAssetId(lpIssue) | |
138 | 200 | let lpId = toBase58String(lp) | |
139 | 201 | let createOrUpdate = invoke(assetsStoreContract(), "createOrUpdate", [lpId, lpLogo, false], nil) | |
140 | 202 | if ((createOrUpdate == createOrUpdate)) | |
141 | 203 | then { | |
142 | 204 | let addLabel = invoke(assetsStoreContract(), "addLabel", [lpId, "DEFI"], nil) | |
143 | 205 | if ((addLabel == addLabel)) | |
144 | 206 | then [BooleanEntry(keyCreated(assetId), true), IntegerEntry(keyTVL(assetId), 0), IntegerEntry(keyTVLHistory(assetId, height), 0), IntegerEntry(keyDelayInBlocks(assetId), delayInBlocks), StringEntry(keyLPIdToAssetId(lpId), assetId), StringEntry(keyAssetIdToLPId(assetId), lpId), StringEntry(keyProxyAddress(assetId), proxyAddress), lpIssue, Burn(lp, 1)] | |
145 | 207 | else throw("Strict value is not equal to itself.") | |
146 | 208 | } | |
147 | 209 | else throw("Strict value is not equal to itself.") | |
148 | 210 | } | |
149 | 211 | else throw("Strict value is not equal to itself.") | |
150 | 212 | } | |
151 | 213 | ||
152 | 214 | ||
153 | 215 | ||
154 | 216 | @Callable(i) | |
155 | 217 | func topUpBalance () = { | |
156 | 218 | let pmt = valueOrErrorMessage(i.payments[0], (contract + "payment must be attached")) | |
157 | 219 | let assetId = toBase58String(value(pmt.assetId)) | |
158 | 220 | let amount = pmt.amount | |
159 | 221 | let pendingWithdrawals = valueOrElse(getInteger(keyPendingWithdrawals(assetId)), 0) | |
160 | 222 | let checks = [mustProxyAddress(i, assetId), if ((size(i.payments) == 1)) | |
161 | 223 | then true | |
162 | 224 | else throwErr("only one payment must be attached"), if (valueOrElse(getBoolean(keyCreated(assetId)), false)) | |
163 | 225 | then true | |
164 | 226 | else throwErr("attached payment asset must be registered in the contract"), if ((pendingWithdrawals != 0)) | |
165 | 227 | then true | |
166 | 228 | else throwErr("zero pendingWithdrawals, nothing to top up"), if ((pendingWithdrawals >= amount)) | |
167 | 229 | then true | |
168 | 230 | else "amount to top up must be less or equal than pendingWithdrawals"] | |
169 | 231 | if ((checks == checks)) | |
170 | 232 | then [IntegerEntry(keyPendingWithdrawals(assetId), (pendingWithdrawals - amount))] | |
171 | 233 | else throw("Strict value is not equal to itself.") | |
172 | 234 | } | |
173 | 235 | ||
174 | 236 | ||
175 | 237 | ||
176 | 238 | @Callable(i) | |
177 | 239 | func setTVL (assetId,newTVL) = { | |
178 | 240 | let checkCaller = mustProxyAddress(i, assetId) | |
179 | 241 | if ((checkCaller == checkCaller)) | |
180 | 242 | then [IntegerEntry(keyTVL(assetId), newTVL), IntegerEntry(keyTVLHistory(assetId, height), newTVL)] | |
181 | 243 | else throw("Strict value is not equal to itself.") | |
182 | 244 | } | |
183 | 245 | ||
184 | 246 | ||
185 | 247 | ||
186 | 248 | @Callable(i) | |
187 | 249 | func setManager (pendingManagerPublicKey) = { | |
188 | 250 | let checkCaller = mustManager(i) | |
189 | 251 | if ((checkCaller == checkCaller)) | |
190 | 252 | then { | |
191 | 253 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
192 | 254 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
193 | 255 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
194 | 256 | else throw("Strict value is not equal to itself.") | |
195 | 257 | } | |
196 | 258 | else throw("Strict value is not equal to itself.") | |
197 | 259 | } | |
198 | 260 | ||
199 | 261 | ||
200 | 262 | ||
201 | 263 | @Callable(i) | |
202 | 264 | func confirmManager () = { | |
203 | 265 | let pm = pendingManagerPublicKeyOrUnit() | |
204 | 266 | let hasPM = if (isDefined(pm)) | |
205 | 267 | then true | |
206 | 268 | else throwErr("no pending manager") | |
207 | 269 | if ((hasPM == hasPM)) | |
208 | 270 | then { | |
209 | 271 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
210 | 272 | then true | |
211 | 273 | else throwErr("you are not pending manager") | |
212 | 274 | if ((checkPM == checkPM)) | |
213 | 275 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
214 | 276 | else throw("Strict value is not equal to itself.") | |
215 | 277 | } | |
216 | 278 | else throw("Strict value is not equal to itself.") | |
217 | 279 | } | |
218 | 280 | ||
219 | 281 | ||
220 | 282 | @Verifier(tx) | |
221 | 283 | func verify () = { | |
222 | 284 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
223 | 285 | case pk: ByteVector => | |
224 | 286 | pk | |
225 | 287 | case _: Unit => | |
226 | 288 | tx.senderPublicKey | |
227 | 289 | case _ => | |
228 | 290 | throw("Match error") | |
229 | 291 | } | |
230 | 292 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
231 | 293 | } | |
232 | 294 |
github/deemru/w8io/169f3d6 36.43 ms ◑