@avaprotocol/sdk-js 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +7 -0
- package/grpc_codegen/avs.proto +297 -0
- package/grpc_codegen/avs.ts +3720 -0
- package/grpc_codegen/avs_grpc_pb.d.ts +211 -0
- package/grpc_codegen/avs_grpc_pb.js +347 -0
- package/{dist/index.d.cts → grpc_codegen/avs_pb.d.ts} +71 -182
- package/grpc_codegen/avs_pb.js +7543 -0
- package/jest.config.cjs +18 -0
- package/package.json +5 -8
- package/scripts/signMessage.js +27 -0
- package/src/__tests__/Client.e2e.test.ts +172 -0
- package/src/auth.js +7 -0
- package/src/auth.ts +3 -0
- package/src/config.js +22 -0
- package/src/config.ts +27 -0
- package/src/index.ts +136 -0
- package/src/rpc-client.ts +7 -0
- package/src/types.js +2 -0
- package/src/types.ts +47 -0
- package/tsconfig.json +19 -0
- package/dist/index.cjs +0 -4545
- package/dist/index.d.ts +0 -1069
- package/dist/index.js +0 -4528
package/.env.example
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package aggregator;
|
|
3
|
+
|
|
4
|
+
option go_package = "./avsproto";
|
|
5
|
+
|
|
6
|
+
import "google/protobuf/timestamp.proto";
|
|
7
|
+
import "google/protobuf/wrappers.proto";
|
|
8
|
+
|
|
9
|
+
message UUID {
|
|
10
|
+
string bytes = 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message Checkin {
|
|
14
|
+
string id = 1;
|
|
15
|
+
string address = 2;
|
|
16
|
+
string signature = 3;
|
|
17
|
+
|
|
18
|
+
message Status {
|
|
19
|
+
int64 uptime = 1;
|
|
20
|
+
int64 queueDepth = 2;
|
|
21
|
+
google.protobuf.Timestamp last_heartbeat = 3;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Status status = 4;
|
|
25
|
+
|
|
26
|
+
string version = 5;
|
|
27
|
+
int32 metricsPort = 6;
|
|
28
|
+
string remoteIP = 7;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message CheckinResp {
|
|
32
|
+
google.protobuf.Timestamp updated_at = 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
message SyncTasksReq {
|
|
36
|
+
string id = 1;
|
|
37
|
+
string address = 2;
|
|
38
|
+
string signature = 3;
|
|
39
|
+
int64 monotonic_clock = 4;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
enum TriggerType {
|
|
43
|
+
TimeTrigger = 0;
|
|
44
|
+
ContractQueryTrigger = 1;
|
|
45
|
+
ExpressionTrigger = 2;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
message TaskTrigger {
|
|
49
|
+
TriggerType trigger_type = 1;
|
|
50
|
+
|
|
51
|
+
TimeCondition schedule = 2;
|
|
52
|
+
ContractQueryCondition contract_query = 3;
|
|
53
|
+
ExpressionCondition expression = 4;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Simple timebase or cron syntax.
|
|
57
|
+
message TimeCondition {
|
|
58
|
+
repeated int64 fixed = 1;
|
|
59
|
+
string cron = 2;
|
|
60
|
+
}
|
|
61
|
+
// A contract method that return true/false
|
|
62
|
+
// Ideally to use when we already have an existing contract that perform the
|
|
63
|
+
// check.
|
|
64
|
+
// This method will be evaluate every block
|
|
65
|
+
message ContractQueryCondition {
|
|
66
|
+
string contract_address = 1;
|
|
67
|
+
string callmsg = 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// An arbitrary expression to express the condition.
|
|
71
|
+
// People can define condition example
|
|
72
|
+
// chainlinkPrice("address-of-eth-usd-pair") > 2644500 && queryContract("contractaddress", "callmsg")[2] < = 5
|
|
73
|
+
// By allow arbitrary expression, people can mix and match to create conplex
|
|
74
|
+
// condition that match their workload
|
|
75
|
+
//
|
|
76
|
+
// The function to be used need to be pre-defined on our task egnine runtime.
|
|
77
|
+
// When a new block is build, our engine will execute these check
|
|
78
|
+
//
|
|
79
|
+
// The expression language is re-present by https://expr-lang.org/
|
|
80
|
+
message ExpressionCondition {
|
|
81
|
+
string expression = 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
message SyncTasksResp {
|
|
85
|
+
string id = 1;
|
|
86
|
+
string checkType = 2;
|
|
87
|
+
|
|
88
|
+
TaskTrigger trigger = 3;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// TaskType represents what kind of work the task will perform
|
|
92
|
+
enum TaskType {
|
|
93
|
+
// Handle default/missing data
|
|
94
|
+
ETHTransferTask = 0;
|
|
95
|
+
|
|
96
|
+
// Generic contract execution which can be used for:
|
|
97
|
+
// ERC20 Transfer, NFT Transfer, auto reclaim, auto restaking etc
|
|
98
|
+
// When executing a contract we need at least 2 things:
|
|
99
|
+
// - target contract address
|
|
100
|
+
// - the message to send to that contract
|
|
101
|
+
ContractExecutionTask = 1;
|
|
102
|
+
|
|
103
|
+
GraphQLDataQueryTask = 2;
|
|
104
|
+
// Make call to a HTTP endpoint
|
|
105
|
+
HTTPAPICallTask = 3;
|
|
106
|
+
// CustomCode allow to run arbitraty JavaScript.
|
|
107
|
+
CustomCodeTask = 4;
|
|
108
|
+
BranchActionTask = 5;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// TaskStatus represents status of the task. The transition is as follow
|
|
112
|
+
enum TaskStatus {
|
|
113
|
+
Active = 0;
|
|
114
|
+
Completed = 1;
|
|
115
|
+
Failed = 2;
|
|
116
|
+
Canceled = 3;
|
|
117
|
+
Executing = 4;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
message ETHTransfer {
|
|
121
|
+
string destination = 1;
|
|
122
|
+
string amount = 2;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
message ContractExecution {
|
|
126
|
+
string contract_address = 1;
|
|
127
|
+
string call_data = 2;
|
|
128
|
+
|
|
129
|
+
string method = 3;
|
|
130
|
+
string encoded_params = 4;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
message GraphQLDataQuery {
|
|
134
|
+
// TODO: support graphql variable
|
|
135
|
+
string url = 1;
|
|
136
|
+
string query = 2;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
message HTTPAPICall {
|
|
140
|
+
string url = 1;
|
|
141
|
+
map<string, string> headers = 2;
|
|
142
|
+
string body = 3;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
enum CustomCodeType {
|
|
146
|
+
JavaScript = 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
message CustomCode {
|
|
150
|
+
CustomCodeType type = 1;
|
|
151
|
+
string body = 2;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
message ConditionJump {
|
|
155
|
+
string expression = 1;
|
|
156
|
+
string next = 2;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
message BranchAction {
|
|
160
|
+
ConditionJump If = 1;
|
|
161
|
+
repeated ConditionJump ElseIfs = 2;
|
|
162
|
+
ConditionJump Else = 3;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
message TaskAction {
|
|
166
|
+
TaskType task_type = 1;
|
|
167
|
+
|
|
168
|
+
string id = 2;
|
|
169
|
+
string name = 3;
|
|
170
|
+
|
|
171
|
+
// Next can be empty. In some kind of block, such as branching, the next is
|
|
172
|
+
// based on branching condition
|
|
173
|
+
repeated string next = 4;
|
|
174
|
+
|
|
175
|
+
// Transfer eth
|
|
176
|
+
ETHTransfer eth_transfer = 10;
|
|
177
|
+
// Run one ore more contracts. The call call also be batched with tool like
|
|
178
|
+
// multicall to wrap many calls
|
|
179
|
+
ContractExecution contract_execution = 11;
|
|
180
|
+
// Make call to a graphql endpoint
|
|
181
|
+
GraphQLDataQuery graphql_data_query = 12;
|
|
182
|
+
// Make call to a HTTP endpoint
|
|
183
|
+
HTTPAPICall http_data_query = 13;
|
|
184
|
+
// CustomCode allow to run arbitraty JavaScript.
|
|
185
|
+
CustomCode custom_code = 14;
|
|
186
|
+
BranchAction branch = 15;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
message Execution {
|
|
190
|
+
int64 epoch = 1;
|
|
191
|
+
string user_op_hash = 2;
|
|
192
|
+
string error = 3;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
message Task {
|
|
196
|
+
UUID id = 1;
|
|
197
|
+
string owner = 2;
|
|
198
|
+
string smart_account_address = 3;
|
|
199
|
+
TaskTrigger trigger = 4;
|
|
200
|
+
repeated TaskAction nodes = 5;
|
|
201
|
+
|
|
202
|
+
// task won't be check before this
|
|
203
|
+
int64 start_at = 6;
|
|
204
|
+
// task won't be run/check after this
|
|
205
|
+
int64 expired_at = 7;
|
|
206
|
+
// arbitrary data about this task
|
|
207
|
+
string memo = 8;
|
|
208
|
+
|
|
209
|
+
int64 completed_at = 9;
|
|
210
|
+
TaskStatus status = 10;
|
|
211
|
+
// repeatable means a task can continue to run even after the first execution
|
|
212
|
+
bool repeatable = 11;
|
|
213
|
+
repeated Execution executions = 12;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
message CreateTaskReq {
|
|
217
|
+
TaskTrigger trigger = 1;
|
|
218
|
+
repeated TaskAction actions = 2;
|
|
219
|
+
int64 start_at = 3;
|
|
220
|
+
int64 expired_at = 4;
|
|
221
|
+
string memo = 5;
|
|
222
|
+
// A repeatable task will continue to be run
|
|
223
|
+
bool repeatable = 6;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
message CreateTaskResp {
|
|
227
|
+
string id = 1;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
message NonceRequest {
|
|
231
|
+
string owner = 1;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
message NonceResp {
|
|
235
|
+
string nonce = 1;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
message AddressRequest {
|
|
239
|
+
string owner = 1;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
message AddressResp {
|
|
243
|
+
string smart_account_address = 1;
|
|
244
|
+
string nonce = 2;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
message ListTasksReq {}
|
|
248
|
+
|
|
249
|
+
message ListTasksResp {
|
|
250
|
+
message TaskItemResp {
|
|
251
|
+
string id = 1;
|
|
252
|
+
TaskStatus status = 2;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
repeated TaskItemResp tasks = 1;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
message GetKeyReq {
|
|
259
|
+
string owner = 1;
|
|
260
|
+
int64 expired_at = 2;
|
|
261
|
+
string signature = 3;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
message KeyResp {
|
|
265
|
+
string key=1;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
message UpdateChecksReq {
|
|
269
|
+
string address = 1;
|
|
270
|
+
string signature = 2;
|
|
271
|
+
repeated string id = 3;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
message UpdateChecksResp {
|
|
275
|
+
google.protobuf.Timestamp updated_at = 1;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
service Aggregator {
|
|
279
|
+
// Auth
|
|
280
|
+
rpc GetKey(GetKeyReq) returns (KeyResp) {};
|
|
281
|
+
|
|
282
|
+
// Smart Acccount
|
|
283
|
+
rpc GetNonce(NonceRequest) returns (NonceResp) {};
|
|
284
|
+
rpc GetSmartAccountAddress(AddressRequest) returns (AddressResp) {};
|
|
285
|
+
|
|
286
|
+
// Task Management
|
|
287
|
+
rpc CreateTask(CreateTaskReq) returns (CreateTaskResp) {};
|
|
288
|
+
rpc ListTasks(ListTasksReq) returns (ListTasksResp) {};
|
|
289
|
+
rpc GetTask(UUID) returns (Task) {};
|
|
290
|
+
rpc CancelTask(UUID) returns (google.protobuf.BoolValue) {};
|
|
291
|
+
rpc DeleteTask(UUID) returns (google.protobuf.BoolValue) {};
|
|
292
|
+
|
|
293
|
+
// Operator endpoint
|
|
294
|
+
rpc Ping(Checkin) returns (CheckinResp) {};
|
|
295
|
+
rpc SyncTasks(SyncTasksReq) returns (stream SyncTasksResp) {};
|
|
296
|
+
rpc UpdateChecks(UpdateChecksReq) returns (UpdateChecksResp) {};
|
|
297
|
+
}
|