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