@rhinestone/sdk 0.2.0 → 0.3.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.
- package/README.md +7 -19
- package/dist/accounts/index.d.ts +15535 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +242 -0
- package/dist/accounts/nexus.d.ts +23281 -0
- package/dist/accounts/nexus.d.ts.map +1 -0
- package/dist/accounts/nexus.js +230 -0
- package/dist/accounts/safe.d.ts +15 -0
- package/dist/accounts/safe.d.ts.map +1 -0
- package/dist/{services/account → accounts}/safe.js +36 -37
- package/dist/accounts/utils.d.ts +27 -0
- package/dist/accounts/utils.d.ts.map +1 -0
- package/dist/accounts/utils.js +155 -0
- package/dist/examples/abi/weth.d.ts +214 -0
- package/dist/examples/abi/weth.d.ts.map +1 -0
- package/dist/examples/abi/weth.js +279 -0
- package/dist/examples/cross-chain-ss.d.ts +1 -0
- package/dist/examples/cross-chain-ss.d.ts.map +1 -0
- package/dist/{example.js → examples/cross-chain-ss.js} +70 -44
- package/dist/examples/omni-account.d.ts +1 -0
- package/dist/examples/omni-account.d.ts.map +1 -0
- package/dist/examples/omni-account.js +169 -0
- package/dist/examples/smart-sessions.d.ts +1 -0
- package/dist/examples/smart-sessions.d.ts.map +1 -0
- package/dist/examples/smart-sessions.js +216 -0
- package/dist/execution/index.d.ts +31 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +222 -0
- package/dist/execution/smart-session.d.ts +14 -0
- package/dist/execution/smart-session.d.ts.map +1 -0
- package/dist/execution/smart-session.js +83 -0
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/dist/modules/abi/smart-sessions.d.ts +42 -0
- package/dist/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/modules/abi/smart-sessions.js +128 -0
- package/dist/modules/common.d.ts +16 -0
- package/dist/modules/common.d.ts.map +1 -0
- package/dist/modules/common.js +5 -0
- package/dist/modules/index.d.ts +33 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +129 -0
- package/dist/modules/omni-account.d.ts +9 -0
- package/dist/modules/omni-account.d.ts.map +1 -0
- package/dist/modules/omni-account.js +7 -0
- package/dist/modules/validators.d.ts +31 -0
- package/dist/modules/validators.d.ts.map +1 -0
- package/dist/modules/validators.js +518 -0
- package/dist/{services/orchestrator → orchestrator}/client.d.ts +2 -5
- package/dist/orchestrator/client.d.ts.map +1 -0
- package/dist/orchestrator/consts.d.ts +4 -0
- package/dist/orchestrator/consts.d.ts.map +1 -0
- package/dist/orchestrator/consts.js +3 -0
- package/dist/orchestrator/error.d.ts.map +1 -0
- package/dist/orchestrator/index.d.ts +9 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +10 -0
- package/dist/orchestrator/registry.d.ts +5 -0
- package/dist/orchestrator/registry.d.ts.map +1 -0
- package/dist/orchestrator/registry.js +187 -0
- package/dist/{services/orchestrator → orchestrator}/types.d.ts +39 -23
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/orchestrator/types.js +7 -0
- package/dist/orchestrator/utils.d.ts +11 -0
- package/dist/orchestrator/utils.d.ts.map +1 -0
- package/dist/{services/orchestrator → orchestrator}/utils.js +20 -6
- package/dist/types.d.ts +70 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/example.d.ts +0 -1
- package/dist/example.d.ts.map +0 -1
- package/dist/services/account/index.d.ts +0 -13
- package/dist/services/account/index.d.ts.map +0 -1
- package/dist/services/account/index.js +0 -54
- package/dist/services/account/nexus.d.ts +0 -9
- package/dist/services/account/nexus.d.ts.map +0 -1
- package/dist/services/account/nexus.js +0 -67
- package/dist/services/account/safe.d.ts +0 -9
- package/dist/services/account/safe.d.ts.map +0 -1
- package/dist/services/modules.d.ts +0 -32
- package/dist/services/modules.d.ts.map +0 -1
- package/dist/services/modules.js +0 -166
- package/dist/services/orchestrator/client.d.ts.map +0 -1
- package/dist/services/orchestrator/consts.d.ts +0 -6
- package/dist/services/orchestrator/consts.d.ts.map +0 -1
- package/dist/services/orchestrator/consts.js +0 -4
- package/dist/services/orchestrator/error.d.ts.map +0 -1
- package/dist/services/orchestrator/index.d.ts +0 -8
- package/dist/services/orchestrator/index.d.ts.map +0 -1
- package/dist/services/orchestrator/index.js +0 -9
- package/dist/services/orchestrator/types.d.ts.map +0 -1
- package/dist/services/orchestrator/types.js +0 -6
- package/dist/services/orchestrator/utils.d.ts +0 -7
- package/dist/services/orchestrator/utils.d.ts.map +0 -1
- package/dist/services/transaction.d.ts +0 -6
- package/dist/services/transaction.d.ts.map +0 -1
- package/dist/services/transaction.js +0 -93
- /package/dist/{services/orchestrator → orchestrator}/client.js +0 -0
- /package/dist/{services/orchestrator → orchestrator}/error.d.ts +0 -0
- /package/dist/{services/orchestrator → orchestrator}/error.js +0 -0
|
@@ -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,10 +1,21 @@
|
|
|
1
1
|
import { RhinestoneAccountConfig, Transaction } 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<
|
|
5
|
-
waitForExecution: (
|
|
6
|
-
|
|
7
|
-
|
|
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 };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC9D,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"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getAddress as getAddressInternal } from './
|
|
1
|
+
import { sendTransaction as sendTransactionInternal, waitForExecution as waitForExecutionInternal, } from './execution';
|
|
2
|
+
import { getAddress as getAddressInternal } from './accounts';
|
|
3
3
|
async function createRhinestoneAccount(config) {
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return
|
|
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,33 @@
|
|
|
1
|
+
import { Address, Chain, Hex } from 'viem';
|
|
2
|
+
import { RhinestoneAccountConfig } from '../types';
|
|
3
|
+
import { Module } from './common';
|
|
4
|
+
import { HOOK_ADDRESS } from './omni-account';
|
|
5
|
+
import { getOwnerValidator } from './validators';
|
|
6
|
+
interface WebAuthnData {
|
|
7
|
+
authenticatorData: Hex;
|
|
8
|
+
clientDataJSON: string;
|
|
9
|
+
typeIndex: number | bigint;
|
|
10
|
+
}
|
|
11
|
+
interface WebauthnValidatorSignature {
|
|
12
|
+
webauthn: WebAuthnData;
|
|
13
|
+
signature: WebauthnSignature | Hex | Uint8Array;
|
|
14
|
+
usePrecompiled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface WebauthnSignature {
|
|
17
|
+
r: bigint;
|
|
18
|
+
s: bigint;
|
|
19
|
+
}
|
|
20
|
+
interface ModeleSetup {
|
|
21
|
+
validators: Module[];
|
|
22
|
+
executors: Module[];
|
|
23
|
+
fallbacks: Module[];
|
|
24
|
+
hooks: Module[];
|
|
25
|
+
registry: Address;
|
|
26
|
+
attesters: Address[];
|
|
27
|
+
threshold: number;
|
|
28
|
+
}
|
|
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, };
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { bytesToHex, encodeAbiParameters, hexToBytes, } from 'viem';
|
|
2
|
+
import { arbitrum, arbitrumSepolia, base, baseSepolia, optimism, optimismSepolia, polygon, polygonAmoy, } from 'viem/chains';
|
|
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
|
+
}
|
|
13
|
+
const executors = [
|
|
14
|
+
{
|
|
15
|
+
address: SAME_CHAIN_MODULE_ADDRESS,
|
|
16
|
+
initData: '0x',
|
|
17
|
+
deInitData: '0x',
|
|
18
|
+
additionalContext: '0x',
|
|
19
|
+
type: MODULE_TYPE_ID_EXECUTOR,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
address: TARGET_MODULE_ADDRESS,
|
|
23
|
+
initData: '0x',
|
|
24
|
+
deInitData: '0x',
|
|
25
|
+
additionalContext: '0x',
|
|
26
|
+
type: MODULE_TYPE_ID_EXECUTOR,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
address: HOOK_ADDRESS,
|
|
30
|
+
initData: '0x',
|
|
31
|
+
deInitData: '0x',
|
|
32
|
+
additionalContext: '0x',
|
|
33
|
+
type: MODULE_TYPE_ID_EXECUTOR,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
const fallbacks = [
|
|
37
|
+
{
|
|
38
|
+
address: TARGET_MODULE_ADDRESS,
|
|
39
|
+
initData: encodeAbiParameters([
|
|
40
|
+
{ name: 'selector', type: 'bytes4' },
|
|
41
|
+
{ name: 'flags', type: 'bytes1' },
|
|
42
|
+
{ name: 'data', type: 'bytes' },
|
|
43
|
+
], ['0x3a5be8cb', '0x00', '0x']),
|
|
44
|
+
deInitData: '0x',
|
|
45
|
+
additionalContext: '0x',
|
|
46
|
+
type: MODULE_TYPE_ID_FALLBACK,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
const hooks = [];
|
|
50
|
+
return {
|
|
51
|
+
validators,
|
|
52
|
+
executors,
|
|
53
|
+
fallbacks,
|
|
54
|
+
hooks,
|
|
55
|
+
registry: RHINESTONE_MODULE_REGISTRY_ADDRESS,
|
|
56
|
+
attesters: [
|
|
57
|
+
RHINESTONE_ATTESTER_ADDRESS,
|
|
58
|
+
OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS,
|
|
59
|
+
],
|
|
60
|
+
threshold: 1,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled = false, }) {
|
|
64
|
+
const { authenticatorData, clientDataJSON, typeIndex } = webauthn;
|
|
65
|
+
let r;
|
|
66
|
+
let s;
|
|
67
|
+
if (typeof signature === 'string' || signature instanceof Uint8Array) {
|
|
68
|
+
const parsedSignature = parseSignature(signature);
|
|
69
|
+
r = parsedSignature.r;
|
|
70
|
+
s = parsedSignature.s;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
r = signature.r;
|
|
74
|
+
s = signature.s;
|
|
75
|
+
}
|
|
76
|
+
return encodeAbiParameters([
|
|
77
|
+
{ type: 'bytes', name: 'authenticatorData' },
|
|
78
|
+
{
|
|
79
|
+
type: 'string',
|
|
80
|
+
name: 'clientDataJSON',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'uint256',
|
|
84
|
+
name: 'responseTypeLocation',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: 'uint256',
|
|
88
|
+
name: 'r',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'uint256',
|
|
92
|
+
name: 's',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'bool',
|
|
96
|
+
name: 'usePrecompiled',
|
|
97
|
+
},
|
|
98
|
+
], [
|
|
99
|
+
authenticatorData,
|
|
100
|
+
clientDataJSON,
|
|
101
|
+
typeof typeIndex === 'bigint' ? typeIndex : BigInt(typeIndex),
|
|
102
|
+
r,
|
|
103
|
+
s,
|
|
104
|
+
usePrecompiled,
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
function isRip7212SupportedNetwork(chain) {
|
|
108
|
+
const supportedChains = [
|
|
109
|
+
optimism,
|
|
110
|
+
optimismSepolia,
|
|
111
|
+
polygon,
|
|
112
|
+
polygonAmoy,
|
|
113
|
+
base,
|
|
114
|
+
baseSepolia,
|
|
115
|
+
arbitrum,
|
|
116
|
+
arbitrumSepolia,
|
|
117
|
+
];
|
|
118
|
+
return supportedChains.includes(chain);
|
|
119
|
+
}
|
|
120
|
+
function parseSignature(signature) {
|
|
121
|
+
const bytes = typeof signature === 'string' ? hexToBytes(signature) : signature;
|
|
122
|
+
const r = bytes.slice(0, 32);
|
|
123
|
+
const s = bytes.slice(32, 64);
|
|
124
|
+
return {
|
|
125
|
+
r: BigInt(bytesToHex(r)),
|
|
126
|
+
s: BigInt(bytesToHex(s)),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
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;AA0RD,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"}
|