@rhinestone/sdk 0.3.0 → 0.4.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 (103) hide show
  1. package/dist/{accounts → src/accounts}/index.d.ts +67 -67
  2. package/dist/{accounts → src/accounts}/index.d.ts.map +1 -1
  3. package/dist/{accounts → src/accounts}/index.js +44 -40
  4. package/dist/{accounts → src/accounts}/nexus.d.ts +93 -93
  5. package/dist/{accounts → src/accounts}/nexus.d.ts.map +1 -1
  6. package/dist/{accounts → src/accounts}/nexus.js +7 -7
  7. package/dist/src/accounts/safe.d.ts +15524 -0
  8. package/dist/src/accounts/safe.d.ts.map +1 -0
  9. package/dist/{accounts → src/accounts}/safe.js +84 -9
  10. package/dist/{accounts → src/accounts}/utils.d.ts +1 -1
  11. package/dist/src/accounts/utils.d.ts.map +1 -0
  12. package/dist/{execution → src/execution}/index.d.ts +1 -1
  13. package/dist/src/execution/index.d.ts.map +1 -0
  14. package/dist/{execution → src/execution}/index.js +7 -8
  15. package/dist/{execution → src/execution}/smart-session.d.ts +2 -3
  16. package/dist/src/execution/smart-session.d.ts.map +1 -0
  17. package/dist/{execution → src/execution}/smart-session.js +4 -6
  18. package/dist/{index.d.ts → src/index.d.ts} +10 -3
  19. package/dist/src/index.d.ts.map +1 -0
  20. package/dist/{index.js → src/index.js} +21 -1
  21. package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
  22. package/dist/src/modules/common.d.ts.map +1 -0
  23. package/dist/{modules → src/modules}/index.d.ts +1 -1
  24. package/dist/src/modules/index.d.ts.map +1 -0
  25. package/dist/{modules → src/modules}/index.js +16 -2
  26. package/dist/src/modules/omni-account.d.ts.map +1 -0
  27. package/dist/src/modules/validators/core.d.ts +23 -0
  28. package/dist/src/modules/validators/core.d.ts.map +1 -0
  29. package/dist/src/modules/validators/core.js +112 -0
  30. package/dist/src/modules/validators/index.d.ts +4 -0
  31. package/dist/src/modules/validators/index.d.ts.map +1 -0
  32. package/dist/src/modules/validators/index.js +3 -0
  33. package/dist/{modules/validators.d.ts → src/modules/validators/smart-sessions.d.ts} +4 -6
  34. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
  35. package/dist/{modules/validators.js → src/modules/validators/smart-sessions.js} +11 -116
  36. package/dist/{orchestrator → src/orchestrator}/client.d.ts +2 -1
  37. package/dist/src/orchestrator/client.d.ts.map +1 -0
  38. package/dist/{orchestrator → src/orchestrator}/client.js +19 -2
  39. package/dist/src/orchestrator/consts.d.ts.map +1 -0
  40. package/dist/src/orchestrator/error.d.ts.map +1 -0
  41. package/dist/src/orchestrator/index.d.ts +11 -0
  42. package/dist/src/orchestrator/index.d.ts.map +1 -0
  43. package/dist/src/orchestrator/index.js +10 -0
  44. package/dist/src/orchestrator/registry.d.ts.map +1 -0
  45. package/dist/{orchestrator → src/orchestrator}/registry.js +1 -1
  46. package/dist/{orchestrator → src/orchestrator}/types.d.ts +50 -2
  47. package/dist/src/orchestrator/types.d.ts.map +1 -0
  48. package/dist/{orchestrator → src/orchestrator}/utils.d.ts +6 -2
  49. package/dist/src/orchestrator/utils.d.ts.map +1 -0
  50. package/dist/{orchestrator → src/orchestrator}/utils.js +76 -2
  51. package/dist/{types.d.ts → src/types.d.ts} +7 -6
  52. package/dist/src/types.d.ts.map +1 -0
  53. package/dist/test/modules/validators/smart-sessions.test.d.ts +2 -0
  54. package/dist/test/modules/validators/smart-sessions.test.d.ts.map +1 -0
  55. package/dist/test/modules/validators/smart-sessions.test.js +20 -0
  56. package/package.json +2 -2
  57. package/dist/accounts/safe.d.ts +0 -15
  58. package/dist/accounts/safe.d.ts.map +0 -1
  59. package/dist/accounts/utils.d.ts.map +0 -1
  60. package/dist/examples/abi/weth.d.ts +0 -214
  61. package/dist/examples/abi/weth.d.ts.map +0 -1
  62. package/dist/examples/abi/weth.js +0 -279
  63. package/dist/examples/cross-chain-ss.d.ts +0 -1
  64. package/dist/examples/cross-chain-ss.d.ts.map +0 -1
  65. package/dist/examples/cross-chain-ss.js +0 -171
  66. package/dist/examples/omni-account.d.ts +0 -1
  67. package/dist/examples/omni-account.d.ts.map +0 -1
  68. package/dist/examples/omni-account.js +0 -169
  69. package/dist/examples/smart-sessions.d.ts +0 -1
  70. package/dist/examples/smart-sessions.d.ts.map +0 -1
  71. package/dist/examples/smart-sessions.js +0 -216
  72. package/dist/execution/index.d.ts.map +0 -1
  73. package/dist/execution/smart-session.d.ts.map +0 -1
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
  76. package/dist/modules/common.d.ts.map +0 -1
  77. package/dist/modules/index.d.ts.map +0 -1
  78. package/dist/modules/omni-account.d.ts.map +0 -1
  79. package/dist/modules/validators.d.ts.map +0 -1
  80. package/dist/orchestrator/client.d.ts.map +0 -1
  81. package/dist/orchestrator/consts.d.ts.map +0 -1
  82. package/dist/orchestrator/error.d.ts.map +0 -1
  83. package/dist/orchestrator/index.d.ts +0 -9
  84. package/dist/orchestrator/index.d.ts.map +0 -1
  85. package/dist/orchestrator/index.js +0 -10
  86. package/dist/orchestrator/registry.d.ts.map +0 -1
  87. package/dist/orchestrator/types.d.ts.map +0 -1
  88. package/dist/orchestrator/utils.d.ts.map +0 -1
  89. package/dist/types.d.ts.map +0 -1
  90. package/dist/{accounts → src/accounts}/utils.js +1 -1
  91. /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
  92. /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
  93. /package/dist/{modules → src/modules}/common.d.ts +0 -0
  94. /package/dist/{modules → src/modules}/common.js +0 -0
  95. /package/dist/{modules → src/modules}/omni-account.d.ts +0 -0
  96. /package/dist/{modules → src/modules}/omni-account.js +0 -0
  97. /package/dist/{orchestrator → src/orchestrator}/consts.d.ts +0 -0
  98. /package/dist/{orchestrator → src/orchestrator}/consts.js +0 -0
  99. /package/dist/{orchestrator → src/orchestrator}/error.d.ts +0 -0
  100. /package/dist/{orchestrator → src/orchestrator}/error.js +0 -0
  101. /package/dist/{orchestrator → src/orchestrator}/registry.d.ts +0 -0
  102. /package/dist/{orchestrator → src/orchestrator}/types.js +0 -0
  103. /package/dist/{types.js → src/types.js} +0 -0
