tx · GZtrLmwpweSUDTLzjPPuKXa8M8dQXoQUWpcnJChWEkaF 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV: -0.05000000 Waves 2024.10.28 10:20 [3346414] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves
{ "type": 13, "id": "GZtrLmwpweSUDTLzjPPuKXa8M8dQXoQUWpcnJChWEkaF", "fee": 5000000, "feeAssetId": null, "timestamp": 1730100027208, "version": 2, "chainId": 84, "sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV", "senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE", "proofs": [ "64mJrgSznUpGLdYK33sKKVj7M6tqAc6y2CmuWCHdJNJWo91QT7DRPosTsfGEBZbE7cB6cPepLLSFgh8nvNznpv9u" ], "script": "base64:BgIbCAISBAoCCAgSBQoDCAgIEgQKAggIEgQKAggIDAARQUlfVE9LRU5fQVNTRVRfSUQBIJPhcjhxBJtq6JpjHwQkt2RTlyw+vGYLg3SvaLskjeJCAAtTVEFUVVNfT1BFTgIEb3BlbgASU1RBVFVTX0NIRUNLRURfT1VUAgtjaGVja2VkX291dAALU1RBVFVTX0RPTkUCBGRvbmUADkNIRUNLRURfT1VUX0JZAhBfY2hlY2tlZF9vdXRfYnlfABNTSU1QTEVfQ0hBVEdQVF9UQVNLAhNzaW1wbGVfQ2hhdEdQVF90YXNrABBDSEVDS19PVVRfSEVJR0hUAhJfY2hlY2tfb3V0X2hlaWdodF8AD1JFR0lTVEVSX0hFSUdIVAIRX3JlZ2lzdGVyX2hlaWdodF8ADUNPTU1JVF9IRUlHSFQCD19jb21taXRfaGVpZ2h0XwEPY2FuQmVDaGVja2VkT3V0AgZ0YXNrSWQEdHlwZQQGc3RhdHVzCQCdCAIFBHRoaXMJAKwCAgkArAICBQZ0YXNrSWQCCF9zdGF0dXNfBQR0eXBlCQAAAgUGc3RhdHVzBQtTVEFUVVNf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lzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICBQZ0YXNrSWQCCF9zdGF0dXNfBQR0eXBlBQtTVEFUVVNfRE9ORQkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUGdGFza0lkAghfcmVzdWx0XwUEdHlwZQUIcmVzcG9uc2UJAMwIAgkBDEludGVnZXJFbnRyeQIJAKwCAgkArAICBQZ0YXNrSWQFDUNPTU1JVF9IRUlHSFQFBHR5cGUFBmhlaWdodAkAzAgCCQEMSW50ZWdlckVudHJ5AgkArAICCQCsAgIFBnRhc2tJZAISX2NvbW1pdF90aW1lc3RhbXBfBQR0eXBlBQl0aW1lc3RhbXAJAMwIAgkBC0RlbGV0ZUVudHJ5AQkArAICCQCsAgIJAKwCAgkArAICCQCsAgICD2NoZWNrZWRfb3V0X2J5XwUPY2FsbGVyUHVibGljS2V5AgFfBQR0eXBlAgFfBQZ0YXNrSWQFA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkmP4uL", "height": 3346414, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8FfhZKXNXG9SNHYDcsrANSKfKaSobwU281H5wQXSCBMo Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let a = base58' | |
4 | + | let a = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1' | |
5 | 5 | ||
6 | - | let b = " | |
6 | + | let b = "open" | |
7 | 7 | ||
8 | - | let c = | |
8 | + | let c = "checked_out" | |
9 | 9 | ||
10 | - | @Callable(d) | |
11 | - | func getAnswerForChat (e,f) = { | |
12 | - | let g = size(d.payments) | |
13 | - | if ((g != 1)) | |
10 | + | let d = "done" | |
11 | + | ||
12 | + | let e = "_checked_out_by_" | |
13 | + | ||
14 | + | let f = "simple_ChatGPT_task" | |
15 | + | ||
16 | + | let g = "_check_out_height_" | |
17 | + | ||
18 | + | let h = "_register_height_" | |
19 | + | ||
20 | + | let i = "_commit_height_" | |
21 | + | ||
22 | + | func j (k,l) = { | |
23 | + | let m = getString(this, ((k + "_status_") + l)) | |
24 | + | (m == b) | |
25 | + | } | |
26 | + | ||
27 | + | ||
28 | + | func n (k,o,l) = { | |
29 | + | let p = getString(this, ((k + e) + l)) | |
30 | + | (p == o) | |
31 | + | } | |
32 | + | ||
33 | + | ||
34 | + | func q (l) = { | |
35 | + | let r = getInteger(this, ("price_" + l)) | |
36 | + | if ($isInstanceOf(r, "Int")) | |
37 | + | then { | |
38 | + | let s = r | |
39 | + | s | |
40 | + | } | |
41 | + | else -1 | |
42 | + | } | |
43 | + | ||
44 | + | ||
45 | + | @Callable(s) | |
46 | + | func registerTask (t,l) = { | |
47 | + | let u = size(s.payments) | |
48 | + | if ((u != 1)) | |
14 | 49 | then throw("Payment necessary!") | |
15 | 50 | else { | |
16 | - | let h = d.payments[0] | |
17 | - | let i = h.amount | |
18 | - | let j = h.assetId | |
19 | - | let k = { | |
20 | - | let l = getInteger(Address(fromBase58String(b)), "price_fullchatgpt") | |
21 | - | if ($isInstanceOf(l, "Int")) | |
51 | + | let v = toBase58String(s.callerPublicKey) | |
52 | + | let w = toBase58String(s.transactionId) | |
53 | + | let x = s.payments[0] | |
54 | + | let y = x.amount | |
55 | + | let z = x.assetId | |
56 | + | let k = ((w + "_") + v) | |
57 | + | let A = lastBlock.timestamp | |
58 | + | let B = q(l) | |
59 | + | let C = { | |
60 | + | let r = getInteger(this, ("dao_user_" + v)) | |
61 | + | if ($isInstanceOf(r, "Int")) | |
22 | 62 | then { | |
23 | - | let | |
24 | - | | |
63 | + | let D = r | |
64 | + | (D + y) | |
25 | 65 | } | |
26 | - | else | |
66 | + | else y | |
27 | 67 | } | |
28 | - | if (if ((j != c)) | |
29 | - | then true | |
30 | - | else (k > i)) | |
31 | - | then throw("Payment of the minimal BAI amount necessary!") | |
32 | - | else { | |
33 | - | let n = toBase58String(d.callerPublicKey) | |
34 | - | let o = toString(lastBlock.timestamp) | |
35 | - | let p = invoke(Address(fromBase58String(b)), "registerTaskCallback", [f, "fullchatgpt", "callback"], [AttachedPayment(c, 10000000)]) | |
36 | - | if ((p == p)) | |
37 | - | then { | |
38 | - | let q = { | |
39 | - | let l = p | |
40 | - | if ($isInstanceOf(l, "String")) | |
41 | - | then { | |
42 | - | let r = l | |
43 | - | r | |
44 | - | } | |
45 | - | else throw("Unknown task id!") | |
46 | - | } | |
47 | - | [StringEntry((e + "_latest"), f), StringEntry((e + "_status"), "waiting"), StringEntry(q, e), StringEntry(((n + "_") + e), ((((f + "_") + o) + "_") + "waiting")), StringEntry((e + "_initiator"), n)] | |
48 | - | } | |
49 | - | else throw("Strict value is not equal to itself.") | |
50 | - | } | |
68 | + | let E = { | |
69 | + | let r = getInteger(this, "dao_sum") | |
70 | + | if ($isInstanceOf(r, "Int")) | |
71 | + | then { | |
72 | + | let D = r | |
73 | + | (D + y) | |
74 | + | } | |
75 | + | else y | |
76 | + | } | |
77 | + | if ((z != a)) | |
78 | + | then throw("Payment only possible in the AI Token!") | |
79 | + | else if ((B == -1)) | |
80 | + | then throw("Task type not supported!") | |
81 | + | else if ((B > y)) | |
82 | + | then throw((("Payment needs to be at least " + toString(B)) + " BAI Token!")) | |
83 | + | else [StringEntry(((k + "_description_") + l), t), StringEntry(((w + "_initializer_") + l), v), StringEntry(((k + "_status_") + l), b), StringEntry((k + "_type"), l), IntegerEntry(((k + h) + l), height), IntegerEntry(((k + "_register_timestamp_") + l), A), BooleanEntry(((("open_" + l) + "_") + k), true), IntegerEntry("dao_sum", E), IntegerEntry(("dao_user_" + v), C)] | |
51 | 84 | } | |
52 | 85 | } | |
53 | 86 | ||
54 | 87 | ||
55 | 88 | ||
56 | - | @Callable(d) | |
57 | - | func callback (q,f) = if ((d.callerPublicKey != a)) | |
58 | - | then throw("Only BAI Contract is allowed to call the callback!") | |
59 | - | else { | |
60 | - | let e = { | |
61 | - | let l = getString(q) | |
62 | - | if ($isInstanceOf(l, "String")) | |
63 | - | then { | |
64 | - | let r = l | |
65 | - | r | |
66 | - | } | |
67 | - | else throw("Chat ID for task id not found!") | |
89 | + | @Callable(s) | |
90 | + | func registerTaskCallback (t,l,F) = { | |
91 | + | let u = size(s.payments) | |
92 | + | if ((u != 1)) | |
93 | + | then throw("Payment necessary!") | |
94 | + | else { | |
95 | + | let v = toBase58String(s.callerPublicKey) | |
96 | + | let G = toString(s.caller) | |
97 | + | let w = toBase58String(s.transactionId) | |
98 | + | let x = s.payments[0] | |
99 | + | let y = x.amount | |
100 | + | let z = x.assetId | |
101 | + | let k = ((w + "_") + v) | |
102 | + | let A = lastBlock.timestamp | |
103 | + | let B = q(l) | |
104 | + | if ((z != a)) | |
105 | + | then throw("Payment only possible in the AI Token!") | |
106 | + | else if ((B == -1)) | |
107 | + | then throw("Task type not supported!") | |
108 | + | else if ((B > y)) | |
109 | + | then throw((("Payment needs to be at least " + toString(B)) + " BAI Token!")) | |
110 | + | else $Tuple2([StringEntry(((k + "_description_") + l), t), StringEntry(((w + "_initializer_") + l), v), StringEntry(((k + "_callback_") + l), F), StringEntry(((k + "_caller_") + l), G), StringEntry(((k + "_status_") + l), b), StringEntry((k + "_type"), l), IntegerEntry(((k + h) + l), height), IntegerEntry(((k + "_register_timestamp_") + l), A), BooleanEntry(((("open_" + l) + "_") + k), true), StringEntry(((("callback_accounting_" + w) + "_") + toString(height)), k)], k) | |
68 | 111 | } | |
69 | - | let n = { | |
70 | - | let l = getString((e + "_initiator")) | |
71 | - | if ($isInstanceOf(l, "String")) | |
72 | - | then { | |
73 | - | let r = l | |
74 | - | r | |
75 | - | } | |
76 | - | else throw("No initiator found!") | |
77 | - | } | |
78 | - | let o = toString(lastBlock.timestamp) | |
79 | - | [StringEntry((e + "_latest"), f), StringEntry((e + "_status"), "done"), StringEntry(((n + "_") + e), ((((f + "_") + o) + "_") + "done")), StringEntry("caller", toBase58String(d.callerPublicKey))] | |
80 | - | } | |
112 | + | } | |
81 | 113 | ||
82 | 114 | ||
83 | - | @Verifier(s) | |
84 | - | func t () = sigVerify(s.bodyBytes, s.proofs[0], s.senderPublicKey) | |
115 | + | ||
116 | + | @Callable(s) | |
117 | + | func checkoutTask (k,l) = { | |
118 | + | let v = toBase58String(s.callerPublicKey) | |
119 | + | let H = j(k, l) | |
120 | + | let A = lastBlock.timestamp | |
121 | + | if (!(H)) | |
122 | + | then throw("Task not open for checkout!") | |
123 | + | else [StringEntry(((k + e) + l), v), StringEntry(((k + "_status_") + l), c), IntegerEntry(((k + g) + l), height), IntegerEntry(((k + "_check_out_timestamp_") + l), A), BooleanEntry(((((("checked_out_by_" + v) + "_") + l) + "_") + k), true), DeleteEntry(((("open_" + l) + "_") + k))] | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | ||
128 | + | @Callable(s) | |
129 | + | func commitTask (k,I) = { | |
130 | + | let v = toBase58String(s.callerPublicKey) | |
131 | + | let l = { | |
132 | + | let r = getString((k + "_type")) | |
133 | + | if ($isInstanceOf(r, "String")) | |
134 | + | then { | |
135 | + | let J = r | |
136 | + | J | |
137 | + | } | |
138 | + | else "not set" | |
139 | + | } | |
140 | + | let K = n(k, v, l) | |
141 | + | let A = lastBlock.timestamp | |
142 | + | let F = { | |
143 | + | let r = getString(((k + "_callback_") + l)) | |
144 | + | if ($isInstanceOf(r, "String")) | |
145 | + | then { | |
146 | + | let J = r | |
147 | + | J | |
148 | + | } | |
149 | + | else "no callback" | |
150 | + | } | |
151 | + | let G = { | |
152 | + | let r = getString(((k + "_caller_") + l)) | |
153 | + | if ($isInstanceOf(r, "String")) | |
154 | + | then { | |
155 | + | let J = r | |
156 | + | J | |
157 | + | } | |
158 | + | else "no callback" | |
159 | + | } | |
160 | + | if (!(K)) | |
161 | + | then throw("Task may only be submitted by the agent who checked the task out!") | |
162 | + | else if ((l == "not set")) | |
163 | + | then throw("Can not identify type of task id") | |
164 | + | else if ((F != "no callback")) | |
165 | + | then { | |
166 | + | let L = invoke(Address(fromBase58String(G)), F, [k, I], nil) | |
167 | + | if ((L == L)) | |
168 | + | then [StringEntry(((k + "_status_") + l), d), StringEntry(((k + "_result_") + l), I), IntegerEntry(((k + i) + l), height), IntegerEntry(((k + "_commit_timestamp_") + l), A), DeleteEntry(((((("checked_out_by_" + v) + "_") + l) + "_") + k))] | |
169 | + | else throw("Strict value is not equal to itself.") | |
170 | + | } | |
171 | + | else [StringEntry(((k + "_status_") + l), d), StringEntry(((k + "_result_") + l), I), IntegerEntry(((k + i) + l), height), IntegerEntry(((k + "_commit_timestamp_") + l), A), DeleteEntry(((((("checked_out_by_" + v) + "_") + l) + "_") + k))] | |
172 | + | } | |
173 | + | ||
174 | + | ||
175 | + | @Verifier(M) | |
176 | + | func N () = sigVerify(M.bodyBytes, M.proofs[0], M.senderPublicKey) | |
85 | 177 |
github/deemru/w8io/169f3d6 32.55 ms ◑