tx · 9184FjYaMmmKUVzh2434rMhdi5DdN4GNUv3dzTYYCa27 3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP: -0.01400000 Waves 2021.11.18 16:23 [1796542] smart account 3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP > SELF 0.00000000 Waves
{ "type": 13, "id": "9184FjYaMmmKUVzh2434rMhdi5DdN4GNUv3dzTYYCa27", "fee": 1400000, "feeAssetId": null, "timestamp": 1637241866173, "version": 2, "chainId": 84, "sender": "3MrFUxcMycRcQDahrA16JhvuEKnbmMF3QZP", "senderPublicKey": "HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq", "proofs": [ "2y6PMGnbY3mgciG43YmHXdyWxsK4iaA3ZU4LBwh1U25TTJ3qCx6wac1L1jAkKR1xvjsTYc5a8UP7Hf85yvv3BGUw" ], "script": "base64:AAIDAAAAAAAAAA4IARIFCgMIAQgSAwoBCAAAABEAAAAADm93bmVyUHVibGljS2V5AQAAACD6+lAsvaY9/ICsFhS1sYMY13YGhvh1jT1AiPapnK+uIAAAAAALcHViS2V5QWxpY2UBAAAAIPr6UCy9pj38gKwWFLWxgxjXdgaG+HWNPUCI9qmcr64gAAAAAAlwdWJLZXlCb2IBAAAAIJSwJHqny7GXkLqb/9sX0sw4nnCkaYeDrScKSJwbx9dLAAAAAAxwdWJLZXlDb29wZXIBAAAAIMviW1daO0ECCbLD7je58oUri4AFkKl3dlICXnEszUFIAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAXQFAAAAByRtYXRjaDAFAAAAAXQAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFA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nR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAAxwdWJLZXlDb29wZXIGCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQUAAAAMcHViS2V5Q29vcGVyBgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAIFAAAADHB1YktleUNvb3BlcgAAAAAAAAAAAQAAAAAAAAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAAOb3duZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYJAABnAAAAAgkAAGQAAAACCQAAZAAAAAIFAAAAC3NpZ25lZEFsaWNlBQAAAAlzaWduZWRCb2IFAAAADHNpZ25lZENvb3BlcgAAAAAAAAAAAlgbD7U=", "height": 1796542, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6iLkHAo7mAApY5TBX1R9KGUgrg1kpWyiJR9mVHgjVa56 Next: 4p9i8s8ELYDDweTxgtKUbG3zXP2BuuBQLg1VDsXVNwmL Diff:
Old | New | Differences | |
---|---|---|---|
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | + | ||
79 | + | @Callable(i) | |
80 | + | func purchase (itemKey) = { | |
81 | + | let pmt = extract(i.payment) | |
82 | + | if (isDefined(pmt.assetId)) | |
83 | + | then throw("can use WAVES only at the moment") | |
84 | + | else if (!(isDefined(itemKey))) | |
85 | + | then throw("You must select Item") | |
86 | + | else { | |
87 | + | let customerAddress = toBase58String(i.caller.bytes) | |
88 | + | let price = getValueItemPrice(itemKey) | |
89 | + | let supplierAddress = getValueItemSupplier(itemKey) | |
90 | + | if ((price > pmt.amount)) | |
91 | + | then throw("purchase amoun cannot be less than item price") | |
92 | + | else if ((pmt.amount > price)) | |
93 | + | then throw("purchase amoun cannot be higher than item price") | |
94 | + | else if ((supplierAddress == NONE)) | |
95 | + | then throw("supplier does not exist") | |
96 | + | else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
97 | + | } | |
98 | + | } | |
99 | + | ||
100 | + | ||
78 | 101 | @Verifier(tx) | |
79 | 102 | func verify () = { | |
80 | 103 | let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq' | |
5 | 5 | ||
6 | 6 | let pubKeyAlice = base58'HtiJZF4j7Jo8jR12wxtKDkNhS3qCe3qsk8QxnnjVvXyq' | |
7 | 7 | ||
8 | 8 | let pubKeyBob = base58'B1R7zeh6VgTv4Xxe3aHhdoZ9aQgWcqN8LFC9smacE96r' | |
9 | 9 | ||
10 | 10 | let pubKeyCooper = base58'EisxKQktzqqd4UsxE7UgVjSHqoWindUpjoB7dsDwfG4o' | |
11 | 11 | ||
12 | 12 | let NONE = "none" | |
13 | 13 | ||
14 | 14 | func getNumberByKey (key) = { | |
15 | 15 | let num = match getInteger(this, key) { | |
16 | 16 | case t: Int => | |
17 | 17 | t | |
18 | 18 | case _ => | |
19 | 19 | 0 | |
20 | 20 | } | |
21 | 21 | num | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getStrByKey (key) = { | |
26 | 26 | let str = match getString(this, key) { | |
27 | 27 | case t: String => | |
28 | 28 | t | |
29 | 29 | case _ => | |
30 | 30 | NONE | |
31 | 31 | } | |
32 | 32 | str | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getKeyItemPrice (item) = (item + "_price") | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getKeyItemData (item) = (item + "_data") | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getKeyItemSupplier (item) = (item + "_owner") | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | @Callable(i) | |
67 | 67 | func addItem (title,price,data) = { | |
68 | 68 | let supplierAddress = toBase58String(i.caller.bytes) | |
69 | 69 | let item = getKeyItem(supplierAddress, title) | |
70 | 70 | if ((0 >= price)) | |
71 | 71 | then throw("purchase amount cannot be less than item price") | |
72 | 72 | else if ((getValueItemSupplier(item) != NONE)) | |
73 | 73 | then throw("an item is already exist") | |
74 | 74 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | + | ||
79 | + | @Callable(i) | |
80 | + | func purchase (itemKey) = { | |
81 | + | let pmt = extract(i.payment) | |
82 | + | if (isDefined(pmt.assetId)) | |
83 | + | then throw("can use WAVES only at the moment") | |
84 | + | else if (!(isDefined(itemKey))) | |
85 | + | then throw("You must select Item") | |
86 | + | else { | |
87 | + | let customerAddress = toBase58String(i.caller.bytes) | |
88 | + | let price = getValueItemPrice(itemKey) | |
89 | + | let supplierAddress = getValueItemSupplier(itemKey) | |
90 | + | if ((price > pmt.amount)) | |
91 | + | then throw("purchase amoun cannot be less than item price") | |
92 | + | else if ((pmt.amount > price)) | |
93 | + | then throw("purchase amoun cannot be higher than item price") | |
94 | + | else if ((supplierAddress == NONE)) | |
95 | + | then throw("supplier does not exist") | |
96 | + | else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, itemKey), (getValueUserItemCounter(customerAddress, itemKey) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
97 | + | } | |
98 | + | } | |
99 | + | ||
100 | + | ||
78 | 101 | @Verifier(tx) | |
79 | 102 | func verify () = { | |
80 | 103 | let signedAlice = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyAlice)) | |
81 | 104 | then true | |
82 | 105 | else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyAlice)) | |
83 | 106 | then true | |
84 | 107 | else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyAlice)) | |
85 | 108 | then 1 | |
86 | 109 | else 0 | |
87 | 110 | let signedBob = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyBob)) | |
88 | 111 | then true | |
89 | 112 | else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyBob)) | |
90 | 113 | then true | |
91 | 114 | else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyBob)) | |
92 | 115 | then 1 | |
93 | 116 | else 0 | |
94 | 117 | let signedCooper = if (if (if (sigVerify(tx.bodyBytes, tx.proofs[0], pubKeyCooper)) | |
95 | 118 | then true | |
96 | 119 | else sigVerify(tx.bodyBytes, tx.proofs[1], pubKeyCooper)) | |
97 | 120 | then true | |
98 | 121 | else sigVerify(tx.bodyBytes, tx.proofs[2], pubKeyCooper)) | |
99 | 122 | then 1 | |
100 | 123 | else 0 | |
101 | 124 | match tx { | |
102 | 125 | case d: SetScriptTransaction => | |
103 | 126 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
104 | 127 | case d: DataTransaction => | |
105 | 128 | true | |
106 | 129 | case _ => | |
107 | 130 | (((signedAlice + signedBob) + signedCooper) >= 2) | |
108 | 131 | } | |
109 | 132 | } | |
110 | 133 |
github/deemru/w8io/026f985 37.90 ms ◑