@charterlabs/rhinestone-sdk 0.3.0 → 0.3.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 (129) hide show
  1. package/README.md +31 -200
  2. package/dist/src/accounts/error.d.ts +8 -1
  3. package/dist/src/accounts/error.d.ts.map +1 -1
  4. package/dist/src/accounts/error.js +10 -1
  5. package/dist/src/accounts/index.d.ts +11 -10
  6. package/dist/src/accounts/index.d.ts.map +1 -1
  7. package/dist/src/accounts/index.js +79 -50
  8. package/dist/src/accounts/kernel.d.ts +3 -5
  9. package/dist/src/accounts/kernel.d.ts.map +1 -1
  10. package/dist/src/accounts/kernel.js +8 -17
  11. package/dist/src/accounts/kernel.test.js +10 -3
  12. package/dist/src/accounts/nexus.d.ts +3 -5
  13. package/dist/src/accounts/nexus.d.ts.map +1 -1
  14. package/dist/src/accounts/nexus.js +108 -57
  15. package/dist/src/accounts/nexus.test.js +10 -3
  16. package/dist/src/accounts/passport.d.ts +4 -7
  17. package/dist/src/accounts/passport.d.ts.map +1 -1
  18. package/dist/src/accounts/passport.js +0 -91
  19. package/dist/src/accounts/safe.d.ts +9 -4
  20. package/dist/src/accounts/safe.d.ts.map +1 -1
  21. package/dist/src/accounts/safe.js +108 -38
  22. package/dist/src/accounts/safe.test.js +10 -3
  23. package/dist/src/accounts/signing/common.d.ts +3 -3
  24. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  25. package/dist/src/accounts/signing/common.js +29 -5
  26. package/dist/src/accounts/signing/message.js +2 -2
  27. package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
  28. package/dist/src/accounts/signing/typedData.js +3 -3
  29. package/dist/src/accounts/startale.d.ts +2 -4
  30. package/dist/src/accounts/startale.d.ts.map +1 -1
  31. package/dist/src/accounts/startale.js +0 -4
  32. package/dist/src/accounts/utils.d.ts.map +1 -1
  33. package/dist/src/accounts/utils.js +10 -3
  34. package/dist/src/accounts/walletClient.d.ts.map +1 -1
  35. package/dist/src/accounts/walletClient.js +6 -0
  36. package/dist/src/actions/compact.d.ts +4 -2
  37. package/dist/src/actions/compact.d.ts.map +1 -1
  38. package/dist/src/actions/compact.js +4 -1
  39. package/dist/src/actions/deployment.d.ts +19 -0
  40. package/dist/src/actions/deployment.d.ts.map +1 -0
  41. package/dist/src/actions/deployment.js +78 -0
  42. package/dist/src/actions/index.d.ts +3 -1
  43. package/dist/src/actions/index.d.ts.map +1 -1
  44. package/dist/src/actions/index.js +12 -0
  45. package/dist/src/actions/smart-sessions.d.ts +17 -8
  46. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  47. package/dist/src/actions/smart-sessions.js +40 -4
  48. package/dist/src/errors/index.d.ts +3 -3
  49. package/dist/src/errors/index.d.ts.map +1 -1
  50. package/dist/src/errors/index.js +3 -1
  51. package/dist/src/execution/compact.d.ts +15 -18
  52. package/dist/src/execution/compact.d.ts.map +1 -1
  53. package/dist/src/execution/compact.js +15 -17
  54. package/dist/src/execution/error.d.ts +2 -8
  55. package/dist/src/execution/error.d.ts.map +1 -1
  56. package/dist/src/execution/error.js +1 -10
  57. package/dist/src/execution/index.d.ts +6 -6
  58. package/dist/src/execution/index.d.ts.map +1 -1
  59. package/dist/src/execution/index.js +22 -28
  60. package/dist/src/execution/permit2.d.ts +12 -17
  61. package/dist/src/execution/permit2.d.ts.map +1 -1
  62. package/dist/src/execution/permit2.js +10 -16
  63. package/dist/src/execution/singleChainOps.d.ts +15 -3
  64. package/dist/src/execution/singleChainOps.d.ts.map +1 -1
  65. package/dist/src/execution/singleChainOps.js +17 -3
  66. package/dist/src/execution/utils.d.ts +36 -12
  67. package/dist/src/execution/utils.d.ts.map +1 -1
  68. package/dist/src/execution/utils.js +180 -133
  69. package/dist/src/index.d.ts +26 -8
  70. package/dist/src/index.d.ts.map +1 -1
  71. package/dist/src/index.js +49 -16
  72. package/dist/src/modules/abi/smart-session-emissary.d.ts +696 -0
  73. package/dist/src/modules/abi/smart-session-emissary.d.ts.map +1 -0
  74. package/dist/src/modules/abi/smart-session-emissary.js +565 -0
  75. package/dist/src/modules/chain-abstraction.d.ts +5 -0
  76. package/dist/src/modules/chain-abstraction.d.ts.map +1 -0
  77. package/dist/src/modules/chain-abstraction.js +7 -0
  78. package/dist/src/modules/common.d.ts +7 -1
  79. package/dist/src/modules/common.d.ts.map +1 -1
  80. package/dist/src/modules/index.d.ts +3 -9
  81. package/dist/src/modules/index.d.ts.map +1 -1
  82. package/dist/src/modules/index.js +11 -8
  83. package/dist/src/modules/index.test.js +3 -9
  84. package/dist/src/modules/legacy.d.ts +10 -0
  85. package/dist/src/modules/legacy.d.ts.map +1 -0
  86. package/dist/src/modules/legacy.js +65 -0
  87. package/dist/src/modules/validators/core.d.ts +2 -1
  88. package/dist/src/modules/validators/core.d.ts.map +1 -1
  89. package/dist/src/modules/validators/core.js +4 -1
  90. package/dist/src/modules/validators/index.d.ts +2 -2
  91. package/dist/src/modules/validators/index.d.ts.map +1 -1
  92. package/dist/src/modules/validators/index.js +1 -6
  93. package/dist/src/modules/validators/smart-sessions.d.ts +112 -23
  94. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  95. package/dist/src/modules/validators/smart-sessions.js +426 -301
  96. package/dist/src/orchestrator/client.d.ts +3 -4
  97. package/dist/src/orchestrator/client.d.ts.map +1 -1
  98. package/dist/src/orchestrator/client.js +49 -53
  99. package/dist/src/orchestrator/error.d.ts +11 -1
  100. package/dist/src/orchestrator/error.d.ts.map +1 -1
  101. package/dist/src/orchestrator/error.js +16 -1
  102. package/dist/src/orchestrator/index.d.ts +5 -5
  103. package/dist/src/orchestrator/index.d.ts.map +1 -1
  104. package/dist/src/orchestrator/index.js +3 -1
  105. package/dist/src/orchestrator/registry.d.ts +3 -2
  106. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  107. package/dist/src/orchestrator/registry.js +15 -14
  108. package/dist/src/orchestrator/registry.test.js +18 -1
  109. package/dist/src/orchestrator/types.d.ts +33 -8
  110. package/dist/src/orchestrator/types.d.ts.map +1 -1
  111. package/dist/src/orchestrator/types.js +15 -1
  112. package/dist/src/types.d.ts +57 -28
  113. package/dist/src/types.d.ts.map +1 -1
  114. package/dist/src/utils/index.d.ts +14 -2
  115. package/dist/src/utils/index.d.ts.map +1 -1
  116. package/dist/src/utils/index.js +46 -4
  117. package/dist/test/utils/utils.d.ts +5 -0
  118. package/dist/test/utils/utils.d.ts.map +1 -0
  119. package/dist/test/utils/utils.js +20 -0
  120. package/package.json +33 -3
  121. package/dist/src/execution/smart-session.d.ts +0 -13
  122. package/dist/src/execution/smart-session.d.ts.map +0 -1
  123. package/dist/src/execution/smart-session.js +0 -178
  124. package/dist/src/modules/omni-account.d.ts +0 -8
  125. package/dist/src/modules/omni-account.d.ts.map +0 -1
  126. package/dist/src/modules/omni-account.js +0 -13
  127. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  128. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  129. package/dist/src/modules/validators/smart-sessions.test.js +0 -222
