tx · 5RyV7rb3i2oC27HBC9Zwh8vCFeLLQb85bpyJ2UgXuJvr

3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3:  -0.01400000 Waves

2020.11.20 17:48 [1273844] smart account 3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3 > SELF 0.00000000 Waves

{ "type": 13, "id": "5RyV7rb3i2oC27HBC9Zwh8vCFeLLQb85bpyJ2UgXuJvr", "fee": 1400000, "feeAssetId": null, "timestamp": 1605883763183, "version": 2, "chainId": 84, "sender": "3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3", "senderPublicKey": "24o2mnMP6y64dijDFoZKhDpV73e1gCFKxQcZ6X9q3z1B", "proofs": [ "41RSr3PatEQKHzWWNDHJj93ZSDUeMuihnJ7hxt53q6gejUmzjMRFd1VxVUAaaazgDfXrjshoJPjrVVWRs7JPZkiv" ], "script": "base64:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAABAAAAAAEWFjY291bnQxUHVibGljS2V5AQAAACD3jXgw7OE1lYUdW8zpPeJRbBzq2i/QfxUY9F31TI9ITgAAAAARYWNjb3VudDJQdWJsaWNLZXkBAAAAIBtXv2hMCq7TJHKvVsoiywB7SjyYC3f6AKFF3CrlAyIVAAAAAA5vdGhlclB1YmxpY0tleQEAAAAg525Riaa48RgJvYxM/FeTNEzhBum4Tb2zEKrgTa8dHVoAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckb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9nZXRLZXlJdGVtUHJpY2UAAAABBQAAAARpdGVtBQAAAAVwcmljZQkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQEAAAAOZ2V0S2V5SXRlbURhdGEAAAABBQAAAARpdGVtBQAAAARkYXRhBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABosQwsA=", "height": 1273844, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9uKQMLdnuAgCjd1htTsbM3MMfrSNSo1RemvaDkhAVtwU Next: 55hNEsKebyqGS8vCw8oeiuQCqf4PRUB5yBvh7WwQxZQG Diff:
OldNewDifferences
6262
6363
6464 @Callable(i)
65-func purchase (coupon) = {
65+func purchase (item) = {
6666 let pmt = value(i.payments)
6767 if (isDefined(pmt[0].assetId))
68- then throw("only wws")
68+ then throw("WAVES tokens only")
6969 else {
70- let customerAddress = toBase58String(i.caller.bytes)
71- let price = match getInteger(this, (coupon + "_coupon_price")) {
72- case a: Int =>
73- a
74- case _ =>
75- 0
76- }
77- if ((price == 0))
78- then throw("coupon not found")
79- else if ((price > pmt[0].amount))
80- then throw("moar moeny")
81- else if ((pmt[0].amount > price))
82- then throw(toString(price))
83- else if ((size(pmt) > 1))
84- then throw("single item only")
85- else [StringEntry(((("status:purchase_" + coupon) + "_customer_") + customerAddress), "confirmed"), IntegerEntry(((("price:purchase_" + coupon) + "_customer_") + customerAddress), price)]
70+ let userAddress = toBase58String(i.caller.bytes)
71+ let price = getValueItemPrice(item)
72+ let supplierAddress = getValueItemSupplier(item)
73+ if ((price > pmt[0].amount))
74+ then throw("purchase less than item price")
75+ else if ((pmt[0].amount > price))
76+ then throw("purchase amount higher than item price")
77+ else if ((size(pmt) > 1))
78+ then throw("single item only")
79+ else if ((supplierAddress == NONE))
80+ then throw("supplier doesn't exist")
81+ else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt[0].amount))]
8682 }
8783 }
8884
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd'
55
66 let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv'
77
88 let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw'
99
1010 let NONE = "none"
1111
1212 func getNumberByKey (key) = {
1313 let num = match getInteger(this, key) {
1414 case a: Int =>
1515 a
1616 case _ =>
1717 0
1818 }
1919 num
2020 }
2121
2222
2323 func getStrByKey (key) = {
2424 let str = match getString(this, key) {
2525 case a: String =>
2626 a
2727 case _ =>
2828 NONE
2929 }
3030 str
3131 }
3232
3333
3434 func getKeyItemPrice (item) = (item + "_price")
3535
3636
3737 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3838
3939
4040 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4141
4242
4343 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4444
4545
4646 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4747
4848
4949 func getKeyItemData (item) = (item + "_data")
5050
5151
5252 func getKeyItemSupplier (item) = (item + "_owner")
5353
5454
5555 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5656
5757
5858 func getKeyBalanceSupplier (account) = (account + "_balance")
5959
6060
6161 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6262
6363
6464 @Callable(i)
65-func purchase (coupon) = {
65+func purchase (item) = {
6666 let pmt = value(i.payments)
6767 if (isDefined(pmt[0].assetId))
68- then throw("only wws")
68+ then throw("WAVES tokens only")
6969 else {
70- let customerAddress = toBase58String(i.caller.bytes)
71- let price = match getInteger(this, (coupon + "_coupon_price")) {
72- case a: Int =>
73- a
74- case _ =>
75- 0
76- }
77- if ((price == 0))
78- then throw("coupon not found")
79- else if ((price > pmt[0].amount))
80- then throw("moar moeny")
81- else if ((pmt[0].amount > price))
82- then throw(toString(price))
83- else if ((size(pmt) > 1))
84- then throw("single item only")
85- else [StringEntry(((("status:purchase_" + coupon) + "_customer_") + customerAddress), "confirmed"), IntegerEntry(((("price:purchase_" + coupon) + "_customer_") + customerAddress), price)]
70+ let userAddress = toBase58String(i.caller.bytes)
71+ let price = getValueItemPrice(item)
72+ let supplierAddress = getValueItemSupplier(item)
73+ if ((price > pmt[0].amount))
74+ then throw("purchase less than item price")
75+ else if ((pmt[0].amount > price))
76+ then throw("purchase amount higher than item price")
77+ else if ((size(pmt) > 1))
78+ then throw("single item only")
79+ else if ((supplierAddress == NONE))
80+ then throw("supplier doesn't exist")
81+ else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt[0].amount))]
8682 }
8783 }
8884
8985
9086
9187 @Callable(i)
9288 func addItem (title,price,data) = {
9389 let supplierAddress = toBase58String(i.caller.bytes)
9490 let item = getKeyItem(supplierAddress, title)
9591 if ((0 >= price))
9692 then throw("purchase amount cannot be less than item price")
9793 else if ((getValueItemSupplier(item) != NONE))
9894 then throw("an item already exist")
9995 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
10096 }
10197
10298
10399 @Verifier(tx)
104100 func verify () = true
105101

github/deemru/w8io/169f3d6 
33.24 ms