tx · J8up4RiDgz5Xik3tYrNmev5JGyhkPZ2FvRDgxsEVjrzV
3N9b7vExDf2qqZt2xG9FUsca7iwLVuih1Ta: -0.01000000 Waves
2023.12.02 10:44 [2868738] smart account 3N9b7vExDf2qqZt2xG9FUsca7iwLVuih1Ta > SELF 0.00000000 Waves
{
"type": 13,
"id": "J8up4RiDgz5Xik3tYrNmev5JGyhkPZ2FvRDgxsEVjrzV",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1701503114436,
"version": 2,
"chainId": 84,
"sender": "3N9b7vExDf2qqZt2xG9FUsca7iwLVuih1Ta",
"senderPublicKey": "4rSYGN3SSXzknh6jLyLqqGdGor584DXdjdP2BAbz7kgt",
"proofs": [
"55BQvR7GaCctyWjxfXn3JoysHoEuAWRj3FFw1YBBnd9Nt2NhEzcoM6M9Cb3xUkUDed7GpRcaaKj4zSqeQod3r3Nz"
],
"script": "base64:AAIFAAAAAAAAABcIAhIGCgQIAQgBEgYKBAgIAQESAwoBCAAAAAwAAAAACWRldmVsb3BlcgkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQIAAAAjM01wNlRUaHZiYjh6OW5wcXo0QUszQnlxQWJ2czdkWVM4dVIBAAAACmtleVBhcnRuZXIAAAABAAAAB2FkZHJlc3MJAAEsAAAAAgIAAAAPJXMlc19fcGFydG5lcl9fBQAAAAdhZGRyZXNzAQAAABBrZXlXYW50ZWRBc3NldElkAAAAAQAAAAdhZGRyZXNzCQABLAAAAAICAAAAFSVzJXNfX3dhbnRlZEFzc2V0SWRfXwUAAAAHYWRkcmVzcwEAAAAPa2V5V2FudGVkQW1vdW50AAAAAQAAAAdhZGRyZXNzCQABLAAAAAICAAAAFCVzJXNfX3dhbnRlZEFtb3VudF9fBQAAAAdhZGRyZXNzAQAAAAprZXlBc3NldElkAAAAAQAAAAdvcmRlcklkCQABLAAAAAICAAAADyVzJXNfX2Fzc2V0SWRfXwUAAAAHb3JkZXJJZAEAAAAJa2V5QW1vdW50AAAAAQA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3NldElkAAAAAQUAAAAHb3JkZXJJZAQAAAAKYXNzZXRJZFJhdwkABB0AAAACBQAAAAR0aGlzBQAAAAphc3NldElkS2V5BAAAAAphc3NldElkU3RyCQEAAAAFdmFsdWUAAAABBQAAAAphc3NldElkUmF3CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAKcmVzdEFtb3VudAkBAAAAB2Zyb21TdHIAAAABBQAAAAphc3NldElkU3RyCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAACWRldmVsb3BlcgkBAAAAEUBleHRyTmF0aXZlKDEwNTUpAAAAAQkBAAAADWtleVNlcnZpY2VGZWUAAAABBQAAAAdvcmRlcklkCQEAAAAHZnJvbVN0cgAAAAEFAAAACmFzc2V0SWRTdHIJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAADWtleVNlcnZpY2VGZWUAAAABBQAAAAdvcmRlcklkCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEJAQAAAAlrZXlBbW91bnQAAAABBQAAAAdvcmRlcklkCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEJAQAAAAprZXlPcmRlcklkAAAAAgUAAAAHb3JkZXJJZAkABCUAAAABCAUAAAABaQAAAAZjYWxsZXIJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAACmtleUFzc2V0SWQAAAABBQAAAAdvcmRlcklkBQAAAANuaWwAAAAAsCi9kA==",
"height": 2868738,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 6ZZGDGFNQLjXvU6jGVaZjyYx1cWQNoYvkLuftQqZ1awE
Next: B3kNCXBdMjnmy3769mVHjJgKoaGSeijuyKnm3bHCZtqu
Diff:
Old | New | | Differences |
---|
18 | 18 | | func keyAmount (orderId) = ("%s%s__amount__" + orderId) |
---|
19 | 19 | | |
---|
20 | 20 | | |
---|
21 | | - | func keyOrderId (orderId) = ("%s%s__orderId__" + orderId) |
---|
| 21 | + | func keyOrderId (orderId,caller) = ((("%s%s__orderId__" + orderId) + "__") + caller) |
---|
22 | 22 | | |
---|
23 | 23 | | |
---|
24 | 24 | | func keyServiceFee (orderId) = ("%s%s__serviceFee__" + orderId) |
---|
|
48 | 48 | | |
---|
49 | 49 | | |
---|
50 | 50 | | @Callable(i) |
---|
51 | | - | func escrow (orderId,amount,assetId,developerFee) = if (isDefined(getString(this, keyOrderId(orderId)))) |
---|
| 51 | + | func escrow (orderId,amount,assetId,developerFee) = if (isDefined(getString(this, keyOrderId(orderId, toString(i.caller))))) |
---|
52 | 52 | | then throw(("You already have an order with this id: " + orderId)) |
---|
53 | 53 | | else if ((0 >= amount)) |
---|
54 | 54 | | then throw("Non-positive order amount") |
---|
55 | 55 | | else { |
---|
56 | 56 | | let orderAmount = (amount - developerFee) |
---|
57 | | - | [IntegerEntry(keyServiceFee(orderId), developerFee), IntegerEntry(keyAmount(orderId), orderAmount), StringEntry(keyOrderId(orderId), orderId), StringEntry(keyAssetId(orderId), assetId)] |
---|
| 57 | + | [IntegerEntry(keyServiceFee(orderId), developerFee), IntegerEntry(keyAmount(orderId), orderAmount), StringEntry(keyOrderId(orderId, toString(i.caller)), orderId), StringEntry(keyAssetId(orderId), assetId)] |
---|
58 | 58 | | } |
---|
59 | 59 | | |
---|
60 | 60 | | |
---|
61 | 61 | | |
---|
62 | 62 | | @Callable(i) |
---|
63 | | - | func deal (orderId,address,amount,minAmount) = if (!(isDefined(keyOrderId(orderId)))) |
---|
| 63 | + | func deal (orderId,address,amount,minAmount) = if (!(isDefined(keyOrderId(orderId, toString(i.caller))))) |
---|
64 | 64 | | then throw(("You don't have an order with this id: " + orderId)) |
---|
65 | 65 | | else if ((amount > getIntegerValue(keyAmount(orderId)))) |
---|
66 | 66 | | then throw("The transaction cannot be executed because the seller does not have enough funds") |
---|
|
70 | 70 | | let assetIdRaw = getString(this, assetIdKey) |
---|
71 | 71 | | let assetIdStr = value(assetIdRaw) |
---|
72 | 72 | | if ((minAmount > restAmount)) |
---|
73 | | - | then [ScriptTransfer(addressFromStringValue(address), amount, fromStr(assetIdStr)), ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId)), DeleteEntry(keyAssetId(orderId))] |
---|
| 73 | + | then [ScriptTransfer(addressFromStringValue(address), amount, fromStr(assetIdStr)), ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId, toString(i.caller))), DeleteEntry(keyAssetId(orderId))] |
---|
74 | 74 | | else [ScriptTransfer(addressFromStringValue(address), amount, fromStr(assetIdStr)), DeleteEntry(keyAmount(orderId)), IntegerEntry(keyAmount(orderId), restAmount)] |
---|
75 | 75 | | } |
---|
76 | 76 | | |
---|
77 | 77 | | |
---|
78 | 78 | | |
---|
79 | 79 | | @Callable(i) |
---|
80 | | - | func cancel (orderId) = if (!(isDefined(keyOrderId(orderId)))) |
---|
| 80 | + | func cancel (orderId) = if (!(isDefined(keyOrderId(orderId, toString(i.caller))))) |
---|
81 | 81 | | then throw(("You don't have an order with this id: " + orderId)) |
---|
82 | 82 | | else { |
---|
83 | 83 | | let restAmount = getIntegerValue(keyAmount(orderId)) |
---|
84 | 84 | | let assetIdKey = keyAssetId(orderId) |
---|
85 | 85 | | let assetIdRaw = getString(this, assetIdKey) |
---|
86 | 86 | | let assetIdStr = value(assetIdRaw) |
---|
87 | | - | [ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId)), DeleteEntry(keyAssetId(orderId))] |
---|
| 87 | + | [ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId, toString(i.caller))), DeleteEntry(keyAssetId(orderId))] |
---|
88 | 88 | | } |
---|
89 | 89 | | |
---|
90 | 90 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 5 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let developer = addressFromStringValue("3Mp6TThvbb8z9npqz4AK3ByqAbvs7dYS8uR") |
---|
5 | 5 | | |
---|
6 | 6 | | func keyPartner (address) = ("%s%s__partner__" + address) |
---|
7 | 7 | | |
---|
8 | 8 | | |
---|
9 | 9 | | func keyWantedAssetId (address) = ("%s%s__wantedAssetId__" + address) |
---|
10 | 10 | | |
---|
11 | 11 | | |
---|
12 | 12 | | func keyWantedAmount (address) = ("%s%s__wantedAmount__" + address) |
---|
13 | 13 | | |
---|
14 | 14 | | |
---|
15 | 15 | | func keyAssetId (orderId) = ("%s%s__assetId__" + orderId) |
---|
16 | 16 | | |
---|
17 | 17 | | |
---|
18 | 18 | | func keyAmount (orderId) = ("%s%s__amount__" + orderId) |
---|
19 | 19 | | |
---|
20 | 20 | | |
---|
21 | | - | func keyOrderId (orderId) = ("%s%s__orderId__" + orderId) |
---|
| 21 | + | func keyOrderId (orderId,caller) = ((("%s%s__orderId__" + orderId) + "__") + caller) |
---|
22 | 22 | | |
---|
23 | 23 | | |
---|
24 | 24 | | func keyServiceFee (orderId) = ("%s%s__serviceFee__" + orderId) |
---|
25 | 25 | | |
---|
26 | 26 | | |
---|
27 | 27 | | func getAmount (amount) = amount |
---|
28 | 28 | | |
---|
29 | 29 | | |
---|
30 | 30 | | func toStr (assetId) = if ((assetId == unit)) |
---|
31 | 31 | | then "WAVES" |
---|
32 | 32 | | else toBase58String(value(assetId)) |
---|
33 | 33 | | |
---|
34 | 34 | | |
---|
35 | 35 | | func fromStr (assetIdStr) = if ((assetIdStr == "WAVES")) |
---|
36 | 36 | | then unit |
---|
37 | 37 | | else fromBase58String(assetIdStr) |
---|
38 | 38 | | |
---|
39 | 39 | | |
---|
40 | 40 | | func checkAsset (assetId) = { |
---|
41 | 41 | | let asset = fromStr(assetId) |
---|
42 | 42 | | if (if ((asset != unit)) |
---|
43 | 43 | | then (assetInfo(value(asset)) == unit) |
---|
44 | 44 | | else false) |
---|
45 | 45 | | then throw("Invalid assetId: assetInfo missing") |
---|
46 | 46 | | else toStr(asset) |
---|
47 | 47 | | } |
---|
48 | 48 | | |
---|
49 | 49 | | |
---|
50 | 50 | | @Callable(i) |
---|
51 | | - | func escrow (orderId,amount,assetId,developerFee) = if (isDefined(getString(this, keyOrderId(orderId)))) |
---|
| 51 | + | func escrow (orderId,amount,assetId,developerFee) = if (isDefined(getString(this, keyOrderId(orderId, toString(i.caller))))) |
---|
52 | 52 | | then throw(("You already have an order with this id: " + orderId)) |
---|
53 | 53 | | else if ((0 >= amount)) |
---|
54 | 54 | | then throw("Non-positive order amount") |
---|
55 | 55 | | else { |
---|
56 | 56 | | let orderAmount = (amount - developerFee) |
---|
57 | | - | [IntegerEntry(keyServiceFee(orderId), developerFee), IntegerEntry(keyAmount(orderId), orderAmount), StringEntry(keyOrderId(orderId), orderId), StringEntry(keyAssetId(orderId), assetId)] |
---|
| 57 | + | [IntegerEntry(keyServiceFee(orderId), developerFee), IntegerEntry(keyAmount(orderId), orderAmount), StringEntry(keyOrderId(orderId, toString(i.caller)), orderId), StringEntry(keyAssetId(orderId), assetId)] |
---|
58 | 58 | | } |
---|
59 | 59 | | |
---|
60 | 60 | | |
---|
61 | 61 | | |
---|
62 | 62 | | @Callable(i) |
---|
63 | | - | func deal (orderId,address,amount,minAmount) = if (!(isDefined(keyOrderId(orderId)))) |
---|
| 63 | + | func deal (orderId,address,amount,minAmount) = if (!(isDefined(keyOrderId(orderId, toString(i.caller))))) |
---|
64 | 64 | | then throw(("You don't have an order with this id: " + orderId)) |
---|
65 | 65 | | else if ((amount > getIntegerValue(keyAmount(orderId)))) |
---|
66 | 66 | | then throw("The transaction cannot be executed because the seller does not have enough funds") |
---|
67 | 67 | | else { |
---|
68 | 68 | | let restAmount = (getIntegerValue(keyAmount(orderId)) - amount) |
---|
69 | 69 | | let assetIdKey = keyAssetId(orderId) |
---|
70 | 70 | | let assetIdRaw = getString(this, assetIdKey) |
---|
71 | 71 | | let assetIdStr = value(assetIdRaw) |
---|
72 | 72 | | if ((minAmount > restAmount)) |
---|
73 | | - | then [ScriptTransfer(addressFromStringValue(address), amount, fromStr(assetIdStr)), ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId)), DeleteEntry(keyAssetId(orderId))] |
---|
| 73 | + | then [ScriptTransfer(addressFromStringValue(address), amount, fromStr(assetIdStr)), ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId, toString(i.caller))), DeleteEntry(keyAssetId(orderId))] |
---|
74 | 74 | | else [ScriptTransfer(addressFromStringValue(address), amount, fromStr(assetIdStr)), DeleteEntry(keyAmount(orderId)), IntegerEntry(keyAmount(orderId), restAmount)] |
---|
75 | 75 | | } |
---|
76 | 76 | | |
---|
77 | 77 | | |
---|
78 | 78 | | |
---|
79 | 79 | | @Callable(i) |
---|
80 | | - | func cancel (orderId) = if (!(isDefined(keyOrderId(orderId)))) |
---|
| 80 | + | func cancel (orderId) = if (!(isDefined(keyOrderId(orderId, toString(i.caller))))) |
---|
81 | 81 | | then throw(("You don't have an order with this id: " + orderId)) |
---|
82 | 82 | | else { |
---|
83 | 83 | | let restAmount = getIntegerValue(keyAmount(orderId)) |
---|
84 | 84 | | let assetIdKey = keyAssetId(orderId) |
---|
85 | 85 | | let assetIdRaw = getString(this, assetIdKey) |
---|
86 | 86 | | let assetIdStr = value(assetIdRaw) |
---|
87 | | - | [ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId)), DeleteEntry(keyAssetId(orderId))] |
---|
| 87 | + | [ScriptTransfer(i.caller, restAmount, fromStr(assetIdStr)), ScriptTransfer(developer, getIntegerValue(keyServiceFee(orderId)), fromStr(assetIdStr)), DeleteEntry(keyServiceFee(orderId)), DeleteEntry(keyAmount(orderId)), DeleteEntry(keyOrderId(orderId, toString(i.caller))), DeleteEntry(keyAssetId(orderId))] |
---|
88 | 88 | | } |
---|
89 | 89 | | |
---|
90 | 90 | | |
---|