tx · 5cnrbEwjRJSpQFMjXT8psszopyha9XTBYdCXKStfb1AY
3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r: -0.04000000 Waves
2022.01.13 17:29 [1877301] smart account 3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r > SELF 0.00000000 Waves
{
"type": 13,
"id": "5cnrbEwjRJSpQFMjXT8psszopyha9XTBYdCXKStfb1AY",
"fee": 4000000,
"feeAssetId": null,
"timestamp": 1642084194153,
"version": 2,
"chainId": 84,
"sender": "3N9R7u449Z1b76QpJp9u3gzPjMYQYnp3V7r",
"senderPublicKey": "GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY",
"proofs": [
"4i9wwDFAeS3VjpwUD6nBaxKs2unX8HdenfJyDd2TRZSpmciCFtbZrj5xEEJ31xwjCKETGbpa9hed9SqjRVPc3q8"
],
"script": "base64:AAIFAAAAAAAAASUIAhIFCgMICAgSAwoBCBoWCgFhEhFob2xkaW5nc1B1YmxpY0tleRoUCgFiEg9ob2xkaW5nc0FkZHJlc3MaFAoBYxIPdHJhbnNmZXJDb3N0UGN0GgYKAWQSAWkaDAoBZRIHb3duZXJJZBoMCgFmEgdhc3NldElkGgsKAWcSBmFtb3VudBoQCgFoEgtvd25lcklkRGF0YRoMCgFpEgckbWF0Y2gwGgYKAWoSAXgaEgoBaxINcGF5bWVudEFtb3VudBodCgFsEhhhbW91bnRUb1JlbWFpbkluSG9sZGluZ3MaHAoBbRIXYW1vdW50VG9UcmFuc2ZlclRvT3duZXIaEQoBbhIMb3duZXJBZGRyZXNzGgcKAW8SAnR4GgsKAXASBnZlcmlmeQAAAAMAAAAAAWEBAAAAIOXdIUWzo+xH6Wo3eUXXdqXp3i8rCPbDs0z4AYmX0NtvAAAAAAFiCQEAAAAUYWRkcmVzc0Zyb21QdWJsaWNLZXkAAAABBQAAAAFhAAAAAAFjAAAAAAAAAAAZAAAAAgAAAAFkAQAAABFhZGRPd25lckFuZEFtb3VudAAAAAMA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bHNlAAAAAgUAAAABaAIAAAAHbm90aGluZwMDCQAAAAAAAAIFAAAAAWcAAAAAAAAAAAAGCQAAZgAAAAIFAAAAAWcFAAAAAWsJAAACAAAAAQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAzUGF5bWVudCBhbmQgYW1vdW50IGRvIG5vdCBtYXRjaC4gVGhpcyBhc3NldHMgY29zdHMgCQABpAAAAAEFAAAAAWcCAAAADWJ1dCB5b3Ugc2VudCAJAAGkAAAAAQUAAAABawQAAAABbAkAAGgAAAACBQAAAAFrCQAAaQAAAAIFAAAAAWMAAAAAAAAAA+gEAAAAAW0JAABlAAAAAgUAAAABawUAAAABbAQAAAABbgkBAAAAB0FkZHJlc3MAAAABCQABmwAAAAEFAAAAAWUJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWQAAAAGY2FsbGVyAAAAAAAAAAABCQACWQAAAAEFAAAAAWYJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAABbgUAAAABbQUAAAAEdW5pdAUAAAADbmlsAAAAAQAAAAFvAQAAAAFwAAAAAAkAAfQAAAADCAUAAAABbwAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAW8AAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAABbwAAAA9zZW5kZXJQdWJsaWNLZXlrICSy",
"height": 1877301,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: C1AZcjvKCf1xw3vAhKY7KyP48cjTTcyd6utuYEFxna6v
Next: HhqFXZzuydjAad3oFCbkTC72rNiyrtN7iCYAjGL5fA1k
Diff:
Old | New | | Differences |
---|
14 | 14 | | |
---|
15 | 15 | | @Callable(i) |
---|
16 | 16 | | func buyFromHoldings (assetId) = { |
---|
17 | | - | let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) { |
---|
| 17 | + | let ownerIdData = getString(this, (("sale_" + assetId) + "_originalOwner")) |
---|
| 18 | + | let ownerId = match ownerIdData { |
---|
18 | 19 | | case _: Unit => |
---|
19 | 20 | | "unset" |
---|
20 | 21 | | case x: String => |
---|
|
32 | 33 | | throw("Match error") |
---|
33 | 34 | | } |
---|
34 | 35 | | if ((ownerId == "unset")) |
---|
35 | | - | then throw(("Original owner not found " + ownerId)) |
---|
| 36 | + | then throw(("Original owner not found " + valueOrElse(ownerIdData, "nothing"))) |
---|
36 | 37 | | else if (if ((amount == 0)) |
---|
37 | 38 | | then true |
---|
38 | 39 | | else (amount > paymentAmount)) |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 5 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let holdingsPublicKey = base58'GUHw1jkstNWTs9SX1KM3pMtq9HXjupvxiTd1urNhNoyY' |
---|
5 | 5 | | |
---|
6 | 6 | | let holdingsAddress = addressFromPublicKey(holdingsPublicKey) |
---|
7 | 7 | | |
---|
8 | 8 | | let transferCostPct = 25 |
---|
9 | 9 | | |
---|
10 | 10 | | @Callable(i) |
---|
11 | 11 | | func addOwnerAndAmount (ownerId,assetId,amount) = [StringEntry((("sale_" + assetId) + "_originalOwner"), ownerId), StringEntry((("sale_" + assetId) + "_amount"), amount)] |
---|
12 | 12 | | |
---|
13 | 13 | | |
---|
14 | 14 | | |
---|
15 | 15 | | @Callable(i) |
---|
16 | 16 | | func buyFromHoldings (assetId) = { |
---|
17 | | - | let ownerId = match getString(this, (("sale_" + assetId) + "_originalOwner")) { |
---|
| 17 | + | let ownerIdData = getString(this, (("sale_" + assetId) + "_originalOwner")) |
---|
| 18 | + | let ownerId = match ownerIdData { |
---|
18 | 19 | | case _: Unit => |
---|
19 | 20 | | "unset" |
---|
20 | 21 | | case x: String => |
---|
21 | 22 | | "unset" |
---|
22 | 23 | | case _ => |
---|
23 | 24 | | throw("Match error") |
---|
24 | 25 | | } |
---|
25 | 26 | | let paymentAmount = valueOrElse(i.payments[0].amount, 0) |
---|
26 | 27 | | let amount = match getString(this, (("sale_" + assetId) + "_amount")) { |
---|
27 | 28 | | case _: Unit => |
---|
28 | 29 | | 0 |
---|
29 | 30 | | case x: String => |
---|
30 | 31 | | (valueOrElse(parseInt(x), 0) * 100000000) |
---|
31 | 32 | | case _ => |
---|
32 | 33 | | throw("Match error") |
---|
33 | 34 | | } |
---|
34 | 35 | | if ((ownerId == "unset")) |
---|
35 | | - | then throw(("Original owner not found " + ownerId)) |
---|
| 36 | + | then throw(("Original owner not found " + valueOrElse(ownerIdData, "nothing"))) |
---|
36 | 37 | | else if (if ((amount == 0)) |
---|
37 | 38 | | then true |
---|
38 | 39 | | else (amount > paymentAmount)) |
---|
39 | 40 | | then throw(((("Payment and amount do not match. This assets costs " + toString(amount)) + "but you sent ") + toString(paymentAmount))) |
---|
40 | 41 | | else { |
---|
41 | 42 | | let amountToRemainInHoldings = (paymentAmount * (transferCostPct / 1000)) |
---|
42 | 43 | | let amountToTransferToOwner = (paymentAmount - amountToRemainInHoldings) |
---|
43 | 44 | | let ownerAddress = Address(toBytes(ownerId)) |
---|
44 | 45 | | [ScriptTransfer(i.caller, 1, fromBase58String(assetId)), ScriptTransfer(ownerAddress, amountToTransferToOwner, unit)] |
---|
45 | 46 | | } |
---|
46 | 47 | | } |
---|
47 | 48 | | |
---|
48 | 49 | | |
---|
49 | 50 | | @Verifier(tx) |
---|
50 | 51 | | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
51 | 52 | | |
---|