tx · 8H87rDQzUsSNTodPrT7ncKhVdCAo1oPipf2QqqTny7k2

3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6:  -0.01400000 Waves

2019.11.16 18:15 [767841] smart account 3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6 > SELF 0.00000000 Waves

{ "type": 13, "id": "8H87rDQzUsSNTodPrT7ncKhVdCAo1oPipf2QqqTny7k2", "fee": 1400000, "feeAssetId": null, "timestamp": 1573917407153, "version": 1, "sender": "3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6", "senderPublicKey": "8bmUdC19peGBa1TGeRZaZfpuDG6yKaGYBd8FQvcBLAXR", "proofs": [ "3dDMoLLwR8dnc6GLsfYyfpmEeNBJxheiGVC7G743fe3ziBoE3v2XMuCcTqw66ZumttGe5YS8g6C6Vdgmb8mr8aLi" ], "script": "base64:AAIDAAAAAAAAAAQIARIAAAAADQAAAAAETk9ORQIAAAAEbm9uZQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAAOZ2V0S2V5SXRlbURhdGEAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAFX2RhdGEBAAAADmdldEtleUl0ZW1TdXBwAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9vd25lcgEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAACmdldEtleUl0ZW0AAAACAAAABHN1cHAAAAAFdGl0bGUJAAEsAAAAAgIAAAAFaXRlbV8JAAJYAAAAAQkAAfcAAAABCQABmwAAAAEJAAEsAAAAAgUAAAAEc3VwcAUAA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AATZ2V0VmFsdWVTdXBwQmFsYW5jZQAAAAEFAAAAB3N1cHBBZHIDCQAAZwAAAAIAAAAAAAAAAAAFAAAAB2JhbGFuY2UJAAACAAAAAQIAAAAUaW5zdWZmaWNpZW50IGJhbGFuY2UJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAARZ2V0S2V5U3VwcEJhbGFuY2UAAAABBQAAAAdzdXBwQWRyAAAAAAAAAAAABQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAdzdXBwQWRyBQAAAAdiYWxhbmNlBQAAAAR1bml0BQAAAANuaWwAAAAAe1nEKg==", "chainId": 84, "height": 767841, "spentComplexity": 0 } View: original | compacted Prev: BH8pWegCNZza68T5ffZRFCFWBFNyYy27VvA5VqfE6L6B Next: CbG2SFGC41RXzayu92DDGmMNxZmZYAeBVZp6xLcc1k4z Diff:
OldNewDifferences
5656
5757
5858 @Callable(i)
59-func purchase (item) = {
60- let pmt = extract(i.payment)
61- if (isDefined(pmt.assetId))
62- then throw("Wawes only")
63- else {
64- let userAdr = toBase58String(i.caller.bytes)
65- let price = getValueItemPrice(item)
66- let suppAdr = getValueItemSupp(item)
67- if ((price > pmt.amount))
68- then throw("purchase amount < price")
69- else if ((pmt.amount > price))
70- then throw("purchase amount > price")
71- else if ((suppAdr == NONE))
72- then throw("supp not exist")
73- else WriteSet([DataEntry(getKeyUserItemCounter(userAdr, item), (getValueUserItemCounter(userAdr, item) + 1)), DataEntry(getKeySuppBalance(suppAdr), (getValueSuppBalance(suppAdr) + pmt.amount))])
74- }
59+func withdraw () = {
60+ let suppAdr = toBase58String(i.caller.bytes)
61+ let balance = getValueSuppBalance(suppAdr)
62+ if ((0 >= balance))
63+ then throw("insufficient balance")
64+ else ScriptResult(WriteSet([DataEntry(getKeySuppBalance(suppAdr), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppAdr), balance, unit)]))
7565 }
7666
7767
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getKeyItemPrice (item) = (item + "_price")
77
88
99 func getKeyItemData (item) = (item + "_data")
1010
1111
1212 func getKeyItemSupp (item) = (item + "_owner")
1313
1414
1515 func getStrByKey (key) = {
1616 let str = match getString(this, key) {
1717 case a: String =>
1818 a
1919 case _ =>
2020 NONE
2121 }
2222 str
2323 }
2424
2525
2626 func getKeyItem (supp,title) = ("item_" + toBase58String(sha256(toBytes((supp + title)))))
2727
2828
2929 func getValueItemSupp (item) = getStrByKey(getKeyItemSupp(item))
3030
3131
3232 func getNumberByKey (key) = {
3333 let num = match getInteger(this, key) {
3434 case a: Int =>
3535 a
3636 case _ =>
3737 0
3838 }
3939 num
4040 }
4141
4242
4343 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
4444
4545
4646 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4747
4848
4949 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
5050
5151
5252 func getKeySuppBalance (supp) = (supp + "_balance")
5353
5454
5555 func getValueSuppBalance (supp) = getNumberByKey(getKeySuppBalance(supp))
5656
5757
5858 @Callable(i)
59-func purchase (item) = {
60- let pmt = extract(i.payment)
61- if (isDefined(pmt.assetId))
62- then throw("Wawes only")
63- else {
64- let userAdr = toBase58String(i.caller.bytes)
65- let price = getValueItemPrice(item)
66- let suppAdr = getValueItemSupp(item)
67- if ((price > pmt.amount))
68- then throw("purchase amount < price")
69- else if ((pmt.amount > price))
70- then throw("purchase amount > price")
71- else if ((suppAdr == NONE))
72- then throw("supp not exist")
73- else WriteSet([DataEntry(getKeyUserItemCounter(userAdr, item), (getValueUserItemCounter(userAdr, item) + 1)), DataEntry(getKeySuppBalance(suppAdr), (getValueSuppBalance(suppAdr) + pmt.amount))])
74- }
59+func withdraw () = {
60+ let suppAdr = toBase58String(i.caller.bytes)
61+ let balance = getValueSuppBalance(suppAdr)
62+ if ((0 >= balance))
63+ then throw("insufficient balance")
64+ else ScriptResult(WriteSet([DataEntry(getKeySuppBalance(suppAdr), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppAdr), balance, unit)]))
7565 }
7666
7767

github/deemru/w8io/169f3d6 
41.57 ms