tx · GMUQLvwSsoZY8M68obd8K1n8riNf3WYNxKwYci3XyfGa 3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr: -0.00500000 Waves 2024.09.26 09:56 [3300250] smart account 3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr > SELF 0.00000000 Waves
{ "type": 13, "id": "GMUQLvwSsoZY8M68obd8K1n8riNf3WYNxKwYci3XyfGa", "fee": 500000, "feeAssetId": null, "timestamp": 1727333806092, "version": 2, "chainId": 84, "sender": "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr", "senderPublicKey": "jXCTQV8PjX2uC9UHBFveupYy9cjhY7stHbzE9cptymw", "proofs": [ "586FCVimehixxPq6jpinu92uypPceDRCRYjR5X3u1Vb4ThpKWGXYW4XtvHxuDC1QYUNyWiSH4GTdpmg87Nis54Xs" ], "script": "base64:BwITCAISAwoBCBIECgICGBIECgICGCEACXNlcGFyYXRvcgICX18AC3dhdmVzU3RyaW5nAgVXQVZFUwAQY29udHJhY3RGaWxlbmFtZQIXbWVtZV9pbV9jYWxjdWxhdG9yLnJpZGUABW11bHQ4AIDC1y8BB3dyYXBFcnIBAXMJAKwCAgkArAICBRBjb250cmFjdEZpbGVuYW1lAgI6IAUBcwEIdGhyb3dFcnIBAXMJAAIBCQEHd3JhcEVycgEFAXMBD3ZhbGlkYXRlQWRkcmVzcwEHYWRkcmVzcwkBCWlzRGVmaW5lZAEJAKYIAQUHYWRkcmVzcwAMU1RBVFVTX0VNUFRZAAAADFNUQVRVU19SRUFEWQABAAlrU2h1dGRvd24CDnNodXRkb3duX19mbGFnAAtrUHJpY2VBc3NldAIMcHJpY2VfX2Fzc2V0AA5rTGlzdGluZ1ZvbHVtZQIPbGlzdGluZ19fdm9sdW1lABFrUG9vbENvbnRyYWN0SGFzaAIUcG9vbF9fY29udHJhY3RfX2hhc2gAE2tMYXN0RW1wdHlQb29sSW5kZXgCF2xhc3RfX2VtcHR5X3Bvb2xfX2luZGV4ABRrRm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pcyBub3QgZXF1YWwgdG8gaXRzZWxmLgC9lUnF", "height": 3300250, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6QwcAS58sr8JhuHuC1JLkVu3GJhWdSsLiMxsRins8jC3 Next: 5cgqR8DJvrRMm5S1PFf2u4iFiGXJvt9pqt2oH75DAaUp 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 isPoolAddressExists (address) = match getInteger(factoryAddress, kPoolIndexFromAddress(address)) { | |
95 | + | case t: Int => | |
96 | + | true | |
97 | + | case _ => | |
98 | + | false | |
99 | + | } | |
100 | + | ||
101 | + | ||
94 | 102 | @Callable(i) | |
95 | 103 | func init (factoryAddressStr) = { | |
96 | 104 | let checkCaller = mustThis(i.caller) | |
105 | 113 | func addEmptyPool (callerPublicKey,args) = { | |
106 | 114 | let newPoolAddress = addressFromPublicKey(callerPublicKey) | |
107 | 115 | let newPoolIndex = (lastEmptyIndex + 1) | |
108 | - | 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)] | |
109 | - | $Tuple2(nil, factoryActions) | |
116 | + | let checks = [if (!(isPoolAddressExists(newPoolAddress))) | |
117 | + | then true | |
118 | + | else throwErr("pool address is already registered")] | |
119 | + | if ((checks == checks)) | |
120 | + | then { | |
121 | + | 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)] | |
122 | + | $Tuple2(nil, factoryActions) | |
123 | + | } | |
124 | + | else throw("Strict value is not equal to itself.") | |
110 | 125 | } | |
111 | 126 | ||
112 | 127 |
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 isPoolAddressExists (address) = match getInteger(factoryAddress, kPoolIndexFromAddress(address)) { | |
95 | + | case t: Int => | |
96 | + | true | |
97 | + | case _ => | |
98 | + | false | |
99 | + | } | |
100 | + | ||
101 | + | ||
94 | 102 | @Callable(i) | |
95 | 103 | func init (factoryAddressStr) = { | |
96 | 104 | let checkCaller = mustThis(i.caller) | |
97 | 105 | if ((checkCaller == checkCaller)) | |
98 | 106 | then [StringEntry(kFactoryAddress, factoryAddressStr)] | |
99 | 107 | else throw("Strict value is not equal to itself.") | |
100 | 108 | } | |
101 | 109 | ||
102 | 110 | ||
103 | 111 | ||
104 | 112 | @Callable(i) | |
105 | 113 | func addEmptyPool (callerPublicKey,args) = { | |
106 | 114 | let newPoolAddress = addressFromPublicKey(callerPublicKey) | |
107 | 115 | let newPoolIndex = (lastEmptyIndex + 1) | |
108 | - | 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)] | |
109 | - | $Tuple2(nil, factoryActions) | |
116 | + | let checks = [if (!(isPoolAddressExists(newPoolAddress))) | |
117 | + | then true | |
118 | + | else throwErr("pool address is already registered")] | |
119 | + | if ((checks == checks)) | |
120 | + | then { | |
121 | + | 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)] | |
122 | + | $Tuple2(nil, factoryActions) | |
123 | + | } | |
124 | + | else throw("Strict value is not equal to itself.") | |
110 | 125 | } | |
111 | 126 | ||
112 | 127 | ||
113 | 128 | ||
114 | 129 | @Callable(i) | |
115 | 130 | func createPool (callerPublicKey,args) = { | |
116 | 131 | let checks = [if (!(shutdown)) | |
117 | 132 | then true | |
118 | 133 | else throwErr("not allowed (shutdown)"), mustFactory(i.caller), if (((lastEmptyIndex - firstEmptyIndex) > 0)) | |
119 | 134 | then true | |
120 | 135 | else throwErr("no empty pools available"), if ((i.payments[1].assetId == unit)) | |
121 | 136 | then true | |
122 | 137 | else throwErr("price asset should be WAVES"), if ((i.payments[1].amount > listingVolume)) | |
123 | 138 | then true | |
124 | 139 | else throwErr("payment[1] amount should be greater than listing volume"), if ((i.payments[0].assetId != unit)) | |
125 | 140 | then true | |
126 | 141 | else throwErr("amount asset cannot be WAVES"), if ((i.payments[0].amount > 0)) | |
127 | 142 | then true | |
128 | 143 | else throwErr("payment[0] amount should be greater than 0")] | |
129 | 144 | if ((checks == checks)) | |
130 | 145 | then { | |
131 | 146 | let amountAssetId = i.payments[0].assetId | |
132 | 147 | let amountAssetIdString = assetIdToString(amountAssetId) | |
133 | 148 | let poolIndex = (firstEmptyIndex + 1) | |
134 | 149 | let poolAddressString = getStringValue(factoryAddress, kPoolAddressFromIndex(poolIndex)) | |
135 | 150 | let poolAddress = addressFromStringValue(poolAddressString) | |
136 | 151 | let actions = [ScriptTransfer(poolAddress, i.payments[0].amount, i.payments[0].assetId), ScriptTransfer(poolAddress, i.payments[1].amount, i.payments[1].assetId)] | |
137 | 152 | let factoryActions = [invoke(factoryAddress, "stringEntry", [kPoolAsset(poolAddress), amountAssetIdString], nil), invoke(factoryAddress, "integerEntry", [kFirstEmptyPoolIndex, poolIndex], nil), invoke(factoryAddress, "integerEntry", [kPoolStatus(poolIndex), STATUS_READY], nil)] | |
138 | 153 | $Tuple2(actions, factoryActions) | |
139 | 154 | } | |
140 | 155 | else throw("Strict value is not equal to itself.") | |
141 | 156 | } | |
142 | 157 | ||
143 | 158 |
github/deemru/w8io/026f985 26.34 ms ◑