@@ -1,10 +1,9 @@
1
- import { bytesToHex, concat, createPublicClient, encodeAbiParameters, encodeFunctionData, encodePacked, hexToBytes, http, keccak256, parseAbi, toHex, zeroHash, isHex, padHex, } from 'viem';
2
- import { RHINESTONE_SPOKE_POOL_ADDRESS, getWethAddress } from '../orchestrator';
3
- import { MODULE_TYPE_ID_VALIDATOR } from './common';
4
- import { enableSessionsAbi } from './abi/smart-sessions';
5
- import { HOOK_ADDRESS } from './omni-account';
6
- const OWNABLE_VALIDATOR_ADDRESS = '0x2483DA3A338895199E5e538530213157e931Bf06';
7
- const WEBAUTHN_VALIDATOR_ADDRESS = '0x2f167e55d42584f65e2e30a748f41ee75a311414';
1
+ import { createPublicClient, encodeAbiParameters, encodeFunctionData, encodePacked, http, isHex, keccak256, padHex, parseAbi, toHex, zeroHash, } from 'viem';
2
+ import { getWethAddress, RHINESTONE_SPOKE_POOL_ADDRESS, } from '../../orchestrator';
3
+ import { enableSessionsAbi } from '../abi/smart-sessions';
4
+ import { MODULE_TYPE_ID_VALIDATOR } from '../common';
5
+ import { HOOK_ADDRESS } from '../omni-account';
6
+ import { getValidator } from './core';
8
7
  const SMART_SESSIONS_VALIDATOR_ADDRESS = '0x00000000002b0ecfbd0496ee71e01257da0e37de';
9
8
  const SMART_SESSION_MODE_USE = '0x00';
10
9
  const SMART_SESSION_MODE_ENABLE = '0x01';
@@ -24,11 +23,6 @@ const ACTION_CONDITION_GREATER_THAN_OR_EQUAL = 3;
24
23
  const ACTION_CONDITION_LESS_THAN_OR_EQUAL = 4;
25
24
  const ACTION_CONDITION_NOT_EQUAL = 5;
26
25
  const ACTION_CONDITION_IN_RANGE = 6;
