@rhinestone/sdk 1.4.2 → 2.0.0-beta.0

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 (202) hide show
  1. package/README.md +89 -1
  2. package/dist/src/accounts/error.d.ts +1 -1
  3. package/dist/src/accounts/error.js +1 -19
  4. package/dist/src/accounts/index.d.ts +5 -5
  5. package/dist/src/accounts/index.js +121 -157
  6. package/dist/src/accounts/json-rpc/index.d.ts +1 -1
  7. package/dist/src/accounts/json-rpc/index.js +8 -10
  8. package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
  9. package/dist/src/accounts/json-rpc/providers.js +4 -7
  10. package/dist/src/accounts/kernel.d.ts +3 -3
  11. package/dist/src/accounts/kernel.js +66 -75
  12. package/dist/src/accounts/nexus.d.ts +3 -3
  13. package/dist/src/accounts/nexus.js +62 -73
  14. package/dist/src/accounts/passport.d.ts +3 -3
  15. package/dist/src/accounts/passport.js +9 -13
  16. package/dist/src/accounts/safe.d.ts +3 -3
  17. package/dist/src/accounts/safe.js +54 -63
  18. package/dist/src/accounts/signing/common.d.ts +10 -4
  19. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  20. package/dist/src/accounts/signing/common.js +30 -36
  21. package/dist/src/accounts/signing/message.d.ts +2 -2
  22. package/dist/src/accounts/signing/message.js +10 -12
  23. package/dist/src/accounts/signing/passkeys.js +11 -17
  24. package/dist/src/accounts/signing/typedData.d.ts +1 -1
  25. package/dist/src/accounts/signing/typedData.js +6 -8
  26. package/dist/src/accounts/startale.d.ts +3 -3
  27. package/dist/src/accounts/startale.js +37 -47
  28. package/dist/src/accounts/utils.d.ts +2 -2
  29. package/dist/src/accounts/utils.js +22 -28
  30. package/dist/src/accounts/walletClient.js +4 -8
  31. package/dist/src/actions/compact.d.ts +1 -1
  32. package/dist/src/actions/compact.js +22 -35
  33. package/dist/src/actions/deployment.d.ts +1 -1
  34. package/dist/src/actions/deployment.js +11 -13
  35. package/dist/src/actions/ecdsa.d.ts +1 -1
  36. package/dist/src/actions/ecdsa.js +14 -20
  37. package/dist/src/actions/index.d.ts +2 -2
  38. package/dist/src/actions/index.js +6 -10
  39. package/dist/src/actions/mfa.d.ts +1 -1
  40. package/dist/src/actions/mfa.js +18 -24
  41. package/dist/src/actions/passkeys.d.ts +2 -2
  42. package/dist/src/actions/passkeys.js +14 -20
  43. package/dist/src/actions/recovery.d.ts +1 -1
  44. package/dist/src/actions/recovery.js +25 -29
  45. package/dist/src/actions/smart-sessions.d.ts +1 -1
  46. package/dist/src/actions/smart-sessions.js +8 -12
  47. package/dist/src/auth/provider.d.ts +7 -0
  48. package/dist/src/auth/provider.d.ts.map +1 -0
  49. package/dist/src/auth/provider.js +38 -0
  50. package/dist/src/errors/index.d.ts +3 -3
  51. package/dist/src/errors/index.js +10 -54
  52. package/dist/src/execution/compact.d.ts +3 -3
  53. package/dist/src/execution/compact.js +10 -18
  54. package/dist/src/execution/error.js +1 -11
  55. package/dist/src/execution/index.d.ts +9 -8
  56. package/dist/src/execution/index.d.ts.map +1 -1
  57. package/dist/src/execution/index.js +54 -67
  58. package/dist/src/execution/permit2.d.ts +5 -5
  59. package/dist/src/execution/permit2.js +8 -13
  60. package/dist/src/execution/singleChainOps.d.ts +2 -2
  61. package/dist/src/execution/singleChainOps.js +1 -3
  62. package/dist/src/execution/types.d.ts +1 -1
  63. package/dist/src/execution/types.js +1 -2
  64. package/dist/src/execution/utils.d.ts +10 -6
  65. package/dist/src/execution/utils.d.ts.map +1 -1
  66. package/dist/src/execution/utils.js +159 -162
  67. package/dist/src/index.d.ts +10 -10
  68. package/dist/src/index.d.ts.map +1 -1
  69. package/dist/src/index.js +57 -67
  70. package/dist/src/jwt-server/digest.d.ts +11 -0
  71. package/dist/src/jwt-server/digest.d.ts.map +1 -0
  72. package/dist/src/jwt-server/digest.js +19 -0
  73. package/dist/src/jwt-server/express.d.ts +16 -0
  74. package/dist/src/jwt-server/express.d.ts.map +1 -0
  75. package/dist/src/jwt-server/express.js +23 -0
  76. package/dist/src/jwt-server/handlers.d.ts +10 -0
  77. package/dist/src/jwt-server/handlers.d.ts.map +1 -0
  78. package/dist/src/jwt-server/handlers.js +37 -0
  79. package/dist/src/jwt-server/index.d.ts +8 -0
  80. package/dist/src/jwt-server/index.d.ts.map +1 -0
  81. package/dist/src/jwt-server/index.js +7 -0
  82. package/dist/src/jwt-server/jcs.d.ts +12 -0
  83. package/dist/src/jwt-server/jcs.d.ts.map +1 -0
  84. package/dist/src/jwt-server/jcs.js +57 -0
  85. package/dist/src/jwt-server/signer.d.ts +18 -0
  86. package/dist/src/jwt-server/signer.d.ts.map +1 -0
  87. package/dist/src/jwt-server/signer.js +68 -0
  88. package/dist/src/jwt-server/sponsorship.d.ts +19 -0
  89. package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
  90. package/dist/src/jwt-server/sponsorship.js +51 -0
  91. package/dist/src/jwt-server/web.d.ts +4 -0
  92. package/dist/src/jwt-server/web.d.ts.map +1 -0
  93. package/dist/src/jwt-server/web.js +23 -0
  94. package/dist/src/modules/abi/smart-session-emissary.js +1 -3
  95. package/dist/src/modules/abi/smart-sessions.js +1 -4
  96. package/dist/src/modules/chain-abstraction.js +1 -5
  97. package/dist/src/modules/common.d.ts +1 -1
  98. package/dist/src/modules/common.js +1 -13
  99. package/dist/src/modules/index.d.ts +5 -5
  100. package/dist/src/modules/index.js +35 -50
  101. package/dist/src/modules/legacy.d.ts +2 -2
  102. package/dist/src/modules/legacy.js +11 -14
  103. package/dist/src/modules/read.d.ts +1 -1
  104. package/dist/src/modules/read.js +11 -15
  105. package/dist/src/modules/validators/core.d.ts +2 -2
  106. package/dist/src/modules/validators/core.js +26 -44
  107. package/dist/src/modules/validators/index.d.ts +2 -2
  108. package/dist/src/modules/validators/index.js +3 -19
  109. package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
  110. package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
  111. package/dist/src/modules/validators/policies/claim/types.js +11 -14
  112. package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
  113. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
  114. package/dist/src/modules/validators/smart-sessions.js +77 -97
  115. package/dist/src/orchestrator/client.d.ts +10 -5
  116. package/dist/src/orchestrator/client.d.ts.map +1 -1
  117. package/dist/src/orchestrator/client.js +73 -66
  118. package/dist/src/orchestrator/consts.d.ts +1 -1
  119. package/dist/src/orchestrator/consts.d.ts.map +1 -1
  120. package/dist/src/orchestrator/consts.js +2 -8
  121. package/dist/src/orchestrator/error.js +1 -33
  122. package/dist/src/orchestrator/index.d.ts +8 -7
  123. package/dist/src/orchestrator/index.d.ts.map +1 -1
  124. package/dist/src/orchestrator/index.js +8 -57
  125. package/dist/src/orchestrator/registry.d.ts +2 -2
  126. package/dist/src/orchestrator/registry.js +19 -33
  127. package/dist/src/orchestrator/types.d.ts +5 -1
  128. package/dist/src/orchestrator/types.d.ts.map +1 -1
  129. package/dist/src/orchestrator/types.js +1 -17
  130. package/dist/src/orchestrator/utils.js +1 -3
  131. package/dist/src/types.d.ts +29 -5
  132. package/dist/src/types.d.ts.map +1 -1
  133. package/dist/src/types.js +1 -2
  134. package/dist/src/utils/index.d.ts +2 -2
  135. package/dist/src/utils/index.js +9 -15
  136. package/package.json +29 -98
  137. package/dist/src/accounts/index.test.d.ts +0 -2
  138. package/dist/src/accounts/index.test.d.ts.map +0 -1
  139. package/dist/src/accounts/index.test.js +0 -33
  140. package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
  141. package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
  142. package/dist/src/accounts/json-rpc/index.test.js +0 -35
  143. package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
  144. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
  145. package/dist/src/accounts/json-rpc/providers.test.js +0 -43
  146. package/dist/src/accounts/kernel.test.d.ts +0 -2
  147. package/dist/src/accounts/kernel.test.d.ts.map +0 -1
  148. package/dist/src/accounts/kernel.test.js +0 -132
  149. package/dist/src/accounts/nexus.test.d.ts +0 -2
  150. package/dist/src/accounts/nexus.test.d.ts.map +0 -1
  151. package/dist/src/accounts/nexus.test.js +0 -118
  152. package/dist/src/accounts/safe.test.d.ts +0 -2
  153. package/dist/src/accounts/safe.test.d.ts.map +0 -1
  154. package/dist/src/accounts/safe.test.js +0 -168
  155. package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
  156. package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
  157. package/dist/src/accounts/signing/passkeys.test.js +0 -88
  158. package/dist/src/accounts/startale.test.d.ts +0 -2
  159. package/dist/src/accounts/startale.test.d.ts.map +0 -1
  160. package/dist/src/accounts/startale.test.js +0 -189
  161. package/dist/src/accounts/utils.test.d.ts +0 -2
  162. package/dist/src/accounts/utils.test.d.ts.map +0 -1
  163. package/dist/src/accounts/utils.test.js +0 -49
  164. package/dist/src/actions/ecdsa.test.d.ts +0 -2
  165. package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
  166. package/dist/src/actions/ecdsa.test.js +0 -99
  167. package/dist/src/actions/passkeys.test.d.ts +0 -2
  168. package/dist/src/actions/passkeys.test.d.ts.map +0 -1
  169. package/dist/src/actions/passkeys.test.js +0 -54
  170. package/dist/src/actions/recovery.test.d.ts +0 -2
  171. package/dist/src/actions/recovery.test.d.ts.map +0 -1
  172. package/dist/src/actions/recovery.test.js +0 -168
  173. package/dist/src/execution/signing.test.d.ts +0 -2
  174. package/dist/src/execution/signing.test.d.ts.map +0 -1
  175. package/dist/src/execution/signing.test.js +0 -465
  176. package/dist/src/execution/utils.test.d.ts +0 -2
  177. package/dist/src/execution/utils.test.d.ts.map +0 -1
  178. package/dist/src/execution/utils.test.js +0 -388
  179. package/dist/src/modules/index.test.d.ts +0 -2
  180. package/dist/src/modules/index.test.d.ts.map +0 -1
  181. package/dist/src/modules/index.test.js +0 -81
  182. package/dist/src/modules/validators/core.test.d.ts +0 -2
  183. package/dist/src/modules/validators/core.test.d.ts.map +0 -1
  184. package/dist/src/modules/validators/core.test.js +0 -101
  185. package/dist/src/modules/validators/policies/claim/permit2.test.d.ts +0 -2
  186. package/dist/src/modules/validators/policies/claim/permit2.test.d.ts.map +0 -1
  187. package/dist/src/modules/validators/policies/claim/permit2.test.js +0 -519
  188. package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
  189. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
  190. package/dist/src/modules/validators/smart-sessions.test.js +0 -311
  191. package/dist/src/orchestrator/registry.test.d.ts +0 -2
  192. package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
  193. package/dist/src/orchestrator/registry.test.js +0 -154
  194. package/dist/src/utils/index.test.d.ts +0 -2
  195. package/dist/src/utils/index.test.d.ts.map +0 -1
  196. package/dist/src/utils/index.test.js +0 -42
  197. package/dist/test/consts.d.ts +0 -10
  198. package/dist/test/consts.d.ts.map +0 -1
  199. package/dist/test/consts.js +0 -22
  200. package/dist/test/utils/utils.d.ts +0 -5
  201. package/dist/test/utils/utils.d.ts.map +0 -1
  202. package/dist/test/utils/utils.js +0 -20
