tx · CjY3hgzNq2ytuYhHwamQ3XXXA2yD3gfqvUxbtaP3nJ7o 3N8bnD2caKnxdcTqvrJUEkDe3XebgfwWjSV: -0.01400000 Waves 2022.03.05 11:53 [1950458] smart account 3N8bnD2caKnxdcTqvrJUEkDe3XebgfwWjSV > SELF 0.00000000 Waves
{ "type": 13, "id": "CjY3hgzNq2ytuYhHwamQ3XXXA2yD3gfqvUxbtaP3nJ7o", "fee": 1400000, "feeAssetId": null, "timestamp": 1646470427861, "version": 1, "sender": "3N8bnD2caKnxdcTqvrJUEkDe3XebgfwWjSV", "senderPublicKey": "8KXPjDuC8ffL9qjNuDBLnkvJKbMojhZYcnm2o75UCyun", "proofs": [ "53Wk1CgAFAj8YQsfwdeEhgwio5HAMCdpvi1pnBy9c8efkYLdxZJxgfuFTdps5iP8MdQYcriqY1GuA1fBRUq6Y446" ], "script": "base64:AAIFAAAAAAAAABgIAhIDCgEIEgMKAQgSABIICgYBAQEBCAEAAAAZAAAAAANTRVACAAAAAl9fAAAAAAVFTVBUWQIAAAAAAAAAAA5pZHhQb29sQWRkcmVzcwAAAAAAAAAAAQAAAAAJaWR4TFBBc0lkAAAAAAAAAAADAAAAAAlpZHhBbUFzSWQAAAAAAAAAAAQAAAAACWlkeFByQXNJZAAAAAAAAAAABQAAAAAPaWR4RmFjdFN0YWtDbnRyAAAAAAAAAAABAQAAAAtrZXlGYWN0Q250cgAAAAACAAAAEyVzX19mYWN0b3J5Q29udHJhY3QBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABQlc19fbWFuYWdlclB1YmxpY0tleQEAAAAaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAAAAC2tleVBvb2xBZGRyAAAAAAIAAAAPJXNfX3Bvb2xBZGRyZXNzAQAAAAtrZXlBbXRBc3NldAAAAAACAAAADyVzX19hbW91bnRBc3NldAEAAAANa2V5UHJpY2VBc3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jaCBlcnJvcgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAD3RhcmdldFB1YmxpY0tleXyHjec=", "chainId": 84, "height": 1950458, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 65FExZyQd7ZcNGwtGvqRGJ3Jgz2rcRtLJH4Q2EGUqPtg Next: GGYxYdttUmjUz8uVUDFspMrU9UXNNYcN6QuCxNB7kUVg Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | func keyFactCntr () = "%s__factoryContract" | |
19 | 19 | ||
20 | 20 | ||
21 | - | func keyManPubKey () = "%s__managerPublicKey" | |
21 | + | func keyManagerPublicKey () = "%s__managerPublicKey" | |
22 | + | ||
23 | + | ||
24 | + | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
22 | 25 | ||
23 | 26 | ||
24 | 27 | func keyPoolAddr () = "%s__poolAddress" | |
61 | 64 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
62 | 65 | ||
63 | 66 | ||
67 | + | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
68 | + | case s: String => | |
69 | + | fromBase58String(s) | |
70 | + | case _: Unit => | |
71 | + | unit | |
72 | + | case _ => | |
73 | + | throw("Match error") | |
74 | + | } | |
75 | + | ||
76 | + | ||
77 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
78 | + | case s: String => | |
79 | + | fromBase58String(s) | |
80 | + | case _: Unit => | |
81 | + | unit | |
82 | + | case _ => | |
83 | + | throw("Match error") | |
84 | + | } | |
85 | + | ||
86 | + | ||
87 | + | func mustManager (i) = { | |
88 | + | let pd = throw("Permission denied") | |
89 | + | match managerPublicKeyOrUnit() { | |
90 | + | case pk: ByteVector => | |
91 | + | if ((i.callerPublicKey == pk)) | |
92 | + | then true | |
93 | + | else pd | |
94 | + | case _: Unit => | |
95 | + | if ((i.caller == this)) | |
96 | + | then true | |
97 | + | else pd | |
98 | + | case _ => | |
99 | + | throw("Match error") | |
100 | + | } | |
101 | + | } | |
102 | + | ||
103 | + | ||
64 | 104 | @Callable(i) | |
65 | - | func constructor (poolAddress) = if ((i.caller != this)) | |
66 | - | then throw("denied") | |
67 | - | else [StringEntry(keyPoolAddr(), poolAddress)] | |
105 | + | func constructor (poolAddress) = { | |
106 | + | let checkCaller = mustManager(i) | |
107 | + | if ((checkCaller == checkCaller)) | |
108 | + | then [StringEntry(keyPoolAddr(), poolAddress)] | |
109 | + | else throw("Strict value is not equal to itself.") | |
110 | + | } | |
111 | + | ||
112 | + | ||
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 | + | } | |
68 | 146 | ||
69 | 147 | ||
70 | 148 | ||
94 | 172 | ||
95 | 173 | ||
96 | 174 | @Verifier(tx) | |
97 | - | func verify () = match tx { | |
98 | - | case _ => | |
99 | - | let admin = valueOrElse(getString(this, keyManPubKey()), EMPTY) | |
100 | - | if ((admin == EMPTY)) | |
101 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
102 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(admin)) | |
103 | - | } | |
175 | + | func verify () = { | |
176 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
177 | + | case pk: ByteVector => | |
178 | + | pk | |
179 | + | case _: Unit => | |
180 | + | tx.senderPublicKey | |
181 | + | case _ => | |
182 | + | throw("Match error") | |
183 | + | } | |
184 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
185 | + | } | |
104 | 186 |
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 idxPoolAddress = 1 | |
9 | 9 | ||
10 | 10 | let idxLPAsId = 3 | |
11 | 11 | ||
12 | 12 | let idxAmAsId = 4 | |
13 | 13 | ||
14 | 14 | let idxPrAsId = 5 | |
15 | 15 | ||
16 | 16 | let idxFactStakCntr = 1 | |
17 | 17 | ||
18 | 18 | func keyFactCntr () = "%s__factoryContract" | |
19 | 19 | ||
20 | 20 | ||
21 | - | func keyManPubKey () = "%s__managerPublicKey" | |
21 | + | func keyManagerPublicKey () = "%s__managerPublicKey" | |
22 | + | ||
23 | + | ||
24 | + | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
22 | 25 | ||
23 | 26 | ||
24 | 27 | func keyPoolAddr () = "%s__poolAddress" | |
25 | 28 | ||
26 | 29 | ||
27 | 30 | func keyAmtAsset () = "%s__amountAsset" | |
28 | 31 | ||
29 | 32 | ||
30 | 33 | func keyPriceAsset () = "%s__priceAsset" | |
31 | 34 | ||
32 | 35 | ||
33 | 36 | func keyFactoryConfig () = "%s__factoryConfig" | |
34 | 37 | ||
35 | 38 | ||
36 | 39 | func keyPoolConfig (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
37 | 40 | ||
38 | 41 | ||
39 | 42 | func keyMappingsBaseAsset2internalId (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
40 | 43 | ||
41 | 44 | ||
42 | 45 | func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
43 | 46 | ||
44 | 47 | ||
45 | 48 | func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
46 | 49 | ||
47 | 50 | ||
48 | 51 | let poolContract = addressFromStringValue(getStringOrFail(this, keyPoolAddr())) | |
49 | 52 | ||
50 | 53 | let factoryContract = addressFromStringValue(getStringOrFail(poolContract, keyFactCntr())) | |
51 | 54 | ||
52 | 55 | func getPoolConfig () = { | |
53 | 56 | let amtAs = getStringOrFail(poolContract, keyAmtAsset()) | |
54 | 57 | let priceAs = getStringOrFail(poolContract, keyPriceAsset()) | |
55 | 58 | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
56 | 59 | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
57 | 60 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
58 | 61 | } | |
59 | 62 | ||
60 | 63 | ||
61 | 64 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
62 | 65 | ||
63 | 66 | ||
67 | + | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
68 | + | case s: String => | |
69 | + | fromBase58String(s) | |
70 | + | case _: Unit => | |
71 | + | unit | |
72 | + | case _ => | |
73 | + | throw("Match error") | |
74 | + | } | |
75 | + | ||
76 | + | ||
77 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
78 | + | case s: String => | |
79 | + | fromBase58String(s) | |
80 | + | case _: Unit => | |
81 | + | unit | |
82 | + | case _ => | |
83 | + | throw("Match error") | |
84 | + | } | |
85 | + | ||
86 | + | ||
87 | + | func mustManager (i) = { | |
88 | + | let pd = throw("Permission denied") | |
89 | + | match managerPublicKeyOrUnit() { | |
90 | + | case pk: ByteVector => | |
91 | + | if ((i.callerPublicKey == pk)) | |
92 | + | then true | |
93 | + | else pd | |
94 | + | case _: Unit => | |
95 | + | if ((i.caller == this)) | |
96 | + | then true | |
97 | + | else pd | |
98 | + | case _ => | |
99 | + | throw("Match error") | |
100 | + | } | |
101 | + | } | |
102 | + | ||
103 | + | ||
64 | 104 | @Callable(i) | |
65 | - | func constructor (poolAddress) = if ((i.caller != this)) | |
66 | - | then throw("denied") | |
67 | - | else [StringEntry(keyPoolAddr(), poolAddress)] | |
105 | + | func constructor (poolAddress) = { | |
106 | + | let checkCaller = mustManager(i) | |
107 | + | if ((checkCaller == checkCaller)) | |
108 | + | then [StringEntry(keyPoolAddr(), poolAddress)] | |
109 | + | else throw("Strict value is not equal to itself.") | |
110 | + | } | |
111 | + | ||
112 | + | ||
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 | + | } | |
68 | 146 | ||
69 | 147 | ||
70 | 148 | ||
71 | 149 | @Callable(i) | |
72 | 150 | func unstakeAndGetOneTkn (amount,exchResult,notUsed,outAmount,outAssetId,slippage) = { | |
73 | 151 | let checkPayments = if ((size(i.payments) != 0)) | |
74 | 152 | then throw("No pmnts expd") | |
75 | 153 | else true | |
76 | 154 | if ((checkPayments == checkPayments)) | |
77 | 155 | then { | |
78 | 156 | let cfg = getPoolConfig() | |
79 | 157 | let factoryCfg = getFactoryConfig() | |
80 | 158 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
81 | 159 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
82 | 160 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
83 | 161 | if ((unstakeInv == unstakeInv)) | |
84 | 162 | then { | |
85 | 163 | let getOneTkn = invoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)]) | |
86 | 164 | if ((getOneTkn == getOneTkn)) | |
87 | 165 | then nil | |
88 | 166 | else throw("Strict value is not equal to itself.") | |
89 | 167 | } | |
90 | 168 | else throw("Strict value is not equal to itself.") | |
91 | 169 | } | |
92 | 170 | else throw("Strict value is not equal to itself.") | |
93 | 171 | } | |
94 | 172 | ||
95 | 173 | ||
96 | 174 | @Verifier(tx) | |
97 | - | func verify () = match tx { | |
98 | - | case _ => | |
99 | - | let admin = valueOrElse(getString(this, keyManPubKey()), EMPTY) | |
100 | - | if ((admin == EMPTY)) | |
101 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
102 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(admin)) | |
103 | - | } | |
175 | + | func verify () = { | |
176 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
177 | + | case pk: ByteVector => | |
178 | + | pk | |
179 | + | case _: Unit => | |
180 | + | tx.senderPublicKey | |
181 | + | case _ => | |
182 | + | throw("Match error") | |
183 | + | } | |
184 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
185 | + | } | |
104 | 186 |
github/deemru/w8io/169f3d6 31.95 ms ◑