tx · 3t1pkGaS9xEaBF9aCShkzvgF1dotDiFS9c7sXgYiK7pa 3MrFECyg5u1oBr6Yv8o7xVHAWdDKYxjSqBH: -0.01400000 Waves 2019.07.02 21:47 [568164] smart account 3MrFECyg5u1oBr6Yv8o7xVHAWdDKYxjSqBH > SELF 0.00000000 Waves
{ "type": 13, "id": "3t1pkGaS9xEaBF9aCShkzvgF1dotDiFS9c7sXgYiK7pa", "fee": 1400000, "feeAssetId": null, "timestamp": 1562093260073, "version": 1, "sender": "3MrFECyg5u1oBr6Yv8o7xVHAWdDKYxjSqBH", "senderPublicKey": "892iV3WR5eKpCHvH7aBmeLbdjiKw9tn3h53LzbfoRFX4", "proofs": [ "3FJRE4fS9qsEKsuJEouMMRrnFpUgdw96nQDDaArcYUqF5LrBE7n6sySyZyPJ5btXvU9s9E9AtdzWgYxFvR8Krusu" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAQAAABNnZXRFeHRBZGRyZXNzT3JhY2xlAAAAAAkBAAAAB2V4dHJhY3QAAAABCQEAAAARYWRkcmVzc0Zyb21TdHJpbmcAAAABAgAAACMzTjhXbllHWkdWVHlrcXRvRHk3ZHpTelFOdmZETnl2UktYcgAAAAALQkxBQ0tMSVNURUQCAAAACWJsYWNrbGlzdAAAAAAETk9ORQIAAAAEbm9uZQEAAAAcZ2V0RXh0S2V5SXRlbVdoaXRlTGlzdFN0YXR1cwAAAAEAAAAHYWNjb3VudAkAASwAAAACBQAAAAdhY2NvdW50AgAAABBfdmVyaWZpZXJfc3RhdHVzAQAAAB5nZXRFeHRWYWx1ZUl0ZW1XaGl0ZUxpc3RTdGF0dXMAAAACAAAABm9yYWNsZQAAAAdhY2NvdW50BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAGb3JhY2xlCQEAAAAcZ2V0RXh0S2V5SXRlbVdoaXRlTGlzdFN0YXR1cwAAAAEFAAAAB2FjY291bnQDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAA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RBZGRyZXNzT3JhY2xlAAAAAAUAAAAPc3VwcGxpZXJBZGRyZXNzAwkAAGcAAAACAAAAAAAAAAAABQAAAAVwcmljZQkAAAIAAAABAgAAAC5wdXJjaGFzZSBhbW91bnQgY2Fubm90IGJlIGxlc3MgdGhlbiBpdGVtIHByaWNlAwkBAAAAAiE9AAAAAgkBAAAAFGdldFZhbHVlSXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAETk9ORQkAAAIAAAABAgAAABlhbmQgaXRlbSBpcyBhbHJlYWR5IGV4aXN0AwkAAAAAAAACBQAAABFzdXBwbGllcldoaXRlbGlzdAUAAAALQkxBQ0tMSVNURUQJAAACAAAAAQIAAAAnc3VwcGxpZXIncyBhY2NvdW50IGhhcyBiZWVuIGJsYWNrbGlzdGVkCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAPc3VwcGxpZXJBZGRyZXNzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQUAAAAEaXRlbQUAAAAFcHJpY2UJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEFAAAABGl0ZW0FAAAABGRhdGEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABxnZXRFeHRLZXlJdGVtV2hpdGVMaXN0U3RhdHVzAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzBQAAABFzdXBwbGllcldoaXRlbGlzdAUAAAADbmlsAAAAAK1piHg=", "chainId": 84, "height": 568164, "spentComplexity": 0 } View: original | compacted Prev: 7A2WAQTwq4ReszdyGDu2i8nVipBdX2bZVJxTmhi78FUv Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func | |
4 | + | func getExtAddressOracle () = extract(addressFromString("3N8WnYGZGVTykqtoDy7dzSzQNvfDNyvRKXr")) | |
5 | 5 | ||
6 | - | ||
7 | - | let verifier = "3N8WnYGZGVTykqtoDy7dzSzQNvfDNyvRKXr" | |
8 | - | ||
9 | - | let VERIFIED = "verified" | |
10 | 6 | ||
11 | 7 | let BLACKLISTED = "blacklist" | |
12 | 8 | ||
9 | + | let NONE = "none" | |
10 | + | ||
11 | + | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
12 | + | ||
13 | + | ||
14 | + | func getExtValueItemWhiteListStatus (oracle,account) = { | |
15 | + | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
16 | + | case a: String => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | NONE | |
20 | + | } | |
21 | + | str | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
26 | + | ||
27 | + | ||
28 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
29 | + | ||
30 | + | ||
31 | + | func getStrByKey (key) = { | |
32 | + | let str = match getString(this, key) { | |
33 | + | case a: String => | |
34 | + | a | |
35 | + | case _ => | |
36 | + | NONE | |
37 | + | } | |
38 | + | str | |
39 | + | } | |
40 | + | ||
41 | + | ||
42 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
43 | + | ||
44 | + | ||
45 | + | func getKeyItemPrice (item) = (item + "_price") | |
46 | + | ||
47 | + | ||
48 | + | func getKeyItemData (item) = (item + "_data") | |
49 | + | ||
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("wrongn 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 then item price") | |
58 | + | else if ((getValueItemSupplier(item) != NONE)) | |
59 | + | then throw("and item is already exist") | |
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/026f985 20.76 ms ◑