tx · 8FBo93fXARxRaEYLjaAoAqenXTR38bRWxmTbyb4zAoNV 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9: -0.01400000 Waves 2021.08.18 16:17 [1663827] smart account 3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9 > SELF 0.00000000 Waves
{ "type": 13, "id": "8FBo93fXARxRaEYLjaAoAqenXTR38bRWxmTbyb4zAoNV", "fee": 1400000, "feeAssetId": null, "timestamp": 1629292681470, "version": 2, "chainId": 84, "sender": "3NBBWfzZtZtszaXbitTKnrB2xXwv26Bn7H9", "senderPublicKey": "D1X9WatF6ARMCmm3jC4Ex5Wd5VQ3LY8i1xbHNqeHqeAa", "proofs": [ "vJwmQvFWaYxrCbQRWwHzquYxtrZ2iGy86rDucsL7g2HmRA4dR9TGYYz9B7cUiRa8ZWGSvTAUvPG3qf6vYmaWLoV", "5is7raXugGLYNPKAynsS757qazakjN5iwLBEFDJm1SBnsnQcySg8aydTkjhwYmmUfjMtQrbkqVLdvXg2UW8WT7mu" ], "script": "base64:AAIFAAAAAAAAABAIAhIAEgQKAggIEgQKAggIAAAAEwAAAAAQa2V5UG9vbHNMaXN0TmFtZQIAAAAFcG9vbHMAAAAAEWtleVByZWZpeFBvb2xOYW1lAgAAAAVwb29sXwAAAAASa2V5UHJlZml4UG9vbEluZGV4AgAAAAZpbmRleF8AAAAAEWtleUluaXRQb29sSGVpZ2h0AgAAABFpbml0X3Bvb2xfaGVpZ2h0XwAAAAASa2V5Q29uZmlybWVkQXNzZXRzAgAAABBjb25maXJtZWRfYXNzZXRzAAAAABBrZXlBc3NldFByaW9yaXR5AgAAAA9hc3NldF9wcmlvcml0eV8AAAAAB2tleVBhaXICAAAABXBhaXJfAAAAAAtrZXlBc3NldElkQQIAAAAKQV9hc3NldF9pZAAAAAALa2V5QXNzZXRJZEICAAAACkJfYXNzZXRfaWQAAAAAD2tleUFkbWluUHViS2V5MQIAAAALYWRtaW5fcHViXzEAAAAAD2tleUFkbWluUHViS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jdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAWQ3JlYXRlQWxpYXNUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFkxlYXNlQ2FuY2VsVHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABBMZWFzZVRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAQSXNzdWVUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAGlVwZGF0ZUFzc2V0SW5mb1RyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAXSW52b2tlU2NyaXB0VHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABlTZXRBc3NldFNjcmlwdFRyYW5zYWN0aW9uBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE0V4Y2hhbmdlVHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdNYXNzVHJhbnNmZXJUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0J1cm5UcmFuc2FjdGlvbgYJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAASUmVpc3N1ZVRyYW5zYWN0aW9uBQAAAA1zaWduZWRCeUFkbWluCQAAAgAAAAECAAAAC01hdGNoIGVycm9yIVwaLw==", "height": 1663827, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CmW44eM4AhggAhNWfxXpXA1YBNrXb8FFjyiCWVWmj2fF Next: FFpUMsAPjD53ymn7sGi6uq928a2nwfuGLDzEuW85xiE2 Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let keyPrefixPoolName = "pool_" | |
7 | 7 | ||
8 | 8 | let keyPrefixPoolIndex = "index_" | |
9 | + | ||
10 | + | let keyInitPoolHeight = "init_pool_height_" | |
9 | 11 | ||
10 | 12 | let keyConfirmedAssets = "confirmed_assets" | |
11 | 13 | ||
16 | 18 | let keyAssetIdA = "A_asset_id" | |
17 | 19 | ||
18 | 20 | let keyAssetIdB = "B_asset_id" | |
19 | - | ||
20 | - | let keyOracleScriptHashCPMM = "script_hash_cpmm" | |
21 | - | ||
22 | - | let keyOracleScriptHashFlat = "script_hash_flat" | |
23 | - | ||
24 | - | let cpmmScriptReferenesAddress = base58'3N77kfPbQyjXWpDALX3xjKw3iEGMWEctV37' | |
25 | - | ||
26 | - | let flatScriptReferenesAddress = base58'3N5Xd7QVQZWntaJwha9Kg42is626GUPjtUW' | |
27 | 21 | ||
28 | 22 | let keyAdminPubKey1 = "admin_pub_1" | |
29 | 23 | ||
37 | 31 | ||
38 | 32 | let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP' | |
39 | 33 | ||
40 | - | let adminStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
41 | - | ||
42 | - | let adminStaking = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
43 | - | ||
44 | 34 | let pools = match getString(this, keyPoolsListName) { | |
45 | 35 | case string: String => | |
46 | 36 | split(string, ",") | |
50 | 40 | ||
51 | 41 | func isSelfCall (i) = if ((i.caller == this)) | |
52 | 42 | then unit | |
53 | - | else | |
43 | + | else throw("Only the Oracle itself can invoke this function") | |
54 | 44 | ||
55 | 45 | ||
56 | 46 | func getPoolNameIfValid (poolName) = { | |
71 | 61 | ||
72 | 62 | ||
73 | 63 | @Callable(i) | |
74 | - | func setPriority (assetId,priority) = valueOrElse(isSelfCall(i), if ((0 > priority)) | |
75 | - | then throw("Priority must be positive") | |
76 | - | else [IntegerEntry((keyAssetPriority + assetId), priority)]) | |
77 | - | ||
78 | - | ||
79 | - | ||
80 | - | @Callable(i) | |
81 | 64 | func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(keyAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(keyAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(keyAdminPubKey3, toBase58String(adminPubKey3))]) | |
82 | 65 | ||
83 | 66 | ||
89 | 72 | let keyIndex = (keyPrefixPoolIndex + validatedAddress) | |
90 | 73 | let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdA), "Asset id A is incorrect") | |
91 | 74 | let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdB), "Asset id B is incorrect") | |
92 | - | let check = isDataStorageUntouched(this) | |
93 | - | let userScriptHash = value(scriptHash(i.caller)) | |
94 | - | let cpmmHash = getBinaryValue(keyOracleScriptHashCPMM) | |
95 | - | let flatHash = getBinaryValue(keyOracleScriptHashFlat) | |
96 | - | let isNotCpmm = if ((userScriptHash != cpmmHash)) | |
97 | - | then true | |
98 | - | else false | |
99 | - | let isNotFlat = if ((userScriptHash != flatHash)) | |
100 | - | then true | |
101 | - | else false | |
102 | - | let isNotEmptyData = if ((!(check) == true)) | |
103 | - | then true | |
104 | - | else false | |
105 | - | let isEmptyData = if ((!(check) == false)) | |
106 | - | then true | |
107 | - | else false | |
108 | - | let isNotEmpty = if ((check == false)) | |
109 | - | then true | |
110 | - | else false | |
111 | - | let isEmpty = if ((check == true)) | |
112 | - | then true | |
113 | - | else false | |
114 | - | let isNotPoolContract = if (if (isNotCpmm) | |
115 | - | then isNotFlat | |
116 | - | else false) | |
117 | - | then true | |
118 | - | else false | |
119 | - | if (if (isNotPoolContract) | |
120 | - | then true | |
121 | - | else if (if (if (isNotEmptyData) | |
122 | - | then !(isEmptyData) | |
123 | - | else false) | |
124 | - | then isNotEmpty | |
125 | - | else false) | |
126 | - | then !(isEmpty) | |
127 | - | else false) | |
128 | - | then throw("Unexpected script was found.") | |
129 | - | else { | |
130 | - | let possiblyAlreadyAddedPool = getString(this, keyName) | |
131 | - | let possibleDuplicateA = getString(this, (((keyPair + assetIdA) + "_") + assetIdB)) | |
132 | - | let possibleDuplicateB = getString(this, (((keyPair + assetIdB) + "_") + assetIdA)) | |
133 | - | if (isDefined(possiblyAlreadyAddedPool)) | |
134 | - | then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\"")) | |
135 | - | else if (if (isDefined(possibleDuplicateA)) | |
136 | - | then true | |
137 | - | else isDefined(possibleDuplicateB)) | |
138 | - | then throw((((("Pool with assets \"" + assetIdA) + "\" and \"") + assetIdB) + "\" is already exists")) | |
139 | - | else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))] | |
140 | - | } | |
75 | + | let possiblyAlreadyAddedPool = getString(this, keyName) | |
76 | + | if (isDefined(possiblyAlreadyAddedPool)) | |
77 | + | then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\"")) | |
78 | + | else [IntegerEntry(keyIndex, size(pools)), IntegerEntry((keyInitPoolHeight + poolAddress), height), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))] | |
141 | 79 | }) | |
142 | 80 | ||
143 | 81 | ||
151 | 89 | then [StringEntry(keyName, getPoolNameIfValid(newPoolName))] | |
152 | 90 | else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added")) | |
153 | 91 | }) | |
154 | - | ||
155 | - | ||
156 | - | ||
157 | - | @Callable(i) | |
158 | - | func updateHashes () = valueOrElse(isSelfCall(i), [BinaryEntry(keyOracleScriptHashCPMM, value(scriptHash(Address(cpmmScriptReferenesAddress)))), BinaryEntry(keyOracleScriptHashFlat, value(scriptHash(Address(flatScriptReferenesAddress))))]) | |
159 | 92 | ||
160 | 93 | ||
161 | 94 | @Verifier(tx) | |
179 | 112 | let isSelfInvokeSetAdmin = if ((inv.dApp == this)) | |
180 | 113 | then containsElement(["setAdmin"], inv.function) | |
181 | 114 | else false | |
182 | - | let isInvokeAddPool = containsElement(["addPool"], inv.function) | |
183 | - | let isSelfInvokeUpdateHashes = if ((inv.dApp == this)) | |
184 | - | then containsElement(["updateHashes"], inv.function) | |
115 | + | let isSelfInvokeAddPool = if ((inv.dApp == this)) | |
116 | + | then containsElement(["addPool"], inv.function) | |
185 | 117 | else false | |
186 | - | if (if (if (if ( | |
118 | + | if (if (if (if (signedByAdmin) | |
187 | 119 | then (size(inv.payments) == 0) | |
188 | 120 | else false) | |
189 | 121 | then isSelfInvokeRenamePool | |
190 | 122 | else false) | |
191 | 123 | then true | |
192 | - | else if ((size(inv.payments) == 0)) | |
193 | - | then isInvokeAddPool | |
124 | + | else if (if (signedByAdminToCallAddPool) | |
125 | + | then (size(inv.payments) == 0) | |
126 | + | else false) | |
127 | + | then isSelfInvokeAddPool | |
194 | 128 | else false) | |
195 | 129 | then true | |
196 | 130 | else if (if (signedByAdmin) | |
197 | 131 | then (size(inv.payments) == 0) | |
198 | 132 | else false) | |
199 | 133 | then isSelfInvokeSetAdmin | |
200 | - | else false) | |
201 | - | then true | |
202 | - | else if (if (signedByAdmin) | |
203 | - | then (size(inv.payments) == 0) | |
204 | - | else false) | |
205 | - | then isSelfInvokeUpdateHashes | |
206 | 134 | else false | |
207 | 135 | case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction => | |
208 | 136 | signedByAdmin |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let keyPoolsListName = "pools" | |
5 | 5 | ||
6 | 6 | let keyPrefixPoolName = "pool_" | |
7 | 7 | ||
8 | 8 | let keyPrefixPoolIndex = "index_" | |
9 | + | ||
10 | + | let keyInitPoolHeight = "init_pool_height_" | |
9 | 11 | ||
10 | 12 | let keyConfirmedAssets = "confirmed_assets" | |
11 | 13 | ||
12 | 14 | let keyAssetPriority = "asset_priority_" | |
13 | 15 | ||
14 | 16 | let keyPair = "pair_" | |
15 | 17 | ||
16 | 18 | let keyAssetIdA = "A_asset_id" | |
17 | 19 | ||
18 | 20 | let keyAssetIdB = "B_asset_id" | |
19 | - | ||
20 | - | let keyOracleScriptHashCPMM = "script_hash_cpmm" | |
21 | - | ||
22 | - | let keyOracleScriptHashFlat = "script_hash_flat" | |
23 | - | ||
24 | - | let cpmmScriptReferenesAddress = base58'3N77kfPbQyjXWpDALX3xjKw3iEGMWEctV37' | |
25 | - | ||
26 | - | let flatScriptReferenesAddress = base58'3N5Xd7QVQZWntaJwha9Kg42is626GUPjtUW' | |
27 | 21 | ||
28 | 22 | let keyAdminPubKey1 = "admin_pub_1" | |
29 | 23 | ||
30 | 24 | let keyAdminPubKey2 = "admin_pub_2" | |
31 | 25 | ||
32 | 26 | let keyAdminPubKey3 = "admin_pub_3" | |
33 | 27 | ||
34 | 28 | let adminPubKey1 = base58'GFmKZ2naZFRoCvNbwKAQVGmLb1uBeWGDgFabdGBuZiuy' | |
35 | 29 | ||
36 | 30 | let adminPubKey2 = base58'GmJXRyhRA79g8yUGgKBAVdnFfQFDMjQG98b1MmLDh5kk' | |
37 | 31 | ||
38 | 32 | let adminPubKey3 = base58'CFhbV6h41hVjbGHudGtS3fYUv7QAKRxFQzKNtx4B5PqP' | |
39 | 33 | ||
40 | - | let adminStartStop = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
41 | - | ||
42 | - | let adminStaking = base58'Kn7NpzaG12dLZgcHf2ipUftU6hbJygmrhFqQYE4B7ZK' | |
43 | - | ||
44 | 34 | let pools = match getString(this, keyPoolsListName) { | |
45 | 35 | case string: String => | |
46 | 36 | split(string, ",") | |
47 | 37 | case nothing => | |
48 | 38 | nil | |
49 | 39 | } | |
50 | 40 | ||
51 | 41 | func isSelfCall (i) = if ((i.caller == this)) | |
52 | 42 | then unit | |
53 | - | else | |
43 | + | else throw("Only the Oracle itself can invoke this function") | |
54 | 44 | ||
55 | 45 | ||
56 | 46 | func getPoolNameIfValid (poolName) = { | |
57 | 47 | let underscoreIndex = valueOrElse(indexOf(poolName, "_"), -1) | |
58 | 48 | let underscoreLastIndex = valueOrElse(lastIndexOf(poolName, "_"), -1) | |
59 | 49 | let hasSingleUnderscore = if (if ((underscoreIndex == underscoreLastIndex)) | |
60 | 50 | then (underscoreIndex > 0) | |
61 | 51 | else false) | |
62 | 52 | then (underscoreIndex != (size(poolName) - 1)) | |
63 | 53 | else false | |
64 | 54 | if (hasSingleUnderscore) | |
65 | 55 | then poolName | |
66 | 56 | else throw("Pool name must consist of two asset names separated by an underscore character") | |
67 | 57 | } | |
68 | 58 | ||
69 | 59 | ||
70 | 60 | func getAddressIfValid (address) = toString(valueOrErrorMessage(addressFromString(address), (("Can't parse \"" + address) + "\" as address"))) | |
71 | 61 | ||
72 | 62 | ||
73 | 63 | @Callable(i) | |
74 | - | func setPriority (assetId,priority) = valueOrElse(isSelfCall(i), if ((0 > priority)) | |
75 | - | then throw("Priority must be positive") | |
76 | - | else [IntegerEntry((keyAssetPriority + assetId), priority)]) | |
77 | - | ||
78 | - | ||
79 | - | ||
80 | - | @Callable(i) | |
81 | 64 | func setAdmin () = valueOrElse(isSelfCall(i), [StringEntry(keyAdminPubKey1, toBase58String(adminPubKey1)), StringEntry(keyAdminPubKey2, toBase58String(adminPubKey2)), StringEntry(keyAdminPubKey3, toBase58String(adminPubKey3))]) | |
82 | 65 | ||
83 | 66 | ||
84 | 67 | ||
85 | 68 | @Callable(i) | |
86 | 69 | func addPool (poolAddress,poolName) = valueOrElse(isSelfCall(i), { | |
87 | 70 | let validatedAddress = getAddressIfValid(poolAddress) | |
88 | 71 | let keyName = (keyPrefixPoolName + validatedAddress) | |
89 | 72 | let keyIndex = (keyPrefixPoolIndex + validatedAddress) | |
90 | 73 | let assetIdA = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdA), "Asset id A is incorrect") | |
91 | 74 | let assetIdB = valueOrErrorMessage(getString(value(addressFromString(poolAddress)), keyAssetIdB), "Asset id B is incorrect") | |
92 | - | let check = isDataStorageUntouched(this) | |
93 | - | let userScriptHash = value(scriptHash(i.caller)) | |
94 | - | let cpmmHash = getBinaryValue(keyOracleScriptHashCPMM) | |
95 | - | let flatHash = getBinaryValue(keyOracleScriptHashFlat) | |
96 | - | let isNotCpmm = if ((userScriptHash != cpmmHash)) | |
97 | - | then true | |
98 | - | else false | |
99 | - | let isNotFlat = if ((userScriptHash != flatHash)) | |
100 | - | then true | |
101 | - | else false | |
102 | - | let isNotEmptyData = if ((!(check) == true)) | |
103 | - | then true | |
104 | - | else false | |
105 | - | let isEmptyData = if ((!(check) == false)) | |
106 | - | then true | |
107 | - | else false | |
108 | - | let isNotEmpty = if ((check == false)) | |
109 | - | then true | |
110 | - | else false | |
111 | - | let isEmpty = if ((check == true)) | |
112 | - | then true | |
113 | - | else false | |
114 | - | let isNotPoolContract = if (if (isNotCpmm) | |
115 | - | then isNotFlat | |
116 | - | else false) | |
117 | - | then true | |
118 | - | else false | |
119 | - | if (if (isNotPoolContract) | |
120 | - | then true | |
121 | - | else if (if (if (isNotEmptyData) | |
122 | - | then !(isEmptyData) | |
123 | - | else false) | |
124 | - | then isNotEmpty | |
125 | - | else false) | |
126 | - | then !(isEmpty) | |
127 | - | else false) | |
128 | - | then throw("Unexpected script was found.") | |
129 | - | else { | |
130 | - | let possiblyAlreadyAddedPool = getString(this, keyName) | |
131 | - | let possibleDuplicateA = getString(this, (((keyPair + assetIdA) + "_") + assetIdB)) | |
132 | - | let possibleDuplicateB = getString(this, (((keyPair + assetIdB) + "_") + assetIdA)) | |
133 | - | if (isDefined(possiblyAlreadyAddedPool)) | |
134 | - | then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\"")) | |
135 | - | else if (if (isDefined(possibleDuplicateA)) | |
136 | - | then true | |
137 | - | else isDefined(possibleDuplicateB)) | |
138 | - | then throw((((("Pool with assets \"" + assetIdA) + "\" and \"") + assetIdB) + "\" is already exists")) | |
139 | - | else [IntegerEntry(keyIndex, size(pools)), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))] | |
140 | - | } | |
75 | + | let possiblyAlreadyAddedPool = getString(this, keyName) | |
76 | + | if (isDefined(possiblyAlreadyAddedPool)) | |
77 | + | then throw((((("Pool with address \"" + validatedAddress) + "\" is already defined with name \"") + value(possiblyAlreadyAddedPool)) + "\"")) | |
78 | + | else [IntegerEntry(keyIndex, size(pools)), IntegerEntry((keyInitPoolHeight + poolAddress), height), StringEntry(keyName, getPoolNameIfValid(poolName)), StringEntry((((keyPair + assetIdA) + "_") + assetIdB), poolAddress), StringEntry(keyPoolsListName, makeString((pools :+ validatedAddress), ","))] | |
141 | 79 | }) | |
142 | 80 | ||
143 | 81 | ||
144 | 82 | ||
145 | 83 | @Callable(i) | |
146 | 84 | func renamePool (poolAddress,newPoolName) = valueOrElse(isSelfCall(i), { | |
147 | 85 | let validatedAddress = getAddressIfValid(poolAddress) | |
148 | 86 | let keyName = (keyPrefixPoolName + validatedAddress) | |
149 | 87 | let possiblyAlreadyAddedPool = getString(this, keyName) | |
150 | 88 | if (isDefined(possiblyAlreadyAddedPool)) | |
151 | 89 | then [StringEntry(keyName, getPoolNameIfValid(newPoolName))] | |
152 | 90 | else throw((("Pool with address \"" + validatedAddress) + "\" has not yet been added")) | |
153 | 91 | }) | |
154 | - | ||
155 | - | ||
156 | - | ||
157 | - | @Callable(i) | |
158 | - | func updateHashes () = valueOrElse(isSelfCall(i), [BinaryEntry(keyOracleScriptHashCPMM, value(scriptHash(Address(cpmmScriptReferenesAddress)))), BinaryEntry(keyOracleScriptHashFlat, value(scriptHash(Address(flatScriptReferenesAddress))))]) | |
159 | 92 | ||
160 | 93 | ||
161 | 94 | @Verifier(tx) | |
162 | 95 | func verify () = { | |
163 | 96 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
164 | 97 | then 1 | |
165 | 98 | else 0 | |
166 | 99 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
167 | 100 | then 1 | |
168 | 101 | else 0 | |
169 | 102 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
170 | 103 | then 1 | |
171 | 104 | else 0 | |
172 | 105 | let signedByAdmin = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
173 | 106 | let signedByAdminToCallAddPool = (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 1) | |
174 | 107 | match tx { | |
175 | 108 | case inv: InvokeScriptTransaction => | |
176 | 109 | let isSelfInvokeRenamePool = if ((inv.dApp == this)) | |
177 | 110 | then containsElement(["renamePool"], inv.function) | |
178 | 111 | else false | |
179 | 112 | let isSelfInvokeSetAdmin = if ((inv.dApp == this)) | |
180 | 113 | then containsElement(["setAdmin"], inv.function) | |
181 | 114 | else false | |
182 | - | let isInvokeAddPool = containsElement(["addPool"], inv.function) | |
183 | - | let isSelfInvokeUpdateHashes = if ((inv.dApp == this)) | |
184 | - | then containsElement(["updateHashes"], inv.function) | |
115 | + | let isSelfInvokeAddPool = if ((inv.dApp == this)) | |
116 | + | then containsElement(["addPool"], inv.function) | |
185 | 117 | else false | |
186 | - | if (if (if (if ( | |
118 | + | if (if (if (if (signedByAdmin) | |
187 | 119 | then (size(inv.payments) == 0) | |
188 | 120 | else false) | |
189 | 121 | then isSelfInvokeRenamePool | |
190 | 122 | else false) | |
191 | 123 | then true | |
192 | - | else if ((size(inv.payments) == 0)) | |
193 | - | then isInvokeAddPool | |
124 | + | else if (if (signedByAdminToCallAddPool) | |
125 | + | then (size(inv.payments) == 0) | |
126 | + | else false) | |
127 | + | then isSelfInvokeAddPool | |
194 | 128 | else false) | |
195 | 129 | then true | |
196 | 130 | else if (if (signedByAdmin) | |
197 | 131 | then (size(inv.payments) == 0) | |
198 | 132 | else false) | |
199 | 133 | then isSelfInvokeSetAdmin | |
200 | - | else false) | |
201 | - | then true | |
202 | - | else if (if (signedByAdmin) | |
203 | - | then (size(inv.payments) == 0) | |
204 | - | else false) | |
205 | - | then isSelfInvokeUpdateHashes | |
206 | 134 | else false | |
207 | 135 | case _: Order|DataTransaction|SponsorFeeTransaction|SetScriptTransaction|CreateAliasTransaction|LeaseCancelTransaction|LeaseTransaction|IssueTransaction|UpdateAssetInfoTransaction|InvokeScriptTransaction|SetAssetScriptTransaction|TransferTransaction|ExchangeTransaction|MassTransferTransaction|BurnTransaction|ReissueTransaction => | |
208 | 136 | signedByAdmin | |
209 | 137 | case _ => | |
210 | 138 | throw("Match error") | |
211 | 139 | } | |
212 | 140 | } | |
213 | 141 |
github/deemru/w8io/169f3d6 43.85 ms ◑