@@ -1,8 +1,7 @@
1
1
  import { type Abi, type Address, type Chain, type Hex, type PublicClient } from 'viem';
2
2
  import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
3
3
  import { type Module } from '../modules/common';
4
- import type { EnableSessionData } from '../modules/validators/smart-sessions';
5
- import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
4
+ import type { OwnerSet, RhinestoneAccountConfig } from '../types';
6
5
  import { type ValidatorConfig } from './utils';
7
6
  declare function getDeployArgs(config: RhinestoneAccountConfig): {
8
7
  factory: `0x${string}`;
@@ -10,7 +9,7 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
10
9
  implementation: `0x${string}`;
11
10
  initializationCallData: `0x${string}`;
12
11
  salt: `0x${string}`;
13
- };
12
+ } | null;
14
13
  declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
15
14
  declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain): {
16
15
  name: string;
@@ -23,7 +22,6 @@ declare function getInstallData(module: Module): Hex[];
23
22
  declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
24
23
  declare function wrapMessageHash(messageHash: Hex, accountAddress: Hex): Hex;
25
24
  declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
26
- declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
27
25
  declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
28
- export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
26
+ export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
29
27
  //# sourceMappingURL=kernel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,EASV,KAAK,GAAG,EAER,KAAK,YAAY,EAMlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAQ1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAEV,QAAQ,EACR,uBAAuB,EACvB,OAAO,E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AAC,iEAYlC;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAclC;AA+ED,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,eAAe,GAChB,CAAA"}
@@ -5,7 +5,6 @@ exports.getInstallData = getInstallData;
5
5
  exports.getAddress = getAddress;
6
6
  exports.getDeployArgs = getDeployArgs;
7
7
  exports.getSmartAccount = getSmartAccount;
8
- exports.getSessionSmartAccount = getSessionSmartAccount;
9
8
  exports.getGuardianSmartAccount = getGuardianSmartAccount;
10
9
  exports.packSignature = packSignature;
11
10
  exports.wrapMessageHash = wrapMessageHash;
@@ -23,6 +22,9 @@ const KERNEL_BYTECODE = '0x603d3d8160223d3973d6cedde84be40893d153be9d467cd6ad378
23
22
  const KERNEL_VERSION = '0.3.3';
24
23
  function getDeployArgs(config) {
25
24
  if (config.initData) {
25
+ if (!('factory' in config.initData)) {
26
+ return null;
27
+ }
26
28
  const factoryData = (0, viem_1.decodeFunctionData)({
27
29
  abi: (0, viem_1.parseAbi)([
28
30
  'function deployWithFactory(address factory,bytes createData,bytes32 salt)',
@@ -90,7 +92,11 @@ function getDeployArgs(config) {
90
92
  };
91
93
  }
92
94
  function getAddress(config) {
93
- const { salt, initializationCallData } = getDeployArgs(config);
95
+ const deployArgs = getDeployArgs(config);
96
+ if (!deployArgs) {
97
+ throw new Error('Cannot derive address: deploy args not available');
98
+ }
99
+ const { salt, initializationCallData } = deployArgs;
94
100
  const actualSalt = (0, viem_1.keccak256)((0, viem_1.concat)([initializationCallData, salt]));
95
101
  return (0, viem_1.getContractAddress)({
96
102
  from: KERNEL_FACTORY_ADDRESS,
@@ -198,21 +204,6 @@ async function getSmartAccount(client, address, owners, validatorAddress, sign)
198
204
  return (0, validators_1.getMockSignature)(owners);
199
205
  }, sign);
200
206
  }
201
- async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign) {
202
- return await getBaseSmartAccount(address, client, validatorAddress, 'validator', async () => {
203
- const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
204
- if (enableData) {
205
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), dummyOpSignature, enableData);
206
- }
207
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), dummyOpSignature);
208
- }, async (hash) => {
209
- const signature = await sign(hash);
210
- if (enableData) {
211
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), signature, enableData);
212
- }
213
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
214
- });
215
- }
216
207
  async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
