tx · 3okdC1kQ5pDdK8ktWtAT27ALWyYaTMQgCn33JUiwtKEJ 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV: -0.05000000 Waves 2023.08.13 22:04 [2709186] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves
{ "type": 13, "id": "3okdC1kQ5pDdK8ktWtAT27ALWyYaTMQgCn33JUiwtKEJ", "fee": 5000000, "feeAssetId": null, "timestamp": 1691953433896, "version": 2, "chainId": 84, "sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV", "senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE", "proofs": [ "UJjoNarCerXKBsQLjSa21189ino7c5q1oB5gWPPUEAzDgVZLoiJcpdF8rZvoKprJfQRxKpSbvNTJcXcVGgYYvjd" ], "script": "base64:BgImCAISBAoCCAgSAwoBCBIECgIICBIDCgEIEgQKAggIEgQKAggIEgANABFBSV9UT0tFTl9BU1NFVF9JRAEgk+FyOHEEm2rommMfBCS3ZFOXLD68ZguDdK9ouySN4kIAC1NUQVRVU19PUEVOAgRvcGVuABJTVEFUVVNfQ0hFQ0tFRF9PVVQCC2NoZWNrZWRfb3V0AAtTVEFUVVNfRE9ORQIEZG9uZQAOQ0hFQ0tFRF9PVVRfQlkCD19jaGVja2VkX291dF9ieQATU0lNUExFX0NIQVRHUFRfVEFTSwITc2ltcGxlX0NoYXRHUFRfdGFzawAQQ0hFQ0tfT1VUX0hFSUdIVAIRX2NoZWNrX291dF9oZWlnaHQAD1JFR0lTVEVSX0hFSUdIVAIQX3JlZ2lzdGVyX2hlaWdodAANQ09NTUlUX0hFSUdIVAIOX2NvbW1pdF9oZWlnaHQBD2NhbkJlQ2hlY2tlZE91dAEGdGFza0lkBAZzdGF0dXMJAJ0IAgUEdGhpcwkArAICBQZ0YXNrSWQCB19zdGF0dXMJAAACBQZzdGF0dXMFC1NUQVRVU19PUEVOAQ5pc0Nv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XBheW1lbnQgbmVjZXNzYXJ5IGluIFdhdmVzLCBVU0RDIG9yIFVTRFQhCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgUGYW1vdW50CQDZBAEFDEJBSV9BU1NFVF9JRAUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleZNFXlU=", "height": 2709186, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6zuBE5c7nEWMMeSmtAfB2X5i6aveTFntARqmMKwA5qCf Next: FxKDSfbh8ZMbjRDi2uj4sggGSK9gezevV3MkhSBK8Syq Diff:
Old | New | Differences | |
---|---|---|---|
111 | 111 | let timestamp = lastBlock.timestamp | |
112 | 112 | if (!(taskStillOpen)) | |
113 | 113 | then throw("Task not open for checkout!") | |
114 | - | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
114 | + | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
115 | 115 | } | |
116 | 116 | ||
117 | 117 | ||
133 | 133 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
134 | 134 | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
135 | 135 | let timestamp = lastBlock.timestamp | |
136 | + | let type = match getString((taskId + "_type")) { | |
137 | + | case s: String => | |
138 | + | s | |
139 | + | case _ => | |
140 | + | "not set" | |
141 | + | } | |
136 | 142 | if (!(correctAgent)) | |
137 | 143 | then throw("Task may only be submitted by the agent who checked the task out!") | |
138 | - | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] | |
144 | + | else if ((type == "not set")) | |
145 | + | then throw("Can not identify type of task id") | |
146 | + | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp), DeleteEntry(((((("checked_out_" + type) + "_") + taskId) + "_by_") + callerPublicKey))] | |
139 | 147 | } | |
140 | 148 | ||
141 | 149 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let AI_TOKEN_ASSET_ID = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1' | |
5 | 5 | ||
6 | 6 | let STATUS_OPEN = "open" | |
7 | 7 | ||
8 | 8 | let STATUS_CHECKED_OUT = "checked_out" | |
9 | 9 | ||
10 | 10 | let STATUS_DONE = "done" | |
11 | 11 | ||
12 | 12 | let CHECKED_OUT_BY = "_checked_out_by" | |
13 | 13 | ||
14 | 14 | let SIMPLE_CHATGPT_TASK = "simple_ChatGPT_task" | |
15 | 15 | ||
16 | 16 | let CHECK_OUT_HEIGHT = "_check_out_height" | |
17 | 17 | ||
18 | 18 | let REGISTER_HEIGHT = "_register_height" | |
19 | 19 | ||
20 | 20 | let COMMIT_HEIGHT = "_commit_height" | |
21 | 21 | ||
22 | 22 | func canBeCheckedOut (taskId) = { | |
23 | 23 | let status = getString(this, (taskId + "_status")) | |
24 | 24 | (status == STATUS_OPEN) | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func isCorrectAgent (taskId,agentId) = { | |
29 | 29 | let checkoutAgentId = getString(this, (taskId + CHECKED_OUT_BY)) | |
30 | 30 | (checkoutAgentId == agentId) | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getTaskId (txId) = { | |
35 | 35 | let callerPublicKey = match getString(this, (txId + "_initializer")) { | |
36 | 36 | case str: String => | |
37 | 37 | str | |
38 | 38 | case _ => | |
39 | 39 | "" | |
40 | 40 | } | |
41 | 41 | match getString(this, ((txId + "_") + callerPublicKey)) { | |
42 | 42 | case str: String => | |
43 | 43 | str | |
44 | 44 | case _ => | |
45 | 45 | "" | |
46 | 46 | } | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func getPriceForType (type) = match getInteger(this, ("price_" + type)) { | |
51 | 51 | case i: Int => | |
52 | 52 | i | |
53 | 53 | case _ => | |
54 | 54 | -1 | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | 59 | func registerTask (description,type) = { | |
60 | 60 | let numberOfPayments = size(i.payments) | |
61 | 61 | if ((numberOfPayments != 1)) | |
62 | 62 | then throw("Payment necessary!") | |
63 | 63 | else { | |
64 | 64 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
65 | 65 | let txId = toBase58String(i.transactionId) | |
66 | 66 | let payment = i.payments[0] | |
67 | 67 | let fee = payment.amount | |
68 | 68 | let feeAssetId = payment.assetId | |
69 | 69 | let taskId = ((txId + "_") + callerPublicKey) | |
70 | 70 | let timestamp = lastBlock.timestamp | |
71 | 71 | let minFee = getPriceForType(type) | |
72 | 72 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
73 | 73 | then throw("Payment only possible in the AI Token!") | |
74 | 74 | else if ((minFee == -1)) | |
75 | 75 | then throw("Task type not supported!") | |
76 | 76 | else if ((minFee > fee)) | |
77 | 77 | then throw((("Payment needs to be at least " + toString(minFee)) + " AI Token!")) | |
78 | 78 | else [StringEntry((taskId + "_description"), description), StringEntry((txId + "_initializer"), callerPublicKey), StringEntry((taskId + "_status"), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry((taskId + REGISTER_HEIGHT), height), IntegerEntry((taskId + "_register_timestamp"), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true)] | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func registerChatGPTTask (description) = { | |
86 | 86 | let numberOfPayments = size(i.payments) | |
87 | 87 | if ((numberOfPayments != 1)) | |
88 | 88 | then throw("Payment necessary!") | |
89 | 89 | else { | |
90 | 90 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
91 | 91 | let txId = toBase58String(i.transactionId) | |
92 | 92 | let payment = i.payments[0] | |
93 | 93 | let fee = payment.amount | |
94 | 94 | let feeAssetId = payment.assetId | |
95 | 95 | let taskId = ((txId + "_") + callerPublicKey) | |
96 | 96 | let timestamp = lastBlock.timestamp | |
97 | 97 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
98 | 98 | then throw("Payment only possible in the AI Token!") | |
99 | 99 | else if ((10000000 > fee)) | |
100 | 100 | then throw("Payment needs to be at least 0.1 AI Token!") | |
101 | 101 | else [StringEntry((taskId + "_description"), description), StringEntry((txId + "_initializer"), callerPublicKey), StringEntry((taskId + "_status"), STATUS_OPEN), StringEntry((taskId + "_type"), SIMPLE_CHATGPT_TASK), IntegerEntry((taskId + REGISTER_HEIGHT), height), IntegerEntry((taskId + "_register_timestamp"), timestamp), BooleanEntry(("open_chatgpt_" + taskId), true)] | |
102 | 102 | } | |
103 | 103 | } | |
104 | 104 | ||
105 | 105 | ||
106 | 106 | ||
107 | 107 | @Callable(i) | |
108 | 108 | func checkoutTask (taskId,type) = { | |
109 | 109 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
110 | 110 | let taskStillOpen = canBeCheckedOut(taskId) | |
111 | 111 | let timestamp = lastBlock.timestamp | |
112 | 112 | if (!(taskStillOpen)) | |
113 | 113 | then throw("Task not open for checkout!") | |
114 | - | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
114 | + | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
115 | 115 | } | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | ||
119 | 119 | @Callable(i) | |
120 | 120 | func checkoutChatGPTTask (taskId) = { | |
121 | 121 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
122 | 122 | let taskStillOpen = canBeCheckedOut(taskId) | |
123 | 123 | let timestamp = lastBlock.timestamp | |
124 | 124 | if (!(taskStillOpen)) | |
125 | 125 | then throw("Task not open for checkout!") | |
126 | 126 | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), DeleteEntry(("open_chatgpt_" + taskId))] | |
127 | 127 | } | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | ||
131 | 131 | @Callable(i) | |
132 | 132 | func commitTask (taskId,response) = { | |
133 | 133 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
134 | 134 | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
135 | 135 | let timestamp = lastBlock.timestamp | |
136 | + | let type = match getString((taskId + "_type")) { | |
137 | + | case s: String => | |
138 | + | s | |
139 | + | case _ => | |
140 | + | "not set" | |
141 | + | } | |
136 | 142 | if (!(correctAgent)) | |
137 | 143 | then throw("Task may only be submitted by the agent who checked the task out!") | |
138 | - | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] | |
144 | + | else if ((type == "not set")) | |
145 | + | then throw("Can not identify type of task id") | |
146 | + | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp), DeleteEntry(((((("checked_out_" + type) + "_") + taskId) + "_by_") + callerPublicKey))] | |
139 | 147 | } | |
140 | 148 | ||
141 | 149 | ||
142 | 150 | ||
143 | 151 | @Callable(i) | |
144 | 152 | func commitChatGPTTask (taskId,response) = { | |
145 | 153 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
146 | 154 | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
147 | 155 | let timestamp = lastBlock.timestamp | |
148 | 156 | if (!(correctAgent)) | |
149 | 157 | then throw("Task may only be submitted by the agent who checked the task out!") | |
150 | 158 | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] | |
151 | 159 | } | |
152 | 160 | ||
153 | 161 | ||
154 | 162 | ||
155 | 163 | @Callable(i) | |
156 | 164 | func buy () = { | |
157 | 165 | let WAVES_USDT_ORACLE = addressFromStringValue("3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy") | |
158 | 166 | let WAVES_USDT_ORACLE_KEY = "%s%s__price__WAVES-USDT" | |
159 | 167 | let USDT_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
160 | 168 | let USDC_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
161 | 169 | let BAI_ASSET_ID = "AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1" | |
162 | 170 | let numberOfPayments = size(i.payments) | |
163 | 171 | if ((numberOfPayments != 1)) | |
164 | 172 | then throw("Payment necessary!") | |
165 | 173 | else { | |
166 | 174 | let payment = i.payments[0] | |
167 | 175 | let feeAssetId = payment.assetId | |
168 | 176 | let feeAssetIdString = match feeAssetId { | |
169 | 177 | case b: ByteVector => | |
170 | 178 | toBase58String(b) | |
171 | 179 | case _ => | |
172 | 180 | "" | |
173 | 181 | } | |
174 | 182 | let paymentAmount = payment.amount | |
175 | 183 | let amount = if (!(isDefined(feeAssetId))) | |
176 | 184 | then { | |
177 | 185 | let wavesUsdtPrice = match getInteger(WAVES_USDT_ORACLE, WAVES_USDT_ORACLE_KEY) { | |
178 | 186 | case n: Int => | |
179 | 187 | n | |
180 | 188 | case _ => | |
181 | 189 | 0 | |
182 | 190 | } | |
183 | 191 | (fraction(paymentAmount, wavesUsdtPrice, 100000000) * 100) | |
184 | 192 | } | |
185 | 193 | else if ((feeAssetIdString == USDT_ASSET_ID)) | |
186 | 194 | then (paymentAmount * 100) | |
187 | 195 | else if ((feeAssetIdString == USDC_ASSET_ID)) | |
188 | 196 | then (paymentAmount * 100) | |
189 | 197 | else throw("payment necessary in Waves, USDC or USDT!") | |
190 | 198 | [ScriptTransfer(i.caller, amount, fromBase58String(BAI_ASSET_ID))] | |
191 | 199 | } | |
192 | 200 | } | |
193 | 201 | ||
194 | 202 | ||
195 | 203 | @Verifier(tx) | |
196 | 204 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
197 | 205 |
github/deemru/w8io/026f985 41.08 ms ◑