tx · Hk6M1LK5mbsjVd9jwSDM9kKpxDi4JM2VQUKPmSt3ZcSh 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs: -0.01400000 Waves 2019.08.27 23:33 [650083] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves
{ "type": 13, "id": "Hk6M1LK5mbsjVd9jwSDM9kKpxDi4JM2VQUKPmSt3ZcSh", "fee": 1400000, "feeAssetId": null, "timestamp": 1566937975710, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "4q2SY53UsVMFtVcrLuFpM1b6MJ5eKzyuU9FwekWhRGjguXrvcGG876AXQGy4LV1czAJsM4ixFUxjkLnyzR5r41RA" ], "script": "base64:AAIDAAAAAAAAAAAAAAAQAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAAClRva2VuUHJpY2UAAAAAAAAAAAoAAAAAEERPTkFURUNPVU5URVJLRVkCAAAACyRET05BVEVfTlVNAAAAAAdCVVlJVEVNAgAAAAkkQlVZX0lURU0AAAAABEJhZzEJAABoAAAAAgAAAAAAAAAAAQUAAAAHV0FWRUxFVAAAAAAEQmFnNQkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAVCYWcxMAkAAGgAAAACAAAAAAAAAAAKBQAAAAdXQVZFTEVUAAAAAAVCYWcyMAkAAGgAAAACAAAAAAAAAAAUBQAAAAdXQVZFTEVUAAAAAAVCYWc1MAkAAGgAAAACAAAAAAAAAAAyBQAAAAdXQVZFTEVUAAAAAAZCYWcxMDAJAABoAAAAAgAAAAAAAA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AIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAN0dHgFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAADc3R4BQAAAAckbWF0Y2gwBgcHQIGsjQ==", "chainId": 84, "height": 650083, "spentComplexity": 0 } View: original | compacted Prev: 8qagVzc1B8M6tZFeprCTi3RmQRWcWX9qMGCrDBhibCvz Next: 4qmcCnWVMZvQTufm9pyJ9wWEfX87qxT3TYMtsNQWSAMN Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | case int: Int => | |
71 | 71 | toString(int) | |
72 | 72 | case _ => | |
73 | - | "" | |
73 | + | "found" | |
74 | 74 | } | |
75 | 75 | rawDataStr | |
76 | 76 | } | |
85 | 85 | let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus) | |
86 | 86 | let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance) | |
87 | 87 | let oldItemsList = ExtractItemsList(key2Items) | |
88 | - | throw(oldItemsList) | |
88 | + | let searchResult = isItemExist(oldItemsList, itemId) | |
89 | + | if ((searchResult == "")) | |
90 | + | then throw("This item not exist") | |
91 | + | else throw(searchResult) | |
89 | 92 | } | |
90 | 93 | ||
91 | 94 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let WAVELET = ((100 * 1000) * 1000) | |
5 | 5 | ||
6 | 6 | let COMMISSION = ((5 * WAVELET) / 1000) | |
7 | 7 | ||
8 | 8 | let TokenPrice = 10 | |
9 | 9 | ||
10 | 10 | let DONATECOUNTERKEY = "$DONATE_NUM" | |
11 | 11 | ||
12 | 12 | let BUYITEM = "$BUY_ITEM" | |
13 | 13 | ||
14 | 14 | let Bag1 = (1 * WAVELET) | |
15 | 15 | ||
16 | 16 | let Bag5 = (5 * WAVELET) | |
17 | 17 | ||
18 | 18 | let Bag10 = (10 * WAVELET) | |
19 | 19 | ||
20 | 20 | let Bag20 = (20 * WAVELET) | |
21 | 21 | ||
22 | 22 | let Bag50 = (50 * WAVELET) | |
23 | 23 | ||
24 | 24 | let Bag100 = (100 * WAVELET) | |
25 | 25 | ||
26 | 26 | func IncrementDonateNum () = { | |
27 | 27 | let gameNum = match getInteger(this, DONATECOUNTERKEY) { | |
28 | 28 | case num: Int => | |
29 | 29 | num | |
30 | 30 | case _ => | |
31 | 31 | 0 | |
32 | 32 | } | |
33 | 33 | (gameNum + 1) | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getBalance (key) = { | |
38 | 38 | let playerBalanceNum = match getInteger(this, key) { | |
39 | 39 | case playerBalanceNum: Int => | |
40 | 40 | playerBalanceNum | |
41 | 41 | case _ => | |
42 | 42 | 0 | |
43 | 43 | } | |
44 | 44 | playerBalanceNum | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func ExtractItemsList (key) = { | |
49 | 49 | let rawDataStr = match getString(this, key) { | |
50 | 50 | case str: String => | |
51 | 51 | str | |
52 | 52 | case _ => | |
53 | 53 | "" | |
54 | 54 | } | |
55 | 55 | rawDataStr | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func getPriceByItemID (itemId) = if ((itemId == "1")) | |
60 | 60 | then 1 | |
61 | 61 | else if ((itemId == "2")) | |
62 | 62 | then 4 | |
63 | 63 | else if ((itemId == "3")) | |
64 | 64 | then 6 | |
65 | 65 | else throw("Неверный ID item") | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func isItemExist (oldItemsList,itemId) = { | |
69 | 69 | let rawDataStr = match indexOf(oldItemsList, (itemId + ":")) { | |
70 | 70 | case int: Int => | |
71 | 71 | toString(int) | |
72 | 72 | case _ => | |
73 | - | "" | |
73 | + | "found" | |
74 | 74 | } | |
75 | 75 | rawDataStr | |
76 | 76 | } | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | @Callable(i) | |
80 | 80 | func buy (itemId) = { | |
81 | 81 | let buyTXId = toBase58String(i.transactionId) | |
82 | 82 | let playerAddress = toString(i.caller) | |
83 | 83 | let key2Items = (playerAddress + "_items") | |
84 | 84 | let balanceMinus = getPriceByItemID(itemId) | |
85 | 85 | let NewBalance = (getBalance((playerAddress + "_balance")) - balanceMinus) | |
86 | 86 | let newBalanceData = DataEntry((playerAddress + "_balance"), NewBalance) | |
87 | 87 | let oldItemsList = ExtractItemsList(key2Items) | |
88 | - | throw(oldItemsList) | |
88 | + | let searchResult = isItemExist(oldItemsList, itemId) | |
89 | + | if ((searchResult == "")) | |
90 | + | then throw("This item not exist") | |
91 | + | else throw(searchResult) | |
89 | 92 | } | |
90 | 93 | ||
91 | 94 | ||
92 | 95 | ||
93 | 96 | @Callable(i) | |
94 | 97 | func reset () = { | |
95 | 98 | let playerAddress = toString(i.caller) | |
96 | 99 | let donateData = [DataEntry(DONATECOUNTERKEY, 0), DataEntry((playerAddress + "_balance"), 0)] | |
97 | 100 | WriteSet(donateData) | |
98 | 101 | } | |
99 | 102 | ||
100 | 103 | ||
101 | 104 | ||
102 | 105 | @Callable(i) | |
103 | 106 | func donate () = { | |
104 | 107 | let newGameNum = IncrementDonateNum() | |
105 | 108 | let donateId = toBase58String(i.transactionId) | |
106 | 109 | let pmt = extract(i.payment) | |
107 | 110 | let playerAddress = toString(i.caller) | |
108 | 111 | let betNotInWaves = isDefined(pmt.assetId) | |
109 | 112 | let feeNotInWaves = isDefined(pmt.assetId) | |
110 | 113 | let donateAmt = pmt.amount | |
111 | 114 | if (betNotInWaves) | |
112 | 115 | then throw("Bet amount must be in Waves") | |
113 | 116 | else if (feeNotInWaves) | |
114 | 117 | then throw("Transaction's fee must be in Waves") | |
115 | 118 | else { | |
116 | 119 | let donateAmtValid = if (if (if (if (if (if ((donateAmt == (Bag1 + COMMISSION))) | |
117 | 120 | then true | |
118 | 121 | else (donateAmt == (Bag5 + COMMISSION))) | |
119 | 122 | then true | |
120 | 123 | else (donateAmt == (Bag10 + COMMISSION))) | |
121 | 124 | then true | |
122 | 125 | else (donateAmt == (Bag20 + COMMISSION))) | |
123 | 126 | then true | |
124 | 127 | else (donateAmt == (Bag50 + COMMISSION))) | |
125 | 128 | then true | |
126 | 129 | else (donateAmt == (Bag100 + COMMISSION))) | |
127 | 130 | then true | |
128 | 131 | else false | |
129 | 132 | if (donateAmtValid) | |
130 | 133 | then { | |
131 | 134 | let donateNum = ((donateAmt - COMMISSION) / WAVELET) | |
132 | 135 | let key2Balance = (playerAddress + "_balance") | |
133 | 136 | let newBalance = (getBalance(key2Balance) + (donateNum * TokenPrice)) | |
134 | 137 | let donateData = [DataEntry(DONATECOUNTERKEY, newGameNum), DataEntry(key2Balance, newBalance), DataEntry(donateId, donateNum)] | |
135 | 138 | WriteSet(donateData) | |
136 | 139 | } | |
137 | 140 | else throw("You paid the wrong amount") | |
138 | 141 | } | |
139 | 142 | } | |
140 | 143 | ||
141 | 144 | ||
142 | 145 | @Verifier(tx) | |
143 | 146 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
144 | 147 | then match tx { | |
145 | 148 | case ttx: TransferTransaction => | |
146 | 149 | true | |
147 | 150 | case stx: SetScriptTransaction => | |
148 | 151 | true | |
149 | 152 | case _ => | |
150 | 153 | false | |
151 | 154 | } | |
152 | 155 | else false | |
153 | 156 |
github/deemru/w8io/026f985 145.58 ms ◑