tx · 4YpctKtJh8wwBX2XmQbKBV4GJx4rnqKhjXWKE4pZDM9b
3N9g8vmJj171kPszhaCUyPDNfNPqaXiFP3Z: -0.04000000 Waves
2020.06.07 23:19 [1033362] smart account 3N9g8vmJj171kPszhaCUyPDNfNPqaXiFP3Z > SELF 0.00000000 Waves
{
"type": 13,
"id": "4YpctKtJh8wwBX2XmQbKBV4GJx4rnqKhjXWKE4pZDM9b",
"fee": 4000000,
"feeAssetId": null,
"timestamp": 1591561206034,
"version": 1,
"sender": "3N9g8vmJj171kPszhaCUyPDNfNPqaXiFP3Z",
"senderPublicKey": "G4tSmURBD4HJkP9Q8xjQhetzYDb1J7Bc581de6M9V7AK",
"proofs": [
"2EpcR8i6SyAJGqsQux7GK8VHkWECL4xt7v5Uy6haa2bUc9GxjzryKZ6AjUN8Yupy2X9EnMWTCoxYxjnYBCEFMe9Y"
],
"script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgUKAwgBCAAAAAcAAAAABE5PTkUCAAAABG5vbmUBAAAACmdldEtleUl0ZW0AAAACAAAACHN1cHBsaWVyAAAABXRpdGxlCQABLAAAAAICAAAABWl0ZW1fCQACWAAAAAEJAAH3AAAAAQkAAZsAAAABCQABLAAAAAIFAAAACHN1cHBsaWVyBQAAAAV0aXRsZQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEmdldEtleUl0ZW1TdXBwbGllcgAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfb3duZXIBAAAAFGdldFZhbHVlSXRlbVN1cHBsaWVyAAAAAQAAAARpdGVtCQEAAAALZ2V0U3RyQnlLZXkAAAABCQEAAAASZ2V0S2V5SXRlbVN1cHBs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height": 1033362,
"spentComplexity": 0
}
View: original | compacted
Prev: DFWPLH6T6C7CXDqBTWGPY8VM3tPiqocXo14H8jCxvw4D
Next: none
Diff:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
| 4 | + | let NONE = "none" |
---|
| 5 | + | |
---|
| 6 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) |
---|
| 7 | + | |
---|
| 8 | + | |
---|
| 9 | + | func getStrByKey (key) = { |
---|
| 10 | + | let str = match getString(this, key) { |
---|
| 11 | + | case a: String => |
---|
| 12 | + | a |
---|
| 13 | + | case _ => |
---|
| 14 | + | NONE |
---|
| 15 | + | } |
---|
| 16 | + | str |
---|
| 17 | + | } |
---|
| 18 | + | |
---|
| 19 | + | |
---|
| 20 | + | func getKeyItemSupplier (item) = (item + "_owner") |
---|
| 21 | + | |
---|
| 22 | + | |
---|
| 23 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) |
---|
| 24 | + | |
---|
| 25 | + | |
---|
| 26 | + | func getKeyItemPrice (item) = (item + "_price") |
---|
| 27 | + | |
---|
| 28 | + | |
---|
| 29 | + | func getKeyItemData (item) = (item + "_data") |
---|
4 | 30 | | |
---|
5 | 31 | | |
---|
6 | 32 | | @Callable(i) |
---|
|
25 | 51 | | } |
---|
26 | 52 | | |
---|
27 | 53 | | |
---|
| 54 | + | |
---|
| 55 | + | @Callable(i) |
---|
| 56 | + | func addItem (title,price,data) = { |
---|
| 57 | + | let supplierAdreess = toBase58String(i.caller.bytes) |
---|
| 58 | + | let item = getKeyItem(supplierAdreess, title) |
---|
| 59 | + | if ((0 >= price)) |
---|
| 60 | + | then throw("purchase amount cannot be less than item price") |
---|
| 61 | + | else if ((getValueItemSupplier(item) != NONE)) |
---|
| 62 | + | then throw("an item already exist") |
---|
| 63 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAdreess), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) |
---|
| 64 | + | } |
---|
| 65 | + | |
---|
| 66 | + | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
| 4 | + | let NONE = "none" |
---|
| 5 | + | |
---|
| 6 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) |
---|
| 7 | + | |
---|
| 8 | + | |
---|
| 9 | + | func getStrByKey (key) = { |
---|
| 10 | + | let str = match getString(this, key) { |
---|
| 11 | + | case a: String => |
---|
| 12 | + | a |
---|
| 13 | + | case _ => |
---|
| 14 | + | NONE |
---|
| 15 | + | } |
---|
| 16 | + | str |
---|
| 17 | + | } |
---|
| 18 | + | |
---|
| 19 | + | |
---|
| 20 | + | func getKeyItemSupplier (item) = (item + "_owner") |
---|
| 21 | + | |
---|
| 22 | + | |
---|
| 23 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) |
---|
| 24 | + | |
---|
| 25 | + | |
---|
| 26 | + | func getKeyItemPrice (item) = (item + "_price") |
---|
| 27 | + | |
---|
| 28 | + | |
---|
| 29 | + | func getKeyItemData (item) = (item + "_data") |
---|
4 | 30 | | |
---|
5 | 31 | | |
---|
6 | 32 | | @Callable(i) |
---|
7 | 33 | | func purchase (item) = { |
---|
8 | 34 | | let pmt = extract(i.payment) |
---|
9 | 35 | | if (isDefined(pmt.assetId)) |
---|
10 | 36 | | then throw("can use WAVES only at the moment") |
---|
11 | 37 | | else { |
---|
12 | 38 | | let customerAdreess = toBase58String(i.caller.bytes) |
---|
13 | 39 | | let price = match getInteger(this, (("item_" + item) + "_coupon_price")) { |
---|
14 | 40 | | case a: Int => |
---|
15 | 41 | | a |
---|
16 | 42 | | case _ => |
---|
17 | 43 | | 0 |
---|
18 | 44 | | } |
---|
19 | 45 | | if ((price > pmt.amount)) |
---|
20 | 46 | | then throw("purchase amount cannot be less than item price") |
---|
21 | 47 | | else if ((pmt.amount > price)) |
---|
22 | 48 | | then throw("purchase amount cannot be higher than item price") |
---|
23 | 49 | | else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer_") + customerAdreess), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer_") + customerAdreess), price)]) |
---|
24 | 50 | | } |
---|
25 | 51 | | } |
---|
26 | 52 | | |
---|
27 | 53 | | |
---|
| 54 | + | |
---|
| 55 | + | @Callable(i) |
---|
| 56 | + | func addItem (title,price,data) = { |
---|
| 57 | + | let supplierAdreess = toBase58String(i.caller.bytes) |
---|
| 58 | + | let item = getKeyItem(supplierAdreess, title) |
---|
| 59 | + | if ((0 >= price)) |
---|
| 60 | + | then throw("purchase amount cannot be less than item price") |
---|
| 61 | + | else if ((getValueItemSupplier(item) != NONE)) |
---|
| 62 | + | then throw("an item already exist") |
---|
| 63 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAdreess), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) |
---|
| 64 | + | } |
---|
| 65 | + | |
---|
| 66 | + | |
---|