tx · 3qomQQsHPbsF4SY7KxySSVT4iwvH8S8MFeHFGsEKzxSs

3NCUy4yewhhgobHrkdSBNiCYajzXApktxaK:  -0.04000000 Waves

2019.09.24 12:31 [690244] smart account 3NCUy4yewhhgobHrkdSBNiCYajzXApktxaK > SELF 0.00000000 Waves

{ "type": 13, "id": "3qomQQsHPbsF4SY7KxySSVT4iwvH8S8MFeHFGsEKzxSs", "fee": 4000000, "feeAssetId": null, "timestamp": 1569317451407, "version": 1, "sender": "3NCUy4yewhhgobHrkdSBNiCYajzXApktxaK", "senderPublicKey": "AEBLjt3LBirAMqq8TDdsSedvidamCEi6fV1nhL2DEpew", "proofs": [ "4AA4jisyCcRwdtaXDq8RBc2b1cDcrzn7aKNHspVWJVRg6hy67cGLzyzS7mZCDNSDTdJL2mxyoUF35rSHToCGpk8y" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA5vd25lclB1YmxpY0tleQEAAAAgkD7fCqmCHKVfL8+fGFXRYhqUJqS1aPUU7D38lld+FgAAAAAAH2Rlc3RpbmF0aW9uV2FsbGV0QWRkcmVzc0RhdGFLZXkCAAAAGmRlc3RpbmF0aW9uX3dhbGxldF9hZGRyZXNzAQAAABFnZXRMb290Qm94RGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgIAAAAJbG9vdF9ib3hfBQAAAAJpZAEAAAAWZ2V0TG9vdEJveFByaWNlRGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgkBAAAAEWdldExvb3RCb3hEYXRhS2V5AAAAAQUAAAACaWQCAAAABl9wcmljZQEAAAAWZ2V0TG9vdEJveExpbWl0RGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgkBAAAAEWdldExvb3RCb3hEYXRhS2V5AAAAAQUAAAACaWQCAAAABl9saW1pdAEAAAAZZ2V0TG9vdEJveEJ1eUNvdW50RGF0YUtleQAAAAEAAAACaWQJAAEsAAAAAgkBAAAAEWdldExvb3RCb3hEYXRhS2V5AAAAAQUAAAACaWQCAAAACl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GltaXQCAAAAISBpdGVtcyBkdWUgbGltaXQsIGN1cnJlbnQgY291bnQ6IAkAAaQAAAABBQAAAAhidXlDb3VudAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABlnZXRMb290Qm94QnV5Q291bnREYXRhS2V5AAAAAQUAAAAFaWRTdHIFAAAAC25ld0J1eUNvdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAG2dldERlc3RpbmF0aW9uV2FsbGV0QWRkcmVzcwAAAAAFAAAADHBsYXllclBheVN1bQUAAAAEdW5pdAUAAAADbmlsAAAAAP+mMm4=", "chainId": 84, "height": 690244, "spentComplexity": 0 } View: original | compacted Prev: HzUbBnmAvgNZjossZqzcZ6HopW3BAmLiVdRxAPAY3jjg Next: 9GZX2QiM9Rquy8zeDhB7QBTauQwHsrg75JsTVp2MUjGQ Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let ownerPublicKey = base58'9UUaVVahBUyLHLQo4HNuQsRMKY9QBH43Grojkbdf4wG4'
4+let ownerPublicKey = base58'Ai5K72PXnQpuH5CCLZcpZWSPGyvSmuBY9PHhFEQStzX9'
55
66 let destinationWalletAddressDataKey = "destination_wallet_address"
77
8-func getLootBoxDataKey (id) = ("loot_box_" + toString(id))
8+func getLootBoxDataKey (id) = ("loot_box_" + id)
9+
10+
11+func getLootBoxPriceDataKey (id) = (getLootBoxDataKey(id) + "_price")
12+
13+
14+func getLootBoxLimitDataKey (id) = (getLootBoxDataKey(id) + "_limit")
15+
16+
17+func getLootBoxBuyCountDataKey (id) = (getLootBoxDataKey(id) + "_buy_count")
918
1019
1120 func getDestinationWalletAddress () = match getString(this, destinationWalletAddressDataKey) {
1827 }
1928
2029
21-func getLootBoxPrice (id) = match getInteger(this, getLootBoxDataKey(id)) {
30+func getLootBoxPrice (id) = match getInteger(this, getLootBoxPriceDataKey(id)) {
2231 case v: Int =>
2332 v
2433 case _ =>
2534 throw("Loot box price undefined")
35+}
36+
37+
38+func getLootBoxLimit (id) = match getInteger(this, getLootBoxLimitDataKey(id)) {
39+ case v: Int =>
40+ v
41+ case _ =>
42+ throw("Loot box limit undefined")
43+}
44+
45+
46+func getLootBoxBuyCount (id) = match getInteger(this, getLootBoxBuyCountDataKey(id)) {
47+ case v: Int =>
48+ v
49+ case _ =>
50+ 0
2651 }
2752
2853
3661
3762
3863 @Callable(i)
39-func setLootBoxPrice (id,price) = if ((i.callerPublicKey != ownerPublicKey))
64+func setLootBoxInfo (id,price,limit) = if ((i.callerPublicKey != ownerPublicKey))
4065 then throw("Only owner can call this method")
4166 else if ((id == 0))
4267 then throw("Loot id undefined")
4368 else if ((price == 0))
4469 then throw("Price undefined")
45- else WriteSet([DataEntry(getLootBoxDataKey(id), price)])
70+ else if ((limit == 0))
71+ then throw("Limit undefined")
72+ else {
73+ let idStr = toString(id)
74+ WriteSet([DataEntry(getLootBoxPriceDataKey(idStr), price), DataEntry(getLootBoxLimitDataKey(idStr), limit)])
75+ }
4676
4777
4878
4979 @Callable(i)
5080 func buyLootBox (id) = {
81+ let idStr = toString(id)
5182 let payment = extract(i.payment)
52- let lootBoxPrice = getLootBoxPrice(id)
53- let playerPaySum = payment.amount
54- if ((playerPaySum != lootBoxPrice))
55- then throw(((("Price must be equal " + toString(lootBoxPrice)) + " wavelets, given: ") + toString(playerPaySum)))
56- else TransferSet([ScriptTransfer(getDestinationWalletAddress(), playerPaySum, unit)])
83+ if (isDefined(payment.assetId))
84+ then throw("Can hodl waves only at the moment")
85+ else {
86+ let buyCount = getLootBoxBuyCount(idStr)
87+ let newBuyCount = (buyCount + 1)
88+ let lootBoxLimit = getLootBoxLimit(idStr)
89+ let lootBoxPrice = getLootBoxPrice(idStr)
90+ let playerPaySum = payment.amount
91+ if ((playerPaySum != lootBoxPrice))
92+ then throw(((("Price must be equal " + toString(lootBoxPrice)) + " wavelets, given: ") + toString(playerPaySum)))
93+ else if ((newBuyCount > lootBoxLimit))
94+ then throw(((("Cannot sale more " + toString(lootBoxLimit)) + " items due limit, current count: ") + toString(buyCount)))
95+ else ScriptResult(WriteSet([DataEntry(getLootBoxBuyCountDataKey(idStr), newBuyCount)]), TransferSet([ScriptTransfer(getDestinationWalletAddress(), playerPaySum, unit)]))
96+ }
5797 }
5898
5999
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let ownerPublicKey = base58'9UUaVVahBUyLHLQo4HNuQsRMKY9QBH43Grojkbdf4wG4'
4+let ownerPublicKey = base58'Ai5K72PXnQpuH5CCLZcpZWSPGyvSmuBY9PHhFEQStzX9'
55
66 let destinationWalletAddressDataKey = "destination_wallet_address"
77
8-func getLootBoxDataKey (id) = ("loot_box_" + toString(id))
8+func getLootBoxDataKey (id) = ("loot_box_" + id)
9+
10+
11+func getLootBoxPriceDataKey (id) = (getLootBoxDataKey(id) + "_price")
12+
13+
14+func getLootBoxLimitDataKey (id) = (getLootBoxDataKey(id) + "_limit")
15+
16+
17+func getLootBoxBuyCountDataKey (id) = (getLootBoxDataKey(id) + "_buy_count")
918
1019
1120 func getDestinationWalletAddress () = match getString(this, destinationWalletAddressDataKey) {
1221 case v: String =>
1322 if ((v == ""))
1423 then throw("Destination wallet address cannot be empty")
1524 else addressFromStringValue(v)
1625 case _ =>
1726 throw("Destination wallet address undefined")
1827 }
1928
2029
21-func getLootBoxPrice (id) = match getInteger(this, getLootBoxDataKey(id)) {
30+func getLootBoxPrice (id) = match getInteger(this, getLootBoxPriceDataKey(id)) {
2231 case v: Int =>
2332 v
2433 case _ =>
2534 throw("Loot box price undefined")
35+}
36+
37+
38+func getLootBoxLimit (id) = match getInteger(this, getLootBoxLimitDataKey(id)) {
39+ case v: Int =>
40+ v
41+ case _ =>
42+ throw("Loot box limit undefined")
43+}
44+
45+
46+func getLootBoxBuyCount (id) = match getInteger(this, getLootBoxBuyCountDataKey(id)) {
47+ case v: Int =>
48+ v
49+ case _ =>
50+ 0
2651 }
2752
2853
2954 @Callable(i)
3055 func setDestinationWallet (address) = if ((i.callerPublicKey != ownerPublicKey))
3156 then throw("Only owner can call this method")
3257 else if ((address == ""))
3358 then throw("Address cannot be empty")
3459 else WriteSet([DataEntry(destinationWalletAddressDataKey, address)])
3560
3661
3762
3863 @Callable(i)
39-func setLootBoxPrice (id,price) = if ((i.callerPublicKey != ownerPublicKey))
64+func setLootBoxInfo (id,price,limit) = if ((i.callerPublicKey != ownerPublicKey))
4065 then throw("Only owner can call this method")
4166 else if ((id == 0))
4267 then throw("Loot id undefined")
4368 else if ((price == 0))
4469 then throw("Price undefined")
45- else WriteSet([DataEntry(getLootBoxDataKey(id), price)])
70+ else if ((limit == 0))
71+ then throw("Limit undefined")
72+ else {
73+ let idStr = toString(id)
74+ WriteSet([DataEntry(getLootBoxPriceDataKey(idStr), price), DataEntry(getLootBoxLimitDataKey(idStr), limit)])
75+ }
4676
4777
4878
4979 @Callable(i)
5080 func buyLootBox (id) = {
81+ let idStr = toString(id)
5182 let payment = extract(i.payment)
52- let lootBoxPrice = getLootBoxPrice(id)
53- let playerPaySum = payment.amount
54- if ((playerPaySum != lootBoxPrice))
55- then throw(((("Price must be equal " + toString(lootBoxPrice)) + " wavelets, given: ") + toString(playerPaySum)))
56- else TransferSet([ScriptTransfer(getDestinationWalletAddress(), playerPaySum, unit)])
83+ if (isDefined(payment.assetId))
84+ then throw("Can hodl waves only at the moment")
85+ else {
86+ let buyCount = getLootBoxBuyCount(idStr)
87+ let newBuyCount = (buyCount + 1)
88+ let lootBoxLimit = getLootBoxLimit(idStr)
89+ let lootBoxPrice = getLootBoxPrice(idStr)
90+ let playerPaySum = payment.amount
91+ if ((playerPaySum != lootBoxPrice))
92+ then throw(((("Price must be equal " + toString(lootBoxPrice)) + " wavelets, given: ") + toString(playerPaySum)))
93+ else if ((newBuyCount > lootBoxLimit))
94+ then throw(((("Cannot sale more " + toString(lootBoxLimit)) + " items due limit, current count: ") + toString(buyCount)))
95+ else ScriptResult(WriteSet([DataEntry(getLootBoxBuyCountDataKey(idStr), newBuyCount)]), TransferSet([ScriptTransfer(getDestinationWalletAddress(), playerPaySum, unit)]))
96+ }
5797 }
5898
5999

github/deemru/w8io/169f3d6 
47.98 ms