tx · 87FwFz1XyTnm3U5d6WtNMByhHVRCyoVwRDre3CrtrspN 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV: -0.05000000 Waves 2023.07.30 16:16 [2688653] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves
{ "type": 13, "id": "87FwFz1XyTnm3U5d6WtNMByhHVRCyoVwRDre3CrtrspN", "fee": 5000000, "feeAssetId": null, "timestamp": 1690723054991, "version": 2, "chainId": 84, "sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV", "senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE", "proofs": [ "64XiAGTYgZAauLvRZMZ81crd5jiLDgR9kAPBqQKNfwZzuVZR9NK16ZLzpBFSNLegt5gz7Nx6CD6QsoPS7E7FYUGc" ], "script": "base64:BgIkCAISBAoCCAgSAwoBCBIECgIICBIDCgEIEgQKAggIEgQKAggIDQARQUlfVE9LRU5fQVNTRVRfSUQBIJPhcjhxBJtq6JpjHwQkt2RTlyw+vGYLg3SvaLskjeJCAAtTVEFUVVNfT1BFTgIEb3BlbgASU1RBVFVTX0NIRUNLRURfT1VUAgtjaGVja2VkX291dAALU1RBVFVTX0RPTkUCBGRvbmUADkNIRUNLRURfT1VUX0JZAg9fY2hlY2tlZF9vdXRfYnkAE1NJTVBMRV9DSEFUR1BUX1RBU0sCE3NpbXBsZV9DaGF0R1BUX3Rhc2sAEENIRUNLX09VVF9IRUlHSFQCEV9jaGVja19vdXRfaGVpZ2h0AA9SRUdJU1RFUl9IRUlHSFQCEF9yZWdpc3Rlcl9oZWlnaHQADUNPTU1JVF9IRUlHSFQCDl9jb21taXRfaGVpZ2h0AQ9jYW5CZUNoZWNrZWRPdXQBBnRhc2tJZAQGc3RhdHVzCQCdCAIFBHRoaXMJAKwCAgUGdGFza0lkAgdfc3RhdHVzCQAAAgUGc3RhdHVzBQtTVEFUVVNfT1BFTgEOaXNDb3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IFBnRhc2tJZAUPY2FsbGVyUHVibGljS2V5BAl0aW1lc3RhbXAIBQlsYXN0QmxvY2sJdGltZXN0YW1wAwkBASEBBQxjb3JyZWN0QWdlbnQJAAIBAkFUYXNrIG1heSBvbmx5IGJlIHN1Ym1pdHRlZCBieSB0aGUgYWdlbnQgd2hvIGNoZWNrZWQgdGhlIHRhc2sgb3V0IQkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBnRhc2tJZAIHX3N0YXR1cwULU1RBVFVTX0RPTkUJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICBQZ0YXNrSWQCB19yZXN1bHQFCHJlc3BvbnNlCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQCsAgIFBnRhc2tJZAUNQ09NTUlUX0hFSUdIVAUGaGVpZ2h0CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQCsAgIFBnRhc2tJZAIRX2NvbW1pdF90aW1lc3RhbXAFCXRpbWVzdGFtcAUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleUNBEG8=", "height": 2688653, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CYQ2oFCXEVoX9JPtRQ7N1q1Jb6mrWBio9NB5f9rCBiRT Next: ApLJrssZrMbELDKVdv2Wi7nq9sGKTixuYBXeyJriDkVB Diff:
Old | New | Differences | |
---|---|---|---|
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | + | func getPriceForType (type) = match getInteger(this, ("price_" + type)) { | |
51 | + | case i: Int => | |
52 | + | i | |
53 | + | case _ => | |
54 | + | -1 | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | @Callable(i) | |
59 | + | func registerTask (description,type) = { | |
60 | + | let numberOfPayments = size(i.payments) | |
61 | + | if ((numberOfPayments != 1)) | |
62 | + | then throw("Payment necessary!") | |
63 | + | else { | |
64 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
65 | + | let txId = toBase58String(i.transactionId) | |
66 | + | let payment = i.payments[0] | |
67 | + | let fee = payment.amount | |
68 | + | let feeAssetId = payment.assetId | |
69 | + | let taskId = ((txId + "_") + callerPublicKey) | |
70 | + | let timestamp = lastBlock.timestamp | |
71 | + | let minFee = getPriceForType(type) | |
72 | + | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
73 | + | then throw("Payment only possible in the AI Token!") | |
74 | + | else if ((minFee == -1)) | |
75 | + | then throw("Task type not supported!") | |
76 | + | else if ((minFee > fee)) | |
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)] | |
79 | + | } | |
80 | + | } | |
81 | + | ||
82 | + | ||
83 | + | ||
50 | 84 | @Callable(i) | |
51 | 85 | func registerChatGPTTask (description) = { | |
52 | 86 | let numberOfPayments = size(i.payments) | |
71 | 105 | ||
72 | 106 | ||
73 | 107 | @Callable(i) | |
108 | + | func checkoutTask (taskId,type) = { | |
109 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
110 | + | let taskStillOpen = canBeCheckedOut(taskId) | |
111 | + | let timestamp = lastBlock.timestamp | |
112 | + | if (!(taskStillOpen)) | |
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))] | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
74 | 120 | func checkoutChatGPTTask (taskId) = { | |
75 | 121 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
76 | 122 | let taskStillOpen = canBeCheckedOut(taskId) | |
78 | 124 | if (!(taskStillOpen)) | |
79 | 125 | then throw("Task not open for checkout!") | |
80 | 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 | + | } | |
128 | + | ||
129 | + | ||
130 | + | ||
131 | + | @Callable(i) | |
132 | + | func commitTask (taskId,response) = { | |
133 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
134 | + | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
135 | + | let timestamp = lastBlock.timestamp | |
136 | + | if (!(correctAgent)) | |
137 | + | 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)] | |
81 | 139 | } | |
82 | 140 | ||
83 | 141 |
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 | + | func getPriceForType (type) = match getInteger(this, ("price_" + type)) { | |
51 | + | case i: Int => | |
52 | + | i | |
53 | + | case _ => | |
54 | + | -1 | |
55 | + | } | |
56 | + | ||
57 | + | ||
58 | + | @Callable(i) | |
59 | + | func registerTask (description,type) = { | |
60 | + | let numberOfPayments = size(i.payments) | |
61 | + | if ((numberOfPayments != 1)) | |
62 | + | then throw("Payment necessary!") | |
63 | + | else { | |
64 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
65 | + | let txId = toBase58String(i.transactionId) | |
66 | + | let payment = i.payments[0] | |
67 | + | let fee = payment.amount | |
68 | + | let feeAssetId = payment.assetId | |
69 | + | let taskId = ((txId + "_") + callerPublicKey) | |
70 | + | let timestamp = lastBlock.timestamp | |
71 | + | let minFee = getPriceForType(type) | |
72 | + | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
73 | + | then throw("Payment only possible in the AI Token!") | |
74 | + | else if ((minFee == -1)) | |
75 | + | then throw("Task type not supported!") | |
76 | + | else if ((minFee > fee)) | |
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)] | |
79 | + | } | |
80 | + | } | |
81 | + | ||
82 | + | ||
83 | + | ||
50 | 84 | @Callable(i) | |
51 | 85 | func registerChatGPTTask (description) = { | |
52 | 86 | let numberOfPayments = size(i.payments) | |
53 | 87 | if ((numberOfPayments != 1)) | |
54 | 88 | then throw("Payment necessary!") | |
55 | 89 | else { | |
56 | 90 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
57 | 91 | let txId = toBase58String(i.transactionId) | |
58 | 92 | let payment = i.payments[0] | |
59 | 93 | let fee = payment.amount | |
60 | 94 | let feeAssetId = payment.assetId | |
61 | 95 | let taskId = ((txId + "_") + callerPublicKey) | |
62 | 96 | let timestamp = lastBlock.timestamp | |
63 | 97 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
64 | 98 | then throw("Payment only possible in the AI Token!") | |
65 | 99 | else if ((10000000 > fee)) | |
66 | 100 | then throw("Payment needs to be at least 0.1 AI Token!") | |
67 | 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)] | |
68 | 102 | } | |
69 | 103 | } | |
70 | 104 | ||
71 | 105 | ||
72 | 106 | ||
73 | 107 | @Callable(i) | |
108 | + | func checkoutTask (taskId,type) = { | |
109 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
110 | + | let taskStillOpen = canBeCheckedOut(taskId) | |
111 | + | let timestamp = lastBlock.timestamp | |
112 | + | if (!(taskStillOpen)) | |
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))] | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
74 | 120 | func checkoutChatGPTTask (taskId) = { | |
75 | 121 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
76 | 122 | let taskStillOpen = canBeCheckedOut(taskId) | |
77 | 123 | let timestamp = lastBlock.timestamp | |
78 | 124 | if (!(taskStillOpen)) | |
79 | 125 | then throw("Task not open for checkout!") | |
80 | 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 | + | } | |
128 | + | ||
129 | + | ||
130 | + | ||
131 | + | @Callable(i) | |
132 | + | func commitTask (taskId,response) = { | |
133 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
134 | + | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
135 | + | let timestamp = lastBlock.timestamp | |
136 | + | if (!(correctAgent)) | |
137 | + | 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)] | |
81 | 139 | } | |
82 | 140 | ||
83 | 141 | ||
84 | 142 | ||
85 | 143 | @Callable(i) | |
86 | 144 | func commitChatGPTTask (taskId,response) = { | |
87 | 145 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
88 | 146 | let correctAgent = isCorrectAgent(taskId, callerPublicKey) | |
89 | 147 | let timestamp = lastBlock.timestamp | |
90 | 148 | if (!(correctAgent)) | |
91 | 149 | then throw("Task may only be submitted by the agent who checked the task out!") | |
92 | 150 | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] | |
93 | 151 | } | |
94 | 152 | ||
95 | 153 | ||
96 | 154 | @Verifier(tx) | |
97 | 155 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
98 | 156 |
github/deemru/w8io/169f3d6 26.76 ms ◑