@rhinestone/sdk 0.2.1 → 0.4.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 (71) hide show
  1. package/README.md +4 -4
  2. package/dist/accounts/index.d.ts +15515 -4
  3. package/dist/accounts/index.d.ts.map +1 -1
  4. package/dist/accounts/index.js +69 -10
  5. package/dist/accounts/nexus.d.ts +15542 -32
  6. package/dist/accounts/nexus.d.ts.map +1 -1
  7. package/dist/accounts/nexus.js +86 -65
  8. package/dist/accounts/safe.d.ts +3 -1
  9. package/dist/accounts/safe.d.ts.map +1 -1
  10. package/dist/accounts/safe.js +8 -2
  11. package/dist/examples/abi/weth.d.ts +214 -0
  12. package/dist/examples/abi/weth.d.ts.map +1 -0
  13. package/dist/examples/abi/weth.js +279 -0
  14. package/dist/examples/cross-chain-ss.d.ts +1 -0
  15. package/dist/examples/cross-chain-ss.d.ts.map +1 -0
  16. package/dist/{example.js → examples/cross-chain-ss.js} +59 -22
  17. package/dist/examples/giza.d.ts +1 -0
  18. package/dist/examples/giza.d.ts.map +1 -0
  19. package/dist/examples/giza.js +124 -0
  20. package/dist/examples/omni-account.d.ts +1 -0
  21. package/dist/examples/omni-account.d.ts.map +1 -0
  22. package/dist/examples/omni-account.js +169 -0
  23. package/dist/examples/smart-sessions.d.ts +1 -0
  24. package/dist/examples/smart-sessions.d.ts.map +1 -0
  25. package/dist/examples/smart-sessions.js +216 -0
  26. package/dist/execution/index.d.ts +28 -3
  27. package/dist/execution/index.d.ts.map +1 -1
  28. package/dist/execution/index.js +177 -47
  29. package/dist/execution/smart-session.d.ts +14 -0
  30. package/dist/execution/smart-session.d.ts.map +1 -0
  31. package/dist/execution/smart-session.js +83 -0
  32. package/dist/index.d.ts +17 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +10 -10
  35. package/dist/modules/abi/smart-sessions.d.ts +42 -0
  36. package/dist/modules/abi/smart-sessions.d.ts.map +1 -0
  37. package/dist/modules/abi/smart-sessions.js +128 -0
  38. package/dist/modules/common.d.ts +16 -0
  39. package/dist/modules/common.d.ts.map +1 -0
  40. package/dist/modules/common.js +5 -0
  41. package/dist/modules/index.d.ts +7 -18
  42. package/dist/modules/index.d.ts.map +1 -1
  43. package/dist/modules/index.js +14 -119
  44. package/dist/modules/omni-account.d.ts +9 -0
  45. package/dist/modules/omni-account.d.ts.map +1 -0
  46. package/dist/modules/omni-account.js +7 -0
  47. package/dist/modules/validators.d.ts +31 -0
  48. package/dist/modules/validators.d.ts.map +1 -0
  49. package/dist/modules/validators.js +521 -0
  50. package/dist/orchestrator/client.d.ts +2 -5
  51. package/dist/orchestrator/client.d.ts.map +1 -1
  52. package/dist/orchestrator/consts.d.ts +3 -1
  53. package/dist/orchestrator/consts.d.ts.map +1 -1
  54. package/dist/orchestrator/consts.js +3 -1
  55. package/dist/orchestrator/index.d.ts +5 -3
  56. package/dist/orchestrator/index.d.ts.map +1 -1
  57. package/dist/orchestrator/index.js +5 -4
  58. package/dist/orchestrator/registry.d.ts +5 -0
  59. package/dist/orchestrator/registry.d.ts.map +1 -0
  60. package/dist/orchestrator/registry.js +187 -0
  61. package/dist/orchestrator/types.d.ts +39 -23
  62. package/dist/orchestrator/types.d.ts.map +1 -1
  63. package/dist/orchestrator/types.js +7 -6
  64. package/dist/orchestrator/utils.d.ts +8 -4
  65. package/dist/orchestrator/utils.d.ts.map +1 -1
  66. package/dist/orchestrator/utils.js +19 -5
  67. package/dist/types.d.ts +64 -4
  68. package/dist/types.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/dist/example.d.ts +0 -1
  71. package/dist/example.d.ts.map +0 -1
