tx · 5EJBhiRcVDXxuJecUFqwuhcEDqS45XYyq3XGCddhE3Kt 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV: -0.01000000 Waves 2023.09.07 10:17 [2744652] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves
{ "type": 13, "id": "5EJBhiRcVDXxuJecUFqwuhcEDqS45XYyq3XGCddhE3Kt", "fee": 1000000, "feeAssetId": null, "timestamp": 1694071129582, "version": 2, "chainId": 84, "sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV", "senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE", "proofs": [ "5cabMsynqu4qiiy96iuFDVGytxCb9cfQEE1zSMacUraor8aWvmqGtECjUHks8LT9zJrJW5E2hQ2K9iBDeW4dGxY8" ], "script": "base64:BgIdCAISBAoCCAgSBQoDCAgIEgQKAggIEgQKAggIEgANABFBSV9UT0tFTl9BU1NFVF9JRAEgk+FyOHEEm2rommMfBCS3ZFOXLD68ZguDdK9ouySN4kIAC1NUQVRVU19PUEVOAgRvcGVuABJTVEFUVVNfQ0hFQ0tFRF9PVVQCC2NoZWNrZWRfb3V0AAtTVEFUVVNfRE9ORQIEZG9uZQAOQ0hFQ0tFRF9PVVRfQlkCEF9jaGVja2VkX291dF9ieV8AE1NJTVBMRV9DSEFUR1BUX1RBU0sCE3NpbXBsZV9DaGF0R1BUX3Rhc2sAEENIRUNLX09VVF9IRUlHSFQCEl9jaGVja19vdXRfaGVpZ2h0XwAPUkVHSVNURVJfSEVJR0hUAhFfcmVnaXN0ZXJfaGVpZ2h0XwANQ09NTUlUX0hFSUdIVAIPX2NvbW1pdF9oZWlnaHRfAQ9jYW5CZUNoZWNrZWRPdXQBBnRhc2tJZAQGc3RhdHVzCQCdCAIFBHRoaXMJAKwCAgUGdGFza0lkAgdfc3RhdHVzCQAAAgUGc3RhdHVzBQtTVEFUVVNfT1BFTgEOaXND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AW4AAAkAaAIJAGsDBQ1wYXltZW50QW1vdW50BQ53YXZlc1VzZHRQcmljZQCAwtcvAGQDCQAAAgUQZmVlQXNzZXRJZFN0cmluZwUNVVNEVF9BU1NFVF9JRAkAaAIFDXBheW1lbnRBbW91bnQAZAMJAAACBRBmZWVBc3NldElkU3RyaW5nBQ1VU0RDX0FTU0VUX0lECQBoAgUNcGF5bWVudEFtb3VudABkCQACAQIpcGF5bWVudCBuZWNlc3NhcnkgaW4gV2F2ZXMsIFVTREMgb3IgVVNEVCEJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyBQZhbW91bnQJANkEAQUMQkFJX0FTU0VUX0lEBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V56RViuw==", "height": 2744652, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FxKDSfbh8ZMbjRDi2uj4sggGSK9gezevV3MkhSBK8Syq Next: ChGeWu4zwoRH9YgcF3C8QqCqokWcUAHYELf7j2GEmzQv Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let STATUS_DONE = "done" | |
11 | 11 | ||
12 | - | let CHECKED_OUT_BY = "_checked_out_by" | |
12 | + | let CHECKED_OUT_BY = "_checked_out_by_" | |
13 | 13 | ||
14 | 14 | let SIMPLE_CHATGPT_TASK = "simple_ChatGPT_task" | |
15 | 15 | ||
16 | - | let CHECK_OUT_HEIGHT = "_check_out_height" | |
16 | + | let CHECK_OUT_HEIGHT = "_check_out_height_" | |
17 | 17 | ||
18 | - | let REGISTER_HEIGHT = "_register_height" | |
18 | + | let REGISTER_HEIGHT = "_register_height_" | |
19 | 19 | ||
20 | - | let COMMIT_HEIGHT = "_commit_height" | |
20 | + | let COMMIT_HEIGHT = "_commit_height_" | |
21 | 21 | ||
22 | 22 | func canBeCheckedOut (taskId) = { | |
23 | 23 | let status = getString(this, (taskId + "_status")) | |
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 | - | 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)] | |
78 | + | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true)] | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | - | func | |
85 | + | func registerTaskCallback (description,type,callback) = { | |
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 | + | let caller = toString(i.caller) | |
91 | 92 | let txId = toBase58String(i.transactionId) | |
92 | 93 | let payment = i.payments[0] | |
93 | 94 | let fee = payment.amount | |
94 | 95 | let feeAssetId = payment.assetId | |
95 | 96 | let taskId = ((txId + "_") + callerPublicKey) | |
96 | 97 | let timestamp = lastBlock.timestamp | |
98 | + | let minFee = getPriceForType(type) | |
97 | 99 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
98 | 100 | then throw("Payment only possible in the AI Token!") | |
99 | - | else if ((10000000 > fee)) | |
100 | - | then throw("Payment needs to be at least 0.1 AI Token!") | |
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)] | |
101 | + | else if ((minFee == -1)) | |
102 | + | then throw("Task type not supported!") | |
103 | + | else if ((minFee > fee)) | |
104 | + | then throw((("Payment needs to be at least " + toString(minFee)) + " AI Token!")) | |
105 | + | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((txId + "_callback_") + type), callback), StringEntry(((txId + "_caller_") + type), caller), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true)] | |
102 | 106 | } | |
103 | 107 | } | |
104 | 108 | ||
111 | 115 | let timestamp = lastBlock.timestamp | |
112 | 116 | if (!(taskStillOpen)) | |
113 | 117 | 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), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
115 | - | } | |
116 | - | ||
117 | - | ||
118 | - | ||
119 | - | @Callable(i) | |
120 | - | func checkoutChatGPTTask (taskId) = { | |
121 | - | let callerPublicKey = toBase58String(i.callerPublicKey) | |
122 | - | let taskStillOpen = canBeCheckedOut(taskId) | |
123 | - | let timestamp = lastBlock.timestamp | |
124 | - | if (!(taskStillOpen)) | |
125 | - | then throw("Task not open for checkout!") | |
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))] | |
118 | + | else [StringEntry(((taskId + CHECKED_OUT_BY) + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_CHECKED_OUT), IntegerEntry(((taskId + CHECK_OUT_HEIGHT) + type), height), IntegerEntry(((taskId + "_check_out_timestamp_") + type), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
127 | 119 | } | |
128 | 120 | ||
129 | 121 | ||
139 | 131 | case _ => | |
140 | 132 | "not set" | |
141 | 133 | } | |
134 | + | let callback = match getString((taskId + "_callback")) { | |
135 | + | case s: String => | |
136 | + | s | |
137 | + | case _ => | |
138 | + | "no callback" | |
139 | + | } | |
140 | + | let caller = match getString((taskId + "_caller")) { | |
141 | + | case s: String => | |
142 | + | s | |
143 | + | case _ => | |
144 | + | "no callback" | |
145 | + | } | |
142 | 146 | if (!(correctAgent)) | |
143 | 147 | then throw("Task may only be submitted by the agent who checked the task out!") | |
144 | 148 | else if ((type == "not set")) | |
145 | 149 | 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_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
147 | - | } | |
148 | - | ||
149 | - | ||
150 | - | ||
151 | - | @Callable(i) | |
152 | - | func commitChatGPTTask (taskId,response) = { | |
153 | - | let callerPublicKey = toBase58String(i.callerPublicKey) | |
154 | - | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
155 | - | let timestamp = lastBlock.timestamp | |
156 | - | if (!(correctAgent)) | |
157 | - | then throw("Task may only be submitted by the agent who checked the task out!") | |
158 | - | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] | |
150 | + | else if ((callback != "no callback")) | |
151 | + | then { | |
152 | + | let result = invoke(Address(fromBase58String(caller)), callback, [response], nil) | |
153 | + | [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
154 | + | } | |
155 | + | else [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
159 | 156 | } | |
160 | 157 | ||
161 | 158 |
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 | - | let CHECKED_OUT_BY = "_checked_out_by" | |
12 | + | let CHECKED_OUT_BY = "_checked_out_by_" | |
13 | 13 | ||
14 | 14 | let SIMPLE_CHATGPT_TASK = "simple_ChatGPT_task" | |
15 | 15 | ||
16 | - | let CHECK_OUT_HEIGHT = "_check_out_height" | |
16 | + | let CHECK_OUT_HEIGHT = "_check_out_height_" | |
17 | 17 | ||
18 | - | let REGISTER_HEIGHT = "_register_height" | |
18 | + | let REGISTER_HEIGHT = "_register_height_" | |
19 | 19 | ||
20 | - | let COMMIT_HEIGHT = "_commit_height" | |
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 | - | 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)] | |
78 | + | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true)] | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | - | func | |
85 | + | func registerTaskCallback (description,type,callback) = { | |
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 | + | let caller = toString(i.caller) | |
91 | 92 | let txId = toBase58String(i.transactionId) | |
92 | 93 | let payment = i.payments[0] | |
93 | 94 | let fee = payment.amount | |
94 | 95 | let feeAssetId = payment.assetId | |
95 | 96 | let taskId = ((txId + "_") + callerPublicKey) | |
96 | 97 | let timestamp = lastBlock.timestamp | |
98 | + | let minFee = getPriceForType(type) | |
97 | 99 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
98 | 100 | then throw("Payment only possible in the AI Token!") | |
99 | - | else if ((10000000 > fee)) | |
100 | - | then throw("Payment needs to be at least 0.1 AI Token!") | |
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)] | |
101 | + | else if ((minFee == -1)) | |
102 | + | then throw("Task type not supported!") | |
103 | + | else if ((minFee > fee)) | |
104 | + | then throw((("Payment needs to be at least " + toString(minFee)) + " AI Token!")) | |
105 | + | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((txId + "_callback_") + type), callback), StringEntry(((txId + "_caller_") + type), caller), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true)] | |
102 | 106 | } | |
103 | 107 | } | |
104 | 108 | ||
105 | 109 | ||
106 | 110 | ||
107 | 111 | @Callable(i) | |
108 | 112 | func checkoutTask (taskId,type) = { | |
109 | 113 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
110 | 114 | let taskStillOpen = canBeCheckedOut(taskId) | |
111 | 115 | let timestamp = lastBlock.timestamp | |
112 | 116 | if (!(taskStillOpen)) | |
113 | 117 | 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), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
115 | - | } | |
116 | - | ||
117 | - | ||
118 | - | ||
119 | - | @Callable(i) | |
120 | - | func checkoutChatGPTTask (taskId) = { | |
121 | - | let callerPublicKey = toBase58String(i.callerPublicKey) | |
122 | - | let taskStillOpen = canBeCheckedOut(taskId) | |
123 | - | let timestamp = lastBlock.timestamp | |
124 | - | if (!(taskStillOpen)) | |
125 | - | then throw("Task not open for checkout!") | |
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))] | |
118 | + | else [StringEntry(((taskId + CHECKED_OUT_BY) + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_CHECKED_OUT), IntegerEntry(((taskId + CHECK_OUT_HEIGHT) + type), height), IntegerEntry(((taskId + "_check_out_timestamp_") + type), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
127 | 119 | } | |
128 | 120 | ||
129 | 121 | ||
130 | 122 | ||
131 | 123 | @Callable(i) | |
132 | 124 | func commitTask (taskId,response) = { | |
133 | 125 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
134 | 126 | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
135 | 127 | let timestamp = lastBlock.timestamp | |
136 | 128 | let type = match getString((taskId + "_type")) { | |
137 | 129 | case s: String => | |
138 | 130 | s | |
139 | 131 | case _ => | |
140 | 132 | "not set" | |
141 | 133 | } | |
134 | + | let callback = match getString((taskId + "_callback")) { | |
135 | + | case s: String => | |
136 | + | s | |
137 | + | case _ => | |
138 | + | "no callback" | |
139 | + | } | |
140 | + | let caller = match getString((taskId + "_caller")) { | |
141 | + | case s: String => | |
142 | + | s | |
143 | + | case _ => | |
144 | + | "no callback" | |
145 | + | } | |
142 | 146 | if (!(correctAgent)) | |
143 | 147 | then throw("Task may only be submitted by the agent who checked the task out!") | |
144 | 148 | else if ((type == "not set")) | |
145 | 149 | 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_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
147 | - | } | |
148 | - | ||
149 | - | ||
150 | - | ||
151 | - | @Callable(i) | |
152 | - | func commitChatGPTTask (taskId,response) = { | |
153 | - | let callerPublicKey = toBase58String(i.callerPublicKey) | |
154 | - | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
155 | - | let timestamp = lastBlock.timestamp | |
156 | - | if (!(correctAgent)) | |
157 | - | then throw("Task may only be submitted by the agent who checked the task out!") | |
158 | - | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] | |
150 | + | else if ((callback != "no callback")) | |
151 | + | then { | |
152 | + | let result = invoke(Address(fromBase58String(caller)), callback, [response], nil) | |
153 | + | [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
154 | + | } | |
155 | + | else [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
159 | 156 | } | |
160 | 157 | ||
161 | 158 | ||
162 | 159 | ||
163 | 160 | @Callable(i) | |
164 | 161 | func buy () = { | |
165 | 162 | let WAVES_USDT_ORACLE = addressFromStringValue("3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy") | |
166 | 163 | let WAVES_USDT_ORACLE_KEY = "%s%s__price__WAVES-USDT" | |
167 | 164 | let USDT_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
168 | 165 | let USDC_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
169 | 166 | let BAI_ASSET_ID = "AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1" | |
170 | 167 | let numberOfPayments = size(i.payments) | |
171 | 168 | if ((numberOfPayments != 1)) | |
172 | 169 | then throw("Payment necessary!") | |
173 | 170 | else { | |
174 | 171 | let payment = i.payments[0] | |
175 | 172 | let feeAssetId = payment.assetId | |
176 | 173 | let feeAssetIdString = match feeAssetId { | |
177 | 174 | case b: ByteVector => | |
178 | 175 | toBase58String(b) | |
179 | 176 | case _ => | |
180 | 177 | "" | |
181 | 178 | } | |
182 | 179 | let paymentAmount = payment.amount | |
183 | 180 | let amount = if (!(isDefined(feeAssetId))) | |
184 | 181 | then { | |
185 | 182 | let wavesUsdtPrice = match getInteger(WAVES_USDT_ORACLE, WAVES_USDT_ORACLE_KEY) { | |
186 | 183 | case n: Int => | |
187 | 184 | n | |
188 | 185 | case _ => | |
189 | 186 | 0 | |
190 | 187 | } | |
191 | 188 | (fraction(paymentAmount, wavesUsdtPrice, 100000000) * 100) | |
192 | 189 | } | |
193 | 190 | else if ((feeAssetIdString == USDT_ASSET_ID)) | |
194 | 191 | then (paymentAmount * 100) | |
195 | 192 | else if ((feeAssetIdString == USDC_ASSET_ID)) | |
196 | 193 | then (paymentAmount * 100) | |
197 | 194 | else throw("payment necessary in Waves, USDC or USDT!") | |
198 | 195 | [ScriptTransfer(i.caller, amount, fromBase58String(BAI_ASSET_ID))] | |
199 | 196 | } | |
200 | 197 | } | |
201 | 198 | ||
202 | 199 | ||
203 | 200 | @Verifier(tx) | |
204 | 201 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
205 | 202 |
github/deemru/w8io/026f985 52.53 ms ◑