tx · 4ivE1AGr4tkLf6aj5KdeM1VuUEnLG1yqANHszFQP6thM

3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r:  -0.04000000 Waves

2022.01.15 22:59 [1880515] smart account 3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r > SELF 0.00000000 Waves

{ "type": 13, "id": "4ivE1AGr4tkLf6aj5KdeM1VuUEnLG1yqANHszFQP6thM", "fee": 4000000, "feeAssetId": null, "timestamp": 1642276831554, "version": 2, "chainId": 84, "sender": "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r", "senderPublicKey": "GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY", "proofs": [ "mCrWzJXiS1cTNnSfhJBMJc6HSMJZNgWu5DHEy2BCnFJz3zLmZJCyjrUgm99rzkPc56xro77EWQ2NerxDEQeGZSU" ], "script": "base64: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", "height": 1880515, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 61zba1DFGcCSqhAZPKUUZRjm8wwBogJmdm1Txj9svZL2 Next: Cxym8uoY2kWiwWkG1yBzP1Cg6xBF259RnCmfHc7piFto Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let COLS = 1024
4+let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r"
55
6-let ROWS = 1024
6+let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY'
77
8-let nftDomain = "https://nft.gridgang.io/"
8+let holdingsAddress = addressFromPublicKey(holdingsPublicKey)
99
10-let DEBUG = true
10+let transferCostPct = 25
1111
12-let holdings = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r"
13-
14-let holdingsAddress = Address(fromBase58String(holdings))
15-
16-func getBoundCoords (data) = {
17- let $t0333355 = data
18- let x = $t0333355._1
19- let y = $t0333355._2
20- let gen = $t0333355._3
21- let d = pow(2, 0, (gen - 1), 0, 0, HALFUP)
22- let tl = $Tuple2((x - d), (y - d))
23- let tc = $Tuple2(x, (y - d))
24- let tr = $Tuple2((x + d), (y + d))
25- let l = $Tuple2((x - d), y)
26- let r = $Tuple2((x + d), y)
27- let bl = $Tuple2((x - d), (y + d))
28- let bc = $Tuple2(x, (y + d))
29- let br = $Tuple2((x + d), (y + d))
30-[$Tuple3(tl, tc, l), $Tuple3(tc, tr, r), $Tuple3(l, bl, bc), $Tuple3(r, bc, br)]
31- }
12+@Callable(i)
13+func addOwnerAndAmount (ownerId,assetId,amount) = [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount)]
3214
3315
34-func checkSquareForEvolve (coords,gen,ownerId) = {
35- let $t0788816 = coords
36- let xy1 = $t0788816._1
37- let xy2 = $t0788816._2
38- let xy3 = $t0788816._3
39- let xy1Key = (((((toString(xy1._1) + ",") + toString(xy1._2)) + ",") + gen) + "_owner")
40- let xy2Key = (((((toString(xy2._1) + ",") + toString(xy2._2)) + ",") + gen) + "_owner")
41- let xy3Key = (((((toString(xy3._1) + ",") + toString(xy3._2)) + ",") + gen) + "_owner")
42- let xyVal1 = match getString(this, xy1Key) {
16+
17+@Callable(i)
18+func buyFromHoldings (assetId) = {
19+ let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) {
4320 case _: Unit =>
4421 "unset"
4522 case x: String =>
4724 case _ =>
4825 throw("Match error")
4926 }
50- let xyVal2 = match getString(this, xy2Key) {
27+ let paymentAmount = valueOrElse(i.payments[0].amount, 0)
28+ let amount = match getString(this, (("sale_" + assetId) + "_amount")) {
5129 case _: Unit =>
52- "unset"
30+ 0
5331 case x: String =>
54- x
32+ (valueOrElse(parseInt(x), 0) * 100000000)
5533 case _ =>
5634 throw("Match error")
5735 }
58- let xyVal3 = match getString(this, xy3Key) {
59- case _: Unit =>
60- "unset"
61- case x: String =>
62- x
63- case _ =>
64- throw("Match error")
65- }
66- if (if ((xyVal1 == ownerId))
67- then (xyVal2 == ownerId)
68- else false)
69- then (xyVal3 == ownerId)
70- else false
36+ if ((ownerId == "unset"))
37+ then throw("Original owner not found ")
38+ else if (if ((amount == 0))
39+ then true
40+ else (amount > paymentAmount))
41+ then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount)))
42+ else {
43+ let transfer = [ScriptTransfer(i.caller, 1, fromBase58String(assetId))]
44+ if ((ownerId != holdingsAddressStr))
45+ then {
46+ let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000))
47+ let amountToTransferToOwner = (paymentAmount - amountToRemainInHoldings)
48+ let ownerAddress = Address(fromBase58String(ownerId))
49+ (transfer ++ [ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)])
50+ }
51+ else transfer
52+ }
7153 }
7254
7355
74-func getXyReturn (xy,gen) = {
75- let $t014921507 = xy
76- let x = $t014921507._1
77- let y = $t014921507._2
78- $Tuple3(x, y, (gen + 1))
79- }
80-
81-
82-func getXy (xyg,ownerId) = {
83- let checkList = getBoundCoords(xyg)
84- let $t016231644 = xyg
85- let x = $t016231644._1
86- let y = $t016231644._2
87- let gen = $t016231644._3
88- let genStr = toString(gen)
89- if (checkSquareForEvolve(checkList[0], genStr, ownerId))
90- then getXyReturn(checkList[0]._1, gen)
91- else if (checkSquareForEvolve(checkList[1], genStr, ownerId))
92- then getXyReturn(checkList[1]._1, gen)
93- else if (checkSquareForEvolve(checkList[2], genStr, ownerId))
94- then getXyReturn(checkList[2]._1, gen)
95- else if (checkSquareForEvolve(checkList[3], genStr, ownerId))
96- then getXyReturn(checkList[3]._1, gen)
97- else xyg
98- }
99-
100-
101-func checkForEvolve (xyg,ownerId) = {
102- let $t022912312 = xyg
103- let x = $t022912312._1
104- let y = $t022912312._2
105- let gen = $t022912312._3
106- let p1 = getXy(xyg, ownerId)
107- if ((p1._3 == gen))
108- then p1
109- else {
110- let p2 = getXy(p1, ownerId)
111- if ((p2._3 == p1._3))
112- then p2
113- else {
114- let p3 = getXy(p2, ownerId)
115- if ((p3._3 == p2._3))
116- then p3
117- else {
118- let p4 = getXy(p3, ownerId)
119- if ((p4._3 == p3._3))
120- then p4
121- else {
122- let p5 = getXy(p4, ownerId)
123- if ((p5._3 == p4._3))
124- then p5
125- else {
126- let p6 = getXy(p5, ownerId)
127- if ((p6._3 == p5._3))
128- then p6
129- else {
130- let p7 = getXy(p6, ownerId)
131- if ((p7._3 == p6._3))
132- then p7
133- else {
134- let p8 = getXy(p7, ownerId)
135- if ((p8._3 == p7._3))
136- then p8
137- else {
138- let p9 = getXy(p8, ownerId)
139- if ((p9._3 == p8._3))
140- then p9
141- else getXy(getXy(p9, ownerId), ownerId)
142- }
143- }
144- }
145- }
146- }
147- }
148- }
149- }
150- }
151-
152-
153-func claimSquare (x,y,ownerId,transactionId) = {
154- let $t033653462 = getXy($Tuple3(parseIntValue(x), parseIntValue(y), 1), ownerId)
155- let resolvedX = $t033653462._1
156- let resolvedY = $t033653462._2
157- let resolvedGen = $t033653462._3
158- let resolvedXStr = toString(resolvedX)
159- let resolvedYStr = toString(resolvedY)
160- let resolvedGenStr = toString(resolvedGen)
161- let assetName = ((resolvedXStr + ",") + resolvedYStr)
162- let assetUrl = ((nftDomain + transactionId) + ".png")
163- let asset = Issue(((assetName + " Gen ") + resolvedGenStr), assetUrl, 1, 0, false)
164- let assetId = calculateAssetId(asset)
165- let gen = resolvedGenStr
166- let dataKeyPrefix = ((assetName + ",") + gen)
167- $Tuple4(asset, assetId, assetUrl, dataKeyPrefix)
168- }
169-
170-
171-@Callable(i)
172-func purchase (x,y) = {
173- let ownerId = toBase58String(i.caller.bytes)
174- let transactionId = toBase58String(i.transactionId)
175- let $t040944184 = claimSquare(x, y, ownerId, transactionId)
176- let asset = $t040944184._1
177- let assetId = $t040944184._2
178- let assetUrl = $t040944184._3
179- let dataKeyPrefix = $t040944184._4
180-[asset, StringEntry((dataKeyPrefix + "_assetId"), toBase58String(assetId)), StringEntry((dataKeyPrefix + "_asset"), assetUrl), StringEntry((dataKeyPrefix + "_owner"), ownerId), StringEntry(transactionId, dataKeyPrefix), ScriptTransfer(i.caller, 1, assetId)]
181- }
182-
183-
184-
185-@Callable(i)
186-func autoBuy (x,y) = {
187- let ownerId = toBase58String(holdingsAddress.bytes)
188- let transactionId = toBase58String(i.transactionId)
189- let $t046334723 = claimSquare(x, y, ownerId, transactionId)
190- let asset = $t046334723._1
191- let assetId = $t046334723._2
192- let assetUrl = $t046334723._3
193- let dataKeyPrefix = $t046334723._4
194- let assetIdStr = toBase58String(assetId)
195- let res = invoke(holdingsAddress, "addOwnerAndAmount", [ownerId, assetIdStr, "2"], [AttachedPayment(unit, 0)])
196- if ((res == res))
197- then [asset, StringEntry((dataKeyPrefix + "_assetId"), assetIdStr), StringEntry((dataKeyPrefix + "_asset"), assetUrl), StringEntry((dataKeyPrefix + "_owner"), ownerId), StringEntry((("sale_" + assetIdStr) + "_originalOwner"), ownerId), IntegerEntry((("sale_" + assetIdStr) + "_amount"), 2), StringEntry(transactionId, dataKeyPrefix), ScriptTransfer(holdingsAddress, 1, assetId)]
198- else throw("Strict value is not equal to itself.")
199- }
200-
201-
202-
203-@Callable(i)
204-func putForSale (assetId,amount) = {
205- let ownerId = toBase58String(i.caller.bytes)
206- let res = invoke(holdingsAddress, "addOwnerAndAmount", [ownerId, assetId, amount], [AttachedPayment(unit, 0)])
207- if ((res == res))
208- then [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount), ScriptTransfer(holdingsAddress, 1, fromBase58String(assetId))]
209- else throw("Strict value is not equal to itself.")
210- }
211-
212-
213-
214-@Callable(i)
215-func finalizeSale (assetId,ownerId) = {
216- let assetData = match assetInfo(fromBase58String(assetId)) {
217- case ass: Asset =>
218- ass
219- case _ =>
220- throw("Asset not found")
221- }
222- let assetName = assetData.name
223- let xPart = split(assetName, ",")
224- let restPart = split(xPart[1], " ")
225- let x = match xPart[0] {
226- case s: String =>
227- valueOrErrorMessage(parseInt(s), "Could not parse 'x'")
228- case _ =>
229- throw("'x' not found")
230- }
231- let y = match restPart[0] {
232- case s: String =>
233- valueOrErrorMessage(parseInt(s), "Could not parse 'y'")
234- case _ =>
235- throw("'y' not found")
236- }
237- let gen = match restPart[2] {
238- case s: String =>
239- valueOrErrorMessage(parseInt(s), "Could not parse 'gen'")
240- case _ =>
241- throw("'gen' not found")
242- }
243- let xStr = toString(x)
244- let yStr = toString(y)
245- let genStr = toString(gen)
246- let $t065516614 = getXy($Tuple3(x, y, gen), ownerId)
247- let parsedX = $t065516614._1
248- let parsedY = $t065516614._2
249- let parsedGen = $t065516614._3
250- let returnList = nil
251- if ((parsedGen == gen))
252- then {
253- let dataKey = ((((xStr + ",") + yStr) + ",") + genStr)
254- $Tuple2([StringEntry((dataKey + "_owner"), ownerId), StringEntry((("sale_" + assetId) + "_originalOwner"), ""), IntegerEntry((("sale_" + assetId) + "_amount"), 0)], dataKey)
255- }
256- else {
257- let transactionId = toBase58String(i.transactionId)
258- let $t069977100 = claimSquare(xStr, yStr, ownerId, transactionId)
259- let asset = $t069977100._1
260- let evolvedAssetId = $t069977100._2
261- let assetUrl = $t069977100._3
262- let dataKeyPrefix = $t069977100._4
263- let dataKey = dataKeyPrefix
264- $Tuple2([asset, StringEntry((dataKey + "_assetId"), toBase58String(evolvedAssetId)), StringEntry((dataKey + "_asset"), assetUrl), StringEntry((dataKey + "_owner"), ownerId), StringEntry(transactionId, dataKey), ScriptTransfer(Address(fromBase58String(ownerId)), 1, fromBase58String(assetId))], dataKey)
265- }
266- }
267-
56+@Verifier(tx)
57+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
26858
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let COLS = 1024
4+let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r"
55
6-let ROWS = 1024
6+let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY'
77
8-let nftDomain = "https://nft.gridgang.io/"
8+let holdingsAddress = addressFromPublicKey(holdingsPublicKey)
99
10-let DEBUG = true
10+let transferCostPct = 25
1111
12-let holdings = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r"
13-
14-let holdingsAddress = Address(fromBase58String(holdings))
15-
16-func getBoundCoords (data) = {
17- let $t0333355 = data
18- let x = $t0333355._1
19- let y = $t0333355._2
20- let gen = $t0333355._3
21- let d = pow(2, 0, (gen - 1), 0, 0, HALFUP)
22- let tl = $Tuple2((x - d), (y - d))
23- let tc = $Tuple2(x, (y - d))
24- let tr = $Tuple2((x + d), (y + d))
25- let l = $Tuple2((x - d), y)
26- let r = $Tuple2((x + d), y)
27- let bl = $Tuple2((x - d), (y + d))
28- let bc = $Tuple2(x, (y + d))
29- let br = $Tuple2((x + d), (y + d))
30-[$Tuple3(tl, tc, l), $Tuple3(tc, tr, r), $Tuple3(l, bl, bc), $Tuple3(r, bc, br)]
31- }
12+@Callable(i)
13+func addOwnerAndAmount (ownerId,assetId,amount) = [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount)]
3214
3315
34-func checkSquareForEvolve (coords,gen,ownerId) = {
35- let $t0788816 = coords
36- let xy1 = $t0788816._1
37- let xy2 = $t0788816._2
38- let xy3 = $t0788816._3
39- let xy1Key = (((((toString(xy1._1) + ",") + toString(xy1._2)) + ",") + gen) + "_owner")
40- let xy2Key = (((((toString(xy2._1) + ",") + toString(xy2._2)) + ",") + gen) + "_owner")
41- let xy3Key = (((((toString(xy3._1) + ",") + toString(xy3._2)) + ",") + gen) + "_owner")
42- let xyVal1 = match getString(this, xy1Key) {
16+
17+@Callable(i)
18+func buyFromHoldings (assetId) = {
19+ let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) {
4320 case _: Unit =>
4421 "unset"
4522 case x: String =>
4623 x
4724 case _ =>
4825 throw("Match error")
4926 }
50- let xyVal2 = match getString(this, xy2Key) {
27+ let paymentAmount = valueOrElse(i.payments[0].amount, 0)
28+ let amount = match getString(this, (("sale_" + assetId) + "_amount")) {
5129 case _: Unit =>
52- "unset"
30+ 0
5331 case x: String =>
54- x
32+ (valueOrElse(parseInt(x), 0) * 100000000)
5533 case _ =>
5634 throw("Match error")
5735 }
58- let xyVal3 = match getString(this, xy3Key) {
59- case _: Unit =>
60- "unset"
61- case x: String =>
62- x
63- case _ =>
64- throw("Match error")
65- }
66- if (if ((xyVal1 == ownerId))
67- then (xyVal2 == ownerId)
68- else false)
69- then (xyVal3 == ownerId)
70- else false
36+ if ((ownerId == "unset"))
37+ then throw("Original owner not found ")
38+ else if (if ((amount == 0))
39+ then true
40+ else (amount > paymentAmount))
41+ then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount)))
42+ else {
43+ let transfer = [ScriptTransfer(i.caller, 1, fromBase58String(assetId))]
44+ if ((ownerId != holdingsAddressStr))
45+ then {
46+ let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000))
47+ let amountToTransferToOwner = (paymentAmount - amountToRemainInHoldings)
48+ let ownerAddress = Address(fromBase58String(ownerId))
49+ (transfer ++ [ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)])
50+ }
51+ else transfer
52+ }
7153 }
7254
7355
74-func getXyReturn (xy,gen) = {
75- let $t014921507 = xy
76- let x = $t014921507._1
77- let y = $t014921507._2
78- $Tuple3(x, y, (gen + 1))
79- }
80-
81-
82-func getXy (xyg,ownerId) = {
83- let checkList = getBoundCoords(xyg)
84- let $t016231644 = xyg
85- let x = $t016231644._1
86- let y = $t016231644._2
87- let gen = $t016231644._3
88- let genStr = toString(gen)
89- if (checkSquareForEvolve(checkList[0], genStr, ownerId))
90- then getXyReturn(checkList[0]._1, gen)
91- else if (checkSquareForEvolve(checkList[1], genStr, ownerId))
92- then getXyReturn(checkList[1]._1, gen)
93- else if (checkSquareForEvolve(checkList[2], genStr, ownerId))
94- then getXyReturn(checkList[2]._1, gen)
95- else if (checkSquareForEvolve(checkList[3], genStr, ownerId))
96- then getXyReturn(checkList[3]._1, gen)
97- else xyg
98- }
99-
100-
101-func checkForEvolve (xyg,ownerId) = {
102- let $t022912312 = xyg
103- let x = $t022912312._1
104- let y = $t022912312._2
105- let gen = $t022912312._3
106- let p1 = getXy(xyg, ownerId)
107- if ((p1._3 == gen))
108- then p1
109- else {
110- let p2 = getXy(p1, ownerId)
111- if ((p2._3 == p1._3))
112- then p2
113- else {
114- let p3 = getXy(p2, ownerId)
115- if ((p3._3 == p2._3))
116- then p3
117- else {
118- let p4 = getXy(p3, ownerId)
119- if ((p4._3 == p3._3))
120- then p4
121- else {
122- let p5 = getXy(p4, ownerId)
123- if ((p5._3 == p4._3))
124- then p5
125- else {
126- let p6 = getXy(p5, ownerId)
127- if ((p6._3 == p5._3))
128- then p6
129- else {
130- let p7 = getXy(p6, ownerId)
131- if ((p7._3 == p6._3))
132- then p7
133- else {
134- let p8 = getXy(p7, ownerId)
135- if ((p8._3 == p7._3))
136- then p8
137- else {
138- let p9 = getXy(p8, ownerId)
139- if ((p9._3 == p8._3))
140- then p9
141- else getXy(getXy(p9, ownerId), ownerId)
142- }
143- }
144- }
145- }
146- }
147- }
148- }
149- }
150- }
151-
152-
153-func claimSquare (x,y,ownerId,transactionId) = {
154- let $t033653462 = getXy($Tuple3(parseIntValue(x), parseIntValue(y), 1), ownerId)
155- let resolvedX = $t033653462._1
156- let resolvedY = $t033653462._2
157- let resolvedGen = $t033653462._3
158- let resolvedXStr = toString(resolvedX)
159- let resolvedYStr = toString(resolvedY)
160- let resolvedGenStr = toString(resolvedGen)
161- let assetName = ((resolvedXStr + ",") + resolvedYStr)
162- let assetUrl = ((nftDomain + transactionId) + ".png")
163- let asset = Issue(((assetName + " Gen ") + resolvedGenStr), assetUrl, 1, 0, false)
164- let assetId = calculateAssetId(asset)
165- let gen = resolvedGenStr
166- let dataKeyPrefix = ((assetName + ",") + gen)
167- $Tuple4(asset, assetId, assetUrl, dataKeyPrefix)
168- }
169-
170-
171-@Callable(i)
172-func purchase (x,y) = {
173- let ownerId = toBase58String(i.caller.bytes)
174- let transactionId = toBase58String(i.transactionId)
175- let $t040944184 = claimSquare(x, y, ownerId, transactionId)
176- let asset = $t040944184._1
177- let assetId = $t040944184._2
178- let assetUrl = $t040944184._3
179- let dataKeyPrefix = $t040944184._4
180-[asset, StringEntry((dataKeyPrefix + "_assetId"), toBase58String(assetId)), StringEntry((dataKeyPrefix + "_asset"), assetUrl), StringEntry((dataKeyPrefix + "_owner"), ownerId), StringEntry(transactionId, dataKeyPrefix), ScriptTransfer(i.caller, 1, assetId)]
181- }
182-
183-
184-
185-@Callable(i)
186-func autoBuy (x,y) = {
187- let ownerId = toBase58String(holdingsAddress.bytes)
188- let transactionId = toBase58String(i.transactionId)
189- let $t046334723 = claimSquare(x, y, ownerId, transactionId)
190- let asset = $t046334723._1
191- let assetId = $t046334723._2
192- let assetUrl = $t046334723._3
193- let dataKeyPrefix = $t046334723._4
194- let assetIdStr = toBase58String(assetId)
195- let res = invoke(holdingsAddress, "addOwnerAndAmount", [ownerId, assetIdStr, "2"], [AttachedPayment(unit, 0)])
196- if ((res == res))
197- then [asset, StringEntry((dataKeyPrefix + "_assetId"), assetIdStr), StringEntry((dataKeyPrefix + "_asset"), assetUrl), StringEntry((dataKeyPrefix + "_owner"), ownerId), StringEntry((("sale_" + assetIdStr) + "_originalOwner"), ownerId), IntegerEntry((("sale_" + assetIdStr) + "_amount"), 2), StringEntry(transactionId, dataKeyPrefix), ScriptTransfer(holdingsAddress, 1, assetId)]
198- else throw("Strict value is not equal to itself.")
199- }
200-
201-
202-
203-@Callable(i)
204-func putForSale (assetId,amount) = {
205- let ownerId = toBase58String(i.caller.bytes)
206- let res = invoke(holdingsAddress, "addOwnerAndAmount", [ownerId, assetId, amount], [AttachedPayment(unit, 0)])
207- if ((res == res))
208- then [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount), ScriptTransfer(holdingsAddress, 1, fromBase58String(assetId))]
209- else throw("Strict value is not equal to itself.")
210- }
211-
212-
213-
214-@Callable(i)
215-func finalizeSale (assetId,ownerId) = {
216- let assetData = match assetInfo(fromBase58String(assetId)) {
217- case ass: Asset =>
218- ass
219- case _ =>
220- throw("Asset not found")
221- }
222- let assetName = assetData.name
223- let xPart = split(assetName, ",")
224- let restPart = split(xPart[1], " ")
225- let x = match xPart[0] {
226- case s: String =>
227- valueOrErrorMessage(parseInt(s), "Could not parse 'x'")
228- case _ =>
229- throw("'x' not found")
230- }
231- let y = match restPart[0] {
232- case s: String =>
233- valueOrErrorMessage(parseInt(s), "Could not parse 'y'")
234- case _ =>
235- throw("'y' not found")
236- }
237- let gen = match restPart[2] {
238- case s: String =>
239- valueOrErrorMessage(parseInt(s), "Could not parse 'gen'")
240- case _ =>
241- throw("'gen' not found")
242- }
243- let xStr = toString(x)
244- let yStr = toString(y)
245- let genStr = toString(gen)
246- let $t065516614 = getXy($Tuple3(x, y, gen), ownerId)
247- let parsedX = $t065516614._1
248- let parsedY = $t065516614._2
249- let parsedGen = $t065516614._3
250- let returnList = nil
251- if ((parsedGen == gen))
252- then {
253- let dataKey = ((((xStr + ",") + yStr) + ",") + genStr)
254- $Tuple2([StringEntry((dataKey + "_owner"), ownerId), StringEntry((("sale_" + assetId) + "_originalOwner"), ""), IntegerEntry((("sale_" + assetId) + "_amount"), 0)], dataKey)
255- }
256- else {
257- let transactionId = toBase58String(i.transactionId)
258- let $t069977100 = claimSquare(xStr, yStr, ownerId, transactionId)
259- let asset = $t069977100._1
260- let evolvedAssetId = $t069977100._2
261- let assetUrl = $t069977100._3
262- let dataKeyPrefix = $t069977100._4
263- let dataKey = dataKeyPrefix
264- $Tuple2([asset, StringEntry((dataKey + "_assetId"), toBase58String(evolvedAssetId)), StringEntry((dataKey + "_asset"), assetUrl), StringEntry((dataKey + "_owner"), ownerId), StringEntry(transactionId, dataKey), ScriptTransfer(Address(fromBase58String(ownerId)), 1, fromBase58String(assetId))], dataKey)
265- }
266- }
267-
56+@Verifier(tx)
57+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
26858

github/deemru/w8io/169f3d6 
64.84 ms