@charterlabs/rhinestone-sdk 0.2.7-dev.4 → 0.2.9

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.
Files changed (110) hide show
  1. package/README.md +46 -8
  2. package/dist/src/accounts/error.d.ts +4 -1
  3. package/dist/src/accounts/error.d.ts.map +1 -1
  4. package/dist/src/accounts/error.js +9 -1
  5. package/dist/src/accounts/index.d.ts +13 -3
  6. package/dist/src/accounts/index.d.ts.map +1 -1
  7. package/dist/src/accounts/index.js +62 -6
  8. package/dist/src/accounts/json-rpc/index.d.ts.map +1 -1
  9. package/dist/src/accounts/json-rpc/index.js +4 -0
  10. package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
  11. package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
  12. package/dist/src/accounts/json-rpc/index.test.js +33 -0
  13. package/dist/src/accounts/json-rpc/providers.d.ts +2 -1
  14. package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
  15. package/dist/src/accounts/json-rpc/providers.js +8 -0
  16. package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
  17. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
  18. package/dist/src/accounts/json-rpc/providers.test.js +43 -0
  19. package/dist/src/accounts/kernel.d.ts +9 -2
  20. package/dist/src/accounts/kernel.d.ts.map +1 -1
  21. package/dist/src/accounts/kernel.js +13 -0
  22. package/dist/src/accounts/nexus.d.ts +9 -2
  23. package/dist/src/accounts/nexus.d.ts.map +1 -1
  24. package/dist/src/accounts/nexus.js +15 -1
  25. package/dist/src/accounts/passport.d.ts +12 -0
  26. package/dist/src/accounts/passport.d.ts.map +1 -0
  27. package/dist/src/accounts/passport.js +173 -0
  28. package/dist/src/accounts/safe.d.ts +9 -2
  29. package/dist/src/accounts/safe.d.ts.map +1 -1
  30. package/dist/src/accounts/safe.js +15 -0
  31. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  32. package/dist/src/accounts/signing/common.js +26 -5
  33. package/dist/src/accounts/signing/message.js +1 -1
  34. package/dist/src/accounts/startale.d.ts +9 -2
  35. package/dist/src/accounts/startale.d.ts.map +1 -1
  36. package/dist/src/accounts/startale.js +15 -0
  37. package/dist/src/accounts/walletClient.d.ts +27 -0
  38. package/dist/src/accounts/walletClient.d.ts.map +1 -1
  39. package/dist/src/accounts/walletClient.js +77 -0
  40. package/dist/src/actions/smart-sessions.d.ts +14 -0
  41. package/dist/src/actions/smart-sessions.d.ts.map +1 -0
  42. package/dist/src/actions/smart-sessions.js +16 -0
  43. package/dist/src/errors/index.d.ts +3 -3
  44. package/dist/src/errors/index.d.ts.map +1 -1
  45. package/dist/src/errors/index.js +18 -1
  46. package/dist/src/execution/compact.d.ts +3 -3
  47. package/dist/src/execution/compact.d.ts.map +1 -1
  48. package/dist/src/execution/compact.js +3 -3
  49. package/dist/src/execution/error.d.ts +8 -1
  50. package/dist/src/execution/error.d.ts.map +1 -1
  51. package/dist/src/execution/error.js +10 -1
  52. package/dist/src/execution/index.d.ts +10 -4
  53. package/dist/src/execution/index.d.ts.map +1 -1
  54. package/dist/src/execution/index.js +85 -12
  55. package/dist/src/execution/permit2.d.ts +2 -2
  56. package/dist/src/execution/permit2.d.ts.map +1 -1
  57. package/dist/src/execution/permit2.js +28 -19
  58. package/dist/src/execution/singleChainOps.d.ts +28 -0
  59. package/dist/src/execution/singleChainOps.d.ts.map +1 -0
  60. package/dist/src/execution/singleChainOps.js +32 -0
  61. package/dist/src/execution/smart-session.d.ts +5 -7
  62. package/dist/src/execution/smart-session.d.ts.map +1 -1
  63. package/dist/src/execution/smart-session.js +114 -229
  64. package/dist/src/execution/types.d.ts +2 -1
  65. package/dist/src/execution/types.d.ts.map +1 -1
  66. package/dist/src/execution/utils.d.ts +16 -9
  67. package/dist/src/execution/utils.d.ts.map +1 -1
  68. package/dist/src/execution/utils.js +151 -76
  69. package/dist/src/index.d.ts +18 -19
  70. package/dist/src/index.d.ts.map +1 -1
  71. package/dist/src/index.js +22 -25
  72. package/dist/src/modules/index.d.ts.map +1 -1
  73. package/dist/src/modules/index.js +1 -1
  74. package/dist/src/modules/index.test.js +1 -1
  75. package/dist/src/modules/read.js +2 -2
  76. package/dist/src/modules/validators/core.d.ts +5 -3
  77. package/dist/src/modules/validators/core.d.ts.map +1 -1
  78. package/dist/src/modules/validators/core.js +39 -2
  79. package/dist/src/modules/validators/smart-sessions.d.ts +8 -8
  80. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  81. package/dist/src/modules/validators/smart-sessions.js +29 -80
  82. package/dist/src/modules/validators/smart-sessions.test.js +4 -5
  83. package/dist/src/orchestrator/client.d.ts +3 -2
  84. package/dist/src/orchestrator/client.d.ts.map +1 -1
  85. package/dist/src/orchestrator/client.js +230 -172
  86. package/dist/src/orchestrator/error.d.ts +137 -1
  87. package/dist/src/orchestrator/error.d.ts.map +1 -1
  88. package/dist/src/orchestrator/error.js +137 -1
  89. package/dist/src/orchestrator/index.d.ts +6 -6
  90. package/dist/src/orchestrator/index.d.ts.map +1 -1
  91. package/dist/src/orchestrator/index.js +19 -3
  92. package/dist/src/orchestrator/registry.d.ts +6 -2
  93. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  94. package/dist/src/orchestrator/registry.js +16 -64
  95. package/dist/src/orchestrator/registry.test.js +24 -24
  96. package/dist/src/orchestrator/types.d.ts +63 -43
  97. package/dist/src/orchestrator/types.d.ts.map +1 -1
  98. package/dist/src/orchestrator/types.js +9 -5
  99. package/dist/src/types.d.ts +42 -9
  100. package/dist/src/types.d.ts.map +1 -1
  101. package/dist/src/utils/index.d.ts +3 -0
  102. package/dist/src/utils/index.d.ts.map +1 -0
  103. package/dist/src/utils/index.js +5 -0
  104. package/package.json +4 -4
  105. package/dist/src/actions/smart-session.d.ts +0 -11
  106. package/dist/src/actions/smart-session.d.ts.map +0 -1
  107. package/dist/src/actions/smart-session.js +0 -13
  108. package/dist/src/execution/smart-session.test.d.ts +0 -2
  109. package/dist/src/execution/smart-session.test.d.ts.map +0 -1
  110. package/dist/src/execution/smart-session.test.js +0 -34
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Orchestrator = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
4
  const viem_1 = require("viem");
