tx · 9GZX2QiM9Rquy8zeDhB7QBTauQwHsrg75JsTVp2MUjGQ 3NCUy4yewhhgobHrkdSBNiCYajzXApktxaK: -0.04000000 Waves 2019.09.24 12:37 [690250] smart account 3NCUy4yewhhgobHrkdSBNiCYajzXApktxaK > SELF 0.00000000 Waves
{ "type": 13, "id": "9GZX2QiM9Rquy8zeDhB7QBTauQwHsrg75JsTVp2MUjGQ", "fee": 4000000, "feeAssetId": null, "timestamp": 1569317756742, "version": 1, "sender": "3NCUy4yewhhgobHrkdSBNiCYajzXApktxaK", "senderPublicKey": "AEBLjt3LBirAMqq8TDdsSedvidamCEi6fV1nhL2DEpew", "proofs": [ "TeR6oAsX37ViMihtog46MFkiZjdwejN87FuyJfAKHtZFJn2Ho7VmvxHXL9ZTW3mUgvzpYhEcme5zjtwicPtvcPo" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA5vd25lclB1YmxpY0tleQEAAAAgkD7fCqmCHKVfL8+fGFXRYhqUJqS1aPUU7D38lld+FgAAAAAAH2Rlc3RpbmF0aW9uV2FsbGV0QWRkcmVzc0RhdGFLZXkCAAAAGmRlc3RpbmF0aW9uX3dhbGxldF9hZGRyZXNzAQAAABFnZXRMb290Qm94RGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgIAAAAJbG9vdF9ib3hfBQAAAAJpZAEAAAAWZ2V0TG9vdEJveFByaWNlRGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgkBAAAAEWdldExvb3RCb3hEYXRhS2V5AAAAAQUAAAACaWQCAAAABl9wcmljZQEAAAAWZ2V0TG9vdEJveExpbWl0RGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgkBAAAAEWdldExvb3RCb3hEYXRhS2V5AAAAAQUAAAACaWQCAAAABl9saW1pdAEAAAAZZ2V0TG9vdEJveEJ1eUNvdW50RGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgkBAAAAEWdldExvb3RCb3hEYXRhS2V5AAAAAQUAAAACaWQCAAAACl9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ltaXQCAAAAISBpdGVtcyBkdWUgbGltaXQsIGN1cnJlbnQgY291bnQ6IAkAAaQAAAABBQAAAAhidXlDb3VudAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABlnZXRMb290Qm94QnV5Q291bnREYXRhS2V5AAAAAQUAAAAFaWRTdHIFAAAAC25ld0J1eUNvdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAG2dldERlc3RpbmF0aW9uV2FsbGV0QWRkcmVzcwAAAAAFAAAADHBsYXllclBheVN1bQUAAAAEdW5pdAUAAAADbmlsAAAAADtayXE=", "chainId": 84, "height": 690250, "spentComplexity": 0 } View: original | compacted Prev: 3qomQQsHPbsF4SY7KxySSVT4iwvH8S8MFeHFGsEKzxSs Next: none Diff:
Old | New | Differences | |
---|---|---|---|
81 | 81 | let idStr = toString(id) | |
82 | 82 | let payment = extract(i.payment) | |
83 | 83 | if (isDefined(payment.assetId)) | |
84 | - | then throw("Can | |
84 | + | then throw("Can hold waves only at the moment") | |
85 | 85 | else { | |
86 | 86 | let buyCount = getLootBoxBuyCount(idStr) | |
87 | 87 | let newBuyCount = (buyCount + 1) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'Ai5K72PXnQpuH5CCLZcpZWSPGyvSmuBY9PHhFEQStzX9' | |
5 | 5 | ||
6 | 6 | let destinationWalletAddressDataKey = "destination_wallet_address" | |
7 | 7 | ||
8 | 8 | func getLootBoxDataKey (id) = ("loot_box_" + id) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func getLootBoxPriceDataKey (id) = (getLootBoxDataKey(id) + "_price") | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func getLootBoxLimitDataKey (id) = (getLootBoxDataKey(id) + "_limit") | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getLootBoxBuyCountDataKey (id) = (getLootBoxDataKey(id) + "_buy_count") | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getDestinationWalletAddress () = match getString(this, destinationWalletAddressDataKey) { | |
21 | 21 | case v: String => | |
22 | 22 | if ((v == "")) | |
23 | 23 | then throw("Destination wallet address cannot be empty") | |
24 | 24 | else addressFromStringValue(v) | |
25 | 25 | case _ => | |
26 | 26 | throw("Destination wallet address undefined") | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getLootBoxPrice (id) = match getInteger(this, getLootBoxPriceDataKey(id)) { | |
31 | 31 | case v: Int => | |
32 | 32 | v | |
33 | 33 | case _ => | |
34 | 34 | throw("Loot box price undefined") | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func getLootBoxLimit (id) = match getInteger(this, getLootBoxLimitDataKey(id)) { | |
39 | 39 | case v: Int => | |
40 | 40 | v | |
41 | 41 | case _ => | |
42 | 42 | throw("Loot box limit undefined") | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getLootBoxBuyCount (id) = match getInteger(this, getLootBoxBuyCountDataKey(id)) { | |
47 | 47 | case v: Int => | |
48 | 48 | v | |
49 | 49 | case _ => | |
50 | 50 | 0 | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | @Callable(i) | |
55 | 55 | func setDestinationWallet (address) = if ((i.callerPublicKey != ownerPublicKey)) | |
56 | 56 | then throw("Only owner can call this method") | |
57 | 57 | else if ((address == "")) | |
58 | 58 | then throw("Address cannot be empty") | |
59 | 59 | else WriteSet([DataEntry(destinationWalletAddressDataKey, address)]) | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | ||
63 | 63 | @Callable(i) | |
64 | 64 | func setLootBoxInfo (id,price,limit) = if ((i.callerPublicKey != ownerPublicKey)) | |
65 | 65 | then throw("Only owner can call this method") | |
66 | 66 | else if ((id == 0)) | |
67 | 67 | then throw("Loot id undefined") | |
68 | 68 | else if ((price == 0)) | |
69 | 69 | then throw("Price undefined") | |
70 | 70 | else if ((limit == 0)) | |
71 | 71 | then throw("Limit undefined") | |
72 | 72 | else { | |
73 | 73 | let idStr = toString(id) | |
74 | 74 | WriteSet([DataEntry(getLootBoxPriceDataKey(idStr), price), DataEntry(getLootBoxLimitDataKey(idStr), limit)]) | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | ||
79 | 79 | @Callable(i) | |
80 | 80 | func buyLootBox (id) = { | |
81 | 81 | let idStr = toString(id) | |
82 | 82 | let payment = extract(i.payment) | |
83 | 83 | if (isDefined(payment.assetId)) | |
84 | - | then throw("Can | |
84 | + | then throw("Can hold waves only at the moment") | |
85 | 85 | else { | |
86 | 86 | let buyCount = getLootBoxBuyCount(idStr) | |
87 | 87 | let newBuyCount = (buyCount + 1) | |
88 | 88 | let lootBoxLimit = getLootBoxLimit(idStr) | |
89 | 89 | let lootBoxPrice = getLootBoxPrice(idStr) | |
90 | 90 | let playerPaySum = payment.amount | |
91 | 91 | if ((playerPaySum != lootBoxPrice)) | |
92 | 92 | then throw(((("Price must be equal " + toString(lootBoxPrice)) + " wavelets, given: ") + toString(playerPaySum))) | |
93 | 93 | else if ((newBuyCount > lootBoxLimit)) | |
94 | 94 | then throw(((("Cannot sale more " + toString(lootBoxLimit)) + " items due limit, current count: ") + toString(buyCount))) | |
95 | 95 | else ScriptResult(WriteSet([DataEntry(getLootBoxBuyCountDataKey(idStr), newBuyCount)]), TransferSet([ScriptTransfer(getDestinationWalletAddress(), playerPaySum, unit)])) | |
96 | 96 | } | |
97 | 97 | } | |
98 | 98 | ||
99 | 99 |
github/deemru/w8io/169f3d6 38.79 ms ◑