@@ -0,0 +1,14 @@
1
+ import { Chain, Hex, Address } from 'viem';
2
+ import { RhinestoneAccountConfig, Session } from '../types';
3
+ import { OrderPath } from '../orchestrator';
4
+ declare function enableSmartSession(chain: Chain, config: RhinestoneAccountConfig, session: Session): Promise<void>;
5
+ declare function hashErc7739(sourceChain: Chain, orderPath: OrderPath, accountAddress: Address): Promise<{
6
+ hash: `0x${string}`;
7
+ appDomainSeparator: `0x${string}`;
8
+ contentsType: string;
9
+ structHash: `0x${string}`;
10
+ orderBundleHash: `0x${string}`;
11
+ }>;
12
+ declare function getSessionSignature(signature: Hex, appDomainSeparator: Hex, structHash: Hex, contentsType: string, withSession: Session): `0x${string}`;
13
+ export { enableSmartSession, hashErc7739, getSessionSignature };
14
+ //# sourceMappingURL=smart-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../execution/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAIL,GAAG,EAGH,OAAO,EACR,MAAM,MAAM,CAAA;AAWb,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAM3C,iBAAe,kBAAkB,CAC/B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,OAAO,iBAyBjB;AAED,iBAAe,WAAW,CACxB,WAAW,EAAE,KAAK,EAClB,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,OAAO;;;;;;GAmExB;AAED,iBAAS,mBAAmB,CAC1B,SAAS,EAAE,GAAG,EACd,kBAAkB,EAAE,GAAG,EACvB,UAAU,EAAE,GAAG,EACf,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,OAAO,iBAkBrB;AAED,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,83 @@
1
+ import { http, createPublicClient, encodePacked, keccak256, encodeAbiParameters, } from 'viem';
2
+ import { getSmartAccount, getAddress } from '../accounts';
3
+ import { getBundlerClient } from '../accounts/utils';
4
+ import { getPermissionId, isSessionEnabled, getSessionAllowedERC7739Content, getAccountEIP712Domain, getEnableSessionCall, } from '../modules/validators';
5
+ import { getOrderBundleHash, hashMultichainCompactWithoutDomainSeparator, } from '../orchestrator/utils';
6
+ async function enableSmartSession(chain, config, session) {
7
+ const publicClient = createPublicClient({
8
+ chain,
9
+ transport: http(),
10
+ });
11
+ const address = await getAddress(config);
12
+ const isEnabled = await isSessionEnabled(publicClient, address, getPermissionId(session));
13
+ if (isEnabled) {
14
+ return;
15
+ }
16
+ const smartAccount = await getSmartAccount(config, publicClient, chain);
17
+ const bundlerClient = getBundlerClient(config, publicClient);
18
+ const enableSessionCall = await getEnableSessionCall(chain, session);
19
+ const opHash = await bundlerClient.sendUserOperation({
20
+ account: smartAccount,
21
+ calls: [enableSessionCall],
22
+ });
23
+ await bundlerClient.waitForUserOperationReceipt({
24
+ hash: opHash,
25
+ });
26
+ }
27
+ async function hashErc7739(sourceChain, orderPath, accountAddress) {
28
+ const publicClient = createPublicClient({
29
+ chain: sourceChain,
30
+ transport: http(),
31
+ });
32
+ const { appDomainSeparator, contentsType } = await getSessionAllowedERC7739Content(sourceChain);
33
+ const orderBundleHash = getOrderBundleHash(orderPath[0].orderBundle);
34
+ // Create hash following ERC-7739 TypedDataSign workflow
35
+ const typedDataSignTypehash = keccak256(encodePacked(['string'], [
36
+ 'TypedDataSign(MultichainCompact contents,string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)'.concat(contentsType),
37
+ ]));
38
+ // Original struct hash
39
+ const structHash = hashMultichainCompactWithoutDomainSeparator(orderPath[0].orderBundle);
40
+ const { name, version, chainId, verifyingContract, salt } = await getAccountEIP712Domain(publicClient, accountAddress);
41
+ // Final hash according to ERC-7739
42
+ const hash = keccak256(encodePacked(['bytes2', 'bytes32', 'bytes32'], [
43
+ '0x1901',
44
+ appDomainSeparator,
45
+ keccak256(encodeAbiParameters([
46
+ { name: 'typedDataSignTypehash', type: 'bytes32' },
47
+ { name: 'structHash', type: 'bytes32' },
48
+ { name: 'name', type: 'bytes32' },
49
+ { name: 'version', type: 'bytes32' },
50
+ { name: 'chainId', type: 'uint256' },
51
+ { name: 'verifyingContract', type: 'address' },
52
+ { name: 'salt', type: 'bytes32' },
53
+ ], [
54
+ typedDataSignTypehash,
55
+ structHash,
56
+ keccak256(encodePacked(['string'], [name])),
57
+ keccak256(encodePacked(['string'], [version])),
58
+ BigInt(Number(chainId)),
59
+ verifyingContract,
60
+ salt,
61
+ ])),
62
+ ]));
63
+ return {
64
+ hash,
65
+ appDomainSeparator,
66
+ contentsType,
67
+ structHash,
68
+ orderBundleHash,
69
+ };
70
+ }
71
+ function getSessionSignature(signature, appDomainSeparator, structHash, contentsType, withSession) {
72
+ const erc7739Signature = encodePacked(['bytes', 'bytes32', 'bytes32', 'string', 'uint16'], [
73
+ signature,
74
+ appDomainSeparator,
75
+ structHash,
76
+ contentsType,
77
+ contentsType.length,
78
+ ]);
79
+ // Pack with permissionId for smart session
80
+ const wrappedSignature = encodePacked(['bytes32', 'bytes'], [getPermissionId(withSession), erc7739Signature]);
81
+ return wrappedSignature;
82
+ }
83
+ export { enableSmartSession, hashErc7739, getSessionSignature };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,23 @@
1
- import { RhinestoneAccountConfig, Transaction } from './types';
1
+ import type { RhinestoneAccountConfig, Transaction, Session } from './types';
2
+ import { type TransactionResult } from './execution';
2
3
  declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<{
3
4
  config: RhinestoneAccountConfig;
4
- sendTransactions: (transaction: Transaction) => Promise<bigint>;
5
- waitForExecution: ({ id }: {
6
- id: bigint;
7
- }) => Promise<import("./orchestrator").BundleResult>;
5
+ sendTransactions: (transaction: Transaction) => Promise<TransactionResult>;
6
+ waitForExecution: (result: TransactionResult) => Promise<import("./orchestrator").BundleResult | {
7
+ actualGasCost: bigint;
8
+ actualGasUsed: bigint;
9
+ entryPoint: import("abitype").Address;
10
+ logs: import("viem").Log<bigint, number, false>[];
11
+ nonce: bigint;
12
+ paymaster?: `0x${string}` | undefined;
13
+ reason?: string | undefined | undefined;
14
+ receipt: import("viem").TransactionReceipt<bigint, number, "success" | "reverted">;
15
+ sender: import("abitype").Address;
16
+ success: boolean;
17
+ userOpHash: import("viem").Hash;
18
+ }>;
8
19
  getAddress: () => Promise<`0x${string}`>;
9
20
  }>;
