tx · 9YRENuSipaY15PJviXKxVJ6xcfBs5Q8Z14Pp1zpUGs8m

3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9:  -0.01400000 Waves

2021.07.14 10:26 [1612988] smart account 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9 > SELF 0.00000000 Waves

{ "type": 13, "id": "9YRENuSipaY15PJviXKxVJ6xcfBs5Q8Z14Pp1zpUGs8m", "fee": 1400000, "feeAssetId": null, "timestamp": 1626247565954, "version": 2, "chainId": 84, "sender": "3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9", "senderPublicKey": "D1X9WatF6ARMCmm3jC4Ex5Wd5VQ3LY8i1xbHNqeHqeAa", "proofs": [ "2tBZ3X4H26rvqViGNj4bo4Zft6BbzEpwXkBFKvWh3tMGfikYjMKm1hSARnLEsLYaFkSz8SAtHF54qAxPCXW11aD7" ], "script": "base64:AAIFAAAAAAAAABQIAhIECgIIARIECgIICBIECgIICAAAABYAAAAAEGtleVBvb2xzTGlzdE5hbWUCAAAABXBvb2xzAAAAABFrZXlQcmVmaXhQb29sTmFtZQIAAAAFcG9vbF8AAAAAEmtleVByZWZpeFBvb2xJbmRleAIAAAAGaW5kZXhfAAAAABFrZXlJbml0UG9vbEhlaWdodAIAAAAQaW5pdF9wb29sX2hpZ2h0XwAAAAASa2V5Q29uZmlybWVkQXNzZXRzAgAAABBjb25maXJtZWRfYXNzZXRzAAAAABBrZXlBc3NldFByaW9yaXR5AgAAAA9hc3NldF9wcmlvcml0eV8AAAAAB2tleVBhaXICAAAABXBhaXJfAAAAAAtrZXlBc3NldElkQQIAAAAKQV9hc3NldF9pZAAAAAALa2V5QXNzZXRJZEICAAAACkJfYXNzZXRfaWQAAAAAD2tleUFkbWluUHViS2V5MQIAAAALYWRtaW5fcHViXzEAAAAAD2tleUFkbWluUHViS2V5MgIAAAALYWRtaW5fcHViXzIAAAAAD2tleUFkbWluUHViS2V5MwIAAAALYWRtaW5fcHViXzMAAAAAD29yYWN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bWluCQAAAgAAAAECAAAAC01hdGNoIGVycm9yk3GZ9w==", "height": 1612988, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DXBW166gve43DXNXfwcCnxAzt9LzN5fknNDYmweqESVv Next: 67Mtps1YjhhcDCD3CexZ6oKXa7dinBagYY2RF6sGrcnZ Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 4 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let adminPubKey1 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
5-
6-let adminPubKey2 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
7-
8-let adminPubKey3 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
9-
104 let keyPoolsListName = "pools"
115
126 let keyPrefixPoolName = "pool_"
137
148 let keyPrefixPoolIndex = "index_"
9+
10+let keyInitPoolHeight = "init_pool_hight_"
11+
12+let keyConfirmedAssets = "confirmed_assets"
13+
14+let keyAssetPriority = "asset_priority_"
15+
16+let keyPair = "pair_"
17+
18+let keyAssetIdA = "A_asset_id"
19+
20+let keyAssetIdB = "B_asset_id"
21+
22+let keyAdminPubKey1 = "admin_pub_1"
23+
24+let keyAdminPubKey2 = "admin_pub_2"
25+
26+let keyAdminPubKey3 = "admin_pub_3"
27+
28+let oracleAdminPool = Address(base58'3N1cPjixuHTujhGvb5HQoFvGt4fkUG8o3KF')
29+
30+func getAdminPub (keyAdminPub) = match getString(oracleAdminPool, keyAdminPub) {
31+ case string: String =>
32+ fromBase58String(string)
33+ case nothing =>
34+ throw("Admin public key is empty")
35+}
36+
37+
38+let adminPubKey1 = getAdminPub(keyAdminPubKey1)
39+
40+let adminPubKey2 = getAdminPub(keyAdminPubKey2)
41+
42+let adminPubKey3 = getAdminPub(keyAdminPubKey3)
43+
44+let adminInvoke = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
1545
1646 let pools = match getString(this, keyPoolsListName) {
1747 case string: String =>
4373
4474
4575 @Callable(i)
76+func setPriority (assetId,priority) = valueOrElse(isSelfCall(i), if ((0 > priority))
77+ then throw("Priority must be positive")
78+ else [IntegerEntry((keyAssetPriority + assetId), priority)])
79+
80+
81+
82+@Callable(i)
4683 func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), {
4784 let validatedAddress = getAddressIfValid(poolAddress)
4885 let keyName = (keyPrefixPoolName + validatedAddress)
4986 let keyIndex = (keyPrefixPoolIndex + validatedAddress)
87+ let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdA), "Asset id A is incorrect")
88+ let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdB), "Asset id B is incorrect")
5089 let possiblyAlreadyAddedPool = getString(this, keyName)
5190 if (isDefined(possiblyAlreadyAddedPool))
5291 then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
53- else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
92+ else [IntegerEntry(keyIndex, size(pools)), IntegerEntry((keyInitPoolHeight + poolAddress), height), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
5493 })
5594
5695
67106
68107
69108 @Verifier(tx)
70-func verify () = match tx {
71- case invoke: InvokeScriptTransaction =>
72- let isSelfInvoke = if ((invoke.dApp == this))
73- then containsElement(["addPool", "renamePool"], invoke.function)
74- else false
75- if ((size(invoke.payments) == 0))
76- then isSelfInvoke
77- else false
78- case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
79- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
80- case _ =>
81- throw("Match error")
82-}
109+func verify () = {
110+ let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
111+ then 1
112+ else 0
113+ let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
114+ then 1
115+ else 0
116+ let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
117+ then 1
118+ else 0
119+ let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
120+ let adminInvokeSigned = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminInvoke))
121+ then 1
122+ else 0
123+ let signedByAdminToCallAddPool = ((((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) + adminInvokeSigned) >= 1)
124+ match tx {
125+ case inv: InvokeScriptTransaction =>
126+ let isSelfInvokeRenamePool = if ((inv.dApp == this))
127+ then containsElement(["renamePool"], inv.function)
128+ else false
129+ let isSelfInvokeAddPool = if ((inv.dApp == this))
130+ then containsElement(["addPool"], inv.function)
131+ else false
132+ if (if (if (signedByAdmin)
133+ then (size(inv.payments) == 0)
134+ else false)
135+ then isSelfInvokeRenamePool
136+ else false)
137+ then true
138+ else if (if (signedByAdminToCallAddPool)
139+ then (size(inv.payments) == 0)
140+ else false)
141+ then isSelfInvokeAddPool
142+ else false
143+ case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
144+ signedByAdmin
145+ case _ =>
146+ throw("Match error")
147+ }
148+ }
83149
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 4 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let adminPubKey1 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
5-
6-let adminPubKey2 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
7-
8-let adminPubKey3 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
9-
104 let keyPoolsListName = "pools"
115
126 let keyPrefixPoolName = "pool_"
137
148 let keyPrefixPoolIndex = "index_"
9+
10+let keyInitPoolHeight = "init_pool_hight_"
11+
12+let keyConfirmedAssets = "confirmed_assets"
13+
14+let keyAssetPriority = "asset_priority_"
15+
16+let keyPair = "pair_"
17+
18+let keyAssetIdA = "A_asset_id"
19+
20+let keyAssetIdB = "B_asset_id"
21+
22+let keyAdminPubKey1 = "admin_pub_1"
23+
24+let keyAdminPubKey2 = "admin_pub_2"
25+
26+let keyAdminPubKey3 = "admin_pub_3"
27+
28+let oracleAdminPool = Address(base58'3N1cPjixuHTujhGvb5HQoFvGt4fkUG8o3KF')
29+
30+func getAdminPub (keyAdminPub) = match getString(oracleAdminPool, keyAdminPub) {
31+ case string: String =>
32+ fromBase58String(string)
33+ case nothing =>
34+ throw("Admin public key is empty")
35+}
36+
37+
38+let adminPubKey1 = getAdminPub(keyAdminPubKey1)
39+
40+let adminPubKey2 = getAdminPub(keyAdminPubKey2)
41+
42+let adminPubKey3 = getAdminPub(keyAdminPubKey3)
43+
44+let adminInvoke = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK'
1545
1646 let pools = match getString(this, keyPoolsListName) {
1747 case string: String =>
1848 split(string, ",")
1949 case nothing =>
2050 nil
2151 }
2252
2353 func isSelfCall (i) = if ((i.caller == this))
2454 then unit
2555 else throw("Only the Oracle itself can invoke this function")
2656
2757
2858 func getPoolNameIfValid (poolName) = {
2959 let underscoreIndex = valueOrElse(indexOf(poolName, "_"), -1)
3060 let underscoreLastIndex = valueOrElse(lastIndexOf(poolName, "_"), -1)
3161 let hasSingleUnderscore = if (if ((underscoreIndex == underscoreLastIndex))
3262 then (underscoreIndex > 0)
3363 else false)
3464 then (underscoreIndex != (size(poolName) - 1))
3565 else false
3666 if (hasSingleUnderscore)
3767 then poolName
3868 else throw("Pool name must consist of two asset names separated by an underscore character")
3969 }
4070
4171
4272 func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address")))
4373
4474
4575 @Callable(i)
76+func setPriority (assetId,priority) = valueOrElse(isSelfCall(i), if ((0 > priority))
77+ then throw("Priority must be positive")
78+ else [IntegerEntry((keyAssetPriority + assetId), priority)])
79+
80+
81+
82+@Callable(i)
4683 func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), {
4784 let validatedAddress = getAddressIfValid(poolAddress)
4885 let keyName = (keyPrefixPoolName + validatedAddress)
4986 let keyIndex = (keyPrefixPoolIndex + validatedAddress)
87+ let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdA), "Asset id A is incorrect")
88+ let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdB), "Asset id B is incorrect")
5089 let possiblyAlreadyAddedPool = getString(this, keyName)
5190 if (isDefined(possiblyAlreadyAddedPool))
5291 then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\""))
53- else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
92+ else [IntegerEntry(keyIndex, size(pools)), IntegerEntry((keyInitPoolHeight + poolAddress), height), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))]
5493 })
5594
5695
5796
5897 @Callable(i)
5998 func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), {
6099 let validatedAddress = getAddressIfValid(poolAddress)
61100 let keyName = (keyPrefixPoolName + validatedAddress)
62101 let possiblyAlreadyAddedPool = getString(this, keyName)
63102 if (isDefined(possiblyAlreadyAddedPool))
64103 then [StringEntry(keyName, getPoolNameIfValid(newPoolName))]
65104 else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added"))
66105 })
67106
68107
69108 @Verifier(tx)
70-func verify () = match tx {
71- case invoke: InvokeScriptTransaction =>
72- let isSelfInvoke = if ((invoke.dApp == this))
73- then containsElement(["addPool", "renamePool"], invoke.function)
74- else false
75- if ((size(invoke.payments) == 0))
76- then isSelfInvoke
77- else false
78- case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
79- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
80- case _ =>
81- throw("Match error")
82-}
109+func verify () = {
110+ let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1))
111+ then 1
112+ else 0
113+ let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2))
114+ then 1
115+ else 0
116+ let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3))
117+ then 1
118+ else 0
119+ let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2)
120+ let adminInvokeSigned = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminInvoke))
121+ then 1
122+ else 0
123+ let signedByAdminToCallAddPool = ((((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) + adminInvokeSigned) >= 1)
124+ match tx {
125+ case inv: InvokeScriptTransaction =>
126+ let isSelfInvokeRenamePool = if ((inv.dApp == this))
127+ then containsElement(["renamePool"], inv.function)
128+ else false
129+ let isSelfInvokeAddPool = if ((inv.dApp == this))
130+ then containsElement(["addPool"], inv.function)
131+ else false
132+ if (if (if (signedByAdmin)
133+ then (size(inv.payments) == 0)
134+ else false)
135+ then isSelfInvokeRenamePool
136+ else false)
137+ then true
138+ else if (if (signedByAdminToCallAddPool)
139+ then (size(inv.payments) == 0)
140+ else false)
141+ then isSelfInvokeAddPool
142+ else false
143+ case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction =>
144+ signedByAdmin
145+ case _ =>
146+ throw("Match error")
147+ }
148+ }
83149

github/deemru/w8io/026f985 
76.61 ms