tx · BC8QvNBEjfnmSJZxmbbb8qpBYCwY19GEnTgaoUCxKv9m 3N5yhZaotBLUGJ1EeegT2KC3iTdhAamcHJ9: -0.01400000 Waves 2019.07.03 22:03 [569634] smart account 3N5yhZaotBLUGJ1EeegT2KC3iTdhAamcHJ9 > SELF 0.00000000 Waves
{ "type": 13, "id": "BC8QvNBEjfnmSJZxmbbb8qpBYCwY19GEnTgaoUCxKv9m", "fee": 1400000, "feeAssetId": null, "timestamp": 1562180594810, "version": 1, "sender": "3N5yhZaotBLUGJ1EeegT2KC3iTdhAamcHJ9", "senderPublicKey": "2kKaoCcJJ7XyWXm1bKS64QdpwGQpmaEcrToYuPd1k2nB", "proofs": [ "kQCZo56sWDQnKcCyTJuWXQSyJbQ2oZPXXH86ESP44WFbpGx2QCFnhBuLxLitAH3rDy3UCwPzVGB9Vv7gmjNsVUL" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAAAAAAtCTEFDS0xJU1RFRAIAAAAJYmxhY2tsaXN0AAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAVfZGF0YQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9vd25lcgEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFGdldFZhbHVlSXRlbVN1cHBsaWVyAAAAAQAAAARpdGVtCQEAAAALZ2V0U3RyQnlLZXkAAAABC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old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status") | |
4 | + | let BLACKLISTED = "blacklist" | |
5 | + | ||
6 | + | let NONE = "none" | |
7 | + | ||
8 | + | func getKeyItemPrice (item) = (item + "_price") | |
5 | 9 | ||
6 | 10 | ||
7 | - | ||
11 | + | func getKeyItemData (item) = (item + "_data") | |
8 | 12 | ||
9 | - | let VERIFIED = "verified" | |
10 | 13 | ||
11 | - | let BLACKLISTED = "blacklist" | |
14 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
15 | + | ||
16 | + | ||
17 | + | func getStrByKey (key) = { | |
18 | + | let str = match getString(this, key) { | |
19 | + | case a: String => | |
20 | + | a | |
21 | + | case _ => | |
22 | + | NONE | |
23 | + | } | |
24 | + | str | |
25 | + | } | |
26 | + | ||
27 | + | ||
28 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
29 | + | ||
30 | + | ||
31 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
32 | + | ||
33 | + | ||
34 | + | func getExtAddressOracle () = extract(addressFromString("3N5yhZaotBLUGJ1EeegT2KC3iTdhAamcHJ9")) | |
35 | + | ||
36 | + | ||
37 | + | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
38 | + | ||
39 | + | ||
40 | + | func getExtValueItemWhiteListStatus (oracle,account) = { | |
41 | + | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
42 | + | case a: String => | |
43 | + | a | |
44 | + | case _ => | |
45 | + | NONE | |
46 | + | } | |
47 | + | str | |
48 | + | } | |
49 | + | ||
12 | 50 | ||
13 | 51 | @Callable(i) | |
14 | - | func setstatus (supplier,status) = { | |
15 | - | let account = toBase58String(i.caller.bytes) | |
16 | - | if ((account != verifier)) | |
17 | - | then throw("only oracle verifier are able to manage whitelist") | |
18 | - | else if (if ((status != VERIFIED)) | |
19 | - | then (status != BLACKLISTED) | |
20 | - | else false) | |
21 | - | then throw("wrong status") | |
22 | - | else WriteSet([DataEntry(getExtValueItemWhiteListStatus(supplier), status)]) | |
52 | + | func addItem (title,price,data) = { | |
53 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
54 | + | let item = getKeyItem(supplierAddress, title) | |
55 | + | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
56 | + | if ((0 >= price)) | |
57 | + | then throw("purchase amount cannot be less than item price") | |
58 | + | else if ((getValueItemSupplier(item) != NONE)) | |
59 | + | then throw("an item already exists") | |
60 | + | else if ((supplierWhiteList == BLACKLISTED)) | |
61 | + | then throw("supplier's account has been blacklisted") | |
62 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)]) | |
23 | 63 | } | |
24 | 64 | ||
25 | 65 |
github/deemru/w8io/169f3d6 26.33 ms ◑