@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.
- package/README.md +46 -8
- package/dist/src/accounts/error.d.ts +4 -1
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +9 -1
- package/dist/src/accounts/index.d.ts +13 -3
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +62 -6
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/index.js +4 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +33 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +2 -1
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +8 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +43 -0
- package/dist/src/accounts/kernel.d.ts +9 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +13 -0
- package/dist/src/accounts/nexus.d.ts +9 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +15 -1
- package/dist/src/accounts/passport.d.ts +12 -0
- package/dist/src/accounts/passport.d.ts.map +1 -0
- package/dist/src/accounts/passport.js +173 -0
- package/dist/src/accounts/safe.d.ts +9 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +15 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +26 -5
- package/dist/src/accounts/signing/message.js +1 -1
- package/dist/src/accounts/startale.d.ts +9 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +15 -0
- package/dist/src/accounts/walletClient.d.ts +27 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -1
- package/dist/src/accounts/walletClient.js +77 -0
- package/dist/src/actions/smart-sessions.d.ts +14 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/smart-sessions.js +16 -0
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +18 -1
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +3 -3
- package/dist/src/execution/error.d.ts +8 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +10 -1
- package/dist/src/execution/index.d.ts +10 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +85 -12
- package/dist/src/execution/permit2.d.ts +2 -2
- package/dist/src/execution/permit2.d.ts.map +1 -1
- package/dist/src/execution/permit2.js +28 -19
- package/dist/src/execution/singleChainOps.d.ts +28 -0
- package/dist/src/execution/singleChainOps.d.ts.map +1 -0
- package/dist/src/execution/singleChainOps.js +32 -0
- package/dist/src/execution/smart-session.d.ts +5 -7
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +114 -229
- package/dist/src/execution/types.d.ts +2 -1
- package/dist/src/execution/types.d.ts.map +1 -1
- package/dist/src/execution/utils.d.ts +16 -9
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +151 -76
- package/dist/src/index.d.ts +18 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +22 -25
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -1
- package/dist/src/modules/index.test.js +1 -1
- package/dist/src/modules/read.js +2 -2
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +39 -2
- package/dist/src/modules/validators/smart-sessions.d.ts +8 -8
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +29 -80
- package/dist/src/modules/validators/smart-sessions.test.js +4 -5
- package/dist/src/orchestrator/client.d.ts +3 -2
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +230 -172
- package/dist/src/orchestrator/error.d.ts +137 -1
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +137 -1
- package/dist/src/orchestrator/index.d.ts +6 -6
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +19 -3
- package/dist/src/orchestrator/registry.d.ts +6 -2
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +16 -64
- package/dist/src/orchestrator/registry.test.js +24 -24
- package/dist/src/orchestrator/types.d.ts +63 -43
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +9 -5
- package/dist/src/types.d.ts +42 -9
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +5 -0
- package/package.json +4 -4
- package/dist/src/actions/smart-session.d.ts +0 -11
- package/dist/src/actions/smart-session.d.ts.map +0 -1
- package/dist/src/actions/smart-session.js +0 -13
- package/dist/src/execution/smart-session.test.d.ts +0 -2
- package/dist/src/execution/smart-session.test.d.ts.map +0 -1
- 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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
errorType,
|
|
239
|
-
|
|
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 === '
|
|
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
|
|
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 === '
|
|
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
|
}
|