@@ -1,23 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEip712Domain = getEip712Domain;
4
- exports.getInstallData = getInstallData;
5
- exports.getAddress = getAddress;
6
- exports.getDefaultValidatorAddress = getDefaultValidatorAddress;
7
- exports.packSignature = packSignature;
8
- exports.getDeployArgs = getDeployArgs;
9
- exports.getSmartAccount = getSmartAccount;
10
- exports.getGuardianSmartAccount = getGuardianSmartAccount;
11
- exports.signEip7702InitData = signEip7702InitData;
12
- exports.getEip7702InitCall = getEip7702InitCall;
13
- const viem_1 = require("viem");
14
- const account_abstraction_1 = require("viem/account-abstraction");
15
- const modules_1 = require("../modules");
16
- const validators_1 = require("../modules/validators");
17
- const core_1 = require("../modules/validators/core");
18
- const error_1 = require("./error");
19
- const utils_1 = require("./utils");
20
- const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
1
+ import { concat, decodeFunctionData, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, parseAbi, size, toHex, zeroAddress, zeroHash, } from 'viem';
2
+ import { entryPoint07Abi, entryPoint07Address, getUserOperationHash, toSmartAccount, } from 'viem/account-abstraction';
3
+ import { getSetup as getModuleSetup } from '../modules/index.js';
4
+ import { getMockSignature } from '../modules/validators/index.js';
5
+ import { OWNABLE_VALIDATOR_ADDRESS } from '../modules/validators/core.js';
6
+ import { AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, SigningNotSupportedForAccountError, } from './error.js';
7
+ import { encode7579Calls, getAccountNonce } from './utils.js';
8
+ const NEXUS_DEFAULT_VALIDATOR_ADDRESS = OWNABLE_VALIDATOR_ADDRESS;
21
9
  const NEXUS_VERSION = '1.2.0';
