@rhinestone/sdk 1.5.1 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +1 -1
  2. package/dist/src/accounts/error.d.ts +1 -1
  3. package/dist/src/accounts/error.js +1 -19
  4. package/dist/src/accounts/index.d.ts +5 -5
  5. package/dist/src/accounts/index.js +121 -157
  6. package/dist/src/accounts/json-rpc/index.d.ts +1 -1
  7. package/dist/src/accounts/json-rpc/index.js +8 -10
  8. package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
  9. package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
  10. package/dist/src/accounts/json-rpc/providers.js +7 -9
  11. package/dist/src/accounts/kernel.d.ts +3 -3
  12. package/dist/src/accounts/kernel.js +66 -75
  13. package/dist/src/accounts/nexus.d.ts +3 -3
  14. package/dist/src/accounts/nexus.js +62 -73
  15. package/dist/src/accounts/passport.d.ts +3 -3
  16. package/dist/src/accounts/passport.js +9 -13
  17. package/dist/src/accounts/safe.d.ts +3 -3
  18. package/dist/src/accounts/safe.js +54 -63
  19. package/dist/src/accounts/signing/common.d.ts +2 -2
  20. package/dist/src/accounts/signing/common.js +30 -36
  21. package/dist/src/accounts/signing/message.d.ts +2 -2
  22. package/dist/src/accounts/signing/message.js +10 -12
  23. package/dist/src/accounts/signing/passkeys.js +11 -17
  24. package/dist/src/accounts/signing/typedData.d.ts +1 -1
  25. package/dist/src/accounts/signing/typedData.js +6 -8
  26. package/dist/src/accounts/startale.d.ts +3 -3
  27. package/dist/src/accounts/startale.js +37 -47
  28. package/dist/src/accounts/utils.d.ts +2 -2
  29. package/dist/src/accounts/utils.js +22 -28
  30. package/dist/src/accounts/walletClient.js +4 -8
  31. package/dist/src/actions/compact.d.ts +1 -1
  32. package/dist/src/actions/compact.js +22 -35
  33. package/dist/src/actions/deployment.d.ts +1 -1
  34. package/dist/src/actions/deployment.js +11 -13
  35. package/dist/src/actions/ecdsa.d.ts +1 -1
  36. package/dist/src/actions/ecdsa.js +14 -20
  37. package/dist/src/actions/index.d.ts +2 -2
  38. package/dist/src/actions/index.js +6 -10
  39. package/dist/src/actions/mfa.d.ts +1 -1
  40. package/dist/src/actions/mfa.js +18 -24
  41. package/dist/src/actions/passkeys.d.ts +2 -2
  42. package/dist/src/actions/passkeys.js +14 -20
  43. package/dist/src/actions/recovery.d.ts +1 -1
  44. package/dist/src/actions/recovery.js +25 -29
  45. package/dist/src/actions/smart-sessions.d.ts +1 -1
  46. package/dist/src/actions/smart-sessions.js +8 -12
  47. package/dist/src/auth/provider.d.ts +1 -1
  48. package/dist/src/auth/provider.js +1 -4
  49. package/dist/src/errors/index.d.ts +4 -4
  50. package/dist/src/errors/index.d.ts.map +1 -1
  51. package/dist/src/errors/index.js +12 -54
  52. package/dist/src/execution/compact.d.ts +1 -144
  53. package/dist/src/execution/compact.d.ts.map +1 -1
  54. package/dist/src/execution/compact.js +1 -117
  55. package/dist/src/execution/error.d.ts +10 -1
  56. package/dist/src/execution/error.d.ts.map +1 -1
  57. package/dist/src/execution/error.js +9 -11
  58. package/dist/src/execution/index.d.ts +10 -11
  59. package/dist/src/execution/index.d.ts.map +1 -1
  60. package/dist/src/execution/index.js +64 -75
  61. package/dist/src/execution/permit2.d.ts +2 -138
  62. package/dist/src/execution/permit2.d.ts.map +1 -1
  63. package/dist/src/execution/permit2.js +5 -239
  64. package/dist/src/execution/utils.d.ts +31 -15
  65. package/dist/src/execution/utils.d.ts.map +1 -1
  66. package/dist/src/execution/utils.js +283 -256
  67. package/dist/src/index.d.ts +15 -14
  68. package/dist/src/index.d.ts.map +1 -1
  69. package/dist/src/index.js +57 -68
  70. package/dist/src/jwt-server/digest.js +3 -6
  71. package/dist/src/jwt-server/express.d.ts +1 -1
  72. package/dist/src/jwt-server/express.d.ts.map +1 -1
  73. package/dist/src/jwt-server/express.js +6 -7
  74. package/dist/src/jwt-server/handlers.d.ts +1 -1
  75. package/dist/src/jwt-server/handlers.js +7 -11
  76. package/dist/src/jwt-server/index.d.ts +7 -7
  77. package/dist/src/jwt-server/index.js +6 -17
  78. package/dist/src/jwt-server/jcs.js +1 -4
  79. package/dist/src/jwt-server/signer.d.ts +1 -1
  80. package/dist/src/jwt-server/signer.js +10 -13
  81. package/dist/src/jwt-server/sponsorship.js +2 -7
  82. package/dist/src/jwt-server/web.d.ts +1 -1
  83. package/dist/src/jwt-server/web.js +5 -9
  84. package/dist/src/modules/abi/smart-session-emissary.js +1 -3
  85. package/dist/src/modules/abi/smart-sessions.js +1 -4
  86. package/dist/src/modules/chain-abstraction.js +1 -5
  87. package/dist/src/modules/common.d.ts +1 -1
  88. package/dist/src/modules/common.js +1 -13
  89. package/dist/src/modules/index.d.ts +5 -5
  90. package/dist/src/modules/index.js +35 -50
  91. package/dist/src/modules/legacy.d.ts +2 -2
  92. package/dist/src/modules/legacy.js +11 -14
  93. package/dist/src/modules/read.d.ts +1 -1
  94. package/dist/src/modules/read.js +11 -15
  95. package/dist/src/modules/validators/core.d.ts +2 -2
  96. package/dist/src/modules/validators/core.js +26 -44
  97. package/dist/src/modules/validators/index.d.ts +2 -2
  98. package/dist/src/modules/validators/index.js +3 -19
  99. package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
  100. package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
  101. package/dist/src/modules/validators/policies/claim/types.js +11 -14
  102. package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
  103. package/dist/src/modules/validators/smart-sessions.js +65 -94
  104. package/dist/src/orchestrator/caip2.d.ts +7 -0
  105. package/dist/src/orchestrator/caip2.d.ts.map +1 -0
  106. package/dist/src/orchestrator/caip2.js +17 -0
  107. package/dist/src/orchestrator/client.d.ts +12 -12
  108. package/dist/src/orchestrator/client.d.ts.map +1 -1
  109. package/dist/src/orchestrator/client.js +199 -305
  110. package/dist/src/orchestrator/consts.d.ts +2 -2
  111. package/dist/src/orchestrator/consts.d.ts.map +1 -1
  112. package/dist/src/orchestrator/consts.js +3 -9
  113. package/dist/src/orchestrator/error.d.ts +72 -217
  114. package/dist/src/orchestrator/error.d.ts.map +1 -1
  115. package/dist/src/orchestrator/error.js +117 -227
  116. package/dist/src/orchestrator/index.d.ts +9 -9
  117. package/dist/src/orchestrator/index.d.ts.map +1 -1
  118. package/dist/src/orchestrator/index.js +7 -56
  119. package/dist/src/orchestrator/registry.d.ts +2 -2
  120. package/dist/src/orchestrator/registry.js +19 -33
  121. package/dist/src/orchestrator/types.d.ts +97 -232
  122. package/dist/src/orchestrator/types.d.ts.map +1 -1
  123. package/dist/src/orchestrator/types.js +1 -17
  124. package/dist/src/orchestrator/utils.js +1 -3
  125. package/dist/src/types.d.ts +5 -7
  126. package/dist/src/types.d.ts.map +1 -1
  127. package/dist/src/types.js +1 -2
  128. package/dist/src/utils/index.d.ts +2 -2
  129. package/dist/src/utils/index.js +9 -15
  130. package/package.json +15 -98
  131. package/dist/src/execution/singleChainOps.d.ts +0 -41
  132. package/dist/src/execution/singleChainOps.d.ts.map +0 -1
  133. package/dist/src/execution/singleChainOps.js +0 -44
  134. package/dist/src/execution/types.d.ts +0 -36
  135. package/dist/src/execution/types.d.ts.map +0 -1
  136. package/dist/src/execution/types.js +0 -2
