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:AAIFAAAAAAAAABMIAhIAEgMKAQgSAwoBCBIDCgEIAAAAAQAAAAAFc2VwYXICAAAAAXwAAAAEAAAAAWkBAAAABXJlc2V0AAAAAAkABRQAAAACCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAACmxhc3RnYW1laWQCAAAAATAFAAAAA25pbAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACAgAAAA1sYXN0Y2hhbGxlbmdlAgAAAAEwBQAAAANuaWwAAAABaQEAAAAJc3RhcnRnYW1lAAAAAQAAAApjaGFsbGVuZ2VyBAAAAANwbXQDCQAAAAAAAAIJAAGQAAAAAQgFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAEJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAJAAACAAAAAQIAAAAVbXVzdCBzdGFrZSBzb21lIHdhdmVzAwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAkAAAIAAAABAgAAABV3b3JrcyB3aXRoIHdhdmVzIG9ubHkEAAAADGNhbGxlckF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AAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAAAAgAAAAhhd2FpdGluZwkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAICAAAACmNoYWxsZW5nZS0FAAAADGNoYWxsZW5kZ2VpZAkABLkAAAACCQAETAAAAAICAAAABXVuc2V0CQAETAAAAAIJAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAABCQAETAAAAAIJAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAACCQAETAAAAAIJAAGRAAAAAgUAAAAJY2hhbGxlbmdlAAAAAAAAAAADBQAAAANuaWwFAAAABXNlcGFyBQAAAANuaWwJAAACAAAAAQIAAAAUY2hhbGxlbmdlIG5vdCBleGlzdHMJAAACAAAAAQIAAAAUY2hhbGxlbmdlIG5vdCBleGlzdHMAAAAAD7YA3Q==", "height": 1825466, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 97rfNZydsLbvHeat7BUXFAB6XyGvw5mXvWZy78mxr7uU Next: DE5oQ2ypNrW6Nz2Lq7NSu5qPU6kFvbEfaxrEANvC3rDq Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separ = "|" | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func reset () = $Tuple2([StringEntry("lastgameid", "0")], [StringEntry("lastchallenge", "0")]) | |
8 | + | ||
9 | + | ||
5 | 10 | ||
6 | 11 | @Callable(i) | |
7 | 12 | func startgame (challenger) = { | |
23 | 28 | let white = if ((conditions[1] == "white")) | |
24 | 29 | then challenger | |
25 | 30 | 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)] | |
33 | 33 | } | |
34 | 34 | else throw("no challenge awaiting") | |
35 | 35 | else throw("need more money") | |
51 | 51 | then throw("works with waves only") | |
52 | 52 | else { | |
53 | 53 | 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))] | |
55 | 56 | } | |
56 | 57 | } | |
57 | 58 | else throw("invalid side") | |
59 | 60 | ||
60 | 61 | ||
61 | 62 | @Callable(i) | |
62 | - | func unsetchallenge () = { | |
63 | + | func unsetchallenge (challendgeid) = { | |
63 | 64 | let callerAdress = toBase58String(i.caller.bytes) | |
64 | - | func getchallenge ( | |
65 | + | func getchallenge (challendgeid) = match getString(("challenge-" + challendgeid)) { | |
65 | 66 | case a: String => | |
66 | - | getStringValue(("challenge-" + | |
67 | + | getStringValue(("challenge-" + challendgeid)) | |
67 | 68 | case _ => | |
68 | 69 | "" | |
69 | 70 | } | |
70 | 71 | ||
71 | - | let challenge = split(getchallenge( | |
72 | + | let challenge = split(getchallenge(challendgeid), separ) | |
72 | 73 | if ((size(challenge) > 0)) | |
73 | 74 | then if ((challenge[0] == "awaiting")) | |
74 | - | then [StringEntry(("challenge-" + | |
75 | + | then [StringEntry(("challenge-" + challendgeid), makeString(["unset", challenge[1], challenge[2], challenge[3]], separ))] | |
75 | 76 | else throw("challenge not exists") | |
76 | 77 | else throw("challenge not exists") | |
77 | 78 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separ = "|" | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func reset () = $Tuple2([StringEntry("lastgameid", "0")], [StringEntry("lastchallenge", "0")]) | |
8 | + | ||
9 | + | ||
5 | 10 | ||
6 | 11 | @Callable(i) | |
7 | 12 | func startgame (challenger) = { | |
8 | 13 | let pmt = if ((size(i.payments) == 1)) | |
9 | 14 | then i.payments[0] | |
10 | 15 | else throw("must stake some waves") | |
11 | 16 | if (isDefined(pmt.assetId)) | |
12 | 17 | then throw("works with waves only") | |
13 | 18 | else { | |
14 | 19 | let callerAdress = toBase58String(i.caller.bytes) | |
15 | 20 | let conditions = split(getStringValue(("challenge-" + challenger)), separ) | |
16 | 21 | if ((size(conditions) > 0)) | |
17 | 22 | then if ((pmt.amount >= parseIntValue(conditions[2]))) | |
18 | 23 | then if ((conditions[0] == "awaiting")) | |
19 | 24 | then { | |
20 | 25 | let black = if ((conditions[1] == "black")) | |
21 | 26 | then challenger | |
22 | 27 | else callerAdress | |
23 | 28 | let white = if ((conditions[1] == "white")) | |
24 | 29 | then challenger | |
25 | 30 | 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)] | |
33 | 33 | } | |
34 | 34 | else throw("no challenge awaiting") | |
35 | 35 | else throw("need more money") | |
36 | 36 | else throw("no challenge") | |
37 | 37 | } | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | 42 | @Callable(i) | |
43 | 43 | func setchallenge (side) = if (if ((side == "black")) | |
44 | 44 | then true | |
45 | 45 | else (side == "white")) | |
46 | 46 | then { | |
47 | 47 | let pmt = if ((size(i.payments) == 1)) | |
48 | 48 | then i.payments[0] | |
49 | 49 | else throw("must stake some waves") | |
50 | 50 | if (isDefined(pmt.assetId)) | |
51 | 51 | then throw("works with waves only") | |
52 | 52 | else { | |
53 | 53 | 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))] | |
55 | 56 | } | |
56 | 57 | } | |
57 | 58 | else throw("invalid side") | |
58 | 59 | ||
59 | 60 | ||
60 | 61 | ||
61 | 62 | @Callable(i) | |
62 | - | func unsetchallenge () = { | |
63 | + | func unsetchallenge (challendgeid) = { | |
63 | 64 | let callerAdress = toBase58String(i.caller.bytes) | |
64 | - | func getchallenge ( | |
65 | + | func getchallenge (challendgeid) = match getString(("challenge-" + challendgeid)) { | |
65 | 66 | case a: String => | |
66 | - | getStringValue(("challenge-" + | |
67 | + | getStringValue(("challenge-" + challendgeid)) | |
67 | 68 | case _ => | |
68 | 69 | "" | |
69 | 70 | } | |
70 | 71 | ||
71 | - | let challenge = split(getchallenge( | |
72 | + | let challenge = split(getchallenge(challendgeid), separ) | |
72 | 73 | if ((size(challenge) > 0)) | |
73 | 74 | then if ((challenge[0] == "awaiting")) | |
74 | - | then [StringEntry(("challenge-" + | |
75 | + | then [StringEntry(("challenge-" + challendgeid), makeString(["unset", challenge[1], challenge[2], challenge[3]], separ))] | |
75 | 76 | else throw("challenge not exists") | |
76 | 77 | else throw("challenge not exists") | |
77 | 78 | } | |
78 | 79 | ||
79 | 80 |
github/deemru/w8io/026f985 26.84 ms ◑