10
21
  export { createRhinestoneAccount };
22
+ export type { Session };
11
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO9D,iBAAe,uBAAuB,CAAC,MAAM,EAAE,uBAAuB;;oCACvB,WAAW;+BAIhB;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE;;GAcvD;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,aAAa,CAAA;AAGpB,iBAAe,uBAAuB,CAAC,MAAM,EAAE,uBAAuB;;oCAC7B,WAAW;+BAIhB,iBAAiB;;;;;;;;;;;;;;GAcpD;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA;AAClC,YAAY,EAAE,OAAO,EAAE,CAAA"}
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { sendTransactions as sendTransactionsInternal, waitForExecution as waitForExecutionInternal, } from './execution';
1
+ import { sendTransaction as sendTransactionInternal, waitForExecution as waitForExecutionInternal, } from './execution';
2
2
  import { getAddress as getAddressInternal } from './accounts';
3
3
  async function createRhinestoneAccount(config) {
4
- const sendTransactions = async (transaction) => {
5
- return await sendTransactionsInternal(config, transaction);
6
- };
7
- const waitForExecution = async ({ id }) => {
8
- return await waitForExecutionInternal(config, id);
9
- };
10
- const getAddress = async () => {
11
- return await getAddressInternal(config);
12
- };
4
+ function sendTransactions(transaction) {
5
+ return sendTransactionInternal(config, transaction);
6
+ }
7
+ function waitForExecution(result) {
8
+ return waitForExecutionInternal(config, result);
9
+ }
10
+ function getAddress() {
11
+ return getAddressInternal(config);
12
+ }
13
13
  return {
14
14
  config,
15
15
  sendTransactions,
@@ -0,0 +1,42 @@
1
+ declare const enableSessionsAbi: {
2
+ type: string;
3
+ name: string;
4
+ inputs: {
5
+ name: string;
6
+ type: string;
7
+ internalType: string;
8
+ components: ({
9
+ name: string;
10
+ type: string;
11
+ internalType: string;
12
+ components?: undefined;
13
+ } | {
14
+ name: string;
15
+ type: string;
16
+ internalType: string;
17
+ components: ({
18
+ name: string;
19
+ type: string;
20
+ internalType: string;
21
+ components?: undefined;
22
+ } | {
23
+ name: string;
24
+ type: string;
25
+ internalType: string;
26
+ components: {
27
+ name: string;
28
+ type: string;
29
+ internalType: string;
30
+ }[];
31
+ })[];
32
+ })[];
33
+ }[];
34
+ outputs: {
35
+ name: string;
36
+ type: string;
37
+ internalType: string;
38
+ }[];
39
+ stateMutability: string;
40
+ }[];
41
+ export { enableSessionsAbi };
42
+ //# sourceMappingURL=smart-sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../modules/abi/smart-sessions.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8HtB,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -0,0 +1,128 @@
1
+ const enableSessionsAbi = [
2
+ {
3
+ type: 'function',
4
+ name: 'enableSessions',
5
+ inputs: [
6
+ {
7
+ name: 'sessions',
8
+ type: 'tuple[]',
9
+ internalType: 'struct Session[]',
10
+ components: [
11
+ {
12
+ name: 'sessionValidator',
13
+ type: 'address',
14
+ internalType: 'contract ISessionValidator',
15
+ },
16
+ {
17
+ name: 'sessionValidatorInitData',
18
+ type: 'bytes',
19
+ internalType: 'bytes',
20
+ },
21
+ { name: 'salt', type: 'bytes32', internalType: 'bytes32' },
22
+ {
23
+ name: 'userOpPolicies',
24
+ type: 'tuple[]',
25
+ internalType: 'struct PolicyData[]',
26
+ components: [
27
+ {
28
+ name: 'policy',
29
+ type: 'address',
30
+ internalType: 'address',
31
+ },
32
+ { name: 'initData', type: 'bytes', internalType: 'bytes' },
33
+ ],
34
+ },
35
+ {
36
+ name: 'erc7739Policies',
37
+ type: 'tuple',
38
+ internalType: 'struct ERC7739Data',
39
+ components: [
40
+ {
41
+ name: 'allowedERC7739Content',
42
+ type: 'tuple[]',
43
+ internalType: 'struct ERC7739Context[]',
44
+ components: [
45
+ {
46
+ name: 'appDomainSeparator',
47
+ type: 'bytes32',
48
+ internalType: 'bytes32',
49
+ },
50
+ {
51
+ name: 'contentName',
52
+ type: 'string[]',
53
+ internalType: 'string[]',
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ name: 'erc1271Policies',
59
+ type: 'tuple[]',
60
+ internalType: 'struct PolicyData[]',
61
+ components: [
62
+ {
63
+ name: 'policy',
64
+ type: 'address',
65
+ internalType: 'address',
66
+ },
67
+ {
68
+ name: 'initData',
69
+ type: 'bytes',
70
+ internalType: 'bytes',
71
+ },
72
+ ],
73
+ },
74
+ ],
75
+ },
76
+ {
77
+ name: 'actions',
78
+ type: 'tuple[]',
79
+ internalType: 'struct ActionData[]',
80
+ components: [
81
+ {
82
+ name: 'actionTargetSelector',
83
+ type: 'bytes4',
84
+ internalType: 'bytes4',
85
+ },
86
+ {
87
+ name: 'actionTarget',
88
+ type: 'address',
89
+ internalType: 'address',
90
+ },
91
+ {
92
+ name: 'actionPolicies',
93
+ type: 'tuple[]',
94
+ internalType: 'struct PolicyData[]',
95
+ components: [
96
+ {
97
+ name: 'policy',
98
+ type: 'address',
99
+ internalType: 'address',
100
+ },
101
+ {
102
+ name: 'initData',
103
+ type: 'bytes',
104
+ internalType: 'bytes',
105
+ },
106
+ ],
107
+ },
108
+ ],
109
+ },
110
+ {
111
+ name: 'permitERC4337Paymaster',
112
+ type: 'bool',
113
+ internalType: 'bool',
114
+ },
115
+ ],
116
+ },
117
+ ],
118
+ outputs: [
119
+ {
120
+ name: 'permissionIds',
121
+ type: 'bytes32[]',
122
+ internalType: 'PermissionId[]',
123
+ },
124
+ ],
125
+ stateMutability: 'nonpayable',
126
+ },
127
+ ];
128
+ export { enableSessionsAbi };
@@ -0,0 +1,16 @@
1
+ import { Address, Hex } from 'viem';
2
+ type ModuleType = typeof MODULE_TYPE_ID_VALIDATOR | typeof MODULE_TYPE_ID_EXECUTOR | typeof MODULE_TYPE_ID_FALLBACK | typeof MODULE_TYPE_ID_HOOK;
3
+ interface Module {
4
+ address: Address;
5
+ initData: Hex;
6
+ deInitData: Hex;
7
+ additionalContext: Hex;
8
+ type: ModuleType;
9
+ }
10
+ declare const MODULE_TYPE_ID_VALIDATOR = 1n;
11
+ declare const MODULE_TYPE_ID_EXECUTOR = 2n;
12
+ declare const MODULE_TYPE_ID_FALLBACK = 3n;
13
+ declare const MODULE_TYPE_ID_HOOK = 4n;
14
+ export { MODULE_TYPE_ID_VALIDATOR, MODULE_TYPE_ID_EXECUTOR, MODULE_TYPE_ID_FALLBACK, MODULE_TYPE_ID_HOOK, };
15
+ export type { Module, ModuleType };
16
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../modules/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAEnC,KAAK,UAAU,GACX,OAAO,wBAAwB,GAC/B,OAAO,uBAAuB,GAC9B,OAAO,uBAAuB,GAC9B,OAAO,mBAAmB,CAAA;AAE9B,UAAU,MAAM;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,GAAG,CAAA;IACf,iBAAiB,EAAE,GAAG,CAAA;IACtB,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,QAAA,MAAM,wBAAwB,KAAK,CAAA;AACnC,QAAA,MAAM,uBAAuB,KAAK,CAAA;AAClC,QAAA,MAAM,uBAAuB,KAAK,CAAA;AAClC,QAAA,MAAM,mBAAmB,KAAK,CAAA;AAE9B,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,GACpB,CAAA;AACD,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA"}
@@ -0,0 +1,5 @@
1
+ const MODULE_TYPE_ID_VALIDATOR = 1n;
2
+ const MODULE_TYPE_ID_EXECUTOR = 2n;
3
+ const MODULE_TYPE_ID_FALLBACK = 3n;
4
+ const MODULE_TYPE_ID_HOOK = 4n;
5
+ export { MODULE_TYPE_ID_VALIDATOR, MODULE_TYPE_ID_EXECUTOR, MODULE_TYPE_ID_FALLBACK, MODULE_TYPE_ID_HOOK, };
@@ -1,13 +1,8 @@
1
1
  import { Address, Chain, Hex } from 'viem';
2
2
  import { RhinestoneAccountConfig } from '../types';
3
- type ModuleType = typeof MODULE_TYPE_ID_VALIDATOR | typeof MODULE_TYPE_ID_EXECUTOR | typeof MODULE_TYPE_ID_FALLBACK | typeof MODULE_TYPE_ID_HOOK;
4
- interface Module {
5
- address: Address;
6
- initData: Hex;
7
- deInitData: Hex;
8
- additionalContext: Hex;
9
- type: ModuleType;
10
- }
3
+ import { Module } from './common';
4
+ import { HOOK_ADDRESS } from './omni-account';
5
+ import { getOwnerValidator } from './validators';
11
6
  interface WebAuthnData {
12
7
  authenticatorData: Hex;
13
8
  clientDataJSON: string;
@@ -22,11 +17,6 @@ interface WebauthnSignature {
22
17
  r: bigint;
23
18
  s: bigint;
24
19
  }
25
- declare const MODULE_TYPE_ID_VALIDATOR = 1n;
26
- declare const MODULE_TYPE_ID_EXECUTOR = 2n;
27
- declare const MODULE_TYPE_ID_FALLBACK = 3n;
28
- declare const MODULE_TYPE_ID_HOOK = 4n;
29
- declare const HOOK_ADDRESS: Address;
30
20
  interface ModeleSetup {
31
21
  validators: Module[];
32
22
  executors: Module[];
@@ -36,9 +26,8 @@ interface ModeleSetup {
36
26
  attesters: Address[];
37
27
  threshold: number;
38
28
  }
39
- declare function getSetup(config: RhinestoneAccountConfig): ModeleSetup;
40
- declare function getValidator(config: RhinestoneAccountConfig): Module;
41
- export declare function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled, }: WebauthnValidatorSignature): `0x${string}`;
42
- export declare function isRip7212SupportedNetwork(chain: Chain): boolean;
43
- export { HOOK_ADDRESS, getSetup, getValidator };
29
+ declare function getSetup(config: RhinestoneAccountConfig): Promise<ModeleSetup>;
30
+ declare function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled, }: WebauthnValidatorSignature): `0x${string}`;
31
+ declare function isRip7212SupportedNetwork(chain: Chain): boolean;
32
+ export { HOOK_ADDRESS, getSetup, getOwnerValidator, getWebauthnValidatorSignature, isRip7212SupportedNetwork, };
44
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,KAAK,EAEL,GAAG,EAIJ,MAAM,MAAM,CAAA;AAYb,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,KAAK,UAAU,GACX,OAAO,wBAAwB,GAC/B,OAAO,uBAAuB,GAC9B,OAAO,uBAAuB,GAC9B,OAAO,mBAAmB,CAAA;AAE9B,UAAU,MAAM;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,GAAG,CAAA;IACf,iBAAiB,EAAE,GAAG,CAAA;IACtB,IAAI,EAAE,UAAU,CAAA;CACjB;AAcD,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3B;AAED,UAAU,0BAA0B;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,SAAS,EAAE,iBAAiB,GAAG,GAAG,GAAG,UAAU,CAAA;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,UAAU,iBAAiB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,QAAA,MAAM,wBAAwB,KAAK,CAAA;AACnC,QAAA,MAAM,uBAAuB,KAAK,CAAA;AAClC,QAAA,MAAM,uBAAuB,KAAK,CAAA;AAClC,QAAA,MAAM,mBAAmB,KAAK,CAAA;AAc9B,QAAA,MAAM,YAAY,EAAE,OAAsD,CAAA;AAM1E,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,iBAAS,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,WAAW,CAoE9D;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,uBAAuB,UAcpD;AAqFD,wBAAgB,6BAA6B,CAAC,EAC5C,QAAQ,EACR,SAAS,EACT,cAAsB,GACvB,EAAE,0BAA0B,iBA6C5B;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,KAAK,WAarD;AA0BD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,KAAK,EAEL,GAAG,EAEJ,MAAM,MAAM,CAAA;AAYb,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,OAAO,EACL,MAAM,EAGP,MAAM,UAAU,CAAA;AACjB,OAAO,EAIL,YAAY,EAGb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAA4B,MAAM,cAAc,CAAA;AAE1E,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3B;AAED,UAAU,0BAA0B;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,SAAS,EAAE,iBAAiB,GAAG,GAAG,GAAG,UAAU,CAAA;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,UAAU,iBAAiB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,iBAAe,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAgE7E;AAED,iBAAS,6BAA6B,CAAC,EACrC,QAAQ,EACR,SAAS,EACT,cAAsB,GACvB,EAAE,0BAA0B,iBA6C5B;AAED,iBAAS,yBAAyB,CAAC,KAAK,EAAE,KAAK,WAa9C;AAaD,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,6BAA6B,EAC7B,yBAAyB,GAC1B,CAAA"}
@@ -1,28 +1,15 @@
1
- import { bytesToHex, encodeAbiParameters, hexToBytes, keccak256, toHex, } from 'viem';
1
+ import { bytesToHex, encodeAbiParameters, hexToBytes, } from 'viem';
2
2
  import { arbitrum, arbitrumSepolia, base, baseSepolia, optimism, optimismSepolia, polygon, polygonAmoy, } from 'viem/chains';
3
- const MODULE_TYPE_ID_VALIDATOR = 1n;
4
- const MODULE_TYPE_ID_EXECUTOR = 2n;
5
- const MODULE_TYPE_ID_FALLBACK = 3n;
6
- const MODULE_TYPE_ID_HOOK = 4n;
7
- const OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS = '0x6D0515e8E499468DCe9583626f0cA15b887f9d03';
8
- const RHINESTONE_MODULE_REGISTRY_ADDRESS = '0x000000000069e2a187aeffb852bf3ccdc95151b2';
9
- const RHINESTONE_ATTESTER_ADDRESS = '0x000000333034E9f539ce08819E12c1b8Cb29084d';
10
- const OWNABLE_VALIDATOR_ADDRESS = '0x2483DA3A338895199E5e538530213157e931Bf06';
11
- const WEBAUTHN_VALIDATOR_ADDRESS = '0x2f167e55d42584f65e2e30a748f41ee75a311414';
12
- const HOOK_ADDRESS = '0x0000000000f6Ed8Be424d673c63eeFF8b9267420';
13
- const TARGET_MODULE_ADDRESS = '0x0000000000E5a37279A001301A837a91b5de1D5E';
14
- const SAME_CHAIN_MODULE_ADDRESS = '0x000000000043ff16d5776c7F0f65Ec485C17Ca04';
15
- function getSetup(config) {
16
- const validator = getValidator(config);
17
- const validators = [
18
- {
19
- address: validator.address,
20
- initData: validator.initData,
21
- deInitData: '0x',
22
- additionalContext: '0x',
23
- type: MODULE_TYPE_ID_VALIDATOR,
24
- },
25
- ];
3
+ import { MODULE_TYPE_ID_EXECUTOR, MODULE_TYPE_ID_FALLBACK, } from './common';
4
+ import { OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, } from './omni-account';
5
+ import { getOwnerValidator, getSmartSessionValidator } from './validators';
6
+ async function getSetup(config) {
7
+ const ownerValidator = getOwnerValidator(config);
8
+ const smartSessionValidator = getSmartSessionValidator(config);
9
+ const validators = [ownerValidator];
10
+ if (smartSessionValidator) {
11
+ validators.push(smartSessionValidator);
12
+ }
26
13
  const executors = [
27
14
  {
28
15
  address: SAME_CHAIN_MODULE_ADDRESS,
@@ -73,88 +60,7 @@ function getSetup(config) {
73
60
  threshold: 1,
74
61
  };
75
62
  }
76
- function getValidator(config) {
77
- const ownerSet = config.owners;
78
- switch (ownerSet.type) {
79
- case 'ecdsa':
80
- return getOwnableValidator({
81
- threshold: ownerSet.threshold ?? 1,
82
- owners: ownerSet.accounts.map((account) => account.address),
83
- });
84
- case 'passkey':
85
- return getWebAuthnValidator({
86
- pubKey: ownerSet.account.publicKey,
87
- authenticatorId: ownerSet.account.id,
88
- });
89
- }
90
- }
91
- function getOwnableValidator({ threshold, owners, }) {
92
- return {
93
- address: OWNABLE_VALIDATOR_ADDRESS,
94
- initData: encodeAbiParameters([
95
- { name: 'threshold', type: 'uint256' },
96
- { name: 'owners', type: 'address[]' },
97
- ], [
98
- BigInt(threshold),
99
- owners.map((owner) => owner.toLowerCase()).sort(),
100
- ]),
101
- deInitData: '0x',
102
- additionalContext: '0x',
103
- type: MODULE_TYPE_ID_VALIDATOR,
104
- };
105
- }
106
- function getWebAuthnValidator(webAuthnCredential) {
107
- let pubKeyX;
108
- let pubKeyY;
109
- // Distinguish between PublicKey and Hex / byte encoded public key
110
- if (typeof webAuthnCredential.pubKey === 'string' ||
111
- webAuthnCredential.pubKey instanceof Uint8Array) {
112
- // It's a P256Credential
113
- const { x, y, prefix } = parsePublicKey(webAuthnCredential.pubKey);
114
- pubKeyX = x;
115
- pubKeyY = y;
116
- if (prefix && prefix !== 4) {
117
- throw new Error('Only uncompressed public keys are supported');
118
- }
119
- }
120
- else {
121
- // It's already a PublicKey
122
- pubKeyX = webAuthnCredential.pubKey.x;
123
- pubKeyY = webAuthnCredential.pubKey.y;
124
- }
125
- return {
126
- address: WEBAUTHN_VALIDATOR_ADDRESS,
127
- initData: encodeAbiParameters([
128
- {
129
- components: [
130
- {
131
- name: 'pubKeyX',
132
- type: 'uint256',
133
- },
134
- {
135
- name: 'pubKeyY',
136
- type: 'uint256',
137
- },
138
- ],
139
- type: 'tuple',
140
- },
141
- {
142
- type: 'bytes32',
143
- name: 'authenticatorIdHash',
144
- },
145
- ], [
146
- {
147
- pubKeyX,
148
- pubKeyY,
149
- },
150
- keccak256(toHex(webAuthnCredential.authenticatorId)),
151
- ]),
152
- deInitData: '0x',
153
- additionalContext: '0x',
154
- type: MODULE_TYPE_ID_VALIDATOR,
155
- };
156
- }
157
- export function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled = false, }) {
63
+ function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled = false, }) {
158
64
  const { authenticatorData, clientDataJSON, typeIndex } = webauthn;
159
65
  let r;
160
66
  let s;
@@ -198,7 +104,7 @@ export function getWebauthnValidatorSignature({ webauthn, signature, usePrecompi
198
104
  usePrecompiled,
199
105
  ]);
200
106
  }
201
- export function isRip7212SupportedNetwork(chain) {
107
+ function isRip7212SupportedNetwork(chain) {
202
108
  const supportedChains = [
203
109
  optimism,
204
110
  optimismSepolia,
@@ -220,15 +126,4 @@ function parseSignature(signature) {
220
126
  s: BigInt(bytesToHex(s)),
221
127
  };
222
128
  }
223
- function parsePublicKey(publicKey) {
224
- const bytes = typeof publicKey === 'string' ? hexToBytes(publicKey) : publicKey;
225
- const offset = bytes.length === 65 ? 1 : 0;
226
- const x = bytes.slice(offset, 32 + offset);
227
- const y = bytes.slice(32 + offset, 64 + offset);
228
- return {
229
- prefix: bytes.length === 65 ? bytes[0] : undefined,
230
- x: BigInt(bytesToHex(x)),
231
- y: BigInt(bytesToHex(y)),
232
- };
233
- }
234
- export { HOOK_ADDRESS, getSetup, getValidator };
129
+ export { HOOK_ADDRESS, getSetup, getOwnerValidator, getWebauthnValidatorSignature, isRip7212SupportedNetwork, };
@@ -0,0 +1,9 @@
1
+ import { Address } from 'viem';
2
+ declare const OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS: Address;
3
+ declare const RHINESTONE_MODULE_REGISTRY_ADDRESS: Address;
4
+ declare const RHINESTONE_ATTESTER_ADDRESS: Address;
5
+ declare const HOOK_ADDRESS: Address;
6
+ declare const TARGET_MODULE_ADDRESS: Address;
7
+ declare const SAME_CHAIN_MODULE_ADDRESS: Address;
8
+ export { OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, };
9
+ //# sourceMappingURL=omni-account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omni-account.d.ts","sourceRoot":"","sources":["../../modules/omni-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAE9C,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAC9C,QAAA,MAAM,2BAA2B,EAAE,OACW,CAAA;AAE9C,QAAA,MAAM,YAAY,EAAE,OAAsD,CAAA;AAC1E,QAAA,MAAM,qBAAqB,EAAE,OACiB,CAAA;AAC9C,QAAA,MAAM,yBAAyB,EAAE,OACa,CAAA;AAE9C,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,GAC1B,CAAA"}
@@ -0,0 +1,7 @@
1
+ const OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS = '0x6D0515e8E499468DCe9583626f0cA15b887f9d03';
2
+ const RHINESTONE_MODULE_REGISTRY_ADDRESS = '0x000000000069e2a187aeffb852bf3ccdc95151b2';
3
+ const RHINESTONE_ATTESTER_ADDRESS = '0x000000333034E9f539ce08819E12c1b8Cb29084d';
4
+ const HOOK_ADDRESS = '0x0000000000f6Ed8Be424d673c63eeFF8b9267420';
5
+ const TARGET_MODULE_ADDRESS = '0x0000000000E5a37279A001301A837a91b5de1D5E';
6
+ const SAME_CHAIN_MODULE_ADDRESS = '0x000000000043ff16d5776c7F0f65Ec485C17Ca04';
7
+ export { OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, };
@@ -0,0 +1,31 @@
1
+ import { Address, Chain, Hex, PublicClient } from 'viem';
2
+ import { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
3
+ import { Module } from './common';
4
+ type SmartSessionModeType = typeof SMART_SESSION_MODE_USE | typeof SMART_SESSION_MODE_ENABLE | typeof SMART_SESSION_MODE_UNSAFE_ENABLE;
5
+ declare const SMART_SESSIONS_VALIDATOR_ADDRESS: Address;
6
+ declare const SMART_SESSION_MODE_USE = "0x00";
7
+ declare const SMART_SESSION_MODE_ENABLE = "0x01";
8
+ declare const SMART_SESSION_MODE_UNSAFE_ENABLE = "0x02";
9
+ declare function getOwnerValidator(config: RhinestoneAccountConfig): Module;
10
+ declare function getEnableSessionCall(chain: Chain, session: Session): Promise<{
11
+ to: `0x${string}`;
12
+ data: `0x${string}`;
13
+ }>;
14
+ declare function getSessionAllowedERC7739Content(chain: Chain): Promise<{
15
+ appDomainSeparator: `0x${string}`;
16
+ contentsType: string;
17
+ }>;
18
+ declare function getSmartSessionValidator(config: RhinestoneAccountConfig): Module | null;
19
+ declare function isSessionEnabled(client: PublicClient, address: Address, permissionId: Hex): Promise<boolean>;
20
+ declare function encodeSmartSessionSignature(mode: SmartSessionModeType, permissionId: Hex, signature: Hex): `0x${string}`;
21
+ declare function getPermissionId(session: Session): `0x${string}`;
22
+ declare function getMockSinature(ownerSet: OwnerSet): Hex;
23
+ declare function getAccountEIP712Domain(client: PublicClient, account: Address): Promise<{
24
+ name: string;
25
+ version: string;
26
+ chainId: bigint;
27
+ verifyingContract: `0x${string}`;
28
+ salt: `0x${string}`;
29
+ }>;
30
+ export { SMART_SESSION_MODE_USE, SMART_SESSION_MODE_ENABLE, SMART_SESSIONS_VALIDATOR_ADDRESS, getOwnerValidator, getSmartSessionValidator, getEnableSessionCall, encodeSmartSessionSignature, getPermissionId, getMockSinature, getAccountEIP712Domain, isSessionEnabled, getSessionAllowedERC7739Content, };
31
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../modules/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAOL,GAAG,EAKH,YAAY,EAKb,MAAM,MAAM,CAAA;AAEb,OAAO,EACL,QAAQ,EAER,uBAAuB,EACvB,OAAO,EAER,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,MAAM,EAA4B,MAAM,UAAU,CAAA;AAwE3D,KAAK,oBAAoB,GACrB,OAAO,sBAAsB,GAC7B,OAAO,yBAAyB,GAChC,OAAO,gCAAgC,CAAA;AAM3C,QAAA,MAAM,gCAAgC,EAAE,OACM,CAAA;AAE9C,QAAA,MAAM,sBAAsB,SAAS,CAAA;AACrC,QAAA,MAAM,yBAAyB,SAAS,CAAA;AACxC,QAAA,MAAM,gCAAgC,SAAS,CAAA;AA8B/C,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAEzD;AAED,iBAAe,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO;;;GAsBjE;AA6BD,iBAAe,+BAA+B,CAAC,KAAK,EAAE,KAAK;;;GAgB1D;AAyDD,iBAAS,wBAAwB,CAC/B,MAAM,EAAE,uBAAuB,GAC9B,MAAM,GAAG,IAAI,CAWf;AA6RD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,GAAG,oBAiClB;AAED,iBAAS,2BAA2B,CAClC,IAAI,EAAE,oBAAoB,EAC1B,YAAY,EAAE,GAAG,EACjB,SAAS,EAAE,GAAG,iBAcf;AAED,iBAAS,eAAe,CAAC,OAAO,EAAE,OAAO,iBAyBxC;AAED,iBAAS,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAUhD;AAED,iBAAe,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO;;;;;;GAoD3E;AAED,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gCAAgC,EAChC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,+BAA+B,GAChC,CAAA"}