tx · BxgXfV6myP6xqbHqYHeDFCKsKgV2PUdcjVdaa8NBAAjp 3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c: -0.01000000 Waves 2023.09.27 13:56 [2773722] smart account 3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c > SELF 0.00000000 Waves
{ "type": 13, "id": "BxgXfV6myP6xqbHqYHeDFCKsKgV2PUdcjVdaa8NBAAjp", "fee": 1000000, "feeAssetId": null, "timestamp": 1695812217407, "version": 2, "chainId": 84, "sender": "3N91zFrRoofbPpkoDbWKrQsQSdLu2EgLL8c", "senderPublicKey": "5FyjUYCR5Q8jvG6ri6Ysz574HerUK6r1LJzzQ7DvSkLk", "proofs": [ "2Jw2GuQ2quovS3Ldaxb1havnts98iR3EGq1NHgZ2vHdJkJ1mdBTCLWW7KVanbmgkDnYv6jH6m4Swix3nfPnu6cQz" ], "script": "base64:BgISCAISBgoEAgICARIAEgQKAggCEwAJc2VwYXJhdG9yAgJfXwELbXVzdEFkZHJlc3MCAWkHYWRkcmVzcwMJAAACCAUBaQZjYWxsZXIFB2FkZHJlc3MGCQEFdGhyb3cAAQhtdXN0VGhpcwEBaQkBC211c3RBZGRyZXNzAgUBaQUEdGhpcwARa1NlcnZpY2VQdWJsaWNLZXkCFCVzX19zZXJ2aWNlUHVibGljS2V5AA1rQm90UHVibGljS2V5AhAlc19fYm90UHVibGljS2V5ABFrRmFjdG9yeVB1YmxpY0tleQIUJXNfX2ZhY3RvcnlQdWJsaWNLZXkAD2tPd25lclB1YmxpY0tleQISJXNfX293bmVyUHVibGljS2V5ABJrQWNjb3VudFNjcmlwdEhhc2gCFSVzX19hY2NvdW50U2NyaXB0SGFzaAERYWNjb3VudFNjcmlwdEhhc2gACQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJwIAgUEdGhpcwUSa0FjY291bnRTY3JpcHRIYXNoAh5hY2NvdW50IHNjcmlwdCBoYXNoIGlzIG5vdCBzZXQACGtDb3VudGVyAgslc19fY291bnRlcg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CB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQhjb21wbGV0ZQIJcmVxdWVzdElkEnJlY2lwaWVudFB1YmxpY0tleQQGY2hlY2tzCQDMCAIDCQEBIQEJARByZXF1ZXN0Q29tcGxldGVkAQUJcmVxdWVzdElkBgkAAgECHHJlcXVlc3QgaXMgYWxyZWFkeSBjb21wbGV0ZWQJAMwIAgMJAAACCQDxBwEIBQFpBmNhbGxlcgkBEWFjY291bnRTY3JpcHRIYXNoAAYJAAIBAg5pbnZhbGlkIHNjcmlwdAkAzAgCAwQHJG1hdGNoMAkAnAgCCAUBaQZjYWxsZXIFEWtGYWN0b3J5UHVibGljS2V5AwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAWIFByRtYXRjaDAJAAACCQCnCAEFAWIFBHRoaXMHBgkAAgECGmludmFsaWQgZmFjdG9yeSBwdWJsaWMga2V5CQDMCAIDBAckbWF0Y2gwCQCcCAIIBQFpBmNhbGxlcgUPa093bmVyUHVibGljS2V5AwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAWIFByRtYXRjaDAJAAACBQFiCQEMcmVxdWVzdE93bmVyAQUJcmVxdWVzdElkBwYJAAIBAhhpbnZhbGlkIG93bmVyIHB1YmxpYyBrZXkFA25pbAMJAAACBQZjaGVja3MFBmNoZWNrcwQGcmVzdWx0CQD8BwQIBQFpBmNhbGxlcgIHYXBwcm92ZQUDbmlsBQNuaWwJAJQKAgkAzAgCCQEMQm9vbGVhbkVudHJ5AgkBEWtSZXF1ZXN0Q29tcGxldGVkAQUJcmVxdWVzdElkBgUDbmlsBQZyZXN1bHQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AMsxkjw==", "height": 2773722, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BxykfUYpQrMHXFD7m7dHEaxvtWEQLMUrTy2Ctdg8Yray Next: CBmUfgwJ6H3VyFs6q2MJ4F6Z2qmiJ2E6NtJVDTCz2sVJ Diff:
Old | New | Differences | |
---|---|---|---|
43 | 43 | func kRequestOwner (requestId) = makeString(["%s%s", requestId, "owner"], separator) | |
44 | 44 | ||
45 | 45 | ||
46 | - | func requestOwner (requestId) = valueOrErrorMessage(getBinary(this, | |
46 | + | func requestOwner (requestId) = valueOrErrorMessage(getBinary(this, kRequestOwner(requestId)), "request is not found") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | let serviceAddress = addressFromPublicKey(getBinaryValue(this, kServicePublicKey)) | |
72 | 72 | if ((checks == checks)) | |
73 | 73 | then { | |
74 | 74 | let requestId = toBase58String(sha256((i.caller.bytes + toBytes(counter())))) | |
75 | - | $Tuple2([BooleanEntry(kRequestCompleted(requestId), false), BinaryEntry(kRequestOwner(requestId), i.callerPublicKey)], unit) | |
75 | + | $Tuple2([BooleanEntry(kRequestCompleted(requestId), false), BinaryEntry(kRequestOwner(requestId), i.callerPublicKey), IntegerEntry(kCounter, (counter() + 1))], unit) | |
76 | 76 | } | |
77 | 77 | else throw("Strict value is not equal to itself.") | |
78 | 78 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | 5 | ||
6 | 6 | func mustAddress (i,address) = if ((i.caller == address)) | |
7 | 7 | then true | |
8 | 8 | else throw() | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func mustThis (i) = mustAddress(i, this) | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | let kServicePublicKey = "%s__servicePublicKey" | |
15 | 15 | ||
16 | 16 | let kBotPublicKey = "%s__botPublicKey" | |
17 | 17 | ||
18 | 18 | let kFactoryPublicKey = "%s__factoryPublicKey" | |
19 | 19 | ||
20 | 20 | let kOwnerPublicKey = "%s__ownerPublicKey" | |
21 | 21 | ||
22 | 22 | let kAccountScriptHash = "%s__accountScriptHash" | |
23 | 23 | ||
24 | 24 | func accountScriptHash () = valueOrErrorMessage(getBinary(this, kAccountScriptHash), "account script hash is not set") | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | let kCounter = "%s__counter" | |
28 | 28 | ||
29 | 29 | func counter () = valueOrElse(getInteger(this, kCounter), 0) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | let kRewardAmount = "%s__rewardAmount" | |
33 | 33 | ||
34 | 34 | func rewardAmount () = valueOrErrorMessage(getInteger(this, kRewardAmount), "reward amount is not set") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func kRequestCompleted (requestId) = makeString(["%s%s", requestId, "completed"], separator) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func requestCompleted (requestId) = valueOrErrorMessage(getBoolean(this, kRequestCompleted(requestId)), "request is not found") | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func kRequestOwner (requestId) = makeString(["%s%s", requestId, "owner"], separator) | |
44 | 44 | ||
45 | 45 | ||
46 | - | func requestOwner (requestId) = valueOrErrorMessage(getBinary(this, | |
46 | + | func requestOwner (requestId) = valueOrErrorMessage(getBinary(this, kRequestOwner(requestId)), "request is not found") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | let serviceAddress = addressFromPublicKey(getBinaryValue(this, kServicePublicKey)) | |
50 | 50 | ||
51 | 51 | let botPublicKey = getBinaryValue(this, kBotPublicKey) | |
52 | 52 | ||
53 | 53 | @Callable(i) | |
54 | 54 | func init (servicePublicKey,botPublicKey,accountScriptHash,rewardAmount) = { | |
55 | 55 | let checkCaller = mustThis(i) | |
56 | 56 | if ((checkCaller == checkCaller)) | |
57 | 57 | then $Tuple2([BinaryEntry(kServicePublicKey, servicePublicKey), BinaryEntry(kBotPublicKey, botPublicKey), BinaryEntry(kAccountScriptHash, accountScriptHash), IntegerEntry(kRewardAmount, rewardAmount)], unit) | |
58 | 58 | else throw("Strict value is not equal to itself.") | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | ||
63 | 63 | @Callable(i) | |
64 | 64 | func request () = { | |
65 | 65 | let checks = [if ((size(i.payments) == 1)) | |
66 | 66 | then true | |
67 | 67 | else throw("1 payment is required"), if ((i.payments[0].assetId == unit)) | |
68 | 68 | then true | |
69 | 69 | else throw("invalid asset"), if ((i.payments[0].amount == rewardAmount())) | |
70 | 70 | then true | |
71 | 71 | else throw("invalid amount")] | |
72 | 72 | if ((checks == checks)) | |
73 | 73 | then { | |
74 | 74 | let requestId = toBase58String(sha256((i.caller.bytes + toBytes(counter())))) | |
75 | - | $Tuple2([BooleanEntry(kRequestCompleted(requestId), false), BinaryEntry(kRequestOwner(requestId), i.callerPublicKey)], unit) | |
75 | + | $Tuple2([BooleanEntry(kRequestCompleted(requestId), false), BinaryEntry(kRequestOwner(requestId), i.callerPublicKey), IntegerEntry(kCounter, (counter() + 1))], unit) | |
76 | 76 | } | |
77 | 77 | else throw("Strict value is not equal to itself.") | |
78 | 78 | } | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | ||
82 | 82 | @Callable(i) | |
83 | 83 | func complete (requestId,recipientPublicKey) = { | |
84 | 84 | let checks = [if (!(requestCompleted(requestId))) | |
85 | 85 | then true | |
86 | 86 | else throw("request is already completed"), if ((scriptHash(i.caller) == accountScriptHash())) | |
87 | 87 | then true | |
88 | 88 | else throw("invalid script"), if ( match getBinary(i.caller, kFactoryPublicKey) { | |
89 | 89 | case b: ByteVector => | |
90 | 90 | (addressFromPublicKey(b) == this) | |
91 | 91 | case _ => | |
92 | 92 | false | |
93 | 93 | }) | |
94 | 94 | then true | |
95 | 95 | else throw("invalid factory public key"), if ( match getBinary(i.caller, kOwnerPublicKey) { | |
96 | 96 | case b: ByteVector => | |
97 | 97 | (b == requestOwner(requestId)) | |
98 | 98 | case _ => | |
99 | 99 | false | |
100 | 100 | }) | |
101 | 101 | then true | |
102 | 102 | else throw("invalid owner public key")] | |
103 | 103 | if ((checks == checks)) | |
104 | 104 | then { | |
105 | 105 | let result = invoke(i.caller, "approve", nil, nil) | |
106 | 106 | $Tuple2([BooleanEntry(kRequestCompleted(requestId), true)], result) | |
107 | 107 | } | |
108 | 108 | else throw("Strict value is not equal to itself.") | |
109 | 109 | } | |
110 | 110 | ||
111 | 111 |
github/deemru/w8io/169f3d6 27.69 ms ◑