@rhinestone/sdk 0.2.1 → 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 +4 -4
- package/dist/accounts/index.d.ts +15515 -4
- package/dist/accounts/index.d.ts.map +1 -1
- package/dist/accounts/index.js +69 -10
- package/dist/accounts/nexus.d.ts +15542 -32
- package/dist/accounts/nexus.d.ts.map +1 -1
- package/dist/accounts/nexus.js +86 -65
- package/dist/accounts/safe.d.ts +3 -1
- package/dist/accounts/safe.d.ts.map +1 -1
- package/dist/accounts/safe.js +8 -2
- 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} +59 -22
- 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 +28 -3
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +177 -47
- 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 +10 -10
- 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 +7 -18
- package/dist/modules/index.d.ts.map +1 -1
- package/dist/modules/index.js +14 -119
- 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/orchestrator/client.d.ts +2 -5
- package/dist/orchestrator/client.d.ts.map +1 -1
- package/dist/orchestrator/consts.d.ts +3 -1
- package/dist/orchestrator/consts.d.ts.map +1 -1
- package/dist/orchestrator/consts.js +3 -1
- package/dist/orchestrator/index.d.ts +5 -3
- package/dist/orchestrator/index.d.ts.map +1 -1
- package/dist/orchestrator/index.js +5 -4
- 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/orchestrator/types.d.ts +39 -23
- package/dist/orchestrator/types.d.ts.map +1 -1
- package/dist/orchestrator/types.js +7 -6
- package/dist/orchestrator/utils.d.ts +8 -4
- package/dist/orchestrator/utils.d.ts.map +1 -1
- package/dist/orchestrator/utils.js +19 -5
- package/dist/types.d.ts +64 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/example.d.ts +0 -1
- package/dist/example.d.ts.map +0 -1
|
@@ -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"}
|
package/dist/modules/index.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { Address, Chain, Hex } from 'viem';
|
|
2
2
|
import { RhinestoneAccountConfig } from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
41
|
-
|
|
42
|
-
export
|
|
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,
|
|
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"}
|
package/dist/modules/index.js
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import { bytesToHex, encodeAbiParameters, hexToBytes,
|
|
1
|
+
import { bytesToHex, encodeAbiParameters, hexToBytes, } from 'viem';
|
|
2
2
|
import { arbitrum, arbitrumSepolia, base, baseSepolia, optimism, optimismSepolia, polygon, polygonAmoy, } from 'viem/chains';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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;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"}
|