@0xtrails/api 0.10.4 → 0.11.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 +6 -0
- package/dist/api-types.d.ts +41 -0
- package/dist/api-types.d.ts.map +1 -0
- package/dist/api-types.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -4
- package/dist/trails-api-v1_5.gen.d.ts +1158 -0
- package/dist/trails-api-v1_5.gen.d.ts.map +1 -0
- package/dist/trails-api-v1_5.gen.js +1220 -0
- package/package.json +1 -1
- package/src/api-types.ts +61 -0
- package/src/index.ts +79 -8
- package/src/trails-api-v1_5.gen.ts +2244 -0
|
@@ -0,0 +1,1220 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// trails-api v1-26.2.10-fcbe559 739a9f32a6c6cb2dabf3c8843e28a336430d748b
|
|
3
|
+
// --
|
|
4
|
+
// Code generated by Webrpc-gen@v0.32.2 with typescript generator. DO NOT EDIT.
|
|
5
|
+
//
|
|
6
|
+
// webrpc-gen -schema=trails-api.ridl -target=typescript -client -service=Trails -methodTreeShake -ignore=@onramp -out=./clients/trails-api.gen.ts
|
|
7
|
+
// Webrpc description and code-gen version
|
|
8
|
+
export const WebrpcVersion = "v1";
|
|
9
|
+
// Schema version of your RIDL schema
|
|
10
|
+
export const WebrpcSchemaVersion = "v1-26.2.10-fcbe559";
|
|
11
|
+
// Schema hash generated from your RIDL schema
|
|
12
|
+
export const WebrpcSchemaHash = "739a9f32a6c6cb2dabf3c8843e28a336430d748b";
|
|
13
|
+
//
|
|
14
|
+
// Schema types
|
|
15
|
+
//
|
|
16
|
+
export var TradeType;
|
|
17
|
+
(function (TradeType) {
|
|
18
|
+
TradeType["EXACT_INPUT"] = "EXACT_INPUT";
|
|
19
|
+
TradeType["EXACT_OUTPUT"] = "EXACT_OUTPUT";
|
|
20
|
+
})(TradeType || (TradeType = {}));
|
|
21
|
+
export var RouteProvider;
|
|
22
|
+
(function (RouteProvider) {
|
|
23
|
+
RouteProvider["AUTO"] = "AUTO";
|
|
24
|
+
RouteProvider["CCTP"] = "CCTP";
|
|
25
|
+
RouteProvider["LIFI"] = "LIFI";
|
|
26
|
+
RouteProvider["RELAY"] = "RELAY";
|
|
27
|
+
RouteProvider["SUSHI"] = "SUSHI";
|
|
28
|
+
RouteProvider["WETH"] = "WETH";
|
|
29
|
+
RouteProvider["ZEROX"] = "ZEROX";
|
|
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 = {}));
|
|
38
|
+
export var IntentProtocolVersion;
|
|
39
|
+
(function (IntentProtocolVersion) {
|
|
40
|
+
IntentProtocolVersion["v1"] = "v1";
|
|
41
|
+
IntentProtocolVersion["v1_5"] = "v1_5";
|
|
42
|
+
})(IntentProtocolVersion || (IntentProtocolVersion = {}));
|
|
43
|
+
export var IntentSource;
|
|
44
|
+
(function (IntentSource) {
|
|
45
|
+
IntentSource["ORIGIN"] = "ORIGIN";
|
|
46
|
+
IntentSource["DESTINATION"] = "DESTINATION";
|
|
47
|
+
})(IntentSource || (IntentSource = {}));
|
|
48
|
+
export var IntentStatus;
|
|
49
|
+
(function (IntentStatus) {
|
|
50
|
+
IntentStatus["QUOTED"] = "QUOTED";
|
|
51
|
+
IntentStatus["COMMITTED"] = "COMMITTED";
|
|
52
|
+
IntentStatus["EXECUTING"] = "EXECUTING";
|
|
53
|
+
IntentStatus["FAILED"] = "FAILED";
|
|
54
|
+
IntentStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
55
|
+
IntentStatus["ABORTED"] = "ABORTED";
|
|
56
|
+
IntentStatus["REFUNDED"] = "REFUNDED";
|
|
57
|
+
})(IntentStatus || (IntentStatus = {}));
|
|
58
|
+
export var TransactionType;
|
|
59
|
+
(function (TransactionType) {
|
|
60
|
+
TransactionType["UNKNOWN"] = "UNKNOWN";
|
|
61
|
+
TransactionType["DEPOSIT"] = "DEPOSIT";
|
|
62
|
+
TransactionType["ORIGIN"] = "ORIGIN";
|
|
63
|
+
TransactionType["DESTINATION"] = "DESTINATION";
|
|
64
|
+
TransactionType["ROUTE"] = "ROUTE";
|
|
65
|
+
TransactionType["REFUND"] = "REFUND";
|
|
66
|
+
})(TransactionType || (TransactionType = {}));
|
|
67
|
+
export var TransactionContext;
|
|
68
|
+
(function (TransactionContext) {
|
|
69
|
+
TransactionContext["NONE"] = "NONE";
|
|
70
|
+
TransactionContext["CCTPV2_MESSAGE"] = "CCTPV2_MESSAGE";
|
|
71
|
+
})(TransactionContext || (TransactionContext = {}));
|
|
72
|
+
export var TransactionStatus;
|
|
73
|
+
(function (TransactionStatus) {
|
|
74
|
+
TransactionStatus["UNKNOWN"] = "UNKNOWN";
|
|
75
|
+
TransactionStatus["ON_HOLD"] = "ON_HOLD";
|
|
76
|
+
TransactionStatus["PENDING"] = "PENDING";
|
|
77
|
+
TransactionStatus["RELAYING"] = "RELAYING";
|
|
78
|
+
TransactionStatus["SENT"] = "SENT";
|
|
79
|
+
TransactionStatus["ERRORED"] = "ERRORED";
|
|
80
|
+
TransactionStatus["MINING"] = "MINING";
|
|
81
|
+
TransactionStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
82
|
+
TransactionStatus["FAILED"] = "FAILED";
|
|
83
|
+
TransactionStatus["ABORTED"] = "ABORTED";
|
|
84
|
+
TransactionStatus["REVERTED"] = "REVERTED";
|
|
85
|
+
})(TransactionStatus || (TransactionStatus = {}));
|
|
86
|
+
export var ChainGasUsageStatus;
|
|
87
|
+
(function (ChainGasUsageStatus) {
|
|
88
|
+
ChainGasUsageStatus["NORMAL"] = "NORMAL";
|
|
89
|
+
ChainGasUsageStatus["BUSY"] = "BUSY";
|
|
90
|
+
ChainGasUsageStatus["VERY_BUSY"] = "VERY_BUSY";
|
|
91
|
+
})(ChainGasUsageStatus || (ChainGasUsageStatus = {}));
|
|
92
|
+
export var CCTPTransferStatus;
|
|
93
|
+
(function (CCTPTransferStatus) {
|
|
94
|
+
CCTPTransferStatus["UNKNOWN"] = "UNKNOWN";
|
|
95
|
+
CCTPTransferStatus["ON_HOLD"] = "ON_HOLD";
|
|
96
|
+
CCTPTransferStatus["PENDING"] = "PENDING";
|
|
97
|
+
CCTPTransferStatus["FETCHING"] = "FETCHING";
|
|
98
|
+
CCTPTransferStatus["COMPLETE"] = "COMPLETE";
|
|
99
|
+
CCTPTransferStatus["FAILED"] = "FAILED";
|
|
100
|
+
})(CCTPTransferStatus || (CCTPTransferStatus = {}));
|
|
101
|
+
export var RelayTransferStatus;
|
|
102
|
+
(function (RelayTransferStatus) {
|
|
103
|
+
RelayTransferStatus["UNKNOWN"] = "UNKNOWN";
|
|
104
|
+
RelayTransferStatus["ON_HOLD"] = "ON_HOLD";
|
|
105
|
+
RelayTransferStatus["PENDING"] = "PENDING";
|
|
106
|
+
RelayTransferStatus["FETCHING"] = "FETCHING";
|
|
107
|
+
RelayTransferStatus["COMPLETE"] = "COMPLETE";
|
|
108
|
+
RelayTransferStatus["REFUNDED"] = "REFUNDED";
|
|
109
|
+
RelayTransferStatus["FAILED"] = "FAILED";
|
|
110
|
+
})(RelayTransferStatus || (RelayTransferStatus = {}));
|
|
111
|
+
export var SortOrder;
|
|
112
|
+
(function (SortOrder) {
|
|
113
|
+
SortOrder["DESC"] = "DESC";
|
|
114
|
+
SortOrder["ASC"] = "ASC";
|
|
115
|
+
})(SortOrder || (SortOrder = {}));
|
|
116
|
+
//
|
|
117
|
+
// Client
|
|
118
|
+
//
|
|
119
|
+
export class Trails {
|
|
120
|
+
hostname;
|
|
121
|
+
fetch;
|
|
122
|
+
path = '/rpc/Trails/';
|
|
123
|
+
constructor(hostname, fetch) {
|
|
124
|
+
this.hostname = hostname.replace(/\/*$/, '');
|
|
125
|
+
this.fetch = (input, init) => fetch(input, init);
|
|
126
|
+
}
|
|
127
|
+
url(name) {
|
|
128
|
+
return this.hostname + this.path + name;
|
|
129
|
+
}
|
|
130
|
+
queryKey = {
|
|
131
|
+
ping: () => ['Trails', 'ping'],
|
|
132
|
+
runtimeStatus: () => ['Trails', 'runtimeStatus'],
|
|
133
|
+
clock: () => ['Trails', 'clock'],
|
|
134
|
+
quoteIntent: (req) => ['Trails', 'quoteIntent', req],
|
|
135
|
+
commitIntent: (req) => ['Trails', 'commitIntent', req],
|
|
136
|
+
executeIntent: (req) => ['Trails', 'executeIntent', req],
|
|
137
|
+
waitIntentReceipt: (req) => ['Trails', 'waitIntentReceipt', req],
|
|
138
|
+
getIntentReceipt: (req) => ['Trails', 'getIntentReceipt', req],
|
|
139
|
+
getIntent: (req) => ['Trails', 'getIntent', req],
|
|
140
|
+
searchIntents: (req) => ['Trails', 'searchIntents', req],
|
|
141
|
+
getIntentConfig: (req) => ['Trails', 'getIntentConfig', req],
|
|
142
|
+
getIntentHistory: (req) => ['Trails', 'getIntentHistory', req],
|
|
143
|
+
abortIntent: (req) => ['Trails', 'abortIntent', req],
|
|
144
|
+
getChains: (req) => ['Trails', 'getChains', req],
|
|
145
|
+
getExactOutputRoutes: (req) => ['Trails', 'getExactOutputRoutes', req],
|
|
146
|
+
getExactInputRoutes: (req) => ['Trails', 'getExactInputRoutes', req],
|
|
147
|
+
getTokenList: (req) => ['Trails', 'getTokenList', req],
|
|
148
|
+
getTokenPrices: (req) => ['Trails', 'getTokenPrices', req],
|
|
149
|
+
getExchangeRate: (req) => ['Trails', 'getExchangeRate', req],
|
|
150
|
+
getCountryList: () => ['Trails', 'getCountryList'],
|
|
151
|
+
getTrailsContracts: () => ['Trails', 'getTrailsContracts'],
|
|
152
|
+
getSupportedIntentProtocolVersions: () => ['Trails', 'getSupportedIntentProtocolVersions'],
|
|
153
|
+
getEarnPools: (req) => ['Trails', 'getEarnPools', req],
|
|
154
|
+
getFiatCurrencyList: () => ['Trails', 'getFiatCurrencyList'],
|
|
155
|
+
getIntentTransactionHistory: (req) => ['Trails', 'getIntentTransactionHistory', req],
|
|
156
|
+
};
|
|
157
|
+
ping = (headers, signal) => {
|
|
158
|
+
return this.fetch(this.url('Ping'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
159
|
+
return buildResponse(res).then(_data => {
|
|
160
|
+
return JsonDecode(_data, 'PingResponse');
|
|
161
|
+
});
|
|
162
|
+
}, (error) => {
|
|
163
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
runtimeStatus = (headers, signal) => {
|
|
167
|
+
return this.fetch(this.url('RuntimeStatus'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
168
|
+
return buildResponse(res).then(_data => {
|
|
169
|
+
return JsonDecode(_data, 'RuntimeStatusResponse');
|
|
170
|
+
});
|
|
171
|
+
}, (error) => {
|
|
172
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
clock = (headers, signal) => {
|
|
176
|
+
return this.fetch(this.url('Clock'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
177
|
+
return buildResponse(res).then(_data => {
|
|
178
|
+
return JsonDecode(_data, 'ClockResponse');
|
|
179
|
+
});
|
|
180
|
+
}, (error) => {
|
|
181
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
quoteIntent = (req, headers, signal) => {
|
|
185
|
+
return this.fetch(this.url('QuoteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
186
|
+
return buildResponse(res).then(_data => {
|
|
187
|
+
return JsonDecode(_data, 'QuoteIntentResponse');
|
|
188
|
+
});
|
|
189
|
+
}, (error) => {
|
|
190
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
commitIntent = (req, headers, signal) => {
|
|
194
|
+
return this.fetch(this.url('CommitIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
195
|
+
return buildResponse(res).then(_data => {
|
|
196
|
+
return JsonDecode(_data, 'CommitIntentResponse');
|
|
197
|
+
});
|
|
198
|
+
}, (error) => {
|
|
199
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
executeIntent = (req, headers, signal) => {
|
|
203
|
+
return this.fetch(this.url('ExecuteIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
204
|
+
return buildResponse(res).then(_data => {
|
|
205
|
+
return JsonDecode(_data, 'ExecuteIntentResponse');
|
|
206
|
+
});
|
|
207
|
+
}, (error) => {
|
|
208
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
waitIntentReceipt = (req, headers, signal) => {
|
|
212
|
+
return this.fetch(this.url('WaitIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
213
|
+
return buildResponse(res).then(_data => {
|
|
214
|
+
return JsonDecode(_data, 'WaitIntentReceiptResponse');
|
|
215
|
+
});
|
|
216
|
+
}, (error) => {
|
|
217
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
getIntentReceipt = (req, headers, signal) => {
|
|
221
|
+
return this.fetch(this.url('GetIntentReceipt'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
222
|
+
return buildResponse(res).then(_data => {
|
|
223
|
+
return JsonDecode(_data, 'GetIntentReceiptResponse');
|
|
224
|
+
});
|
|
225
|
+
}, (error) => {
|
|
226
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
getIntent = (req, headers, signal) => {
|
|
230
|
+
return this.fetch(this.url('GetIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
231
|
+
return buildResponse(res).then(_data => {
|
|
232
|
+
return JsonDecode(_data, 'GetIntentResponse');
|
|
233
|
+
});
|
|
234
|
+
}, (error) => {
|
|
235
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
searchIntents = (req, headers, signal) => {
|
|
239
|
+
return this.fetch(this.url('SearchIntents'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
240
|
+
return buildResponse(res).then(_data => {
|
|
241
|
+
return JsonDecode(_data, 'SearchIntentsResponse');
|
|
242
|
+
});
|
|
243
|
+
}, (error) => {
|
|
244
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
getIntentConfig = (req, headers, signal) => {
|
|
248
|
+
return this.fetch(this.url('GetIntentConfig'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
249
|
+
return buildResponse(res).then(_data => {
|
|
250
|
+
return JsonDecode(_data, 'GetIntentConfigResponse');
|
|
251
|
+
});
|
|
252
|
+
}, (error) => {
|
|
253
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
getIntentHistory = (req, headers, signal) => {
|
|
257
|
+
return this.fetch(this.url('GetIntentHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
258
|
+
return buildResponse(res).then(_data => {
|
|
259
|
+
return JsonDecode(_data, 'GetIntentHistoryResponse');
|
|
260
|
+
});
|
|
261
|
+
}, (error) => {
|
|
262
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
abortIntent = (req, headers, signal) => {
|
|
266
|
+
return this.fetch(this.url('AbortIntent'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
267
|
+
return buildResponse(res).then(_data => {
|
|
268
|
+
return JsonDecode(_data, 'AbortIntentResponse');
|
|
269
|
+
});
|
|
270
|
+
}, (error) => {
|
|
271
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
getChains = (req, headers, signal) => {
|
|
275
|
+
return this.fetch(this.url('GetChains'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
276
|
+
return buildResponse(res).then(_data => {
|
|
277
|
+
return JsonDecode(_data, 'GetChainsResponse');
|
|
278
|
+
});
|
|
279
|
+
}, (error) => {
|
|
280
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
getExactOutputRoutes = (req, headers, signal) => {
|
|
284
|
+
return this.fetch(this.url('GetExactOutputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
285
|
+
return buildResponse(res).then(_data => {
|
|
286
|
+
return JsonDecode(_data, 'GetExactOutputRoutesResponse');
|
|
287
|
+
});
|
|
288
|
+
}, (error) => {
|
|
289
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
getExactInputRoutes = (req, headers, signal) => {
|
|
293
|
+
return this.fetch(this.url('GetExactInputRoutes'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
294
|
+
return buildResponse(res).then(_data => {
|
|
295
|
+
return JsonDecode(_data, 'GetExactInputRoutesResponse');
|
|
296
|
+
});
|
|
297
|
+
}, (error) => {
|
|
298
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
getTokenList = (req, headers, signal) => {
|
|
302
|
+
return this.fetch(this.url('GetTokenList'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
303
|
+
return buildResponse(res).then(_data => {
|
|
304
|
+
return JsonDecode(_data, 'GetTokenListResponse');
|
|
305
|
+
});
|
|
306
|
+
}, (error) => {
|
|
307
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
getTokenPrices = (req, headers, signal) => {
|
|
311
|
+
return this.fetch(this.url('GetTokenPrices'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
312
|
+
return buildResponse(res).then(_data => {
|
|
313
|
+
return JsonDecode(_data, 'GetTokenPricesResponse');
|
|
314
|
+
});
|
|
315
|
+
}, (error) => {
|
|
316
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
getExchangeRate = (req, headers, signal) => {
|
|
320
|
+
return this.fetch(this.url('GetExchangeRate'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
321
|
+
return buildResponse(res).then(_data => {
|
|
322
|
+
return JsonDecode(_data, 'GetExchangeRateResponse');
|
|
323
|
+
});
|
|
324
|
+
}, (error) => {
|
|
325
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
getCountryList = (headers, signal) => {
|
|
329
|
+
return this.fetch(this.url('GetCountryList'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
330
|
+
return buildResponse(res).then(_data => {
|
|
331
|
+
return JsonDecode(_data, 'GetCountryListResponse');
|
|
332
|
+
});
|
|
333
|
+
}, (error) => {
|
|
334
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
getTrailsContracts = (headers, signal) => {
|
|
338
|
+
return this.fetch(this.url('GetTrailsContracts'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
339
|
+
return buildResponse(res).then(_data => {
|
|
340
|
+
return JsonDecode(_data, 'GetTrailsContractsResponse');
|
|
341
|
+
});
|
|
342
|
+
}, (error) => {
|
|
343
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
getSupportedIntentProtocolVersions = (headers, signal) => {
|
|
347
|
+
return this.fetch(this.url('GetSupportedIntentProtocolVersions'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
348
|
+
return buildResponse(res).then(_data => {
|
|
349
|
+
return JsonDecode(_data, 'GetSupportedIntentProtocolVersionsResponse');
|
|
350
|
+
});
|
|
351
|
+
}, (error) => {
|
|
352
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
getEarnPools = (req, headers, signal) => {
|
|
356
|
+
return this.fetch(this.url('GetEarnPools'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
357
|
+
return buildResponse(res).then(_data => {
|
|
358
|
+
return JsonDecode(_data, 'GetEarnPoolsResponse');
|
|
359
|
+
});
|
|
360
|
+
}, (error) => {
|
|
361
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
getFiatCurrencyList = (headers, signal) => {
|
|
365
|
+
return this.fetch(this.url('GetFiatCurrencyList'), createHttpRequest('{}', headers, signal)).then((res) => {
|
|
366
|
+
return buildResponse(res).then(_data => {
|
|
367
|
+
return JsonDecode(_data, 'GetFiatCurrencyListResponse');
|
|
368
|
+
});
|
|
369
|
+
}, (error) => {
|
|
370
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
getIntentTransactionHistory = (req, headers, signal) => {
|
|
374
|
+
return this.fetch(this.url('GetIntentTransactionHistory'), createHttpRequest(JsonEncode(req), headers, signal)).then((res) => {
|
|
375
|
+
return buildResponse(res).then(_data => {
|
|
376
|
+
return JsonDecode(_data, 'GetIntentTransactionHistoryResponse');
|
|
377
|
+
});
|
|
378
|
+
}, (error) => {
|
|
379
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error instanceof Error ? error.message : String(error)}` });
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
const createHttpRequest = (body = '{}', headers = {}, signal = null) => {
|
|
384
|
+
const reqHeaders = { ...headers, 'Content-Type': 'application/json', [WebrpcHeader]: WebrpcHeaderValue };
|
|
385
|
+
return { method: 'POST', headers: reqHeaders, body, signal };
|
|
386
|
+
};
|
|
387
|
+
const buildResponse = (res) => {
|
|
388
|
+
return res.text().then(text => {
|
|
389
|
+
let data;
|
|
390
|
+
try {
|
|
391
|
+
data = JSON.parse(text);
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
throw WebrpcBadResponseError.new({
|
|
395
|
+
status: res.status,
|
|
396
|
+
cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
if (!res.ok) {
|
|
400
|
+
const code = (typeof data.code === 'number') ? data.code : 0;
|
|
401
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
402
|
+
}
|
|
403
|
+
return data;
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
//
|
|
407
|
+
// BigInt helpers
|
|
408
|
+
//
|
|
409
|
+
const BIG_INT_FIELDS = {
|
|
410
|
+
CommitIntentRequest: [['intent', 'Intent']],
|
|
411
|
+
DepositIntentEntry: ['permitAmount'],
|
|
412
|
+
DepositSignature: ['permitAmount', ['selectedGasFeeOption', 'FeeOption']],
|
|
413
|
+
DepositTransaction: ['amount', 'value'],
|
|
414
|
+
ExecuteIntentRequest: [['depositSignature', 'DepositSignature']],
|
|
415
|
+
FeeOption: ['amount'],
|
|
416
|
+
GasFeeOptions: [['feeOptions', 'FeeOption[]']],
|
|
417
|
+
GetIntentHistoryResponse: [['intents', 'IntentHistory[]']],
|
|
418
|
+
GetIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']],
|
|
419
|
+
GetIntentResponse: [['intent', 'Intent']],
|
|
420
|
+
GetIntentTransactionHistoryResponse: [['intents', 'IntentSummary[]']],
|
|
421
|
+
Intent: [['quoteRequest', 'QuoteIntentRequest'], 'salt', ['depositTransaction', 'DepositTransaction'], ['originCalls', 'IntentCalls'], ['destinationCalls', 'IntentCalls'], ['originPrecondition', 'TransactionPrecondition'], ['destinationPrecondition', 'TransactionPrecondition'], ['quote', 'IntentProviderQuote'], ['fees', 'IntentFees']],
|
|
422
|
+
IntentCalls: ['space', 'nonce', ['calls', 'TransactionCall[]']],
|
|
423
|
+
IntentFees: [['originGas', 'IntentTransactionGasFee'], ['destinationGas', 'IntentTransactionGasFee'], ['provider', 'IntentProviderFees'], 'feeTokenAmount', 'feeTokenTotal', 'gasFeeTotal', 'trailsFeeTotal', 'collectorFeeTotal', 'providerFeeTotal', 'totalFeeAmount'],
|
|
424
|
+
IntentHistory: [['receipt', 'IntentReceipt']],
|
|
425
|
+
IntentProviderFees: ['quoteProviderFee', 'trailsFee', 'quoteProviderWithTrailsFee', 'totalFeeAmount'],
|
|
426
|
+
IntentProviderQuote: ['fromAmount', 'fromAmountMin', 'toAmount', 'toAmountMin'],
|
|
427
|
+
IntentReceipt: [['depositTransaction', 'IntentTransaction'], ['originTransaction', 'IntentTransaction'], ['destinationTransaction', 'IntentTransaction'], ['refundTransaction', 'IntentTransaction'], ['summary', 'IntentReceiptSummary']],
|
|
428
|
+
IntentReceiptSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
429
|
+
IntentSummary: ['originTokenAmount', 'destinationTokenAmount'],
|
|
430
|
+
IntentTransaction: ['tokenAmount', ['precondition', 'TransactionPrecondition'], ['depositIntentEntry', 'DepositIntentEntry']],
|
|
431
|
+
IntentTransactionGasFee: ['totalGasLimit', 'gasPrice', 'totalFeeAmount', ['metaTxnFeeDetails', 'MetaTxnFeeDetails']],
|
|
432
|
+
MetaTxnFeeDetails: ['estimatedGasLimit', 'feeNative'],
|
|
433
|
+
PassThroughTransaction: ['amount', 'value'],
|
|
434
|
+
PassthroughInfo: [['passthroughTransaction', 'PassThroughTransaction']],
|
|
435
|
+
QuoteIntentRequest: ['destinationCallValue', 'originTokenAmount', 'destinationTokenAmount'],
|
|
436
|
+
QuoteIntentResponse: [['intent', 'Intent'], ['gasFeeOptions', 'GasFeeOptions'], ['passthrough', 'PassthroughInfo']],
|
|
437
|
+
SearchIntentsResponse: [['intents', 'Intent[]']],
|
|
438
|
+
TransactionCall: ['value', 'gasLimit'],
|
|
439
|
+
TransactionPrecondition: ['minAmount'],
|
|
440
|
+
WaitIntentReceiptResponse: [['intentReceipt', 'IntentReceipt']]
|
|
441
|
+
};
|
|
442
|
+
// Decode in-place: mutate object graph; throw if expected numeric string is invalid.
|
|
443
|
+
function decodeType(typ, obj) {
|
|
444
|
+
if (obj == null || typeof obj !== 'object')
|
|
445
|
+
return obj;
|
|
446
|
+
const descs = BIG_INT_FIELDS[typ] || [];
|
|
447
|
+
if (!descs.length)
|
|
448
|
+
return obj;
|
|
449
|
+
for (const d of descs) {
|
|
450
|
+
if (Array.isArray(d)) {
|
|
451
|
+
const [fieldName, nestedType] = d;
|
|
452
|
+
if (fieldName.endsWith('[]')) {
|
|
453
|
+
const base = fieldName.slice(0, -2);
|
|
454
|
+
const arr = obj[base];
|
|
455
|
+
if (Array.isArray(arr)) {
|
|
456
|
+
for (let i = 0; i < arr.length; i++)
|
|
457
|
+
arr[i] = decodeType(nestedType, arr[i]);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
else if (obj[fieldName]) {
|
|
461
|
+
// Handle nestedType that might be an array type like 'Message[]'
|
|
462
|
+
if (nestedType.endsWith('[]')) {
|
|
463
|
+
const baseType = nestedType.slice(0, -2);
|
|
464
|
+
const arr = obj[fieldName];
|
|
465
|
+
if (Array.isArray(arr)) {
|
|
466
|
+
for (let i = 0; i < arr.length; i++)
|
|
467
|
+
arr[i] = decodeType(baseType, arr[i]);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
obj[fieldName] = decodeType(nestedType, obj[fieldName]);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
if (d.endsWith('[]')) {
|
|
477
|
+
const base = d.slice(0, -2);
|
|
478
|
+
const arr = obj[base];
|
|
479
|
+
if (Array.isArray(arr)) {
|
|
480
|
+
for (let i = 0; i < arr.length; i++) {
|
|
481
|
+
const v = arr[i];
|
|
482
|
+
if (typeof v === 'string') {
|
|
483
|
+
try {
|
|
484
|
+
arr[i] = BigInt(v);
|
|
485
|
+
}
|
|
486
|
+
catch (e) {
|
|
487
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${base}[${i}]: ${v}` });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const v = obj[d];
|
|
495
|
+
if (typeof v === 'string') {
|
|
496
|
+
try {
|
|
497
|
+
obj[d] = BigInt(v);
|
|
498
|
+
}
|
|
499
|
+
catch (e) {
|
|
500
|
+
throw WebrpcBadResponseError.new({ cause: `Invalid bigint value for ${d}: ${v}` });
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return obj;
|
|
505
|
+
}
|
|
506
|
+
// Encode object to JSON with BigInts converted to decimal strings.
|
|
507
|
+
export const JsonEncode = (obj) => {
|
|
508
|
+
return JSON.stringify(obj, (key, value) => typeof value === 'bigint' ? value.toString() : value);
|
|
509
|
+
};
|
|
510
|
+
// Decode data (JSON string or already-parsed object) and convert declared BigInt string fields back to BigInt.
|
|
511
|
+
export const JsonDecode = (data, typ = '') => {
|
|
512
|
+
let parsed = data;
|
|
513
|
+
if (typeof data === 'string') {
|
|
514
|
+
try {
|
|
515
|
+
parsed = JSON.parse(data);
|
|
516
|
+
}
|
|
517
|
+
catch (err) {
|
|
518
|
+
throw WebrpcBadResponseError.new({ cause: `JsonDecode: JSON.parse failed: ${err.message}` });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return decodeType(typ, parsed);
|
|
522
|
+
};
|
|
523
|
+
export class WebrpcError extends Error {
|
|
524
|
+
code;
|
|
525
|
+
status;
|
|
526
|
+
constructor(error = {}) {
|
|
527
|
+
super(error.message);
|
|
528
|
+
this.name = error.name || 'WebrpcEndpointError';
|
|
529
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
530
|
+
this.message = error.message || `endpoint error`;
|
|
531
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
532
|
+
if (error.cause !== undefined)
|
|
533
|
+
this.cause = error.cause;
|
|
534
|
+
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
535
|
+
}
|
|
536
|
+
static new(payload) {
|
|
537
|
+
return new this({ message: payload.message, code: payload.code, status: payload.status, cause: payload.cause });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
export class WebrpcEndpointError extends WebrpcError {
|
|
541
|
+
constructor(error = {}) {
|
|
542
|
+
super(error);
|
|
543
|
+
this.name = error.name || 'WebrpcEndpoint';
|
|
544
|
+
this.code = typeof error.code === 'number' ? error.code : 0;
|
|
545
|
+
this.message = error.message || `endpoint error`;
|
|
546
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
547
|
+
if (error.cause !== undefined)
|
|
548
|
+
this.cause = error.cause;
|
|
549
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
export class WebrpcRequestFailedError extends WebrpcError {
|
|
553
|
+
constructor(error = {}) {
|
|
554
|
+
super(error);
|
|
555
|
+
this.name = error.name || 'WebrpcRequestFailed';
|
|
556
|
+
this.code = typeof error.code === 'number' ? error.code : -1;
|
|
557
|
+
this.message = error.message || `request failed`;
|
|
558
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
559
|
+
if (error.cause !== undefined)
|
|
560
|
+
this.cause = error.cause;
|
|
561
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
export class WebrpcBadRouteError extends WebrpcError {
|
|
565
|
+
constructor(error = {}) {
|
|
566
|
+
super(error);
|
|
567
|
+
this.name = error.name || 'WebrpcBadRoute';
|
|
568
|
+
this.code = typeof error.code === 'number' ? error.code : -2;
|
|
569
|
+
this.message = error.message || `bad route`;
|
|
570
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
571
|
+
if (error.cause !== undefined)
|
|
572
|
+
this.cause = error.cause;
|
|
573
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
export class WebrpcBadMethodError extends WebrpcError {
|
|
577
|
+
constructor(error = {}) {
|
|
578
|
+
super(error);
|
|
579
|
+
this.name = error.name || 'WebrpcBadMethod';
|
|
580
|
+
this.code = typeof error.code === 'number' ? error.code : -3;
|
|
581
|
+
this.message = error.message || `bad method`;
|
|
582
|
+
this.status = typeof error.status === 'number' ? error.status : 405;
|
|
583
|
+
if (error.cause !== undefined)
|
|
584
|
+
this.cause = error.cause;
|
|
585
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
export class WebrpcBadRequestError extends WebrpcError {
|
|
589
|
+
constructor(error = {}) {
|
|
590
|
+
super(error);
|
|
591
|
+
this.name = error.name || 'WebrpcBadRequest';
|
|
592
|
+
this.code = typeof error.code === 'number' ? error.code : -4;
|
|
593
|
+
this.message = error.message || `bad request`;
|
|
594
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
595
|
+
if (error.cause !== undefined)
|
|
596
|
+
this.cause = error.cause;
|
|
597
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
export class WebrpcBadResponseError extends WebrpcError {
|
|
601
|
+
constructor(error = {}) {
|
|
602
|
+
super(error);
|
|
603
|
+
this.name = error.name || 'WebrpcBadResponse';
|
|
604
|
+
this.code = typeof error.code === 'number' ? error.code : -5;
|
|
605
|
+
this.message = error.message || `bad response`;
|
|
606
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
607
|
+
if (error.cause !== undefined)
|
|
608
|
+
this.cause = error.cause;
|
|
609
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
export class WebrpcServerPanicError extends WebrpcError {
|
|
613
|
+
constructor(error = {}) {
|
|
614
|
+
super(error);
|
|
615
|
+
this.name = error.name || 'WebrpcServerPanic';
|
|
616
|
+
this.code = typeof error.code === 'number' ? error.code : -6;
|
|
617
|
+
this.message = error.message || `server panic`;
|
|
618
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
619
|
+
if (error.cause !== undefined)
|
|
620
|
+
this.cause = error.cause;
|
|
621
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
export class WebrpcInternalErrorError extends WebrpcError {
|
|
625
|
+
constructor(error = {}) {
|
|
626
|
+
super(error);
|
|
627
|
+
this.name = error.name || 'WebrpcInternalError';
|
|
628
|
+
this.code = typeof error.code === 'number' ? error.code : -7;
|
|
629
|
+
this.message = error.message || `internal error`;
|
|
630
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
631
|
+
if (error.cause !== undefined)
|
|
632
|
+
this.cause = error.cause;
|
|
633
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
export class WebrpcClientAbortedError extends WebrpcError {
|
|
637
|
+
constructor(error = {}) {
|
|
638
|
+
super(error);
|
|
639
|
+
this.name = error.name || 'WebrpcClientAborted';
|
|
640
|
+
this.code = typeof error.code === 'number' ? error.code : -8;
|
|
641
|
+
this.message = error.message || `request aborted by client`;
|
|
642
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
643
|
+
if (error.cause !== undefined)
|
|
644
|
+
this.cause = error.cause;
|
|
645
|
+
Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
export class WebrpcStreamLostError extends WebrpcError {
|
|
649
|
+
constructor(error = {}) {
|
|
650
|
+
super(error);
|
|
651
|
+
this.name = error.name || 'WebrpcStreamLost';
|
|
652
|
+
this.code = typeof error.code === 'number' ? error.code : -9;
|
|
653
|
+
this.message = error.message || `stream lost`;
|
|
654
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
655
|
+
if (error.cause !== undefined)
|
|
656
|
+
this.cause = error.cause;
|
|
657
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
export class WebrpcStreamFinishedError extends WebrpcError {
|
|
661
|
+
constructor(error = {}) {
|
|
662
|
+
super(error);
|
|
663
|
+
this.name = error.name || 'WebrpcStreamFinished';
|
|
664
|
+
this.code = typeof error.code === 'number' ? error.code : -10;
|
|
665
|
+
this.message = error.message || `stream finished`;
|
|
666
|
+
this.status = typeof error.status === 'number' ? error.status : 200;
|
|
667
|
+
if (error.cause !== undefined)
|
|
668
|
+
this.cause = error.cause;
|
|
669
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
//
|
|
673
|
+
// Schema errors
|
|
674
|
+
//
|
|
675
|
+
export class UnauthorizedError extends WebrpcError {
|
|
676
|
+
constructor(error = {}) {
|
|
677
|
+
super(error);
|
|
678
|
+
this.name = error.name || 'Unauthorized';
|
|
679
|
+
this.code = typeof error.code === 'number' ? error.code : 1000;
|
|
680
|
+
this.message = error.message || `Unauthorized access`;
|
|
681
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
682
|
+
if (error.cause !== undefined)
|
|
683
|
+
this.cause = error.cause;
|
|
684
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
export class PermissionDeniedError extends WebrpcError {
|
|
688
|
+
constructor(error = {}) {
|
|
689
|
+
super(error);
|
|
690
|
+
this.name = error.name || 'PermissionDenied';
|
|
691
|
+
this.code = typeof error.code === 'number' ? error.code : 1001;
|
|
692
|
+
this.message = error.message || `Permission denied`;
|
|
693
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
694
|
+
if (error.cause !== undefined)
|
|
695
|
+
this.cause = error.cause;
|
|
696
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
export class SessionExpiredError extends WebrpcError {
|
|
700
|
+
constructor(error = {}) {
|
|
701
|
+
super(error);
|
|
702
|
+
this.name = error.name || 'SessionExpired';
|
|
703
|
+
this.code = typeof error.code === 'number' ? error.code : 1002;
|
|
704
|
+
this.message = error.message || `Session expired`;
|
|
705
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
706
|
+
if (error.cause !== undefined)
|
|
707
|
+
this.cause = error.cause;
|
|
708
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
export class MethodNotFoundError extends WebrpcError {
|
|
712
|
+
constructor(error = {}) {
|
|
713
|
+
super(error);
|
|
714
|
+
this.name = error.name || 'MethodNotFound';
|
|
715
|
+
this.code = typeof error.code === 'number' ? error.code : 1003;
|
|
716
|
+
this.message = error.message || `Method not found`;
|
|
717
|
+
this.status = typeof error.status === 'number' ? error.status : 404;
|
|
718
|
+
if (error.cause !== undefined)
|
|
719
|
+
this.cause = error.cause;
|
|
720
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
export class RequestConflictError extends WebrpcError {
|
|
724
|
+
constructor(error = {}) {
|
|
725
|
+
super(error);
|
|
726
|
+
this.name = error.name || 'RequestConflict';
|
|
727
|
+
this.code = typeof error.code === 'number' ? error.code : 1004;
|
|
728
|
+
this.message = error.message || `Conflict with target resource`;
|
|
729
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
730
|
+
if (error.cause !== undefined)
|
|
731
|
+
this.cause = error.cause;
|
|
732
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
export class AbortedError extends WebrpcError {
|
|
736
|
+
constructor(error = {}) {
|
|
737
|
+
super(error);
|
|
738
|
+
this.name = error.name || 'Aborted';
|
|
739
|
+
this.code = typeof error.code === 'number' ? error.code : 1005;
|
|
740
|
+
this.message = error.message || `Request aborted`;
|
|
741
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
742
|
+
if (error.cause !== undefined)
|
|
743
|
+
this.cause = error.cause;
|
|
744
|
+
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
export class GeoblockedError extends WebrpcError {
|
|
748
|
+
constructor(error = {}) {
|
|
749
|
+
super(error);
|
|
750
|
+
this.name = error.name || 'Geoblocked';
|
|
751
|
+
this.code = typeof error.code === 'number' ? error.code : 1006;
|
|
752
|
+
this.message = error.message || `Geoblocked region`;
|
|
753
|
+
this.status = typeof error.status === 'number' ? error.status : 451;
|
|
754
|
+
if (error.cause !== undefined)
|
|
755
|
+
this.cause = error.cause;
|
|
756
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
export class RateLimitedError extends WebrpcError {
|
|
760
|
+
constructor(error = {}) {
|
|
761
|
+
super(error);
|
|
762
|
+
this.name = error.name || 'RateLimited';
|
|
763
|
+
this.code = typeof error.code === 'number' ? error.code : 1007;
|
|
764
|
+
this.message = error.message || `Rate-limited. Please slow down.`;
|
|
765
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
766
|
+
if (error.cause !== undefined)
|
|
767
|
+
this.cause = error.cause;
|
|
768
|
+
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
export class ProjectNotFoundError extends WebrpcError {
|
|
772
|
+
constructor(error = {}) {
|
|
773
|
+
super(error);
|
|
774
|
+
this.name = error.name || 'ProjectNotFound';
|
|
775
|
+
this.code = typeof error.code === 'number' ? error.code : 1008;
|
|
776
|
+
this.message = error.message || `Project not found`;
|
|
777
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
778
|
+
if (error.cause !== undefined)
|
|
779
|
+
this.cause = error.cause;
|
|
780
|
+
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
export class AccessKeyNotFoundError extends WebrpcError {
|
|
784
|
+
constructor(error = {}) {
|
|
785
|
+
super(error);
|
|
786
|
+
this.name = error.name || 'AccessKeyNotFound';
|
|
787
|
+
this.code = typeof error.code === 'number' ? error.code : 1101;
|
|
788
|
+
this.message = error.message || `Access key not found`;
|
|
789
|
+
this.status = typeof error.status === 'number' ? error.status : 401;
|
|
790
|
+
if (error.cause !== undefined)
|
|
791
|
+
this.cause = error.cause;
|
|
792
|
+
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
export class AccessKeyMismatchError extends WebrpcError {
|
|
796
|
+
constructor(error = {}) {
|
|
797
|
+
super(error);
|
|
798
|
+
this.name = error.name || 'AccessKeyMismatch';
|
|
799
|
+
this.code = typeof error.code === 'number' ? error.code : 1102;
|
|
800
|
+
this.message = error.message || `Access key mismatch`;
|
|
801
|
+
this.status = typeof error.status === 'number' ? error.status : 409;
|
|
802
|
+
if (error.cause !== undefined)
|
|
803
|
+
this.cause = error.cause;
|
|
804
|
+
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
export class InvalidOriginError extends WebrpcError {
|
|
808
|
+
constructor(error = {}) {
|
|
809
|
+
super(error);
|
|
810
|
+
this.name = error.name || 'InvalidOrigin';
|
|
811
|
+
this.code = typeof error.code === 'number' ? error.code : 1103;
|
|
812
|
+
this.message = error.message || `Invalid origin for Access Key`;
|
|
813
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
814
|
+
if (error.cause !== undefined)
|
|
815
|
+
this.cause = error.cause;
|
|
816
|
+
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
export class InvalidServiceError extends WebrpcError {
|
|
820
|
+
constructor(error = {}) {
|
|
821
|
+
super(error);
|
|
822
|
+
this.name = error.name || 'InvalidService';
|
|
823
|
+
this.code = typeof error.code === 'number' ? error.code : 1104;
|
|
824
|
+
this.message = error.message || `Service not enabled for Access key`;
|
|
825
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
826
|
+
if (error.cause !== undefined)
|
|
827
|
+
this.cause = error.cause;
|
|
828
|
+
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
export class UnauthorizedUserError extends WebrpcError {
|
|
832
|
+
constructor(error = {}) {
|
|
833
|
+
super(error);
|
|
834
|
+
this.name = error.name || 'UnauthorizedUser';
|
|
835
|
+
this.code = typeof error.code === 'number' ? error.code : 1105;
|
|
836
|
+
this.message = error.message || `Unauthorized user`;
|
|
837
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
838
|
+
if (error.cause !== undefined)
|
|
839
|
+
this.cause = error.cause;
|
|
840
|
+
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
export class QuotaExceededError extends WebrpcError {
|
|
844
|
+
constructor(error = {}) {
|
|
845
|
+
super(error);
|
|
846
|
+
this.name = error.name || 'QuotaExceeded';
|
|
847
|
+
this.code = typeof error.code === 'number' ? error.code : 1200;
|
|
848
|
+
this.message = error.message || `Quota request exceeded`;
|
|
849
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
850
|
+
if (error.cause !== undefined)
|
|
851
|
+
this.cause = error.cause;
|
|
852
|
+
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
export class QuotaRateLimitError extends WebrpcError {
|
|
856
|
+
constructor(error = {}) {
|
|
857
|
+
super(error);
|
|
858
|
+
this.name = error.name || 'QuotaRateLimit';
|
|
859
|
+
this.code = typeof error.code === 'number' ? error.code : 1201;
|
|
860
|
+
this.message = error.message || `Quota rate limit exceeded`;
|
|
861
|
+
this.status = typeof error.status === 'number' ? error.status : 429;
|
|
862
|
+
if (error.cause !== undefined)
|
|
863
|
+
this.cause = error.cause;
|
|
864
|
+
Object.setPrototypeOf(this, QuotaRateLimitError.prototype);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
export class NoDefaultKeyError extends WebrpcError {
|
|
868
|
+
constructor(error = {}) {
|
|
869
|
+
super(error);
|
|
870
|
+
this.name = error.name || 'NoDefaultKey';
|
|
871
|
+
this.code = typeof error.code === 'number' ? error.code : 1300;
|
|
872
|
+
this.message = error.message || `No default access key found`;
|
|
873
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
874
|
+
if (error.cause !== undefined)
|
|
875
|
+
this.cause = error.cause;
|
|
876
|
+
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
export class MaxAccessKeysError extends WebrpcError {
|
|
880
|
+
constructor(error = {}) {
|
|
881
|
+
super(error);
|
|
882
|
+
this.name = error.name || 'MaxAccessKeys';
|
|
883
|
+
this.code = typeof error.code === 'number' ? error.code : 1301;
|
|
884
|
+
this.message = error.message || `Access keys limit reached`;
|
|
885
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
886
|
+
if (error.cause !== undefined)
|
|
887
|
+
this.cause = error.cause;
|
|
888
|
+
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
export class AtLeastOneKeyError extends WebrpcError {
|
|
892
|
+
constructor(error = {}) {
|
|
893
|
+
super(error);
|
|
894
|
+
this.name = error.name || 'AtLeastOneKey';
|
|
895
|
+
this.code = typeof error.code === 'number' ? error.code : 1302;
|
|
896
|
+
this.message = error.message || `You need at least one Access Key`;
|
|
897
|
+
this.status = typeof error.status === 'number' ? error.status : 403;
|
|
898
|
+
if (error.cause !== undefined)
|
|
899
|
+
this.cause = error.cause;
|
|
900
|
+
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
export class TimeoutError extends WebrpcError {
|
|
904
|
+
constructor(error = {}) {
|
|
905
|
+
super(error);
|
|
906
|
+
this.name = error.name || 'Timeout';
|
|
907
|
+
this.code = typeof error.code === 'number' ? error.code : 1900;
|
|
908
|
+
this.message = error.message || `Request timed out`;
|
|
909
|
+
this.status = typeof error.status === 'number' ? error.status : 408;
|
|
910
|
+
if (error.cause !== undefined)
|
|
911
|
+
this.cause = error.cause;
|
|
912
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
export class InvalidArgumentError extends WebrpcError {
|
|
916
|
+
constructor(error = {}) {
|
|
917
|
+
super(error);
|
|
918
|
+
this.name = error.name || 'InvalidArgument';
|
|
919
|
+
this.code = typeof error.code === 'number' ? error.code : 2000;
|
|
920
|
+
this.message = error.message || `Invalid argument`;
|
|
921
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
922
|
+
if (error.cause !== undefined)
|
|
923
|
+
this.cause = error.cause;
|
|
924
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
export class UnexpectedError extends WebrpcError {
|
|
928
|
+
constructor(error = {}) {
|
|
929
|
+
super(error);
|
|
930
|
+
this.name = error.name || 'Unexpected';
|
|
931
|
+
this.code = typeof error.code === 'number' ? error.code : 2001;
|
|
932
|
+
this.message = error.message || `Unexpected server error`;
|
|
933
|
+
this.status = typeof error.status === 'number' ? error.status : 500;
|
|
934
|
+
if (error.cause !== undefined)
|
|
935
|
+
this.cause = error.cause;
|
|
936
|
+
Object.setPrototypeOf(this, UnexpectedError.prototype);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
export class UnavailableError extends WebrpcError {
|
|
940
|
+
constructor(error = {}) {
|
|
941
|
+
super(error);
|
|
942
|
+
this.name = error.name || 'Unavailable';
|
|
943
|
+
this.code = typeof error.code === 'number' ? error.code : 2002;
|
|
944
|
+
this.message = error.message || `Unavailable resource`;
|
|
945
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
946
|
+
if (error.cause !== undefined)
|
|
947
|
+
this.cause = error.cause;
|
|
948
|
+
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
export class QueryFailedError extends WebrpcError {
|
|
952
|
+
constructor(error = {}) {
|
|
953
|
+
super(error);
|
|
954
|
+
this.name = error.name || 'QueryFailed';
|
|
955
|
+
this.code = typeof error.code === 'number' ? error.code : 2003;
|
|
956
|
+
this.message = error.message || `Query failed`;
|
|
957
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
958
|
+
if (error.cause !== undefined)
|
|
959
|
+
this.cause = error.cause;
|
|
960
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
export class IntentStatusError extends WebrpcError {
|
|
964
|
+
constructor(error = {}) {
|
|
965
|
+
super(error);
|
|
966
|
+
this.name = error.name || 'IntentStatus';
|
|
967
|
+
this.code = typeof error.code === 'number' ? error.code : 2004;
|
|
968
|
+
this.message = error.message || `Invalid intent status`;
|
|
969
|
+
this.status = typeof error.status === 'number' ? error.status : 422;
|
|
970
|
+
if (error.cause !== undefined)
|
|
971
|
+
this.cause = error.cause;
|
|
972
|
+
Object.setPrototypeOf(this, IntentStatusError.prototype);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
export class NotFoundError extends WebrpcError {
|
|
976
|
+
constructor(error = {}) {
|
|
977
|
+
super(error);
|
|
978
|
+
this.name = error.name || 'NotFound';
|
|
979
|
+
this.code = typeof error.code === 'number' ? error.code : 8000;
|
|
980
|
+
this.message = error.message || `Resource not found`;
|
|
981
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
982
|
+
if (error.cause !== undefined)
|
|
983
|
+
this.cause = error.cause;
|
|
984
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
export class UnsupportedNetworkError extends WebrpcError {
|
|
988
|
+
constructor(error = {}) {
|
|
989
|
+
super(error);
|
|
990
|
+
this.name = error.name || 'UnsupportedNetwork';
|
|
991
|
+
this.code = typeof error.code === 'number' ? error.code : 8008;
|
|
992
|
+
this.message = error.message || `Unsupported network`;
|
|
993
|
+
this.status = typeof error.status === 'number' ? error.status : 422;
|
|
994
|
+
if (error.cause !== undefined)
|
|
995
|
+
this.cause = error.cause;
|
|
996
|
+
Object.setPrototypeOf(this, UnsupportedNetworkError.prototype);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
export class ClientOutdatedError extends WebrpcError {
|
|
1000
|
+
constructor(error = {}) {
|
|
1001
|
+
super(error);
|
|
1002
|
+
this.name = error.name || 'ClientOutdated';
|
|
1003
|
+
this.code = typeof error.code === 'number' ? error.code : 8009;
|
|
1004
|
+
this.message = error.message || `Client is outdated`;
|
|
1005
|
+
this.status = typeof error.status === 'number' ? error.status : 422;
|
|
1006
|
+
if (error.cause !== undefined)
|
|
1007
|
+
this.cause = error.cause;
|
|
1008
|
+
Object.setPrototypeOf(this, ClientOutdatedError.prototype);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
export class IntentsSkippedError extends WebrpcError {
|
|
1012
|
+
constructor(error = {}) {
|
|
1013
|
+
super(error);
|
|
1014
|
+
this.name = error.name || 'IntentsSkipped';
|
|
1015
|
+
this.code = typeof error.code === 'number' ? error.code : 7000;
|
|
1016
|
+
this.message = error.message || `Intents skipped as client is attempting a transaction that does not require intents`;
|
|
1017
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1018
|
+
if (error.cause !== undefined)
|
|
1019
|
+
this.cause = error.cause;
|
|
1020
|
+
Object.setPrototypeOf(this, IntentsSkippedError.prototype);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
export class QuoteExpiredError extends WebrpcError {
|
|
1024
|
+
constructor(error = {}) {
|
|
1025
|
+
super(error);
|
|
1026
|
+
this.name = error.name || 'QuoteExpired';
|
|
1027
|
+
this.code = typeof error.code === 'number' ? error.code : 7001;
|
|
1028
|
+
this.message = error.message || `Intent quote has expired. Please try again.`;
|
|
1029
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1030
|
+
if (error.cause !== undefined)
|
|
1031
|
+
this.cause = error.cause;
|
|
1032
|
+
Object.setPrototypeOf(this, QuoteExpiredError.prototype);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
export class IntentsDisabledError extends WebrpcError {
|
|
1036
|
+
constructor(error = {}) {
|
|
1037
|
+
super(error);
|
|
1038
|
+
this.name = error.name || 'IntentsDisabled';
|
|
1039
|
+
this.code = typeof error.code === 'number' ? error.code : 9000;
|
|
1040
|
+
this.message = error.message || `Intents service is currently unavailable`;
|
|
1041
|
+
this.status = typeof error.status === 'number' ? error.status : 400;
|
|
1042
|
+
if (error.cause !== undefined)
|
|
1043
|
+
this.cause = error.cause;
|
|
1044
|
+
Object.setPrototypeOf(this, IntentsDisabledError.prototype);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
export var errors;
|
|
1048
|
+
(function (errors) {
|
|
1049
|
+
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
1050
|
+
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
1051
|
+
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
1052
|
+
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
1053
|
+
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
1054
|
+
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
1055
|
+
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
1056
|
+
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
1057
|
+
errors["WebrpcClientAborted"] = "WebrpcClientAborted";
|
|
1058
|
+
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
1059
|
+
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
1060
|
+
errors["Unauthorized"] = "Unauthorized";
|
|
1061
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
|
1062
|
+
errors["SessionExpired"] = "SessionExpired";
|
|
1063
|
+
errors["MethodNotFound"] = "MethodNotFound";
|
|
1064
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
1065
|
+
errors["Aborted"] = "Aborted";
|
|
1066
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
1067
|
+
errors["RateLimited"] = "RateLimited";
|
|
1068
|
+
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
1069
|
+
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
1070
|
+
errors["AccessKeyMismatch"] = "AccessKeyMismatch";
|
|
1071
|
+
errors["InvalidOrigin"] = "InvalidOrigin";
|
|
1072
|
+
errors["InvalidService"] = "InvalidService";
|
|
1073
|
+
errors["UnauthorizedUser"] = "UnauthorizedUser";
|
|
1074
|
+
errors["QuotaExceeded"] = "QuotaExceeded";
|
|
1075
|
+
errors["QuotaRateLimit"] = "QuotaRateLimit";
|
|
1076
|
+
errors["NoDefaultKey"] = "NoDefaultKey";
|
|
1077
|
+
errors["MaxAccessKeys"] = "MaxAccessKeys";
|
|
1078
|
+
errors["AtLeastOneKey"] = "AtLeastOneKey";
|
|
1079
|
+
errors["Timeout"] = "Timeout";
|
|
1080
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
|
1081
|
+
errors["Unexpected"] = "Unexpected";
|
|
1082
|
+
errors["Unavailable"] = "Unavailable";
|
|
1083
|
+
errors["QueryFailed"] = "QueryFailed";
|
|
1084
|
+
errors["IntentStatus"] = "IntentStatus";
|
|
1085
|
+
errors["NotFound"] = "NotFound";
|
|
1086
|
+
errors["UnsupportedNetwork"] = "UnsupportedNetwork";
|
|
1087
|
+
errors["ClientOutdated"] = "ClientOutdated";
|
|
1088
|
+
errors["IntentsSkipped"] = "IntentsSkipped";
|
|
1089
|
+
errors["QuoteExpired"] = "QuoteExpired";
|
|
1090
|
+
errors["IntentsDisabled"] = "IntentsDisabled";
|
|
1091
|
+
})(errors || (errors = {}));
|
|
1092
|
+
export var WebrpcErrorCodes;
|
|
1093
|
+
(function (WebrpcErrorCodes) {
|
|
1094
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
|
1095
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
|
1096
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
|
1097
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
|
1098
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
|
1099
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
1100
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
1101
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
1102
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
|
|
1103
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
1104
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
1105
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
1106
|
+
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
|
1107
|
+
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
|
1108
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
|
1109
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
|
1110
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Aborted"] = 1005] = "Aborted";
|
|
1111
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
|
|
1112
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 1007] = "RateLimited";
|
|
1113
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 1008] = "ProjectNotFound";
|
|
1114
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyNotFound"] = 1101] = "AccessKeyNotFound";
|
|
1115
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyMismatch"] = 1102] = "AccessKeyMismatch";
|
|
1116
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidOrigin"] = 1103] = "InvalidOrigin";
|
|
1117
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidService"] = 1104] = "InvalidService";
|
|
1118
|
+
WebrpcErrorCodes[WebrpcErrorCodes["UnauthorizedUser"] = 1105] = "UnauthorizedUser";
|
|
1119
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QuotaExceeded"] = 1200] = "QuotaExceeded";
|
|
1120
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QuotaRateLimit"] = 1201] = "QuotaRateLimit";
|
|
1121
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NoDefaultKey"] = 1300] = "NoDefaultKey";
|
|
1122
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MaxAccessKeys"] = 1301] = "MaxAccessKeys";
|
|
1123
|
+
WebrpcErrorCodes[WebrpcErrorCodes["AtLeastOneKey"] = 1302] = "AtLeastOneKey";
|
|
1124
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 1900] = "Timeout";
|
|
1125
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2000] = "InvalidArgument";
|
|
1126
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unexpected"] = 2001] = "Unexpected";
|
|
1127
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unavailable"] = 2002] = "Unavailable";
|
|
1128
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QueryFailed"] = 2003] = "QueryFailed";
|
|
1129
|
+
WebrpcErrorCodes[WebrpcErrorCodes["IntentStatus"] = 2004] = "IntentStatus";
|
|
1130
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 8000] = "NotFound";
|
|
1131
|
+
WebrpcErrorCodes[WebrpcErrorCodes["UnsupportedNetwork"] = 8008] = "UnsupportedNetwork";
|
|
1132
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ClientOutdated"] = 8009] = "ClientOutdated";
|
|
1133
|
+
WebrpcErrorCodes[WebrpcErrorCodes["IntentsSkipped"] = 7000] = "IntentsSkipped";
|
|
1134
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QuoteExpired"] = 7001] = "QuoteExpired";
|
|
1135
|
+
WebrpcErrorCodes[WebrpcErrorCodes["IntentsDisabled"] = 9000] = "IntentsDisabled";
|
|
1136
|
+
})(WebrpcErrorCodes || (WebrpcErrorCodes = {}));
|
|
1137
|
+
export const webrpcErrorByCode = {
|
|
1138
|
+
[0]: WebrpcEndpointError,
|
|
1139
|
+
[-1]: WebrpcRequestFailedError,
|
|
1140
|
+
[-2]: WebrpcBadRouteError,
|
|
1141
|
+
[-3]: WebrpcBadMethodError,
|
|
1142
|
+
[-4]: WebrpcBadRequestError,
|
|
1143
|
+
[-5]: WebrpcBadResponseError,
|
|
1144
|
+
[-6]: WebrpcServerPanicError,
|
|
1145
|
+
[-7]: WebrpcInternalErrorError,
|
|
1146
|
+
[-8]: WebrpcClientAbortedError,
|
|
1147
|
+
[-9]: WebrpcStreamLostError,
|
|
1148
|
+
[-10]: WebrpcStreamFinishedError,
|
|
1149
|
+
[1000]: UnauthorizedError,
|
|
1150
|
+
[1001]: PermissionDeniedError,
|
|
1151
|
+
[1002]: SessionExpiredError,
|
|
1152
|
+
[1003]: MethodNotFoundError,
|
|
1153
|
+
[1004]: RequestConflictError,
|
|
1154
|
+
[1005]: AbortedError,
|
|
1155
|
+
[1006]: GeoblockedError,
|
|
1156
|
+
[1007]: RateLimitedError,
|
|
1157
|
+
[1008]: ProjectNotFoundError,
|
|
1158
|
+
[1101]: AccessKeyNotFoundError,
|
|
1159
|
+
[1102]: AccessKeyMismatchError,
|
|
1160
|
+
[1103]: InvalidOriginError,
|
|
1161
|
+
[1104]: InvalidServiceError,
|
|
1162
|
+
[1105]: UnauthorizedUserError,
|
|
1163
|
+
[1200]: QuotaExceededError,
|
|
1164
|
+
[1201]: QuotaRateLimitError,
|
|
1165
|
+
[1300]: NoDefaultKeyError,
|
|
1166
|
+
[1301]: MaxAccessKeysError,
|
|
1167
|
+
[1302]: AtLeastOneKeyError,
|
|
1168
|
+
[1900]: TimeoutError,
|
|
1169
|
+
[2000]: InvalidArgumentError,
|
|
1170
|
+
[2001]: UnexpectedError,
|
|
1171
|
+
[2002]: UnavailableError,
|
|
1172
|
+
[2003]: QueryFailedError,
|
|
1173
|
+
[2004]: IntentStatusError,
|
|
1174
|
+
[8000]: NotFoundError,
|
|
1175
|
+
[8008]: UnsupportedNetworkError,
|
|
1176
|
+
[8009]: ClientOutdatedError,
|
|
1177
|
+
[7000]: IntentsSkippedError,
|
|
1178
|
+
[7001]: QuoteExpiredError,
|
|
1179
|
+
[9000]: IntentsDisabledError,
|
|
1180
|
+
};
|
|
1181
|
+
//
|
|
1182
|
+
// Webrpc
|
|
1183
|
+
//
|
|
1184
|
+
export const WebrpcHeader = "Webrpc";
|
|
1185
|
+
export const WebrpcHeaderValue = "webrpc@v0.32.2;gen-typescript@v0.23.1;trails-api@v1-26.2.10-fcbe559";
|
|
1186
|
+
export function VersionFromHeader(headers) {
|
|
1187
|
+
const headerValue = headers.get(WebrpcHeader);
|
|
1188
|
+
if (!headerValue) {
|
|
1189
|
+
return {
|
|
1190
|
+
WebrpcGenVersion: "",
|
|
1191
|
+
codeGenName: "",
|
|
1192
|
+
codeGenVersion: "",
|
|
1193
|
+
schemaName: "",
|
|
1194
|
+
schemaVersion: "",
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
return parseWebrpcGenVersions(headerValue);
|
|
1198
|
+
}
|
|
1199
|
+
function parseWebrpcGenVersions(header) {
|
|
1200
|
+
const versions = header.split(";");
|
|
1201
|
+
if (versions.length < 3) {
|
|
1202
|
+
return {
|
|
1203
|
+
WebrpcGenVersion: "",
|
|
1204
|
+
codeGenName: "",
|
|
1205
|
+
codeGenVersion: "",
|
|
1206
|
+
schemaName: "",
|
|
1207
|
+
schemaVersion: "",
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
const [_, WebrpcGenVersion] = versions[0].split("@");
|
|
1211
|
+
const [codeGenName, codeGenVersion] = versions[1].split("@");
|
|
1212
|
+
const [schemaName, schemaVersion] = versions[2].split("@");
|
|
1213
|
+
return {
|
|
1214
|
+
WebrpcGenVersion: WebrpcGenVersion ?? "",
|
|
1215
|
+
codeGenName: codeGenName ?? "",
|
|
1216
|
+
codeGenVersion: codeGenVersion ?? "",
|
|
1217
|
+
schemaName: schemaName ?? "",
|
|
1218
|
+
schemaVersion: schemaVersion ?? "",
|
|
1219
|
+
};
|
|
1220
|
+
}
|