217
208
  return await getBaseSmartAccount(address, client, validatorAddress, 'validator', async () => {
218
209
  return (0, validators_1.getMockSignature)(guardians);
@@ -2,18 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const consts_1 = require("../../test/consts");
5
+ const utils_1 = require("../../test/utils/utils");
5
6
  const common_1 = require("../modules/common");
6
7
  const kernel_1 = require("./kernel");
7
8
  const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
8
9
  (0, vitest_1.describe)('Accounts: Kernel', () => {
9
10
  (0, vitest_1.describe)('Deploy Args', () => {
10
11
  (0, vitest_1.test)('ECDSA owners', () => {
11
- const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
12
+ const deployArgs = (0, kernel_1.getDeployArgs)({
12
13
  owners: {
13
14
  type: 'ecdsa',
14
15
  accounts: [consts_1.accountA, consts_1.accountB],
15
16
  },
16
17
  });
18
+ (0, utils_1.assertNotNull)(deployArgs);
19
+ const { factory, factoryData, salt, implementation, initializationCallData, } = deployArgs;
17
20
  (0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
18
21
  (0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b01000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
19
22
  (0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
@@ -21,12 +24,14 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
21
24
  (0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b01000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
22
25
  });
23
26
  (0, vitest_1.test)('Passkey owner', () => {
24
- const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
27
+ const deployArgs = (0, kernel_1.getDeployArgs)({
25
28
  owners: {
26
29
  type: 'passkey',
27
30
  accounts: [consts_1.passkeyAccount],
28
31
  },
29
32
  });
33
+ (0, utils_1.assertNotNull)(deployArgs);
34
+ const { factory, factoryData, salt, implementation, initializationCallData, } = deployArgs;
30
35
  (0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
31
36
  (0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003443c3b752b010000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
32
37
  (0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
@@ -34,7 +39,7 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
34
39
  (0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
35
40
  });
36
41
  (0, vitest_1.test)('Existing account', () => {
37
- const { factory, factoryData } = (0, kernel_1.getDeployArgs)({
42
+ const deployArgs = (0, kernel_1.getDeployArgs)({
38
43
  owners: {
39
44
  type: 'ecdsa',
40
45
  accounts: [consts_1.accountA, consts_1.accountB],
@@ -46,6 +51,8 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
46
51
  intentExecutorInstalled: false,
47
52
  },
48
53
  });
54
+ (0, utils_1.assertNotNull)(deployArgs);
55
+ const { factory, factoryData } = deployArgs;
49
56
  (0, vitest_1.expect)(factory).toEqual('0xd703aaE79538628d27099B8c4f621bE4CCd142d5');
50
57
  (0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
51
58
  });
@@ -1,8 +1,7 @@
1
1
  import type { Abi, Account, Address, Chain, Hex, PublicClient } from 'viem';
2
2
  import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
3
3
  import type { Module } from '../modules/common';
4
- import type { EnableSessionData } from '../modules/validators/smart-sessions';
5
- import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
4
+ import type { OwnerSet, RhinestoneAccountConfig } from '../types';
6
5
  import { type ValidatorConfig } from './utils';
7
6
  declare function getDeployArgs(config: RhinestoneAccountConfig): {
8
7
  salt: `0x${string}`;
@@ -11,7 +10,7 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
11
10
  implementation: `0x${string}`;
12
11
  initData: `0x${string}`;
13
12
  initializationCallData: `0x${string}`;
14
- };
13
+ } | null;
15
14
  declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
16
15
  declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain): {
17
16
  name: string;
@@ -24,12 +23,11 @@ declare function getInstallData(module: Module): `0x${string}`;
24
23
  declare function getDefaultValidatorAddress(version: '1.0.2' | '1.2.0' | 'rhinestone-1.0.0-beta' | 'rhinestone-1.0.0' | undefined): Address;
25
24
  declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
26
25
  declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
27
- declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
28
26
  declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
29
27
  declare function signEip7702InitData(config: RhinestoneAccountConfig, eoa: Account): Promise<`0x${string}`>;
30
28
  declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature: Hex): {
31
29
  initData: `0x${string}`;
32
30
  contract: `0x${string}`;
33
31
  };
34
- export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
32
+ export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
35
33
  //# sourceMappingURL=nexus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAe3E,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAEV,QAAQ,EACR,uBAAuB,EACvB,OAAO,EACR,MAAM,UAAU,CAAA;AAMjB,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAA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EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,EACtE,uBAAuB,GAAE,OAAyC,0BAWnE;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACjC,uBAAuB,GAAE,OAAyC,iEAYnE;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACjC,uBAAuB,GAAE,OAAyC,iEAcnE;AAqFD,iBAAe,mBAAmB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,GAAG,EAAE,OAAO,0BA8Bb;AAED,iBAAS,kBAAkB,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,GAAG;;;EA0C1E;AA6FD,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,EACV,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
@@ -7,7 +7,6 @@ exports.getDefaultValidatorAddress = getDefaultValidatorAddress;
7
7
  exports.packSignature = packSignature;
8
8
  exports.getDeployArgs = getDeployArgs;
9
9
  exports.getSmartAccount = getSmartAccount;
10
- exports.getSessionSmartAccount = getSessionSmartAccount;
11
10
  exports.getGuardianSmartAccount = getGuardianSmartAccount;
12
11
  exports.signEip7702InitData = signEip7702InitData;
13
12
  exports.getEip7702InitCall = getEip7702InitCall;
@@ -29,45 +28,19 @@ const NEXUS_K1_VALIDATOR = '0x00000004171351c442b202678c48d8ab5b321e8f';
29
28
  const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
30
29
  function getDeployArgs(config) {
31
30
  if (config.initData) {
32
- const factoryData = (0, viem_1.decodeFunctionData)({
33
- abi: (0, viem_1.parseAbi)([
34
- 'function createAccount(address eoaOwner,uint256 index,address[] attesters,uint8 threshold)',
35
- ]),
36
- data: config.initData.factoryData,
37
- });
38
- if (factoryData.functionName !== 'createAccount') {
39
- throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data', 'nexus');
31
+ if (!('factory' in config.initData)) {
32
+ return null;
40
33
  }
41
- const owner = factoryData.args[0];
42
- const index = factoryData.args[1];
43
- const attesters = factoryData.args[2];
44
- const threshold = factoryData.args[3];
45
- const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
46
- const implementation = config.initData.factory === NEXUS_FACTORY_ADDRESS
47
- ? NEXUS_IMPLEMENTATION_ADDRESS
48
- : NEXUS_IMPLEMENTATION_1_0_0;
49
- const registry = viem_1.zeroAddress;
50
- const bootstrapData = (0, viem_1.encodeFunctionData)({
51
- abi: (0, viem_1.parseAbi)([
52
- 'function initNexusWithSingleValidator(address validator,bytes data,address registry,address[] attesters,uint8 threshold)',
53
- ]),
54
- functionName: 'initNexusWithSingleValidator',
55
- args: [NEXUS_K1_VALIDATOR, owner, registry, attesters, threshold],
56
- });
57
- const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_1_0_0, bootstrapData]);
58
- const initializationCallData = (0, viem_1.encodeFunctionData)({
59
- abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
60
- functionName: 'initializeAccount',
61
- args: [initData],
62
- });
63
- return {
64
- salt,
65
- factory: config.initData.factory,
66
- factoryData: config.initData.factoryData,
67
- implementation,
68
- initData,
69
- initializationCallData,
70
- };
34
+ const { factory, factoryData } = config.initData;
35
+ const v1Result = tryDecodeV1FactoryData(factory, factoryData);
36
+ if (v1Result) {
37
+ return v1Result;
38
+ }
39
+ const v0Result = tryDecodeV0FactoryData(factory, factoryData);
40
+ if (v0Result) {
41
+ return v0Result;
42
+ }
43
+ throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data: unrecognized schema', 'nexus');
71
44
  }
72
45
  const account = config.account;
73
46
  const defaultSalt = (0, viem_1.keccak256)('0x');
@@ -156,7 +129,14 @@ function getDeployArgs(config) {
156
129
  };
157
130
  }
158
131
  function getAddress(config) {
159
- const { factory, salt, initializationCallData, implementation } = getDeployArgs(config);
132
+ const deployArgs = getDeployArgs(config);
133
+ if (!deployArgs) {
134
+ if (config.initData?.address) {
135
+ return config.initData.address;
136
+ }
137
+ throw new Error('Cannot derive address: deploy args not available');
138
+ }
139
+ const { factory, salt, initializationCallData, implementation } = deployArgs;
160
140
  const creationCode = factory === NEXUS_FACTORY_ADDRESS
161
141
  ? NEXUS_CREATION_CODE
162
142
  : '0x603d3d8160223d3973000000039dfcad030719b07296710f045f0558f760095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
@@ -247,21 +227,6 @@ async function getSmartAccount(client, address, owners, validatorAddress, sign,
247
227
  return (0, validators_1.getMockSignature)(owners);
248
228
  }, sign, defaultValidatorAddress);
249
229
  }
250
- async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
251
- return await getBaseSmartAccount(address, client, validatorAddress, async () => {
252
- const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
253
- if (enableData) {
254
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), dummyOpSignature, enableData);
255
- }
256
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), dummyOpSignature);
257
- }, async (hash) => {
258
- const signature = await sign(hash);
259
- if (enableData) {
260
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), signature, enableData);
261
- }
262
- return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
263
- }, defaultValidatorAddress);
264
- }
265
230
  async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
266
231
  return await getBaseSmartAccount(address, client, validatorAddress, async () => {
267
232
  return (0, validators_1.getMockSignature)(guardians);
@@ -343,7 +308,11 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
343
308
  });
344
309
  }
345
310
  async function signEip7702InitData(config, eoa) {
346
- const { initData } = getDeployArgs(config);
311
+ const deployArgs = getDeployArgs(config);
312
+ if (!deployArgs) {
313
+ throw new Error('Cannot sign EIP-7702 init data: deploy args not available');
314
+ }
315
+ const { initData } = deployArgs;
347
316
  if (!eoa.signTypedData) {
348
317
  throw new error_1.SigningNotSupportedForAccountError();
349
318
  }
@@ -376,7 +345,11 @@ function getEip7702InitCall(config, signature) {
376
345
  const encodedData = (0, viem_1.encodePacked)(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
377
346
  return encodedData;
378
347
  }
379
- const { initData } = getDeployArgs(config);
348
+ const deployArgs = getDeployArgs(config);
349
+ if (!deployArgs) {
350
+ throw new Error('Cannot get EIP-7702 init call: deploy args not available');
351
+ }
352
+ const { initData } = deployArgs;
380
353
  const encodedData = getEncodedData(initData);
381
354
  const accountFullData = (0, viem_1.concat)([signature, encodedData]);
382
355
  const accountInitCallData = (0, viem_1.encodeFunctionData)({
@@ -402,3 +375,81 @@ function getEip7702InitCall(config, signature) {
402
375
  contract: NEXUS_IMPLEMENTATION_ADDRESS,
403
376
  };
404
377
  }
378
+ function tryDecodeV1FactoryData(factory, factoryData) {
379
+ try {
380
+ const decoded = (0, viem_1.decodeFunctionData)({
381
+ abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
382
+ data: factoryData,
383
+ });
384
+ const initData = decoded.args[0];
385
+ const salt = decoded.args[1];
386
+ const initializationCallData = (0, viem_1.encodeFunctionData)({
387
+ abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
388
+ functionName: 'initializeAccount',
389
+ args: [initData],
390
+ });
391
+ return {
392
+ salt,
393
+ factory,
394
+ factoryData,
395
+ implementation: NEXUS_IMPLEMENTATION_ADDRESS,
396
+ initData,
397
+ initializationCallData,
398
+ };
399
+ }
400
+ catch (error) {
401
+ if (isAbiDecodingError(error)) {
402
+ return null;
403
+ }
404
+ throw error;
405
+ }
406
+ }
407
+ function tryDecodeV0FactoryData(factory, factoryData) {
408
+ try {
409
+ const decoded = (0, viem_1.decodeFunctionData)({
410
+ abi: (0, viem_1.parseAbi)([
411
+ 'function createAccount(address eoaOwner,uint256 index,address[] attesters,uint8 threshold)',
412
+ ]),
413
+ data: factoryData,
414
+ });
415
+ const owner = decoded.args[0];
416
+ const index = decoded.args[1];
417
+ const attesters = decoded.args[2];
418
+ const threshold = decoded.args[3];
419
+ const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
420
+ const implementation = factory === NEXUS_FACTORY_ADDRESS
421
+ ? NEXUS_IMPLEMENTATION_ADDRESS
422
+ : NEXUS_IMPLEMENTATION_1_0_0;
423
+ const registry = viem_1.zeroAddress;
424
+ const bootstrapData = (0, viem_1.encodeFunctionData)({
425
+ abi: (0, viem_1.parseAbi)([
426
+ 'function initNexusWithSingleValidator(address validator,bytes data,address registry,address[] attesters,uint8 threshold)',
427
+ ]),
428
+ functionName: 'initNexusWithSingleValidator',
429
+ args: [NEXUS_K1_VALIDATOR, owner, registry, attesters, threshold],
430
+ });
431
+ const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_1_0_0, bootstrapData]);
432
+ const initializationCallData = (0, viem_1.encodeFunctionData)({
433
+ abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
434
+ functionName: 'initializeAccount',
435
+ args: [initData],
436
+ });
437
+ return {
438
+ salt,
439
+ factory,
440
+ factoryData,
441
+ implementation,
442
+ initData,
443
+ initializationCallData,
444
+ };
445
+ }
446
+ catch (error) {
447
+ if (isAbiDecodingError(error)) {
448
+ return null;
449
+ }
450
+ throw error;
451
+ }
452
+ }
453
+ function isAbiDecodingError(error) {
454
+ return (error instanceof Error && error.name === 'AbiFunctionSignatureNotFoundError');
455
+ }
@@ -2,18 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const consts_1 = require("../../test/consts");
5
+ const utils_1 = require("../../test/utils/utils");
5
6
  const common_1 = require("../modules/common");
6
7
  const nexus_1 = require("./nexus");
7
8
  const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
8
9
  (0, vitest_1.describe)('Accounts: Nexus', () => {
9
10
  (0, vitest_1.describe)('Deploy Args', () => {
10
11
  (0, vitest_1.test)('ECDSA owners', () => {
11
- const { factory, factoryData, salt, implementation, initializationCallData, } = (0, nexus_1.getDeployArgs)({
12
+ const deployArgs = (0, nexus_1.getDeployArgs)({
12
13
  owners: {
13
14
  type: 'ecdsa',
14
15
  accounts: [consts_1.accountA, consts_1.accountB],
15
16
  },
16
17
  });
18
+ (0, utils_1.assertNotNull)(deployArgs);
19
+ const { factory, factoryData, salt, implementation, initializationCallData, } = deployArgs;
17
20
  (0, vitest_1.expect)(factory).toEqual('0x0000000000679A258c64d2F20F310e12B64b7375');
18
21
  (0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
19
22
  (0, vitest_1.expect)(salt).toEqual('0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470');
@@ -21,12 +24,14 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
21
24
  (0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a14190000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
22
25
  });
23
26
  (0, vitest_1.test)('Passkey owner', () => {
24
- const { factory, factoryData, salt, implementation, initializationCallData, } = (0, nexus_1.getDeployArgs)({
27
+ const deployArgs = (0, nexus_1.getDeployArgs)({
25
28
  owners: {
26
29
  type: 'passkey',
27
30
  accounts: [consts_1.passkeyAccount],
28
31
  },
29
32
  });
33
+ (0, utils_1.assertNotNull)(deployArgs);
34
+ const { factory, factoryData, salt, implementation, initializationCallData, } = deployArgs;
30
35
  (0, vitest_1.expect)(factory).toEqual('0x0000000000679A258c64d2F20F310e12B64b7375');
31
36
  (0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003448643787600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
32
37
  (0, vitest_1.expect)(salt).toEqual('0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470');
@@ -34,7 +39,7 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
34
39
  (0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003448643787600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
35
40
  });
36
41
  (0, vitest_1.test)('Existing account', () => {
37
- const { factory, factoryData } = (0, nexus_1.getDeployArgs)({
42
+ const deployArgs = (0, nexus_1.getDeployArgs)({
38
43
  owners: {
39
44
  type: 'ecdsa',
40
45
  accounts: [consts_1.accountA, consts_1.accountB],
@@ -46,6 +51,8 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
46
51
  intentExecutorInstalled: false,
47
52
  },
48
53
  });
54
+ (0, utils_1.assertNotNull)(deployArgs);
55
+ const { factory, factoryData } = deployArgs;
49
56
  (0, vitest_1.expect)(factory).toEqual('0x00000bb19a3579F4D779215dEf97AFbd0e30DB55');
50
57
  (0, vitest_1.expect)(factoryData).toEqual('0x0d51f0b7000000000000000000000000db8fca317427c3f85b6734af6455f287011c54b50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
51
58
  });
@@ -1,12 +1,9 @@
1
- import type { Abi, Address, Hex, PublicClient } from 'viem';
2
- import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
1
+ import type { Hex } from 'viem';
3
2
  import type { Module } from '../modules/common';
4
- import { type EnableSessionData } from '../modules/validators/smart-sessions';
5
- import type { RhinestoneAccountConfig, Session } from '../types';
6
- import { type ValidatorConfig } from './utils';
3
+ import type { RhinestoneAccountConfig } from '../types';
4
+ import type { ValidatorConfig } from './utils';
7
5
  declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
8
6
  declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
9
- declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
10
7
  declare function getInstallData(module: Module): `0x${string}`;
11
- export { getAddress, packSignature, getSessionSmartAccount, getInstallData };
8
+ export { getAddress, packSignature, getInstallData };
12
9
  //# sourceMappingURL=passport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"passport.d.ts","sourceRoot":"","sources":["../../../accounts/passport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAW,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAWpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAK/C,OAAO,EACL,KAAK,iBAAiB,EAIvB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAWhF,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAsBlD;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAuClC;AAmHD,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"passport.d.ts","sourceRoot":"","sources":["../../../accounts/passport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,GAAG,EAAE,MAAM,MAAM,CAAA;AAUjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAsBlD;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;AAoCD,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA"}
@@ -2,13 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAddress = getAddress;
4
4
  exports.packSignature = packSignature;
5
- exports.getSessionSmartAccount = getSessionSmartAccount;
6
5
  exports.getInstallData = getInstallData;
7
6
  const viem_1 = require("viem");
8
- const account_abstraction_1 = require("viem/account-abstraction");
9
- const validators_1 = require("../modules/validators");
10
- const smart_sessions_1 = require("../modules/validators/smart-sessions");
11
- const utils_1 = require("./utils");
12
7
  const CREATION_CODE = '0x6054600f3d396034805130553df3fe63906111273d3560e01c14602b57363d3d373d3d3d3d369030545af43d82803e156027573d90f35b3d90fd5b30543d5260203df3';
13
8
  const PASSPORT_FACTORY_ADDRESS = '0xD70C6386Ca012CDeb249B4E46C53d3507D9CBB87';
14
9
  const PASSPORT_MAIN_MODULE = '0x0d1Bf2f4Ab334324665aeb8d481fF92CdE289439';
@@ -39,92 +34,6 @@ async function packSignature(signature, validator, transformSignature = (signatu
39
34
  const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
40
35
  return packedSig;
41
36
  }
42
- async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign) {
43
- return await getBaseSmartAccount(address, client, validatorAddress, async () => {
44
- const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
45
- if (enableData) {
46
- return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_ENABLE, (0, smart_sessions_1.getPermissionId)(session), dummyOpSignature, enableData);
47
- }
48
- return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_USE, (0, smart_sessions_1.getPermissionId)(session), dummyOpSignature);
49
- }, async (hash) => {
50
- const signature = await sign(hash);
51
- if (enableData) {
52
- return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_ENABLE, (0, smart_sessions_1.getPermissionId)(session), signature, enableData);
53
- }
54
- return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_USE, (0, smart_sessions_1.getPermissionId)(session), signature);
55
- });
56
- }
57
- async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation) {
58
- return await (0, account_abstraction_1.toSmartAccount)({
59
- client,
60
- entryPoint: {
61
- abi: account_abstraction_1.entryPoint07Abi,
62
- address: account_abstraction_1.entryPoint07Address,
63
- version: '0.7',
64
- },
65
- async decodeCalls() {
66
- throw new Error('Not implemented');
67
- },
68
- async encodeCalls(calls) {
69
- return (0, utils_1.encode7579Calls)({
70
- mode: {
71
- type: calls.length > 1 ? 'batchcall' : 'call',
72
- revertOnError: false,
73
- selector: '0x',
74
- context: '0x',
75
- },
76
- callData: calls,
77
- });
78
- },
79
- async getAddress() {
80
- return address;
81
- },
82
- async getFactoryArgs() {
83
- return {};
84
- },
85
- async getNonce(args) {
86
- const validatorAddress = nonceValidatorAddress;
87
- const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
88
- const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
89
- const defaultedValidationMode = '0x00';
90
- const key = (0, viem_1.concat)([
91
- (0, viem_1.toHex)(defaultedKey, { size: 3 }),
92
- defaultedValidationMode,
93
- validatorAddress,
94
- ]);
95
- return (0, utils_1.getAccountNonce)(client, {
96
- address,
97
- entryPointAddress: account_abstraction_1.entryPoint07Address,
98
- key: BigInt(key),
99
- });
100
- },
101
- async getStubSignature() {
102
- return getStubSignature();
103
- },
104
- async signMessage() {
105
- throw new Error('Not implemented');
106
- },
107
- async signTypedData() {
108
- throw new Error('Not implemented');
109
- },
110
- async signUserOperation(parameters) {
111
- const { chainId = client.chain?.id, ...userOperation } = parameters;
112
- if (!chainId)
113
- throw new Error('Chain id not found');
114
- const hash = (0, account_abstraction_1.getUserOperationHash)({
115
- userOperation: {
116
- ...userOperation,
117
- sender: userOperation.sender ?? (await this.getAddress()),
118
- signature: '0x',
119
- },
120
- entryPointAddress: account_abstraction_1.entryPoint07Address,
121
- entryPointVersion: '0.7',
122
- chainId: chainId,
123
- });
124
- return await signUserOperation(hash);
125
- },
126
- });
127
- }
128
37
  function encodeImageHash(threshold, accounts) {
129
38
  const sorted = accounts.sort((a, b) => a.account.address.toLowerCase() < b.account.address.toLowerCase() ? -1 : 1);
130
39
  let imageHash = (0, viem_1.encodePacked)(['uint256'], [BigInt(threshold)]);