@rhinestone/sdk 2.0.0-beta.0 → 2.0.0-beta.2

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 (89) hide show
  1. package/README.md +43 -2
  2. package/dist/src/accounts/index.d.ts.map +1 -1
  3. package/dist/src/accounts/index.js +6 -34
  4. package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
  5. package/dist/src/accounts/json-rpc/providers.js +3 -2
  6. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  7. package/dist/src/actions/smart-sessions.js +3 -3
  8. package/dist/src/errors/index.d.ts +3 -3
  9. package/dist/src/errors/index.d.ts.map +1 -1
  10. package/dist/src/errors/index.js +6 -4
  11. package/dist/src/execution/compact.d.ts +1 -144
  12. package/dist/src/execution/compact.d.ts.map +1 -1
  13. package/dist/src/execution/compact.js +1 -109
  14. package/dist/src/execution/error.d.ts +10 -1
  15. package/dist/src/execution/error.d.ts.map +1 -1
  16. package/dist/src/execution/error.js +9 -1
  17. package/dist/src/execution/index.d.ts +5 -7
  18. package/dist/src/execution/index.d.ts.map +1 -1
  19. package/dist/src/execution/index.js +24 -44
  20. package/dist/src/execution/utils.d.ts +29 -13
  21. package/dist/src/execution/utils.d.ts.map +1 -1
  22. package/dist/src/execution/utils.js +174 -122
  23. package/dist/src/index.d.ts +21 -16
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/index.js +15 -45
  26. package/dist/src/modules/index.d.ts +2 -2
  27. package/dist/src/modules/index.d.ts.map +1 -1
  28. package/dist/src/modules/index.js +2 -2
  29. package/dist/src/modules/read.d.ts.map +1 -1
  30. package/dist/src/modules/read.js +2 -4
  31. package/dist/src/modules/validators/index.d.ts +2 -2
  32. package/dist/src/modules/validators/index.d.ts.map +1 -1
  33. package/dist/src/modules/validators/index.js +2 -2
  34. package/dist/src/modules/validators/permissions.d.ts +5 -0
  35. package/dist/src/modules/validators/permissions.d.ts.map +1 -0
  36. package/dist/src/modules/validators/permissions.js +111 -0
  37. package/dist/src/modules/validators/policies/claim/permit2.d.ts +29 -3
  38. package/dist/src/modules/validators/policies/claim/permit2.d.ts.map +1 -1
  39. package/dist/src/modules/validators/smart-sessions.d.ts +14 -27
  40. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  41. package/dist/src/modules/validators/smart-sessions.js +74 -22
  42. package/dist/src/orchestrator/caip2.d.ts +7 -0
  43. package/dist/src/orchestrator/caip2.d.ts.map +1 -0
  44. package/dist/src/orchestrator/caip2.js +17 -0
  45. package/dist/src/orchestrator/client.d.ts +11 -11
  46. package/dist/src/orchestrator/client.d.ts.map +1 -1
  47. package/dist/src/orchestrator/client.js +193 -295
  48. package/dist/src/orchestrator/consts.d.ts +2 -2
  49. package/dist/src/orchestrator/consts.d.ts.map +1 -1
  50. package/dist/src/orchestrator/consts.js +2 -2
  51. package/dist/src/orchestrator/error.d.ts +72 -217
  52. package/dist/src/orchestrator/error.d.ts.map +1 -1
  53. package/dist/src/orchestrator/error.js +117 -195
  54. package/dist/src/orchestrator/index.d.ts +5 -5
  55. package/dist/src/orchestrator/index.d.ts.map +1 -1
  56. package/dist/src/orchestrator/index.js +3 -3
  57. package/dist/src/orchestrator/registry.d.ts +1 -8
  58. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  59. package/dist/src/orchestrator/registry.js +1 -26
  60. package/dist/src/orchestrator/types.d.ts +97 -232
  61. package/dist/src/orchestrator/types.d.ts.map +1 -1
  62. package/dist/src/types.d.ts +101 -32
  63. package/dist/src/types.d.ts.map +1 -1
  64. package/dist/src/utils/index.d.ts +2 -1
  65. package/dist/src/utils/index.d.ts.map +1 -1
  66. package/dist/src/utils/index.js +2 -1
  67. package/dist/src/utils/walletClient.d.ts.map +1 -0
  68. package/dist/src/{accounts → utils}/walletClient.js +1 -1
  69. package/package.json +1 -5
  70. package/dist/src/accounts/passport.d.ts +0 -9
  71. package/dist/src/accounts/passport.d.ts.map +0 -1
  72. package/dist/src/accounts/passport.js +0 -78
  73. package/dist/src/accounts/walletClient.d.ts.map +0 -1
  74. package/dist/src/actions/compact.d.ts +0 -15
  75. package/dist/src/actions/compact.d.ts.map +0 -1
  76. package/dist/src/actions/compact.js +0 -200
  77. package/dist/src/actions/deployment.d.ts +0 -19
  78. package/dist/src/actions/deployment.d.ts.map +0 -1
  79. package/dist/src/actions/deployment.js +0 -76
  80. package/dist/src/execution/permit2.d.ts +0 -143
  81. package/dist/src/execution/permit2.d.ts.map +0 -1
  82. package/dist/src/execution/permit2.js +0 -280
  83. package/dist/src/execution/singleChainOps.d.ts +0 -41
  84. package/dist/src/execution/singleChainOps.d.ts.map +0 -1
  85. package/dist/src/execution/singleChainOps.js +0 -42
  86. package/dist/src/execution/types.d.ts +0 -36
  87. package/dist/src/execution/types.d.ts.map +0 -1
  88. package/dist/src/execution/types.js +0 -1
  89. /package/dist/src/{accounts → utils}/walletClient.d.ts +0 -0
