tx · 9ZsGgdMa9AwbW9TacU7RyQ3ihsRYvuugN67aSaByNe4r 3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr: -0.01000000 Waves 2024.11.26 12:09 [3388185] smart account 3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr > SELF 0.00000000 Waves
{ "type": 13, "id": "9ZsGgdMa9AwbW9TacU7RyQ3ihsRYvuugN67aSaByNe4r", "fee": 1000000, "feeAssetId": null, "timestamp": 1732612251737, "version": 2, "chainId": 84, "sender": "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr", "senderPublicKey": "jXCTQV8PjX2uC9UHBFveupYy9cjhY7stHbzE9cptymw", "proofs": [ "4gv1VEH67rq4r6V5SP8FtN78YLff9ZiPfdiroJvgL9oYxNoSG3QGxtrE86WLKXR6YNuJN3sepD6PkXKJW8fV7HYH" ], "script": "base64:BwIZCAISAwoBCBIECgICGBIECgICGBIECgICGCYACXNlcGFyYXRvcgICX18AC3dhdmVzU3RyaW5nAgVXQVZFUwAQY29udHJhY3RGaWxlbmFtZQIXbWVtZV9pbV9jYWxjdWxhdG9yLnJpZGUABW11bHQ4AIDC1y8BB3dyYXBFcnIBAXMJAKwCAgkArAICBRBjb250cmFjdEZpbGVuYW1lAgI6IAUBcwEIdGhyb3dFcnIBAXMJAAIBCQEHd3JhcEVycgEFAXMBD3ZhbGlkYXRlQWRkcmVzcwEHYWRkcmVzcwkBCWlzRGVmaW5lZAEJAKYIAQUHYWRkcmVzcwAMU1RBVFVTX0VNUFRZAAAADFNUQVRVU19SRUFEWQABAAlrU2h1dGRvd24CDnNodXRkb3duX19mbGFnAAtrUHJpY2VBc3NldAIMcHJpY2VfX2Fzc2V0AA5rTGlzdGluZ1ZvbHVtZQIPbGlzdGluZ19fdm9sdW1lAAxrQ3JlYXRpb25GZWUCEnNldHVwX19jcmVhdGlvbkZlZQAMa0N1cnZlVGFyZ2V0AhJzZXR1cF9fY3VydmVUYXJnZXQAEWtWaXJ0d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WtXfwGc5cjj89BdcPAWYkS4qy5f69 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
201 | 201 | } | |
202 | 202 | ||
203 | 203 | ||
204 | + | @Verifier(tx) | |
205 | + | func verify () = { | |
206 | + | let keyAdminAddressList = "%s__adminAddressList" | |
207 | + | let keyAllowedTxId = "%s__txId" | |
208 | + | let adminList = split(valueOrElse(getString(factoryAddress, keyAdminAddressList), ""), "__") | |
209 | + | let byOwner = if ((size(adminList) >= 3)) | |
210 | + | then false | |
211 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
212 | + | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(factoryAddress, keyAllowedTxId), ""))) | |
213 | + | if (byAdmins) | |
214 | + | then true | |
215 | + | else byOwner | |
216 | + | } | |
217 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 7 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | 5 | ||
6 | 6 | let wavesString = "WAVES" | |
7 | 7 | ||
8 | 8 | let contractFilename = "meme_im_calculator.ride" | |
9 | 9 | ||
10 | 10 | let mult8 = 100000000 | |
11 | 11 | ||
12 | 12 | func wrapErr (s) = ((contractFilename + ": ") + s) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func throwErr (s) = throw(wrapErr(s)) | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func validateAddress (address) = isDefined(addressFromString(address)) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | let STATUS_EMPTY = 0 | |
22 | 22 | ||
23 | 23 | let STATUS_READY = 1 | |
24 | 24 | ||
25 | 25 | let kShutdown = "shutdown__flag" | |
26 | 26 | ||
27 | 27 | let kPriceAsset = "price__asset" | |
28 | 28 | ||
29 | 29 | let kListingVolume = "listing__volume" | |
30 | 30 | ||
31 | 31 | let kCreationFee = "setup__creationFee" | |
32 | 32 | ||
33 | 33 | let kCurveTarget = "setup__curveTarget" | |
34 | 34 | ||
35 | 35 | let kVirtualLiquidity = "setup__virtualLiquidity" | |
36 | 36 | ||
37 | 37 | let kPoolContractHash = "pool__contract__hash" | |
38 | 38 | ||
39 | 39 | let kLastEmptyPoolIndex = "last__empty_pool__index" | |
40 | 40 | ||
41 | 41 | let kFirstEmptyPoolIndex = "first__empty__pool__index" | |
42 | 42 | ||
43 | 43 | func kPoolAddressFromIndex (index) = makeString(["pool", toString(index)], separator) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func kPoolIndexFromAddress (address) = makeString(["pool", toString(address)], separator) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func kPoolAsset (address) = makeString(["asset", toString(address)], separator) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func kPoolStatus (index) = makeString(["pool", "status", toString(index)], separator) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | let kFactoryAddress = "factory__address" | |
56 | 56 | ||
57 | 57 | let factoryAddressOption = match getString(this, kFactoryAddress) { | |
58 | 58 | case s: String => | |
59 | 59 | addressFromString(s) | |
60 | 60 | case _: Unit => | |
61 | 61 | unit | |
62 | 62 | case _ => | |
63 | 63 | throw("Match error") | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | let factoryAddress = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
67 | 67 | ||
68 | 68 | let shutdown = valueOrElse(getBoolean(factoryAddress, kShutdown), false) | |
69 | 69 | ||
70 | 70 | let lastEmptyIndex = valueOrElse(getInteger(factoryAddress, kLastEmptyPoolIndex), 0) | |
71 | 71 | ||
72 | 72 | let firstEmptyIndex = valueOrElse(getInteger(factoryAddress, kFirstEmptyPoolIndex), 0) | |
73 | 73 | ||
74 | 74 | let listingVolume = valueOrElse(getInteger(factoryAddress, kListingVolume), 0) | |
75 | 75 | ||
76 | 76 | let creationFee = valueOrElse(getInteger(factoryAddress, kCreationFee), 0) | |
77 | 77 | ||
78 | 78 | let poolContractHash = getBinary(factoryAddress, kPoolContractHash) | |
79 | 79 | ||
80 | 80 | func parseAssetId (input) = if ((input == wavesString)) | |
81 | 81 | then unit | |
82 | 82 | else fromBase58String(input) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func assetIdToString (input) = if ((input == unit)) | |
86 | 86 | then wavesString | |
87 | 87 | else toBase58String(value(input)) | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func mustAddress (caller,address) = if ((caller == address)) | |
91 | 91 | then true | |
92 | 92 | else throwErr("permission denied") | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | func mustThis (caller) = mustAddress(caller, this) | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | func mustFactory (caller) = mustAddress(caller, factoryAddress) | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func checkContractScript (address) = match poolContractHash { | |
102 | 102 | case hash: ByteVector => | |
103 | 103 | (scriptHash(address) == hash) | |
104 | 104 | case _ => | |
105 | 105 | true | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func isPoolExists (poolAddress) = isDefined(getInteger(factoryAddress, kPoolIndexFromAddress(poolAddress))) | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | @Callable(i) | |
113 | 113 | func init (factoryAddressStr) = { | |
114 | 114 | let checkCaller = mustThis(i.caller) | |
115 | 115 | if ((checkCaller == checkCaller)) | |
116 | 116 | then [StringEntry(kFactoryAddress, factoryAddressStr)] | |
117 | 117 | else throw("Strict value is not equal to itself.") | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | 122 | @Callable(i) | |
123 | 123 | func addEmptyPool (callerPublicKey,args) = { | |
124 | 124 | let newPoolAddress = addressFromPublicKey(callerPublicKey) | |
125 | 125 | let newPoolIndex = (lastEmptyIndex + 1) | |
126 | 126 | let checks = [if (!(shutdown)) | |
127 | 127 | then true | |
128 | 128 | else throwErr("not allowed (shutdown)"), if (checkContractScript(newPoolAddress)) | |
129 | 129 | then true | |
130 | 130 | else throwErr("pool script is not allowed"), if (!(isPoolExists(newPoolAddress))) | |
131 | 131 | then true | |
132 | 132 | else throwErr("pool address is already registered")] | |
133 | 133 | if ((checks == checks)) | |
134 | 134 | then { | |
135 | 135 | let factoryActions = [invoke(factoryAddress, "integerEntry", [kLastEmptyPoolIndex, newPoolIndex], nil), invoke(factoryAddress, "stringEntry", [kPoolAddressFromIndex(newPoolIndex), toString(newPoolAddress)], nil), invoke(factoryAddress, "integerEntry", [kPoolIndexFromAddress(newPoolAddress), newPoolIndex], nil), invoke(factoryAddress, "integerEntry", [kPoolStatus(newPoolIndex), STATUS_EMPTY], nil)] | |
136 | 136 | $Tuple2(nil, factoryActions) | |
137 | 137 | } | |
138 | 138 | else throw("Strict value is not equal to itself.") | |
139 | 139 | } | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | ||
143 | 143 | @Callable(i) | |
144 | 144 | func createPool (callerPublicKey,args) = { | |
145 | 145 | let minPayment = (listingVolume + creationFee) | |
146 | 146 | let checks = [if (!(shutdown)) | |
147 | 147 | then true | |
148 | 148 | else throwErr("Temporary shutdown"), mustFactory(i.caller), if (((lastEmptyIndex - firstEmptyIndex) > 0)) | |
149 | 149 | then true | |
150 | 150 | else throwErr("No empty pool available"), if ((i.payments[0].assetId == unit)) | |
151 | 151 | then true | |
152 | 152 | else throwErr("Payment should be in WAVES"), if ((i.payments[0].amount >= minPayment)) | |
153 | 153 | then true | |
154 | 154 | else throwErr((("Payment should be greater or equal " + toString(minPayment)) + " WAVELET")), if (isDefined(args[0])) | |
155 | 155 | then true | |
156 | 156 | else throwErr("Token name is not provided"), if (isDefined(args[1])) | |
157 | 157 | then true | |
158 | 158 | else throwErr("Token description is not provided"), if (isDefined(args[2])) | |
159 | 159 | then true | |
160 | 160 | else throwErr("Token quantity is not provided"), if ((parseInt(args[2]) != unit)) | |
161 | 161 | then true | |
162 | 162 | else throwErr("Token quantity should be a number")] | |
163 | 163 | if ((checks == checks)) | |
164 | 164 | then { | |
165 | 165 | let poolIndex = (firstEmptyIndex + 1) | |
166 | 166 | let poolAddressString = getStringValue(factoryAddress, kPoolAddressFromIndex(poolIndex)) | |
167 | 167 | let poolAddress = addressFromStringValue(poolAddressString) | |
168 | 168 | let callerAddress = addressFromPublicKey(callerPublicKey) | |
169 | 169 | let poolDomain = take(poolAddressString, 8) | |
170 | 170 | let poolOwner = toString(callerAddress) | |
171 | 171 | let tokenName = args[0] | |
172 | 172 | let tokenDesc = args[1] | |
173 | 173 | let tokenQuantity = args[2] | |
174 | 174 | let initPoolInvoke = invoke(factoryAddress, "initPoolInvoke", [poolAddressString, [poolDomain, poolOwner, tokenName, tokenDesc, tokenQuantity]], [AttachedPayment(i.payments[0].assetId, i.payments[0].amount)]) | |
175 | 175 | if ((initPoolInvoke == initPoolInvoke)) | |
176 | 176 | then { | |
177 | 177 | let factoryActions = [invoke(factoryAddress, "integerEntry", [kFirstEmptyPoolIndex, poolIndex], nil), invoke(factoryAddress, "integerEntry", [kPoolStatus(poolIndex), STATUS_READY], nil)] | |
178 | 178 | $Tuple2(nil, factoryActions) | |
179 | 179 | } | |
180 | 180 | else throw("Strict value is not equal to itself.") | |
181 | 181 | } | |
182 | 182 | else throw("Strict value is not equal to itself.") | |
183 | 183 | } | |
184 | 184 | ||
185 | 185 | ||
186 | 186 | ||
187 | 187 | @Callable(i) | |
188 | 188 | func notifyStatusUpdate (callerPublicKey,args) = { | |
189 | 189 | let poolAddress = addressFromPublicKey(callerPublicKey) | |
190 | 190 | let checks = [if (isPoolExists(poolAddress)) | |
191 | 191 | then true | |
192 | 192 | else throwErr("pool not found"), mustFactory(i.caller)] | |
193 | 193 | if ((checks == checks)) | |
194 | 194 | then { | |
195 | 195 | let poolIndex = getIntegerValue(factoryAddress, kPoolIndexFromAddress(poolAddress)) | |
196 | 196 | let newStatus = parseIntValue(args[0]) | |
197 | 197 | let factoryActions = [invoke(factoryAddress, "integerEntry", [kPoolStatus(poolIndex), newStatus], nil)] | |
198 | 198 | $Tuple2(nil, factoryActions) | |
199 | 199 | } | |
200 | 200 | else throw("Strict value is not equal to itself.") | |
201 | 201 | } | |
202 | 202 | ||
203 | 203 | ||
204 | + | @Verifier(tx) | |
205 | + | func verify () = { | |
206 | + | let keyAdminAddressList = "%s__adminAddressList" | |
207 | + | let keyAllowedTxId = "%s__txId" | |
208 | + | let adminList = split(valueOrElse(getString(factoryAddress, keyAdminAddressList), ""), "__") | |
209 | + | let byOwner = if ((size(adminList) >= 3)) | |
210 | + | then false | |
211 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
212 | + | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(factoryAddress, keyAllowedTxId), ""))) | |
213 | + | if (byAdmins) | |
214 | + | then true | |
215 | + | else byOwner | |
216 | + | } | |
217 | + |
github/deemru/w8io/026f985 28.95 ms ◑