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:AAIFAAAAAAAAABgIAhIDCgEIEgMKAQgSABIICgYBAQEBCAEAAAAZAAAAAANTRVACAAAAAl9fAAAAAAVFTVBUWQIAAAAAAAAAAA5pZHhQb29sQWRkcmVzcwAAAAAAAAAAAQAAAAAJaWR4TFBBc0lkAAAAAAAAAAADAAAAAAlpZHhBbUFzSWQAAAAAAAAAAAQAAAAACWlkeFByQXNJZAAAAAAAAAAABQAAAAAPaWR4RmFjdFN0YWtDbnRyAAAAAAAAAAABAQAAAAtrZXlGYWN0Q250cgAAAAACAAAAEyVzX19mYWN0b3J5Q29udHJhY3QBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABQlc19fbWFuYWdlclB1YmxpY0tleQEAAAAaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAAAAAgAAABslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAAAAC2tleVBvb2xBZGRyAAAAAAIAAAAPJXNfX3Bvb2xBZGRyZXNzAQAAAAtrZXlBbXRBc3NldAAAAAACAAAADyVzX19hbW91bnRBc3NldAEAAAANa2V5UHJpY2VBc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RjaCBlcnJvcgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAD3RhcmdldFB1YmxpY0tleXyHjec=", "chainId": 84, "height": 1950458, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 65FExZyQd7ZcNGwtGvqRGJ3Jgz2rcRtLJH4Q2EGUqPtg Next: GGYxYdttUmjUz8uVUDFspMrU9UXNNYcN6QuCxNB7kUVg Diff:
OldNewDifferences
1818 func keyFactCntr () = "%s__factoryContract"
1919
2020
21-func keyManPubKey () = "%s__managerPublicKey"
21+func keyManagerPublicKey () = "%s__managerPublicKey"
22+
23+
24+func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
2225
2326
2427 func keyPoolAddr () = "%s__poolAddress"
6164 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
6265
6366
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+
64104 @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+ }
68146
69147
70148
94172
95173
96174 @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+ }
104186
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let EMPTY = ""
77
88 let idxPoolAddress = 1
99
1010 let idxLPAsId = 3
1111
1212 let idxAmAsId = 4
1313
1414 let idxPrAsId = 5
1515
1616 let idxFactStakCntr = 1
1717
1818 func keyFactCntr () = "%s__factoryContract"
1919
2020
21-func keyManPubKey () = "%s__managerPublicKey"
21+func keyManagerPublicKey () = "%s__managerPublicKey"
22+
23+
24+func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
2225
2326
2427 func keyPoolAddr () = "%s__poolAddress"
2528
2629
2730 func keyAmtAsset () = "%s__amountAsset"
2831
2932
3033 func keyPriceAsset () = "%s__priceAsset"
3134
3235
3336 func keyFactoryConfig () = "%s__factoryConfig"
3437
3538
3639 func keyPoolConfig (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
3740
3841
3942 func keyMappingsBaseAsset2internalId (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
4043
4144
4245 func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
4346
4447
4548 func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
4649
4750
4851 let poolContract = addressFromStringValue(getStringOrFail(this, keyPoolAddr()))
4952
5053 let factoryContract = addressFromStringValue(getStringOrFail(poolContract, keyFactCntr()))
5154
5255 func getPoolConfig () = {
5356 let amtAs = getStringOrFail(poolContract, keyAmtAsset())
5457 let priceAs = getStringOrFail(poolContract, keyPriceAsset())
5558 let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs))
5659 let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs))
5760 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP)
5861 }
5962
6063
6164 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
6265
6366
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+
64104 @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+ }
68146
69147
70148
71149 @Callable(i)
72150 func unstakeAndGetOneTkn (amount,exchResult,notUsed,outAmount,outAssetId,slippage) = {
73151 let checkPayments = if ((size(i.payments) != 0))
74152 then throw("No pmnts expd")
75153 else true
76154 if ((checkPayments == checkPayments))
77155 then {
78156 let cfg = getPoolConfig()
79157 let factoryCfg = getFactoryConfig()
80158 let lpAssetId = fromBase58String(cfg[idxLPAsId])
81159 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
82160 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
83161 if ((unstakeInv == unstakeInv))
84162 then {
85163 let getOneTkn = invoke(poolContract, "getOneTkn", [exchResult, notUsed, outAmount, outAssetId, slippage], [AttachedPayment(lpAssetId, amount)])
86164 if ((getOneTkn == getOneTkn))
87165 then nil
88166 else throw("Strict value is not equal to itself.")
89167 }
90168 else throw("Strict value is not equal to itself.")
91169 }
92170 else throw("Strict value is not equal to itself.")
93171 }
94172
95173
96174 @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+ }
104186

github/deemru/w8io/169f3d6 
31.95 ms