tx · 2F9oh357sBXUQrcGcuHJkdKmmKHSCsihzHQQupNU3JhW 3MyXnDWMtqpfkuFJtyBHaUWoWxtGoD8SpBQ: -0.01400000 Waves 2020.11.20 15:39 [1273711] smart account 3MyXnDWMtqpfkuFJtyBHaUWoWxtGoD8SpBQ > SELF 0.00000000 Waves
{ "type": 13, "id": "2F9oh357sBXUQrcGcuHJkdKmmKHSCsihzHQQupNU3JhW", "fee": 1400000, "feeAssetId": null, "timestamp": 1605876076680, "version": 2, "chainId": 84, "sender": "3MyXnDWMtqpfkuFJtyBHaUWoWxtGoD8SpBQ", "senderPublicKey": "FYobWqooJHEVQFRHr8NU7ewYZ2AJdMzuDBm8WR9PiAx1", "proofs": [ "5MtbJQK6VgxFqfDKJFn1uhKyYPbUvnG4EmHxzPw3Dhs3eC6xfd7DaL38fc3FsosQzJiLWdAsmuDu8xfi82wojquJ" ], "script": "base64:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAABAAAAAAEWFjY291bnQxUHVibGljS2V5AQAAACD3jXgw7OE1lYUdW8zpPeJRbBzq2i/QfxUY9F31TI9ITgAAAAARYWNjb3VudDJQdWJsaWNLZXkBAAAAIBtXv2hMCq7TJHKvVsoiywB7SjyYC3f6AKFF3CrlAyIVAAAAAA5vdGhlclB1YmxpY0tleQEAAAAg525Riaa48RgJvYxM/FeTNEzhBum4Tb2zEKrgTa8dHVoAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAA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WwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAlzaWduYXR1cmUJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAFAAAACXNpZ25hdHVyZQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBQAAAAlzaWduYXR1cmUFAAAACXNpZ25hdHVyZZilZd0=", "height": 1273711, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8PkN6BuduVRnrCLbyonx3B8Qq5ZB3nTnCTkwvQpv8Qer Next: 3P99T9HihyjJaLKhecAJFRxsmZ6x2zbiHut6GpEunhB9 Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv' | |
7 | 7 | ||
8 | 8 | let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw' | |
9 | + | ||
10 | + | let NONE = "none" | |
11 | + | ||
12 | + | func getNumberByKey (key) = { | |
13 | + | let num = match getInteger(this, key) { | |
14 | + | case a: Int => | |
15 | + | a | |
16 | + | case _ => | |
17 | + | 0 | |
18 | + | } | |
19 | + | num | |
20 | + | } | |
21 | + | ||
22 | + | ||
23 | + | func getStrByKey (key) = { | |
24 | + | let str = match getString(this, key) { | |
25 | + | case a: String => | |
26 | + | a | |
27 | + | case _ => | |
28 | + | NONE | |
29 | + | } | |
30 | + | str | |
31 | + | } | |
32 | + | ||
33 | + | ||
34 | + | func getKeyItemPrice (item) = (item + "_price") | |
35 | + | ||
36 | + | ||
37 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
38 | + | ||
39 | + | ||
40 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
41 | + | ||
42 | + | ||
43 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
44 | + | ||
45 | + | ||
46 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
47 | + | ||
48 | + | ||
49 | + | func getKeyItemData (item) = (item + "_data") | |
50 | + | ||
51 | + | ||
52 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
53 | + | ||
54 | + | ||
55 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
56 | + | ||
57 | + | ||
58 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
59 | + | ||
60 | + | ||
61 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
62 | + | ||
9 | 63 | ||
10 | 64 | @Callable(i) | |
11 | 65 | func purchase (coupon) = { | |
33 | 87 | } | |
34 | 88 | ||
35 | 89 | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func addItem (title,price,data) = { | |
93 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
94 | + | let item = getKeyItem(supplierAddress, title) | |
95 | + | if ((0 >= price)) | |
96 | + | then throw("purchase amount cannot be less than item price") | |
97 | + | else if ((getValueItemSupplier(item) != NONE)) | |
98 | + | then throw("an item already exist") | |
99 | + | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)] | |
100 | + | } | |
101 | + | ||
102 | + | ||
36 | 103 | @Verifier(tx) | |
37 | 104 | func verify () = { | |
38 | - | let account1 = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], account1PublicKey)) | |
39 | - | then true | |
40 | - | else sigVerify(tx.bodyBytes, tx.proofs[1], account1PublicKey)) | |
41 | - | then true | |
42 | - | else sigVerify(tx.bodyBytes, tx.proofs[2], account1PublicKey) | |
43 | - | let account2 = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], account2PublicKey)) | |
44 | - | then true | |
45 | - | else sigVerify(tx.bodyBytes, tx.proofs[1], account2PublicKey)) | |
46 | - | then true | |
47 | - | else sigVerify(tx.bodyBytes, tx.proofs[2], account2PublicKey) | |
48 | - | let other = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], otherPublicKey)) | |
49 | - | then true | |
50 | - | else sigVerify(tx.bodyBytes, tx.proofs[1], otherPublicKey)) | |
51 | - | then true | |
52 | - | else sigVerify(tx.bodyBytes, tx.proofs[2], otherPublicKey) | |
53 | - | let account1account2 = if (account1) | |
54 | - | then account2 | |
55 | - | else false | |
56 | - | let account1other = if (account1) | |
57 | - | then other | |
58 | - | else false | |
59 | - | let account2other = if (other) | |
60 | - | then account2 | |
61 | - | else false | |
105 | + | let signature = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
62 | 106 | match tx { | |
63 | 107 | case d: SetScriptTransaction => | |
64 | - | | |
108 | + | signature | |
65 | 109 | case d: DataTransaction => | |
66 | - | | |
110 | + | signature | |
67 | 111 | case _ => | |
68 | - | if (if (account1account2) | |
69 | - | then true | |
70 | - | else account1other) | |
71 | - | then true | |
72 | - | else account2other | |
112 | + | signature | |
73 | 113 | } | |
74 | 114 | } | |
75 | 115 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd' | |
5 | 5 | ||
6 | 6 | let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv' | |
7 | 7 | ||
8 | 8 | let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw' | |
9 | + | ||
10 | + | let NONE = "none" | |
11 | + | ||
12 | + | func getNumberByKey (key) = { | |
13 | + | let num = match getInteger(this, key) { | |
14 | + | case a: Int => | |
15 | + | a | |
16 | + | case _ => | |
17 | + | 0 | |
18 | + | } | |
19 | + | num | |
20 | + | } | |
21 | + | ||
22 | + | ||
23 | + | func getStrByKey (key) = { | |
24 | + | let str = match getString(this, key) { | |
25 | + | case a: String => | |
26 | + | a | |
27 | + | case _ => | |
28 | + | NONE | |
29 | + | } | |
30 | + | str | |
31 | + | } | |
32 | + | ||
33 | + | ||
34 | + | func getKeyItemPrice (item) = (item + "_price") | |
35 | + | ||
36 | + | ||
37 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
38 | + | ||
39 | + | ||
40 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
41 | + | ||
42 | + | ||
43 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
44 | + | ||
45 | + | ||
46 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
47 | + | ||
48 | + | ||
49 | + | func getKeyItemData (item) = (item + "_data") | |
50 | + | ||
51 | + | ||
52 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
53 | + | ||
54 | + | ||
55 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
56 | + | ||
57 | + | ||
58 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
59 | + | ||
60 | + | ||
61 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
62 | + | ||
9 | 63 | ||
10 | 64 | @Callable(i) | |
11 | 65 | func purchase (coupon) = { | |
12 | 66 | let pmt = value(i.payments) | |
13 | 67 | if (isDefined(pmt[0].assetId)) | |
14 | 68 | then throw("only wws") | |
15 | 69 | else { | |
16 | 70 | let customerAddress = toBase58String(i.caller.bytes) | |
17 | 71 | let price = match getInteger(this, (coupon + "_coupon_price")) { | |
18 | 72 | case a: Int => | |
19 | 73 | a | |
20 | 74 | case _ => | |
21 | 75 | 0 | |
22 | 76 | } | |
23 | 77 | if ((price == 0)) | |
24 | 78 | then throw("coupon not found") | |
25 | 79 | else if ((price > pmt[0].amount)) | |
26 | 80 | then throw("moar moeny") | |
27 | 81 | else if ((pmt[0].amount > price)) | |
28 | 82 | then throw(toString(price)) | |
29 | 83 | else if ((size(pmt) > 1)) | |
30 | 84 | then throw("single item only") | |
31 | 85 | else [StringEntry(((("status:purchase_" + coupon) + "_customer_") + customerAddress), "confirmed"), IntegerEntry(((("price:purchase_" + coupon) + "_customer_") + customerAddress), price)] | |
32 | 86 | } | |
33 | 87 | } | |
34 | 88 | ||
35 | 89 | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func addItem (title,price,data) = { | |
93 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
94 | + | let item = getKeyItem(supplierAddress, title) | |
95 | + | if ((0 >= price)) | |
96 | + | then throw("purchase amount cannot be less than item price") | |
97 | + | else if ((getValueItemSupplier(item) != NONE)) | |
98 | + | then throw("an item already exist") | |
99 | + | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)] | |
100 | + | } | |
101 | + | ||
102 | + | ||
36 | 103 | @Verifier(tx) | |
37 | 104 | func verify () = { | |
38 | - | let account1 = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], account1PublicKey)) | |
39 | - | then true | |
40 | - | else sigVerify(tx.bodyBytes, tx.proofs[1], account1PublicKey)) | |
41 | - | then true | |
42 | - | else sigVerify(tx.bodyBytes, tx.proofs[2], account1PublicKey) | |
43 | - | let account2 = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], account2PublicKey)) | |
44 | - | then true | |
45 | - | else sigVerify(tx.bodyBytes, tx.proofs[1], account2PublicKey)) | |
46 | - | then true | |
47 | - | else sigVerify(tx.bodyBytes, tx.proofs[2], account2PublicKey) | |
48 | - | let other = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], otherPublicKey)) | |
49 | - | then true | |
50 | - | else sigVerify(tx.bodyBytes, tx.proofs[1], otherPublicKey)) | |
51 | - | then true | |
52 | - | else sigVerify(tx.bodyBytes, tx.proofs[2], otherPublicKey) | |
53 | - | let account1account2 = if (account1) | |
54 | - | then account2 | |
55 | - | else false | |
56 | - | let account1other = if (account1) | |
57 | - | then other | |
58 | - | else false | |
59 | - | let account2other = if (other) | |
60 | - | then account2 | |
61 | - | else false | |
105 | + | let signature = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
62 | 106 | match tx { | |
63 | 107 | case d: SetScriptTransaction => | |
64 | - | | |
108 | + | signature | |
65 | 109 | case d: DataTransaction => | |
66 | - | | |
110 | + | signature | |
67 | 111 | case _ => | |
68 | - | if (if (account1account2) | |
69 | - | then true | |
70 | - | else account1other) | |
71 | - | then true | |
72 | - | else account2other | |
112 | + | signature | |
73 | 113 | } | |
74 | 114 | } | |
75 | 115 |
github/deemru/w8io/169f3d6 37.96 ms ◑