tx · AhCShtmr2zhZntHaY2xHSQXqikxVL5gc8Xf9MecTM2hV
3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni: -0.01400000 Waves
2019.08.19 14:20 [637962] smart account 3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni > SELF 0.00000000 Waves
{
"type": 13,
"id": "AhCShtmr2zhZntHaY2xHSQXqikxVL5gc8Xf9MecTM2hV",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1566213652899,
"version": 1,
"sender": "3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni",
"senderPublicKey": "5qEf6v7n4Cm55KWEaSs76eUft3uwLezLoJeBrf6u9BKE",
"proofs": [
"3n9duRzYiprtAnTAjV5QUs3FPiR4PnbwfZEs7puuxSMzSPt7LuynTgZtQegBaKVgPFysNgNRt2pVs4vPqEuTYXjU"
],
"script": "base64:AAIDAAAAAAAAAAAAAAAFAAAAAAp3YXZlc1Rva2VuBQAAAAR1bml0AQAAAAlwYXltZW50T2YAAAABAAAAA2tleQkAASwAAAACAgAAAAtwYXltZW50X29mXwUAAAADa2V5AQAAAAhzdGF0dXNPZgAAAAEAAAADa2V5CQABLAAAAAICAAAACnN0YXR1c19vZl8FAAAAA2tleQAAAAAFb3duZXIJAQAAAAV2YWx1ZQAAAAEJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM041aFFtNnR3VmhGZ2Y4bUtCa0pwTmh4d2NCbnBac1B5bmkBAAAAEGlzUGF5bWVudFBlbmRpbmcAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzCQABLAAAAAICAAAACnN0YXR1c19vZl8FAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFzBQAAAAckbWF0Y2gwCQAAAAAAAAIFAAAAAXMCAAAAB3BlbmRpbmcHAAAAAwAAAAFpAQAAABBzZXRXYWl0VG9QYXltZW50AAAAA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SBoYXMgYmVlbiBwYXllZCBvciByZWplY3RlZAAAAAFpAQAAAAZyZWplY3QAAAABAAAAA2tleQMJAQAAABBpc1BheW1lbnRQZW5kaW5nAAAAAQUAAAADa2V5CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAIc3RhdHVzT2YAAAABBQAAAANrZXkCAAAACHJlamVjdGVkBQAAAANuaWwJAAACAAAAAQIAAAAoT3JkZXIgYWxyZWFkeSBoYXMgYmVlbiBwYXllZCBvciByZWplY3RlZAAAAAARzhSF",
"chainId": 84,
"height": 637962,
"spentComplexity": 0
}
View: original | compacted
Prev: CSrrtvcWK5PNkVHx3SH6JA5dhUhrLqw3QC1kKeP7Rzay
Next: qPgECP2aQ4ByJYJqfoF3ZCAPGyXxuzjq8jLp4XeVC8W
Diff:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let ownerKey = "owner" |
---|
5 | | - | |
---|
6 | 4 | | let wavesToken = unit |
---|
7 | 5 | | |
---|
8 | 6 | | func paymentOf (key) = ("payment_of_" + key) |
---|
|
11 | 9 | | func statusOf (key) = ("status_of_" + key) |
---|
12 | 10 | | |
---|
13 | 11 | | |
---|
14 | | - | let owner = addressFromStringValue(value(getString(this, ownerKey))) |
---|
| 12 | + | let owner = value(addressFromStringValue("3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni")) |
---|
15 | 13 | | |
---|
16 | 14 | | func isPaymentPending (key) = match getString(this, ("status_of_" + key)) { |
---|
17 | 15 | | case s: String => |
---|
|
19 | 17 | | case _ => |
---|
20 | 18 | | false |
---|
21 | 19 | | } |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | @Callable(i) |
---|
25 | | - | func init (owner,token) = if ((i.caller == this)) |
---|
26 | | - | then WriteSet([DataEntry(ownerKey, owner)]) |
---|
27 | | - | else throw("only dapp itself can init") |
---|
28 | | - | |
---|
29 | 20 | | |
---|
30 | 21 | | |
---|
31 | 22 | | @Callable(i) |
---|
|
39 | 30 | | case a: AttachedPayment => |
---|
40 | 31 | | if ((a.assetId == unit)) |
---|
41 | 32 | | then { |
---|
42 | | - | let data = WriteSet([DataEntry("status_of_test", "paid")]) |
---|
43 | | - | ScriptResult(data, TransferSet([ScriptTransfer(Address(base58'3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni'), 10, wavesToken)])) |
---|
| 33 | + | let data = WriteSet([DataEntry(statusOf(key), "paid")]) |
---|
| 34 | + | let payment = extract(getInteger(this, paymentOf(key))) |
---|
| 35 | + | ScriptResult(data, TransferSet([ScriptTransfer(owner, payment, wavesToken)])) |
---|
44 | 36 | | } |
---|
45 | | - | else throw("can only WAVES, but got ") |
---|
| 37 | + | else throw(("can only WAVES, but got " + toBase58String(value(a.assetId)))) |
---|
46 | 38 | | case _ => |
---|
47 | 39 | | throw("payment in assetTokens must be attached") |
---|
48 | 40 | | } |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let ownerKey = "owner" |
---|
5 | | - | |
---|
6 | 4 | | let wavesToken = unit |
---|
7 | 5 | | |
---|
8 | 6 | | func paymentOf (key) = ("payment_of_" + key) |
---|
9 | 7 | | |
---|
10 | 8 | | |
---|
11 | 9 | | func statusOf (key) = ("status_of_" + key) |
---|
12 | 10 | | |
---|
13 | 11 | | |
---|
14 | | - | let owner = addressFromStringValue(value(getString(this, ownerKey))) |
---|
| 12 | + | let owner = value(addressFromStringValue("3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni")) |
---|
15 | 13 | | |
---|
16 | 14 | | func isPaymentPending (key) = match getString(this, ("status_of_" + key)) { |
---|
17 | 15 | | case s: String => |
---|
18 | 16 | | (s == "pending") |
---|
19 | 17 | | case _ => |
---|
20 | 18 | | false |
---|
21 | 19 | | } |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | @Callable(i) |
---|
25 | | - | func init (owner,token) = if ((i.caller == this)) |
---|
26 | | - | then WriteSet([DataEntry(ownerKey, owner)]) |
---|
27 | | - | else throw("only dapp itself can init") |
---|
28 | | - | |
---|
29 | 20 | | |
---|
30 | 21 | | |
---|
31 | 22 | | @Callable(i) |
---|
32 | 23 | | func setWaitToPayment (key,payment) = WriteSet([DataEntry(statusOf(key), "pending"), DataEntry(paymentOf(key), payment)]) |
---|
33 | 24 | | |
---|
34 | 25 | | |
---|
35 | 26 | | |
---|
36 | 27 | | @Callable(i) |
---|
37 | 28 | | func pay (key) = if (isPaymentPending(key)) |
---|
38 | 29 | | then match i.payment { |
---|
39 | 30 | | case a: AttachedPayment => |
---|
40 | 31 | | if ((a.assetId == unit)) |
---|
41 | 32 | | then { |
---|
42 | | - | let data = WriteSet([DataEntry("status_of_test", "paid")]) |
---|
43 | | - | ScriptResult(data, TransferSet([ScriptTransfer(Address(base58'3N5hQm6twVhFgf8mKBkJpNhxwcBnpZsPyni'), 10, wavesToken)])) |
---|
| 33 | + | let data = WriteSet([DataEntry(statusOf(key), "paid")]) |
---|
| 34 | + | let payment = extract(getInteger(this, paymentOf(key))) |
---|
| 35 | + | ScriptResult(data, TransferSet([ScriptTransfer(owner, payment, wavesToken)])) |
---|
44 | 36 | | } |
---|
45 | | - | else throw("can only WAVES, but got ") |
---|
| 37 | + | else throw(("can only WAVES, but got " + toBase58String(value(a.assetId)))) |
---|
46 | 38 | | case _ => |
---|
47 | 39 | | throw("payment in assetTokens must be attached") |
---|
48 | 40 | | } |
---|
49 | 41 | | else throw("Order already has been payed or rejected") |
---|
50 | 42 | | |
---|
51 | 43 | | |
---|
52 | 44 | | |
---|
53 | 45 | | @Callable(i) |
---|
54 | 46 | | func reject (key) = if (isPaymentPending(key)) |
---|
55 | 47 | | then WriteSet([DataEntry(statusOf(key), "rejected")]) |
---|
56 | 48 | | else throw("Order already has been payed or rejected") |
---|
57 | 49 | | |
---|
58 | 50 | | |
---|