22
10
  const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000000032ddc454c3bdcba80484ad5a798705';
23
11
  const NEXUS_FACTORY_ADDRESS = '0x0000000000679a258c64d2f20f310e12b64b7375';
@@ -40,21 +28,21 @@ function getDeployArgs(config) {
40
28
  if (v0Result) {
41
29
  return v0Result;
42
30
  }
43
- throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data: unrecognized schema', 'nexus');
31
+ throw new AccountConfigurationNotSupportedError('Invalid factory data: unrecognized schema', 'nexus');
44
32
  }
45
33
  const account = config.account;
46
- const defaultSalt = (0, viem_1.keccak256)('0x');
34
+ const defaultSalt = keccak256('0x');
47
35
  const salt = account?.salt ?? defaultSalt;
48
- const moduleSetup = (0, modules_1.getSetup)(config);
36
+ const moduleSetup = getModuleSetup(config);
49
37
  // Filter out the default validator
50
38
  const defaultValidator = moduleSetup.validators.find((v) => v.address === NEXUS_DEFAULT_VALIDATOR_ADDRESS);
51
39
  const defaultValidatorInitData = defaultValidator
52
40
  ? defaultValidator.initData
53
41
  : '0x';
54
42
  const validators = moduleSetup.validators.filter((v) => v.address !== NEXUS_DEFAULT_VALIDATOR_ADDRESS);
