tx · 4a2cDu64bQgMpnYozKHBxabDH3kUCuzSkpGgHbs64YN1 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR: -0.01400000 Waves 2019.07.14 03:37 [584703] smart account 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR > SELF 0.00000000 Waves
{ "type": 13, "id": "4a2cDu64bQgMpnYozKHBxabDH3kUCuzSkpGgHbs64YN1", "fee": 1400000, "feeAssetId": null, "timestamp": 1563064661352, "version": 1, "sender": "3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR", "senderPublicKey": "Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV", "proofs": [ "2GV5SvtK5D6WHQeXxeXvGfTF3au3dD44g36wxmGcyGn9NYiKHY3ELCwNHjGNmmvinPi8DcspugG8X5pkRfcHtgPv" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAA5vd25lclB1YmxpY0tleQEAAAAgAnfP9tCFuj2k2BUY5PW9DVGxrCHBHKJwugv8WyiaGXIAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtU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AAAALnB1cmNoYXNlIGFtb3VudCBjYW5ub3QgYmUgbGVzcyB0aGFuIGl0ZW0gcHJpY2UDCQEAAAACIT0AAAACCQEAAAAUZ2V0VmFsdWVJdGVtU3VwcGxpZXIAAAABBQAAAARpdGVtBQAAAAROT05FCQAAAgAAAAECAAAAGGFuIGl0ZW0gaXMgYWxyZWFkeSBleGlzdAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEmdldEtleUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0FAAAAD3N1cHBsaWVyQWRkcmVzcwkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEFAAAABGl0ZW0FAAAABXByaWNlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAOZ2V0S2V5SXRlbURhdGEAAAABBQAAAARpdGVtBQAAAARkYXRhBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA5vd25lclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgfJxp3Q", "chainId": 84, "height": 584703, "spentComplexity": 0 } View: original | compacted Prev: AQgjFY4Fjpu7ridNAuiCcX3ZMyRYn4q5U9dv192pwRuA Next: 894iPjxFqLcpYsmtd9R8mtGehzij8DQbRaKRQFUjnSr2 Diff:
Old | New | Differences | |
---|---|---|---|
106 | 106 | ||
107 | 107 | ||
108 | 108 | @Callable(i) | |
109 | + | func withdraw () = { | |
110 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
111 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
112 | + | if ((0 >= balance)) | |
113 | + | then throw("insufficient balance") | |
114 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
109 | 120 | func addItem (title,price,data) = { | |
110 | 121 | let supplierAddress = toBase58String(i.caller.bytes) | |
111 | 122 | let item = getKeyItem(supplierAddress, title) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV' | |
5 | 5 | ||
6 | 6 | let NONE = "none" | |
7 | 7 | ||
8 | 8 | func getNumberByKey (key) = { | |
9 | 9 | let num = match getInteger(this, key) { | |
10 | 10 | case a: Int => | |
11 | 11 | a | |
12 | 12 | case _ => | |
13 | 13 | 0 | |
14 | 14 | } | |
15 | 15 | num | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getStrByKey (key) = { | |
20 | 20 | let str = match getString(this, key) { | |
21 | 21 | case a: String => | |
22 | 22 | a | |
23 | 23 | case _ => | |
24 | 24 | NONE | |
25 | 25 | } | |
26 | 26 | str | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getKeyItemPrice (item) = (item + "_price") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getKeyItemData (item) = (item + "_data") | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getKeyItemSupplier (item) = (item + "_owner") | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func getKeyCommitsCount (item) = (item + "_comcnt") | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getKeyItemStatus (item) = (item + "_status") | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | @Callable(i) | |
88 | 88 | func purchase (item) = { | |
89 | 89 | let pmt = extract(i.payment) | |
90 | 90 | if (isDefined(pmt.assetId)) | |
91 | 91 | then throw("can use WAVES only at the moment") | |
92 | 92 | else { | |
93 | 93 | let userAddress = toBase58String(i.caller.bytes) | |
94 | 94 | let price = getValueItemPrice(item) | |
95 | 95 | let supplierAddress = getValueItemSupplier(item) | |
96 | 96 | if ((price > pmt.amount)) | |
97 | 97 | then throw("purchase amount cannot be less than item price") | |
98 | 98 | else if ((pmt.amount > price)) | |
99 | 99 | then throw("purchase amount cannot be higher than item price") | |
100 | 100 | else if ((supplierAddress == NONE)) | |
101 | 101 | then throw("supplier does not exist") | |
102 | 102 | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
103 | 103 | } | |
104 | 104 | } | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | 108 | @Callable(i) | |
109 | + | func withdraw () = { | |
110 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
111 | + | let balance = getValueBalanceSupplier(supplierAddress) | |
112 | + | if ((0 >= balance)) | |
113 | + | then throw("insufficient balance") | |
114 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
109 | 120 | func addItem (title,price,data) = { | |
110 | 121 | let supplierAddress = toBase58String(i.caller.bytes) | |
111 | 122 | let item = getKeyItem(supplierAddress, title) | |
112 | 123 | if ((0 >= price)) | |
113 | 124 | then throw("purchase amount cannot be less than item price") | |
114 | 125 | else if ((getValueItemSupplier(item) != NONE)) | |
115 | 126 | then throw("an item is already exist") | |
116 | 127 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
117 | 128 | } | |
118 | 129 | ||
119 | 130 | ||
120 | 131 | @Verifier(tx) | |
121 | 132 | func verify () = match tx { | |
122 | 133 | case d: SetScriptTransaction => | |
123 | 134 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
124 | 135 | case d: DataTransaction => | |
125 | 136 | true | |
126 | 137 | case _ => | |
127 | 138 | false | |
128 | 139 | } | |
129 | 140 |
github/deemru/w8io/169f3d6 34.97 ms ◑