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