@charterlabs/rhinestone-sdk 0.2.7-dev.3 → 0.2.8
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 +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +31 -20
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +231 -25
- package/dist/src/accounts/index.test.js +2 -4
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +52 -0
- package/dist/src/accounts/kernel.d.ts +1 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +29 -1
- package/dist/src/accounts/kernel.test.js +35 -8
- package/dist/src/accounts/nexus.d.ts +4 -3
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +82 -14
- package/dist/src/accounts/nexus.test.js +33 -6
- 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.map +1 -1
- package/dist/src/accounts/safe.js +85 -53
- package/dist/src/accounts/safe.test.js +33 -6
- package/dist/src/accounts/signing/common.d.ts +4 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +21 -9
- package/dist/src/accounts/signing/message.d.ts +1 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +6 -6
- package/dist/src/accounts/signing/passkeys.d.ts +8 -1
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
- package/dist/src/accounts/signing/passkeys.js +35 -0
- package/dist/src/accounts/signing/passkeys.test.js +15 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +2 -2
- package/dist/src/accounts/startale.test.js +0 -4
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -166
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +25 -544
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-sessions.d.ts +23 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/{smart-session.js → smart-sessions.js} +13 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +50 -0
- package/dist/src/execution/compact.d.ts +25 -9
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +29 -103
- package/dist/src/execution/error.d.ts +6 -6
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +13 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +115 -46
- package/dist/src/execution/multiChainOps.d.ts +40 -0
- package/dist/src/execution/multiChainOps.d.ts.map +1 -0
- package/dist/src/execution/multiChainOps.js +39 -0
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +291 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +3 -3
- package/dist/src/execution/types.d.ts +36 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +43 -28
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +269 -99
- package/dist/src/index.d.ts +38 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +121 -69
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +3 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +16 -13
- package/dist/src/modules/index.test.js +9 -12
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +5 -1
- 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 +29 -10
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -72
- package/dist/src/modules/validators/smart-sessions.test.js +4 -8
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +4 -2
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +230 -162
- package/dist/src/orchestrator/consts.d.ts +1 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +1 -3
- package/dist/src/orchestrator/error.d.ts +111 -1
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +128 -1
- package/dist/src/orchestrator/index.d.ts +4 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +16 -1
- package/dist/src/orchestrator/registry.d.ts +3 -25
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +82 -46
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +53 -43
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +74 -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 +73 -2
- package/dist/src/actions/index.test.d.ts +0 -2
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/actions/smart-session.d.ts +0 -11
- package/dist/src/actions/smart-session.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.json +0 -365
|
@@ -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,43 +12,38 @@ 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
|
-
async getMaxTokenAmount(userAddress, destinationChainId, destinationTokenAddress, destinationGasUnits) {
|
|
46
|
+
async getMaxTokenAmount(userAddress, destinationChainId, destinationTokenAddress, destinationGasUnits, sponsored) {
|
|
56
47
|
const intentCost = await this.getIntentCost({
|
|
57
48
|
account: {
|
|
58
49
|
address: userAddress,
|
|
@@ -63,7 +54,6 @@ class Orchestrator {
|
|
|
63
54
|
data: '0x',
|
|
64
55
|
},
|
|
65
56
|
],
|
|
66
|
-
delegations: {},
|
|
67
57
|
},
|
|
68
58
|
destinationExecutions: [],
|
|
69
59
|
destinationChainId,
|
|
@@ -73,6 +63,14 @@ class Orchestrator {
|
|
|
73
63
|
tokenAddress: destinationTokenAddress,
|
|
74
64
|
},
|
|
75
65
|
],
|
|
66
|
+
options: {
|
|
67
|
+
topupCompact: false,
|
|
68
|
+
sponsorSettings: {
|
|
69
|
+
gasSponsored: sponsored,
|
|
70
|
+
bridgeFeesSponsored: sponsored,
|
|
71
|
+
swapFeesSponsored: sponsored,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
76
74
|
});
|
|
77
75
|
if (!intentCost.hasFulfilledAll) {
|
|
78
76
|
return 0n;
|
|
@@ -83,144 +81,184 @@ class Orchestrator {
|
|
|
83
81
|
return 0n;
|
|
84
82
|
}
|
|
85
83
|
const tokenAmount = tokenReceived.destinationAmount;
|
|
86
|
-
if (tokenAmount < 0n) {
|
|
84
|
+
if (BigInt(tokenAmount) < 0n) {
|
|
87
85
|
throw new Error(`Balance not available. Make sure the account is deployed`);
|
|
88
86
|
}
|
|
89
|
-
|
|
87
|
+
// `sponsorSettings` is not taken into account in the API response for now
|
|
88
|
+
// As a workaround, we use the `amountSpent` if the transaction is sponsored
|
|
89
|
+
return sponsored
|
|
90
|
+
? BigInt(tokenReceived.amountSpent)
|
|
91
|
+
: BigInt(tokenReceived.destinationAmount);
|
|
90
92
|
}
|
|
91
93
|
async getIntentCost(input) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
tokenAddress: transfer.tokenAddress,
|
|
98
|
-
})),
|
|
99
|
-
}),
|
|
100
|
-
}, {
|
|
101
|
-
headers: {
|
|
102
|
-
'x-api-key': this.apiKey,
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
return response.data;
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
this.parseError(error);
|
|
109
|
-
throw new Error('Failed to get intent cost');
|
|
110
|
-
}
|
|
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
|
+
});
|
|
111
99
|
}
|
|
112
100
|
async getIntentRoute(input) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'x-api-key': this.apiKey,
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
return response.data;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
this.parseError(error);
|
|
125
|
-
throw new Error('Failed to get intent route');
|
|
126
|
-
}
|
|
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
|
+
});
|
|
127
106
|
}
|
|
128
|
-
async submitIntent(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
'x-api-key': this.apiKey,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
return response.data;
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
this.parseError(error);
|
|
141
|
-
throw new Error('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
|
+
};
|
|
142
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
|
+
});
|
|
143
121
|
}
|
|
144
122
|
async getIntentOpStatus(intentId) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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;
|
|
133
|
+
}
|
|
134
|
+
return headers;
|
|
135
|
+
}
|
|
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
|
+
},
|
|
149
158
|
},
|
|
150
159
|
});
|
|
151
|
-
return response.data;
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
this.parseError(error);
|
|
155
|
-
throw new Error('Failed to get intent op status');
|
|
156
160
|
}
|
|
161
|
+
return response.json();
|
|
157
162
|
}
|
|
158
163
|
parseError(error) {
|
|
159
164
|
if (error.response) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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';
|
|
187
199
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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);
|
|
207
237
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
+
});
|
|
211
255
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
errorType,
|
|
217
|
-
|
|
218
|
-
};
|
|
219
|
-
this.parseErrorMessage(message, finalErrorParams);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
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
|
+
});
|
|
224
262
|
}
|
|
225
263
|
}
|
|
226
264
|
}
|
|
@@ -228,7 +266,8 @@ class Orchestrator {
|
|
|
228
266
|
if (message === 'Insufficient balance') {
|
|
229
267
|
throw new error_1.InsufficientBalanceError(errorParams);
|
|
230
268
|
}
|
|
231
|
-
else if (message === 'Unsupported chain id'
|
|
269
|
+
else if (message === 'Unsupported chain id' ||
|
|
270
|
+
message === 'Unsupported chain ids') {
|
|
232
271
|
throw new error_1.UnsupportedChainIdError(errorParams);
|
|
233
272
|
}
|
|
234
273
|
else if (message.startsWith('Unsupported chain ')) {
|
|
@@ -249,6 +288,10 @@ class Orchestrator {
|
|
|
249
288
|
}
|
|
250
289
|
throw new error_1.OrchestratorError({ message, ...errorParams });
|
|
251
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
|
+
}
|
|
252
295
|
else if (message.includes('not supported on chain')) {
|
|
253
296
|
const tokenMatch = message.match(/Token (.+) not supported on chain (\d+)/);
|
|
254
297
|
if (tokenMatch) {
|
|
@@ -264,18 +307,43 @@ class Orchestrator {
|
|
|
264
307
|
else if (message === 'Invalid API key') {
|
|
265
308
|
throw new error_1.InvalidApiKeyError(errorParams);
|
|
266
309
|
}
|
|
310
|
+
else if (message === 'Insufficient permissions') {
|
|
311
|
+
throw new error_1.ForbiddenError(errorParams);
|
|
312
|
+
}
|
|
267
313
|
else if (message === 'Invalid bundle signature') {
|
|
268
314
|
throw new error_1.InvalidIntentSignatureError(errorParams);
|
|
269
315
|
}
|
|
270
|
-
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') {
|
|
271
321
|
throw new error_1.OnlyOneTargetTokenAmountCanBeUnsetError(errorParams);
|
|
272
322
|
}
|
|
273
|
-
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') {
|
|
274
326
|
throw new error_1.NoPathFoundError(errorParams);
|
|
275
327
|
}
|
|
276
|
-
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') {
|
|
277
334
|
throw new error_1.IntentNotFoundError(errorParams);
|
|
278
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
|
+
}
|
|
279
347
|
else {
|
|
280
348
|
throw new error_1.OrchestratorError({ message, ...errorParams });
|
|
281
349
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
declare const PROD_ORCHESTRATOR_URL = "https://v1.orchestrator.rhinestone.dev";
|
|
2
2
|
declare const STAGING_ORCHESTRATOR_URL = "https://staging.v1.orchestrator.rhinestone.dev";
|
|
3
|
-
declare const DEV_ORCHESTRATOR_URL = "https://dev.v1.orchestrator.rhinestone.dev";
|
|
4
3
|
declare const RHINESTONE_SPOKE_POOL_ADDRESS = "0x000000000060f6e853447881951574cdd0663530";
|
|
5
|
-
export { PROD_ORCHESTRATOR_URL, STAGING_ORCHESTRATOR_URL,
|
|
4
|
+
export { PROD_ORCHESTRATOR_URL, STAGING_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, };
|
|
6
5
|
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../orchestrator/consts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,qBAAqB,2CAA2C,CAAA;AACtE,QAAA,MAAM,wBAAwB,mDACoB,CAAA;AAClD,QAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../orchestrator/consts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,qBAAqB,2CAA2C,CAAA;AACtE,QAAA,MAAM,wBAAwB,mDACoB,CAAA;AAClD,QAAA,MAAM,6BAA6B,+CACW,CAAA;AAE9C,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,6BAA6B,GAC9B,CAAA"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RHINESTONE_SPOKE_POOL_ADDRESS = exports.
|
|
3
|
+
exports.RHINESTONE_SPOKE_POOL_ADDRESS = exports.STAGING_ORCHESTRATOR_URL = exports.PROD_ORCHESTRATOR_URL = void 0;
|
|
4
4
|
const PROD_ORCHESTRATOR_URL = 'https://v1.orchestrator.rhinestone.dev';
|
|
5
5
|
exports.PROD_ORCHESTRATOR_URL = PROD_ORCHESTRATOR_URL;
|
|
6
6
|
const STAGING_ORCHESTRATOR_URL = 'https://staging.v1.orchestrator.rhinestone.dev';
|
|
7
7
|
exports.STAGING_ORCHESTRATOR_URL = STAGING_ORCHESTRATOR_URL;
|
|
8
|
-
const DEV_ORCHESTRATOR_URL = 'https://dev.v1.orchestrator.rhinestone.dev';
|
|
9
|
-
exports.DEV_ORCHESTRATOR_URL = DEV_ORCHESTRATOR_URL;
|
|
10
8
|
const RHINESTONE_SPOKE_POOL_ADDRESS = '0x000000000060f6e853447881951574cdd0663530';
|
|
11
9
|
exports.RHINESTONE_SPOKE_POOL_ADDRESS = RHINESTONE_SPOKE_POOL_ADDRESS;
|