tx · 5Sbdp8bsXZFhQCmKyuLBP53Ta1HfHB9sm4JbqXAWv9iD 3MpKvUfNxrgF7QotPjFwi8thMagSveNScKe: -0.01400000 Waves 2020.11.10 18:39 [1259442] smart account 3MpKvUfNxrgF7QotPjFwi8thMagSveNScKe > SELF 0.00000000 Waves
{ "type": 13, "id": "5Sbdp8bsXZFhQCmKyuLBP53Ta1HfHB9sm4JbqXAWv9iD", "fee": 1400000, "feeAssetId": null, "timestamp": 1605022785541, "version": 2, "chainId": 84, "sender": "3MpKvUfNxrgF7QotPjFwi8thMagSveNScKe", "senderPublicKey": "9GE2xN4fms9YNDxR1hGg52RynqDd8125TA42g4X29ZV7", "proofs": [ "44YAtPm4WiVEFp3cXpeFSbmErtpJZ1E1HM36x7XFz4HqtbTvhghL97qdfgJ3KcxHDR3anxoLSPtGVqCYXiXtLqct" ], "script": "base64:AAIEAAAAAAAAABUIAhIGCgQIAQEIEgQKAggIEgMKAQgAAAAEAAAAAAJjZgkBAAAAFGFkZHJlc3NGcm9tUHVibGljS2V5AAAAAQkAAlkAAAABAgAAACxKN3Z5b1VBOEdkNVFNcTRZVnRlZHB2MTlkd0NZcm9aRVlyTjhiS2dMenFWOAAAAAAEb3BicgEAAAAg8w+nJ903R+IZ8oK5CbdbBTqw7e4xxmj9cHNLUMCmE7gBAAAAEGdldEFsbG93ZWRUb2tlbnMAAAABAAAAB3Rva2VuSWQEAAAABWFsbG93BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAB3Rva2VuSWQDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQcFAAAABWFsbG93AQAAAAx2ZXJpZmljYXRpb24AAAACAAAAAW0AAAABcwQAAAAGZ2V0TXNnCQABmwAAAAEJAAJYAAAAAQkAAfUAAAABCQAB9gAAAAEJAAGbAAAAAQUAAAABbQkAAfQAAAADBQAAAAZnZXRNc2cJAAJZAAAAAQUAAAABcwEA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BpcyBub3QgYXV0aG9yaXplZCB0byBkZWxpc3QgdG9rZW5zCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAAB3Rva2VuSWQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAACY2YAAAAAAACYloAFAAAABHVuaXQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5nSmDqQ==", "height": 1259442, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: A3zUQAMN52oDDVDcmChLRTMxfVz8ir2ZJU65egy6Mwed Next: AGUmHk5ndUsGSLdTyz5KcRdDWrPqxu2e7je2xaxuGH83 Diff:
Old | New | Differences | |
---|---|---|---|
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | - | func compareHash (c,h) = (keccak256(blake2b256(toBytes(c))) == fromBase58String(h)) | |
19 | + | func verification (m,s) = { | |
20 | + | let getMsg = toBytes(toBase58String(keccak256(blake2b256(toBytes(m))))) | |
21 | + | sigVerify(getMsg, fromBase58String(s), base58'C8jRoXECFheT6JPcAkcyWPadYbxBA6tSyAqXqjq5dicS') | |
22 | + | } | |
20 | 23 | ||
21 | 24 | ||
22 | 25 | @Callable(i) | |
23 | - | func opbrBuy (tokenId,qtd,price, | |
26 | + | func opbrBuy (tokenId,qtd,price,sig) = { | |
24 | 27 | let buyerAddr = toBase58String(i.caller.bytes) | |
25 | 28 | let pmt = i.payments | |
26 | 29 | let allowed = getAllowedTokens(tokenId) | |
28 | 31 | then throw("Payment for exchange is mandatory") | |
29 | 32 | else if ((size(pmt) == 2)) | |
30 | 33 | then throw("Only one payment per transaction is allowed") | |
31 | - | else if (!( | |
32 | - | then throw(" | |
34 | + | else if (!(verification((tokenId + toString((qtd + pmt[0].amount))), sig))) | |
35 | + | then throw("Stop hacking me!") | |
33 | 36 | else if (if (isDefined(pmt[0].assetId)) | |
34 | 37 | then (allowed == false) | |
35 | 38 | else false) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let cf = addressFromPublicKey(fromBase58String("J7vyoUA8Gd5QMq4YVtedpv19dwCYroZEYrN8bKgLzqV8")) | |
5 | 5 | ||
6 | 6 | let opbr = base58'HMov2457acf5MEJr85fvXYL3vrTEevFpsEQkHh1yfdUT' | |
7 | 7 | ||
8 | 8 | func getAllowedTokens (tokenId) = { | |
9 | 9 | let allow = match getString(this, tokenId) { | |
10 | 10 | case a: String => | |
11 | 11 | a | |
12 | 12 | case _ => | |
13 | 13 | false | |
14 | 14 | } | |
15 | 15 | allow | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | - | func compareHash (c,h) = (keccak256(blake2b256(toBytes(c))) == fromBase58String(h)) | |
19 | + | func verification (m,s) = { | |
20 | + | let getMsg = toBytes(toBase58String(keccak256(blake2b256(toBytes(m))))) | |
21 | + | sigVerify(getMsg, fromBase58String(s), base58'C8jRoXECFheT6JPcAkcyWPadYbxBA6tSyAqXqjq5dicS') | |
22 | + | } | |
20 | 23 | ||
21 | 24 | ||
22 | 25 | @Callable(i) | |
23 | - | func opbrBuy (tokenId,qtd,price, | |
26 | + | func opbrBuy (tokenId,qtd,price,sig) = { | |
24 | 27 | let buyerAddr = toBase58String(i.caller.bytes) | |
25 | 28 | let pmt = i.payments | |
26 | 29 | let allowed = getAllowedTokens(tokenId) | |
27 | 30 | if ((size(pmt) == 0)) | |
28 | 31 | then throw("Payment for exchange is mandatory") | |
29 | 32 | else if ((size(pmt) == 2)) | |
30 | 33 | then throw("Only one payment per transaction is allowed") | |
31 | - | else if (!( | |
32 | - | then throw(" | |
34 | + | else if (!(verification((tokenId + toString((qtd + pmt[0].amount))), sig))) | |
35 | + | then throw("Stop hacking me!") | |
33 | 36 | else if (if (isDefined(pmt[0].assetId)) | |
34 | 37 | then (allowed == false) | |
35 | 38 | else false) | |
36 | 39 | then throw("The used token is not accepted") | |
37 | 40 | else if (if (isDefined(pmt[0].assetId)) | |
38 | 41 | then (fromBase58String(tokenId) != pmt[0].assetId) | |
39 | 42 | else false) | |
40 | 43 | then throw("declared token is different from submitted token") | |
41 | 44 | else { | |
42 | 45 | let c = fraction(1, pmt[0].amount, 100) | |
43 | 46 | [ScriptTransfer(i.caller, qtd, opbr), ScriptTransfer(cf, c, pmt[0].assetId)] | |
44 | 47 | } | |
45 | 48 | } | |
46 | 49 | ||
47 | 50 | ||
48 | 51 | ||
49 | 52 | @Callable(i) | |
50 | 53 | func tokenList (tokenId,ticker) = { | |
51 | 54 | let Addr = toBase58String(i.caller.bytes) | |
52 | 55 | if (if ((Addr != toString(this))) | |
53 | 56 | then (Addr != toString(cf)) | |
54 | 57 | else false) | |
55 | 58 | then throw("The address is not authorized to list tokens") | |
56 | 59 | else [StringEntry(tokenId, ticker), ScriptTransfer(cf, 1000000, unit)] | |
57 | 60 | } | |
58 | 61 | ||
59 | 62 | ||
60 | 63 | ||
61 | 64 | @Callable(i) | |
62 | 65 | func tokenDelist (tokenId) = { | |
63 | 66 | let Addr = toBase58String(i.caller.bytes) | |
64 | 67 | if (if ((Addr != toString(this))) | |
65 | 68 | then (Addr != toString(cf)) | |
66 | 69 | else false) | |
67 | 70 | then throw("The address is not authorized to delist tokens") | |
68 | 71 | else [DeleteEntry(tokenId), ScriptTransfer(cf, 10000000, unit)] | |
69 | 72 | } | |
70 | 73 | ||
71 | 74 | ||
72 | 75 | @Verifier(tx) | |
73 | 76 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
74 | 77 |
github/deemru/w8io/169f3d6 32.98 ms ◑