@rhinestone/sdk 0.1.0 → 0.2.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.
- package/README.md +4 -16
- package/dist/accounts/index.d.ts +24 -0
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/accounts/index.js +183 -0
- package/dist/accounts/nexus.d.ts +7771 -0
- package/dist/accounts/nexus.d.ts.map +1 -0
- package/dist/accounts/nexus.js +209 -0
- package/dist/accounts/safe.d.ts +13 -0
- package/dist/accounts/safe.d.ts.map +1 -0
- package/dist/accounts/safe.js +100 -0
- 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/example.js +32 -27
- package/dist/{services/transaction.d.ts → execution/index.d.ts} +2 -2
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/{services/transaction.js → execution/index.js} +12 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{services/modules.d.ts → modules/index.d.ts} +18 -8
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/{services/modules.js → modules/index.js} +75 -15
- package/dist/orchestrator/client.d.ts.map +1 -0
- package/dist/orchestrator/consts.d.ts +2 -0
- package/dist/orchestrator/consts.d.ts.map +1 -0
- package/dist/orchestrator/consts.js +1 -0
- package/dist/orchestrator/error.d.ts.map +1 -0
- package/dist/orchestrator/index.d.ts +7 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/{services/orchestrator → orchestrator}/index.js +2 -2
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/orchestrator/utils.d.ts.map +1 -0
- package/dist/{services/orchestrator → orchestrator}/utils.js +1 -1
- package/dist/types.d.ts +8 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/services/account.d.ts +0 -13
- package/dist/services/account.d.ts.map +0 -1
- package/dist/services/account.js +0 -127
- package/dist/services/modules.d.ts.map +0 -1
- 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/types.d.ts.map +0 -1
- package/dist/services/orchestrator/utils.d.ts.map +0 -1
- package/dist/services/transaction.d.ts.map +0 -1
- /package/dist/{services/orchestrator → orchestrator}/client.d.ts +0 -0
- /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
- /package/dist/{services/orchestrator → orchestrator}/types.d.ts +0 -0
- /package/dist/{services/orchestrator → orchestrator}/types.js +0 -0
- /package/dist/{services/orchestrator → orchestrator}/utils.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,GAAG,EAQT,MAAM,MAAM,CAAA;AAQb,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAalD,iBAAe,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;GA8E3D;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB;;;IAqDxD;AAED,iBAAe,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;8rBAoFigH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAHvn/B;AAED,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { encodeAbiParameters, encodeFunctionData, keccak256, parseAbi, zeroAddress, concat, toHex, } from 'viem';
|
|
2
|
+
import { entryPoint07Address, getUserOperationHash, entryPoint07Abi, toSmartAccount, } from 'viem/account-abstraction';
|
|
3
|
+
import { getSetup as getModuleSetup } from '../modules';
|
|
4
|
+
import { encode7579Calls, getAccountNonce } from './utils';
|
|
5
|
+
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000004f43c49e93c970e84001853a70923b03';
|
|
6
|
+
const NEXUS_FACTORY_ADDRESS = '0x000000001D1D5004a02bAfAb9de2D6CE5b7B13de';
|
|
7
|
+
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000D3254452a909E4eeD47455Af7E27C289';
|
|
8
|
+
const K1_MEE_VALIDATOR_ADDRESS = '0x00000000d12897ddadc2044614a9677b191a2d95';
|
|
9
|
+
async function getDeployArgs(config) {
|
|
10
|
+
const salt = keccak256('0x');
|
|
11
|
+
const moduleSetup = getModuleSetup(config);
|
|
12
|
+
const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [
|
|
13
|
+
NEXUS_BOOTSTRAP_ADDRESS,
|
|
14
|
+
encodeFunctionData({
|
|
15
|
+
abi: parseAbi([
|
|
16
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
17
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
18
|
+
'struct RegistryConfig {address registry;address[] attesters;uint8 threshold;}',
|
|
19
|
+
'function initNexus(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks,RegistryConfig registryConfig) external',
|
|
20
|
+
]),
|
|
21
|
+
functionName: 'initNexus',
|
|
22
|
+
args: [
|
|
23
|
+
moduleSetup.validators.map((v) => ({
|
|
24
|
+
module: v.address,
|
|
25
|
+
initData: v.initData,
|
|
26
|
+
})),
|
|
27
|
+
moduleSetup.executors.map((e) => ({
|
|
28
|
+
module: e.address,
|
|
29
|
+
initData: e.initData,
|
|
30
|
+
})),
|
|
31
|
+
{
|
|
32
|
+
module: zeroAddress,
|
|
33
|
+
initData: '0x',
|
|
34
|
+
},
|
|
35
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
36
|
+
module: f.address,
|
|
37
|
+
initData: f.initData,
|
|
38
|
+
})),
|
|
39
|
+
[],
|
|
40
|
+
{
|
|
41
|
+
registry: moduleSetup.registry,
|
|
42
|
+
attesters: moduleSetup.attesters,
|
|
43
|
+
threshold: moduleSetup.threshold,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
const factoryData = encodeFunctionData({
|
|
49
|
+
abi: parseAbi(['function createAccount(bytes,bytes32)']),
|
|
50
|
+
functionName: 'createAccount',
|
|
51
|
+
args: [initData, salt],
|
|
52
|
+
});
|
|
53
|
+
const creationCode = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
54
|
+
const initializationCallData = encodeFunctionData({
|
|
55
|
+
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
56
|
+
functionName: 'initializeAccount',
|
|
57
|
+
args: [initData],
|
|
58
|
+
});
|
|
59
|
+
const accountInitData = encodeAbiParameters([
|
|
60
|
+
{
|
|
61
|
+
name: 'address',
|
|
62
|
+
type: 'address',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'calldata',
|
|
66
|
+
type: 'bytes',
|
|
67
|
+
},
|
|
68
|
+
], [NEXUS_IMPLEMENTATION_ADDRESS, initializationCallData]);
|
|
69
|
+
const hashedInitcode = keccak256(concat([creationCode, accountInitData]));
|
|
70
|
+
return {
|
|
71
|
+
factory: NEXUS_FACTORY_ADDRESS,
|
|
72
|
+
factoryData,
|
|
73
|
+
salt,
|
|
74
|
+
hashedInitcode,
|
|
75
|
+
implementation: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
76
|
+
initializationCallData,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function get7702InitCalls(config) {
|
|
80
|
+
const eoa = config.eoa;
|
|
81
|
+
if (!eoa) {
|
|
82
|
+
throw new Error('EIP-7702 accounts must have an EOA account');
|
|
83
|
+
}
|
|
84
|
+
const moduleSetup = getModuleSetup(config);
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
to: eoa.address,
|
|
88
|
+
data: encodeFunctionData({
|
|
89
|
+
abi: parseAbi([
|
|
90
|
+
'function setRegistry(address newRegistry, address[] calldata attesters, uint8 threshold)',
|
|
91
|
+
]),
|
|
92
|
+
functionName: 'setRegistry',
|
|
93
|
+
args: [
|
|
94
|
+
moduleSetup.registry,
|
|
95
|
+
moduleSetup.attesters,
|
|
96
|
+
moduleSetup.threshold,
|
|
97
|
+
],
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
...moduleSetup.validators.map((validator) => ({
|
|
101
|
+
to: eoa.address,
|
|
102
|
+
data: encodeFunctionData({
|
|
103
|
+
abi: parseAbi([
|
|
104
|
+
'function installModule(uint256 moduleTypeId, address module, bytes calldata initData)',
|
|
105
|
+
]),
|
|
106
|
+
functionName: 'installModule',
|
|
107
|
+
args: [validator.type, validator.address, validator.initData],
|
|
108
|
+
}),
|
|
109
|
+
})),
|
|
110
|
+
...moduleSetup.executors.map((executor) => ({
|
|
111
|
+
to: eoa.address,
|
|
112
|
+
data: encodeFunctionData({
|
|
113
|
+
abi: parseAbi([
|
|
114
|
+
'function installModule(uint256 moduleTypeId, address module, bytes calldata initData)',
|
|
115
|
+
]),
|
|
116
|
+
functionName: 'installModule',
|
|
117
|
+
args: [executor.type, executor.address, executor.initData],
|
|
118
|
+
}),
|
|
119
|
+
})),
|
|
120
|
+
...moduleSetup.fallbacks.map((fallback) => ({
|
|
121
|
+
to: eoa.address,
|
|
122
|
+
data: encodeFunctionData({
|
|
123
|
+
abi: parseAbi([
|
|
124
|
+
'function installModule(uint256 moduleTypeId, address module, bytes calldata initData)',
|
|
125
|
+
]),
|
|
126
|
+
functionName: 'installModule',
|
|
127
|
+
args: [fallback.type, fallback.address, fallback.initData],
|
|
128
|
+
}),
|
|
129
|
+
})),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
async function get7702SmartAccount(account, client) {
|
|
133
|
+
return await toSmartAccount({
|
|
134
|
+
client,
|
|
135
|
+
entryPoint: {
|
|
136
|
+
abi: entryPoint07Abi,
|
|
137
|
+
address: entryPoint07Address,
|
|
138
|
+
version: '0.7',
|
|
139
|
+
},
|
|
140
|
+
async decodeCalls() {
|
|
141
|
+
throw new Error('Not implemented');
|
|
142
|
+
},
|
|
143
|
+
async encodeCalls(calls) {
|
|
144
|
+
return encode7579Calls({
|
|
145
|
+
mode: {
|
|
146
|
+
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
147
|
+
revertOnError: false,
|
|
148
|
+
selector: '0x',
|
|
149
|
+
context: '0x',
|
|
150
|
+
},
|
|
151
|
+
callData: calls,
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
async getAddress() {
|
|
155
|
+
return account.address;
|
|
156
|
+
},
|
|
157
|
+
async getFactoryArgs() {
|
|
158
|
+
return {};
|
|
159
|
+
},
|
|
160
|
+
async getNonce(args) {
|
|
161
|
+
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
162
|
+
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
163
|
+
const defaultedValidationMode = '0x00';
|
|
164
|
+
const key = concat([
|
|
165
|
+
toHex(defaultedKey, { size: 3 }),
|
|
166
|
+
defaultedValidationMode,
|
|
167
|
+
zeroAddress,
|
|
168
|
+
]);
|
|
169
|
+
const address = await this.getAddress();
|
|
170
|
+
return getAccountNonce(client, {
|
|
171
|
+
address,
|
|
172
|
+
entryPointAddress: entryPoint07Address,
|
|
173
|
+
key: BigInt(key),
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
async getStubSignature() {
|
|
177
|
+
const dynamicPart = K1_MEE_VALIDATOR_ADDRESS.substring(2).padEnd(40, '0');
|
|
178
|
+
return `0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${dynamicPart}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`;
|
|
179
|
+
},
|
|
180
|
+
async signMessage() {
|
|
181
|
+
throw new Error('Not implemented');
|
|
182
|
+
},
|
|
183
|
+
async signTypedData() {
|
|
184
|
+
throw new Error('Not implemented');
|
|
185
|
+
},
|
|
186
|
+
async signUserOperation(parameters) {
|
|
187
|
+
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
188
|
+
if (!chainId)
|
|
189
|
+
throw new Error('Chain id not found');
|
|
190
|
+
const hash = getUserOperationHash({
|
|
191
|
+
userOperation: {
|
|
192
|
+
...userOperation,
|
|
193
|
+
sender: userOperation.sender ?? (await this.getAddress()),
|
|
194
|
+
signature: '0x',
|
|
195
|
+
},
|
|
196
|
+
entryPointAddress: entryPoint07Address,
|
|
197
|
+
entryPointVersion: '0.7',
|
|
198
|
+
chainId: chainId,
|
|
199
|
+
});
|
|
200
|
+
if (!account.signMessage) {
|
|
201
|
+
throw new Error('Sign message not supported by account');
|
|
202
|
+
}
|
|
203
|
+
return await account.signMessage({
|
|
204
|
+
message: { raw: hash },
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
export { getDeployArgs, get7702InitCalls, get7702SmartAccount };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RhinestoneAccountConfig } from '../types';
|
|
2
|
+
declare function getDeployArgs(config: RhinestoneAccountConfig): Promise<{
|
|
3
|
+
factory: `0x${string}`;
|
|
4
|
+
factoryData: `0x${string}`;
|
|
5
|
+
salt: `0x${string}`;
|
|
6
|
+
hashedInitcode: `0x${string}`;
|
|
7
|
+
implementation: `0x${string}`;
|
|
8
|
+
initializationCallData: null;
|
|
9
|
+
}>;
|
|
10
|
+
declare function get7702InitCalls(): never;
|
|
11
|
+
declare function get7702SmartAccount(): never;
|
|
12
|
+
export { getDeployArgs, get7702InitCalls, get7702SmartAccount };
|
|
13
|
+
//# sourceMappingURL=safe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../accounts/safe.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAclD,iBAAe,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;GA0E3D;AAED,iBAAS,gBAAgB,IAAI,KAAK,CAEjC;AAED,iBAAS,mBAAmB,IAAI,KAAK,CAEpC;AAsBD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { encodeFunctionData, encodePacked, keccak256, parseAbi, zeroAddress, } from 'viem';
|
|
2
|
+
import { getSetup as getModuleSetup } from '../modules';
|
|
3
|
+
const SAFE_7579_LAUNCHPAD_ADDRESS = '0x7579011aB74c46090561ea277Ba79D510c6C00ff';
|
|
4
|
+
const SAFE_7579_ADAPTER_ADDRESS = '0x7579ee8307284f293b1927136486880611f20002';
|
|
5
|
+
const SAFE_SINGLETON_ADDRESS = '0x29fcb43b46531bca003ddc8fcb67ffe91900c762';
|
|
6
|
+
const SAFE_PROXY_FACTORY_ADDRESS = '0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67';
|
|
7
|
+
const NO_SAFE_OWNER_ADDRESS = '0xbabe99e62d8bcbd3acf5ccbcfcd4f64fe75e5e72';
|
|
8
|
+
async function getDeployArgs(config) {
|
|
9
|
+
{
|
|
10
|
+
const owners = getOwners(config);
|
|
11
|
+
const threshold = getThreshold(config);
|
|
12
|
+
const moduleSetup = getModuleSetup(config);
|
|
13
|
+
const initData = encodeFunctionData({
|
|
14
|
+
abi: parseAbi([
|
|
15
|
+
'function setup(address[] calldata _owners,uint256 _threshold,address to,bytes calldata data,address fallbackHandler,address paymentToken,uint256 payment, address paymentReceiver) external',
|
|
16
|
+
]),
|
|
17
|
+
functionName: 'setup',
|
|
18
|
+
args: [
|
|
19
|
+
owners,
|
|
20
|
+
threshold,
|
|
21
|
+
SAFE_7579_LAUNCHPAD_ADDRESS,
|
|
22
|
+
encodeFunctionData({
|
|
23
|
+
abi: parseAbi([
|
|
24
|
+
'struct ModuleInit {address module;bytes initData;}',
|
|
25
|
+
'function addSafe7579(address safe7579,ModuleInit[] calldata validators,ModuleInit[] calldata executors,ModuleInit[] calldata fallbacks, ModuleInit[] calldata hooks,address[] calldata attesters,uint8 threshold) external',
|
|
26
|
+
]),
|
|
27
|
+
functionName: 'addSafe7579',
|
|
28
|
+
args: [
|
|
29
|
+
SAFE_7579_ADAPTER_ADDRESS,
|
|
30
|
+
moduleSetup.validators.map((v) => ({
|
|
31
|
+
module: v.address,
|
|
32
|
+
initData: v.initData,
|
|
33
|
+
})),
|
|
34
|
+
moduleSetup.executors.map((e) => ({
|
|
35
|
+
module: e.address,
|
|
36
|
+
initData: e.initData,
|
|
37
|
+
})),
|
|
38
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
39
|
+
module: f.address,
|
|
40
|
+
initData: f.initData,
|
|
41
|
+
})),
|
|
42
|
+
moduleSetup.hooks.map((h) => ({
|
|
43
|
+
module: h.address,
|
|
44
|
+
initData: h.initData,
|
|
45
|
+
})),
|
|
46
|
+
moduleSetup.attesters,
|
|
47
|
+
moduleSetup.threshold,
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
SAFE_7579_ADAPTER_ADDRESS,
|
|
51
|
+
zeroAddress,
|
|
52
|
+
BigInt(0),
|
|
53
|
+
zeroAddress,
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
const saltNonce = 0n;
|
|
57
|
+
const factoryData = encodeFunctionData({
|
|
58
|
+
abi: parseAbi([
|
|
59
|
+
'function createProxyWithNonce(address singleton,bytes calldata initializer,uint256 saltNonce) external payable returns (address)',
|
|
60
|
+
]),
|
|
61
|
+
functionName: 'createProxyWithNonce',
|
|
62
|
+
args: [SAFE_SINGLETON_ADDRESS, initData, saltNonce],
|
|
63
|
+
});
|
|
64
|
+
const salt = keccak256(encodePacked(['bytes32', 'uint256'], [keccak256(initData), saltNonce]));
|
|
65
|
+
const hashedInitcode = '0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee';
|
|
66
|
+
return {
|
|
67
|
+
factory: SAFE_PROXY_FACTORY_ADDRESS,
|
|
68
|
+
factoryData,
|
|
69
|
+
salt,
|
|
70
|
+
hashedInitcode,
|
|
71
|
+
implementation: SAFE_SINGLETON_ADDRESS,
|
|
72
|
+
initializationCallData: null,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function get7702InitCalls() {
|
|
77
|
+
throw new Error('EIP-7702 is not supported for Safe accounts');
|
|
78
|
+
}
|
|
79
|
+
function get7702SmartAccount() {
|
|
80
|
+
throw new Error('EIP-7702 is not supported for Safe accounts');
|
|
81
|
+
}
|
|
82
|
+
function getOwners(config) {
|
|
83
|
+
const ownerSet = config.owners;
|
|
84
|
+
switch (ownerSet.type) {
|
|
85
|
+
case 'ecdsa':
|
|
86
|
+
return ownerSet.accounts.map((account) => account.address);
|
|
87
|
+
case 'passkey':
|
|
88
|
+
return [NO_SAFE_OWNER_ADDRESS];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getThreshold(config) {
|
|
92
|
+
const ownerSet = config.owners;
|
|
93
|
+
switch (ownerSet.type) {
|
|
94
|
+
case 'ecdsa':
|
|
95
|
+
return ownerSet.threshold ? BigInt(ownerSet.threshold) : 1n;
|
|
96
|
+
case 'passkey':
|
|
97
|
+
return 1n;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export { getDeployArgs, get7702InitCalls, get7702SmartAccount };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Address, type Hex, type Client } from 'viem';
|
|
2
|
+
import { RhinestoneAccountConfig } from '../types';
|
|
3
|
+
type CallType = 'call' | 'delegatecall' | 'batchcall';
|
|
4
|
+
interface ExecutionMode<callType extends CallType> {
|
|
5
|
+
type: callType;
|
|
6
|
+
revertOnError?: boolean;
|
|
7
|
+
selector?: Hex;
|
|
8
|
+
context?: Hex;
|
|
9
|
+
}
|
|
10
|
+
interface EncodeCallDataParams<callType extends CallType> {
|
|
11
|
+
mode: ExecutionMode<callType>;
|
|
12
|
+
callData: readonly {
|
|
13
|
+
to: Address;
|
|
14
|
+
value?: bigint | undefined;
|
|
15
|
+
data?: Hex | undefined;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
interface GetAccountNonceParams {
|
|
19
|
+
address: Address;
|
|
20
|
+
entryPointAddress: Address;
|
|
21
|
+
key?: bigint;
|
|
22
|
+
}
|
|
23
|
+
declare function encode7579Calls<callType extends CallType>({ mode, callData, }: EncodeCallDataParams<callType>): Hex;
|
|
24
|
+
declare function getAccountNonce(client: Client, args: GetAccountNonceParams): Promise<bigint>;
|
|
25
|
+
declare function getBundlerClient(config: RhinestoneAccountConfig, client: Client): import("viem/account-abstraction").BundlerClient<import("viem").HttpTransport<undefined, false>, undefined, undefined, Client, undefined>;
|
|
26
|
+
export { encode7579Calls, getAccountNonce, getBundlerClient };
|
|
27
|
+
//# sourceMappingURL=utils.d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AO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { concatHex, encodeAbiParameters, encodeFunctionData, encodePacked, http, toBytes, toHex, } from 'viem';
|
|
2
|
+
import { readContract } from 'viem/actions';
|
|
3
|
+
import { getAction } from 'viem/utils';
|
|
4
|
+
import { createBundlerClient } from 'viem/account-abstraction';
|
|
5
|
+
function parseCallType(callType) {
|
|
6
|
+
switch (callType) {
|
|
7
|
+
case 'call':
|
|
8
|
+
return '0x00';
|
|
9
|
+
case 'batchcall':
|
|
10
|
+
return '0x01';
|
|
11
|
+
case 'delegatecall':
|
|
12
|
+
return '0xff';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function encodeExecutionMode({ type, revertOnError, selector, context, }) {
|
|
16
|
+
return encodePacked(['bytes1', 'bytes1', 'bytes4', 'bytes4', 'bytes22'], [
|
|
17
|
+
toHex(toBytes(parseCallType(type), { size: 1 })),
|
|
18
|
+
toHex(toBytes(revertOnError ? '0x01' : '0x00', { size: 1 })),
|
|
19
|
+
toHex(toBytes('0x0', { size: 4 })),
|
|
20
|
+
toHex(toBytes(selector ?? '0x', { size: 4 })),
|
|
21
|
+
toHex(toBytes(context ?? '0x', { size: 22 })),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
function encode7579Calls({ mode, callData, }) {
|
|
25
|
+
if (callData.length > 1 && mode?.type !== 'batchcall') {
|
|
26
|
+
throw new Error(`mode ${JSON.stringify(mode)} does not supported for batchcall calldata`);
|
|
27
|
+
}
|
|
28
|
+
const executeAbi = [
|
|
29
|
+
{
|
|
30
|
+
type: 'function',
|
|
31
|
+
name: 'execute',
|
|
32
|
+
inputs: [
|
|
33
|
+
{
|
|
34
|
+
name: 'execMode',
|
|
35
|
+
type: 'bytes32',
|
|
36
|
+
internalType: 'ExecMode',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'executionCalldata',
|
|
40
|
+
type: 'bytes',
|
|
41
|
+
internalType: 'bytes',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
outputs: [],
|
|
45
|
+
stateMutability: 'payable',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
if (callData.length > 1) {
|
|
49
|
+
return encodeFunctionData({
|
|
50
|
+
abi: executeAbi,
|
|
51
|
+
functionName: 'execute',
|
|
52
|
+
args: [
|
|
53
|
+
encodeExecutionMode(mode),
|
|
54
|
+
encodeAbiParameters([
|
|
55
|
+
{
|
|
56
|
+
name: 'executionBatch',
|
|
57
|
+
type: 'tuple[]',
|
|
58
|
+
components: [
|
|
59
|
+
{
|
|
60
|
+
name: 'target',
|
|
61
|
+
type: 'address',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'value',
|
|
65
|
+
type: 'uint256',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'callData',
|
|
69
|
+
type: 'bytes',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
], [
|
|
74
|
+
callData.map((arg) => {
|
|
75
|
+
return {
|
|
76
|
+
target: arg.to,
|
|
77
|
+
value: arg.value ?? 0n,
|
|
78
|
+
callData: arg.data ?? '0x',
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
]),
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const call = callData.length === 0 ? undefined : callData[0];
|
|
86
|
+
if (!call) {
|
|
87
|
+
throw new Error('No calls to encode');
|
|
88
|
+
}
|
|
89
|
+
return encodeFunctionData({
|
|
90
|
+
abi: executeAbi,
|
|
91
|
+
functionName: 'execute',
|
|
92
|
+
args: [
|
|
93
|
+
encodeExecutionMode(mode),
|
|
94
|
+
concatHex([
|
|
95
|
+
call.to,
|
|
96
|
+
toHex(call.value ?? 0n, { size: 32 }),
|
|
97
|
+
call.data ?? '0x',
|
|
98
|
+
]),
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async function getAccountNonce(client, args) {
|
|
103
|
+
const { address, entryPointAddress, key = 0n } = args;
|
|
104
|
+
return await getAction(client, readContract, 'readContract')({
|
|
105
|
+
address: entryPointAddress,
|
|
106
|
+
abi: [
|
|
107
|
+
{
|
|
108
|
+
inputs: [
|
|
109
|
+
{
|
|
110
|
+
name: 'sender',
|
|
111
|
+
type: 'address',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'key',
|
|
115
|
+
type: 'uint192',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
name: 'getNonce',
|
|
119
|
+
outputs: [
|
|
120
|
+
{
|
|
121
|
+
name: 'nonce',
|
|
122
|
+
type: 'uint256',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
stateMutability: 'view',
|
|
126
|
+
type: 'function',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
functionName: 'getNonce',
|
|
130
|
+
args: [address, key],
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function getBundlerClient(config, client) {
|
|
134
|
+
function getBundlerEndpoint(config, chainId) {
|
|
135
|
+
switch (config.type) {
|
|
136
|
+
case 'pimlico':
|
|
137
|
+
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=${config.apiKey}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const { bundler } = config;
|
|
141
|
+
if (!bundler) {
|
|
142
|
+
throw new Error('Bundler is required');
|
|
143
|
+
}
|
|
144
|
+
const chainId = client.chain?.id;
|
|
145
|
+
if (!chainId) {
|
|
146
|
+
throw new Error('Chain id is required');
|
|
147
|
+
}
|
|
148
|
+
const endpoint = getBundlerEndpoint(bundler, chainId);
|
|
149
|
+
return createBundlerClient({
|
|
150
|
+
client,
|
|
151
|
+
transport: http(endpoint),
|
|
152
|
+
paymaster: true,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
export { encode7579Calls, getAccountNonce, getBundlerClient };
|
package/dist/example.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
|
|
3
|
-
// import {
|
|
3
|
+
// import {
|
|
4
|
+
// baseSepolia,
|
|
5
|
+
// arbitrumSepolia,
|
|
6
|
+
// optimismSepolia,
|
|
7
|
+
// arbitrum,
|
|
8
|
+
// base,
|
|
9
|
+
// optimism,
|
|
10
|
+
// sepolia,
|
|
11
|
+
// } from 'viem/chains'
|
|
4
12
|
// import {
|
|
5
13
|
// Chain,
|
|
6
14
|
// createPublicClient,
|
|
@@ -10,7 +18,6 @@
|
|
|
10
18
|
// Hex,
|
|
11
19
|
// http,
|
|
12
20
|
// parseEther,
|
|
13
|
-
// parseUnits,
|
|
14
21
|
// } from 'viem'
|
|
15
22
|
// import { createRhinestoneAccount } from './index'
|
|
16
23
|
// const fundingPrivateKey = process.env.FUNDING_PRIVATE_KEY
|
|
@@ -23,18 +30,17 @@
|
|
|
23
30
|
// }
|
|
24
31
|
// const sourceChain = baseSepolia
|
|
25
32
|
// const targetChain = arbitrumSepolia
|
|
26
|
-
// const usdc = getTokenAddress(sourceChain)
|
|
27
33
|
// const usdcTarget = getTokenAddress(targetChain)
|
|
28
34
|
// const usdcAmount = 1n
|
|
29
35
|
// const fundingAccount = privateKeyToAccount(fundingPrivateKey as Hex)
|
|
30
36
|
// const publicClient = createPublicClient({
|
|
31
37
|
// chain: sourceChain,
|
|
32
|
-
// transport:
|
|
38
|
+
// transport: getTransport(sourceChain),
|
|
33
39
|
// })
|
|
34
40
|
// const fundingClient = createWalletClient({
|
|
35
41
|
// account: fundingAccount,
|
|
36
42
|
// chain: sourceChain,
|
|
37
|
-
// transport:
|
|
43
|
+
// transport: getTransport(sourceChain),
|
|
38
44
|
// })
|
|
39
45
|
// console.log('new pks', [
|
|
40
46
|
// generatePrivateKey(),
|
|
@@ -42,22 +48,24 @@
|
|
|
42
48
|
// generatePrivateKey(),
|
|
43
49
|
// ])
|
|
44
50
|
// const privateKeyA =
|
|
45
|
-
// '
|
|
51
|
+
// '0xc1d2bc5a55f47783735daad366cefa85a7fbd2619a2639c1f0bef7aafe6217b0'
|
|
46
52
|
// const accountA = privateKeyToAccount(privateKeyA)
|
|
47
53
|
// const privateKeyB =
|
|
48
|
-
// '
|
|
54
|
+
// '0xe076077b3c53583d0eefcad6b30929cc0dfd58e9a2566cf6a059e327ec62fdbe'
|
|
49
55
|
// const accountB = privateKeyToAccount(privateKeyB)
|
|
50
56
|
// const privateKeyC =
|
|
51
|
-
// '
|
|
57
|
+
// '0x34afca21087883dba533ecf1d9d705dd2ab8a1933e98db704bb7d9ff83edcaa8'
|
|
52
58
|
// const accountC = privateKeyToAccount(privateKeyC)
|
|
53
59
|
// const rhinestoneAccount = await createRhinestoneAccount({
|
|
54
60
|
// account: {
|
|
55
|
-
// type: '
|
|
61
|
+
// type: 'nexus',
|
|
56
62
|
// },
|
|
57
63
|
// owners: {
|
|
58
64
|
// type: 'ecdsa',
|
|
59
|
-
// accounts: [accountA, accountB],
|
|
65
|
+
// accounts: [accountA, accountB, accountC],
|
|
66
|
+
// threshold: 2,
|
|
60
67
|
// },
|
|
68
|
+
// sessions: [],
|
|
61
69
|
// rhinestoneApiKey,
|
|
62
70
|
// deployerAccount: fundingAccount,
|
|
63
71
|
// })
|
|
@@ -74,23 +82,6 @@
|
|
|
74
82
|
// })
|
|
75
83
|
// await publicClient.waitForTransactionReceipt({ hash: txHash })
|
|
76
84
|
// }
|
|
77
|
-
// const usdcBalance = await publicClient.readContract({
|
|
78
|
-
// address: usdc,
|
|
79
|
-
// abi: erc20Abi,
|
|
80
|
-
// functionName: 'balanceOf',
|
|
81
|
-
// args: [address],
|
|
82
|
-
// })
|
|
83
|
-
// if (usdcBalance < usdcAmount) {
|
|
84
|
-
// const txHash2 = await fundingClient.sendTransaction({
|
|
85
|
-
// to: usdc,
|
|
86
|
-
// data: encodeFunctionData({
|
|
87
|
-
// abi: erc20Abi,
|
|
88
|
-
// functionName: 'transfer',
|
|
89
|
-
// args: [address, usdcAmount],
|
|
90
|
-
// }),
|
|
91
|
-
// })
|
|
92
|
-
// await publicClient.waitForTransactionReceipt({ hash: txHash2 })
|
|
93
|
-
// }
|
|
94
85
|
// const bundleId = await rhinestoneAccount.sendTransactions({
|
|
95
86
|
// sourceChain,
|
|
96
87
|
// targetChain,
|
|
@@ -117,13 +108,27 @@
|
|
|
117
108
|
// console.log('status', bundleResult.status)
|
|
118
109
|
// function getTokenAddress(chain: Chain) {
|
|
119
110
|
// switch (chain.id) {
|
|
111
|
+
// case sepolia.id:
|
|
112
|
+
// return '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238'
|
|
120
113
|
// case baseSepolia.id:
|
|
121
114
|
// return '0x036cbd53842c5426634e7929541ec2318f3dcf7e'
|
|
122
115
|
// case arbitrumSepolia.id:
|
|
123
116
|
// return '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d'
|
|
124
117
|
// case optimismSepolia.id:
|
|
125
118
|
// return '0x5fd84259d66Cd46123540766Be93DFE6D43130D7'
|
|
119
|
+
// case base.id:
|
|
120
|
+
// return '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
|
|
121
|
+
// case arbitrum.id:
|
|
122
|
+
// return '0xaf88d065e77c8cC2239327C5EDb3A432268e5831'
|
|
123
|
+
// case optimism.id:
|
|
124
|
+
// return '0x0b2c639c533813f4aa9d7837caf62653d097ff85'
|
|
126
125
|
// default:
|
|
127
126
|
// throw new Error('Unsupported chain')
|
|
128
127
|
// }
|
|
129
128
|
// }
|
|
129
|
+
// function getTransport(chain: Chain) {
|
|
130
|
+
// if (chain.id === sepolia.id) {
|
|
131
|
+
// return http('https://ethereum-sepolia-rpc.publicnode.com')
|
|
132
|
+
// }
|
|
133
|
+
// return http()
|
|
134
|
+
// }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type BundleResult } from '
|
|
1
|
+
import { type BundleResult } from '../orchestrator';
|
|
2
2
|
import { RhinestoneAccountConfig, Transaction } from '../types';
|
|
3
3
|
declare function sendTransactions(config: RhinestoneAccountConfig, transaction: Transaction): Promise<bigint>;
|
|
4
4
|
declare function waitForExecution(config: RhinestoneAccountConfig, id: bigint): Promise<BundleResult>;
|
|
5
5
|
export { sendTransactions, waitForExecution };
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../execution/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,YAAY,EAQlB,MAAM,iBAAiB,CAAA;AAaxB,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAY,MAAM,UAAU,CAAA;AAIzE,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,mBA4DzB;AAED,iBAAe,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,EAAE,EAAE,MAAM,yBAe1E;AAkCD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA"}
|