tx · 7HhGoX2KGrwQJWc9LaBuDMmvHpLNsCrLd6o8dnoh7w5s 3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr: -0.00500000 Waves 2024.10.11 09:44 [3321827] smart account 3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr > SELF 0.00000000 Waves
{ "type": 13, "id": "7HhGoX2KGrwQJWc9LaBuDMmvHpLNsCrLd6o8dnoh7w5s", "fee": 500000, "feeAssetId": null, "timestamp": 1728629047266, "version": 2, "chainId": 84, "sender": "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr", "senderPublicKey": "jXCTQV8PjX2uC9UHBFveupYy9cjhY7stHbzE9cptymw", "proofs": [ "2yv83nketEUfwKPtCNAxz4fVqTxMUWpWuxAz4kQXsxFnJkjX5cok8fxBp2M5P3S1sEW73L3SjSXgBA8Agmp6zZid" ], "script": "base64:BwIZCAISAwoBCBIECgICGBIECgICGBIECgICGCEACXNlcGFyYXRvcgICX18AC3dhdmVzU3RyaW5nAgVXQVZFUwAQY29udHJhY3RGaWxlbmFtZQIXbWVtZV9pbV9jYWxjdWxhdG9yLnJpZGUABW11bHQ4AIDC1y8BB3dyYXBFcnIBAXMJAKwCAgkArAICBRBjb250cmFjdEZpbGVuYW1lAgI6IAUBcwEIdGhyb3dFcnIBAXMJAAIBCQEHd3JhcEVycgEFAXMBD3ZhbGlkYXRlQWRkcmVzcwEHYWRkcmVzcwkBCWlzRGVmaW5lZAEJAKYIAQUHYWRkcmVzcwAMU1RBVFVTX0VNUFRZAAAADFNUQVRVU19SRUFEWQABAAlrU2h1dGRvd24CDnNodXRkb3duX19mbGFnAAtrUHJpY2VBc3NldAIMcHJpY2VfX2Fzc2V0AA5rTGlzdGluZ1ZvbHVtZQIPbGlzdGluZ19fdm9sdW1lABFrUG9vbENvbnRyYWN0SGFzaAIUcG9vbF9fY29udHJhY3RfX2hhc2gAE2tMYXN0RW1wdHlQb29sSW5kZXgCF2xhc3RfX2VtcHR5X3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ArA2R5uTSP7nBTy Diff:
Old | New | Differences | |
---|---|---|---|
91 | 91 | func poolContractHash () = valueOrErrorMessage(getBinary(factoryAddress, kPoolContractHash), wrapErr("pool contract script hash is not set")) | |
92 | 92 | ||
93 | 93 | ||
94 | + | func isPoolExists (poolAddress) = isDefined(getInteger(factoryAddress, kPoolIndexFromAddress(poolAddress))) | |
95 | + | ||
96 | + | ||
94 | 97 | @Callable(i) | |
95 | 98 | func init (factoryAddressStr) = { | |
96 | 99 | let checkCaller = mustThis(i.caller) | |
107 | 110 | let newPoolIndex = (lastEmptyIndex + 1) | |
108 | 111 | let checks = [if (!(shutdown)) | |
109 | 112 | then true | |
110 | - | else throwErr("not allowed (shutdown)"), if (!( | |
113 | + | else throwErr("not allowed (shutdown)"), if (!(isPoolExists(newPoolAddress))) | |
111 | 114 | then true | |
112 | 115 | else throwErr("pool address is already registered")] | |
113 | 116 | if ((checks == checks)) | |
160 | 163 | } | |
161 | 164 | ||
162 | 165 | ||
166 | + | ||
167 | + | @Callable(i) | |
168 | + | func notifyStatusUpdate (callerPublicKey,args) = { | |
169 | + | let poolAddress = addressFromPublicKey(callerPublicKey) | |
170 | + | let checks = [if (isPoolExists(poolAddress)) | |
171 | + | then true | |
172 | + | else throwErr("pool not found")] | |
173 | + | if ((checks == checks)) | |
174 | + | then { | |
175 | + | let poolIndex = getIntegerValue(factoryAddress, kPoolIndexFromAddress(poolAddress)) | |
176 | + | let newStatus = parseIntValue(args[0]) | |
177 | + | let factoryActions = [invoke(factoryAddress, "integerEntry", [kPoolStatus(poolIndex), newStatus], nil)] | |
178 | + | $Tuple2(nil, factoryActions) | |
179 | + | } | |
180 | + | else throw("Strict value is not equal to itself.") | |
181 | + | } | |
182 | + | ||
183 | + |
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 kPoolContractHash = "pool__contract__hash" | |
32 | 32 | ||
33 | 33 | let kLastEmptyPoolIndex = "last__empty_pool__index" | |
34 | 34 | ||
35 | 35 | let kFirstEmptyPoolIndex = "first__empty__pool__index" | |
36 | 36 | ||
37 | 37 | func kPoolAddressFromIndex (index) = makeString(["pool", toString(index)], separator) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func kPoolIndexFromAddress (address) = makeString(["pool", toString(address)], separator) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func kPoolAsset (address) = makeString(["asset", toString(address)], separator) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func kPoolStatus (index) = makeString(["pool", "status", toString(index)], separator) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | let kFactoryAddress = "factory__address" | |
50 | 50 | ||
51 | 51 | let factoryAddressOption = match getString(this, kFactoryAddress) { | |
52 | 52 | case s: String => | |
53 | 53 | addressFromString(s) | |
54 | 54 | case _: Unit => | |
55 | 55 | unit | |
56 | 56 | case _ => | |
57 | 57 | throw("Match error") | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | let factoryAddress = valueOrErrorMessage(factoryAddressOption, wrapErr("invalid factory address")) | |
61 | 61 | ||
62 | 62 | let shutdown = valueOrElse(getBoolean(factoryAddress, kShutdown), false) | |
63 | 63 | ||
64 | 64 | let lastEmptyIndex = valueOrElse(getInteger(factoryAddress, kLastEmptyPoolIndex), 0) | |
65 | 65 | ||
66 | 66 | let firstEmptyIndex = valueOrElse(getInteger(factoryAddress, kFirstEmptyPoolIndex), 0) | |
67 | 67 | ||
68 | 68 | let listingVolume = valueOrElse(getInteger(factoryAddress, kListingVolume), 0) | |
69 | 69 | ||
70 | 70 | func parseAssetId (input) = if ((input == wavesString)) | |
71 | 71 | then unit | |
72 | 72 | else fromBase58String(input) | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func assetIdToString (input) = if ((input == unit)) | |
76 | 76 | then wavesString | |
77 | 77 | else toBase58String(value(input)) | |
78 | 78 | ||
79 | 79 | ||
80 | 80 | func mustAddress (caller,address) = if ((caller == address)) | |
81 | 81 | then true | |
82 | 82 | else throwErr("permission denied") | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func mustThis (caller) = mustAddress(caller, this) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func mustFactory (caller) = mustAddress(caller, factoryAddress) | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func poolContractHash () = valueOrErrorMessage(getBinary(factoryAddress, kPoolContractHash), wrapErr("pool contract script hash is not set")) | |
92 | 92 | ||
93 | 93 | ||
94 | + | func isPoolExists (poolAddress) = isDefined(getInteger(factoryAddress, kPoolIndexFromAddress(poolAddress))) | |
95 | + | ||
96 | + | ||
94 | 97 | @Callable(i) | |
95 | 98 | func init (factoryAddressStr) = { | |
96 | 99 | let checkCaller = mustThis(i.caller) | |
97 | 100 | if ((checkCaller == checkCaller)) | |
98 | 101 | then [StringEntry(kFactoryAddress, factoryAddressStr)] | |
99 | 102 | else throw("Strict value is not equal to itself.") | |
100 | 103 | } | |
101 | 104 | ||
102 | 105 | ||
103 | 106 | ||
104 | 107 | @Callable(i) | |
105 | 108 | func addEmptyPool (callerPublicKey,args) = { | |
106 | 109 | let newPoolAddress = addressFromPublicKey(callerPublicKey) | |
107 | 110 | let newPoolIndex = (lastEmptyIndex + 1) | |
108 | 111 | let checks = [if (!(shutdown)) | |
109 | 112 | then true | |
110 | - | else throwErr("not allowed (shutdown)"), if (!( | |
113 | + | else throwErr("not allowed (shutdown)"), if (!(isPoolExists(newPoolAddress))) | |
111 | 114 | then true | |
112 | 115 | else throwErr("pool address is already registered")] | |
113 | 116 | if ((checks == checks)) | |
114 | 117 | then { | |
115 | 118 | 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)] | |
116 | 119 | $Tuple2(nil, factoryActions) | |
117 | 120 | } | |
118 | 121 | else throw("Strict value is not equal to itself.") | |
119 | 122 | } | |
120 | 123 | ||
121 | 124 | ||
122 | 125 | ||
123 | 126 | @Callable(i) | |
124 | 127 | func createPool (callerPublicKey,args) = { | |
125 | 128 | let checks = [if (!(shutdown)) | |
126 | 129 | then true | |
127 | 130 | else throwErr("not allowed (shutdown)"), mustFactory(i.caller), if (((lastEmptyIndex - firstEmptyIndex) > 0)) | |
128 | 131 | then true | |
129 | 132 | else throwErr("no empty pools available"), if ((i.payments[0].assetId == unit)) | |
130 | 133 | then true | |
131 | 134 | else throwErr("payment should be in WAVES"), if ((i.payments[0].amount > listingVolume)) | |
132 | 135 | then true | |
133 | 136 | else throwErr("payment amount should be greater than listing volume"), if (isDefined(args[0])) | |
134 | 137 | then true | |
135 | 138 | else throwErr("tokenName is not provided"), if (isDefined(args[1])) | |
136 | 139 | then true | |
137 | 140 | else throwErr("tokenDescription is not provided"), if (isDefined(args[2])) | |
138 | 141 | then true | |
139 | 142 | else throwErr("tokenQuantity is not provided")] | |
140 | 143 | if ((checks == checks)) | |
141 | 144 | then { | |
142 | 145 | let poolIndex = (firstEmptyIndex + 1) | |
143 | 146 | let poolAddressString = getStringValue(factoryAddress, kPoolAddressFromIndex(poolIndex)) | |
144 | 147 | let poolAddress = addressFromStringValue(poolAddressString) | |
145 | 148 | let callerAddress = addressFromPublicKey(callerPublicKey) | |
146 | 149 | let poolDomain = take(poolAddressString, 8) | |
147 | 150 | let poolOwner = toString(callerAddress) | |
148 | 151 | let tokenName = args[0] | |
149 | 152 | let tokenDesc = args[1] | |
150 | 153 | let tokenQuantity = args[2] | |
151 | 154 | let initPoolInvoke = invoke(factoryAddress, "initPoolInvoke", [poolAddressString, [poolDomain, poolOwner, tokenName, tokenDesc, tokenQuantity]], [AttachedPayment(i.payments[0].assetId, i.payments[0].amount)]) | |
152 | 155 | if ((initPoolInvoke == initPoolInvoke)) | |
153 | 156 | then { | |
154 | 157 | let factoryActions = [invoke(factoryAddress, "integerEntry", [kFirstEmptyPoolIndex, poolIndex], nil), invoke(factoryAddress, "integerEntry", [kPoolStatus(poolIndex), STATUS_READY], nil)] | |
155 | 158 | $Tuple2(nil, factoryActions) | |
156 | 159 | } | |
157 | 160 | else throw("Strict value is not equal to itself.") | |
158 | 161 | } | |
159 | 162 | else throw("Strict value is not equal to itself.") | |
160 | 163 | } | |
161 | 164 | ||
162 | 165 | ||
166 | + | ||
167 | + | @Callable(i) | |
168 | + | func notifyStatusUpdate (callerPublicKey,args) = { | |
169 | + | let poolAddress = addressFromPublicKey(callerPublicKey) | |
170 | + | let checks = [if (isPoolExists(poolAddress)) | |
171 | + | then true | |
172 | + | else throwErr("pool not found")] | |
173 | + | if ((checks == checks)) | |
174 | + | then { | |
175 | + | let poolIndex = getIntegerValue(factoryAddress, kPoolIndexFromAddress(poolAddress)) | |
176 | + | let newStatus = parseIntValue(args[0]) | |
177 | + | let factoryActions = [invoke(factoryAddress, "integerEntry", [kPoolStatus(poolIndex), newStatus], nil)] | |
178 | + | $Tuple2(nil, factoryActions) | |
179 | + | } | |
180 | + | else throw("Strict value is not equal to itself.") | |
181 | + | } | |
182 | + | ||
183 | + |
github/deemru/w8io/169f3d6 31.56 ms ◑