tx · BKmxNnS46wfZwPUBJgtoSEj2ctp4tY4qnjqCzzUrJGhu
3N1HYdheNiiTtHgi2n3jLAek6N3H4guaciG: -1.40000000 Waves
2019.11.01 13:42 [745686] smart account 3N1HYdheNiiTtHgi2n3jLAek6N3H4guaciG > SELF 0.00000000 Waves
{
"type": 13,
"id": "BKmxNnS46wfZwPUBJgtoSEj2ctp4tY4qnjqCzzUrJGhu",
"fee": 140000000,
"feeAssetId": null,
"timestamp": 1572604696051,
"version": 1,
"sender": "3N1HYdheNiiTtHgi2n3jLAek6N3H4guaciG",
"senderPublicKey": "ABg8e4W86BPhY1TMBNFDsAi6N9qAVf6DqAVAHSXHttzT",
"proofs": [
"4Vmce2qfWHUQJV9xQsnDLzsTkTFkPYJfpZnBxDxkAHCM3Jrrn4fJzqSdXKeRqsxBGBEeFPXtVKKy4QZ5gbjLhn7m"
],
"script": "base64:AAIDAAAAAAAAAAsIARIAEgUKAwgBCAAAAAcAAAAABE5PTkUCAAAABG5vbmUBAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAVfZGF0YQEAAAAKZ2V0S2V5SXRlbQAAAAIAAAAIc3VwcGxpZXIAAAAFdGl0bGUJAAEsAAAAAgIAAAAFaXRlbV8JAAJYAAAAAQkAAfcAAAABCQABmwAAAAEJAAEsAAAAAgUAAAAIc3VwcGxpZXIFAAAABXRpdGxlAQAAABJnZXRLZXlJdGVtU3VwcGxpZX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AAA9zZW5kZXJQdWJsaWNLZXnaZKww",
"chainId": 84,
"height": 745686,
"spentComplexity": 0
}
View: original | compacted
Prev: 6S1bvufpHw8jcvi3tDmxHue3AzkWwij4GaHWHZgyZUKu
Next: HrKgdghWapQaKmaEN9smxXMXUr5yhZ7LB5ZbGCenFG16
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 getStrByKey (key) = { |
---|
| 7 | + | let str = match getString(this, key) { |
---|
| 8 | + | case a: String => |
---|
| 9 | + | a |
---|
| 10 | + | case _ => |
---|
| 11 | + | NONE |
---|
| 12 | + | } |
---|
| 13 | + | str |
---|
| 14 | + | } |
---|
| 15 | + | |
---|
| 16 | + | |
---|
| 17 | + | func getKeyItemPrice (item) = (item + "_price") |
---|
| 18 | + | |
---|
| 19 | + | |
---|
| 20 | + | func getKeyItemData (item) = (item + "_data") |
---|
| 21 | + | |
---|
| 22 | + | |
---|
| 23 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) |
---|
| 24 | + | |
---|
| 25 | + | |
---|
| 26 | + | func getKeyItemSupplier (item) = (item + "_owner") |
---|
| 27 | + | |
---|
| 28 | + | |
---|
| 29 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) |
---|
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 supplierAddress = toBase58String(i.caller.bytes) |
---|
| 58 | + | let item = getKeyItem(supplierAddress, 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 is already exist") |
---|
| 63 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) |
---|
| 64 | + | } |
---|
| 65 | + | |
---|
| 66 | + | |
---|
28 | 67 | | @Verifier(tx) |
---|
29 | 68 | | func standardVerifier () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
30 | 69 | | |
---|
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 getStrByKey (key) = { |
---|
| 7 | + | let str = match getString(this, key) { |
---|
| 8 | + | case a: String => |
---|
| 9 | + | a |
---|
| 10 | + | case _ => |
---|
| 11 | + | NONE |
---|
| 12 | + | } |
---|
| 13 | + | str |
---|
| 14 | + | } |
---|
| 15 | + | |
---|
| 16 | + | |
---|
| 17 | + | func getKeyItemPrice (item) = (item + "_price") |
---|
| 18 | + | |
---|
| 19 | + | |
---|
| 20 | + | func getKeyItemData (item) = (item + "_data") |
---|
| 21 | + | |
---|
| 22 | + | |
---|
| 23 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) |
---|
| 24 | + | |
---|
| 25 | + | |
---|
| 26 | + | func getKeyItemSupplier (item) = (item + "_owner") |
---|
| 27 | + | |
---|
| 28 | + | |
---|
| 29 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) |
---|
4 | 30 | | |
---|
5 | 31 | | |
---|
6 | 32 | | @Callable(i) |
---|
7 | 33 | | func purchase () = { |
---|
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 customerAddress = toBase58String(i.caller.bytes) |
---|
13 | 39 | | let price = match getInteger(this, "item_A_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 ((price > pmt.amount)) |
---|
22 | 48 | | then throw("purchase amount cannot be higher than item price") |
---|
23 | 49 | | else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)]) |
---|
24 | 50 | | } |
---|
25 | 51 | | } |
---|
26 | 52 | | |
---|
27 | 53 | | |
---|
| 54 | + | |
---|
| 55 | + | @Callable(i) |
---|
| 56 | + | func addItem (title,price,data) = { |
---|
| 57 | + | let supplierAddress = toBase58String(i.caller.bytes) |
---|
| 58 | + | let item = getKeyItem(supplierAddress, 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 is already exist") |
---|
| 63 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) |
---|
| 64 | + | } |
---|
| 65 | + | |
---|
| 66 | + | |
---|
28 | 67 | | @Verifier(tx) |
---|
29 | 68 | | func standardVerifier () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
30 | 69 | | |
---|