27
- const ECDSA_MOCK_SIGNATURE = '0x81d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b';
28
- const WEBAUTHN_MOCK_SIGNATURE = '0x00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db15e9015d280cb19527881c625fee43fd3a405d5b0d199a8c8e6589a7381209e40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000';
29
- function getOwnerValidator(config) {
30
- return getValidator(config.owners);
31
- }
32
26
  async function getEnableSessionCall(chain, session) {
33
27
  const { appDomainSeparator, contentsType } = await getSessionAllowedERC7739Content(chain);
34
28
  const allowedERC7739Content = [
@@ -144,20 +138,6 @@ function getSmartSessionValidator(config) {
144
138
  type: MODULE_TYPE_ID_VALIDATOR,
145
139
  };
146
140
  }
147
- function getValidator(owners) {
148
- switch (owners.type) {
149
- case 'ecdsa':
150
- return getOwnableValidator({
151
- threshold: owners.threshold ?? 1,
152
- owners: owners.accounts.map((account) => account.address),
153
- });
154
- case 'passkey':
155
- return getWebAuthnValidator({
156
- pubKey: owners.account.publicKey,
157
- authenticatorId: owners.account.id,
158
- });
159
- }
160
- }
161
141
  function getPolicyData(policy) {
162
142
  switch (policy.type) {
163
143
  case 'sudo':
@@ -289,7 +269,10 @@ function getPolicyData(policy) {
289
269
  case 'time-frame': {
290
270
  return {
291
271
  policy: TIME_FRAME_POLICY_ADDRESS,
292
- initData: encodePacked(['uint128', 'uint128'], [BigInt(policy.validUntil), BigInt(policy.validAfter)]),
272
+ initData: encodePacked(['uint128', 'uint128'], [
273
+ BigInt(policy.validUntil) / 1000n,
274
+ BigInt(policy.validAfter) / 1000n,
275
+ ]),
293
276
  };
294
277
  }
295
278
  case 'usage-limit': {
@@ -309,83 +292,6 @@ function getPolicyData(policy) {
309
292
  function createFixedArray(length, getValue) {
310
293
  return Array.from({ length }, (_, i) => getValue(i));
311
294
  }
312
- function getOwnableValidator({ threshold, owners, }) {
313
- return {
314
- address: OWNABLE_VALIDATOR_ADDRESS,
315
- initData: encodeAbiParameters([
316
- { name: 'threshold', type: 'uint256' },
317
- { name: 'owners', type: 'address[]' },
318
- ], [
319
- BigInt(threshold),
320
- owners.map((owner) => owner.toLowerCase()).sort(),
321
- ]),
322
- deInitData: '0x',
323
- additionalContext: '0x',
324
- type: MODULE_TYPE_ID_VALIDATOR,
325
- };
326
- }
327
- function getWebAuthnValidator(webAuthnCredential) {
328
- let pubKeyX;
329
- let pubKeyY;
330
- // Distinguish between PublicKey and Hex / byte encoded public key
331
- if (typeof webAuthnCredential.pubKey === 'string' ||
332
- webAuthnCredential.pubKey instanceof Uint8Array) {
333
- // It's a P256Credential
334
- const { x, y, prefix } = parsePublicKey(webAuthnCredential.pubKey);
335
- pubKeyX = x;
336
- pubKeyY = y;
337
- if (prefix && prefix !== 4) {
338
- throw new Error('Only uncompressed public keys are supported');
339
- }
340
- }
341
- else {
342
- // It's already a PublicKey
343
- pubKeyX = webAuthnCredential.pubKey.x;
344
- pubKeyY = webAuthnCredential.pubKey.y;
345
- }
346
- return {
347
- address: WEBAUTHN_VALIDATOR_ADDRESS,
348
- initData: encodeAbiParameters([
349
- {
350
- components: [
351
- {
352
- name: 'pubKeyX',
353
- type: 'uint256',
354
- },
355
- {
356
- name: 'pubKeyY',
357
- type: 'uint256',
358
- },
359
- ],
360
- type: 'tuple',
361
- },
362
- {
363
- type: 'bytes32',
364
- name: 'authenticatorIdHash',
365
- },
366
- ], [
367
- {
368
- pubKeyX,
369
- pubKeyY,
370
- },
371
- keccak256(toHex(webAuthnCredential.authenticatorId)),
372
- ]),
373
- deInitData: '0x',
374
- additionalContext: '0x',
375
- type: MODULE_TYPE_ID_VALIDATOR,
376
- };
377
- }
378
- function parsePublicKey(publicKey) {
379
- const bytes = typeof publicKey === 'string' ? hexToBytes(publicKey) : publicKey;
380
- const offset = bytes.length === 65 ? 1 : 0;
381
- const x = bytes.slice(offset, 32 + offset);
382
- const y = bytes.slice(32 + offset, 64 + offset);
383
- return {
384
- prefix: bytes.length === 65 ? bytes[0] : undefined,
385
- x: BigInt(bytesToHex(x)),
386
- y: BigInt(bytesToHex(y)),
387
- };
388
- }
389
295
  async function isSessionEnabled(client, address, permissionId) {
390
296
  return await client.readContract({
391
297
  address: SMART_SESSIONS_VALIDATOR_ADDRESS,
@@ -451,17 +357,6 @@ function getPermissionId(session) {
451
357
  session.salt ?? zeroHash,
452
358
  ]));
453
359
  }
454
- function getMockSinature(ownerSet) {
455
- switch (ownerSet.type) {
456
- case 'ecdsa': {
457
- const owners = ownerSet.accounts.map((account) => account.address);
458
- const signatures = owners.map(() => ECDSA_MOCK_SIGNATURE);
459
- return concat(signatures);
460
- }
461
- case 'passkey':
462
- return WEBAUTHN_MOCK_SIGNATURE;
463
- }
464
- }
465
360
  async function getAccountEIP712Domain(client, account) {
466
361
  const data = await client.readContract({
467
362
  address: account,
@@ -515,4 +410,4 @@ async function getAccountEIP712Domain(client, account) {
515
410
  salt: data[5],
516
411
  };
517
412
  }
518
- export { SMART_SESSION_MODE_USE, SMART_SESSION_MODE_ENABLE, SMART_SESSIONS_VALIDATOR_ADDRESS, getOwnerValidator, getSmartSessionValidator, getEnableSessionCall, encodeSmartSessionSignature, getPermissionId, getMockSinature, getAccountEIP712Domain, isSessionEnabled, getSessionAllowedERC7739Content, };
413
+ export { SMART_SESSION_MODE_USE, SMART_SESSION_MODE_ENABLE, SMART_SESSIONS_VALIDATOR_ADDRESS, getSmartSessionValidator, getEnableSessionCall, encodeSmartSessionSignature, getPermissionId, getAccountEIP712Domain, isSessionEnabled, getSessionAllowedERC7739Content, };
@@ -1,6 +1,6 @@
1
1
  import { Address, Hex } from 'viem';
2
2
  import { UserOperation } from 'viem/account-abstraction';
3
- import { type UserTokenBalance, type MetaIntent, type SignedMultiChainCompact, type PostOrderBundleResult, type BundleResult, type BundleEvent, type OrderPath } from './types';
3
+ import { type BundleEvent, type BundleResult, type MetaIntent, type OrderCostResult, type OrderFeeInput, type OrderPath, type PostOrderBundleResult, type SignedMultiChainCompact, type UserTokenBalance } from './types';
4
4
  export declare class Orchestrator {
5
5
  private serverUrl;
6
6
  private apiKey;
@@ -11,6 +11,7 @@ export declare class Orchestrator {
11
11
  [chainId: number]: Address[];
12
12
  };
13
13
  }): Promise<UserTokenBalance[]>;
14
+ getIntentCost(intent: MetaIntent | OrderFeeInput, userAddress: Address): Promise<OrderCostResult>;
14
15
  getOrderPath(intent: MetaIntent, userAddress: Address): Promise<OrderPath>;
15
16
  postSignedOrderBundle(signedOrderBundles: {
16
17
  signedOrderBundle: SignedMultiChainCompact;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../orchestrator/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAU,GAAG,EAAE,MAAM,MAAM,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAGxD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAA;AAShB,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,MAAM,CAAQ;gBAEV,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKvC,YAAY,CAChB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;QACnB,MAAM,CAAC,EAAE;YACP,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAAA;SAC7B,CAAA;KACF,GACA,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAwCxB,aAAa,CACjB,MAAM,EAAE,UAAU,GAAG,aAAa,EAClC,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,eAAe,CAAC;IAqBrB,YAAY,CAChB,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC;IAgCf,qBAAqB,CACzB,kBAAkB,EAAE;QAClB,iBAAiB,EAAE,uBAAuB,CAAA;QAC1C,QAAQ,CAAC,EAAE,GAAG,CAAA;QACd,MAAM,CAAC,EAAE,aAAa,CAAA;KACvB,EAAE,GACF,OAAO,CAAC,qBAAqB,CAAC;IA2C3B,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAyBxD,iBAAiB,CACrB,KAAK,GAAE,MAAW,EAClB,MAAM,GAAE,MAAU,GACjB,OAAO,CAAC;QAAE,cAAc,EAAE,WAAW,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAuBlE,OAAO,CAAC,UAAU;CA6DnB"}
@@ -1,7 +1,7 @@
1
1
  import axios from 'axios';
2
2
  import { concat } from 'viem';
3
- import { convertBigIntFields, parseCompactResponse, parsePendingBundleEvent, } from './utils';
4
3
  import { OrchestratorError } from './error';
4
+ import { convertBigIntFields, parseCompactResponse, parseOrderCost, parseOrderCostResult, parsePendingBundleEvent, } from './utils';
5
5
  export class Orchestrator {
6
6
  serverUrl;
7
7
  apiKey;
@@ -42,6 +42,22 @@ export class Orchestrator {
42
42
  throw new Error('Failed to get portfolio');
43
43
  }
44
44
  }
45
+ async getIntentCost(intent, userAddress) {
46
+ try {
47
+ const response = await axios.post(`${this.serverUrl}/accounts/${userAddress}/bundles/cost`, {
48
+ ...convertBigIntFields(intent),
49
+ }, {
50
+ headers: {
51
+ 'x-api-key': this.apiKey,
52
+ },
53
+ });
54
+ return parseOrderCostResult(response.data);
55
+ }
56
+ catch (error) {
57
+ this.parseError(error);
58
+ throw new Error(error);
59
+ }
60
+ }
45
61
  async getOrderPath(intent, userAddress) {
46
62
  try {
47
63
  const response = await axios.post(`${this.serverUrl}/accounts/${userAddress}/bundles/path`, {
@@ -60,6 +76,7 @@ export class Orchestrator {
60
76
  value: BigInt(exec.value),
61
77
  };
62
78
  }),
79
+ intentCost: parseOrderCost(orderPath.intentCost),
63
80
  };
64
81
  });
65
82
  }
@@ -196,7 +213,7 @@ export class Orchestrator {
196
213
  message: error.response.data.errors[0].message,
197
214
  context,
198
215
  errorType,
199
- traceId: context['traceId'],
216
+ traceId: context.traceId,
200
217
  });
201
218
  }
202
219
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../orchestrator/consts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,gBAAgB,wCAAwC,CAAA;AAC9D,QAAA,MAAM,6BAA6B,+CACW,CAAA;AAE9C,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../orchestrator/error.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;gBAErB,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;IAQD,IAAI,OAAO,WAEV;IAED,IAAI,OAAO,QAEV;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,OAAO,WAEV;CACF"}
@@ -0,0 +1,11 @@
1
+ import { Orchestrator } from './client';
2
+ import { RHINESTONE_SPOKE_POOL_ADDRESS } from './consts';
3
+ import { OrchestratorError } from './error';
4
+ import { getTokenBalanceSlot, getWethAddress } from './registry';
5
+ import type { BundleResult, MetaIntent, OrderPath, SignedMultiChainCompact } from './types';
6
+ import { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING } from './types';
7
+ import { getEmptyUserOp, getOrderBundleHash } from './utils';
8
+ declare function getOrchestrator(apiKey: string, orchestratorUrl?: string): Orchestrator;
9
+ export type { BundleResult, MetaIntent, OrderPath, SignedMultiChainCompact };
10
+ export { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, OrchestratorError, getOrchestrator, getOrderBundleHash, getEmptyUserOp, getWethAddress, getTokenBalanceSlot, };
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAoB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5D,iBAAS,eAAe,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM,GACvB,YAAY,CAEd;AAED,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAA;AAC5E,OAAO,EACL,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,6BAA6B,EAC7B,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,mBAAmB,GACpB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Orchestrator } from './client';
2
+ import { ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS } from './consts';
3
+ import { OrchestratorError } from './error';
4
+ import { getTokenBalanceSlot, getWethAddress } from './registry';
5
+ import { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, } from './types';
6
+ import { getEmptyUserOp, getOrderBundleHash } from './utils';
7
+ function getOrchestrator(apiKey, orchestratorUrl) {
8
+ return new Orchestrator(orchestratorUrl ?? ORCHESTRATOR_URL, apiKey);
9
+ }
10
+ export { BUNDLE_STATUS_FAILED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_PENDING, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, OrchestratorError, getOrchestrator, getOrderBundleHash, getEmptyUserOp, getWethAddress, getTokenBalanceSlot, };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAe,MAAM,MAAM,CAAA;AAclD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,0UAoCnC;AAED,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,GACpB,MAAM,GAAG,IAAI,CAqJf;AAED,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { zeroAddress } from 'viem';
2
- import { base, mainnet, arbitrum, optimism, polygon, sepolia, baseSepolia, arbitrumSepolia, optimismSepolia, polygonAmoy, } from 'viem/chains';
2
+ import { arbitrum, arbitrumSepolia, base, baseSepolia, mainnet, optimism, optimismSepolia, polygon, polygonAmoy, sepolia, } from 'viem/chains';
3
3
  function getWethAddress(chain) {
4
4
  switch (chain.id) {
5
5
  case mainnet.id: {
@@ -1,6 +1,6 @@
1
1
  import { Address, Hex } from 'viem';
2
2
  import type { UserOperation } from 'viem/account-abstraction';
3
- import { sepolia, baseSepolia, arbitrumSepolia, optimismSepolia, polygonAmoy, mainnet, base, arbitrum, optimism, polygon } from 'viem/chains';
3
+ import { arbitrum, arbitrumSepolia, base, baseSepolia, mainnet, optimism, optimismSepolia, polygon, polygonAmoy, sepolia } from 'viem/chains';
4
4
  type SupportedTestnet = typeof sepolia.id | typeof baseSepolia.id | typeof arbitrumSepolia.id | typeof optimismSepolia.id | typeof polygonAmoy.id;
5
5
  type SupportedMainnet = typeof mainnet.id | typeof base.id | typeof arbitrum.id | typeof optimism.id | typeof polygon.id;
6
6
  type SupportedChain = SupportedMainnet | SupportedTestnet;
@@ -84,6 +84,7 @@ interface MetaIntentBase {
84
84
  type OrderPath = {
85
85
  orderBundle: MultiChainCompact;
86
86
  injectedExecutions: Execution[];
87
+ intentCost: OrderCost;
87
88
  }[];
88
89
  type MetaIntentEmpty = MetaIntentBase & WithoutOperation;
89
90
  type MetaIntentWithUserOp = MetaIntentBase & WithUserOp;
@@ -151,6 +152,53 @@ interface UserTokenBalance {
151
152
  balance: bigint;
152
153
  }[];
153
154
  }
155
+ interface UserChainBalances {
156
+ [chainId: number]: {
157
+ [tokenAddress: Address]: bigint;
158
+ };
159
+ }
160
+ interface OrderFeeInput {
161
+ targetChainId: number;
162
+ targetGasUnits?: bigint;
163
+ userOp?: {
164
+ callGasLimit: bigint;
165
+ verificationGasLimit: bigint;
166
+ preVerificationGas: bigint;
167
+ };
168
+ tokenTransfers: {
169
+ tokenAddress: Address;
170
+ amount?: bigint;
171
+ }[];
172
+ accountAccessList?: {
173
+ chainId: number;
174
+ tokenAddress: Address;
175
+ }[];
176
+ }
177
+ interface TokenFulfillmentStatus {
178
+ hasFulfilled: boolean;
179
+ tokenAddress: Address;
180
+ amountSpent: bigint;
181
+ targetAmount: bigint;
182
+ fee: bigint;
183
+ }
184
+ interface OrderCost {
185
+ hasFulfilledAll: true;
186
+ tokensSpent: UserChainBalances;
187
+ tokensReceived: TokenFulfillmentStatus[];
188
+ }
189
+ interface InsufficientBalanceResult {
190
+ hasFulfilledAll: false;
191
+ tokenShortfall: {
192
+ tokenAddress: Address;
193
+ targetAmount: bigint;
194
+ amountSpent: bigint;
195
+ fee: bigint;
196
+ tokenSymbol: string;
197
+ tokenDecimals: number;
198
+ }[];
199
+ totalTokenShortfallInUSD: bigint;
200
+ }
201
+ type OrderCostResult = OrderCost | InsufficientBalanceResult;
154
202
  type TokenArrays6909 = readonly (readonly [bigint, bigint])[];
155
203
  declare const BUNDLE_STATUS_PENDING = "PENDING";
156
204
  declare const BUNDLE_STATUS_FAILED = "FAILED";
@@ -158,6 +206,6 @@ declare const BUNDLE_STATUS_EXPIRED = "EXPIRED";
158
206
  declare const BUNDLE_STATUS_PARTIALLY_COMPLETED = "PARTIALLY_COMPLETED";
159
207
  declare const BUNDLE_STATUS_COMPLETED = "COMPLETED";
160
208
  declare const BUNDLE_STATUS_UNKNOWN = "UNKNOWN";
161
- export type { SupportedChain, BundleStatus, PostOrderBundleResult, MetaIntentEmpty, MetaIntentWithUserOp, MetaIntentWithExecutions, MetaIntent, TokenArrays6909, Execution, BundleResult, BundleEvent, Witness, Segment, MultiChainCompact, SignedMultiChainCompact, UserTokenBalance, OrderPath, };
209
+ export type { SupportedChain, BundleStatus, PostOrderBundleResult, MetaIntentEmpty, MetaIntentWithUserOp, MetaIntentWithExecutions, MetaIntent, TokenArrays6909, Execution, BundleResult, BundleEvent, Witness, Segment, MultiChainCompact, SignedMultiChainCompact, UserTokenBalance, OrderPath, UserChainBalances, OrderFeeInput, TokenFulfillmentStatus, OrderCost, InsufficientBalanceResult, OrderCostResult, };
162
210
  export { BUNDLE_STATUS_PENDING, BUNDLE_STATUS_FAILED, BUNDLE_STATUS_EXPIRED, BUNDLE_STATUS_PARTIALLY_COMPLETED, BUNDLE_STATUS_COMPLETED, BUNDLE_STATUS_UNKNOWN, };
163
211
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../orchestrator/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EACL,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,WAAW,EACX,OAAO,EACP,QAAQ,EACR,eAAe,EACf,OAAO,EACP,WAAW,EACX,OAAO,EACR,MAAM,aAAa,CAAA;AAEpB,KAAK,gBAAgB,GACjB,OAAO,OAAO,CAAC,EAAE,GACjB,OAAO,WAAW,CAAC,EAAE,GACrB,OAAO,eAAe,CAAC,EAAE,GACzB,OAAO,eAAe,CAAC,EAAE,GACzB,OAAO,WAAW,CAAC,EAAE,CAAA;AACzB,KAAK,gBAAgB,GACjB,OAAO,OAAO,CAAC,EAAE,GACjB,OAAO,IAAI,CAAC,EAAE,GACd,OAAO,QAAQ,CAAC,EAAE,GAClB,OAA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AAsB,EACtB,SAAS,EACT,yBAAyB,EACzB,eAAe,GAChB,CAAA;AACD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,iCAAiC,EACjC,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
@@ -1,11 +1,15 @@
1
1
  import { Hex } from 'viem';
2
2
  import { UserOperation } from 'viem/account-abstraction';
3
- import { BundleEvent, MultiChainCompact } from './types';
3
+ import { BundleEvent, InsufficientBalanceResult, MultiChainCompact, OrderCost, OrderCostResult, UserChainBalances } from './types';
4
4
  declare function getEmptyUserOp(): UserOperation<'0.7'>;
5
5
  declare function getOrderBundleHash(orderBundle: MultiChainCompact): Hex;
6
6
  declare function convertBigIntFields(obj: any): any;
7
7
  declare function parseCompactResponse(response: any): MultiChainCompact;
8
+ declare function parseUseChainBalances(response: any): UserChainBalances;
9
+ declare function parseOrderCost(response: any): OrderCost;
10
+ declare function parseInsufficientBalanceResult(response: any): InsufficientBalanceResult;
11
+ declare function parseOrderCostResult(response: any): OrderCostResult;
8
12
  declare function parsePendingBundleEvent(response: any): BundleEvent;
9
13
  declare function hashMultichainCompactWithoutDomainSeparator(multiChainCompact: MultiChainCompact): Hex;
10
- export { getEmptyUserOp, getOrderBundleHash, convertBigIntFields, parseCompactResponse, parsePendingBundleEvent, hashMultichainCompactWithoutDomainSeparator, };
14
+ export { getEmptyUserOp, getOrderBundleHash, convertBigIntFields, parseCompactResponse, parsePendingBundleEvent, hashMultichainCompactWithoutDomainSeparator, parseUseChainBalances, parseOrderCost, parseInsufficientBalanceResult, parseOrderCostResult, };
11
15
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../orchestrator/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,GAAG,EAIJ,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAIxD,OAAO,EACL,WAAW,EAEX,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,EACT,eAAe,EAIf,iBAAiB,EAElB,MAAM,SAAS,CAAA;AAWhB,iBAAS,cAAc,IAAI,aAAa,CAAC,KAAK,CAAC,CAY9C;AAED,iBAAS,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,GAAG,GAAG,CAM/D;AAED,iBAAS,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAwB1C;AAED,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,iBAAiB,CAiC9D;AAED,iBAAS,qBAAqB,CAAC,QAAQ,EAAE,GAAG,GAAG,iBAAiB,CAe/D;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,SAAS,CAoChD;AAED,iBAAS,8BAA8B,CACrC,QAAQ,EAAE,GAAG,GACZ,yBAAyB,CAsB3B;AAED,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,eAAe,CAS5D;AAED,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,GAAG,GAAG,WAAW,CAkC3D;AAkBD,iBAAS,2CAA2C,CAClD,iBAAiB,EAAE,iBAAiB,GACnC,GAAG,CAmBL;AAyGD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,2CAA2C,EAC3C,qBAAqB,EACrB,cAAc,EACd,8BAA8B,EAC9B,oBAAoB,GACrB,CAAA"}
@@ -34,7 +34,7 @@ function convertBigIntFields(obj) {
34
34
  if (typeof obj === 'object') {
35
35
  const result = {};
36
36
  for (const key in obj) {
37
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
37
+ if (Object.hasOwn(obj, key)) {
38
38
  result[key] = convertBigIntFields(obj[key]);
39
39
  }
40
40
  }
@@ -76,6 +76,80 @@ function parseCompactResponse(response) {
76
76
  }),
77
77
  };
78
78
  }
79
+ function parseUseChainBalances(response) {
80
+ const result = {};
81
+ for (const chainIdStr in response) {
82
+ const chainId = Number(chainIdStr);
83
+ const chainData = response[chainIdStr];
84
+ result[chainId] = {};
85
+ for (const tokenAddress in chainData) {
86
+ const balanceStr = chainData[tokenAddress]?.balance;
87
+ result[chainId][tokenAddress] = BigInt(balanceStr);
88
+ }
89
+ }
90
+ return result;
91
+ }
92
+ function parseOrderCost(response) {
93
+ const tokensSpent = {};
94
+ for (const chainIdStr in response.tokensSpent) {
95
+ const chainId = Number(chainIdStr);
96
+ tokensSpent[chainId] = {};
97
+ const chainTokens = response.tokensSpent[chainIdStr];
98
+ for (const tokenAddress in chainTokens) {
99
+ const balanceStr = chainTokens[tokenAddress];
100
+ if (typeof balanceStr !== 'string') {
101
+ throw new Error(`Expected string balance for token ${tokenAddress} on chain ${chainId}`);
102
+ }
103
+ tokensSpent[chainId][tokenAddress] = BigInt(balanceStr);
104
+ }
105
+ }
106
+ const tokensReceived = response.tokensReceived.map((entry) => {
107
+ return {
108
+ tokenAddress: entry.tokenAddress,
109
+ hasFulfilled: entry.hasFulfilled,
110
+ amountSpent: BigInt(entry.amountSpent),
111
+ targetAmount: BigInt(entry.targetAmount),
112
+ fee: BigInt(entry.fee),
113
+ };
114
+ });
115
+ return {
116
+ hasFulfilledAll: true,
117
+ tokensSpent,
118
+ tokensReceived,
119
+ };
120
+ }
121
+ function parseInsufficientBalanceResult(response) {
122
+ if (!Array.isArray(response.tokenShortfall)) {
123
+ throw new Error('Expected tokenShortfall to be an array');
124
+ }
125
+ const tokenShortfall = response.tokenShortfall.map((entry) => {
126
+ return {
127
+ tokenAddress: entry.tokenAddress,
128
+ targetAmount: BigInt(entry.targetAmount),
129
+ amountSpent: BigInt(entry.amountSpent),
130
+ fee: BigInt(entry.fee),
131
+ tokenSymbol: entry.tokenSymbol,
132
+ tokenDecimals: entry.tokenDecimals,
133
+ };
134
+ });
135
+ const result = {
136
+ hasFulfilledAll: false,
137
+ tokenShortfall,
138
+ totalTokenShortfallInUSD: BigInt(response.totalTokenShortfallInUSD),
139
+ };
140
+ return result;
141
+ }
142
+ function parseOrderCostResult(response) {
143
+ if (typeof response.hasFulfilledAll !== 'boolean') {
144
+ throw new Error('Missing or invalid hasFulfilledAll field');
145
+ }
146
+ if (response.hasFulfilledAll) {
147
+ return parseOrderCost(response);
148
+ }
149
+ else {
150
+ return parseInsufficientBalanceResult(response);
151
+ }
152
+ }
79
153
  function parsePendingBundleEvent(response) {
80
154
  return {
81
155
  type: response.type,
@@ -207,4 +281,4 @@ function hashExecution(execution) {
207
281
  keccak256(execution.data),
208
282
  ]));
209
283
  }
210
- export { getEmptyUserOp, getOrderBundleHash, convertBigIntFields, parseCompactResponse, parsePendingBundleEvent, hashMultichainCompactWithoutDomainSeparator, };
284
+ export { getEmptyUserOp, getOrderBundleHash, convertBigIntFields, parseCompactResponse, parsePendingBundleEvent, hashMultichainCompactWithoutDomainSeparator, parseUseChainBalances, parseOrderCost, parseInsufficientBalanceResult, parseOrderCostResult, };
@@ -1,5 +1,8 @@
1
1
  import { Account, Address, Chain, Hex } from 'viem';
2
2
  import { WebAuthnAccount } from 'viem/account-abstraction';
3
+ interface AccountProviderConfig {
4
+ type: 'safe' | 'nexus';
5
+ }
3
6
  interface OwnableValidatorConfig {
4
7
  type: 'ecdsa';
5
8
  accounts: Account[];
@@ -38,8 +41,8 @@ interface SpendingLimitsPolicy {
38
41
  }
39
42
  interface TimeFramePolicy {
40
43
  type: 'time-frame';
41
- validUntil: bigint;
42
- validAfter: bigint;
44
+ validUntil: number;
45
+ validAfter: number;
43
46
  }
44
47
  interface UsageLimitPolicy {
45
48
  type: 'usage-limit';
@@ -62,9 +65,7 @@ interface Session {
62
65
  salt?: Hex;
63
66
  }
64
67
  interface RhinestoneAccountConfig {
65
- account: {
66
- type: 'safe' | 'nexus';
67
- };
68
+ account?: AccountProviderConfig;
68
69
  owners: OwnerSet;
69
70
  rhinestoneApiKey: string;
70
71
  deployerAccount: Account;
@@ -103,5 +104,5 @@ interface CrossChainTransaction extends BaseTransaction {
103
104
  targetChain: Chain;
104
105
  }
105
106
  type Transaction = SameChainTransaction | CrossChainTransaction;
106
- export type { RhinestoneAccountConfig, BundlerConfig, Transaction, Call, TokenRequest, OwnerSet, SignerSet, Session, Policy, UniversalActionPolicyParamCondition, };
107
+ export type { RhinestoneAccountConfig, AccountProviderConfig, BundlerConfig, Transaction, Call, TokenRequest, OwnerSet, SignerSet, Session, Policy, UniversalActionPolicyParamCondition, };
107
108
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,eAAe,CAAA;CACzB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,KAAK,QAAQ,GAAG,sBAAsB,GAAG,uBAAuB,CAAA;AAEhE,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,UAAU,qBAAqB;IAC7B,IAAI,EAAE,kBAAkB,CAAA;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,KAAK,EAAE,CAAC,8BAA8B,EAAE,GAAG,8BAA8B,EAAE,CAAC,CAAA;CAC7E;AAED,UAAU,8BAA8B;IACtC,SAAS,EAAE,mCAAmC,CAAA;IAC9C,cAAc,EAAE,MAAM,CAAA;I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MAAM,CAAA;IACxB,eAAe,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;IACpB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,SAAS,CAAA;QACf,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB;AAED,UAAU,IAAI;IACZ,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,KAAK,SAAS,GAAG,gBAAgB,CAAA;AAEjC,UAAU,eAAe;IACvB,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,OAAO,CAAC,EAAE,SAAS,CAAA;CACpB;AAED,UAAU,oBAAqB,SAAQ,eAAe;IACpD,KAAK,EAAE,KAAK,CAAA;CACb;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACrD,WAAW,EAAE,KAAK,CAAA;IAClB,WAAW,EAAE,KAAK,CAAA;CACnB;AAED,KAAK,WAAW,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE/D,YAAY,EACV,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,MAAM,EACN,mCAAmC,GACpC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=smart-sessions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-sessions.test.d.ts","sourceRoot":"","sources":["../../../../../test/modules/validators/smart-sessions.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { privateKeyToAccount } from 'viem/accounts';
2
+ import { expect, test } from 'vitest';
3
+ import { getPermissionId } from '../../../src/modules/validators/smart-sessions';
4
+ test('getPermissionId', () => {
5
+ const accountA = privateKeyToAccount('0x2be89d993f98bbaab8b83f1a2830cb9414e19662967c7ba2a0f43d2a9125bd6d');
6
+ const accountB = privateKeyToAccount('0x39e2fec1a04c088f939d81de8f1abebdebf899a6cfb9968f9b663a7afba8301b');
7
+ expect(getPermissionId({
8
+ owners: {
9
+ type: 'ecdsa',
10
+ accounts: [accountA, accountB],
11
+ },
12
+ })).toBe('0xa16d89135da22ae1b97b6ac6ebc047dce282640bbbf56059958d96527b720344');
13
+ expect(getPermissionId({
14
+ owners: {
15
+ type: 'ecdsa',
16
+ accounts: [accountA, accountB],
17
+ },
18
+ salt: '0x97340e1cfff3319c76ef22b2bc9d3231071d550125d68c9d4a8972823f166320',
19
+ })).toBe('0x85ff7cd77e7e0f8fbc2e42c86cdb948e4c79ac5a5e4595def4c38d7ed804eef9');
20
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhinestone/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "End-to-end chain abstraction and modularity toolkit",
5
5
  "author": {
6
6
  "name": "Rhinestone",
@@ -38,6 +38,6 @@
38
38
  "axios": "^1.7.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "viem": "^2.20.0"
41
+ "viem": "^2.28.0"
42
42
  }
43
43
  }
@@ -1,15 +0,0 @@
1
- import { RhinestoneAccountConfig } from '../types';
2
- declare function getDeployArgs(config: RhinestoneAccountConfig): Promise<{
3
- factory: `0x${string}`;
4
- factoryData: `0x${string}`;
5
- salt: `0x${string}`;
6
- hashedInitcode: `0x${string}`;
7
- implementation: `0x${string}`;
8
- initializationCallData: null;
9
- }>;
10
- declare function getSmartAccount(): Promise<never>;
11
- declare function getSessionSmartAccount(): Promise<never>;
12
- declare function get7702InitCalls(): never;
13
- declare function get7702SmartAccount(): never;
14
- export { getDeployArgs, getSmartAccount, getSessionSmartAccount, get7702InitCalls, get7702SmartAccount, };
15
- //# sourceMappingURL=safe.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../accounts/safe.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAclD,iBAAe,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;GA0E3D;AAED,iBAAe,eAAe,IAAI,OAAO,CAAC,KAAK,CAAC,CAE/C;AAED,iBAAe,sBAAsB,IAAI,OAAO,CAAC,KAAK,CAAC,CAEtD;AAED,iBAAS,gBAAgB,IAAI,KAAK,CAEjC;AAED,iBAAS,mBAAmB,IAAI,KAAK,CAEpC;AAsBD,OAAO,EACL,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,GACpB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../accounts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,MAAM,EAQZ,MAAM,MAAM,CAAA;AAKb,OAAO,EAAiB,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAEjE,KAAK,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,WAAW,CAAA;AAErD,UAAU,aAAa,CAAC,QAAQ,SAAS,QAAQ;IAC/C,IAAI,EAAE,QAAQ,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,OAAO,CAAC,EAAE,GAAG,CAAA;CACd;AAED,UAAU,oBAAoB,CAAC,QAAQ,SAAS,QAAQ;IACtD,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC7B,Q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