9
5
  const error_1 = require("./error");
10
6
  const utils_1 = require("./utils");
@@ -16,41 +12,36 @@ class Orchestrator {
16
12
  this.apiKey = apiKey;
17
13
  }
18
14
  async getPortfolio(userAddress, filter) {
19
- try {
20
- const response = await axios_1.default.get(`${this.serverUrl}/accounts/${userAddress}/portfolio`, {
21
- params: {
22
- chainIds: filter?.chainIds?.join(','),
23
- tokens: filter?.tokens
24
- ? Object.entries(filter.tokens)
25
- .map(([chainId, tokens]) => tokens.map((token) => `${chainId}:${token}`))
26
- .reduce(viem_1.concat, [])
27
- : undefined,
28
- },
29
- headers: {
30
- 'x-api-key': this.apiKey,
31
- },
32
- });
33
- const portfolioResponse = response.data.portfolio;
34
- const portfolio = portfolioResponse.map((tokenResponse) => ({
35
- symbol: tokenResponse.tokenName,
36
- decimals: tokenResponse.tokenDecimals,
37
- balances: {
38
- locked: BigInt(tokenResponse.balance.locked),
39
- unlocked: BigInt(tokenResponse.balance.unlocked),
40
- },
41
- chains: tokenResponse.tokenChainBalance.map((chainBalance) => ({
42
- chain: chainBalance.chainId,
43
- address: chainBalance.tokenAddress,
44
- locked: BigInt(chainBalance.balance.locked),
45
- unlocked: BigInt(chainBalance.balance.unlocked),
46
- })),
47
- }));
48
- return portfolio;
15
+ const params = new URLSearchParams();
16
+ if (filter?.chainIds) {
17
+ params.set('chainIds', filter.chainIds.join(','));
49
18
  }
50
- catch (error) {
51
- this.parseError(error);
52
- throw new error_1.OrchestratorError({ message: 'Failed to get portfolio' });
19
+ if (filter?.tokens) {
20
+ params.set('tokens', Object.entries(filter.tokens)
21
+ .flatMap(([chainId, tokens]) => tokens.map((token) => `${chainId}:${token}`))
22
+ .join(','));
53
23
  }
24
+ const url = new URL(`${this.serverUrl}/accounts/${userAddress}/portfolio`);
25
+ url.search = params.toString();
26
+ const json = await this.fetch(url.toString(), {
27
+ headers: this.getHeaders(),
28
+ });
29
+ const portfolioResponse = json.portfolio;
30
+ const portfolio = portfolioResponse.map((tokenResponse) => ({
31
+ symbol: tokenResponse.tokenName,
32
+ decimals: tokenResponse.tokenDecimals,
33
+ balances: {
34
+ locked: BigInt(tokenResponse.balance.locked),
35
+ unlocked: BigInt(tokenResponse.balance.unlocked),
36
+ },
37
+ chains: tokenResponse.tokenChainBalance.map((chainBalance) => ({
38
+ chain: chainBalance.chainId,
39
+ address: chainBalance.tokenAddress,
40
+ locked: BigInt(chainBalance.balance.locked),
41
+ unlocked: BigInt(chainBalance.balance.unlocked),
42
+ })),
43
+ }));
44
+ return portfolio;
54
45
  }
55
46
  async getMaxTokenAmount(userAddress, destinationChainId, destinationTokenAddress, destinationGasUnits, sponsored) {
56
47
  const intentCost = await this.getIntentCost({
@@ -67,7 +58,7 @@ class Orchestrator {
67
58
  destinationExecutions: [],
68
59
  destinationChainId,
69
60
  destinationGasUnits,
70
- tokenTransfers: [
61
+ tokenRequests: [
71
62
  {
72
63
  tokenAddress: destinationTokenAddress,
73
64
  },
@@ -90,159 +81,184 @@ class Orchestrator {
90
81
  return 0n;
91
82
  }
92
83
  const tokenAmount = tokenReceived.destinationAmount;
93
- if (tokenAmount < 0n) {
84
+ if (BigInt(tokenAmount) < 0n) {
94
85
  throw new Error(`Balance not available. Make sure the account is deployed`);
95
86
  }
96
87
  // `sponsorSettings` is not taken into account in the API response for now
97
88
  // As a workaround, we use the `amountSpent` if the transaction is sponsored
98
89
  return sponsored
99
- ? tokenReceived.amountSpent
100
- : tokenReceived.destinationAmount;
90
+ ? BigInt(tokenReceived.amountSpent)
91
+ : BigInt(tokenReceived.destinationAmount);
101
92
  }
102
93
  async getIntentCost(input) {
103
- try {
104
- const response = await axios_1.default.post(`${this.serverUrl}/intents/cost`, {
105
- ...(0, utils_1.convertBigIntFields)(input),
106
- }, {
107
- headers: {
108
- 'x-api-key': this.apiKey,
109
- },
110
- });
111
- return response.data;
112
- }
113
- catch (error) {
114
- this.parseError(error);
115
- throw new error_1.OrchestratorError({ message: 'Failed to get intent cost' });
116
- }
94
+ return await this.fetch(`${this.serverUrl}/intents/cost`, {
95
+ method: 'POST',
96
+ headers: this.getHeaders(),
97
+ body: JSON.stringify((0, utils_1.convertBigIntFields)(input)),
98
+ });
117
99
  }
118
100
  async getIntentRoute(input) {
119
- try {
120
- const response = await axios_1.default.post(`${this.serverUrl}/intents/route`, {
121
- ...(0, utils_1.convertBigIntFields)(input),
122
- }, {
123
- headers: {
124
- 'x-api-key': this.apiKey,
125
- },
126
- });
127
- return response.data;
128
- }
129
- catch (error) {
130
- this.parseError(error);
131
- throw new error_1.OrchestratorError({ message: 'Failed to get intent route' });
132
- }
101
+ return await this.fetch(`${this.serverUrl}/intents/route`, {
102
+ method: 'POST',
103
+ headers: this.getHeaders(),
104
+ body: JSON.stringify((0, utils_1.convertBigIntFields)(input)),
105
+ });
133
106
  }
134
- async submitIntent(signedIntentOp) {
135
- try {
136
- const response = await axios_1.default.post(`${this.serverUrl}/intent-operations`, {
137
- signedIntentOp: (0, utils_1.convertBigIntFields)(signedIntentOp),
138
- }, {
139
- headers: {
140
- 'x-api-key': this.apiKey,
141
- },
142
- });
143
- return response.data;
144
- }
145
- catch (error) {
146
- this.parseError(error);
147
- throw new error_1.OrchestratorError({ message: 'Failed to submit intent' });
107
+ async submitIntent(signedIntentOpUnformatted, dryRun) {
108
+ const signedIntentOp = (0, utils_1.convertBigIntFields)(signedIntentOpUnformatted);
109
+ if (dryRun) {
110
+ signedIntentOp.options = {
111
+ dryRun: true,
112
+ };
148
113
  }
114
+ return await this.fetch(`${this.serverUrl}/intent-operations`, {
115
+ method: 'POST',
116
+ headers: this.getHeaders(),
117
+ body: JSON.stringify({
118
+ signedIntentOp,
119
+ }),
120
+ });
149
121
  }
150
- async simulateIntent(signedIntentOp) {
151
- try {
152
- const response = await axios_1.default.post(`${this.serverUrl}/intent-operations/simulate`, {
153
- signedIntentOp: (0, utils_1.convertBigIntFields)(signedIntentOp),
154
- }, {
155
- headers: {
156
- 'x-api-key': this.apiKey,
157
- },
158
- });
159
- return response.data;
160
- }
161
- catch (error) {
162
- this.parseError(error);
163
- throw new error_1.OrchestratorError({ message: 'Failed to simulate intent' });
122
+ async getIntentOpStatus(intentId) {
123
+ return await this.fetch(`${this.serverUrl}/intent-operation/${intentId.toString()}`, {
124
+ headers: this.getHeaders(),
125
+ });
126
+ }
127
+ getHeaders() {
128
+ const headers = {
129
+ 'Content-Type': 'application/json',
130
+ };
131
+ if (this.apiKey) {
132
+ headers['x-api-key'] = this.apiKey;
164
133
  }
134
+ return headers;
165
135
  }
166
- async getIntentOpStatus(intentId) {
167
- try {
168
- const response = await axios_1.default.get(`${this.serverUrl}/intent-operation/${intentId.toString()}/status`, {
169
- headers: {
170
- 'x-api-key': this.apiKey,
136
+ async fetch(url, options) {
137
+ const response = await fetch(url, options);
138
+ if (!response.ok) {
139
+ let errorData = {};
140
+ try {
141
+ errorData = await response.json();
142
+ }
143
+ catch {
144
+ try {
145
+ const text = await response.text();
146
+ errorData = { message: text };
147
+ }
148
+ catch { }
149
+ }
150
+ const retryAfterHeader = response.headers?.get?.('retry-after') || undefined;
151
+ this.parseError({
152
+ response: {
153
+ status: response.status,
154
+ data: errorData,
155
+ headers: {
156
+ retryAfter: retryAfterHeader,
157
+ },
171
158
  },
172
159
  });
173
- return response.data;
174
- }
175
- catch (error) {
176
- this.parseError(error);
177
- throw new error_1.OrchestratorError({ message: 'Failed to get intent op status' });
178
160
  }
161
+ return response.json();
179
162
  }
180
163
  parseError(error) {
181
164
  if (error.response) {
182
- let errorType;
183
- if (error.response.status) {
184
- switch (error.response.status) {
185
- case 400:
186
- errorType = 'Bad Request';
187
- break;
188
- case 401:
189
- errorType = 'Unauthorized';
190
- break;
191
- case 403:
192
- errorType = 'Forbidden';
193
- break;
194
- case 404:
195
- errorType = 'Not Found';
196
- break;
197
- case 409:
198
- errorType = 'Conflict';
199
- break;
200
- case 422:
201
- errorType = 'Unprocessable Entity';
202
- break;
203
- case 500:
204
- errorType = 'Internal Server Error';
205
- break;
206
- default:
207
- errorType = 'Unknown';
208
- }
165
+ const status = error.response.status;
166
+ const { headers } = error.response;
167
+ const { errors = [], traceId, message } = error.response.data || {};
168
+ let errorType = 'Unknown';
169
+ switch (status) {
170
+ case 400:
171
+ errorType = 'Bad Request';
172
+ break;
173
+ case 401:
174
+ errorType = 'Unauthorized';
175
+ break;
176
+ case 403:
177
+ errorType = 'Forbidden';
178
+ break;
179
+ case 404:
180
+ errorType = 'Not Found';
181
+ break;
182
+ case 409:
183
+ errorType = 'Conflict';
184
+ break;
185
+ case 422:
186
+ errorType = 'Unprocessable Entity';
187
+ break;
188
+ case 429:
189
+ errorType = 'Too Many Requests';
190
+ break;
191
+ case 500:
192
+ errorType = 'Internal Server Error';
193
+ break;
194
+ case 503:
195
+ errorType = 'Service Unavailable';
196
+ break;
197
+ default:
198
+ errorType = 'Unknown';
209
199
  }
210
- let context = {};
211
- if (error.response.data) {
212
- const { errors, traceId, message } = error.response.data;
213
- if (message) {
214
- const mainErrorParams = {
215
- context: { traceId },
216
- errorType,
217
- traceId,
218
- };
219
- this.parseErrorMessage(message, mainErrorParams);
220
- }
221
- for (const err of errors) {
222
- let errorMessage = `Rhinestone Error: ${err.message}`;
223
- if (errorType) {
224
- errorMessage += ` (${errorType})`;
225
- }
226
- if (traceId) {
227
- errorMessage += ` [Trace ID: ${traceId}]`;
228
- context.traceId = traceId;
200
+ const baseParams = {
201
+ context: { traceId },
202
+ errorType,
203
+ traceId,
204
+ statusCode: status,
205
+ };
206
+ if (status === 429) {
207
+ const retryAfter = headers?.retryAfter;
208
+ const context = { traceId, retryAfter };
209
+ throw new error_1.RateLimitedError({
210
+ ...baseParams,
211
+ context,
212
+ });
213
+ }
214
+ if (status === 503) {
215
+ throw new error_1.ServiceUnavailableError(baseParams);
216
+ }
217
+ if (message) {
218
+ this.parseErrorMessage(message, baseParams);
219
+ }
220
+ for (const err of errors) {
221
+ const mergedParams = {
222
+ ...baseParams,
223
+ context: { ...err.context, traceId },
224
+ };
225
+ this.parseErrorMessage(err.message, mergedParams);
226
+ }
227
+ switch (status) {
228
+ case 400:
229
+ throw new error_1.BadRequestError({
230
+ ...baseParams,
231
+ context: { traceId, errors },
232
+ message: message,
233
+ });
234
+ case 401:
235
+ if (message === 'Authentication is required') {
236
+ throw new error_1.AuthenticationRequiredError(baseParams);
229
237
  }
230
- console.error(errorMessage);
231
- if (err.context) {
232
- console.error(`Context: ${JSON.stringify(err.context, undefined, 4)}`);
238
+ throw new error_1.UnauthorizedError(baseParams);
239
+ case 403:
240
+ throw new error_1.ForbiddenError(baseParams);
241
+ case 404:
242
+ throw new error_1.ResourceNotFoundError(baseParams);
243
+ case 409:
244
+ throw new error_1.ConflictError(baseParams);
245
+ case 500:
246
+ if (errors && errors.length > 0) {
247
+ const mergedParams = {
248
+ ...baseParams,
249
+ context: { ...errors[0].context, traceId },
250
+ };
251
+ throw new error_1.OrchestratorError({
252
+ ...mergedParams,
253
+ message: errors[0].message || 'Internal Server Error',
254
+ });
233
255
  }
234
- context = { ...context, ...err.context };
235
- const message = err.message;
236
- const finalErrorParams = {
237
- context: { ...context, traceId },
238
- errorType,
239
- traceId,
240
- };
241
- this.parseErrorMessage(message, finalErrorParams);
242
- }
243
- }
244
- else {
245
- console.error(error);
256
+ throw new error_1.InternalServerError(baseParams);
257
+ default:
258
+ throw new error_1.OrchestratorError({
259
+ ...baseParams,
260
+ message: message || errorType,
261
+ });
246
262
  }
247
263
  }
248
264
  }
@@ -250,7 +266,8 @@ class Orchestrator {
250
266
  if (message === 'Insufficient balance') {
251
267
  throw new error_1.InsufficientBalanceError(errorParams);
252
268
  }
253
- else if (message === 'Unsupported chain id') {
269
+ else if (message === 'Unsupported chain id' ||
270
+ message === 'Unsupported chain ids') {
254
271
  throw new error_1.UnsupportedChainIdError(errorParams);
255
272
  }
256
273
  else if (message.startsWith('Unsupported chain ')) {
@@ -271,6 +288,10 @@ class Orchestrator {
271
288
  }
272
289
  throw new error_1.OrchestratorError({ message, ...errorParams });
273
290
  }
291
+ else if (message === 'Unsupported token addresses') {
292
+ // generic unsupported tokens without specific symbol/chain context
293
+ throw new error_1.BadRequestError({ message, ...errorParams });
294
+ }
274
295
  else if (message.includes('not supported on chain')) {
275
296
  const tokenMatch = message.match(/Token (.+) not supported on chain (\d+)/);
276
297
  if (tokenMatch) {
@@ -286,18 +307,55 @@ class Orchestrator {
286
307
  else if (message === 'Invalid API key') {
287
308
  throw new error_1.InvalidApiKeyError(errorParams);
288
309
  }
310
+ else if (message === 'Insufficient permissions') {
311
+ throw new error_1.ForbiddenError(errorParams);
312
+ }
289
313
  else if (message === 'Invalid bundle signature') {
290
314
  throw new error_1.InvalidIntentSignatureError(errorParams);
291
315
  }
292
- else if (message === 'Only one target token amount can be unset') {
316
+ else if (message === 'Invalid checksum signature') {
317
+ throw new error_1.InvalidIntentSignatureError(errorParams);
318
+ }
319
+ else if (message === 'Only one target token amount can be unset' ||
320
+ message === 'Only one max-out transfer is allowed') {
293
321
  throw new error_1.OnlyOneTargetTokenAmountCanBeUnsetError(errorParams);
294
322
  }
295
- else if (message === 'No Path Found') {
323
+ else if (message === 'No valid settlement plan found for the given transfers' ||
324
+ message === 'No valid transfers sent for settlement quotes' ||
325
+ message === 'No Path Found') {
296
326
  throw new error_1.NoPathFoundError(errorParams);
297
327
  }
298
- else if (message === 'Order bundle not found') {
328
+ else if (message === 'Emissary is not enabled' ||
329
+ message === 'Emissary is not the expected address') {
330
+ throw new error_1.ForbiddenError(errorParams);
331
+ }
332
+ else if (message.includes('No such intent with nonce') ||
333
+ message === 'Order bundle not found') {
299
334
  throw new error_1.IntentNotFoundError(errorParams);
300
335
  }
336
+ else if (message === 'Could not retrieve a valid quote from any aggregator') {
337
+ throw new error_1.NoPathFoundError(errorParams);
338
+ }
339
+ else if (message === 'No aggregators available for swap') {
340
+ throw new error_1.InternalServerError(errorParams);
341
+ }
342
+ else if (message === 'entity.parse.failed' ||
343
+ message === 'entity.too.large' ||
344
+ message === 'encoding.unsupported') {
345
+ throw new error_1.BodyParserError({ message, ...errorParams });
346
+ }
347
+ else if (message === 'Bundle simulation failed') {
348
+ const simulations = errorParams.context.error.simulations;
349
+ const { traceId, errorType, statusCode, context } = errorParams;
350
+ throw new error_1.SimulationFailedError({
351
+ message,
352
+ context,
353
+ errorType,
354
+ traceId,
355
+ statusCode,
356
+ simulations,
357
+ });
358
+ }
301
359
  else {
302
360
  throw new error_1.OrchestratorError({ message, ...errorParams });
303
361
  }