55
- const bootstrapData = (0, viem_1.size)(defaultValidatorInitData)
56
- ? (0, viem_1.encodeFunctionData)({
57
- abi: (0, viem_1.parseAbi)([
43
+ const bootstrapData = size(defaultValidatorInitData)
44
+ ? encodeFunctionData({
45
+ abi: parseAbi([
58
46
  'struct BootstrapConfig {address module;bytes initData;}',
59
47
  'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
60
48
  'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
@@ -71,7 +59,7 @@ function getDeployArgs(config) {
71
59
  initData: e.initData,
72
60
  })),
73
61
  {
74
- module: viem_1.zeroAddress,
62
+ module: zeroAddress,
75
63
  initData: '0x',
76
64
  },
77
65
  moduleSetup.fallbacks.map((f) => ({
@@ -81,8 +69,8 @@ function getDeployArgs(config) {
81
69
  [],
82
70
  ],
83
71
  })
84
- : (0, viem_1.encodeFunctionData)({
85
- abi: (0, viem_1.parseAbi)([
72
+ : encodeFunctionData({
73
+ abi: parseAbi([
86
74
  'struct BootstrapConfig {address module;bytes initData;}',
87
75
  'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
88
76
  'function initNexusNoRegistry(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
@@ -98,7 +86,7 @@ function getDeployArgs(config) {
98
86
  initData: e.initData,
99
87
  })),
100
88
  {
101
- module: viem_1.zeroAddress,
89
+ module: zeroAddress,
102
90
  initData: '0x',
103
91
  },
104
92
  moduleSetup.fallbacks.map((f) => ({
@@ -108,14 +96,14 @@ function getDeployArgs(config) {
108
96
  [],
109
97
  ],
110
98
  });
111
- const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_ADDRESS, bootstrapData]);
112
- const factoryData = (0, viem_1.encodeFunctionData)({
113
- abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
99
+ const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_ADDRESS, bootstrapData]);
100
+ const factoryData = encodeFunctionData({
101
+ abi: parseAbi(['function createAccount(bytes,bytes32)']),
114
102
  functionName: 'createAccount',
115
103
  args: [initData, salt],
116
104
  });
117
- const initializationCallData = (0, viem_1.encodeFunctionData)({
118
- abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
105
+ const initializationCallData = encodeFunctionData({
106
+ abi: parseAbi(['function initializeAccount(bytes)']),
119
107
  functionName: 'initializeAccount',
120
108
  args: [initData],
121
109
  });
@@ -141,7 +129,7 @@ function getAddress(config) {
141
129
  ? NEXUS_CREATION_CODE
142
130
  : '0x603d3d8160223d3973000000039dfcad030719b07296710f045f0558f760095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
143
131
  const accountInitData = factory.toLowerCase() === NEXUS_FACTORY_ADDRESS
144
- ? (0, viem_1.encodeAbiParameters)([
132
+ ? encodeAbiParameters([
145
133
  {
146
134
  name: 'address',
147
135
  type: 'address',
@@ -152,28 +140,28 @@ function getAddress(config) {
152
140
  },
153
141
  ], [implementation, initializationCallData])
154
142
  : '0x';
155
- const address = (0, viem_1.getContractAddress)({
143
+ const address = getContractAddress({
156
144
  opcode: 'CREATE2',
157
145
  from: factory,
158
146
  salt,
159
- bytecode: (0, viem_1.concat)([creationCode, accountInitData]),
147
+ bytecode: concat([creationCode, accountInitData]),
160
148
  });
161
149
  return address;
162
150
  }
163
151
  function getEip712Domain(config, chain) {
164
152
  if (config.initData) {
165
- throw new error_1.Eip712DomainNotAvailableError('Existing Nexus accounts are not yet supported');
153
+ throw new Eip712DomainNotAvailableError('Existing Nexus accounts are not yet supported');
166
154
  }
167
155
  return {
168
156
  name: 'Nexus',
169
157
  version: NEXUS_VERSION,
170
158
  chainId: chain.id,
171
159
  verifyingContract: getAddress(config),
172
- salt: viem_1.zeroHash,
160
+ salt: zeroHash,
173
161
  };
174
162
  }
175
163
  function getInstallData(module) {
176
- return (0, viem_1.encodeFunctionData)({
164
+ return encodeFunctionData({
177
165
  abi: [
178
166
  {
179
167
  type: 'function',
@@ -217,36 +205,36 @@ function getDefaultValidatorAddress(version) {
217
205
  }
218
206
  async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
219
207
  const validatorAddress = validator.address === defaultValidatorAddress
220
- ? viem_1.zeroAddress
208
+ ? zeroAddress
221
209
  : validator.address;
222
- const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
210
+ const packedSig = encodePacked(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
223
211
  return packedSig;
224
212
  }
225
213
  async function getSmartAccount(client, address, owners, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
226
214
  return getBaseSmartAccount(address, client, validatorAddress, async () => {
227
- return (0, validators_1.getMockSignature)(owners);
215
+ return getMockSignature(owners);
228
216
  }, sign, defaultValidatorAddress);
229
217
  }
230
218
  async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
231
219
  return await getBaseSmartAccount(address, client, validatorAddress, async () => {
232
- return (0, validators_1.getMockSignature)(guardians);
220
+ return getMockSignature(guardians);
233
221
  }, async (hash) => {
234
222
  return await sign(hash);
235
223
  }, defaultValidatorAddress);
236
224
  }
237
225
  async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
238
- return await (0, account_abstraction_1.toSmartAccount)({
226
+ return await toSmartAccount({
239
227
  client,
240
228
  entryPoint: {
241
- abi: account_abstraction_1.entryPoint07Abi,
242
- address: account_abstraction_1.entryPoint07Address,
229
+ abi: entryPoint07Abi,
230
+ address: entryPoint07Address,
243
231
  version: '0.7',
244
232
  },
245
233
  async decodeCalls() {
246
234
  throw new Error('Not implemented');
247
235
  },
248
236
  async encodeCalls(calls) {
249
- return (0, utils_1.encode7579Calls)({
237
+ return encode7579Calls({
250
238
  mode: {
251
239
  type: calls.length > 1 ? 'batchcall' : 'call',
252
240
  revertOnError: false,
@@ -264,19 +252,19 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
264
252
  },
265
253
  async getNonce(args) {
266
254
  const validatorAddress = nonceValidatorAddress === defaultValidatorAddress
267
- ? viem_1.zeroAddress
255
+ ? zeroAddress
268
256
  : nonceValidatorAddress;
269
257
  const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
270
258
  const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
271
259
  const defaultedValidationMode = '0x00';
272
- const key = (0, viem_1.concat)([
273
- (0, viem_1.toHex)(defaultedKey, { size: 3 }),
260
+ const key = concat([
261
+ toHex(defaultedKey, { size: 3 }),
274
262
  defaultedValidationMode,
275
263
  validatorAddress,
276
264
  ]);
277
- return (0, utils_1.getAccountNonce)(client, {
265
+ return getAccountNonce(client, {
278
266
  address,
279
- entryPointAddress: account_abstraction_1.entryPoint07Address,
267
+ entryPointAddress: entryPoint07Address,
280
268
  key: BigInt(key),
281
269
  });
282
270
  },
@@ -293,13 +281,13 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
293
281
  const { chainId = client.chain?.id, ...userOperation } = parameters;
294
282
  if (!chainId)
295
283
  throw new Error('Chain id not found');
296
- const hash = (0, account_abstraction_1.getUserOperationHash)({
284
+ const hash = getUserOperationHash({
297
285
  userOperation: {
298
286
  ...userOperation,
299
287
  sender: userOperation.sender ?? (await this.getAddress()),
300
288
  signature: '0x',
301
289
  },
302
- entryPointAddress: account_abstraction_1.entryPoint07Address,
290
+ entryPointAddress: entryPoint07Address,
303
291
  entryPointVersion: '0.7',
304
292
  chainId: chainId,
305
293
  });
@@ -314,7 +302,7 @@ async function signEip7702InitData(config, eoa) {
314
302
  }
315
303
  const { initData } = deployArgs;
316
304
  if (!eoa.signTypedData) {
317
- throw new error_1.SigningNotSupportedForAccountError();
305
+ throw new SigningNotSupportedForAccountError();
318
306
  }
319
307
  const signature = await eoa.signTypedData({
320
308
  domain: {
@@ -342,7 +330,7 @@ function getEip7702InitCall(config, signature) {
342
330
  const chainIds = [0n];
343
331
  const chainIdIndex = 0n;
344
332
  const chainIdsLength = 1n;
345
- const encodedData = (0, viem_1.encodePacked)(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
333
+ const encodedData = encodePacked(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
346
334
  return encodedData;
347
335
  }
348
336
  const deployArgs = getDeployArgs(config);
@@ -351,8 +339,8 @@ function getEip7702InitCall(config, signature) {
351
339
  }
352
340
  const { initData } = deployArgs;
353
341
  const encodedData = getEncodedData(initData);
354
- const accountFullData = (0, viem_1.concat)([signature, encodedData]);
355
- const accountInitCallData = (0, viem_1.encodeFunctionData)({
342
+ const accountFullData = concat([signature, encodedData]);
343
+ const accountInitCallData = encodeFunctionData({
356
344
  abi: [
357
345
  {
358
346
  type: 'function',
@@ -377,14 +365,14 @@ function getEip7702InitCall(config, signature) {
377
365
  }
378
366
  function tryDecodeV1FactoryData(factory, factoryData) {
379
367
  try {
380
- const decoded = (0, viem_1.decodeFunctionData)({
381
- abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
368
+ const decoded = decodeFunctionData({
369
+ abi: parseAbi(['function createAccount(bytes,bytes32)']),
382
370
  data: factoryData,
383
371
  });
384
372
  const initData = decoded.args[0];
385
373
  const salt = decoded.args[1];
386
- const initializationCallData = (0, viem_1.encodeFunctionData)({
387
- abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
374
+ const initializationCallData = encodeFunctionData({
375
+ abi: parseAbi(['function initializeAccount(bytes)']),
388
376
  functionName: 'initializeAccount',
389
377
  args: [initData],
390
378
  });
@@ -406,8 +394,8 @@ function tryDecodeV1FactoryData(factory, factoryData) {
406
394
  }
407
395
  function tryDecodeV0FactoryData(factory, factoryData) {
408
396
  try {
409
- const decoded = (0, viem_1.decodeFunctionData)({
410
- abi: (0, viem_1.parseAbi)([
397
+ const decoded = decodeFunctionData({
398
+ abi: parseAbi([
411
399
  'function createAccount(address eoaOwner,uint256 index,address[] attesters,uint8 threshold)',
412
400
  ]),
413
401
  data: factoryData,
@@ -416,21 +404,21 @@ function tryDecodeV0FactoryData(factory, factoryData) {
416
404
  const index = decoded.args[1];
417
405
  const attesters = decoded.args[2];
418
406
  const threshold = decoded.args[3];
419
- const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
407
+ const salt = keccak256(encodePacked(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
420
408
  const implementation = factory.toLowerCase() === NEXUS_FACTORY_ADDRESS
421
409
  ? NEXUS_IMPLEMENTATION_ADDRESS
422
410
  : NEXUS_IMPLEMENTATION_1_0_0;
423
- const registry = viem_1.zeroAddress;
424
- const bootstrapData = (0, viem_1.encodeFunctionData)({
425
- abi: (0, viem_1.parseAbi)([
411
+ const registry = zeroAddress;
412
+ const bootstrapData = encodeFunctionData({
413
+ abi: parseAbi([
426
414
  'function initNexusWithSingleValidator(address validator,bytes data,address registry,address[] attesters,uint8 threshold)',
427
415
  ]),
428
416
  functionName: 'initNexusWithSingleValidator',
429
417
  args: [NEXUS_K1_VALIDATOR, owner, registry, attesters, threshold],
430
418
  });
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)']),
419
+ const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_1_0_0, bootstrapData]);
420
+ const initializationCallData = encodeFunctionData({
421
+ abi: parseAbi(['function initializeAccount(bytes)']),
434
422
  functionName: 'initializeAccount',
435
423
  args: [initData],
436
424
  });
@@ -453,3 +441,4 @@ function tryDecodeV0FactoryData(factory, factoryData) {
453
441
  function isAbiDecodingError(error) {
454
442
  return (error instanceof Error && error.name === 'AbiFunctionSignatureNotFoundError');
455
443
  }
444
+ export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
@@ -1,7 +1,7 @@
1
1
  import type { Hex } from 'viem';
2
- import type { Module } from '../modules/common';
3
- import type { RhinestoneAccountConfig } from '../types';
4
- import type { ValidatorConfig } from './utils';
2
+ import type { Module } from '../modules/common.js';
3
+ import type { RhinestoneAccountConfig } from '../types.js';
4
+ import type { ValidatorConfig } from './utils.js';
5
5
  declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
6
6
  declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
7
7
  declare function getInstallData(module: Module): `0x${string}`;
@@ -1,9 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAddress = getAddress;
4
- exports.packSignature = packSignature;
5
- exports.getInstallData = getInstallData;
6
- const viem_1 = require("viem");
1
+ import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, padHex, } from 'viem';
7
2
  const CREATION_CODE = '0x6054600f3d396034805130553df3fe63906111273d3560e01c14602b57363d3d373d3d3d3d369030545af43d82803e156027573d90f35b3d90fd5b30543d5260203df3';
8
3
  const PASSPORT_FACTORY_ADDRESS = '0xd70c6386ca012cdeb249b4e46c53d3507d9cbb87';
9
4
  const PASSPORT_MAIN_MODULE = '0x0d1bf2f4ab334324665aeb8d481ff92cde289439';
@@ -20,25 +15,25 @@ function getAddress(config) {
20
15
  account: owner,
21
16
  }));
22
17
  const salt = encodeImageHash(owners.threshold ?? 1, ownerAccounts);
23
- const accountInitData = (0, viem_1.padHex)(PASSPORT_MAIN_MODULE, { size: 32 });
24
- const address = (0, viem_1.getContractAddress)({
18
+ const accountInitData = padHex(PASSPORT_MAIN_MODULE, { size: 32 });
19
+ const address = getContractAddress({
25
20
  opcode: 'CREATE2',
26
21
  from: PASSPORT_FACTORY_ADDRESS,
27
22
  salt,
28
- bytecode: (0, viem_1.concat)([CREATION_CODE, accountInitData]),
23
+ bytecode: concat([CREATION_CODE, accountInitData]),
29
24
  });
30
25
  return address;
31
26
  }
32
27
  async function packSignature(signature, validator, transformSignature = (signature) => signature) {
33
28
  const validatorAddress = validator.address;
34
- const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
29
+ const packedSig = encodePacked(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
35
30
  return packedSig;
36
31
  }
37
32
  function encodeImageHash(threshold, accounts) {
38
33
  const sorted = accounts.sort((a, b) => a.account.address.toLowerCase() < b.account.address.toLowerCase() ? -1 : 1);
39
- let imageHash = (0, viem_1.encodePacked)(['uint256'], [BigInt(threshold)]);
34
+ let imageHash = encodePacked(['uint256'], [BigInt(threshold)]);
40
35
  for (const account of sorted) {
41
- imageHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
36
+ imageHash = keccak256(encodeAbiParameters([
42
37
  {
43
38
  type: 'bytes32',
44
39
  },
@@ -53,7 +48,7 @@ function encodeImageHash(threshold, accounts) {
53
48
  return imageHash;
54
49
  }
55
50
  function getInstallData(module) {
56
- return (0, viem_1.encodeFunctionData)({
51
+ return encodeFunctionData({
57
52
  abi: [
58
53
  {
59
54
  type: 'function',
@@ -80,3 +75,4 @@ function getInstallData(module) {
80
75
  args: [module.type, module.address, module.initData],
81
76
  });
82
77
  }
78
+ export { getAddress, packSignature, getInstallData };
@@ -1,8 +1,8 @@
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
- import type { Module } from '../modules/common';
4
- import type { OwnerSet, RhinestoneAccountConfig } from '../types';
5
- import { type ValidatorConfig } from './utils';
3
+ import type { Module } from '../modules/common.js';
4
+ import type { OwnerSet, RhinestoneAccountConfig } from '../types.js';
5
+ import { type ValidatorConfig } from './utils.js';
6
6
  declare function getDeployArgs(config: RhinestoneAccountConfig): {
7
7
  factory: `0x${string}`;
8
8
  factoryData: `0x${string}`;