@rhinestone/sdk 1.5.1 → 2.0.0-beta.1

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