tx · GKU2UhMYuSVNJUSFZV9jmYQBspiC5UjYpYxHwtxZGxbb 3N6oB7VbceD3NoguGkfGnBMF4hcHZVbK8io: -0.01700000 Waves 2024.11.01 19:36 [3352708] smart account 3N6oB7VbceD3NoguGkfGnBMF4hcHZVbK8io > SELF 0.00000000 Waves
{ "type": 13, "id": "GKU2UhMYuSVNJUSFZV9jmYQBspiC5UjYpYxHwtxZGxbb", "fee": 1700000, "feeAssetId": null, "timestamp": 1730479033820, "version": 2, "chainId": 84, "sender": "3N6oB7VbceD3NoguGkfGnBMF4hcHZVbK8io", "senderPublicKey": "2cUCdub81Us7Le3h97BRsS5HupDXo5sErj1dwyNHKNU2", "proofs": [ "2gsVGsEBgEcyNE9VJxYHyjZucDUeDVHLaMZ1ZdWdzLjDtRfKL2q9Q9Bj2DLQZ11c7BMTLNVQw7PwiBZK8UmAAcuN" ], "script": "base64:BgJACAISAwoBCBIDCgEBEgMKAQESAwoBCBIDCgEIEgMKAQgSBAoCCAgSBQoDCAgIEgUKAwgICBIECgIICBIECgIICCABFHRyeUdldFN0cmluZ0V4dGVybmFsAgdhZGRyZXNzA2tleQQHJG1hdGNoMAkAnQgCBQdhZGRyZXNzBQNrZXkDCQABAgUHJG1hdGNoMAIGU3RyaW5nBAFhBQckbWF0Y2gwBQFhAgABDHRyeUdldFN0cmluZwEDa2V5CQEUdHJ5R2V0U3RyaW5nRXh0ZXJuYWwCBQR0aGlzBQNrZXkBHnN0YXRpY0tleV90dXJ0bGVSZWJpcnRoQWRkcmVzcwACG3N0YXRpY190dXJ0bGVSZWJpcnRoQWRkcmVzcwEJZ2V0T3JhY2xlAAkBB0FkZHJlc3MBCQDZBAEJAQx0cnlHZXRTdHJpbmcBAhRzdGF0aWNfb3JhY2xlQWRkcmVzcwENZ2V0RWdnQXNzZXRJZAAJANkEAQkBFHRyeUdldFN0cmluZ0V4dGVybmFsAgkBCWdldE9yYWNsZQACEXN0YXRpY19lZ2dBc3NldElkARFnZXRSZWJpcnRoQWR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AUCdHgGcHJvb2ZzAAEFCnNlY29uZFVzZXIAAQMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAIFCnNlY29uZFVzZXIAAQAABA90aGlyZFVzZXJTaWduZWQDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQl0aGlyZFVzZXIAAQMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAEFCXRoaXJkVXNlcgABAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAgUJdGhpcmRVc2VyAAEAAAQPc2lnbmF0dXJlc0NvdW50CQBkAgkAZAIFD2ZpcnN0VXNlclNpZ25lZAUQc2Vjb25kVXNlclNpZ25lZAUPdGhpcmRVc2VyU2lnbmVkBAckbWF0Y2gwBQJ0eAkAZwIFD3NpZ25hdHVyZXNDb3VudAACp1NTQQ==", "height": 3352708, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6Rf2qELLRJHNH5KGNitsMPy6ifr71Qmk1XZKoBEtZQVC Next: none Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | - | func tryGetIntExternal (address,key) = match getInteger(address, key) { | |
13 | - | case a: Int => | |
14 | - | a | |
15 | - | case _ => | |
16 | - | throw("RTGIE: Something went wrong") | |
17 | - | } | |
12 | + | func tryGetString (key) = tryGetStringExternal(this, key) | |
18 | 13 | ||
19 | 14 | ||
20 | - | func asBoolean (value) = match value { | |
21 | - | case boolean: Boolean => | |
22 | - | boolean | |
23 | - | case _ => | |
24 | - | throw("FAB: wrong type, expected: Boolean") | |
25 | - | } | |
15 | + | func staticKey_turtleRebirthAddress () = "static_turtleRebirthAddress" | |
26 | 16 | ||
27 | 17 | ||
28 | - | func tryGetString (key) = tryGetStringExternal(this, key) | |
18 | + | func getOracle () = Address(fromBase58String(tryGetString("static_oracleAddress"))) | |
19 | + | ||
20 | + | ||
21 | + | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), "static_eggAssetId")) | |
22 | + | ||
23 | + | ||
24 | + | func getRebirthAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_rebirthAddress"))) | |
25 | + | ||
26 | + | ||
27 | + | func getBabyDuckAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_babyDuckAddress"))) | |
28 | + | ||
29 | + | ||
30 | + | func getRefContractAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_refContractAddress"))) | |
31 | + | ||
32 | + | ||
33 | + | func getCouponsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_couponsAddress"))) | |
34 | + | ||
35 | + | ||
36 | + | func getBurnAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_burnAddress"))) | |
37 | + | ||
38 | + | ||
39 | + | func getTurtleRebirthAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_turtleRebirthAddress()))) | |
29 | 40 | ||
30 | 41 | ||
31 | 42 | let delayForHatching = 2 | |
32 | 43 | ||
33 | - | ||
44 | + | let typesAmount = 10 | |
34 | 45 | ||
46 | + | let RefererReward = 5 | |
35 | 47 | ||
36 | - | ||
48 | + | let HatchingStarted = "HATCHING_STARTED" | |
37 | 49 | ||
50 | + | let HatchingFinished = "HATCHING_FINISHED" | |
38 | 51 | ||
39 | - | func staticKey_incubatorAddress () = "static_incubatorAddress" | |
40 | - | ||
41 | - | ||
42 | - | func staticKey_breederAddress () = "static_breederAddress" | |
43 | - | ||
44 | - | ||
45 | - | func staticKey_farmingAddress () = "static_farmingAddressNew" | |
46 | - | ||
47 | - | ||
48 | - | func staticKey_babyDuckAddress () = "static_babyDuckAddress" | |
49 | - | ||
50 | - | ||
51 | - | func staticKey_gameDappAddress () = "static_gameDappAddress" | |
52 | - | ||
53 | - | ||
54 | - | func staticKey_itemsAddress () = "static_itemsAddress" | |
55 | - | ||
56 | - | ||
57 | - | func staticKey_couponsAddress () = "static_couponsAddress" | |
58 | - | ||
59 | - | ||
60 | - | func staticKey_huntAddress () = "static_huntAddress" | |
61 | - | ||
62 | - | ||
63 | - | func staticKey_burnAddress () = "static_burnAddress" | |
64 | - | ||
65 | - | ||
66 | - | func staticKey_refContractAddress () = "static_refContractAddress" | |
67 | - | ||
68 | - | ||
69 | - | func staticKey_extraFee () = "static_extraFee" | |
70 | - | ||
71 | - | ||
72 | - | func staticKey_feeAggregator () = "static_feeAggregator" | |
73 | - | ||
74 | - | ||
75 | - | func getOracle () = Address(fromBase58String(tryGetString(staticKey_oracleAddress()))) | |
76 | - | ||
77 | - | ||
78 | - | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), staticKey_eggAssetId())) | |
79 | - | ||
80 | - | ||
81 | - | func getIncubatorAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_incubatorAddress()))) | |
82 | - | ||
83 | - | ||
84 | - | func getBreederAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_breederAddress()))) | |
85 | - | ||
86 | - | ||
87 | - | func getFarmingAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_farmingAddress()))) | |
88 | - | ||
89 | - | ||
90 | - | func getBabyDuckAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_babyDuckAddress()))) | |
91 | - | ||
92 | - | ||
93 | - | func getGameDappAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_gameDappAddress()))) | |
94 | - | ||
95 | - | ||
96 | - | func getItemsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_itemsAddress()))) | |
97 | - | ||
98 | - | ||
99 | - | func getCouponsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_couponsAddress()))) | |
100 | - | ||
101 | - | ||
102 | - | func getHuntAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_huntAddress()))) | |
103 | - | ||
104 | - | ||
105 | - | func getBurnAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_burnAddress()))) | |
106 | - | ||
107 | - | ||
108 | - | func getRefContractAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_refContractAddress()))) | |
109 | - | ||
110 | - | ||
111 | - | func getFeeAggregator () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_feeAggregator()))) | |
112 | - | ||
113 | - | ||
114 | - | func checkAdditionalPayment (payment) = if (isDefined(payment.assetId)) | |
115 | - | then throw("RCAP: Please attach waves") | |
116 | - | else { | |
117 | - | let feeAmount = getIntegerValue(getOracle(), staticKey_extraFee()) | |
118 | - | if ((payment.amount != feeAmount)) | |
119 | - | then throw((("RCAP: Please attach exactly " + toString(feeAmount)) + " amount of wavelets")) | |
120 | - | else [ScriptTransfer(getFeeAggregator(), feeAmount, unit)] | |
121 | - | } | |
122 | - | ||
123 | - | ||
124 | - | let PHOENIXBASEOPTIONS = 1000 | |
125 | - | ||
126 | - | func tryGetInteger (key) = match getInteger(this, key) { | |
127 | - | case b: Int => | |
128 | - | b | |
129 | - | case _ => | |
130 | - | 0 | |
131 | - | } | |
132 | - | ||
133 | - | ||
134 | - | func asString (value) = match value { | |
135 | - | case s: String => | |
136 | - | s | |
137 | - | case s: Int => | |
138 | - | throw("wrong type, expected: String, got: Int") | |
139 | - | case s: Unit => | |
140 | - | throw("wrong type, expected: String, got: Unit") | |
141 | - | case _ => | |
142 | - | throw("wrong type, expected: String") | |
143 | - | } | |
144 | - | ||
145 | - | ||
146 | - | let feeAmount = tryGetInteger("currentPrice") | |
147 | - | ||
148 | - | func getAmountOrClear (amount) = if (contains(amount, "0")) | |
149 | - | then "" | |
150 | - | else amount | |
151 | - | ||
152 | - | ||
153 | - | func getAssetOrigin (generation) = if ((generation == "G")) | |
154 | - | then getIncubatorAddress() | |
155 | - | else getBreederAddress() | |
156 | - | ||
157 | - | ||
158 | - | func getAssetRarity (genotype,generation) = { | |
159 | - | let quantity = getIntegerValue(getAssetOrigin(generation), (("stats_" + genotype) + "_quantity")) | |
160 | - | let power = pow((10000 / quantity), 4, 5, 1, 2, FLOOR) | |
161 | - | if ((power > 0)) | |
162 | - | then power | |
163 | - | else 2 | |
52 | + | func isLocked () = { | |
53 | + | let masterAddress = Address(base58'3PEPftf2kWZDmAaWBjs6BUJa9957kiA2PkU') | |
54 | + | match getInteger(masterAddress, "egglock") { | |
55 | + | case b: Int => | |
56 | + | b | |
57 | + | case _ => | |
58 | + | 0 | |
59 | + | } | |
164 | 60 | } | |
165 | 61 | ||
166 | 62 | ||
167 | - | func getAssetFarmingPower (assetId) = if (if ((value(assetInfo(assetId)).issuer == getBreederAddress())) | |
168 | - | then true | |
169 | - | else (value(assetInfo(assetId)).issuer == getIncubatorAddress())) | |
170 | - | then { | |
171 | - | let assetName = value(assetInfo(assetId)).name | |
172 | - | let generation = take(takeRight(assetName, 2), 1) | |
173 | - | let farmGen = asString(invoke(getBreederAddress(), "getGenFromName", [assetName], nil)) | |
174 | - | if ((farmGen == farmGen)) | |
175 | - | then $Tuple2(farmGen, getAssetRarity(farmGen, generation)) | |
176 | - | else throw("Strict value is not equal to itself.") | |
177 | - | } | |
178 | - | else throw("not valid NFT") | |
63 | + | func getHatchingStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status") | |
179 | 64 | ||
180 | 65 | ||
181 | - | func getRandomNumber (options,txId,hatchingFinishHeight,offset) = { | |
182 | - | let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1))) | |
183 | - | let randomHash = sha256((txId + value(randomSeedBlock.vrf))) | |
184 | - | (toInt(randomHash, (offset * 8)) % options) | |
66 | + | func getHatchingFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh") | |
67 | + | ||
68 | + | ||
69 | + | func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di") | |
70 | + | ||
71 | + | ||
72 | + | func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount") | |
73 | + | ||
74 | + | ||
75 | + | func tryGetInteger (key) = { | |
76 | + | let val = match getInteger(this, key) { | |
77 | + | case b: Int => | |
78 | + | b | |
79 | + | case _ => | |
80 | + | 0 | |
81 | + | } | |
82 | + | val | |
185 | 83 | } | |
186 | 84 | ||
187 | 85 | ||
188 | - | func getRandomWin (tx,finishHeight,assetRarity) = { | |
189 | - | let jackpotRandom = getRandomNumber(10, tx, finishHeight, 1) | |
190 | - | if ((jackpotRandom == 1)) | |
191 | - | then "phoenix" | |
192 | - | else { | |
193 | - | let n = getRandomNumber(1000, tx, finishHeight, 0) | |
194 | - | if ((10 > n)) | |
195 | - | then "item!ART-FREEGENE" | |
196 | - | else if ((126 > n)) | |
197 | - | then "ar" | |
198 | - | else if ((186 > n)) | |
199 | - | then "item!ART-FIRE_ARMOUR" | |
200 | - | else if ((206 > n)) | |
201 | - | then "item!ART-FEED5" | |
202 | - | else if ((226 > n)) | |
203 | - | then "item!ART-FEED10" | |
204 | - | else if ((246 > n)) | |
205 | - | then "item!ART-FEED15" | |
206 | - | else if ((266 > n)) | |
207 | - | then "item!ART-FEED20" | |
208 | - | else if ((286 > n)) | |
209 | - | then "item!ART-FEED25" | |
210 | - | else if ((296 > n)) | |
211 | - | then "item!ART-FEED50" | |
212 | - | else if ((300 > n)) | |
213 | - | then "item!ART-FEED100" | |
214 | - | else if ((310 > n)) | |
215 | - | then "item!ART-CROWN" | |
216 | - | else if ((350 > n)) | |
217 | - | then "incubator" | |
218 | - | else if ((460 > n)) | |
219 | - | then if ((50 > assetRarity)) | |
220 | - | then "item!ART-BUILTBODY" | |
221 | - | else "item!ART-MUTARIUM-D" | |
222 | - | else if ((480 > n)) | |
223 | - | then "item!ART-SNAKE" | |
224 | - | else if ((510 > n)) | |
225 | - | then "item!ART-ROBODUCK" | |
226 | - | else if ((600 > n)) | |
227 | - | then "item!ART-KATANA" | |
228 | - | else if ((650 > n)) | |
229 | - | then if ((50 > assetRarity)) | |
230 | - | then "item!ART-SCEPTER" | |
231 | - | else "item!ART-MUTARIUM-D" | |
232 | - | else if ((710 > n)) | |
233 | - | then "item!ART-MUTARIUM-D" | |
234 | - | else if ((720 > n)) | |
235 | - | then "item!ART-MUTARIUM-G" | |
236 | - | else if ((890 > n)) | |
237 | - | then "duckling_10" | |
238 | - | else if ((960 > n)) | |
239 | - | then "duckling_20" | |
240 | - | else "duckling_40" | |
241 | - | } | |
86 | + | let discountCoefficient = tryGetInteger("discountCoefficient") | |
87 | + | ||
88 | + | let saleCoefficient = tryGetInteger("saleCoefficient") | |
89 | + | ||
90 | + | func getRandomNumber (variants,txId,hatchingFinishHeight,offset) = { | |
91 | + | let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1))) | |
92 | + | let randomHash = sha256(((base58'incubator' + txId) + value(randomSeedBlock.vrf))) | |
93 | + | (toInt(randomHash, offset) % variants) | |
242 | 94 | } | |
243 | 95 | ||
244 | 96 | ||
245 | - | func getOrigin (assetId) = { | |
246 | - | let assetName = value(assetInfo(assetId)).name | |
247 | - | let generation = take(takeRight(assetName, 2), 1) | |
248 | - | if (if ((generation == "G")) | |
249 | - | then true | |
250 | - | else (generation == "J")) | |
251 | - | then getIncubatorAddress() | |
252 | - | else getBreederAddress() | |
97 | + | func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen)) | |
98 | + | ||
99 | + | ||
100 | + | func getRandomName (txId,hatchingFinishHeight) = { | |
101 | + | let jackpotRandom = getRandomNumber(200, txId, hatchingFinishHeight, 4) | |
102 | + | let entry = IntegerEntry("last_jackpot_random", jackpotRandom) | |
103 | + | let typeRandom = getRandomNumber(4, txId, hatchingFinishHeight, 5) | |
104 | + | let colorRandom = getRandomNumber(4, txId, hatchingFinishHeight, 6) | |
105 | + | let color = if ((colorRandom == 0)) | |
106 | + | then "Y" | |
107 | + | else if ((colorRandom == 1)) | |
108 | + | then "G" | |
109 | + | else if ((colorRandom == 2)) | |
110 | + | then "B" | |
111 | + | else "R" | |
112 | + | if ((typeRandom == 0)) | |
113 | + | then $Tuple3(("DUCK-MMMMMMMM-G" + color), "8M-G", entry) | |
114 | + | else if ((typeRandom == 1)) | |
115 | + | then $Tuple3(("DUCK-NNNNNNNN-G" + color), "8N-G", entry) | |
116 | + | else if ((typeRandom == 2)) | |
117 | + | then $Tuple3(("DUCK-OOOOOOOO-G" + color), "8O-G", entry) | |
118 | + | else $Tuple3(("DUCK-PPPPPPPP-G" + color), "8P-G", entry) | |
119 | + | } | |
120 | + | ||
121 | + | ||
122 | + | func countEggsNeededAmount (totalDucksAmount) = { | |
123 | + | let n = totalDucksAmount | |
124 | + | let g = discountCoefficient | |
125 | + | let s = saleCoefficient | |
126 | + | let t = typesAmount | |
127 | + | let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN) | |
128 | + | if ((saleCoefficient == 0)) | |
129 | + | then (price * 1000000) | |
130 | + | else (((price * 1000000) / 100) * (100 - saleCoefficient)) | |
253 | 131 | } | |
254 | 132 | ||
255 | 133 | ||
256 | 134 | func asInt (value) = match value { | |
257 | 135 | case int: Int => | |
258 | 136 | int | |
259 | - | case string: String => | |
260 | - | throw(("RAI: wrong type, expected: Int, but got: " + string)) | |
261 | 137 | case _ => | |
262 | - | throw(" | |
138 | + | throw("IAI: wrong type, expected: Int") | |
263 | 139 | } | |
140 | + | ||
141 | + | ||
142 | + | func finishHatchingInternal (txIdStr,owner) = { | |
143 | + | let txId = fromBase58String(txIdStr) | |
144 | + | let hatchingStatusKey = getHatchingStatusKey(owner, txId) | |
145 | + | let finishHeightKey = getHatchingFinishHeightKey(owner, txId) | |
146 | + | let duckIdKey = getDuckIdKey(owner, txId) | |
147 | + | let duckFromBaby = match getBoolean((("hatching_" + txIdStr) + "_babyDuck")) { | |
148 | + | case t: Boolean => | |
149 | + | t | |
150 | + | case _ => | |
151 | + | false | |
152 | + | } | |
153 | + | let hatchingTxStatus = getStringValue(this, hatchingStatusKey) | |
154 | + | let hatchingFinishHeight = getIntegerValue(this, finishHeightKey) | |
155 | + | if ((hatchingTxStatus == HatchingFinished)) | |
156 | + | then { | |
157 | + | let duckId = getStringValue(this, getDuckIdKey(owner, txId)) | |
158 | + | throw(("IFDH: The duck was hatched and claimed already, here is the folowing: " + duckId)) | |
159 | + | } | |
160 | + | else if ((hatchingFinishHeight > height)) | |
161 | + | then throw((((("Hatching is not finished yet " + toString((hatchingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((hatchingFinishHeight - height))) + " minutes")) | |
162 | + | else { | |
163 | + | let $t055055591 = getRandomName(txId, hatchingFinishHeight) | |
164 | + | let duckGen = $t055055591._1 | |
165 | + | let farmGen = $t055055591._2 | |
166 | + | let jackpotRandomEntry = $t055055591._3 | |
167 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
168 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, hatchingFinishHeight) | |
169 | + | let assetId = calculateAssetId(asset) | |
170 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
171 | + | [StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), BooleanEntry((("duck_" + toBase58String(assetId)) + "_grown"), duckFromBaby), IntegerEntry(getDuckStatsKey(duckGen), amount), jackpotRandomEntry, IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(Address(fromBase58String(owner)), 1, assetId)] | |
172 | + | } | |
173 | + | } | |
264 | 174 | ||
265 | 175 | ||
266 | 176 | func getBool (key) = match getBoolean(this, key) { | |
274 | 184 | func isTestEnv () = getBool("TESTENV") | |
275 | 185 | ||
276 | 186 | ||
277 | - | func finishRebirthInternal (initTx,address,payment,double) = { | |
278 | - | let finishBlock = tryGetInteger((((("address_" + address) + "_initTx_") + initTx) + "_finishBlock")) | |
279 | - | let assetRarity = tryGetInteger((((("address_" + address) + "_initTx_") + initTx) + "_assetRarity")) | |
280 | - | let status = tryGetString((((("address_" + address) + "_initTx_") + initTx) + "_status")) | |
281 | - | let validPayment = checkAdditionalPayment(payment) | |
282 | - | if ((validPayment == validPayment)) | |
283 | - | then { | |
284 | - | let recordAction = invoke(getCouponsAddress(), "recordAction", ["REBIRTH"], nil) | |
285 | - | if ((recordAction == recordAction)) | |
286 | - | then { | |
287 | - | func getAccessItemAssetId (address) = fromBase58String(tryGetStringExternal(address, "static_accessItemAssetId")) | |
288 | - | ||
289 | - | func getAccessItemPrice (address) = tryGetIntExternal(address, "static_accessItemPrice") | |
290 | - | ||
291 | - | if ((status != "open")) | |
292 | - | then throw("rebirth is finished or not open") | |
293 | - | else if ((finishBlock > height)) | |
294 | - | then throw("you cannot finish rebirth, yet") | |
295 | - | else { | |
296 | - | let win = getRandomWin(fromBase58String(initTx), finishBlock, assetRarity) | |
297 | - | let txId = initTx | |
298 | - | let result = if ((indexOf(win, "perch") != unit)) | |
299 | - | then { | |
300 | - | let color = takeRight(win, 1) | |
301 | - | let result = if (!(double)) | |
302 | - | then { | |
303 | - | let first = invoke(getFarmingAddress(), "addFreePerch", [address, color, 1], nil) | |
304 | - | if ((first == first)) | |
305 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first))] | |
306 | - | else throw("Strict value is not equal to itself.") | |
307 | - | } | |
308 | - | else { | |
309 | - | let first = invoke(getFarmingAddress(), "addFreePerch", [address, color, 2], nil) | |
310 | - | if ((first == first)) | |
311 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result1"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win1"), win)] | |
312 | - | else throw("Strict value is not equal to itself.") | |
313 | - | } | |
314 | - | if ((result == result)) | |
315 | - | then result | |
316 | - | else throw("Strict value is not equal to itself.") | |
317 | - | } | |
318 | - | else if ((win == "incubator")) | |
319 | - | then { | |
320 | - | let result = if (!(double)) | |
321 | - | then { | |
322 | - | let first = invoke(getIncubatorAddress(), "issueFreeDuck", [address, txId], nil) | |
323 | - | if ((first == first)) | |
324 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first))] | |
325 | - | else throw("Strict value is not equal to itself.") | |
326 | - | } | |
327 | - | else { | |
328 | - | let first = invoke(getIncubatorAddress(), "issueFreeDuck", [address, txId], nil) | |
329 | - | if ((first == first)) | |
330 | - | then { | |
331 | - | let second = invoke(getBabyDuckAddress(), "issueFreeDuckling", [address, txId, 100], nil) | |
332 | - | if ((second == second)) | |
333 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result1"), asString(second)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win1"), "duckling_100")] | |
334 | - | else throw("Strict value is not equal to itself.") | |
335 | - | } | |
336 | - | else throw("Strict value is not equal to itself.") | |
337 | - | } | |
338 | - | if ((result == result)) | |
339 | - | then result | |
340 | - | else throw("Strict value is not equal to itself.") | |
341 | - | } | |
342 | - | else if ((win == "ar")) | |
343 | - | then { | |
344 | - | let assetId = getAccessItemAssetId(getHuntAddress()) | |
345 | - | let price = getAccessItemPrice(getHuntAddress()) | |
346 | - | let call = invoke(getHuntAddress(), "buyAccessItemOther", [address], [AttachedPayment(assetId, price)]) | |
347 | - | if ((call == call)) | |
348 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(call))] | |
349 | - | else throw("Strict value is not equal to itself.") | |
350 | - | } | |
351 | - | else if ((win == "phoenix")) | |
352 | - | then { | |
353 | - | let call = invoke(getIncubatorAddress(), "issueJackpot", [address, txId, "WWWWHWTF"], nil) | |
354 | - | if ((call == call)) | |
355 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(call))] | |
356 | - | else throw("Strict value is not equal to itself.") | |
357 | - | } | |
358 | - | else if ((indexOf(win, "duckling") != unit)) | |
359 | - | then { | |
360 | - | let level = parseIntValue(split(win, "_")[1]) | |
361 | - | let levelFinal = if (double) | |
362 | - | then (2 * level) | |
363 | - | else level | |
364 | - | let call = invoke(getBabyDuckAddress(), "issueFreeDuckling", [address, txId, levelFinal], nil) | |
365 | - | if ((call == call)) | |
366 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(call))] | |
367 | - | else throw("Strict value is not equal to itself.") | |
368 | - | } | |
369 | - | else if ((indexOf(win, "item") != unit)) | |
370 | - | then { | |
371 | - | let itemName = split(win, "!")[1] | |
372 | - | let result = if (!(double)) | |
373 | - | then { | |
374 | - | let first = invoke(getItemsAddress(), "issueArtefactIndex", [itemName, address, 0], nil) | |
375 | - | if ((first == first)) | |
376 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first))] | |
377 | - | else throw("Strict value is not equal to itself.") | |
378 | - | } | |
379 | - | else { | |
380 | - | let first = invoke(getItemsAddress(), "issueArtefactIndex", [itemName, address, 0], nil) | |
381 | - | if ((first == first)) | |
382 | - | then { | |
383 | - | let second = invoke(getItemsAddress(), "issueArtefactIndex", [itemName, address, 1], nil) | |
384 | - | if ((second == second)) | |
385 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(second)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win1"), win)] | |
386 | - | else throw("Strict value is not equal to itself.") | |
387 | - | } | |
388 | - | else throw("Strict value is not equal to itself.") | |
389 | - | } | |
390 | - | if ((result == result)) | |
391 | - | then result | |
392 | - | else throw("Strict value is not equal to itself.") | |
393 | - | } | |
394 | - | else throw("RFB: Some error occured, please contact the admins!") | |
395 | - | ((result ++ [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win"), win), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_status"), "finish")]) ++ validPayment) | |
396 | - | } | |
397 | - | } | |
398 | - | else throw("Strict value is not equal to itself.") | |
399 | - | } | |
400 | - | else throw("Strict value is not equal to itself.") | |
401 | - | } | |
402 | - | ||
403 | - | ||
404 | 187 | @Callable(i) | |
405 | 188 | func configureOracle (oracle) = if ((i.caller != this)) | |
406 | - | then throw(" | |
189 | + | then throw("ICU: admin only") | |
407 | 190 | else [StringEntry("static_oracleAddress", oracle)] | |
408 | 191 | ||
409 | 192 | ||
410 | 193 | ||
411 | 194 | @Callable(i) | |
412 | - | func initRebirth (refererAddress) = { | |
413 | - | let pmt = i.payments[0] | |
414 | - | let assetId = value(pmt.assetId) | |
415 | - | let initTx = toBase58String(i.transactionId) | |
416 | - | let address = toString(i.caller) | |
417 | - | if ((pmt.amount != 1)) | |
418 | - | then throw("NFT is not attached") | |
195 | + | func setDiscount (val) = if ((i.caller != this)) | |
196 | + | then throw("ISD: admin_only") | |
197 | + | else [IntegerEntry("discountCoefficient", val)] | |
198 | + | ||
199 | + | ||
200 | + | ||
201 | + | @Callable(i) | |
202 | + | func setSale (val) = if ((i.caller != this)) | |
203 | + | then throw("ISS: admin_only") | |
204 | + | else [IntegerEntry("saleCoefficient", val)] | |
205 | + | ||
206 | + | ||
207 | + | ||
208 | + | @Callable(i) | |
209 | + | func startDuckHatching (refererAddress) = if ((getBabyDuckAddress() != i.caller)) | |
210 | + | then throw("ISDHFA: From now on this is only possible through ducklings!") | |
211 | + | else if ((isLocked() > 0)) | |
212 | + | then throw("ISDH: EGG operations are temporarily locked") | |
419 | 213 | else { | |
420 | - | let amountPaidByCoupons = asInt(invoke(getCouponsAddress(), "useCoupons", [feeAmount], nil)) | |
421 | - | if ((amountPaidByCoupons == amountPaidByCoupons)) | |
422 | - | then { | |
423 | - | let leftToPay = (feeAmount - amountPaidByCoupons) | |
424 | - | let validPayment = checkAdditionalPayment(i.payments[1]) | |
425 | - | if ((validPayment == validPayment)) | |
426 | - | then { | |
427 | - | let payment = if ((leftToPay != 0)) | |
428 | - | then { | |
429 | - | let feePayment = value(i.payments[2]) | |
430 | - | if ((feePayment.assetId != getEggAssetId())) | |
431 | - | then throw("You need to attach EGG tokens as fee") | |
432 | - | else if ((leftToPay > feePayment.amount)) | |
433 | - | then throw(("You need to attach the following amount of EGG tokens as fee: 0." + toString(leftToPay))) | |
434 | - | else { | |
435 | - | let refererRewardForPerch = fraction(leftToPay, 5, 100) | |
436 | - | let refCall = asBoolean(invoke(getRefContractAddress(), "refPayment", [refererAddress], [AttachedPayment(getEggAssetId(), refererRewardForPerch)])) | |
437 | - | if ((refCall == refCall)) | |
438 | - | then { | |
439 | - | let toBurn = if (refCall) | |
440 | - | then (leftToPay - refererRewardForPerch) | |
441 | - | else leftToPay | |
442 | - | let burnCall = invoke(getBurnAddress(), "burnAttachedPayments", nil, [AttachedPayment(getEggAssetId(), toBurn)]) | |
443 | - | if ((burnCall == burnCall)) | |
444 | - | then leftToPay | |
445 | - | else throw("Strict value is not equal to itself.") | |
446 | - | } | |
447 | - | else throw("Strict value is not equal to itself.") | |
448 | - | } | |
449 | - | } | |
450 | - | else 0 | |
451 | - | if ((payment == payment)) | |
452 | - | then { | |
453 | - | let $t01380913858 = getAssetFarmingPower(assetId) | |
454 | - | let gen = $t01380913858._1 | |
455 | - | let rarity = $t01380913858._2 | |
456 | - | let call = invoke(getOrigin(assetId), "reduceRarity", [toBase58String(assetId), gen], nil) | |
457 | - | if ((call == call)) | |
458 | - | then ([IntegerEntry((((("address_" + address) + "_initTx_") + initTx) + "_finishBlock"), (height + delayForHatching)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_status"), "open"), IntegerEntry((((("address_" + address) + "_initTx_") + initTx) + "_assetRarity"), rarity), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_assetId"), toBase58String(assetId))] ++ validPayment) | |
459 | - | else throw("Strict value is not equal to itself.") | |
460 | - | } | |
461 | - | else throw("Strict value is not equal to itself.") | |
462 | - | } | |
463 | - | else throw("Strict value is not equal to itself.") | |
464 | - | } | |
465 | - | else throw("Strict value is not equal to itself.") | |
214 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
215 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
216 | + | [StringEntry(getHatchingStatusKey(toString(i.originCaller), i.transactionId), HatchingStarted), IntegerEntry(getHatchingFinishHeightKey(toString(i.originCaller), i.transactionId), (height + delayForHatching)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), BooleanEntry((("hatching_" + toBase58String(i.transactionId)) + "_babyDuck"), true)] | |
217 | + | } | |
218 | + | ||
219 | + | ||
220 | + | ||
221 | + | @Callable(i) | |
222 | + | func startDuckHatchingForAddress (address) = if ((isLocked() > 0)) | |
223 | + | then throw("ISDHFA: EGG operations are temporarily locked") | |
224 | + | else if ((i.caller != this)) | |
225 | + | then throw("ISDHFA: Permission denied") | |
226 | + | else { | |
227 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
228 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
229 | + | [StringEntry(getHatchingStatusKey(address, i.transactionId), HatchingStarted), IntegerEntry(getHatchingFinishHeightKey(address, i.transactionId), (height + delayForHatching)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), BooleanEntry((("hatching_" + toBase58String(i.transactionId)) + "_promo"), true)] | |
230 | + | } | |
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | @Callable(i) | |
235 | + | func finishDuckHatching (txIdStr) = { | |
236 | + | let owner = toString(i.originCaller) | |
237 | + | finishHatchingInternal(txIdStr, owner) | |
238 | + | } | |
239 | + | ||
240 | + | ||
241 | + | ||
242 | + | @Callable(i) | |
243 | + | func issueFreeDuck (address,txIdStr) = if ((i.caller != getRebirthAddress())) | |
244 | + | then throw("ISFD: rebirth only") | |
245 | + | else { | |
246 | + | let txId = fromBase58String(txIdStr) | |
247 | + | let hatchingStatusKey = getHatchingStatusKey(address, txId) | |
248 | + | let finishHeightKey = getHatchingFinishHeightKey(address, txId) | |
249 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
250 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
251 | + | let $t093379499 = getRandomName(txId, (valueOrErrorMessage(transactionHeightById(txId), ((txIdStr + " not found ") + toBase58String(txId))) + 1)) | |
252 | + | let duckGen = $t093379499._1 | |
253 | + | let farmGen = $t093379499._2 | |
254 | + | let jackpotRandomEntry = $t093379499._3 | |
255 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
256 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, height) | |
257 | + | let assetId = calculateAssetId(asset) | |
258 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
259 | + | let duckIdKey = getDuckIdKey(address, txId) | |
260 | + | $Tuple2([IntegerEntry(getHatchingFinishHeightKey(address, txId), height), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), jackpotRandomEntry, StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), IntegerEntry(getDuckStatsKey(duckGen), amount), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], toBase58String(assetId)) | |
261 | + | } | |
262 | + | ||
263 | + | ||
264 | + | ||
265 | + | @Callable(i) | |
266 | + | func issueFreeDuckDefinedGenes (address,txIdStr,genes) = if (if ((i.caller != this)) | |
267 | + | then (i.caller != getTurtleRebirthAddress()) | |
268 | + | else false) | |
269 | + | then throw("IIFDDG: Admin only!") | |
270 | + | else { | |
271 | + | let txId = fromBase58String(txIdStr) | |
272 | + | let hatchingStatusKey = getHatchingStatusKey(address, txId) | |
273 | + | let finishHeightKey = getHatchingFinishHeightKey(address, txId) | |
274 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
275 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
276 | + | let colorRandom = getRandomNumber(4, txId, height, 6) | |
277 | + | let color = if ((colorRandom == 0)) | |
278 | + | then "Y" | |
279 | + | else if ((colorRandom == 1)) | |
280 | + | then "G" | |
281 | + | else if ((colorRandom == 2)) | |
282 | + | then "B" | |
283 | + | else "R" | |
284 | + | let $t01119611273 = $Tuple2(((("DUCK-" + genes) + "-G") + color), (("8" + take(genes, 1)) + "-G")) | |
285 | + | let duckGen = $t01119611273._1 | |
286 | + | let farmGen = $t01119611273._2 | |
287 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
288 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, height) | |
289 | + | let assetId = calculateAssetId(asset) | |
290 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
291 | + | let duckIdKey = getDuckIdKey(address, txId) | |
292 | + | $Tuple2([IntegerEntry(getHatchingFinishHeightKey(address, txId), height), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), IntegerEntry(getDuckStatsKey(duckGen), amount), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], toBase58String(assetId)) | |
293 | + | } | |
294 | + | ||
295 | + | ||
296 | + | ||
297 | + | @Callable(i) | |
298 | + | func issueJackpot (address,txIdStr,gen) = if (if ((i.caller != getRebirthAddress())) | |
299 | + | then (i.caller != this) | |
300 | + | else false) | |
301 | + | then throw("ISJ: admin or rebirth only") | |
302 | + | else { | |
303 | + | let txId = fromBase58String(txIdStr) | |
304 | + | let hatchingStatusKey = getHatchingStatusKey(address, txId) | |
305 | + | let finishHeightKey = getHatchingFinishHeightKey(address, txId) | |
306 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
307 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
308 | + | let $t01272212774 = $Tuple2((("DUCK-" + gen) + "-JU"), "8W-J") | |
309 | + | let duckGen = $t01272212774._1 | |
310 | + | let farmGen = $t01272212774._2 | |
311 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
312 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, height) | |
313 | + | let assetId = calculateAssetId(asset) | |
314 | + | let duckIdKey = getDuckIdKey(address, txId) | |
315 | + | let valueDuckIdKeyExits = tryGetString(duckIdKey) | |
316 | + | if ((valueDuckIdKeyExits != "")) | |
317 | + | then throw((("ISJ: You will override following duckId :" + duckIdKey) + " make sure that your txId is unique!")) | |
318 | + | else $Tuple2([IntegerEntry(getHatchingFinishHeightKey(address, txId), height), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), IntegerEntry(getDuckStatsKey(duckGen), (tryGetInteger(getDuckStatsKey(duckGen)) + 1)), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], toBase58String(assetId)) | |
319 | + | } | |
320 | + | ||
321 | + | ||
322 | + | ||
323 | + | @Callable(i) | |
324 | + | func reduceRarity (assetId,fGen) = { | |
325 | + | let asset = fromBase58String(assetId) | |
326 | + | if (if ((i.caller != getRebirthAddress())) | |
327 | + | then (i.caller != this) | |
328 | + | else false) | |
329 | + | then throw("IRR: admin or rebirth only") | |
330 | + | else { | |
331 | + | let duckGen = value(assetInfo(asset)).name | |
332 | + | let letter = takeRight(take(duckGen, 6), 1) | |
333 | + | let farmGen = (("8" + letter) + "-G") | |
334 | + | [IntegerEntry(getDuckStatsKey(duckGen), (tryGetInteger(getDuckStatsKey(duckGen)) - 1)), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) - 1))] | |
466 | 335 | } | |
467 | 336 | } | |
468 | 337 | ||
469 | 338 | ||
470 | 339 | ||
471 | 340 | @Callable(i) | |
472 | - | func finishRebirth (initTx) = finishRebirthInternal(initTx, toString(i.caller), i.payments[0], false) | |
473 | - | ||
474 | - | ||
475 | - | ||
476 | - | @Callable(i) | |
477 | - | func finishRebirthDouble (initTx) = if (!(if ((size(i.payments) == 2)) | |
478 | - | then (i.payments[0].amount == 1) | |
479 | - | else false)) | |
480 | - | then throw("Invalid payment") | |
481 | - | else { | |
482 | - | let assetId = value(i.payments[0].assetId) | |
483 | - | let boosterType = asString(invoke(getItemsAddress(), "checkArtefactDetails", [toBase58String(assetId)], nil)) | |
484 | - | if ((boosterType == boosterType)) | |
485 | - | then if ((boosterType == "ART-GIFT_DOUBL")) | |
486 | - | then ([Burn(assetId, 1)] ++ finishRebirthInternal(initTx, toString(i.caller), i.payments[1], true)) | |
487 | - | else throw("Error! Wrong item attached to double rewards!") | |
488 | - | else throw("Strict value is not equal to itself.") | |
489 | - | } | |
341 | + | func finishDuckHatchingAdmin (txIdStr,owner) = if ((i.caller != this)) | |
342 | + | then throw("IFDHA: Only admins can run this!") | |
343 | + | else finishHatchingInternal(txIdStr, owner) | |
490 | 344 | ||
491 | 345 | ||
492 | 346 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func tryGetStringExternal (address,key) = match getString(address, key) { | |
5 | 5 | case a: String => | |
6 | 6 | a | |
7 | 7 | case _ => | |
8 | 8 | "" | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | - | func tryGetIntExternal (address,key) = match getInteger(address, key) { | |
13 | - | case a: Int => | |
14 | - | a | |
15 | - | case _ => | |
16 | - | throw("RTGIE: Something went wrong") | |
17 | - | } | |
12 | + | func tryGetString (key) = tryGetStringExternal(this, key) | |
18 | 13 | ||
19 | 14 | ||
20 | - | func asBoolean (value) = match value { | |
21 | - | case boolean: Boolean => | |
22 | - | boolean | |
23 | - | case _ => | |
24 | - | throw("FAB: wrong type, expected: Boolean") | |
25 | - | } | |
15 | + | func staticKey_turtleRebirthAddress () = "static_turtleRebirthAddress" | |
26 | 16 | ||
27 | 17 | ||
28 | - | func tryGetString (key) = tryGetStringExternal(this, key) | |
18 | + | func getOracle () = Address(fromBase58String(tryGetString("static_oracleAddress"))) | |
19 | + | ||
20 | + | ||
21 | + | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), "static_eggAssetId")) | |
22 | + | ||
23 | + | ||
24 | + | func getRebirthAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_rebirthAddress"))) | |
25 | + | ||
26 | + | ||
27 | + | func getBabyDuckAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_babyDuckAddress"))) | |
28 | + | ||
29 | + | ||
30 | + | func getRefContractAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_refContractAddress"))) | |
31 | + | ||
32 | + | ||
33 | + | func getCouponsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_couponsAddress"))) | |
34 | + | ||
35 | + | ||
36 | + | func getBurnAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), "static_burnAddress"))) | |
37 | + | ||
38 | + | ||
39 | + | func getTurtleRebirthAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_turtleRebirthAddress()))) | |
29 | 40 | ||
30 | 41 | ||
31 | 42 | let delayForHatching = 2 | |
32 | 43 | ||
33 | - | ||
44 | + | let typesAmount = 10 | |
34 | 45 | ||
46 | + | let RefererReward = 5 | |
35 | 47 | ||
36 | - | ||
48 | + | let HatchingStarted = "HATCHING_STARTED" | |
37 | 49 | ||
50 | + | let HatchingFinished = "HATCHING_FINISHED" | |
38 | 51 | ||
39 | - | func staticKey_incubatorAddress () = "static_incubatorAddress" | |
40 | - | ||
41 | - | ||
42 | - | func staticKey_breederAddress () = "static_breederAddress" | |
43 | - | ||
44 | - | ||
45 | - | func staticKey_farmingAddress () = "static_farmingAddressNew" | |
46 | - | ||
47 | - | ||
48 | - | func staticKey_babyDuckAddress () = "static_babyDuckAddress" | |
49 | - | ||
50 | - | ||
51 | - | func staticKey_gameDappAddress () = "static_gameDappAddress" | |
52 | - | ||
53 | - | ||
54 | - | func staticKey_itemsAddress () = "static_itemsAddress" | |
55 | - | ||
56 | - | ||
57 | - | func staticKey_couponsAddress () = "static_couponsAddress" | |
58 | - | ||
59 | - | ||
60 | - | func staticKey_huntAddress () = "static_huntAddress" | |
61 | - | ||
62 | - | ||
63 | - | func staticKey_burnAddress () = "static_burnAddress" | |
64 | - | ||
65 | - | ||
66 | - | func staticKey_refContractAddress () = "static_refContractAddress" | |
67 | - | ||
68 | - | ||
69 | - | func staticKey_extraFee () = "static_extraFee" | |
70 | - | ||
71 | - | ||
72 | - | func staticKey_feeAggregator () = "static_feeAggregator" | |
73 | - | ||
74 | - | ||
75 | - | func getOracle () = Address(fromBase58String(tryGetString(staticKey_oracleAddress()))) | |
76 | - | ||
77 | - | ||
78 | - | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), staticKey_eggAssetId())) | |
79 | - | ||
80 | - | ||
81 | - | func getIncubatorAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_incubatorAddress()))) | |
82 | - | ||
83 | - | ||
84 | - | func getBreederAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_breederAddress()))) | |
85 | - | ||
86 | - | ||
87 | - | func getFarmingAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_farmingAddress()))) | |
88 | - | ||
89 | - | ||
90 | - | func getBabyDuckAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_babyDuckAddress()))) | |
91 | - | ||
92 | - | ||
93 | - | func getGameDappAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_gameDappAddress()))) | |
94 | - | ||
95 | - | ||
96 | - | func getItemsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_itemsAddress()))) | |
97 | - | ||
98 | - | ||
99 | - | func getCouponsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_couponsAddress()))) | |
100 | - | ||
101 | - | ||
102 | - | func getHuntAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_huntAddress()))) | |
103 | - | ||
104 | - | ||
105 | - | func getBurnAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_burnAddress()))) | |
106 | - | ||
107 | - | ||
108 | - | func getRefContractAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_refContractAddress()))) | |
109 | - | ||
110 | - | ||
111 | - | func getFeeAggregator () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_feeAggregator()))) | |
112 | - | ||
113 | - | ||
114 | - | func checkAdditionalPayment (payment) = if (isDefined(payment.assetId)) | |
115 | - | then throw("RCAP: Please attach waves") | |
116 | - | else { | |
117 | - | let feeAmount = getIntegerValue(getOracle(), staticKey_extraFee()) | |
118 | - | if ((payment.amount != feeAmount)) | |
119 | - | then throw((("RCAP: Please attach exactly " + toString(feeAmount)) + " amount of wavelets")) | |
120 | - | else [ScriptTransfer(getFeeAggregator(), feeAmount, unit)] | |
121 | - | } | |
122 | - | ||
123 | - | ||
124 | - | let PHOENIXBASEOPTIONS = 1000 | |
125 | - | ||
126 | - | func tryGetInteger (key) = match getInteger(this, key) { | |
127 | - | case b: Int => | |
128 | - | b | |
129 | - | case _ => | |
130 | - | 0 | |
131 | - | } | |
132 | - | ||
133 | - | ||
134 | - | func asString (value) = match value { | |
135 | - | case s: String => | |
136 | - | s | |
137 | - | case s: Int => | |
138 | - | throw("wrong type, expected: String, got: Int") | |
139 | - | case s: Unit => | |
140 | - | throw("wrong type, expected: String, got: Unit") | |
141 | - | case _ => | |
142 | - | throw("wrong type, expected: String") | |
143 | - | } | |
144 | - | ||
145 | - | ||
146 | - | let feeAmount = tryGetInteger("currentPrice") | |
147 | - | ||
148 | - | func getAmountOrClear (amount) = if (contains(amount, "0")) | |
149 | - | then "" | |
150 | - | else amount | |
151 | - | ||
152 | - | ||
153 | - | func getAssetOrigin (generation) = if ((generation == "G")) | |
154 | - | then getIncubatorAddress() | |
155 | - | else getBreederAddress() | |
156 | - | ||
157 | - | ||
158 | - | func getAssetRarity (genotype,generation) = { | |
159 | - | let quantity = getIntegerValue(getAssetOrigin(generation), (("stats_" + genotype) + "_quantity")) | |
160 | - | let power = pow((10000 / quantity), 4, 5, 1, 2, FLOOR) | |
161 | - | if ((power > 0)) | |
162 | - | then power | |
163 | - | else 2 | |
52 | + | func isLocked () = { | |
53 | + | let masterAddress = Address(base58'3PEPftf2kWZDmAaWBjs6BUJa9957kiA2PkU') | |
54 | + | match getInteger(masterAddress, "egglock") { | |
55 | + | case b: Int => | |
56 | + | b | |
57 | + | case _ => | |
58 | + | 0 | |
59 | + | } | |
164 | 60 | } | |
165 | 61 | ||
166 | 62 | ||
167 | - | func getAssetFarmingPower (assetId) = if (if ((value(assetInfo(assetId)).issuer == getBreederAddress())) | |
168 | - | then true | |
169 | - | else (value(assetInfo(assetId)).issuer == getIncubatorAddress())) | |
170 | - | then { | |
171 | - | let assetName = value(assetInfo(assetId)).name | |
172 | - | let generation = take(takeRight(assetName, 2), 1) | |
173 | - | let farmGen = asString(invoke(getBreederAddress(), "getGenFromName", [assetName], nil)) | |
174 | - | if ((farmGen == farmGen)) | |
175 | - | then $Tuple2(farmGen, getAssetRarity(farmGen, generation)) | |
176 | - | else throw("Strict value is not equal to itself.") | |
177 | - | } | |
178 | - | else throw("not valid NFT") | |
63 | + | func getHatchingStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status") | |
179 | 64 | ||
180 | 65 | ||
181 | - | func getRandomNumber (options,txId,hatchingFinishHeight,offset) = { | |
182 | - | let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1))) | |
183 | - | let randomHash = sha256((txId + value(randomSeedBlock.vrf))) | |
184 | - | (toInt(randomHash, (offset * 8)) % options) | |
66 | + | func getHatchingFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh") | |
67 | + | ||
68 | + | ||
69 | + | func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di") | |
70 | + | ||
71 | + | ||
72 | + | func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount") | |
73 | + | ||
74 | + | ||
75 | + | func tryGetInteger (key) = { | |
76 | + | let val = match getInteger(this, key) { | |
77 | + | case b: Int => | |
78 | + | b | |
79 | + | case _ => | |
80 | + | 0 | |
81 | + | } | |
82 | + | val | |
185 | 83 | } | |
186 | 84 | ||
187 | 85 | ||
188 | - | func getRandomWin (tx,finishHeight,assetRarity) = { | |
189 | - | let jackpotRandom = getRandomNumber(10, tx, finishHeight, 1) | |
190 | - | if ((jackpotRandom == 1)) | |
191 | - | then "phoenix" | |
192 | - | else { | |
193 | - | let n = getRandomNumber(1000, tx, finishHeight, 0) | |
194 | - | if ((10 > n)) | |
195 | - | then "item!ART-FREEGENE" | |
196 | - | else if ((126 > n)) | |
197 | - | then "ar" | |
198 | - | else if ((186 > n)) | |
199 | - | then "item!ART-FIRE_ARMOUR" | |
200 | - | else if ((206 > n)) | |
201 | - | then "item!ART-FEED5" | |
202 | - | else if ((226 > n)) | |
203 | - | then "item!ART-FEED10" | |
204 | - | else if ((246 > n)) | |
205 | - | then "item!ART-FEED15" | |
206 | - | else if ((266 > n)) | |
207 | - | then "item!ART-FEED20" | |
208 | - | else if ((286 > n)) | |
209 | - | then "item!ART-FEED25" | |
210 | - | else if ((296 > n)) | |
211 | - | then "item!ART-FEED50" | |
212 | - | else if ((300 > n)) | |
213 | - | then "item!ART-FEED100" | |
214 | - | else if ((310 > n)) | |
215 | - | then "item!ART-CROWN" | |
216 | - | else if ((350 > n)) | |
217 | - | then "incubator" | |
218 | - | else if ((460 > n)) | |
219 | - | then if ((50 > assetRarity)) | |
220 | - | then "item!ART-BUILTBODY" | |
221 | - | else "item!ART-MUTARIUM-D" | |
222 | - | else if ((480 > n)) | |
223 | - | then "item!ART-SNAKE" | |
224 | - | else if ((510 > n)) | |
225 | - | then "item!ART-ROBODUCK" | |
226 | - | else if ((600 > n)) | |
227 | - | then "item!ART-KATANA" | |
228 | - | else if ((650 > n)) | |
229 | - | then if ((50 > assetRarity)) | |
230 | - | then "item!ART-SCEPTER" | |
231 | - | else "item!ART-MUTARIUM-D" | |
232 | - | else if ((710 > n)) | |
233 | - | then "item!ART-MUTARIUM-D" | |
234 | - | else if ((720 > n)) | |
235 | - | then "item!ART-MUTARIUM-G" | |
236 | - | else if ((890 > n)) | |
237 | - | then "duckling_10" | |
238 | - | else if ((960 > n)) | |
239 | - | then "duckling_20" | |
240 | - | else "duckling_40" | |
241 | - | } | |
86 | + | let discountCoefficient = tryGetInteger("discountCoefficient") | |
87 | + | ||
88 | + | let saleCoefficient = tryGetInteger("saleCoefficient") | |
89 | + | ||
90 | + | func getRandomNumber (variants,txId,hatchingFinishHeight,offset) = { | |
91 | + | let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1))) | |
92 | + | let randomHash = sha256(((base58'incubator' + txId) + value(randomSeedBlock.vrf))) | |
93 | + | (toInt(randomHash, offset) % variants) | |
242 | 94 | } | |
243 | 95 | ||
244 | 96 | ||
245 | - | func getOrigin (assetId) = { | |
246 | - | let assetName = value(assetInfo(assetId)).name | |
247 | - | let generation = take(takeRight(assetName, 2), 1) | |
248 | - | if (if ((generation == "G")) | |
249 | - | then true | |
250 | - | else (generation == "J")) | |
251 | - | then getIncubatorAddress() | |
252 | - | else getBreederAddress() | |
97 | + | func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen)) | |
98 | + | ||
99 | + | ||
100 | + | func getRandomName (txId,hatchingFinishHeight) = { | |
101 | + | let jackpotRandom = getRandomNumber(200, txId, hatchingFinishHeight, 4) | |
102 | + | let entry = IntegerEntry("last_jackpot_random", jackpotRandom) | |
103 | + | let typeRandom = getRandomNumber(4, txId, hatchingFinishHeight, 5) | |
104 | + | let colorRandom = getRandomNumber(4, txId, hatchingFinishHeight, 6) | |
105 | + | let color = if ((colorRandom == 0)) | |
106 | + | then "Y" | |
107 | + | else if ((colorRandom == 1)) | |
108 | + | then "G" | |
109 | + | else if ((colorRandom == 2)) | |
110 | + | then "B" | |
111 | + | else "R" | |
112 | + | if ((typeRandom == 0)) | |
113 | + | then $Tuple3(("DUCK-MMMMMMMM-G" + color), "8M-G", entry) | |
114 | + | else if ((typeRandom == 1)) | |
115 | + | then $Tuple3(("DUCK-NNNNNNNN-G" + color), "8N-G", entry) | |
116 | + | else if ((typeRandom == 2)) | |
117 | + | then $Tuple3(("DUCK-OOOOOOOO-G" + color), "8O-G", entry) | |
118 | + | else $Tuple3(("DUCK-PPPPPPPP-G" + color), "8P-G", entry) | |
119 | + | } | |
120 | + | ||
121 | + | ||
122 | + | func countEggsNeededAmount (totalDucksAmount) = { | |
123 | + | let n = totalDucksAmount | |
124 | + | let g = discountCoefficient | |
125 | + | let s = saleCoefficient | |
126 | + | let t = typesAmount | |
127 | + | let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN) | |
128 | + | if ((saleCoefficient == 0)) | |
129 | + | then (price * 1000000) | |
130 | + | else (((price * 1000000) / 100) * (100 - saleCoefficient)) | |
253 | 131 | } | |
254 | 132 | ||
255 | 133 | ||
256 | 134 | func asInt (value) = match value { | |
257 | 135 | case int: Int => | |
258 | 136 | int | |
259 | - | case string: String => | |
260 | - | throw(("RAI: wrong type, expected: Int, but got: " + string)) | |
261 | 137 | case _ => | |
262 | - | throw(" | |
138 | + | throw("IAI: wrong type, expected: Int") | |
263 | 139 | } | |
140 | + | ||
141 | + | ||
142 | + | func finishHatchingInternal (txIdStr,owner) = { | |
143 | + | let txId = fromBase58String(txIdStr) | |
144 | + | let hatchingStatusKey = getHatchingStatusKey(owner, txId) | |
145 | + | let finishHeightKey = getHatchingFinishHeightKey(owner, txId) | |
146 | + | let duckIdKey = getDuckIdKey(owner, txId) | |
147 | + | let duckFromBaby = match getBoolean((("hatching_" + txIdStr) + "_babyDuck")) { | |
148 | + | case t: Boolean => | |
149 | + | t | |
150 | + | case _ => | |
151 | + | false | |
152 | + | } | |
153 | + | let hatchingTxStatus = getStringValue(this, hatchingStatusKey) | |
154 | + | let hatchingFinishHeight = getIntegerValue(this, finishHeightKey) | |
155 | + | if ((hatchingTxStatus == HatchingFinished)) | |
156 | + | then { | |
157 | + | let duckId = getStringValue(this, getDuckIdKey(owner, txId)) | |
158 | + | throw(("IFDH: The duck was hatched and claimed already, here is the folowing: " + duckId)) | |
159 | + | } | |
160 | + | else if ((hatchingFinishHeight > height)) | |
161 | + | then throw((((("Hatching is not finished yet " + toString((hatchingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((hatchingFinishHeight - height))) + " minutes")) | |
162 | + | else { | |
163 | + | let $t055055591 = getRandomName(txId, hatchingFinishHeight) | |
164 | + | let duckGen = $t055055591._1 | |
165 | + | let farmGen = $t055055591._2 | |
166 | + | let jackpotRandomEntry = $t055055591._3 | |
167 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
168 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, hatchingFinishHeight) | |
169 | + | let assetId = calculateAssetId(asset) | |
170 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
171 | + | [StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), BooleanEntry((("duck_" + toBase58String(assetId)) + "_grown"), duckFromBaby), IntegerEntry(getDuckStatsKey(duckGen), amount), jackpotRandomEntry, IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(Address(fromBase58String(owner)), 1, assetId)] | |
172 | + | } | |
173 | + | } | |
264 | 174 | ||
265 | 175 | ||
266 | 176 | func getBool (key) = match getBoolean(this, key) { | |
267 | 177 | case b: Boolean => | |
268 | 178 | b | |
269 | 179 | case _ => | |
270 | 180 | false | |
271 | 181 | } | |
272 | 182 | ||
273 | 183 | ||
274 | 184 | func isTestEnv () = getBool("TESTENV") | |
275 | 185 | ||
276 | 186 | ||
277 | - | func finishRebirthInternal (initTx,address,payment,double) = { | |
278 | - | let finishBlock = tryGetInteger((((("address_" + address) + "_initTx_") + initTx) + "_finishBlock")) | |
279 | - | let assetRarity = tryGetInteger((((("address_" + address) + "_initTx_") + initTx) + "_assetRarity")) | |
280 | - | let status = tryGetString((((("address_" + address) + "_initTx_") + initTx) + "_status")) | |
281 | - | let validPayment = checkAdditionalPayment(payment) | |
282 | - | if ((validPayment == validPayment)) | |
283 | - | then { | |
284 | - | let recordAction = invoke(getCouponsAddress(), "recordAction", ["REBIRTH"], nil) | |
285 | - | if ((recordAction == recordAction)) | |
286 | - | then { | |
287 | - | func getAccessItemAssetId (address) = fromBase58String(tryGetStringExternal(address, "static_accessItemAssetId")) | |
288 | - | ||
289 | - | func getAccessItemPrice (address) = tryGetIntExternal(address, "static_accessItemPrice") | |
290 | - | ||
291 | - | if ((status != "open")) | |
292 | - | then throw("rebirth is finished or not open") | |
293 | - | else if ((finishBlock > height)) | |
294 | - | then throw("you cannot finish rebirth, yet") | |
295 | - | else { | |
296 | - | let win = getRandomWin(fromBase58String(initTx), finishBlock, assetRarity) | |
297 | - | let txId = initTx | |
298 | - | let result = if ((indexOf(win, "perch") != unit)) | |
299 | - | then { | |
300 | - | let color = takeRight(win, 1) | |
301 | - | let result = if (!(double)) | |
302 | - | then { | |
303 | - | let first = invoke(getFarmingAddress(), "addFreePerch", [address, color, 1], nil) | |
304 | - | if ((first == first)) | |
305 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first))] | |
306 | - | else throw("Strict value is not equal to itself.") | |
307 | - | } | |
308 | - | else { | |
309 | - | let first = invoke(getFarmingAddress(), "addFreePerch", [address, color, 2], nil) | |
310 | - | if ((first == first)) | |
311 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result1"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win1"), win)] | |
312 | - | else throw("Strict value is not equal to itself.") | |
313 | - | } | |
314 | - | if ((result == result)) | |
315 | - | then result | |
316 | - | else throw("Strict value is not equal to itself.") | |
317 | - | } | |
318 | - | else if ((win == "incubator")) | |
319 | - | then { | |
320 | - | let result = if (!(double)) | |
321 | - | then { | |
322 | - | let first = invoke(getIncubatorAddress(), "issueFreeDuck", [address, txId], nil) | |
323 | - | if ((first == first)) | |
324 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first))] | |
325 | - | else throw("Strict value is not equal to itself.") | |
326 | - | } | |
327 | - | else { | |
328 | - | let first = invoke(getIncubatorAddress(), "issueFreeDuck", [address, txId], nil) | |
329 | - | if ((first == first)) | |
330 | - | then { | |
331 | - | let second = invoke(getBabyDuckAddress(), "issueFreeDuckling", [address, txId, 100], nil) | |
332 | - | if ((second == second)) | |
333 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result1"), asString(second)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win1"), "duckling_100")] | |
334 | - | else throw("Strict value is not equal to itself.") | |
335 | - | } | |
336 | - | else throw("Strict value is not equal to itself.") | |
337 | - | } | |
338 | - | if ((result == result)) | |
339 | - | then result | |
340 | - | else throw("Strict value is not equal to itself.") | |
341 | - | } | |
342 | - | else if ((win == "ar")) | |
343 | - | then { | |
344 | - | let assetId = getAccessItemAssetId(getHuntAddress()) | |
345 | - | let price = getAccessItemPrice(getHuntAddress()) | |
346 | - | let call = invoke(getHuntAddress(), "buyAccessItemOther", [address], [AttachedPayment(assetId, price)]) | |
347 | - | if ((call == call)) | |
348 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(call))] | |
349 | - | else throw("Strict value is not equal to itself.") | |
350 | - | } | |
351 | - | else if ((win == "phoenix")) | |
352 | - | then { | |
353 | - | let call = invoke(getIncubatorAddress(), "issueJackpot", [address, txId, "WWWWHWTF"], nil) | |
354 | - | if ((call == call)) | |
355 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(call))] | |
356 | - | else throw("Strict value is not equal to itself.") | |
357 | - | } | |
358 | - | else if ((indexOf(win, "duckling") != unit)) | |
359 | - | then { | |
360 | - | let level = parseIntValue(split(win, "_")[1]) | |
361 | - | let levelFinal = if (double) | |
362 | - | then (2 * level) | |
363 | - | else level | |
364 | - | let call = invoke(getBabyDuckAddress(), "issueFreeDuckling", [address, txId, levelFinal], nil) | |
365 | - | if ((call == call)) | |
366 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(call))] | |
367 | - | else throw("Strict value is not equal to itself.") | |
368 | - | } | |
369 | - | else if ((indexOf(win, "item") != unit)) | |
370 | - | then { | |
371 | - | let itemName = split(win, "!")[1] | |
372 | - | let result = if (!(double)) | |
373 | - | then { | |
374 | - | let first = invoke(getItemsAddress(), "issueArtefactIndex", [itemName, address, 0], nil) | |
375 | - | if ((first == first)) | |
376 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first))] | |
377 | - | else throw("Strict value is not equal to itself.") | |
378 | - | } | |
379 | - | else { | |
380 | - | let first = invoke(getItemsAddress(), "issueArtefactIndex", [itemName, address, 0], nil) | |
381 | - | if ((first == first)) | |
382 | - | then { | |
383 | - | let second = invoke(getItemsAddress(), "issueArtefactIndex", [itemName, address, 1], nil) | |
384 | - | if ((second == second)) | |
385 | - | then [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(first)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_result"), asString(second)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win1"), win)] | |
386 | - | else throw("Strict value is not equal to itself.") | |
387 | - | } | |
388 | - | else throw("Strict value is not equal to itself.") | |
389 | - | } | |
390 | - | if ((result == result)) | |
391 | - | then result | |
392 | - | else throw("Strict value is not equal to itself.") | |
393 | - | } | |
394 | - | else throw("RFB: Some error occured, please contact the admins!") | |
395 | - | ((result ++ [StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_win"), win), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_status"), "finish")]) ++ validPayment) | |
396 | - | } | |
397 | - | } | |
398 | - | else throw("Strict value is not equal to itself.") | |
399 | - | } | |
400 | - | else throw("Strict value is not equal to itself.") | |
401 | - | } | |
402 | - | ||
403 | - | ||
404 | 187 | @Callable(i) | |
405 | 188 | func configureOracle (oracle) = if ((i.caller != this)) | |
406 | - | then throw(" | |
189 | + | then throw("ICU: admin only") | |
407 | 190 | else [StringEntry("static_oracleAddress", oracle)] | |
408 | 191 | ||
409 | 192 | ||
410 | 193 | ||
411 | 194 | @Callable(i) | |
412 | - | func initRebirth (refererAddress) = { | |
413 | - | let pmt = i.payments[0] | |
414 | - | let assetId = value(pmt.assetId) | |
415 | - | let initTx = toBase58String(i.transactionId) | |
416 | - | let address = toString(i.caller) | |
417 | - | if ((pmt.amount != 1)) | |
418 | - | then throw("NFT is not attached") | |
195 | + | func setDiscount (val) = if ((i.caller != this)) | |
196 | + | then throw("ISD: admin_only") | |
197 | + | else [IntegerEntry("discountCoefficient", val)] | |
198 | + | ||
199 | + | ||
200 | + | ||
201 | + | @Callable(i) | |
202 | + | func setSale (val) = if ((i.caller != this)) | |
203 | + | then throw("ISS: admin_only") | |
204 | + | else [IntegerEntry("saleCoefficient", val)] | |
205 | + | ||
206 | + | ||
207 | + | ||
208 | + | @Callable(i) | |
209 | + | func startDuckHatching (refererAddress) = if ((getBabyDuckAddress() != i.caller)) | |
210 | + | then throw("ISDHFA: From now on this is only possible through ducklings!") | |
211 | + | else if ((isLocked() > 0)) | |
212 | + | then throw("ISDH: EGG operations are temporarily locked") | |
419 | 213 | else { | |
420 | - | let amountPaidByCoupons = asInt(invoke(getCouponsAddress(), "useCoupons", [feeAmount], nil)) | |
421 | - | if ((amountPaidByCoupons == amountPaidByCoupons)) | |
422 | - | then { | |
423 | - | let leftToPay = (feeAmount - amountPaidByCoupons) | |
424 | - | let validPayment = checkAdditionalPayment(i.payments[1]) | |
425 | - | if ((validPayment == validPayment)) | |
426 | - | then { | |
427 | - | let payment = if ((leftToPay != 0)) | |
428 | - | then { | |
429 | - | let feePayment = value(i.payments[2]) | |
430 | - | if ((feePayment.assetId != getEggAssetId())) | |
431 | - | then throw("You need to attach EGG tokens as fee") | |
432 | - | else if ((leftToPay > feePayment.amount)) | |
433 | - | then throw(("You need to attach the following amount of EGG tokens as fee: 0." + toString(leftToPay))) | |
434 | - | else { | |
435 | - | let refererRewardForPerch = fraction(leftToPay, 5, 100) | |
436 | - | let refCall = asBoolean(invoke(getRefContractAddress(), "refPayment", [refererAddress], [AttachedPayment(getEggAssetId(), refererRewardForPerch)])) | |
437 | - | if ((refCall == refCall)) | |
438 | - | then { | |
439 | - | let toBurn = if (refCall) | |
440 | - | then (leftToPay - refererRewardForPerch) | |
441 | - | else leftToPay | |
442 | - | let burnCall = invoke(getBurnAddress(), "burnAttachedPayments", nil, [AttachedPayment(getEggAssetId(), toBurn)]) | |
443 | - | if ((burnCall == burnCall)) | |
444 | - | then leftToPay | |
445 | - | else throw("Strict value is not equal to itself.") | |
446 | - | } | |
447 | - | else throw("Strict value is not equal to itself.") | |
448 | - | } | |
449 | - | } | |
450 | - | else 0 | |
451 | - | if ((payment == payment)) | |
452 | - | then { | |
453 | - | let $t01380913858 = getAssetFarmingPower(assetId) | |
454 | - | let gen = $t01380913858._1 | |
455 | - | let rarity = $t01380913858._2 | |
456 | - | let call = invoke(getOrigin(assetId), "reduceRarity", [toBase58String(assetId), gen], nil) | |
457 | - | if ((call == call)) | |
458 | - | then ([IntegerEntry((((("address_" + address) + "_initTx_") + initTx) + "_finishBlock"), (height + delayForHatching)), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_status"), "open"), IntegerEntry((((("address_" + address) + "_initTx_") + initTx) + "_assetRarity"), rarity), StringEntry((((("address_" + address) + "_initTx_") + initTx) + "_assetId"), toBase58String(assetId))] ++ validPayment) | |
459 | - | else throw("Strict value is not equal to itself.") | |
460 | - | } | |
461 | - | else throw("Strict value is not equal to itself.") | |
462 | - | } | |
463 | - | else throw("Strict value is not equal to itself.") | |
464 | - | } | |
465 | - | else throw("Strict value is not equal to itself.") | |
214 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
215 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
216 | + | [StringEntry(getHatchingStatusKey(toString(i.originCaller), i.transactionId), HatchingStarted), IntegerEntry(getHatchingFinishHeightKey(toString(i.originCaller), i.transactionId), (height + delayForHatching)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), BooleanEntry((("hatching_" + toBase58String(i.transactionId)) + "_babyDuck"), true)] | |
217 | + | } | |
218 | + | ||
219 | + | ||
220 | + | ||
221 | + | @Callable(i) | |
222 | + | func startDuckHatchingForAddress (address) = if ((isLocked() > 0)) | |
223 | + | then throw("ISDHFA: EGG operations are temporarily locked") | |
224 | + | else if ((i.caller != this)) | |
225 | + | then throw("ISDHFA: Permission denied") | |
226 | + | else { | |
227 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
228 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
229 | + | [StringEntry(getHatchingStatusKey(address, i.transactionId), HatchingStarted), IntegerEntry(getHatchingFinishHeightKey(address, i.transactionId), (height + delayForHatching)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), BooleanEntry((("hatching_" + toBase58String(i.transactionId)) + "_promo"), true)] | |
230 | + | } | |
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | @Callable(i) | |
235 | + | func finishDuckHatching (txIdStr) = { | |
236 | + | let owner = toString(i.originCaller) | |
237 | + | finishHatchingInternal(txIdStr, owner) | |
238 | + | } | |
239 | + | ||
240 | + | ||
241 | + | ||
242 | + | @Callable(i) | |
243 | + | func issueFreeDuck (address,txIdStr) = if ((i.caller != getRebirthAddress())) | |
244 | + | then throw("ISFD: rebirth only") | |
245 | + | else { | |
246 | + | let txId = fromBase58String(txIdStr) | |
247 | + | let hatchingStatusKey = getHatchingStatusKey(address, txId) | |
248 | + | let finishHeightKey = getHatchingFinishHeightKey(address, txId) | |
249 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
250 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
251 | + | let $t093379499 = getRandomName(txId, (valueOrErrorMessage(transactionHeightById(txId), ((txIdStr + " not found ") + toBase58String(txId))) + 1)) | |
252 | + | let duckGen = $t093379499._1 | |
253 | + | let farmGen = $t093379499._2 | |
254 | + | let jackpotRandomEntry = $t093379499._3 | |
255 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
256 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, height) | |
257 | + | let assetId = calculateAssetId(asset) | |
258 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
259 | + | let duckIdKey = getDuckIdKey(address, txId) | |
260 | + | $Tuple2([IntegerEntry(getHatchingFinishHeightKey(address, txId), height), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), jackpotRandomEntry, StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), IntegerEntry(getDuckStatsKey(duckGen), amount), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], toBase58String(assetId)) | |
261 | + | } | |
262 | + | ||
263 | + | ||
264 | + | ||
265 | + | @Callable(i) | |
266 | + | func issueFreeDuckDefinedGenes (address,txIdStr,genes) = if (if ((i.caller != this)) | |
267 | + | then (i.caller != getTurtleRebirthAddress()) | |
268 | + | else false) | |
269 | + | then throw("IIFDDG: Admin only!") | |
270 | + | else { | |
271 | + | let txId = fromBase58String(txIdStr) | |
272 | + | let hatchingStatusKey = getHatchingStatusKey(address, txId) | |
273 | + | let finishHeightKey = getHatchingFinishHeightKey(address, txId) | |
274 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
275 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
276 | + | let colorRandom = getRandomNumber(4, txId, height, 6) | |
277 | + | let color = if ((colorRandom == 0)) | |
278 | + | then "Y" | |
279 | + | else if ((colorRandom == 1)) | |
280 | + | then "G" | |
281 | + | else if ((colorRandom == 2)) | |
282 | + | then "B" | |
283 | + | else "R" | |
284 | + | let $t01119611273 = $Tuple2(((("DUCK-" + genes) + "-G") + color), (("8" + take(genes, 1)) + "-G")) | |
285 | + | let duckGen = $t01119611273._1 | |
286 | + | let farmGen = $t01119611273._2 | |
287 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
288 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, height) | |
289 | + | let assetId = calculateAssetId(asset) | |
290 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
291 | + | let duckIdKey = getDuckIdKey(address, txId) | |
292 | + | $Tuple2([IntegerEntry(getHatchingFinishHeightKey(address, txId), height), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), IntegerEntry(getDuckStatsKey(duckGen), amount), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], toBase58String(assetId)) | |
293 | + | } | |
294 | + | ||
295 | + | ||
296 | + | ||
297 | + | @Callable(i) | |
298 | + | func issueJackpot (address,txIdStr,gen) = if (if ((i.caller != getRebirthAddress())) | |
299 | + | then (i.caller != this) | |
300 | + | else false) | |
301 | + | then throw("ISJ: admin or rebirth only") | |
302 | + | else { | |
303 | + | let txId = fromBase58String(txIdStr) | |
304 | + | let hatchingStatusKey = getHatchingStatusKey(address, txId) | |
305 | + | let finishHeightKey = getHatchingFinishHeightKey(address, txId) | |
306 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
307 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
308 | + | let $t01272212774 = $Tuple2((("DUCK-" + gen) + "-JU"), "8W-J") | |
309 | + | let duckGen = $t01272212774._1 | |
310 | + | let farmGen = $t01272212774._2 | |
311 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
312 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, height) | |
313 | + | let assetId = calculateAssetId(asset) | |
314 | + | let duckIdKey = getDuckIdKey(address, txId) | |
315 | + | let valueDuckIdKeyExits = tryGetString(duckIdKey) | |
316 | + | if ((valueDuckIdKeyExits != "")) | |
317 | + | then throw((("ISJ: You will override following duckId :" + duckIdKey) + " make sure that your txId is unique!")) | |
318 | + | else $Tuple2([IntegerEntry(getHatchingFinishHeightKey(address, txId), height), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000)), StringEntry(hatchingStatusKey, HatchingFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), IntegerEntry(getDuckStatsKey(duckGen), (tryGetInteger(getDuckStatsKey(duckGen)) + 1)), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(value(addressFromString(address)), 1, assetId)], toBase58String(assetId)) | |
319 | + | } | |
320 | + | ||
321 | + | ||
322 | + | ||
323 | + | @Callable(i) | |
324 | + | func reduceRarity (assetId,fGen) = { | |
325 | + | let asset = fromBase58String(assetId) | |
326 | + | if (if ((i.caller != getRebirthAddress())) | |
327 | + | then (i.caller != this) | |
328 | + | else false) | |
329 | + | then throw("IRR: admin or rebirth only") | |
330 | + | else { | |
331 | + | let duckGen = value(assetInfo(asset)).name | |
332 | + | let letter = takeRight(take(duckGen, 6), 1) | |
333 | + | let farmGen = (("8" + letter) + "-G") | |
334 | + | [IntegerEntry(getDuckStatsKey(duckGen), (tryGetInteger(getDuckStatsKey(duckGen)) - 1)), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) - 1))] | |
466 | 335 | } | |
467 | 336 | } | |
468 | 337 | ||
469 | 338 | ||
470 | 339 | ||
471 | 340 | @Callable(i) | |
472 | - | func finishRebirth (initTx) = finishRebirthInternal(initTx, toString(i.caller), i.payments[0], false) | |
473 | - | ||
474 | - | ||
475 | - | ||
476 | - | @Callable(i) | |
477 | - | func finishRebirthDouble (initTx) = if (!(if ((size(i.payments) == 2)) | |
478 | - | then (i.payments[0].amount == 1) | |
479 | - | else false)) | |
480 | - | then throw("Invalid payment") | |
481 | - | else { | |
482 | - | let assetId = value(i.payments[0].assetId) | |
483 | - | let boosterType = asString(invoke(getItemsAddress(), "checkArtefactDetails", [toBase58String(assetId)], nil)) | |
484 | - | if ((boosterType == boosterType)) | |
485 | - | then if ((boosterType == "ART-GIFT_DOUBL")) | |
486 | - | then ([Burn(assetId, 1)] ++ finishRebirthInternal(initTx, toString(i.caller), i.payments[1], true)) | |
487 | - | else throw("Error! Wrong item attached to double rewards!") | |
488 | - | else throw("Strict value is not equal to itself.") | |
489 | - | } | |
341 | + | func finishDuckHatchingAdmin (txIdStr,owner) = if ((i.caller != this)) | |
342 | + | then throw("IFDHA: Only admins can run this!") | |
343 | + | else finishHatchingInternal(txIdStr, owner) | |
490 | 344 | ||
491 | 345 | ||
492 | 346 | @Verifier(tx) | |
493 | 347 | func verify () = if (isTestEnv()) | |
494 | 348 | then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
495 | 349 | else { | |
496 | 350 | let firstUser = base58'6TdaXEfhnjYquvPf3yV7MFxt2CbgFmaqsvGwkKfXtKi4' | |
497 | 351 | let secondUser = base58'7DsP2WaMLocbHuUxux7pbXRjTrrZ1TFQPsi5QumS3gr8' | |
498 | 352 | let thirdUser = base58'BpFWP3p3JgYrrP45xfrKzeMcWMEXoinj4FVPPkUiA8D3' | |
499 | 353 | let firstUserSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], firstUser)) | |
500 | 354 | then 1 | |
501 | 355 | else if (sigVerify(tx.bodyBytes, tx.proofs[1], firstUser)) | |
502 | 356 | then 1 | |
503 | 357 | else if (sigVerify(tx.bodyBytes, tx.proofs[2], firstUser)) | |
504 | 358 | then 1 | |
505 | 359 | else 0 | |
506 | 360 | let secondUserSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], secondUser)) | |
507 | 361 | then 1 | |
508 | 362 | else if (sigVerify(tx.bodyBytes, tx.proofs[1], secondUser)) | |
509 | 363 | then 1 | |
510 | 364 | else if (sigVerify(tx.bodyBytes, tx.proofs[2], secondUser)) | |
511 | 365 | then 1 | |
512 | 366 | else 0 | |
513 | 367 | let thirdUserSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], thirdUser)) | |
514 | 368 | then 1 | |
515 | 369 | else if (sigVerify(tx.bodyBytes, tx.proofs[1], thirdUser)) | |
516 | 370 | then 1 | |
517 | 371 | else if (sigVerify(tx.bodyBytes, tx.proofs[2], thirdUser)) | |
518 | 372 | then 1 | |
519 | 373 | else 0 | |
520 | 374 | let signaturesCount = ((firstUserSigned + secondUserSigned) + thirdUserSigned) | |
521 | 375 | match tx { | |
522 | 376 | case _ => | |
523 | 377 | (signaturesCount >= 2) | |
524 | 378 | } | |
525 | 379 | } | |
526 | 380 |
github/deemru/w8io/026f985 71.92 ms ◑