tx · BDkMF8YL9aCgQW2nKnhiVqMJK5KsJei2P35xPFFGA4n7 3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r: -0.04000000 Waves 2022.03.29 20:29 [1985515] smart account 3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r > SELF 0.00000000 Waves
{ "type": 13, "id": "BDkMF8YL9aCgQW2nKnhiVqMJK5KsJei2P35xPFFGA4n7", "fee": 4000000, "feeAssetId": null, "timestamp": 1648574994615, "version": 2, "chainId": 84, "sender": "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r", "senderPublicKey": "GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY", "proofs": [ "2XwvH58qyup35xSx7rcm6WDhBP68fgxbDzhr7RPShasWqkusELkL9YFpTnkzy7gVY7eFPNwtTQgWzB2GTNvBPEhx" ], "script": "base64:AAIFAAAAAAAAABMIAhIFCgMICAESAwoBCBIDCgEIAAAABwAAAAAOZEFwcEFkZHJlc3NTdHICAAAAIzNONHZxVVhXdzh0ZjIzTERXRGJTRXBKWkg2ZGVudDNFVEZ1AAAAAA1kQXBwUHVibGljS2V5AQAAACCzTPDXKuB0zaBQL2OyxsOCbI4Rkb6W1CjA/1Wz1uFLVwAAAAALZEFwcEFkZHJlc3MJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAADWRBcHBQdWJsaWNLZXkAAAAAEmhvbGRpbmdzQWRkcmVzc1N0cgIAAAAjM045Ujd1NDQ5WjFiNzZRcEpwOXUzZ3pQak1ZUVlucDNWN3IAAAAAEWhvbGRpbmdzUHVibGljS2V5AQAAACDl3SFFs6PsR+lqN3lF13al6d4vKwj2w7NM+AGJl9DbbwAAAAAPaG9sZGluZ3NBZGRyZXNzCQEAAAAUYWRkcmVzc0Zyb21QdWJsaWNLZXkAAAABBQAAABFob2xkaW5nc1B1YmxpY0tleQAAAAAPdHJhbnNmZXJDb3N0UGN0AAAAAAAAAAAyAAAAAwAAAAFpAQ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AAAPdHJhbnNmZXJDb3N0UGN0BAAAABdhbW91bnRUb1RyYW5zZmVyVG9Pd25lcgkAAGUAAAACBQAAAA1wYXltZW50QW1vdW50BQAAABhhbW91bnRUb1JlbWFpbkluSG9sZGluZ3MEAAAADG93bmVyQWRkcmVzcwkBAAAAB0FkZHJlc3MAAAABCQACWQAAAAEFAAAAB293bmVySWQJAAROAAAAAgUAAAAIdHJhbnNmZXIJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAMb3duZXJBZGRyZXNzBQAAABdhbW91bnRUb1RyYW5zZmVyVG9Pd25lcgUAAAAEdW5pdAUAAAADbmlsBQAAAAh0cmFuc2ZlcgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAAAwMJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BgkAAAAAAAACCQEAAAAUYWRkcmVzc0Zyb21QdWJsaWNLZXkAAAABCAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BQAAAA9ob2xkaW5nc0FkZHJlc3MGCQAAAAAAAAIJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkFAAAAC2RBcHBBZGRyZXNzDVAuqw==", "height": 1985515, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EEjSXYunekwFJjcXwoL6ukoaJSJjLv3vCdi5cZYenKDf Next: EauHYAnjvbPtrTwbGfq1r2jbjsMFZUEMEkNiSFXihXzD Diff:
Old | New | Differences | |
---|---|---|---|
71 | 71 | else (amount > paymentAmount)) | |
72 | 72 | then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount))) | |
73 | 73 | else { | |
74 | - | let res = invoke(dAppAddress, "finalizeSale", [assetId, ownerId], [AttachedPayment(unit, 0)]) | |
74 | + | let callerId = toBase58String(i.caller.bytes) | |
75 | + | let res = invoke(dAppAddress, "finalizeSale", [assetId, callerId], [AttachedPayment(unit, 0)]) | |
75 | 76 | if ((res == res)) | |
76 | 77 | then { | |
77 | 78 | let transfer = [ScriptTransfer(i.caller, 1, fromBase58String(assetId)), StringEntry((("sale_" + assetId) + "_originalOwner"), ""), IntegerEntry((("sale_" + assetId) + "_amount"), 0)] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let dAppAddressStr = "3N4vqUXWw8tf23LDWDbSEpJZH6dent3ETFu" | |
5 | 5 | ||
6 | 6 | let dAppPublicKey = base58'D4v2S9mjah7eEEmuQVBNd4WipC3scs8V4PjuDBweWatE' | |
7 | 7 | ||
8 | 8 | let dAppAddress = addressFromPublicKey(dAppPublicKey) | |
9 | 9 | ||
10 | 10 | let holdingsAddressStr = "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r" | |
11 | 11 | ||
12 | 12 | let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY' | |
13 | 13 | ||
14 | 14 | let holdingsAddress = addressFromPublicKey(holdingsPublicKey) | |
15 | 15 | ||
16 | 16 | let transferCostPct = 50 | |
17 | 17 | ||
18 | 18 | @Callable(i) | |
19 | 19 | func addOwnerAndAmount (ownerId,assetId,amount) = [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), IntegerEntry((("sale_" + assetId) + "_amount"), amount)] | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | 23 | @Callable(i) | |
24 | 24 | func revokeForSale (assetId) = { | |
25 | 25 | let callerId = toBase58String(i.caller.bytes) | |
26 | 26 | let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) { | |
27 | 27 | case _: Unit => | |
28 | 28 | "unset" | |
29 | 29 | case x: String => | |
30 | 30 | x | |
31 | 31 | case _ => | |
32 | 32 | throw("Match error") | |
33 | 33 | } | |
34 | 34 | if ((callerId != ownerId)) | |
35 | 35 | then throw("Owners do not match") | |
36 | 36 | else { | |
37 | 37 | let res = invoke(dAppAddress, "addOwnerAndAmount", ["", assetId, 0], [AttachedPayment(unit, 0)]) | |
38 | 38 | if ((res == res)) | |
39 | 39 | then [ScriptTransfer(i.caller, 1, fromBase58String(assetId))] | |
40 | 40 | else throw("Strict value is not equal to itself.") | |
41 | 41 | } | |
42 | 42 | } | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | @Callable(i) | |
47 | 47 | func buyFromHoldings (assetId) = { | |
48 | 48 | let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) { | |
49 | 49 | case _: Unit => | |
50 | 50 | "unset" | |
51 | 51 | case x: String => | |
52 | 52 | x | |
53 | 53 | case _ => | |
54 | 54 | throw("Match error") | |
55 | 55 | } | |
56 | 56 | let paymentAmount = valueOrElse(i.payments[0].amount, 0) | |
57 | 57 | let amount = match getInteger(this, (("sale_" + assetId) + "_amount")) { | |
58 | 58 | case _: Unit => | |
59 | 59 | 0 | |
60 | 60 | case x: Int => | |
61 | 61 | x | |
62 | 62 | case _ => | |
63 | 63 | throw("Match error") | |
64 | 64 | } | |
65 | 65 | if (if ((ownerId == "unset")) | |
66 | 66 | then true | |
67 | 67 | else (ownerId == "")) | |
68 | 68 | then throw("Original owner not found ") | |
69 | 69 | else if (if ((amount == 0)) | |
70 | 70 | then true | |
71 | 71 | else (amount > paymentAmount)) | |
72 | 72 | then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount))) | |
73 | 73 | else { | |
74 | - | let res = invoke(dAppAddress, "finalizeSale", [assetId, ownerId], [AttachedPayment(unit, 0)]) | |
74 | + | let callerId = toBase58String(i.caller.bytes) | |
75 | + | let res = invoke(dAppAddress, "finalizeSale", [assetId, callerId], [AttachedPayment(unit, 0)]) | |
75 | 76 | if ((res == res)) | |
76 | 77 | then { | |
77 | 78 | let transfer = [ScriptTransfer(i.caller, 1, fromBase58String(assetId)), StringEntry((("sale_" + assetId) + "_originalOwner"), ""), IntegerEntry((("sale_" + assetId) + "_amount"), 0)] | |
78 | 79 | if ((ownerId != holdingsAddressStr)) | |
79 | 80 | then { | |
80 | 81 | let amountToRemainInHoldings = (paymentAmount / transferCostPct) | |
81 | 82 | let amountToTransferToOwner = (paymentAmount - amountToRemainInHoldings) | |
82 | 83 | let ownerAddress = Address(fromBase58String(ownerId)) | |
83 | 84 | (transfer ++ [ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)]) | |
84 | 85 | } | |
85 | 86 | else transfer | |
86 | 87 | } | |
87 | 88 | else throw("Strict value is not equal to itself.") | |
88 | 89 | } | |
89 | 90 | } | |
90 | 91 | ||
91 | 92 | ||
92 | 93 | @Verifier(tx) | |
93 | 94 | func verify () = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
94 | 95 | then true | |
95 | 96 | else (addressFromPublicKey(tx.senderPublicKey) == holdingsAddress)) | |
96 | 97 | then true | |
97 | 98 | else (addressFromPublicKey(tx.senderPublicKey) == dAppAddress) | |
98 | 99 |
github/deemru/w8io/169f3d6 50.85 ms ◑