tx · 2DVNQpK7Ca1SGqhDddLFdKAe5cLYazUwyTt6iKzUKxe3

3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV:  -0.01000000 Waves

2021.12.08 18:40 [1825466] smart account 3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV > SELF 0.00000000 Waves

{ "type": 13, "id": "2DVNQpK7Ca1SGqhDddLFdKAe5cLYazUwyTt6iKzUKxe3", "fee": 1000000, "feeAssetId": null, "timestamp": 1638978109968, "version": 2, "chainId": 84, "sender": "3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV", "senderPublicKey": "5amLtMwixiEesBDKPy9dkFWntG2fNxhTs5n69JbQE9F7", "proofs": [ "2YwZnYNs4k7B6Qcn5zkXktLnJsHQNpaDZPco8hU9UKcvzyuo3knGgGNdMWZsEaQF41i3tXVPpnti2SFNWxFb7Xrf" ], "script": "base64:AAIFAAAAAAAAABMIAhIAEgMKAQgSAwoBCBIDCgEIAAAAAQAAAAAFc2VwYXICAAAAAXwAAAAEAAAAAWkBAAAABXJlc2V0AAAAAAkABRQAAAACCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAACmxhc3RnYW1laWQCAAAAATAFAAAAA25pbAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACAgAAAA1sYXN0Y2hhbGxlbmdlAgAAAAEwBQAAAANuaWwAAAABaQEAAAAJc3RhcnRnYW1lAAAAAQAAAApjaGFsbGVuZ2VyBAAAAANwbXQDCQAAAAAAAAIJAAGQAAAAAQgFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAEJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAJAAACAAAAAQIAAAAVbXVzdCBzdGFrZSBzb21lIHdhdmVzAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAkAAAIAAAABAgAAABV3b3JrcyB3aXRoIHdhdmVzIG9ubHkEAAAADGNhbGxlck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JAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAAAAgAAAAhhd2FpdGluZwkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAICAAAACmNoYWxsZW5nZS0FAAAADGNoYWxsZW5kZ2VpZAkABLkAAAACCQAETAAAAAICAAAABXVuc2V0CQAETAAAAAIJAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAABCQAETAAAAAIJAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAACCQAETAAAAAIJAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAADBQAAAANuaWwFAAAABXNlcGFyBQAAAANuaWwJAAACAAAAAQIAAAAUY2hhbGxlbmdlIG5vdCBleGlzdHMJAAACAAAAAQIAAAAUY2hhbGxlbmdlIG5vdCBleGlzdHMAAAAAD7YA3Q==", "height": 1825466, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 97rfNZydsLbvHeat7BUXFAB6XyGvw5mXvWZy78mxr7uU Next: DE5oQ2ypNrW6Nz2Lq7NSu5qPU6kFvbEfaxrEANvC3rDq Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separ = "|"
5+
6+@Callable(i)
7+func reset () = $Tuple2([StringEntry("lastgameid", "0")], [StringEntry("lastchallenge", "0")])
8+
9+
510
611 @Callable(i)
712 func startgame (challenger) = {
2328 let white = if ((conditions[1] == "white"))
2429 then challenger
2530 else callerAdress
26- let gameid = match getInteger("lastgameid") {
27- case a: Int =>
28- getIntegerValue("lastgameid")
29- case _ =>
30- 1
31- }
32-[StringEntry(("challenge-" + challenger), makeString(["answered", conditions[1], conditions[2], callerAdress], separ)), StringEntry(("game-" + toString(gameid)), makeString(["ongoing", white, black, conditions[2], "0", "white", "startblock", "laststepblock"], separ)), ScriptTransfer(i.caller, (pmt.amount - parseIntValue(conditions[2])), unit)]
31+ let gameid = toString((getIntegerValue("lastgameid") + 1))
32+[StringEntry(("challenge-" + challenger), makeString(["answered", conditions[1], conditions[2], callerAdress], separ)), StringEntry(gameid, makeString(["ongoing", white, black, conditions[2], "0", "white", "startblock", "laststepblock"], separ)), StringEntry("lastgameid", gameid), ScriptTransfer(i.caller, (pmt.amount - parseIntValue(conditions[2])), unit)]
3333 }
3434 else throw("no challenge awaiting")
3535 else throw("need more money")
5151 then throw("works with waves only")
5252 else {
5353 let callerAdress = toBase58String(i.caller.bytes)
54-[StringEntry(("challenge-" + callerAdress), makeString(["awaiting", side, toString(pmt.amount)], separ))]
54+ let challengeid = toString((getIntegerValue("lastchallengeid") + 1))
55+[StringEntry(("challenge-" + challengeid), makeString(["awaiting", callerAdress, side, toString(pmt.amount)], separ))]
5556 }
5657 }
5758 else throw("invalid side")
5960
6061
6162 @Callable(i)
62-func unsetchallenge () = {
63+func unsetchallenge (challendgeid) = {
6364 let callerAdress = toBase58String(i.caller.bytes)
64- func getchallenge (challendger) = match getString(("challenge-" + challendger)) {
65+ func getchallenge (challendgeid) = match getString(("challenge-" + challendgeid)) {
6566 case a: String =>
66- getStringValue(("challenge-" + challendger))
67+ getStringValue(("challenge-" + challendgeid))
6768 case _ =>
6869 ""
6970 }
7071
71- let challenge = split(getchallenge(callerAdress), separ)
72+ let challenge = split(getchallenge(challendgeid), separ)
7273 if ((size(challenge) > 0))
7374 then if ((challenge[0] == "awaiting"))
74- then [StringEntry(("challenge-" + callerAdress), makeString(["unset", challenge[1], challenge[2]], separ))]
75+ then [StringEntry(("challenge-" + challendgeid), makeString(["unset", challenge[1], challenge[2], challenge[3]], separ))]
7576 else throw("challenge not exists")
7677 else throw("challenge not exists")
7778 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separ = "|"
5+
6+@Callable(i)
7+func reset () = $Tuple2([StringEntry("lastgameid", "0")], [StringEntry("lastchallenge", "0")])
8+
9+
510
611 @Callable(i)
712 func startgame (challenger) = {
813 let pmt = if ((size(i.payments) == 1))
914 then i.payments[0]
1015 else throw("must stake some waves")
1116 if (isDefined(pmt.assetId))
1217 then throw("works with waves only")
1318 else {
1419 let callerAdress = toBase58String(i.caller.bytes)
1520 let conditions = split(getStringValue(("challenge-" + challenger)), separ)
1621 if ((size(conditions) > 0))
1722 then if ((pmt.amount >= parseIntValue(conditions[2])))
1823 then if ((conditions[0] == "awaiting"))
1924 then {
2025 let black = if ((conditions[1] == "black"))
2126 then challenger
2227 else callerAdress
2328 let white = if ((conditions[1] == "white"))
2429 then challenger
2530 else callerAdress
26- let gameid = match getInteger("lastgameid") {
27- case a: Int =>
28- getIntegerValue("lastgameid")
29- case _ =>
30- 1
31- }
32-[StringEntry(("challenge-" + challenger), makeString(["answered", conditions[1], conditions[2], callerAdress], separ)), StringEntry(("game-" + toString(gameid)), makeString(["ongoing", white, black, conditions[2], "0", "white", "startblock", "laststepblock"], separ)), ScriptTransfer(i.caller, (pmt.amount - parseIntValue(conditions[2])), unit)]
31+ let gameid = toString((getIntegerValue("lastgameid") + 1))
32+[StringEntry(("challenge-" + challenger), makeString(["answered", conditions[1], conditions[2], callerAdress], separ)), StringEntry(gameid, makeString(["ongoing", white, black, conditions[2], "0", "white", "startblock", "laststepblock"], separ)), StringEntry("lastgameid", gameid), ScriptTransfer(i.caller, (pmt.amount - parseIntValue(conditions[2])), unit)]
3333 }
3434 else throw("no challenge awaiting")
3535 else throw("need more money")
3636 else throw("no challenge")
3737 }
3838 }
3939
4040
4141
4242 @Callable(i)
4343 func setchallenge (side) = if (if ((side == "black"))
4444 then true
4545 else (side == "white"))
4646 then {
4747 let pmt = if ((size(i.payments) == 1))
4848 then i.payments[0]
4949 else throw("must stake some waves")
5050 if (isDefined(pmt.assetId))
5151 then throw("works with waves only")
5252 else {
5353 let callerAdress = toBase58String(i.caller.bytes)
54-[StringEntry(("challenge-" + callerAdress), makeString(["awaiting", side, toString(pmt.amount)], separ))]
54+ let challengeid = toString((getIntegerValue("lastchallengeid") + 1))
55+[StringEntry(("challenge-" + challengeid), makeString(["awaiting", callerAdress, side, toString(pmt.amount)], separ))]
5556 }
5657 }
5758 else throw("invalid side")
5859
5960
6061
6162 @Callable(i)
62-func unsetchallenge () = {
63+func unsetchallenge (challendgeid) = {
6364 let callerAdress = toBase58String(i.caller.bytes)
64- func getchallenge (challendger) = match getString(("challenge-" + challendger)) {
65+ func getchallenge (challendgeid) = match getString(("challenge-" + challendgeid)) {
6566 case a: String =>
66- getStringValue(("challenge-" + challendger))
67+ getStringValue(("challenge-" + challendgeid))
6768 case _ =>
6869 ""
6970 }
7071
71- let challenge = split(getchallenge(callerAdress), separ)
72+ let challenge = split(getchallenge(challendgeid), separ)
7273 if ((size(challenge) > 0))
7374 then if ((challenge[0] == "awaiting"))
74- then [StringEntry(("challenge-" + callerAdress), makeString(["unset", challenge[1], challenge[2]], separ))]
75+ then [StringEntry(("challenge-" + challendgeid), makeString(["unset", challenge[1], challenge[2], challenge[3]], separ))]
7576 else throw("challenge not exists")
7677 else throw("challenge not exists")
7778 }
7879
7980

github/deemru/w8io/026f985 
26.84 ms