@@ -1,12 +1,7 @@
1
+ import { fromCaip2, toCaip2 } from './caip2.js';
1
2
  import { API_VERSION, SDK_VERSION } from './consts.js';
2
- import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, } from './error.js';
3
+ import { OrchestratorError, parseErrorEnvelope, } from './error.js';
3
4
  import { convertBigIntFields } from './utils.js';
4
- function parseTokenAmountsRecord(record) {
5
- return Object.fromEntries(Object.entries(record).map(([addr, amount]) => [
6
- addr,
7
- BigInt(amount),
8
- ]));
9
- }
10
5
  export class Orchestrator {
11
6
  serverUrl;
12
7
  authProvider;
@@ -16,112 +11,90 @@ export class Orchestrator {
16
11
  this.authProvider = authProvider;
17
12
  this.extraHeaders = headers;
18
13
  }
19
- async getPortfolio(userAddress, filter) {
14
+ async getPortfolio(accountAddress, filter) {
20
15
  const params = new URLSearchParams();
21
16
  if (filter?.chainIds) {
22
- params.set('chainIds', filter.chainIds.join(','));
17
+ for (const id of filter.chainIds) {
18
+ params.append('chainIds', toCaip2(id));
19
+ }
23
20
  }
24
21
  if (filter?.tokens) {
25
- params.set('tokens', Object.entries(filter.tokens)
26
- .flatMap(([chainId, tokens]) => tokens.map((token) => `${chainId}:${token}`))
27
- .join(','));
22
+ for (const [chainId, tokens] of Object.entries(filter.tokens)) {
23
+ for (const token of tokens) {
24
+ params.append('tokens', `${toCaip2(Number(chainId))}:${token}`);
25
+ }
26
+ }
28
27
  }
29
- const url = new URL(`${this.serverUrl}/accounts/${userAddress}/portfolio`);
28
+ const url = new URL(`${this.serverUrl}/accounts/${accountAddress}/portfolio`);
30
29
  url.search = params.toString();
31
30
  const json = await this.fetch(url.toString(), {
32
31
  headers: await this.getHeaders(),
33
32
  });
34
- const portfolioResponse = json.portfolio;
35
- const portfolio = portfolioResponse.map((tokenResponse) => ({
36
- symbol: tokenResponse.tokenName,
37
- decimals: tokenResponse.tokenDecimals,
38
- balances: {
39
- locked: BigInt(tokenResponse.balance.locked),
40
- unlocked: BigInt(tokenResponse.balance.unlocked),
41
- },
42
- chains: tokenResponse.tokenChainBalance.map((chainBalance) => ({
43
- chain: chainBalance.chainId,
44
- address: chainBalance.tokenAddress,
45
- locked: BigInt(chainBalance.balance.locked),
46
- unlocked: BigInt(chainBalance.balance.unlocked),
33
+ const portfolioWire = json.portfolio;
34
+ return portfolioWire.map((token) => ({
35
+ symbol: token.symbol,
36
+ chains: token.chains.map((c) => ({
37
+ chain: parseChainId(c.chainId),
38
+ address: c.address,
39
+ decimals: c.decimals,
40
+ locked: BigInt(c.balance.locked),
41
+ unlocked: BigInt(c.balance.unlocked),
47
42
  })),
48
43
  }));
49
- return portfolio;
50
44
  }
51
- async getIntentRoute(input) {
52
- const body = convertBigIntFields(input);
53
- return await this.fetch(`${this.serverUrl}/intents/route`, {
45
+ async createQuote(input) {
46
+ const body = encodeIntentInput(input);
47
+ const json = await this.fetch(`${this.serverUrl}/quotes`, {
54
48
  method: 'POST',
55
49
  headers: await this.getHeaders(),
56
50
  body: JSON.stringify(body),
57
51
  });
52
+ return decodeQuoteResponse(json);
58
53
  }
59
- async splitIntents(input) {
60
- const response = await fetch(`${this.serverUrl}/intents/split`, {
54
+ async getSplit(input) {
55
+ const body = convertBigIntFields({
56
+ chainId: toCaip2(input.chain.id),
57
+ tokens: input.tokens,
58
+ settlementLayers: input.settlementLayers,
59
+ });
60
+ const json = await this.fetch(`${this.serverUrl}/intents/splits`, {
61
61
  method: 'POST',
62
62
  headers: await this.getHeaders(),
63
- body: JSON.stringify(convertBigIntFields({
64
- chainId: input.chain.id,
65
- tokens: input.tokens,
66
- settlementLayers: input.settlementLayers,
67
- })),
68
- });
69
- if (response.ok) {
70
- const json = await response.json();
71
- return {
72
- intents: json.intents.map(parseTokenAmountsRecord),
73
- };
74
- }
75
- let errorData = {};
76
- try {
77
- errorData = await response.json();
78
- }
79
- catch {
80
- try {
81
- const text = await response.text();
82
- errorData = { message: text };
83
- }
84
- catch { }
85
- }
86
- if (response.status === 422 &&
87
- errorData.error === 'INSUFFICIENT_LIQUIDITY') {
88
- throw new InsufficientLiquidityError({
89
- availableIntents: errorData.availableIntents.map(parseTokenAmountsRecord),
90
- unfillable: parseTokenAmountsRecord(errorData.unfillable),
91
- traceId: errorData.traceId,
92
- statusCode: 422,
93
- });
94
- }
95
- this.parseError({
96
- response: {
97
- status: response.status,
98
- data: errorData,
99
- headers: {},
100
- },
63
+ body: JSON.stringify(body),
101
64
  });
102
- throw new OrchestratorError({ message: 'Unexpected error' });
65
+ return {
66
+ intents: json.intents.map(parseTokenAmountsRecord),
67
+ };
103
68
  }
104
- async submitIntent(signedIntentOpUnformatted, dryRun, policyContext) {
105
- const signedIntentOp = convertBigIntFields(signedIntentOpUnformatted);
106
- if (dryRun) {
107
- signedIntentOp.options = {
108
- dryRun: true,
109
- };
110
- }
111
- const body = { signedIntentOp };
69
+ async createIntent(request, policyContext) {
70
+ const body = convertBigIntFields(request);
112
71
  const headers = policyContext
113
72
  ? await this.getSubmitHeaders(policyContext.intentInput, policyContext.isSponsored)
114
73
  : await this.getHeaders();
115
- return await this.fetch(`${this.serverUrl}/intent-operations`, {
74
+ return await this.fetch(`${this.serverUrl}/intents`, {
116
75
  method: 'POST',
117
76
  headers,
118
77
  body: JSON.stringify(body),
119
78
  });
120
79
  }
121
- async getIntentOpStatus(intentId) {
122
- return await this.fetch(`${this.serverUrl}/intent-operation/${intentId.toString()}`, {
80
+ async getIntent(intentId) {
81
+ const json = await this.fetch(`${this.serverUrl}/intents/${intentId}`, {
123
82
  headers: await this.getHeaders(),
124
83
  });
84
+ return {
85
+ status: json.status,
86
+ claims: (json.claims ?? []).map((claim) => ({
87
+ depositId: claim.depositId !== undefined ? BigInt(claim.depositId) : 0n,
88
+ chainId: parseChainId(claim.chainId),
89
+ status: claim.status,
90
+ claimTimestamp: claim.claimTimestamp,
91
+ claimTransactionHash: claim.claimTransactionHash,
92
+ })),
93
+ destinationChainId: parseChainId(json.destinationChainId),
94
+ accountAddress: json.accountAddress,
95
+ fillTimestamp: json.fillTimestamp,
96
+ fillTransactionHash: json.fillTransactionHash,
97
+ };
125
98
  }
126
99
  async getHeaders() {
127
100
  const auth = await this.authProvider.getHeaders();
@@ -138,6 +111,7 @@ export class Orchestrator {
138
111
  return {
139
112
  'Content-Type': 'application/json',
140
113
  'x-sdk-version': SDK_VERSION,
114
+ 'x-api-version': API_VERSION,
141
115
  ...auth,
142
116
  ...this.extraHeaders,
143
117
  };
@@ -145,228 +119,152 @@ export class Orchestrator {
145
119
  async fetch(url, options) {
146
120
  const response = await fetch(url, options);
147
121
  if (!response.ok) {
148
- let errorData = {};
122
+ let body;
149
123
  try {
150
- errorData = await response.json();
124
+ body = await response.json();
151
125
  }
152
126
  catch {
153
- try {
154
- const text = await response.text();
155
- errorData = { message: text };
156
- }
157
- catch { }
127
+ body = {
128
+ code: 'INTERNAL_ERROR',
129
+ message: `Request failed with status ${response.status}`,
130
+ traceId: '',
131
+ };
158
132
  }
159
- const retryAfterHeader = response.headers?.get?.('retry-after') || undefined;
160
- this.parseError({
161
- response: {
162
- status: response.status,
163
- data: errorData,
164
- headers: {
165
- retryAfter: retryAfterHeader,
166
- },
167
- },
168
- });
133
+ const retryAfter = response.headers?.get?.('retry-after') ?? undefined;
134
+ throw parseErrorEnvelope(body, response.status, retryAfter ?? undefined);
169
135
  }
170
136
  return response.json();
171
137
  }
172
- parseError(error) {
173
- if (error.response) {
174
- const status = error.response.status;
175
- const { headers } = error.response;
176
- const { errors = [], traceId, message } = error.response.data || {};
177
- let errorType = 'Unknown';
178
- switch (status) {
179
- case 400:
180
- errorType = 'Bad Request';
181
- break;
182
- case 401:
183
- errorType = 'Unauthorized';
184
- break;
185
- case 403:
186
- errorType = 'Forbidden';
187
- break;
188
- case 404:
189
- errorType = 'Not Found';
190
- break;
191
- case 409:
192
- errorType = 'Conflict';
193
- break;
194
- case 422:
195
- errorType = 'Unprocessable Entity';
196
- break;
197
- case 429:
198
- errorType = 'Too Many Requests';
199
- break;
200
- case 500:
201
- errorType = 'Internal Server Error';
202
- break;
203
- case 503:
204
- errorType = 'Service Unavailable';
205
- break;
206
- default:
207
- errorType = 'Unknown';
208
- }
209
- const baseParams = {
210
- context: { traceId },
211
- errorType,
212
- traceId,
213
- statusCode: status,
214
- };
215
- if (status === 429) {
216
- const retryAfter = headers?.retryAfter;
217
- const context = { traceId, retryAfter };
218
- throw new RateLimitedError({
219
- ...baseParams,
220
- context,
221
- });
222
- }
223
- if (status === 503) {
224
- throw new ServiceUnavailableError(baseParams);
225
- }
226
- if (message) {
227
- this.parseErrorMessage(message, baseParams);
228
- }
229
- for (const err of errors) {
230
- const mergedParams = {
231
- ...baseParams,
232
- context: { ...err.context, traceId },
233
- };
234
- this.parseErrorMessage(err.message, mergedParams);
235
- }
236
- switch (status) {
237
- case 400:
238
- throw new BadRequestError({
239
- ...baseParams,
240
- context: { traceId, errors },
241
- message: message,
242
- });
243
- case 401:
244
- if (message === 'Authentication is required') {
245
- throw new AuthenticationRequiredError(baseParams);
246
- }
247
- throw new UnauthorizedError(baseParams);
248
- case 403:
249
- throw new ForbiddenError(baseParams);
250
- case 404:
251
- throw new ResourceNotFoundError(baseParams);
252
- case 409:
253
- throw new ConflictError(baseParams);
254
- case 500:
255
- if (errors && errors.length > 0) {
256
- const mergedParams = {
257
- ...baseParams,
258
- context: { ...errors[0].context, traceId },
259
- };
260
- throw new OrchestratorError({
261
- ...mergedParams,
262
- message: errors[0].message || 'Internal Server Error',
263
- });
264
- }
265
- throw new InternalServerError(baseParams);
266
- default:
267
- throw new OrchestratorError({
268
- ...baseParams,
269
- message: message || errorType,
270
- });
271
- }
272
- }
138
+ }
139
+ function parseTokenAmountsRecord(record) {
140
+ return Object.fromEntries(Object.entries(record).map(([addr, amount]) => [
141
+ addr,
142
+ BigInt(amount),
143
+ ]));
144
+ }
145
+ function parseChainId(value) {
146
+ if (typeof value === 'number')
147
+ return value;
148
+ if (typeof value === 'string') {
149
+ if (value.startsWith('eip155:'))
150
+ return fromCaip2(value);
151
+ return Number(value);
273
152
  }
274
- parseErrorMessage(message, errorParams) {
275
- if (message === 'Insufficient balance') {
276
- throw new InsufficientBalanceError(errorParams);
277
- }
278
- else if (message === 'Unsupported chain id' ||
279
- message === 'Unsupported chain ids') {
280
- throw new UnsupportedChainIdError(errorParams);
281
- }
282
- else if (message.startsWith('Unsupported chain ')) {
283
- const chainIdMatch = message.match(/Unsupported chain (\d+)/);
284
- if (chainIdMatch) {
285
- const chainId = parseInt(chainIdMatch[1], 10);
286
- throw new UnsupportedChainError(chainId, errorParams);
287
- }
288
- throw new UnsupportedChainIdError(errorParams);
289
- }
290
- else if (message.includes('Unsupported token') &&
291
- message.includes('for chain')) {
292
- const tokenMatch = message.match(/Unsupported token (\w+) for chain (\d+)/);
293
- if (tokenMatch) {
294
- const tokenSymbol = tokenMatch[1];
295
- const chainId = parseInt(tokenMatch[2], 10);
296
- throw new UnsupportedTokenError(tokenSymbol, chainId, errorParams);
297
- }
298
- throw new OrchestratorError({ message, ...errorParams });
299
- }
300
- else if (message === 'Unsupported token addresses') {
301
- // generic unsupported tokens without specific symbol/chain context
302
- throw new BadRequestError({ message, ...errorParams });
303
- }
304
- else if (message.includes('not supported on chain')) {
305
- const tokenMatch = message.match(/Token (.+) not supported on chain (\d+)/);
306
- if (tokenMatch) {
307
- const tokenAddress = tokenMatch[1];
308
- const chainId = parseInt(tokenMatch[2], 10);
309
- throw new TokenNotSupportedError(tokenAddress, chainId, errorParams);
153
+ throw new OrchestratorError({
154
+ message: `Invalid chain id value: ${String(value)}`,
155
+ });
156
+ }
157
+ function encodeIntentInput(input) {
158
+ const { account, destinationChainId, destinationExecutions, destinationGasUnits, tokenRequests, recipient, accountAccessList, options, preClaimExecutions, } = input;
159
+ const wire = {
160
+ account,
161
+ destinationChainId: toCaip2(destinationChainId),
162
+ destinationExecutions,
163
+ tokenRequests,
164
+ recipient,
165
+ accountAccessList: encodeAccountAccessList(accountAccessList),
166
+ options: encodeOptions(options),
167
+ };
168
+ if (destinationGasUnits !== undefined) {
169
+ wire.destinationGasLimit = destinationGasUnits;
170
+ }
171
+ if (preClaimExecutions) {
172
+ wire.preClaimExecutions = Object.fromEntries(Object.entries(preClaimExecutions).map(([chainId, ops]) => [
173
+ toCaip2(Number(chainId)),
174
+ ops,
175
+ ]));
176
+ }
177
+ return convertBigIntFields(wire);
178
+ }
179
+ function encodeAccountAccessList(list) {
180
+ if (!list)
181
+ return undefined;
182
+ const out = {};
183
+ if ('chainIds' in list && list.chainIds) {
184
+ out.chainIds = list.chainIds.map(toCaip2);
185
+ }
186
+ if ('tokens' in list && list.tokens) {
187
+ out.tokens = list.tokens;
188
+ }
189
+ if ('chainTokens' in list && list.chainTokens) {
190
+ out.chainTokens = Object.fromEntries(Object.entries(list.chainTokens).map(([chainId, tokens]) => [
191
+ toCaip2(Number(chainId)),
192
+ tokens,
193
+ ]));
194
+ }
195
+ if ('chainTokenAmounts' in list && list.chainTokenAmounts) {
196
+ out.chainTokenAmounts = Object.fromEntries(Object.entries(list.chainTokenAmounts).map(([chainId, tokens]) => [
197
+ toCaip2(Number(chainId)),
198
+ tokens,
199
+ ]));
200
+ }
201
+ return out;
202
+ }
203
+ function encodeAuxiliaryFunds(funds) {
204
+ return Object.fromEntries(Object.entries(funds).map(([chainId, balances]) => [
205
+ toCaip2(Number(chainId)),
206
+ balances,
207
+ ]));
208
+ }
209
+ function encodeOptions(options) {
210
+ if (!options.auxiliaryFunds)
211
+ return options;
212
+ return {
213
+ ...options,
214
+ auxiliaryFunds: encodeAuxiliaryFunds(options.auxiliaryFunds),
215
+ };
216
+ }
217
+ function decodeQuoteResponse(json) {
218
+ const routes = (json.routes ?? []);
219
+ return { routes: routes.map(decodeQuote) };
220
+ }
221
+ function decodeQuote(route) {
222
+ return {
223
+ intentId: route.intentId,
224
+ expiresAt: route.expiresAt,
225
+ estimatedFillTime: route.estimatedFillTime,
226
+ settlementLayer: route.settlementLayer,
227
+ signData: route.signData,
228
+ cost: decodeCost(route.cost),
229
+ tokenRequirements: route.tokenRequirements
230
+ ? decodeTokenRequirements(route.tokenRequirements)
231
+ : undefined,
232
+ };
233
+ }
234
+ function decodeCost(cost) {
235
+ return {
236
+ input: cost.input.map(decodeCostTokenEntry),
237
+ output: cost.output.map(decodeCostTokenEntry),
238
+ feeToken: cost.feeToken
239
+ ? {
240
+ chainId: parseChainId(cost.feeToken.chainId),
241
+ tokenAddress: cost.feeToken.tokenAddress,
310
242
  }
311
- throw new OrchestratorError({ message, ...errorParams });
312
- }
313
- else if (message === 'Authentication is required') {
314
- throw new AuthenticationRequiredError(errorParams);
315
- }
316
- else if (message === 'Invalid API key') {
317
- throw new InvalidApiKeyError(errorParams);
318
- }
319
- else if (message === 'Insufficient permissions') {
320
- throw new ForbiddenError(errorParams);
321
- }
322
- else if (message === 'Invalid bundle signature') {
323
- throw new InvalidIntentSignatureError(errorParams);
324
- }
325
- else if (message === 'Invalid checksum signature') {
326
- throw new InvalidIntentSignatureError(errorParams);
327
- }
328
- else if (message === 'Only one target token amount can be unset' ||
329
- message === 'Only one max-out transfer is allowed') {
330
- throw new OnlyOneTargetTokenAmountCanBeUnsetError(errorParams);
331
- }
332
- else if (message === 'No valid settlement plan found for the given transfers' ||
333
- message === 'No valid transfers sent for settlement quotes' ||
334
- message === 'No Path Found') {
335
- throw new NoPathFoundError(errorParams);
336
- }
337
- else if (message === 'Emissary is not enabled' ||
338
- message === 'Emissary is not the expected address') {
339
- throw new ForbiddenError(errorParams);
340
- }
341
- else if (message.includes('No such intent with nonce') ||
342
- message === 'Order bundle not found') {
343
- throw new IntentNotFoundError(errorParams);
344
- }
345
- else if (message === 'Could not retrieve a valid quote from any aggregator') {
346
- throw new NoPathFoundError(errorParams);
347
- }
348
- else if (message === 'No aggregators available for swap') {
349
- throw new InternalServerError(errorParams);
350
- }
351
- else if (message === 'entity.parse.failed' ||
352
- message === 'entity.too.large' ||
353
- message === 'encoding.unsupported') {
354
- throw new BodyParserError({ message, ...errorParams });
355
- }
356
- else if (message === 'Bundle simulation failed') {
357
- const simulations = errorParams.context.error.simulations;
358
- const { traceId, errorType, statusCode, context } = errorParams;
359
- throw new SimulationFailedError({
360
- message,
361
- context,
362
- errorType,
363
- traceId,
364
- statusCode,
365
- simulations,
366
- });
367
- }
368
- else {
369
- throw new OrchestratorError({ message, ...errorParams });
243
+ : undefined,
244
+ fees: cost.fees,
245
+ };
246
+ }
247
+ function decodeCostTokenEntry(entry) {
248
+ return {
249
+ chainId: parseChainId(entry.chainId),
250
+ tokenAddress: entry.tokenAddress,
251
+ symbol: entry.symbol,
252
+ decimals: entry.decimals,
253
+ price: entry.price,
254
+ amount: BigInt(entry.amount),
255
+ };
256
+ }
257
+ function decodeTokenRequirements(wire) {
258
+ const out = {};
259
+ for (const [chainKey, tokens] of Object.entries(wire)) {
260
+ const chainId = parseChainId(chainKey);
261
+ out[chainId] = {};
262
+ for (const [tokenAddress, requirement] of Object.entries(tokens)) {
263
+ out[chainId][tokenAddress] = {
264
+ ...requirement,
265
+ amount: BigInt(requirement.amount),
266
+ };
370
267
  }
371
268
  }
269
+ return out;
372
270
  }
@@ -1,6 +1,6 @@
1
1
  declare const PROD_ORCHESTRATOR_URL = "https://v1.orchestrator.rhinestone.dev";
2
2
  declare const RHINESTONE_SPOKE_POOL_ADDRESS = "0x000000000060f6e853447881951574cdd0663530";
3
- declare const SDK_VERSION = "2.0.0-beta.0";
4
- declare const API_VERSION = "2026-01.alps";
3
+ declare const SDK_VERSION = "2.0.0-beta.2";
4
+ declare const API_VERSION = "2026-04.blanc";
5
5
  export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION, API_VERSION, };
6
6
  //# 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,6BAA6B,+CACW,CAAA;AAE9C,QAAA,MAAM,WAAW,iBAAiB,CAAA;AAClC,QAAA,MAAM,WAAW,iBAAiB,CAAA;AAElC,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,WAAW,EACX,WAAW,GACZ,CAAA"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../orchestrator/consts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,qBAAqB,2CAA2C,CAAA;AACtE,QAAA,MAAM,6BAA6B,+CACW,CAAA;AAE9C,QAAA,MAAM,WAAW,iBAAiB,CAAA;AAClC,QAAA,MAAM,WAAW,kBAAkB,CAAA;AAEnC,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,WAAW,EACX,WAAW,GACZ,CAAA"}
@@ -1,5 +1,5 @@
1
1
  const PROD_ORCHESTRATOR_URL = 'https://v1.orchestrator.rhinestone.dev';
2
2
  const RHINESTONE_SPOKE_POOL_ADDRESS = '0x000000000060f6e853447881951574cdd0663530';
3
- const SDK_VERSION = '2.0.0-beta.0';
4
- const API_VERSION = '2026-01.alps';
3
+ const SDK_VERSION = '2.0.0-beta.2';
4
+ const API_VERSION = '2026-04.blanc';
5
5
  export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION, API_VERSION, };