tx · 37TExifogww359RfURTGDrep7n1gNyn53g5hGEQsSndX 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9: -0.01600000 Waves 2022.09.01 14:01 [2209983] smart account 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9 > SELF 0.00000000 Waves
{ "type": 13, "id": "37TExifogww359RfURTGDrep7n1gNyn53g5hGEQsSndX", "fee": 1600000, "feeAssetId": null, "timestamp": 1662030054344, "version": 2, "chainId": 84, "sender": "3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9", "senderPublicKey": "D1X9WatF6ARMCmm3jC4Ex5Wd5VQ3LY8i1xbHNqeHqeAa", "proofs": [ "5pfn7dbepzkmdjdiyw4E4A5qFfCz1Ci5Gng5g7ZUigw8kYjksijYrPmyhszMDe4TPTonD96QC4onJM2zFAK1KUZk", "W9it2jSpY3SEBQciNnwdgesru39eF2raVR4uk228MwwZCLQo7NUp8qLKzadBWUPdePBYACMyP2DkJZMPJ21MUYo" ], "script": "base64:BgIfCAISABIECgIICBIECgIICBIDCgEEEgMKAQgSAwoBCBIAD2tQcmVmaXhQb29sTmFtZQIFcG9vbF8ABWtQYWlyAgVwYWlyXwAJa0Fzc2V0SWRBAgpBX2Fzc2V0X2lkAAlrQXNzZXRJZEICCkJfYXNzZXRfaWQAH2tMYXVuY2hwYWREYXRhVHJhbnNhY3Rpb25TdGF0dXMCIWxhdW5jaHBhZF9kYXRhX3RyYW5zYWN0aW9uX3N0YXR1cwANa0FkbWluUHViS2V5MQILYWRtaW5fcHViXzEADWtBZG1pblB1YktleTICC2FkbWluX3B1Yl8yAA1rQWRtaW5QdWJLZXkzAgthZG1pbl9wdWJfMwASa0FkbWluSW52b2tlUHViS2V5AhBhZG1pbl9pbnZva2VfcHViABRrQWNoaWV2ZW1lbnRzV3JpdGVycwIUYWNoaWV2ZW1lbnRzX3dyaXRlcnMADGFkbWluUHViS2V5MQEg4qeMQDuGzRfmtEuH2+Whg6yuKqHsNy5eZQUT8rXs7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Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let kPoolsListName = "pools" | |
5 | - | ||
6 | 4 | let kPrefixPoolName = "pool_" | |
7 | - | ||
8 | - | let kPrefixPoolIndex = "index_" | |
9 | 5 | ||
10 | 6 | let kPair = "pair_" | |
11 | 7 | ||
33 | 29 | ||
34 | 30 | let adminPubKeyInvoke = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
35 | 31 | ||
36 | - | let pools = match getString(this, kPoolsListName) { | |
37 | - | case string: String => | |
38 | - | split(string, ",") | |
39 | - | case nothing => | |
40 | - | nil | |
41 | - | } | |
42 | - | ||
43 | 32 | func isSelfCall (i) = if ((i.caller == this)) | |
44 | 33 | then unit | |
45 | 34 | else throw("Only the Oracle itself can invoke this function") | |
59 | 48 | } | |
60 | 49 | ||
61 | 50 | ||
51 | + | func getPoolType (poolAddress) = { | |
52 | + | let version = valueOrErrorMessage(getString(poolAddress, "version"), "Pool is not initialized") | |
53 | + | if ((version == "1.0.0")) | |
54 | + | then "cpmm" | |
55 | + | else if ((version == "2.0.0")) | |
56 | + | then "flat" | |
57 | + | else if ((version == "3.0.0")) | |
58 | + | then "multycurve" | |
59 | + | else throw("Unknown version of pool") | |
60 | + | } | |
61 | + | ||
62 | + | ||
62 | 63 | func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address"))) | |
63 | 64 | ||
64 | 65 | ||
71 | 72 | func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), { | |
72 | 73 | let validatedAddress = getAddressIfValid(poolAddress) | |
73 | 74 | let keyName = (kPrefixPoolName + validatedAddress) | |
74 | - | let keyIndex = (kPrefixPoolIndex + validatedAddress) | |
75 | - | let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdA), "Asset id A is incorrect") | |
76 | - | let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdB), "Asset id B is incorrect") | |
77 | 75 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
78 | 76 | if (isDefined(possiblyAlreadyAddedPool)) | |
79 | 77 | then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\"")) | |
80 | - | else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((kPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(kPoolsListName, makeString((pools :+ validatedAddress), ","))] | |
78 | + | else ([StringEntry(keyName, getPoolNameIfValid(poolName))] ++ (if ((getPoolType(value(addressFromString(poolAddress))) == "multycurve")) | |
79 | + | then nil | |
80 | + | else { | |
81 | + | let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdA), "Asset id A is incorrect") | |
82 | + | let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdB), "Asset id B is incorrect") | |
83 | + | [StringEntry((((kPair + assetIdA) + "_") + assetIdB), poolAddress)] | |
84 | + | })) | |
81 | 85 | }) | |
82 | 86 | ||
83 | 87 | ||
186 | 190 | else false) | |
187 | 191 | then isSelfInvokeRemoveAchievementsWriter | |
188 | 192 | else false | |
189 | - | case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction => | |
193 | + | case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|InvokeExpressionTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction => | |
190 | 194 | signedByAdmin | |
191 | 195 | case _ => | |
192 | 196 | throw("Match error") |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let kPoolsListName = "pools" | |
5 | - | ||
6 | 4 | let kPrefixPoolName = "pool_" | |
7 | - | ||
8 | - | let kPrefixPoolIndex = "index_" | |
9 | 5 | ||
10 | 6 | let kPair = "pair_" | |
11 | 7 | ||
12 | 8 | let kAssetIdA = "A_asset_id" | |
13 | 9 | ||
14 | 10 | let kAssetIdB = "B_asset_id" | |
15 | 11 | ||
16 | 12 | let kLaunchpadDataTransactionStatus = "launchpad_data_transaction_status" | |
17 | 13 | ||
18 | 14 | let kAdminPubKey1 = "admin_pub_1" | |
19 | 15 | ||
20 | 16 | let kAdminPubKey2 = "admin_pub_2" | |
21 | 17 | ||
22 | 18 | let kAdminPubKey3 = "admin_pub_3" | |
23 | 19 | ||
24 | 20 | let kAdminInvokePubKey = "admin_invoke_pub" | |
25 | 21 | ||
26 | 22 | let kAchievementsWriters = "achievements_writers" | |
27 | 23 | ||
28 | 24 | let adminPubKey1 = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy' | |
29 | 25 | ||
30 | 26 | let adminPubKey2 = base58'GmJXRyhRA79g8yUGgKBAVdnFfQFDMjQG98b1MmLDh5kk' | |
31 | 27 | ||
32 | 28 | let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP' | |
33 | 29 | ||
34 | 30 | let adminPubKeyInvoke = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
35 | 31 | ||
36 | - | let pools = match getString(this, kPoolsListName) { | |
37 | - | case string: String => | |
38 | - | split(string, ",") | |
39 | - | case nothing => | |
40 | - | nil | |
41 | - | } | |
42 | - | ||
43 | 32 | func isSelfCall (i) = if ((i.caller == this)) | |
44 | 33 | then unit | |
45 | 34 | else throw("Only the Oracle itself can invoke this function") | |
46 | 35 | ||
47 | 36 | ||
48 | 37 | func getPoolNameIfValid (poolName) = { | |
49 | 38 | let underscoreIndex = valueOrElse(indexOf(poolName, "_"), -1) | |
50 | 39 | let underscoreLastIndex = valueOrElse(lastIndexOf(poolName, "_"), -1) | |
51 | 40 | let hasSingleUnderscore = if (if ((underscoreIndex == underscoreLastIndex)) | |
52 | 41 | then (underscoreIndex > 0) | |
53 | 42 | else false) | |
54 | 43 | then (underscoreIndex != (size(poolName) - 1)) | |
55 | 44 | else false | |
56 | 45 | if (hasSingleUnderscore) | |
57 | 46 | then poolName | |
58 | 47 | else throw("Pool name must consist of two asset names separated by an underscore character") | |
59 | 48 | } | |
60 | 49 | ||
61 | 50 | ||
51 | + | func getPoolType (poolAddress) = { | |
52 | + | let version = valueOrErrorMessage(getString(poolAddress, "version"), "Pool is not initialized") | |
53 | + | if ((version == "1.0.0")) | |
54 | + | then "cpmm" | |
55 | + | else if ((version == "2.0.0")) | |
56 | + | then "flat" | |
57 | + | else if ((version == "3.0.0")) | |
58 | + | then "multycurve" | |
59 | + | else throw("Unknown version of pool") | |
60 | + | } | |
61 | + | ||
62 | + | ||
62 | 63 | func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address"))) | |
63 | 64 | ||
64 | 65 | ||
65 | 66 | @Callable(i) | |
66 | 67 | func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(kAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(kAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(kAdminPubKey3, toBase58String(adminPubKey3)), StringEntry(kAdminInvokePubKey, toBase58String(adminPubKeyInvoke))]) | |
67 | 68 | ||
68 | 69 | ||
69 | 70 | ||
70 | 71 | @Callable(i) | |
71 | 72 | func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), { | |
72 | 73 | let validatedAddress = getAddressIfValid(poolAddress) | |
73 | 74 | let keyName = (kPrefixPoolName + validatedAddress) | |
74 | - | let keyIndex = (kPrefixPoolIndex + validatedAddress) | |
75 | - | let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdA), "Asset id A is incorrect") | |
76 | - | let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdB), "Asset id B is incorrect") | |
77 | 75 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
78 | 76 | if (isDefined(possiblyAlreadyAddedPool)) | |
79 | 77 | then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\"")) | |
80 | - | else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((kPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(kPoolsListName, makeString((pools :+ validatedAddress), ","))] | |
78 | + | else ([StringEntry(keyName, getPoolNameIfValid(poolName))] ++ (if ((getPoolType(value(addressFromString(poolAddress))) == "multycurve")) | |
79 | + | then nil | |
80 | + | else { | |
81 | + | let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdA), "Asset id A is incorrect") | |
82 | + | let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), kAssetIdB), "Asset id B is incorrect") | |
83 | + | [StringEntry((((kPair + assetIdA) + "_") + assetIdB), poolAddress)] | |
84 | + | })) | |
81 | 85 | }) | |
82 | 86 | ||
83 | 87 | ||
84 | 88 | ||
85 | 89 | @Callable(i) | |
86 | 90 | func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), { | |
87 | 91 | let validatedAddress = getAddressIfValid(poolAddress) | |
88 | 92 | let keyName = (kPrefixPoolName + validatedAddress) | |
89 | 93 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
90 | 94 | if (isDefined(possiblyAlreadyAddedPool)) | |
91 | 95 | then [StringEntry(keyName, getPoolNameIfValid(newPoolName))] | |
92 | 96 | else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added")) | |
93 | 97 | }) | |
94 | 98 | ||
95 | 99 | ||
96 | 100 | ||
97 | 101 | @Callable(i) | |
98 | 102 | func launchpadDataTransactionStatus (status) = valueOrElse(isSelfCall(i), [BooleanEntry(kLaunchpadDataTransactionStatus, status)]) | |
99 | 103 | ||
100 | 104 | ||
101 | 105 | ||
102 | 106 | @Callable(i) | |
103 | 107 | func addAchievementsWriter (address) = valueOrElse(isSelfCall(i), { | |
104 | 108 | let writers = valueOrElse(getString(this, kAchievementsWriters), "") | |
105 | 109 | let data = if ((writers == "")) | |
106 | 110 | then nil | |
107 | 111 | else split(writers, ",") | |
108 | 112 | [StringEntry(kAchievementsWriters, makeString((data :+ address), ","))] | |
109 | 113 | }) | |
110 | 114 | ||
111 | 115 | ||
112 | 116 | ||
113 | 117 | @Callable(i) | |
114 | 118 | func removeAchievementsWriter (address) = valueOrElse(isSelfCall(i), { | |
115 | 119 | let writers = split(valueOrElse(getString(this, kAchievementsWriters), ""), ",") | |
116 | 120 | let index = valueOrErrorMessage(indexOf(writers, address), "Can't find address in the list") | |
117 | 121 | [StringEntry(kAchievementsWriters, makeString(removeByIndex(writers, index), ","))] | |
118 | 122 | }) | |
119 | 123 | ||
120 | 124 | ||
121 | 125 | @Verifier(tx) | |
122 | 126 | func verify () = { | |
123 | 127 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
124 | 128 | then 1 | |
125 | 129 | else 0 | |
126 | 130 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
127 | 131 | then 1 | |
128 | 132 | else 0 | |
129 | 133 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
130 | 134 | then 1 | |
131 | 135 | else 0 | |
132 | 136 | let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
133 | 137 | let signedByAdminToCallAddPool = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 1) | |
134 | 138 | match tx { | |
135 | 139 | case inv: InvokeScriptTransaction => | |
136 | 140 | let isSelfInvokeRenamePool = if ((inv.dApp == this)) | |
137 | 141 | then containsElement(["renamePool"], inv.function) | |
138 | 142 | else false | |
139 | 143 | let isSelfInvokeSetAdmin = if ((inv.dApp == this)) | |
140 | 144 | then containsElement(["setAdmin"], inv.function) | |
141 | 145 | else false | |
142 | 146 | let isSelfInvokeAddPool = if ((inv.dApp == this)) | |
143 | 147 | then containsElement(["addPool"], inv.function) | |
144 | 148 | else false | |
145 | 149 | let isSelfInvokeLaunchpadDataTxStatus = if ((inv.dApp == this)) | |
146 | 150 | then containsElement(["launchpadDataTransactionStatus"], inv.function) | |
147 | 151 | else false | |
148 | 152 | let isSelfInvokeAddAchievementsWriter = if ((inv.dApp == this)) | |
149 | 153 | then containsElement(["addAchievementsWriter"], inv.function) | |
150 | 154 | else false | |
151 | 155 | let isSelfInvokeRemoveAchievementsWriter = if ((inv.dApp == this)) | |
152 | 156 | then containsElement(["removeAchievementsWriter"], inv.function) | |
153 | 157 | else false | |
154 | 158 | if (if (if (if (if (if (if (signedByAdmin) | |
155 | 159 | then (size(inv.payments) == 0) | |
156 | 160 | else false) | |
157 | 161 | then isSelfInvokeRenamePool | |
158 | 162 | else false) | |
159 | 163 | then true | |
160 | 164 | else if (if (signedByAdminToCallAddPool) | |
161 | 165 | then (size(inv.payments) == 0) | |
162 | 166 | else false) | |
163 | 167 | then isSelfInvokeAddPool | |
164 | 168 | else false) | |
165 | 169 | then true | |
166 | 170 | else if (if (signedByAdmin) | |
167 | 171 | then (size(inv.payments) == 0) | |
168 | 172 | else false) | |
169 | 173 | then isSelfInvokeSetAdmin | |
170 | 174 | else false) | |
171 | 175 | then true | |
172 | 176 | else if (if (signedByAdmin) | |
173 | 177 | then (size(inv.payments) == 0) | |
174 | 178 | else false) | |
175 | 179 | then isSelfInvokeLaunchpadDataTxStatus | |
176 | 180 | else false) | |
177 | 181 | then true | |
178 | 182 | else if (if (signedByAdmin) | |
179 | 183 | then (size(inv.payments) == 0) | |
180 | 184 | else false) | |
181 | 185 | then isSelfInvokeAddAchievementsWriter | |
182 | 186 | else false) | |
183 | 187 | then true | |
184 | 188 | else if (if (signedByAdmin) | |
185 | 189 | then (size(inv.payments) == 0) | |
186 | 190 | else false) | |
187 | 191 | then isSelfInvokeRemoveAchievementsWriter | |
188 | 192 | else false | |
189 | - | case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction => | |
193 | + | case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|InvokeExpressionTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction => | |
190 | 194 | signedByAdmin | |
191 | 195 | case _ => | |
192 | 196 | throw("Match error") | |
193 | 197 | } | |
194 | 198 | } | |
195 | 199 |
github/deemru/w8io/169f3d6 48.75 ms ◑