tx · 88e1FpicY1ovEaZ72UL8zXSdeTFu4BXtCZcd2gjra5sT
3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV: -0.05000000 Waves
2023.06.08 12:07 [2613491] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves
{
"type": 13,
"id": "88e1FpicY1ovEaZ72UL8zXSdeTFu4BXtCZcd2gjra5sT",
"fee": 5000000,
"feeAssetId": null,
"timestamp": 1686215296670,
"version": 2,
"chainId": 84,
"sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV",
"senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE",
"proofs": [
"3vL1vsFffFT4cZrcE3awKP3rMgj89sFQKZA2hmzKjS71wK4jimyEmS7tJsHLBsYtkxeDWp8wko5N9YptC3jac9Eo"
],
"script": "base64:BgISCAISAwoBCBIDCgEIEgQKAggIDAARQUlfVE9LRU5fQVNTRVRfSUQBIJPhcjhxBJtq6JpjHwQkt2RTlyw+vGYLg3SvaLskjeJCAAtTVEFUVVNfT1BFTgIEb3BlbgASU1RBVFVTX0NIRUNLRURfT1VUAgtjaGVja2VkX291dAALU1RBVFVTX0RPTkUCBGRvbmUADkNIRUNLRURfT1VUX0JZAg9fY2hlY2tlZF9vdXRfYnkAE1NJTVBMRV9DSEFUR1BUX1RBU0sCFHNpbWlwbGVfQ2hhdEdQVF90YXNrABBDSEVDS19PVVRfSEVJR0hUAhFfY2hlY2tfb3V0X2hlaWdodAAPUkVHSVNURVJfSEVJR0hUAhBfcmVnaXN0ZXJfaGVpZ2h0AA1DT01NSVRfSEVJR0hUAg5fY29tbWl0X2hlaWdodAEPY2FuQmVDaGVja2VkT3V0AQZ0YXNrSWQEBnN0YXR1cwkAnQgCBQR0aGlzCQCsAgIFBnRhc2tJZAIHX3N0YXR1cwkAAAIFBnN0YXR1cwULU1RBVFVTX09QRU4BDmlzQ29ycmVjdEFnZW50AgZ0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hhdEdQVFRhc2sCBHR4SWQIcmVzcG9uc2UEBnRhc2tJZAkBCWdldFRhc2tJZAEFBHR4SWQED2NhbGxlclB1YmxpY0tleQkAsAkBCAUBaQ9jYWxsZXJQdWJsaWNLZXkEDGNvcnJlY3RBZ2VudAkBDmlzQ29ycmVjdEFnZW50AgUGdGFza0lkBQ9jYWxsZXJQdWJsaWNLZXkECXRpbWVzdGFtcAgFCWxhc3RCbG9jawl0aW1lc3RhbXADCQEBIQEFDGNvcnJlY3RBZ2VudAkAAgECQVRhc2sgbWF5IG9ubHkgYmUgc3VibWl0dGVkIGJ5IHRoZSBhZ2VudCB3aG8gY2hlY2tlZCB0aGUgdGFzayBvdXQhCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgUGdGFza0lkAgdfc3RhdHVzBQtTVEFUVVNfRE9ORQkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBnRhc2tJZAIHX3Jlc3VsdAUIcmVzcG9uc2UJAMwIAgkBDEludGVnZXJFbnRyeQIJAKwCAgUGdGFza0lkBQ1DT01NSVRfSEVJR0hUBQZoZWlnaHQJAMwIAgkBDEludGVnZXJFbnRyeQIJAKwCAgUGdGFza0lkAhFfY29tbWl0X3RpbWVzdGFtcAUJdGltZXN0YW1wBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5adciOg==",
"height": 2613491,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 49FFoEg2Skhtwq43ZkHFswZg2y34DTuqMUn5vaUsrGyB
Next: 5QieAPFibJjRStRtjoFYnsznM3J9AMo288W2GjskhD3q
Diff:
Old | New | | Differences |
---|
11 | 11 | | |
---|
12 | 12 | | let CHECKED_OUT_BY = "_checked_out_by" |
---|
13 | 13 | | |
---|
| 14 | + | let SIMPLE_CHATGPT_TASK = "simiple_ChatGPT_task" |
---|
| 15 | + | |
---|
| 16 | + | let CHECK_OUT_HEIGHT = "_check_out_height" |
---|
| 17 | + | |
---|
| 18 | + | let REGISTER_HEIGHT = "_register_height" |
---|
| 19 | + | |
---|
| 20 | + | let COMMIT_HEIGHT = "_commit_height" |
---|
| 21 | + | |
---|
14 | 22 | | func canBeCheckedOut (taskId) = { |
---|
15 | 23 | | let status = getString(this, (taskId + "_status")) |
---|
16 | 24 | | (status == STATUS_OPEN) |
---|
|
23 | 31 | | } |
---|
24 | 32 | | |
---|
25 | 33 | | |
---|
| 34 | + | func getTaskId (txId) = { |
---|
| 35 | + | let callerPublicKey = match getString(this, (txId + "_initializer")) { |
---|
| 36 | + | case str: String => |
---|
| 37 | + | str |
---|
| 38 | + | case _ => |
---|
| 39 | + | "" |
---|
| 40 | + | } |
---|
| 41 | + | match getString(this, ((txId + "_") + callerPublicKey)) { |
---|
| 42 | + | case str: String => |
---|
| 43 | + | str |
---|
| 44 | + | case _ => |
---|
| 45 | + | "" |
---|
| 46 | + | } |
---|
| 47 | + | } |
---|
| 48 | + | |
---|
| 49 | + | |
---|
26 | 50 | | @Callable(i) |
---|
27 | 51 | | func registerChatGPTTask (description) = { |
---|
28 | 52 | | let callerPublicKey = toUtf8String(i.callerPublicKey) |
---|
|
30 | 54 | | let payment = i.payments[0] |
---|
31 | 55 | | let fee = payment.amount |
---|
32 | 56 | | let feeAssetId = payment.assetId |
---|
| 57 | + | let taskId = ((txId + "_") + callerPublicKey) |
---|
| 58 | + | let timestamp = lastBlock.timestamp |
---|
33 | 59 | | if ((feeAssetId != AI_TOKEN_ASSET_ID)) |
---|
34 | 60 | | then throw("Payment only possible in the AI Token!") |
---|
35 | | - | else if ((100000000 > fee)) |
---|
36 | | - | then throw("Payment needs to be at least on AI Token!") |
---|
37 | | - | else [StringEntry((txId + "_description"), description), StringEntry((txId + "_initializer"), callerPublicKey), StringEntry((txId + "_status"), STATUS_OPEN)] |
---|
| 61 | + | else if ((10000000 > fee)) |
---|
| 62 | + | then throw("Payment needs to be at least 0.1 AI Token!") |
---|
| 63 | + | 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)] |
---|
38 | 64 | | } |
---|
39 | 65 | | |
---|
40 | 66 | | |
---|
41 | 67 | | |
---|
42 | 68 | | @Callable(i) |
---|
43 | | - | func checkoutChatGPTTask (taskId) = { |
---|
| 69 | + | func checkoutChatGPTTask (txId) = { |
---|
| 70 | + | let taskId = getTaskId(txId) |
---|
44 | 71 | | let callerPublicKey = toUtf8String(i.callerPublicKey) |
---|
45 | 72 | | let taskStillOpen = canBeCheckedOut(taskId) |
---|
| 73 | + | let timestamp = lastBlock.timestamp |
---|
46 | 74 | | if (!(taskStillOpen)) |
---|
47 | 75 | | then throw("Task not open for checkout!") |
---|
48 | | - | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT)] |
---|
| 76 | + | 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)] |
---|
49 | 77 | | } |
---|
50 | 78 | | |
---|
51 | 79 | | |
---|
52 | 80 | | |
---|
53 | 81 | | @Callable(i) |
---|
54 | | - | func finishChatGPTTask (taskId,response) = { |
---|
| 82 | + | func commitChatGPTTask (txId,response) = { |
---|
| 83 | + | let taskId = getTaskId(txId) |
---|
55 | 84 | | let callerPublicKey = toUtf8String(i.callerPublicKey) |
---|
56 | 85 | | let correctAgent = isCorrectAgent(taskId, callerPublicKey) |
---|
| 86 | + | let timestamp = lastBlock.timestamp |
---|
57 | 87 | | if (!(correctAgent)) |
---|
58 | 88 | | then throw("Task may only be submitted by the agent who checked the task out!") |
---|
59 | | - | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response)] |
---|
| 89 | + | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] |
---|
60 | 90 | | } |
---|
61 | 91 | | |
---|
62 | 92 | | |
---|
Full:
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 | + | let SIMPLE_CHATGPT_TASK = "simiple_ChatGPT_task" |
---|
| 15 | + | |
---|
| 16 | + | let CHECK_OUT_HEIGHT = "_check_out_height" |
---|
| 17 | + | |
---|
| 18 | + | let REGISTER_HEIGHT = "_register_height" |
---|
| 19 | + | |
---|
| 20 | + | let COMMIT_HEIGHT = "_commit_height" |
---|
| 21 | + | |
---|
14 | 22 | | func canBeCheckedOut (taskId) = { |
---|
15 | 23 | | let status = getString(this, (taskId + "_status")) |
---|
16 | 24 | | (status == STATUS_OPEN) |
---|
17 | 25 | | } |
---|
18 | 26 | | |
---|
19 | 27 | | |
---|
20 | 28 | | func isCorrectAgent (taskId,agentId) = { |
---|
21 | 29 | | let checkoutAgentId = getString(this, (taskId + CHECKED_OUT_BY)) |
---|
22 | 30 | | (checkoutAgentId == agentId) |
---|
23 | 31 | | } |
---|
24 | 32 | | |
---|
25 | 33 | | |
---|
| 34 | + | func getTaskId (txId) = { |
---|
| 35 | + | let callerPublicKey = match getString(this, (txId + "_initializer")) { |
---|
| 36 | + | case str: String => |
---|
| 37 | + | str |
---|
| 38 | + | case _ => |
---|
| 39 | + | "" |
---|
| 40 | + | } |
---|
| 41 | + | match getString(this, ((txId + "_") + callerPublicKey)) { |
---|
| 42 | + | case str: String => |
---|
| 43 | + | str |
---|
| 44 | + | case _ => |
---|
| 45 | + | "" |
---|
| 46 | + | } |
---|
| 47 | + | } |
---|
| 48 | + | |
---|
| 49 | + | |
---|
26 | 50 | | @Callable(i) |
---|
27 | 51 | | func registerChatGPTTask (description) = { |
---|
28 | 52 | | let callerPublicKey = toUtf8String(i.callerPublicKey) |
---|
29 | 53 | | let txId = toUtf8String(i.transactionId) |
---|
30 | 54 | | let payment = i.payments[0] |
---|
31 | 55 | | let fee = payment.amount |
---|
32 | 56 | | let feeAssetId = payment.assetId |
---|
| 57 | + | let taskId = ((txId + "_") + callerPublicKey) |
---|
| 58 | + | let timestamp = lastBlock.timestamp |
---|
33 | 59 | | if ((feeAssetId != AI_TOKEN_ASSET_ID)) |
---|
34 | 60 | | then throw("Payment only possible in the AI Token!") |
---|
35 | | - | else if ((100000000 > fee)) |
---|
36 | | - | then throw("Payment needs to be at least on AI Token!") |
---|
37 | | - | else [StringEntry((txId + "_description"), description), StringEntry((txId + "_initializer"), callerPublicKey), StringEntry((txId + "_status"), STATUS_OPEN)] |
---|
| 61 | + | else if ((10000000 > fee)) |
---|
| 62 | + | then throw("Payment needs to be at least 0.1 AI Token!") |
---|
| 63 | + | 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)] |
---|
38 | 64 | | } |
---|
39 | 65 | | |
---|
40 | 66 | | |
---|
41 | 67 | | |
---|
42 | 68 | | @Callable(i) |
---|
43 | | - | func checkoutChatGPTTask (taskId) = { |
---|
| 69 | + | func checkoutChatGPTTask (txId) = { |
---|
| 70 | + | let taskId = getTaskId(txId) |
---|
44 | 71 | | let callerPublicKey = toUtf8String(i.callerPublicKey) |
---|
45 | 72 | | let taskStillOpen = canBeCheckedOut(taskId) |
---|
| 73 | + | let timestamp = lastBlock.timestamp |
---|
46 | 74 | | if (!(taskStillOpen)) |
---|
47 | 75 | | then throw("Task not open for checkout!") |
---|
48 | | - | else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT)] |
---|
| 76 | + | 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)] |
---|
49 | 77 | | } |
---|
50 | 78 | | |
---|
51 | 79 | | |
---|
52 | 80 | | |
---|
53 | 81 | | @Callable(i) |
---|
54 | | - | func finishChatGPTTask (taskId,response) = { |
---|
| 82 | + | func commitChatGPTTask (txId,response) = { |
---|
| 83 | + | let taskId = getTaskId(txId) |
---|
55 | 84 | | let callerPublicKey = toUtf8String(i.callerPublicKey) |
---|
56 | 85 | | let correctAgent = isCorrectAgent(taskId, callerPublicKey) |
---|
| 86 | + | let timestamp = lastBlock.timestamp |
---|
57 | 87 | | if (!(correctAgent)) |
---|
58 | 88 | | then throw("Task may only be submitted by the agent who checked the task out!") |
---|
59 | | - | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response)] |
---|
| 89 | + | else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)] |
---|
60 | 90 | | } |
---|
61 | 91 | | |
---|
62 | 92 | | |
---|
63 | 93 | | @Verifier(tx) |
---|
64 | 94 | | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
65 | 95 | | |
---|