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:AAIFAAAAAAAAABQIAhIECgIIARIECgIICBIECgIICAAAABYAAAAAEGtleVBvb2xzTGlzdE5hbWUCAAAABXBvb2xzAAAAABFrZXlQcmVmaXhQb29sTmFtZQIAAAAFcG9vbF8AAAAAEmtleVByZWZpeFBvb2xJbmRleAIAAAAGaW5kZXhfAAAAABFrZXlJbml0UG9vbEhlaWdodAIAAAAQaW5pdF9wb29sX2hpZ2h0XwAAAAASa2V5Q29uZmlybWVkQXNzZXRzAgAAABBjb25maXJtZWRfYXNzZXRzAAAAABBrZXlBc3NldFByaW9yaXR5AgAAAA9hc3NldF9wcmlvcml0eV8AAAAAB2tleVBhaXICAAAABXBhaXJfAAAAAAtrZXlBc3NldElkQQIAAAAKQV9hc3NldF9pZAAAAAALa2V5QXNzZXRJZEICAAAACkJfYXNzZXRfaWQAAAAAD2tleUFkbWluUHViS2V5MQIAAAALYWRtaW5fcHViXzEAAAAAD2tleUFkbWluUHViS2V5MgIAAAALYWRtaW5fcHViXzIAAAAAD2tleUFkbWluUHViS2V5MwIAAAALYWRtaW5fcHViXzMAAAAAD29yYWNs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WluCQAAAgAAAAECAAAAC01hdGNoIGVycm9yk3GZ9w==", "height": 1612988, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DXBW166gve43DXNXfwcCnxAzt9LzN5fknNDYmweqESVv Next: 67Mtps1YjhhcDCD3CexZ6oKXa7dinBagYY2RF6sGrcnZ Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let adminPubKey1 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
5 | - | ||
6 | - | let adminPubKey2 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
7 | - | ||
8 | - | let adminPubKey3 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
9 | - | ||
10 | 4 | let keyPoolsListName = "pools" | |
11 | 5 | ||
12 | 6 | let keyPrefixPoolName = "pool_" | |
13 | 7 | ||
14 | 8 | 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' | |
15 | 45 | ||
16 | 46 | let pools = match getString(this, keyPoolsListName) { | |
17 | 47 | case string: String => | |
43 | 73 | ||
44 | 74 | ||
45 | 75 | @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) | |
46 | 83 | func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), { | |
47 | 84 | let validatedAddress = getAddressIfValid(poolAddress) | |
48 | 85 | let keyName = (keyPrefixPoolName + validatedAddress) | |
49 | 86 | 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") | |
50 | 89 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
51 | 90 | if (isDefined(possiblyAlreadyAddedPool)) | |
52 | 91 | 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), ","))] | |
54 | 93 | }) | |
55 | 94 | ||
56 | 95 | ||
67 | 106 | ||
68 | 107 | ||
69 | 108 | @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 | + | } | |
83 | 149 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let adminPubKey1 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
5 | - | ||
6 | - | let adminPubKey2 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
7 | - | ||
8 | - | let adminPubKey3 = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
9 | - | ||
10 | 4 | let keyPoolsListName = "pools" | |
11 | 5 | ||
12 | 6 | let keyPrefixPoolName = "pool_" | |
13 | 7 | ||
14 | 8 | 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' | |
15 | 45 | ||
16 | 46 | let pools = match getString(this, keyPoolsListName) { | |
17 | 47 | case string: String => | |
18 | 48 | split(string, ",") | |
19 | 49 | case nothing => | |
20 | 50 | nil | |
21 | 51 | } | |
22 | 52 | ||
23 | 53 | func isSelfCall (i) = if ((i.caller == this)) | |
24 | 54 | then unit | |
25 | 55 | else throw("Only the Oracle itself can invoke this function") | |
26 | 56 | ||
27 | 57 | ||
28 | 58 | func getPoolNameIfValid (poolName) = { | |
29 | 59 | let underscoreIndex = valueOrElse(indexOf(poolName, "_"), -1) | |
30 | 60 | let underscoreLastIndex = valueOrElse(lastIndexOf(poolName, "_"), -1) | |
31 | 61 | let hasSingleUnderscore = if (if ((underscoreIndex == underscoreLastIndex)) | |
32 | 62 | then (underscoreIndex > 0) | |
33 | 63 | else false) | |
34 | 64 | then (underscoreIndex != (size(poolName) - 1)) | |
35 | 65 | else false | |
36 | 66 | if (hasSingleUnderscore) | |
37 | 67 | then poolName | |
38 | 68 | else throw("Pool name must consist of two asset names separated by an underscore character") | |
39 | 69 | } | |
40 | 70 | ||
41 | 71 | ||
42 | 72 | func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address"))) | |
43 | 73 | ||
44 | 74 | ||
45 | 75 | @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) | |
46 | 83 | func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), { | |
47 | 84 | let validatedAddress = getAddressIfValid(poolAddress) | |
48 | 85 | let keyName = (keyPrefixPoolName + validatedAddress) | |
49 | 86 | 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") | |
50 | 89 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
51 | 90 | if (isDefined(possiblyAlreadyAddedPool)) | |
52 | 91 | 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), ","))] | |
54 | 93 | }) | |
55 | 94 | ||
56 | 95 | ||
57 | 96 | ||
58 | 97 | @Callable(i) | |
59 | 98 | func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), { | |
60 | 99 | let validatedAddress = getAddressIfValid(poolAddress) | |
61 | 100 | let keyName = (keyPrefixPoolName + validatedAddress) | |
62 | 101 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
63 | 102 | if (isDefined(possiblyAlreadyAddedPool)) | |
64 | 103 | then [StringEntry(keyName, getPoolNameIfValid(newPoolName))] | |
65 | 104 | else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added")) | |
66 | 105 | }) | |
67 | 106 | ||
68 | 107 | ||
69 | 108 | @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 | + | } | |
83 | 149 |
github/deemru/w8io/026f985 76.61 ms ◑