@@ -1,20 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEip712Domain = getEip712Domain;
4
- exports.getInstallData = getInstallData;
5
- exports.getAddress = getAddress;
6
- exports.packSignature = packSignature;
7
- exports.getDeployArgs = getDeployArgs;
8
- exports.getV0DeployArgs = getV0DeployArgs;
9
- exports.getSmartAccount = getSmartAccount;
10
- exports.getGuardianSmartAccount = getGuardianSmartAccount;
11
- const viem_1 = require("viem");
12
- const account_abstraction_1 = require("viem/account-abstraction");
13
- const modules_1 = require("../modules");
14
- const legacy_1 = require("../modules/legacy");
15
- const validators_1 = require("../modules/validators");
16
- const error_1 = require("./error");
17
- const utils_1 = require("./utils");
1
+ import { concat, decodeFunctionData, encodeAbiParameters, encodeFunctionData, encodePacked, getContractAddress, keccak256, parseAbi, parseAbiParameters, 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 { getV0Attesters, getV0Setup as getV0ModuleSetup, } from '../modules/legacy.js';
5
+ import { getMockSignature } from '../modules/validators/index.js';
6
+ import { AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, OwnersFieldRequiredError, } from './error.js';
7
+ import { encode7579Calls, getAccountNonce } from './utils.js';
18
8
  const SAFE_7579_LAUNCHPAD_V2_ADDRESS = '0x75798463024bda64d83c94a64bc7d7eab41300ef';
19
9
  const SAFE_7579_ADAPTER_V2_ADDRESS = '0x7579f2ad53b01c3d8779fe17928e0d48885b0003';
20
10
  const SAFE_7579_LAUNCHPAD_V1_ADDRESS = '0x7579011ab74c46090561ea277ba79d510c6c00ff';
@@ -28,19 +18,19 @@ function getDeployArgs(config) {
28
18
  if (!('factory' in config.initData)) {
29
19
  return null;
30
20
  }
31
- const factoryData = (0, viem_1.decodeFunctionData)({
32
- abi: (0, viem_1.parseAbi)([
21
+ const factoryData = decodeFunctionData({
22
+ abi: parseAbi([
33
23
  'function createProxyWithNonce(address singleton,bytes calldata initializer,uint256 saltNonce) external payable returns (address)',
34
24
  ]),
35
25
  data: config.initData.factoryData,
36
26
  });
37
27
  if (factoryData.functionName !== 'createProxyWithNonce') {
38
- throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data', 'safe');
28
+ throw new AccountConfigurationNotSupportedError('Invalid factory data', 'safe');
39
29
  }
40
30
  const implementation = factoryData.args[0];
41
31
  const initData = factoryData.args[1];
42
32
  const saltNonce = factoryData.args[2];
43
- const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32', 'uint256'], [(0, viem_1.keccak256)(initData), saltNonce]));
33
+ const salt = keccak256(encodePacked(['bytes32', 'uint256'], [keccak256(initData), saltNonce]));
44
34
  return {
45
35
  factory: config.initData.factory,
46
36
  factoryData: config.initData.factoryData,
@@ -51,7 +41,7 @@ function getDeployArgs(config) {
51
41
  }
52
42
  const owners = getOwners(config);
53
43
  const threshold = getThreshold(config);
54
- const moduleSetup = (0, modules_1.getSetup)(config);
44
+ const moduleSetup = getModuleSetup(config);
55
45
  const modules = [
56
46
  ...moduleSetup.validators,
57
47
  ...moduleSetup.executors,
@@ -60,8 +50,8 @@ function getDeployArgs(config) {
60
50
  ];
61
51
  const adapter = SAFE_7579_ADAPTER_V2_ADDRESS;
62
52
  const launchpad = SAFE_7579_LAUNCHPAD_V2_ADDRESS;
63
- const calldata = (0, viem_1.encodeFunctionData)({
64
- abi: (0, viem_1.parseAbi)([
53
+ const calldata = encodeFunctionData({
54
+ abi: parseAbi([
65
55
  'struct ModuleInit {address module;bytes initData;uint256 moduleType}',
66
56
  'function addSafe7579(address safe7579,ModuleInit[] calldata modules,address[] calldata attesters,uint8 threshold) external',
67
57
  ]),
@@ -77,8 +67,8 @@ function getDeployArgs(config) {
77
67
  0,
78
68
  ],
79
69
  });
80
- const initData = (0, viem_1.encodeFunctionData)({
81
- abi: (0, viem_1.parseAbi)([
70
+ const initData = encodeFunctionData({
71
+ abi: parseAbi([
82
72
  'function setup(address[] calldata _owners,uint256 _threshold,address to,bytes calldata data,address fallbackHandler,address paymentToken,uint256 payment, address paymentReceiver) external',
83
73
  ]),
84
74
  functionName: 'setup',
@@ -88,21 +78,21 @@ function getDeployArgs(config) {
88
78
  launchpad,
89
79
  calldata,
90
80
  adapter,
91
- viem_1.zeroAddress,
81
+ zeroAddress,
92
82
  BigInt(0),
93
- viem_1.zeroAddress,
83
+ zeroAddress,
94
84
  ],
95
85
  });
96
86
  const account = config.account;
97
87
  const saltNonce = account?.nonce ?? 0n;
98
- const factoryData = (0, viem_1.encodeFunctionData)({
99
- abi: (0, viem_1.parseAbi)([
88
+ const factoryData = encodeFunctionData({
89
+ abi: parseAbi([
100
90
  'function createProxyWithNonce(address singleton,bytes calldata initializer,uint256 saltNonce) external payable returns (address)',
101
91
  ]),
102
92
  functionName: 'createProxyWithNonce',
103
93
  args: [SAFE_SINGLETON_ADDRESS, initData, saltNonce],
104
94
  });
105
- const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32', 'uint256'], [(0, viem_1.keccak256)(initData), saltNonce]));
95
+ const salt = keccak256(encodePacked(['bytes32', 'uint256'], [keccak256(initData), saltNonce]));
106
96
  return {
107
97
  factory: SAFE_PROXY_FACTORY_ADDRESS,
108
98
  factoryData,
@@ -113,16 +103,16 @@ function getDeployArgs(config) {
113
103
  }
114
104
  function getV0DeployArgs(config) {
115
105
  if (config.initData) {
116
- throw new error_1.AccountConfigurationNotSupportedError('Custom V0 accounts are not supported', 'safe');
106
+ throw new AccountConfigurationNotSupportedError('Custom V0 accounts are not supported', 'safe');
117
107
  }
118
108
  const owners = getOwners(config);
119
109
  const threshold = getThreshold(config);
120
- const attesters = (0, legacy_1.getV0Attesters)();
121
- const moduleSetup = (0, legacy_1.getV0Setup)(config);
110
+ const attesters = getV0Attesters();
111
+ const moduleSetup = getV0ModuleSetup(config);
122
112
  const adapter = SAFE_7579_ADAPTER_V1_ADDRESS;
123
113
  const launchpad = SAFE_7579_LAUNCHPAD_V1_ADDRESS;
124
- const calldata = (0, viem_1.encodeFunctionData)({
125
- abi: (0, viem_1.parseAbi)([
114
+ const calldata = encodeFunctionData({
115
+ abi: parseAbi([
126
116
  'struct ModuleInit {address module;bytes initData;}',
127
117
  'function addSafe7579(address safe7579,ModuleInit[] calldata validators,ModuleInit[] calldata executors,ModuleInit[] calldata fallbacks, ModuleInit[] calldata hooks,address[] calldata attesters,uint8 threshold) external',
128
118
  ]),
@@ -149,8 +139,8 @@ function getV0DeployArgs(config) {
149
139
  attesters.threshold,
150
140
  ],
151
141
  });
152
- const initData = (0, viem_1.encodeFunctionData)({
153
- abi: (0, viem_1.parseAbi)([
142
+ const initData = encodeFunctionData({
143
+ abi: parseAbi([
154
144
  'function setup(address[] calldata _owners,uint256 _threshold,address to,bytes calldata data,address fallbackHandler,address paymentToken,uint256 payment, address paymentReceiver) external',
155
145
  ]),
156
146
  functionName: 'setup',
@@ -160,21 +150,21 @@ function getV0DeployArgs(config) {
160
150
  launchpad,
161
151
  calldata,
162
152
  adapter,
163
- viem_1.zeroAddress,
153
+ zeroAddress,
164
154
  BigInt(0),
165
- viem_1.zeroAddress,
155
+ zeroAddress,
166
156
  ],
167
157
  });
168
158
  const account = config.account;
169
159
  const saltNonce = account?.nonce ?? 0n;
170
- const factoryData = (0, viem_1.encodeFunctionData)({
171
- abi: (0, viem_1.parseAbi)([
160
+ const factoryData = encodeFunctionData({
161
+ abi: parseAbi([
172
162
  'function createProxyWithNonce(address singleton,bytes calldata initializer,uint256 saltNonce) external payable returns (address)',
173
163
  ]),
174
164
  functionName: 'createProxyWithNonce',
175
165
  args: [SAFE_SINGLETON_ADDRESS, initData, saltNonce],
176
166
  });
177
- const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32', 'uint256'], [(0, viem_1.keccak256)(initData), saltNonce]));
167
+ const salt = keccak256(encodePacked(['bytes32', 'uint256'], [keccak256(initData), saltNonce]));
178
168
  return {
179
169
  factory: SAFE_PROXY_FACTORY_ADDRESS,
180
170
  factoryData,
@@ -192,29 +182,29 @@ function getAddress(config) {
192
182
  throw new Error('Cannot derive address: deploy args not available');
193
183
  }
194
184
  const { factory, implementation, salt } = deployArgs;
195
- const constructorArgs = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)('address singleton'), [implementation]);
196
- const address = (0, viem_1.getContractAddress)({
185
+ const constructorArgs = encodeAbiParameters(parseAbiParameters('address singleton'), [implementation]);
186
+ const address = getContractAddress({
197
187
  opcode: 'CREATE2',
198
188
  from: factory,
199
189
  salt,
200
- bytecode: (0, viem_1.concat)([SAFE_PROXY_INIT_CODE, constructorArgs]),
190
+ bytecode: concat([SAFE_PROXY_INIT_CODE, constructorArgs]),
201
191
  });
202
192
  return address;
203
193
  }
204
194
  function getEip712Domain(config, chain) {
205
195
  if (config.initData && !('factory' in config.initData)) {
206
- throw new error_1.Eip712DomainNotAvailableError('Existing Safe-7579 accounts are not yet supported');
196
+ throw new Eip712DomainNotAvailableError('Existing Safe-7579 accounts are not yet supported');
207
197
  }
208
198
  return {
209
199
  name: 'rhinestone safe7579',
210
200
  version: 'v1.0.0',
211
201
  chainId: chain.id,
212
202
  verifyingContract: getAddress(config),
213
- salt: viem_1.zeroHash,
203
+ salt: zeroHash,
214
204
  };
215
205
  }
216
206
  function getInstallData(module) {
217
- return (0, viem_1.encodeFunctionData)({
207
+ return encodeFunctionData({
218
208
  abi: [
219
209
  {
220
210
  type: 'function',
@@ -242,33 +232,33 @@ function getInstallData(module) {
242
232
  });
243
233
  }
244
234
  async function packSignature(signature, validator, transformSignature = (signature) => signature) {
245
- return (0, viem_1.encodePacked)(['address', 'bytes'], [validator.address, transformSignature(signature)]);
235
+ return encodePacked(['address', 'bytes'], [validator.address, transformSignature(signature)]);
246
236
  }
247
237
  async function getSmartAccount(client, address, owners, validatorAddress, sign) {
248
238
  return getBaseSmartAccount(address, client, validatorAddress, async () => {
249
- return (0, validators_1.getMockSignature)(owners);
239
+ return getMockSignature(owners);
250
240
  }, sign);
251
241
  }
252
242
  async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
253
243
  return await getBaseSmartAccount(address, client, validatorAddress, async () => {
254
- return (0, validators_1.getMockSignature)(guardians);
244
+ return getMockSignature(guardians);
255
245
  }, async (hash) => {
256
246
  return await sign(hash);
257
247
  });
258
248
  }
259
249
  async function getBaseSmartAccount(address, client, validatorAddress, getStubSignature, signUserOperation) {
260
- return await (0, account_abstraction_1.toSmartAccount)({
250
+ return await toSmartAccount({
261
251
  client,
262
252
  entryPoint: {
263
- abi: account_abstraction_1.entryPoint07Abi,
264
- address: account_abstraction_1.entryPoint07Address,
253
+ abi: entryPoint07Abi,
254
+ address: entryPoint07Address,
265
255
  version: '0.7',
266
256
  },
267
257
  async decodeCalls() {
268
258
  throw new Error('Not implemented');
269
259
  },
270
260
  async encodeCalls(calls) {
271
- return (0, utils_1.encode7579Calls)({
261
+ return encode7579Calls({
272
262
  mode: {
273
263
  type: calls.length > 1 ? 'batchcall' : 'call',
274
264
  revertOnError: false,
@@ -285,10 +275,10 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
285
275
  return {};
286
276
  },
287
277
  async getNonce() {
288
- const key = (0, viem_1.concat)([validatorAddress, '0x00000000']);
289
- const nonce = await (0, utils_1.getAccountNonce)(client, {
278
+ const key = concat([validatorAddress, '0x00000000']);
279
+ const nonce = await getAccountNonce(client, {
290
280
  address,
291
- entryPointAddress: account_abstraction_1.entryPoint07Address,
281
+ entryPointAddress: entryPoint07Address,
292
282
  key: BigInt(key),
293
283
  });
294
284
  return nonce;
@@ -306,13 +296,13 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
306
296
  const { chainId = client.chain?.id, ...userOperation } = parameters;
307
297
  if (!chainId)
308
298
  throw new Error('Chain id not found');
309
- const hash = (0, account_abstraction_1.getUserOperationHash)({
299
+ const hash = getUserOperationHash({
310
300
  userOperation: {
311
301
  ...userOperation,
312
302
  sender: userOperation.sender ?? (await this.getAddress()),
313
303
  signature: '0x',
314
304
  },
315
- entryPointAddress: account_abstraction_1.entryPoint07Address,
305
+ entryPointAddress: entryPoint07Address,
316
306
  entryPointVersion: '0.7',
317
307
  chainId: chainId,
318
308
  });
@@ -322,7 +312,7 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
322
312
  }
323
313
  function getOwners(config) {
324
314
  if (!config.owners) {
325
- throw new error_1.OwnersFieldRequiredError();
315
+ throw new OwnersFieldRequiredError();
326
316
  }
327
317
  const ownerSet = config.owners;
328
318
  switch (ownerSet.type) {
@@ -337,7 +327,7 @@ function getOwners(config) {
337
327
  }
338
328
  function getThreshold(config) {
339
329
  if (!config.owners) {
340
- throw new error_1.OwnersFieldRequiredError();
330
+ throw new OwnersFieldRequiredError();
341
331
  }
342
332
  const ownerSet = config.owners;
343
333
  switch (ownerSet.type) {
@@ -350,3 +340,4 @@ function getThreshold(config) {
350
340
  return 1n;
351
341
  }
352
342
  }
343
+ export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getV0DeployArgs, getSmartAccount, getGuardianSmartAccount, };
@@ -1,7 +1,7 @@
1
1
  import { type Account, type Address, type Chain, type Hex } from 'viem';
2
2
  import type { WebAuthnAccount } from 'viem/account-abstraction';
3
- import { type ResolvedSessionSignerSet } from '../../modules/validators/smart-sessions';
4
- import type { OwnerSet, SignerSet } from '../../types';
3
+ import { type ResolvedSessionSignerSet } from '../../modules/validators/smart-sessions.js';
4
+ import type { OwnerSet, SignerSet } from '../../types.js';
5
5
  declare function convertOwnerSetToSignerSet(owners: OwnerSet): SignerSet;
6
6
  type WebAuthnSignMetadata = {
7
7
  authenticatorData: Hex;
@@ -1,15 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertOwnerSetToSignerSet = convertOwnerSetToSignerSet;
4
- exports.signWithMultiFactorAuth = signWithMultiFactorAuth;
5
- exports.signWithSession = signWithSession;
6
- exports.signWithGuardians = signWithGuardians;
7
- exports.signWithOwners = signWithOwners;
8
- const viem_1 = require("viem");
9
- const modules_1 = require("../../modules");
10
- const core_1 = require("../../modules/validators/core");
11
- const smart_sessions_1 = require("../../modules/validators/smart-sessions");
12
- const passkeys_1 = require("./passkeys");
1
+ import { concat, createWalletClient, custom, encodeAbiParameters, encodePacked, hashMessage, pad, padHex, toHex, } from 'viem';
2
+ import { isRip7212SupportedNetwork } from '../../modules/index.js';
3
+ import { ENS_VALIDATOR_ADDRESS, getValidator, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_V0_VALIDATOR_ADDRESS, } from '../../modules/validators/core.js';
4
+ import { packSignature as packSmartSessionSignature, } from '../../modules/validators/smart-sessions.js';
5
+ import { generateCredentialId, packSignature as packPasskeySignature, packSignatureV0 as packPasskeySignatureV0, parsePublicKey, parseSignature, } from './passkeys.js';
13
6
  function convertOwnerSetToSignerSet(owners) {
14
7
  switch (owners.type) {
15
8
  case 'ecdsa': {
@@ -17,7 +10,7 @@ function convertOwnerSetToSignerSet(owners) {
17
10
  type: 'owner',
18
11
  kind: 'ecdsa',
19
12
  accounts: owners.accounts,
20
- module: owners.module ?? core_1.OWNABLE_VALIDATOR_ADDRESS,
13
+ module: owners.module ?? OWNABLE_VALIDATOR_ADDRESS,
21
14
  };
22
15
  }
23
16
  case 'ens': {
@@ -25,7 +18,7 @@ function convertOwnerSetToSignerSet(owners) {
25
18
  type: 'owner',
26
19
  kind: 'ecdsa',
27
20
  accounts: owners.accounts,
28
- module: owners.module ?? core_1.ENS_VALIDATOR_ADDRESS,
21
+ module: owners.module ?? ENS_VALIDATOR_ADDRESS,
29
22
  };
30
23
  }
31
24
  case 'passkey': {
@@ -47,7 +40,7 @@ function convertOwnerSetToSignerSet(owners) {
47
40
  type: validator.type,
48
41
  id: index,
49
42
  accounts: validator.accounts,
50
- module: validator.module ?? core_1.OWNABLE_VALIDATOR_ADDRESS,
43
+ module: validator.module ?? OWNABLE_VALIDATOR_ADDRESS,
51
44
  };
52
45
  }
53
46
  case 'ens': {
@@ -55,7 +48,7 @@ function convertOwnerSetToSignerSet(owners) {
55
48
  type: 'ecdsa',
56
49
  id: index,
57
50
  accounts: validator.accounts,
58
- module: validator.module ?? core_1.ENS_VALIDATOR_ADDRESS,
51
+ module: validator.module ?? ENS_VALIDATOR_ADDRESS,
59
52
  };
60
53
  }
61
54
  case 'passkey': {
@@ -83,7 +76,7 @@ async function signWithMultiFactorAuth(signers, chain, address, params, isUserOp
83
76
  const validatorSigners = convertOwnerSetToSignerSet(validator);
84
77
  return signMain(validatorSigners, chain, address, params, isUserOpHash);
85
78
  }));
86
- const data = (0, viem_1.encodeAbiParameters)([
79
+ const data = encodeAbiParameters([
87
80
  {
88
81
  components: [
89
82
  {
@@ -98,10 +91,10 @@ async function signWithMultiFactorAuth(signers, chain, address, params, isUserOp
98
91
  },
99
92
  ], [
100
93
  signers.validators.map((validator, index) => {
101
- const validatorModule = (0, core_1.getValidator)(validator);
94
+ const validatorModule = getValidator(validator);
102
95
  return {
103
- packedValidatorAndId: (0, viem_1.concat)([
104
- (0, viem_1.pad)((0, viem_1.toHex)(validator.id), {
96
+ packedValidatorAndId: concat([
97
+ pad(toHex(validator.id), {
105
98
  size: 12,
106
99
  }),
107
100
  validatorModule.address,
@@ -116,15 +109,15 @@ async function signWithSession(signers, chain, address, hash, signMain) {
116
109
  const sessionSigners = convertOwnerSetToSignerSet(signers.session.owners);
117
110
  const signedHash = signers.verifyExecutions
118
111
  ? hash
119
- : (0, viem_1.hashMessage)({
120
- raw: (0, viem_1.encodePacked)(['bytes32', 'bytes32'], [(0, viem_1.padHex)(address), hash]),
112
+ : hashMessage({
113
+ raw: encodePacked(['bytes32', 'bytes32'], [padHex(address), hash]),
121
114
  });
122
115
  const validatorSignature = await signMain(sessionSigners, chain, address, signedHash, false);
123
- return (0, smart_sessions_1.packSignature)(signers, validatorSignature);
116
+ return packSmartSessionSignature(signers, validatorSignature);
124
117
  }
125
118
  async function signWithGuardians(signers, params, signingFunctions) {
126
119
  const signatures = await Promise.all(signers.guardians.map((account) => signingFunctions.signEcdsa(account, params, false)));
127
- return (0, viem_1.concat)(signatures);
120
+ return concat(signatures);
128
121
  }
129
122
  async function signWithOwners(signers, chain, address, params, signingFunctions, isUserOpHash, signMain) {
130
123
  async function signEcdsWithChain(account, params, updateV, chain) {
@@ -132,9 +125,9 @@ async function signWithOwners(signers, chain, address, params, signingFunctions,
132
125
  const transport = client?.transport;
133
126
  if (transport) {
134
127
  // Switch chain
135
- const walletClient = (0, viem_1.createWalletClient)({
128
+ const walletClient = createWalletClient({
136
129
  chain,
137
- transport: (0, viem_1.custom)(transport),
130
+ transport: custom(transport),
138
131
  account,
139
132
  });
140
133
  await walletClient.switchChain({
@@ -150,22 +143,22 @@ async function signWithOwners(signers, chain, address, params, signingFunctions,
150
143
  // ENS validator (based on Ownable) also uses the same signature format
151
144
  // This is not needed for UserOps
152
145
  const isOwnableOrENS = !signers.module ||
153
- signers.module?.toLowerCase() === core_1.OWNABLE_VALIDATOR_ADDRESS ||
154
- signers.module?.toLowerCase() === core_1.ENS_VALIDATOR_ADDRESS;
146
+ signers.module?.toLowerCase() === OWNABLE_VALIDATOR_ADDRESS ||
147
+ signers.module?.toLowerCase() === ENS_VALIDATOR_ADDRESS;
155
148
  const updateV = isOwnableOrENS && !isUserOpHash;
156
149
  const signatures = await Promise.all(signers.accounts.map((account) => signEcdsWithChain(account, params, updateV, chain)));
157
- return (0, viem_1.concat)(signatures);
150
+ return concat(signatures);
158
151
  }
159
152
  case 'passkey': {
160
153
  const signatures = await Promise.all(signers.accounts.map((account) => signingFunctions.signPasskey(account, params)));
161
- const usePrecompile = (0, modules_1.isRip7212SupportedNetwork)(chain);
154
+ const usePrecompile = isRip7212SupportedNetwork(chain);
162
155
  const credIds = signers.accounts.map((account) => {
163
156
  const publicKey = account.publicKey;
164
- const { x, y } = (0, passkeys_1.parsePublicKey)(publicKey);
165
- return (0, passkeys_1.generateCredentialId)(x, y, address);
157
+ const { x, y } = parsePublicKey(publicKey);
158
+ return generateCredentialId(x, y, address);
166
159
  });
167
160
  const webAuthns = signatures.map((signature) => {
168
- const { r, s } = (0, passkeys_1.parseSignature)(signature.signature);
161
+ const { r, s } = parseSignature(signature.signature);
169
162
  return {
170
163
  authenticatorData: signature.webauthn.authenticatorData,
171
164
  clientDataJSON: signature.webauthn.clientDataJSON,
@@ -175,10 +168,10 @@ async function signWithOwners(signers, chain, address, params, signingFunctions,
175
168
  s,
176
169
  };
177
170
  });
178
- if (signers.module?.toLowerCase() === core_1.WEBAUTHN_V0_VALIDATOR_ADDRESS) {
179
- return (0, passkeys_1.packSignatureV0)(webAuthns[0], usePrecompile);
171
+ if (signers.module?.toLowerCase() === WEBAUTHN_V0_VALIDATOR_ADDRESS) {
172
+ return packPasskeySignatureV0(webAuthns[0], usePrecompile);
180
173
  }
181
- return (0, passkeys_1.packSignature)(credIds, usePrecompile, webAuthns);
174
+ return packPasskeySignature(credIds, usePrecompile, webAuthns);
182
175
  }
183
176
  case 'multi-factor': {
184
177
  return signWithMultiFactorAuth(signers, chain, address, params, isUserOpHash, signMain);
@@ -188,3 +181,4 @@ async function signWithOwners(signers, chain, address, params, signingFunctions,
188
181
  }
189
182
  }
190
183
  }
184
+ export { convertOwnerSetToSignerSet, signWithMultiFactorAuth, signWithSession, signWithGuardians, signWithOwners, };
@@ -1,6 +1,6 @@
1
1
  import { type Address, type Chain, type Hex } from 'viem';
2
- import type { ResolvedSessionSignerSet } from '../../modules/validators/smart-sessions';
3
- import type { SignerSet } from '../../types';
2
+ import type { ResolvedSessionSignerSet } from '../../modules/validators/smart-sessions.js';
3
+ import type { SignerSet } from '../../types.js';
4
4
  type InternalSignerSet = SignerSet | ResolvedSessionSignerSet;
5
5
  declare function sign(signers: InternalSignerSet, chain: Chain, address: Address, hash: Hex, isUserOpHash: boolean): Promise<Hex>;
6
6
  export { sign };
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sign = sign;
4
- const viem_1 = require("viem");
5
- const error_1 = require("../error");
6
- const common_1 = require("./common");
1
+ import { concat, parseSignature, toHex, } from 'viem';
2
+ import { SigningNotSupportedForAccountError } from '../error.js';
3
+ import { signWithGuardians, signWithOwners, signWithSession, } from './common.js';
7
4
  async function sign(signers, chain, address, hash, isUserOpHash) {
8
5
  const signingFunctions = {
9
6
  signEcdsa: (account, hash, updateV) => signEcdsa(account, hash, updateV),
@@ -11,31 +8,31 @@ async function sign(signers, chain, address, hash, isUserOpHash) {
11
8
  };
12
9
  switch (signers.type) {
13
10
  case 'owner': {
14
- return (0, common_1.signWithOwners)(signers, chain, address, hash, signingFunctions, isUserOpHash, sign);
11
+ return signWithOwners(signers, chain, address, hash, signingFunctions, isUserOpHash, sign);
15
12
  }
16
13
  case 'experimental_session': {
17
- return (0, common_1.signWithSession)(signers, chain, address, hash, sign);
14
+ return signWithSession(signers, chain, address, hash, sign);
18
15
  }
19
16
  case 'guardians': {
20
- return (0, common_1.signWithGuardians)(signers, hash, signingFunctions);
17
+ return signWithGuardians(signers, hash, signingFunctions);
21
18
  }
22
19
  }
23
20
  }
24
21
  async function signEcdsa(account, hash, updateV) {
25
22
  if (!account.signMessage) {
26
- throw new error_1.SigningNotSupportedForAccountError();
23
+ throw new SigningNotSupportedForAccountError();
27
24
  }
28
25
  const originalSignature = await account.signMessage({
29
26
  message: { raw: hash },
30
27
  });
31
28
  // Manually tweak the `v` value to trigger the message prefixing onchain
32
29
  // https://github.com/rhinestonewtf/checknsignatures/blob/main/src/CheckNSignatures.sol#L53-L61
33
- const { r, s, v } = (0, viem_1.parseSignature)(originalSignature);
30
+ const { r, s, v } = parseSignature(originalSignature);
34
31
  if (!v) {
35
32
  throw new Error('Invalid signature');
36
33
  }
37
34
  const newV = updateV ? v + 4n : v;
38
- const newSignature = (0, viem_1.concat)([r, s, (0, viem_1.toHex)(newV)]);
35
+ const newSignature = concat([r, s, toHex(newV)]);
39
36
  return newSignature;
40
37
  }
41
38
  async function signPasskey(account, hash) {
@@ -45,3 +42,4 @@ async function signPasskey(account, hash) {
45
42
  signature,
46
43
  };
47
44
  }
45
+ export { sign };
@@ -1,32 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePublicKey = parsePublicKey;
4
- exports.parseSignature = parseSignature;
5
- exports.generateCredentialId = generateCredentialId;
6
- exports.packSignature = packSignature;
7
- exports.packSignatureV0 = packSignatureV0;
8
- const viem_1 = require("viem");
1
+ import { bytesToHex, encodeAbiParameters, hexToBytes, keccak256, } from 'viem';
9
2
  function parsePublicKey(publicKey) {
10
- const bytes = typeof publicKey === 'string' ? (0, viem_1.hexToBytes)(publicKey) : publicKey;
3
+ const bytes = typeof publicKey === 'string' ? hexToBytes(publicKey) : publicKey;
11
4
  const offset = bytes.length === 65 ? 1 : 0;
12
5
  const x = bytes.slice(offset, 32 + offset);
13
6
  const y = bytes.slice(32 + offset, 64 + offset);
14
7
  return {
15
- x: BigInt((0, viem_1.bytesToHex)(x)),
16
- y: BigInt((0, viem_1.bytesToHex)(y)),
8
+ x: BigInt(bytesToHex(x)),
9
+ y: BigInt(bytesToHex(y)),
17
10
  };
18
11
  }
19
12
  function parseSignature(signature) {
20
- const bytes = typeof signature === 'string' ? (0, viem_1.hexToBytes)(signature) : signature;
13
+ const bytes = typeof signature === 'string' ? hexToBytes(signature) : signature;
21
14
  const r = bytes.slice(0, 32);
22
15
  const s = bytes.slice(32, 64);
23
16
  return {
24
- r: BigInt((0, viem_1.bytesToHex)(r)),
25
- s: BigInt((0, viem_1.bytesToHex)(s)),
17
+ r: BigInt(bytesToHex(r)),
18
+ s: BigInt(bytesToHex(s)),
26
19
  };
27
20
  }
28
21
  function generateCredentialId(pubKeyX, pubKeyY, account) {
29
- return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
22
+ return keccak256(encodeAbiParameters([
30
23
  {
31
24
  type: 'uint256',
32
25
  },
@@ -48,7 +41,7 @@ function packSignature(credIds, usePrecompile, webAuthns) {
48
41
  credIds = credIdsAndWebAuthns.map(({ credId }) => credId);
49
42
  webAuthns = credIdsAndWebAuthns.map(({ webAuthn }) => webAuthn);
50
43
  // Encode
51
- return (0, viem_1.encodeAbiParameters)([
44
+ return encodeAbiParameters([
52
45
  {
53
46
  type: 'bytes32[]',
54
47
  name: 'credIds',
@@ -90,7 +83,7 @@ function packSignature(credIds, usePrecompile, webAuthns) {
90
83
  ], [credIds, usePrecompile, webAuthns]);
91
84
  }
92
85
  function packSignatureV0(webauthn, usePrecompiled) {
93
- return (0, viem_1.encodeAbiParameters)([
86
+ return encodeAbiParameters([
94
87
  { type: 'bytes', name: 'authenticatorData' },
95
88
  {
96
89
  type: 'string',
@@ -123,3 +116,4 @@ function packSignatureV0(webauthn, usePrecompiled) {
123
116
  usePrecompiled,
124
117
  ]);
125
118
  }
119
+ export { parsePublicKey, parseSignature, generateCredentialId, packSignature, packSignatureV0, };
@@ -1,5 +1,5 @@
1
1
  import type { Address, Chain, HashTypedDataParameters, Hex, TypedData } from 'viem';
2
- import type { SignerSet } from '../../types';
2
+ import type { SignerSet } from '../../types.js';
3
3
  declare function sign<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(signers: SignerSet, chain: Chain, address: Address, parameters: HashTypedDataParameters<typedData, primaryType>): Promise<Hex>;
4
4
  export { sign };
5
5
  //# sourceMappingURL=typedData.d.ts.map
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sign = sign;
4
- const error_1 = require("../error");
5
- const common_1 = require("./common");
1
+ import { SigningNotSupportedForAccountError } from '../error.js';
2
+ import { signWithGuardians, signWithOwners, } from './common.js';
6
3
  async function sign(signers, chain, address, parameters) {
7
4
  const signingFunctions = {
8
5
  signEcdsa: (account, params) => signEcdsa(account, params),
@@ -10,10 +7,10 @@ async function sign(signers, chain, address, parameters) {
10
7
  };
11
8
  switch (signers.type) {
12
9
  case 'owner': {
13
- return (0, common_1.signWithOwners)(signers, chain, address, parameters, signingFunctions, false, sign);
10
+ return signWithOwners(signers, chain, address, parameters, signingFunctions, false, sign);
14
11
  }
15
12
  case 'guardians': {
16
- return (0, common_1.signWithGuardians)(signers, parameters, signingFunctions);
13
+ return signWithGuardians(signers, parameters, signingFunctions);
17
14
  }
18
15
  case 'experimental_session': {
19
16
  throw new Error('Not supported');
@@ -22,7 +19,7 @@ async function sign(signers, chain, address, parameters) {
22
19
  }
23
20
  async function signEcdsa(account, parameters) {
24
21
  if (!account.signTypedData) {
25
- throw new error_1.SigningNotSupportedForAccountError();
22
+ throw new SigningNotSupportedForAccountError();
26
23
  }
27
24
  return await account.signTypedData(parameters);
28
25
  }
@@ -33,3 +30,4 @@ async function signPasskey(account, parameters) {
33
30
  signature,
34
31
  };
35
32
  }
33
+ export { sign };
@@ -1,7 +1,7 @@
1
1
  import type { Address, Chain, Hex, PublicClient } from 'viem';
2
- import type { Module } from '../modules/common';
3
- import type { OwnerSet, RhinestoneAccountConfig } from '../types';
4
- import type { ValidatorConfig } from './utils';
2
+ import type { Module } from '../modules/common.js';
3
+ import type { OwnerSet, RhinestoneAccountConfig } from '../types.js';
4
+ import type { ValidatorConfig } from './utils.js';
5
5
  declare const K1_DEFAULT_VALIDATOR_ADDRESS: Address;
6
6
  declare function getDeployArgs(config: RhinestoneAccountConfig): {
7
7
  factory: `0x${string}`;