@0xtrails/api 0.9.3 → 0.10.0
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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-typecheck.log +2 -2
- package/CHANGELOG.md +49 -0
- package/dist/trails-api.gen.d.ts +163 -4
- package/dist/trails-api.gen.d.ts.map +1 -1
- package/dist/trails-api.gen.js +170 -74
- package/dist/trails-onramp.gen.d.ts +529 -0
- package/dist/trails-onramp.gen.d.ts.map +1 -0
- package/dist/trails-onramp.gen.js +887 -0
- package/package.json +1 -1
- package/src/trails-api.gen.ts +584 -288
- package/src/trails-onramp.gen.ts +1261 -0
package/dist/trails-api.gen.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// trails-api v1
|
|
2
|
+
// trails-api v1 9923827ab0683bd37e4aa9e713fa728b4c930297
|
|
3
3
|
// --
|
|
4
|
-
// Code generated by Webrpc-gen@v0.
|
|
4
|
+
// Code generated by Webrpc-gen@v0.32.2 with typescript generator. DO NOT EDIT.
|
|
5
5
|
//
|
|
6
6
|
// webrpc-gen -schema=trails-api.ridl -target=typescript -client -service=Trails -methodTreeShake -ignore=@onramp -out=./clients/trails-api.gen.ts
|
|
7
7
|
// Webrpc description and code-gen version
|
|
8
|
-
export const WebrpcVersion =
|
|
8
|
+
export const WebrpcVersion = 'v1';
|
|
9
9
|
// Schema version of your RIDL schema
|
|
10
|
-
export const WebrpcSchemaVersion =
|
|
10
|
+
export const WebrpcSchemaVersion = 'v1';
|
|
11
11
|
// Schema hash generated from your RIDL schema
|
|
12
|
-
export const WebrpcSchemaHash =
|
|
12
|
+
export const WebrpcSchemaHash = '9923827ab0683bd37e4aa9e713fa728b4c930297';
|
|
13
13
|
//
|
|
14
14
|
// Schema types
|
|
15
15
|
//
|
|
@@ -25,8 +25,16 @@ export var RouteProvider;
|
|
|
25
25
|
RouteProvider["LIFI"] = "LIFI";
|
|
26
26
|
RouteProvider["RELAY"] = "RELAY";
|
|
27
27
|
RouteProvider["SUSHI"] = "SUSHI";
|
|
28
|
+
RouteProvider["WETH"] = "WETH";
|
|
28
29
|
RouteProvider["ZEROX"] = "ZEROX";
|
|
29
30
|
})(RouteProvider || (RouteProvider = {}));
|
|
31
|
+
export var FundMethod;
|
|
32
|
+
(function (FundMethod) {
|
|
33
|
+
FundMethod["WALLET"] = "WALLET";
|
|
34
|
+
FundMethod["DIRECT_TRANSFER"] = "DIRECT_TRANSFER";
|
|
35
|
+
FundMethod["ONRAMP_MESH"] = "ONRAMP_MESH";
|
|
36
|
+
FundMethod["ONRAMP_MELD"] = "ONRAMP_MELD";
|
|
37
|
+
})(FundMethod || (FundMethod = {}));
|
|
30
38
|
export var IntentStatus;
|
|
31
39
|
(function (IntentStatus) {
|
|
32
40
|
IntentStatus["QUOTED"] = "QUOTED";
|
|
@@ -44,6 +52,7 @@ export var TransactionType;
|
|
|
44
52
|
TransactionType["ORIGIN"] = "ORIGIN";
|
|
45
53
|
TransactionType["DESTINATION"] = "DESTINATION";
|
|
46
54
|
TransactionType["ROUTE"] = "ROUTE";
|
|
55
|
+
TransactionType["REFUND"] = "REFUND";
|
|
47
56
|
})(TransactionType || (TransactionType = {}));
|
|
48
57
|
export var TransactionContext;
|
|
49
58
|
(function (TransactionContext) {
|
|
@@ -79,6 +88,16 @@ export var CCTPTransferStatus;
|
|
|
79
88
|
CCTPTransferStatus["COMPLETE"] = "COMPLETE";
|
|
80
89
|
CCTPTransferStatus["FAILED"] = "FAILED";
|
|
81
90
|
})(CCTPTransferStatus || (CCTPTransferStatus = {}));
|
|
91
|
+
export var RelayTransferStatus;
|
|
92
|
+
(function (RelayTransferStatus) {
|
|
93
|
+
RelayTransferStatus["UNKNOWN"] = "UNKNOWN";
|
|
94
|
+
RelayTransferStatus["ON_HOLD"] = "ON_HOLD";
|
|
95
|
+
RelayTransferStatus["PENDING"] = "PENDING";
|
|
96
|
+
RelayTransferStatus["FETCHING"] = "FETCHING";
|
|
97
|
+
RelayTransferStatus["COMPLETE"] = "COMPLETE";
|
|
98
|
+
RelayTransferStatus["REFUNDED"] = "REFUNDED";
|
|
99
|
+
RelayTransferStatus["FAILED"] = "FAILED";
|
|
100
|
+
})(RelayTransferStatus || (RelayTransferStatus = {}));
|
|
82
101
|
export var SortOrder;
|
|
83
102
|
(function (SortOrder) {
|
|
84
103
|
SortOrder["DESC"] = "DESC";
|
|
@@ -116,183 +135,227 @@ export class Trails {
|
|
|
116
135
|
getExactInputRoutes: (req) => ['Trails', 'getExactInputRoutes', req],
|
|
117
136
|
getTokenList: (req) => ['Trails', 'getTokenList', req],
|
|
118
137
|
getTokenPrices: (req) => ['Trails', 'getTokenPrices', req],
|
|
138
|
+
getExchangeRate: (req) => ['Trails', 'getExchangeRate', req],
|
|
139
|
+
getCountryList: () => ['Trails', 'getCountryList'],
|
|
119
140
|
getTrailsContracts: () => ['Trails', 'getTrailsContracts'],
|
|
120
|
-
|
|
141
|
+
getEarnPools: (req) => ['Trails', 'getEarnPools', req],
|
|
142
|
+
getFiatCurrencyList: () => ['Trails', 'getFiatCurrencyList'],
|
|
143
|
+
getIntentTransactionHistory: (req) => ['Trails', 'getIntentTransactionHistory', req]
|
|
121
144
|
};
|
|
122
145
|
ping = (headers, signal) => {
|
|
123
|
-
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(
|
|
146
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
124
147
|
return buildResponse(res).then(_data => {
|
|
125
148
|
return JsonDecode(_data, 'PingResponse');
|
|
126
149
|
});
|
|
127
|
-
},
|
|
150
|
+
}, error => {
|
|
128
151
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
129
152
|
});
|
|
130
153
|
};
|
|
131
154
|
runtimeStatus = (headers, signal) => {
|
|
132
|
-
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(
|
|
155
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
133
156
|
return buildResponse(res).then(_data => {
|
|
134
157
|
return JsonDecode(_data, 'RuntimeStatusResponse');
|
|
135
158
|
});
|
|
136
|
-
},
|
|
159
|
+
}, error => {
|
|
137
160
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
138
161
|
});
|
|
139
162
|
};
|
|
140
163
|
clock = (headers, signal) => {
|
|
141
|
-
return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then(
|
|
164
|
+
return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
142
165
|
return buildResponse(res).then(_data => {
|
|
143
166
|
return JsonDecode(_data, 'ClockResponse');
|
|
144
167
|
});
|
|
145
|
-
},
|
|
168
|
+
}, error => {
|
|
146
169
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
147
170
|
});
|
|
148
171
|
};
|
|
149
172
|
quoteIntent = (req, headers, signal) => {
|
|
150
|
-
return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
173
|
+
return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
151
174
|
return buildResponse(res).then(_data => {
|
|
152
175
|
return JsonDecode(_data, 'QuoteIntentResponse');
|
|
153
176
|
});
|
|
154
|
-
},
|
|
177
|
+
}, error => {
|
|
155
178
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
156
179
|
});
|
|
157
180
|
};
|
|
158
181
|
commitIntent = (req, headers, signal) => {
|
|
159
|
-
return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
182
|
+
return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
160
183
|
return buildResponse(res).then(_data => {
|
|
161
184
|
return JsonDecode(_data, 'CommitIntentResponse');
|
|
162
185
|
});
|
|
163
|
-
},
|
|
186
|
+
}, error => {
|
|
164
187
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
165
188
|
});
|
|
166
189
|
};
|
|
167
190
|
executeIntent = (req, headers, signal) => {
|
|
168
|
-
return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
191
|
+
return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
169
192
|
return buildResponse(res).then(_data => {
|
|
170
193
|
return JsonDecode(_data, 'ExecuteIntentResponse');
|
|
171
194
|
});
|
|
172
|
-
},
|
|
195
|
+
}, error => {
|
|
173
196
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
174
197
|
});
|
|
175
198
|
};
|
|
176
199
|
waitIntentReceipt = (req, headers, signal) => {
|
|
177
|
-
return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
200
|
+
return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
178
201
|
return buildResponse(res).then(_data => {
|
|
179
202
|
return JsonDecode(_data, 'WaitIntentReceiptResponse');
|
|
180
203
|
});
|
|
181
|
-
},
|
|
204
|
+
}, error => {
|
|
182
205
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
183
206
|
});
|
|
184
207
|
};
|
|
185
208
|
getIntentReceipt = (req, headers, signal) => {
|
|
186
|
-
return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
209
|
+
return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
187
210
|
return buildResponse(res).then(_data => {
|
|
188
211
|
return JsonDecode(_data, 'GetIntentReceiptResponse');
|
|
189
212
|
});
|
|
190
|
-
},
|
|
213
|
+
}, error => {
|
|
191
214
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
192
215
|
});
|
|
193
216
|
};
|
|
194
217
|
getIntent = (req, headers, signal) => {
|
|
195
|
-
return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
218
|
+
return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
196
219
|
return buildResponse(res).then(_data => {
|
|
197
220
|
return JsonDecode(_data, 'GetIntentResponse');
|
|
198
221
|
});
|
|
199
|
-
},
|
|
222
|
+
}, error => {
|
|
200
223
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
201
224
|
});
|
|
202
225
|
};
|
|
203
226
|
searchIntents = (req, headers, signal) => {
|
|
204
|
-
return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
227
|
+
return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
205
228
|
return buildResponse(res).then(_data => {
|
|
206
229
|
return JsonDecode(_data, 'SearchIntentsResponse');
|
|
207
230
|
});
|
|
208
|
-
},
|
|
231
|
+
}, error => {
|
|
209
232
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
210
233
|
});
|
|
211
234
|
};
|
|
212
235
|
getIntentHistory = (req, headers, signal) => {
|
|
213
|
-
return this.fetch(this.url('GetIntentHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
236
|
+
return this.fetch(this.url('GetIntentHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
214
237
|
return buildResponse(res).then(_data => {
|
|
215
238
|
return JsonDecode(_data, 'GetIntentHistoryResponse');
|
|
216
239
|
});
|
|
217
|
-
},
|
|
240
|
+
}, error => {
|
|
218
241
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
219
242
|
});
|
|
220
243
|
};
|
|
221
244
|
abortIntent = (req, headers, signal) => {
|
|
222
|
-
return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
245
|
+
return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
223
246
|
return buildResponse(res).then(_data => {
|
|
224
247
|
return JsonDecode(_data, 'AbortIntentResponse');
|
|
225
248
|
});
|
|
226
|
-
},
|
|
249
|
+
}, error => {
|
|
227
250
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
228
251
|
});
|
|
229
252
|
};
|
|
230
253
|
getChains = (req, headers, signal) => {
|
|
231
|
-
return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
254
|
+
return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
232
255
|
return buildResponse(res).then(_data => {
|
|
233
256
|
return JsonDecode(_data, 'GetChainsResponse');
|
|
234
257
|
});
|
|
235
|
-
},
|
|
258
|
+
}, error => {
|
|
236
259
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
237
260
|
});
|
|
238
261
|
};
|
|
239
262
|
getExactOutputRoutes = (req, headers, signal) => {
|
|
240
|
-
return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
263
|
+
return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
241
264
|
return buildResponse(res).then(_data => {
|
|
242
265
|
return JsonDecode(_data, 'GetExactOutputRoutesResponse');
|
|
243
266
|
});
|
|
244
|
-
},
|
|
267
|
+
}, error => {
|
|
245
268
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
246
269
|
});
|
|
247
270
|
};
|
|
248
271
|
getExactInputRoutes = (req, headers, signal) => {
|
|
249
|
-
return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
272
|
+
return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
250
273
|
return buildResponse(res).then(_data => {
|
|
251
274
|
return JsonDecode(_data, 'GetExactInputRoutesResponse');
|
|
252
275
|
});
|
|
253
|
-
},
|
|
276
|
+
}, error => {
|
|
254
277
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
255
278
|
});
|
|
256
279
|
};
|
|
257
280
|
getTokenList = (req, headers, signal) => {
|
|
258
|
-
return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
281
|
+
return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
259
282
|
return buildResponse(res).then(_data => {
|
|
260
283
|
return JsonDecode(_data, 'GetTokenListResponse');
|
|
261
284
|
});
|
|
262
|
-
},
|
|
285
|
+
}, error => {
|
|
263
286
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
264
287
|
});
|
|
265
288
|
};
|
|
266
289
|
getTokenPrices = (req, headers, signal) => {
|
|
267
|
-
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
290
|
+
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
268
291
|
return buildResponse(res).then(_data => {
|
|
269
292
|
return JsonDecode(_data, 'GetTokenPricesResponse');
|
|
270
293
|
});
|
|
271
|
-
},
|
|
294
|
+
}, error => {
|
|
295
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
getExchangeRate = (req, headers, signal) => {
|
|
299
|
+
return this.fetch(this.url('GetExchangeRate'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
300
|
+
return buildResponse(res).then(_data => {
|
|
301
|
+
return JsonDecode(_data, 'GetExchangeRateResponse');
|
|
302
|
+
});
|
|
303
|
+
}, error => {
|
|
304
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
getCountryList = (headers, signal) => {
|
|
308
|
+
return this.fetch(this.url('GetCountryList'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
309
|
+
return buildResponse(res).then(_data => {
|
|
310
|
+
return JsonDecode(_data, 'GetCountryListResponse');
|
|
311
|
+
});
|
|
312
|
+
}, error => {
|
|
272
313
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
273
314
|
});
|
|
274
315
|
};
|
|
275
316
|
getTrailsContracts = (headers, signal) => {
|
|
276
|
-
return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then(
|
|
317
|
+
return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
277
318
|
return buildResponse(res).then(_data => {
|
|
278
319
|
return JsonDecode(_data, 'GetTrailsContractsResponse');
|
|
279
320
|
});
|
|
280
|
-
},
|
|
321
|
+
}, error => {
|
|
322
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
getEarnPools = (req, headers, signal) => {
|
|
326
|
+
return this.fetch(this.url('GetEarnPools'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
327
|
+
return buildResponse(res).then(_data => {
|
|
328
|
+
return JsonDecode(_data, 'GetEarnPoolsResponse');
|
|
329
|
+
});
|
|
330
|
+
}, error => {
|
|
331
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
getFiatCurrencyList = (headers, signal) => {
|
|
335
|
+
return this.fetch(this.url('GetFiatCurrencyList'), createHttpRequest('{}', headers, signal)).then(res => {
|
|
336
|
+
return buildResponse(res).then(_data => {
|
|
337
|
+
return JsonDecode(_data, 'GetFiatCurrencyListResponse');
|
|
338
|
+
});
|
|
339
|
+
}, error => {
|
|
281
340
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
282
341
|
});
|
|
283
342
|
};
|
|
284
343
|
getIntentTransactionHistory = (req, headers, signal) => {
|
|
285
|
-
return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(
|
|
344
|
+
return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then(res => {
|
|
286
345
|
return buildResponse(res).then(_data => {
|
|
287
346
|
return JsonDecode(_data, 'GetIntentTransactionHistoryResponse');
|
|
288
347
|
});
|
|
289
|
-
},
|
|
348
|
+
}, error => {
|
|
290
349
|
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
291
350
|
});
|
|
292
351
|
};
|
|
293
352
|
}
|
|
294
353
|
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
295
|
-
const reqHeaders = {
|
|
354
|
+
const reqHeaders = {
|
|
355
|
+
...headers,
|
|
356
|
+
'Content-Type': 'application/json',
|
|
357
|
+
[WebrpcHeader]: WebrpcHeaderValue
|
|
358
|
+
};
|
|
296
359
|
return { method: 'POST', headers: reqHeaders, body, signal };
|
|
297
360
|
};
|
|
298
361
|
const buildResponse = (res) => {
|
|
@@ -308,7 +371,7 @@ const buildResponse = (res) => {
|
|
|
308
371
|
});
|
|
309
372
|
}
|
|
310
373
|
if (!res.ok) {
|
|
311
|
-
const code =
|
|
374
|
+
const code = typeof data.code === 'number' ? data.code : 0;
|
|
312
375
|
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
313
376
|
}
|
|
314
377
|
return data;
|
|
@@ -321,7 +384,7 @@ const BIG_INT_FIELDS = {
|
|
|
321
384
|
CommitIntentRequest: [['intent', 'Intent']],
|
|
322
385
|
DepositIntentEntry: ['permitAmount'],
|
|
323
386
|
DepositSignature: ['permitAmount', ['selectedGasFeeOption', 'FeeOption']],
|
|
324
|
-
DepositTransaction: ['amount'],
|
|
387
|
+
DepositTransaction: ['amount', 'value'],
|
|
325
388
|
ExecuteIntentRequest: [['depositSignature', 'DepositSignature']],
|
|
326
389
|
FeeOption: ['amount'],
|
|
327
390
|
GasFeeOptions: [['feeOptions', 'FeeOption[]']],
|
|
@@ -329,20 +392,53 @@ const BIG_INT_FIELDS = {
|
|
|
329
392
|
GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
|
|
330
393
|
GetIntentResponse: [['intent', 'Intent']],
|
|
331
394
|
GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
|
|
332
|
-
Intent: [
|
|
395
|
+
Intent: [
|
|
396
|
+
['quoteRequest', 'QuoteIntentRequest'],
|
|
397
|
+
'salt',
|
|
398
|
+
['depositTransaction', 'DepositTransaction'],
|
|
399
|
+
['originCalls', 'IntentCalls'],
|
|
400
|
+
['destinationCalls', 'IntentCalls'],
|
|
401
|
+
['originPrecondition', 'TransactionPrecondition'],
|
|
402
|
+
['destinationPrecondition', 'TransactionPrecondition'],
|
|
403
|
+
['quote', 'IntentProviderQuote'],
|
|
404
|
+
['fees', 'IntentFees']
|
|
405
|
+
],
|
|
333
406
|
IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
|
|
334
|
-
IntentFees: [
|
|
407
|
+
IntentFees: [
|
|
408
|
+
['originGas', 'IntentTransactionGasFee'],
|
|
409
|
+
['destinationGas', 'IntentTransactionGasFee'],
|
|
410
|
+
['provider', 'IntentProviderFees'],
|
|
411
|
+
'feeTokenAmount',
|
|
412
|
+
'feeTokenTotal',
|
|
413
|
+
'gasFeeTotal',
|
|
414
|
+
'trailsFeeTotal',
|
|
415
|
+
'collectorFeeTotal',
|
|
416
|
+
'providerFeeTotal',
|
|
417
|
+
'totalFeeAmount'
|
|
418
|
+
],
|
|
335
419
|
IntentHistory: [['receipt', 'IntentReceipt']],
|
|
336
420
|
IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'quoteProviderWithTrailsFee', 'totalFeeAmount'],
|
|
337
421
|
IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
|
|
338
|
-
IntentReceipt: [
|
|
422
|
+
IntentReceipt: [
|
|
423
|
+
['depositTransaction', 'IntentTransaction'],
|
|
424
|
+
['originTransaction', 'IntentTransaction'],
|
|
425
|
+
['destinationTransaction', 'IntentTransaction'],
|
|
426
|
+
['refundTransaction', 'IntentTransaction'],
|
|
427
|
+
['summary', 'IntentReceiptSummary']
|
|
428
|
+
],
|
|
339
429
|
IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
340
430
|
IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
341
431
|
IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
|
|
342
432
|
IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
|
|
343
433
|
MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
|
|
434
|
+
PassThroughTransaction: ['amount', 'value'],
|
|
435
|
+
PassthroughInfo: [['passthroughTransaction', 'PassThroughTransaction']],
|
|
344
436
|
QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
|
|
345
|
-
QuoteIntentResponse: [
|
|
437
|
+
QuoteIntentResponse: [
|
|
438
|
+
['intent', 'Intent'],
|
|
439
|
+
['gasFeeOptions', 'GasFeeOptions'],
|
|
440
|
+
['passthrough', 'PassthroughInfo']
|
|
441
|
+
],
|
|
346
442
|
SearchIntentsResponse: [['intents', 'Intent[]']],
|
|
347
443
|
TransactionCall: ['value', 'gasLimit'],
|
|
348
444
|
TransactionPrecondition: ['minAmount'],
|
|
@@ -414,7 +510,7 @@ function decodeType(typ, obj) {
|
|
|
414
510
|
}
|
|
415
511
|
// Encode object to JSON with BigInts converted to decimal strings.
|
|
416
512
|
export const JsonEncode = (obj) => {
|
|
417
|
-
return JSON.stringify(obj, (key, value) => typeof value === 'bigint' ? value.toString() : value);
|
|
513
|
+
return JSON.stringify(obj, (key, value) => (typeof value === 'bigint' ? value.toString() : value));
|
|
418
514
|
};
|
|
419
515
|
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
420
516
|
export const JsonDecode = (data, typ = '') => {
|
|
@@ -1085,45 +1181,45 @@ export const webrpcErrorByCode = {
|
|
|
1085
1181
|
[8009]: ClientOutdatedError,
|
|
1086
1182
|
[7000]: IntentsSkippedError,
|
|
1087
1183
|
[7001]: QuoteExpiredError,
|
|
1088
|
-
[9000]: IntentsDisabledError
|
|
1184
|
+
[9000]: IntentsDisabledError
|
|
1089
1185
|
};
|
|
1090
1186
|
//
|
|
1091
1187
|
// Webrpc
|
|
1092
1188
|
//
|
|
1093
|
-
export const WebrpcHeader =
|
|
1094
|
-
export const WebrpcHeaderValue =
|
|
1189
|
+
export const WebrpcHeader = 'Webrpc';
|
|
1190
|
+
export const WebrpcHeaderValue = 'webrpc@v0.32.2;gen-typescript@v0.23.1;trails-api@v1';
|
|
1095
1191
|
export function VersionFromHeader(headers) {
|
|
1096
1192
|
const headerValue = headers.get(WebrpcHeader);
|
|
1097
1193
|
if (!headerValue) {
|
|
1098
1194
|
return {
|
|
1099
|
-
WebrpcGenVersion:
|
|
1100
|
-
codeGenName:
|
|
1101
|
-
codeGenVersion:
|
|
1102
|
-
schemaName:
|
|
1103
|
-
schemaVersion:
|
|
1195
|
+
WebrpcGenVersion: '',
|
|
1196
|
+
codeGenName: '',
|
|
1197
|
+
codeGenVersion: '',
|
|
1198
|
+
schemaName: '',
|
|
1199
|
+
schemaVersion: ''
|
|
1104
1200
|
};
|
|
1105
1201
|
}
|
|
1106
1202
|
return parseWebrpcGenVersions(headerValue);
|
|
1107
1203
|
}
|
|
1108
1204
|
function parseWebrpcGenVersions(header) {
|
|
1109
|
-
const versions = header.split(
|
|
1205
|
+
const versions = header.split(';');
|
|
1110
1206
|
if (versions.length < 3) {
|
|
1111
1207
|
return {
|
|
1112
|
-
WebrpcGenVersion:
|
|
1113
|
-
codeGenName:
|
|
1114
|
-
codeGenVersion:
|
|
1115
|
-
schemaName:
|
|
1116
|
-
schemaVersion:
|
|
1208
|
+
WebrpcGenVersion: '',
|
|
1209
|
+
codeGenName: '',
|
|
1210
|
+
codeGenVersion: '',
|
|
1211
|
+
schemaName: '',
|
|
1212
|
+
schemaVersion: ''
|
|
1117
1213
|
};
|
|
1118
1214
|
}
|
|
1119
|
-
const [_, WebrpcGenVersion] = versions[0].split(
|
|
1120
|
-
const [codeGenName, codeGenVersion] = versions[1].split(
|
|
1121
|
-
const [schemaName, schemaVersion] = versions[2].split(
|
|
1215
|
+
const [_, WebrpcGenVersion] = versions[0].split('@');
|
|
1216
|
+
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
1217
|
+
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
1122
1218
|
return {
|
|
1123
|
-
WebrpcGenVersion: WebrpcGenVersion ??
|
|
1124
|
-
codeGenName: codeGenName ??
|
|
1125
|
-
codeGenVersion: codeGenVersion ??
|
|
1126
|
-
schemaName: schemaName ??
|
|
1127
|
-
schemaVersion: schemaVersion ??
|
|
1219
|
+
WebrpcGenVersion: WebrpcGenVersion ?? '',
|
|
1220
|
+
codeGenName: codeGenName ?? '',
|
|
1221
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
1222
|
+
schemaName: schemaName ?? '',
|
|
1223
|
+
schemaVersion: schemaVersion ?? ''
|
|
1128
1224
|
};
|
|
1129
1225
|
}
|