@rhinestone/sdk 1.5.1 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +7 -9
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +2 -2
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- package/dist/src/auth/provider.d.ts +1 -1
- package/dist/src/auth/provider.js +1 -4
- package/dist/src/errors/index.d.ts +4 -4
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +12 -54
- package/dist/src/execution/compact.d.ts +1 -144
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +1 -117
- package/dist/src/execution/error.d.ts +10 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +9 -11
- package/dist/src/execution/index.d.ts +10 -11
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +64 -75
- package/dist/src/execution/permit2.d.ts +2 -138
- package/dist/src/execution/permit2.d.ts.map +1 -1
- package/dist/src/execution/permit2.js +5 -239
- package/dist/src/execution/utils.d.ts +31 -15
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +283 -256
- package/dist/src/index.d.ts +15 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +57 -68
- package/dist/src/jwt-server/digest.js +3 -6
- package/dist/src/jwt-server/express.d.ts +1 -1
- package/dist/src/jwt-server/express.d.ts.map +1 -1
- package/dist/src/jwt-server/express.js +6 -7
- package/dist/src/jwt-server/handlers.d.ts +1 -1
- package/dist/src/jwt-server/handlers.js +7 -11
- package/dist/src/jwt-server/index.d.ts +7 -7
- package/dist/src/jwt-server/index.js +6 -17
- package/dist/src/jwt-server/jcs.js +1 -4
- package/dist/src/jwt-server/signer.d.ts +1 -1
- package/dist/src/jwt-server/signer.js +10 -13
- package/dist/src/jwt-server/sponsorship.js +2 -7
- package/dist/src/jwt-server/web.d.ts +1 -1
- package/dist/src/jwt-server/web.js +5 -9
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.js +65 -94
- package/dist/src/orchestrator/caip2.d.ts +7 -0
- package/dist/src/orchestrator/caip2.d.ts.map +1 -0
- package/dist/src/orchestrator/caip2.js +17 -0
- package/dist/src/orchestrator/client.d.ts +12 -12
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +199 -305
- package/dist/src/orchestrator/consts.d.ts +2 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +3 -9
- package/dist/src/orchestrator/error.d.ts +72 -217
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +117 -227
- package/dist/src/orchestrator/index.d.ts +9 -9
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +7 -56
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.d.ts +97 -232
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +5 -7
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +15 -98
- package/dist/src/execution/singleChainOps.d.ts +0 -41
- package/dist/src/execution/singleChainOps.d.ts.map +0 -1
- package/dist/src/execution/singleChainOps.js +0 -44
- package/dist/src/execution/types.d.ts +0 -36
- package/dist/src/execution/types.d.ts.map +0 -1
- package/dist/src/execution/types.js +0 -2
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getAddress = getAddress;
|
|
7
|
-
exports.packSignature = packSignature;
|
|
8
|
-
exports.getDeployArgs = getDeployArgs;
|
|
9
|
-
exports.getSmartAccount = getSmartAccount;
|
|
10
|
-
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
11
|
-
const viem_1 = require("viem");
|
|
12
|
-
const modules_1 = require("../modules");
|
|
13
|
-
const core_1 = require("../modules/validators/core");
|
|
14
|
-
const error_1 = require("./error");
|
|
15
|
-
const nexus_1 = require("./nexus");
|
|
1
|
+
import { concat, decodeFunctionData, encodeAbiParameters, encodeFunctionData, encodePacked, keccak256, parseAbi, slice, zeroAddress, zeroHash, } from 'viem';
|
|
2
|
+
import { getSetup as getModuleSetup } from '../modules/index.js';
|
|
3
|
+
import { getOwnerValidator } from '../modules/validators/core.js';
|
|
4
|
+
import { AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, } from './error.js';
|
|
5
|
+
import { getGuardianSmartAccount as getNexusGuardianSmartAccount, getInstallData as getNexusInstallData, getSmartAccount as getNexusSmartAccount, packSignature as packNexusSignature, } from './nexus.js';
|
|
16
6
|
const K1_DEFAULT_VALIDATOR_ADDRESS = '0x00000072f286204bb934ed49d8969e86f7dec7b1';
|
|
17
|
-
exports.K1_DEFAULT_VALIDATOR_ADDRESS = K1_DEFAULT_VALIDATOR_ADDRESS;
|
|
18
7
|
const STARTALE_VERSION = '1.0.0';
|
|
19
8
|
const IMPLEMENTATION_ADDRESS = '0x000000b8f5f723a680d3d7ee624fe0bc84a6e05a';
|
|
20
9
|
const FACTORY_ADDRESS = '0x0000003b3e7b530b4f981ae80d9350392defef90';
|
|
@@ -27,14 +16,14 @@ function getDeployArgs(config) {
|
|
|
27
16
|
}
|
|
28
17
|
const { factory, factoryData } = config.initData;
|
|
29
18
|
try {
|
|
30
|
-
const decoded =
|
|
31
|
-
abi:
|
|
19
|
+
const decoded = decodeFunctionData({
|
|
20
|
+
abi: parseAbi(['function createAccount(bytes,bytes32)']),
|
|
32
21
|
data: factoryData,
|
|
33
22
|
});
|
|
34
23
|
const initData = decoded.args[0];
|
|
35
24
|
const salt = decoded.args[1];
|
|
36
|
-
const initializationCallData =
|
|
37
|
-
abi:
|
|
25
|
+
const initializationCallData = encodeFunctionData({
|
|
26
|
+
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
38
27
|
functionName: 'initializeAccount',
|
|
39
28
|
args: [initData],
|
|
40
29
|
});
|
|
@@ -51,27 +40,27 @@ function getDeployArgs(config) {
|
|
|
51
40
|
}
|
|
52
41
|
}
|
|
53
42
|
const account = config.account;
|
|
54
|
-
const salt = account?.salt ??
|
|
55
|
-
const moduleSetup = (
|
|
56
|
-
const ownerValidator =
|
|
43
|
+
const salt = account?.salt ?? zeroHash;
|
|
44
|
+
const moduleSetup = getModuleSetup(config);
|
|
45
|
+
const ownerValidator = getOwnerValidator(config);
|
|
57
46
|
const isK1 = ownerValidator.address.toLowerCase() ===
|
|
58
47
|
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
59
48
|
if (isK1 &&
|
|
60
49
|
config.owners &&
|
|
61
50
|
'accounts' in config.owners &&
|
|
62
51
|
config.owners.accounts.length > 1) {
|
|
63
|
-
throw new
|
|
52
|
+
throw new AccountConfigurationNotSupportedError('K1 validator only supports a single owner', 'startale');
|
|
64
53
|
}
|
|
65
54
|
const initData = isK1
|
|
66
55
|
? getK1InitData(config, moduleSetup)
|
|
67
56
|
: getOwnableInitData(moduleSetup);
|
|
68
|
-
const factoryData =
|
|
69
|
-
abi:
|
|
57
|
+
const factoryData = encodeFunctionData({
|
|
58
|
+
abi: parseAbi(['function createAccount(bytes,bytes32)']),
|
|
70
59
|
functionName: 'createAccount',
|
|
71
60
|
args: [initData, salt],
|
|
72
61
|
});
|
|
73
|
-
const initializationCallData =
|
|
74
|
-
abi:
|
|
62
|
+
const initializationCallData = encodeFunctionData({
|
|
63
|
+
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
75
64
|
functionName: 'initializeAccount',
|
|
76
65
|
args: [initData],
|
|
77
66
|
});
|
|
@@ -87,10 +76,10 @@ function getK1InitData(config, moduleSetup) {
|
|
|
87
76
|
const ownerAddress = config.owners.accounts[0]
|
|
88
77
|
.address;
|
|
89
78
|
const validators = moduleSetup.validators.filter((v) => v.address.toLowerCase() !== K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase());
|
|
90
|
-
return
|
|
79
|
+
return encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [
|
|
91
80
|
BOOTSTRAP_ADDRESS,
|
|
92
|
-
|
|
93
|
-
abi:
|
|
81
|
+
encodeFunctionData({
|
|
82
|
+
abi: parseAbi([
|
|
94
83
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
95
84
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
96
85
|
'function initWithDefaultValidatorAndOtherModules(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external payable',
|
|
@@ -107,8 +96,8 @@ function getK1InitData(config, moduleSetup) {
|
|
|
107
96
|
initData: e.initData,
|
|
108
97
|
})),
|
|
109
98
|
{
|
|
110
|
-
module:
|
|
111
|
-
initData:
|
|
99
|
+
module: zeroAddress,
|
|
100
|
+
initData: zeroHash,
|
|
112
101
|
},
|
|
113
102
|
moduleSetup.fallbacks.map((f) => ({
|
|
114
103
|
module: f.address,
|
|
@@ -120,10 +109,10 @@ function getK1InitData(config, moduleSetup) {
|
|
|
120
109
|
]);
|
|
121
110
|
}
|
|
122
111
|
function getOwnableInitData(moduleSetup) {
|
|
123
|
-
return
|
|
112
|
+
return encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [
|
|
124
113
|
BOOTSTRAP_ADDRESS,
|
|
125
|
-
|
|
126
|
-
abi:
|
|
114
|
+
encodeFunctionData({
|
|
115
|
+
abi: parseAbi([
|
|
127
116
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
128
117
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
129
118
|
'function init(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
@@ -139,7 +128,7 @@ function getOwnableInitData(moduleSetup) {
|
|
|
139
128
|
initData: e.initData,
|
|
140
129
|
})),
|
|
141
130
|
{
|
|
142
|
-
module:
|
|
131
|
+
module: zeroAddress,
|
|
143
132
|
initData: '0x',
|
|
144
133
|
},
|
|
145
134
|
moduleSetup.fallbacks.map((f) => ({
|
|
@@ -160,7 +149,7 @@ function getAddress(config) {
|
|
|
160
149
|
throw new Error('Cannot derive address: deploy args not available');
|
|
161
150
|
}
|
|
162
151
|
const { factory, salt, initializationCallData } = deployArgs;
|
|
163
|
-
const accountInitData =
|
|
152
|
+
const accountInitData = encodeAbiParameters([
|
|
164
153
|
{
|
|
165
154
|
name: 'address',
|
|
166
155
|
type: 'address',
|
|
@@ -170,32 +159,33 @@ function getAddress(config) {
|
|
|
170
159
|
type: 'bytes',
|
|
171
160
|
},
|
|
172
161
|
], [IMPLEMENTATION_ADDRESS, initializationCallData]);
|
|
173
|
-
const hashedInitcode =
|
|
174
|
-
const hash =
|
|
175
|
-
const address =
|
|
162
|
+
const hashedInitcode = keccak256(concat([CREATION_CODE, accountInitData]));
|
|
163
|
+
const hash = keccak256(encodePacked(['bytes1', 'address', 'bytes32', 'bytes'], ['0xff', factory, salt, hashedInitcode]));
|
|
164
|
+
const address = slice(hash, 12, 32);
|
|
176
165
|
return address;
|
|
177
166
|
}
|
|
178
167
|
function getEip712Domain(config, chain) {
|
|
179
168
|
if (config.initData) {
|
|
180
|
-
throw new
|
|
169
|
+
throw new Eip712DomainNotAvailableError('Existing Startale accounts are not yet supported');
|
|
181
170
|
}
|
|
182
171
|
return {
|
|
183
172
|
name: 'Startale',
|
|
184
173
|
version: STARTALE_VERSION,
|
|
185
174
|
chainId: chain.id,
|
|
186
175
|
verifyingContract: getAddress(config),
|
|
187
|
-
salt:
|
|
176
|
+
salt: zeroHash,
|
|
188
177
|
};
|
|
189
178
|
}
|
|
190
179
|
function getInstallData(module) {
|
|
191
|
-
return (
|
|
180
|
+
return getNexusInstallData(module);
|
|
192
181
|
}
|
|
193
182
|
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
194
|
-
return (
|
|
183
|
+
return packNexusSignature(signature, validator, transformSignature, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
195
184
|
}
|
|
196
185
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
197
|
-
return (
|
|
186
|
+
return getNexusSmartAccount(client, address, owners, validatorAddress, sign, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
198
187
|
}
|
|
199
188
|
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
200
|
-
return (
|
|
189
|
+
return getNexusGuardianSmartAccount(client, address, guardians, validatorAddress, sign, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
201
190
|
}
|
|
191
|
+
export { K1_DEFAULT_VALIDATOR_ADDRESS, getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Address, Client, Hex } from 'viem';
|
|
2
|
-
import type { RhinestoneConfig } from '../types';
|
|
3
|
-
import { createTransport } from './json-rpc';
|
|
2
|
+
import type { RhinestoneConfig } from '../types.js';
|
|
3
|
+
import { createTransport } from './json-rpc/index.js';
|
|
4
4
|
type CallType = 'call' | 'delegatecall' | 'batchcall';
|
|
5
5
|
interface ValidatorConfig {
|
|
6
6
|
address: Address;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getBundlerClient = getBundlerClient;
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const account_abstraction_1 = require("viem/account-abstraction");
|
|
9
|
-
const actions_1 = require("viem/actions");
|
|
10
|
-
const utils_1 = require("viem/utils");
|
|
11
|
-
const json_rpc_1 = require("./json-rpc");
|
|
12
|
-
Object.defineProperty(exports, "createTransport", { enumerable: true, get: function () { return json_rpc_1.createTransport; } });
|
|
1
|
+
import { concatHex, encodeAbiParameters, encodeFunctionData, encodePacked, http, toBytes, toHex, } from 'viem';
|
|
2
|
+
import { createBundlerClient, createPaymasterClient, } from 'viem/account-abstraction';
|
|
3
|
+
import { readContract } from 'viem/actions';
|
|
4
|
+
import { getAction } from 'viem/utils';
|
|
5
|
+
import { createTransport } from './json-rpc/index.js';
|
|
13
6
|
function parseCallType(callType) {
|
|
14
7
|
switch (callType) {
|
|
15
8
|
case 'call':
|
|
@@ -21,12 +14,12 @@ function parseCallType(callType) {
|
|
|
21
14
|
}
|
|
22
15
|
}
|
|
23
16
|
function encodeExecutionMode({ type, revertOnError, selector, context, }) {
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
return encodePacked(['bytes1', 'bytes1', 'bytes4', 'bytes4', 'bytes22'], [
|
|
18
|
+
toHex(toBytes(parseCallType(type), { size: 1 })),
|
|
19
|
+
toHex(toBytes(revertOnError ? '0x01' : '0x00', { size: 1 })),
|
|
20
|
+
toHex(toBytes('0x0', { size: 4 })),
|
|
21
|
+
toHex(toBytes(selector ?? '0x', { size: 4 })),
|
|
22
|
+
toHex(toBytes(context ?? '0x', { size: 22 })),
|
|
30
23
|
]);
|
|
31
24
|
}
|
|
32
25
|
function encode7579Calls({ mode, callData, }) {
|
|
@@ -54,12 +47,12 @@ function encode7579Calls({ mode, callData, }) {
|
|
|
54
47
|
},
|
|
55
48
|
];
|
|
56
49
|
if (callData.length > 1) {
|
|
57
|
-
return
|
|
50
|
+
return encodeFunctionData({
|
|
58
51
|
abi: executeAbi,
|
|
59
52
|
functionName: 'execute',
|
|
60
53
|
args: [
|
|
61
54
|
encodeExecutionMode(mode),
|
|
62
|
-
|
|
55
|
+
encodeAbiParameters([
|
|
63
56
|
{
|
|
64
57
|
name: 'executionBatch',
|
|
65
58
|
type: 'tuple[]',
|
|
@@ -94,14 +87,14 @@ function encode7579Calls({ mode, callData, }) {
|
|
|
94
87
|
if (!call) {
|
|
95
88
|
throw new Error('No calls to encode');
|
|
96
89
|
}
|
|
97
|
-
return
|
|
90
|
+
return encodeFunctionData({
|
|
98
91
|
abi: executeAbi,
|
|
99
92
|
functionName: 'execute',
|
|
100
93
|
args: [
|
|
101
94
|
encodeExecutionMode(mode),
|
|
102
|
-
|
|
95
|
+
concatHex([
|
|
103
96
|
call.to,
|
|
104
|
-
|
|
97
|
+
toHex(call.value ?? 0n, { size: 32 }),
|
|
105
98
|
call.data ?? '0x',
|
|
106
99
|
]),
|
|
107
100
|
],
|
|
@@ -109,7 +102,7 @@ function encode7579Calls({ mode, callData, }) {
|
|
|
109
102
|
}
|
|
110
103
|
async function getAccountNonce(client, args) {
|
|
111
104
|
const { address, entryPointAddress, key = 0n } = args;
|
|
112
|
-
return await
|
|
105
|
+
return await getAction(client, readContract, 'readContract')({
|
|
113
106
|
address: entryPointAddress,
|
|
114
107
|
abi: [
|
|
115
108
|
{
|
|
@@ -171,12 +164,12 @@ function getBundlerClient(config, client) {
|
|
|
171
164
|
? getPaymasterEndpoint(paymaster, chainId)
|
|
172
165
|
: undefined;
|
|
173
166
|
const isCustomBundler = bundler?.type === 'custom';
|
|
174
|
-
return
|
|
167
|
+
return createBundlerClient({
|
|
175
168
|
client,
|
|
176
|
-
transport:
|
|
169
|
+
transport: http(endpoint),
|
|
177
170
|
paymaster: paymasterEndpoint
|
|
178
|
-
?
|
|
179
|
-
transport:
|
|
171
|
+
? createPaymasterClient({
|
|
172
|
+
transport: http(paymasterEndpoint),
|
|
180
173
|
})
|
|
181
174
|
: undefined,
|
|
182
175
|
userOperation: isCustomBundler
|
|
@@ -206,3 +199,4 @@ async function getGasPriceEstimate(bundlerUrl) {
|
|
|
206
199
|
maxPriorityFeePerGas: BigInt(json.result.fast.maxPriorityFeePerGas),
|
|
207
200
|
};
|
|
208
201
|
}
|
|
202
|
+
export { encode7579Calls, getAccountNonce, getBundlerClient, createTransport };
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.walletClientToAccount = walletClientToAccount;
|
|
4
|
-
exports.wrapParaAccount = wrapParaAccount;
|
|
5
|
-
const error_1 = require("./error");
|
|
1
|
+
import { WalletClientNoConnectedAccountError } from './error.js';
|
|
6
2
|
/**
|
|
7
3
|
* Adapts a Viem/Wagmi WalletClient into an Account-like signer that the SDK can consume.
|
|
8
4
|
* Ensures address is set and routes sign methods through the provided client.
|
|
9
5
|
*/
|
|
10
|
-
function walletClientToAccount(walletClient) {
|
|
6
|
+
export function walletClientToAccount(walletClient) {
|
|
11
7
|
const address = walletClient.account?.address;
|
|
12
8
|
if (!address) {
|
|
13
|
-
throw new
|
|
9
|
+
throw new WalletClientNoConnectedAccountError();
|
|
14
10
|
}
|
|
15
11
|
const account = {
|
|
16
12
|
address,
|
|
@@ -66,7 +62,7 @@ function walletClientToAccount(walletClient) {
|
|
|
66
62
|
* const authorization = await wrappedAccount.signAuthorization?.({ ... })
|
|
67
63
|
* ```
|
|
68
64
|
*/
|
|
69
|
-
function wrapParaAccount(viemAccount, walletId) {
|
|
65
|
+
export function wrapParaAccount(viemAccount, walletId) {
|
|
70
66
|
// Store the wallet ID for signing operations (for debugging purposes)
|
|
71
67
|
const effectiveWalletId = walletId || viemAccount.walletId || viemAccount._walletId;
|
|
72
68
|
// Store reference for potential debugging
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address, type Hex } from 'viem';
|
|
2
|
-
import type { CalldataInput, LazyCallInput } from '../types';
|
|
2
|
+
import type { CalldataInput, LazyCallInput } from '../types.js';
|
|
3
3
|
declare const ALLOCATOR_ADDRESS = "0xc7732071e3a1be6cfce6d13bb05699a31a457679";
|
|
4
4
|
declare function depositEther(value: bigint): LazyCallInput;
|
|
5
5
|
declare function enableEtherWithdrawal(): CalldataInput;
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ALLOCATOR_ADDRESS = void 0;
|
|
4
|
-
exports.depositEther = depositEther;
|
|
5
|
-
exports.enableEtherWithdrawal = enableEtherWithdrawal;
|
|
6
|
-
exports.disableEtherWithdrawal = disableEtherWithdrawal;
|
|
7
|
-
exports.withdrawEther = withdrawEther;
|
|
8
|
-
exports.depositErc20 = depositErc20;
|
|
9
|
-
exports.enableErc20Withdrawal = enableErc20Withdrawal;
|
|
10
|
-
exports.disableErc20Withdrawal = disableErc20Withdrawal;
|
|
11
|
-
exports.withdrawErc20 = withdrawErc20;
|
|
12
|
-
exports.approveErc20 = approveErc20;
|
|
13
|
-
exports.lockTag = lockTag;
|
|
14
|
-
const viem_1 = require("viem");
|
|
15
|
-
const compact_1 = require("../execution/compact");
|
|
1
|
+
import { concat, encodeFunctionData, erc20Abi, zeroAddress, } from 'viem';
|
|
2
|
+
import { COMPACT_ADDRESS } from '../execution/compact.js';
|
|
16
3
|
const ALLOCATOR_ADDRESS = '0xc7732071e3a1be6cfce6d13bb05699a31a457679';
|
|
17
|
-
exports.ALLOCATOR_ADDRESS = ALLOCATOR_ADDRESS;
|
|
18
4
|
const DEFAULT_RESET_PERIOD = 6;
|
|
19
5
|
const DEFAULT_SCOPE = 0;
|
|
20
6
|
function depositEther(value) {
|
|
21
7
|
return {
|
|
22
8
|
async resolve({ accountAddress }) {
|
|
23
9
|
return {
|
|
24
|
-
to:
|
|
25
|
-
data:
|
|
10
|
+
to: COMPACT_ADDRESS,
|
|
11
|
+
data: encodeFunctionData({
|
|
26
12
|
abi: [
|
|
27
13
|
{
|
|
28
14
|
type: 'function',
|
|
@@ -46,17 +32,17 @@ function depositEther(value) {
|
|
|
46
32
|
};
|
|
47
33
|
}
|
|
48
34
|
function enableEtherWithdrawal() {
|
|
49
|
-
const id =
|
|
35
|
+
const id = concat([lockTag(), zeroAddress]);
|
|
50
36
|
return enableForcedWithdrawal(BigInt(id));
|
|
51
37
|
}
|
|
52
38
|
function disableEtherWithdrawal() {
|
|
53
|
-
const id =
|
|
39
|
+
const id = concat([lockTag(), zeroAddress]);
|
|
54
40
|
return disableForcedWithdrawal(BigInt(id));
|
|
55
41
|
}
|
|
56
42
|
function withdrawEther(value) {
|
|
57
43
|
return {
|
|
58
44
|
async resolve({ accountAddress }) {
|
|
59
|
-
const id =
|
|
45
|
+
const id = concat([lockTag(), zeroAddress]);
|
|
60
46
|
return forcedWithdrawal(BigInt(id), accountAddress, value);
|
|
61
47
|
},
|
|
62
48
|
};
|
|
@@ -65,9 +51,9 @@ function depositErc20(tokenAddress, amount) {
|
|
|
65
51
|
return {
|
|
66
52
|
async resolve({ accountAddress }) {
|
|
67
53
|
return {
|
|
68
|
-
to:
|
|
54
|
+
to: COMPACT_ADDRESS,
|
|
69
55
|
value: 0n,
|
|
70
|
-
data:
|
|
56
|
+
data: encodeFunctionData({
|
|
71
57
|
abi: [
|
|
72
58
|
{
|
|
73
59
|
type: 'function',
|
|
@@ -92,25 +78,25 @@ function depositErc20(tokenAddress, amount) {
|
|
|
92
78
|
};
|
|
93
79
|
}
|
|
94
80
|
function enableErc20Withdrawal(tokenAddress) {
|
|
95
|
-
const id =
|
|
81
|
+
const id = concat([lockTag(), tokenAddress]);
|
|
96
82
|
return enableForcedWithdrawal(BigInt(id));
|
|
97
83
|
}
|
|
98
84
|
function disableErc20Withdrawal(tokenAddress) {
|
|
99
|
-
const id =
|
|
85
|
+
const id = concat([lockTag(), tokenAddress]);
|
|
100
86
|
return disableForcedWithdrawal(BigInt(id));
|
|
101
87
|
}
|
|
102
88
|
function withdrawErc20(tokenAddress, amount) {
|
|
103
89
|
return {
|
|
104
90
|
async resolve({ accountAddress }) {
|
|
105
|
-
const id =
|
|
91
|
+
const id = concat([lockTag(), tokenAddress]);
|
|
106
92
|
return forcedWithdrawal(BigInt(id), accountAddress, amount);
|
|
107
93
|
},
|
|
108
94
|
};
|
|
109
95
|
}
|
|
110
96
|
function enableForcedWithdrawal(id) {
|
|
111
97
|
return {
|
|
112
|
-
to:
|
|
113
|
-
data:
|
|
98
|
+
to: COMPACT_ADDRESS,
|
|
99
|
+
data: encodeFunctionData({
|
|
114
100
|
abi: [
|
|
115
101
|
{
|
|
116
102
|
type: 'function',
|
|
@@ -128,8 +114,8 @@ function enableForcedWithdrawal(id) {
|
|
|
128
114
|
}
|
|
129
115
|
function disableForcedWithdrawal(id) {
|
|
130
116
|
return {
|
|
131
|
-
to:
|
|
132
|
-
data:
|
|
117
|
+
to: COMPACT_ADDRESS,
|
|
118
|
+
data: encodeFunctionData({
|
|
133
119
|
abi: [
|
|
134
120
|
{
|
|
135
121
|
type: 'function',
|
|
@@ -147,8 +133,8 @@ function disableForcedWithdrawal(id) {
|
|
|
147
133
|
}
|
|
148
134
|
function forcedWithdrawal(id, recipient, amount) {
|
|
149
135
|
return {
|
|
150
|
-
to:
|
|
151
|
-
data:
|
|
136
|
+
to: COMPACT_ADDRESS,
|
|
137
|
+
data: encodeFunctionData({
|
|
152
138
|
abi: [
|
|
153
139
|
{
|
|
154
140
|
type: 'function',
|
|
@@ -172,10 +158,10 @@ function approveErc20(tokenAddress, amount) {
|
|
|
172
158
|
return {
|
|
173
159
|
to: tokenAddress,
|
|
174
160
|
value: 0n,
|
|
175
|
-
data:
|
|
176
|
-
abi:
|
|
161
|
+
data: encodeFunctionData({
|
|
162
|
+
abi: erc20Abi,
|
|
177
163
|
functionName: 'approve',
|
|
178
|
-
args: [
|
|
164
|
+
args: [COMPACT_ADDRESS, amount],
|
|
179
165
|
}),
|
|
180
166
|
};
|
|
181
167
|
}
|
|
@@ -211,3 +197,4 @@ function lockTag() {
|
|
|
211
197
|
const hex = tagBig.toString(16).slice(0, 24);
|
|
212
198
|
return `0x${hex}`;
|
|
213
199
|
}
|
|
200
|
+
export { ALLOCATOR_ADDRESS, depositEther, enableEtherWithdrawal, disableEtherWithdrawal, withdrawEther, depositErc20, enableErc20Withdrawal, disableErc20Withdrawal, withdrawErc20, approveErc20, lockTag, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Chain } from 'viem';
|
|
2
|
-
import type { AccountProviderConfig, RhinestoneSDKConfig } from '../types';
|
|
2
|
+
import type { AccountProviderConfig, RhinestoneSDKConfig } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Deploy smart accounts for multiple users from a backend using a sponsor wallet.
|
|
5
5
|
* The sponsor pays for gas, but users own and control their accounts.
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const accounts_1 = require("../accounts");
|
|
6
|
-
const utils_1 = require("../accounts/utils");
|
|
1
|
+
import { createPublicClient, createWalletClient } from 'viem';
|
|
2
|
+
import { getAddress as getAddressInternal, getInitCode as getInitCodeInternal, isDeployed as isDeployedInternal, } from '../accounts/index.js';
|
|
3
|
+
import { createTransport } from '../accounts/utils.js';
|
|
7
4
|
async function deployWithCustomFactory(sponsorConfig, chain, factoryArgs) {
|
|
8
5
|
const sponsorOwners = sponsorConfig.owners;
|
|
9
6
|
if (!sponsorOwners ||
|
|
@@ -15,14 +12,14 @@ async function deployWithCustomFactory(sponsorConfig, chain, factoryArgs) {
|
|
|
15
12
|
if (!('signTransaction' in sponsorAccount)) {
|
|
16
13
|
throw new Error('Sponsor account must be able to sign transactions');
|
|
17
14
|
}
|
|
18
|
-
const publicClient =
|
|
15
|
+
const publicClient = createPublicClient({
|
|
19
16
|
chain,
|
|
20
|
-
transport:
|
|
17
|
+
transport: createTransport(chain, sponsorConfig.provider),
|
|
21
18
|
});
|
|
22
|
-
const walletClient =
|
|
19
|
+
const walletClient = createWalletClient({
|
|
23
20
|
account: sponsorAccount,
|
|
24
21
|
chain,
|
|
25
|
-
transport:
|
|
22
|
+
transport: createTransport(chain, sponsorConfig.provider),
|
|
26
23
|
});
|
|
27
24
|
const hash = await walletClient.sendTransaction({
|
|
28
25
|
to: factoryArgs.factory,
|
|
@@ -52,8 +49,8 @@ async function deployAccountsForOwners(params) {
|
|
|
52
49
|
},
|
|
53
50
|
...sdkConfig,
|
|
54
51
|
};
|
|
55
|
-
const accountAddress = (
|
|
56
|
-
const isAlreadyDeployed = await (
|
|
52
|
+
const accountAddress = getAddressInternal(userConfig);
|
|
53
|
+
const isAlreadyDeployed = await isDeployedInternal(userConfig, chain);
|
|
57
54
|
if (isAlreadyDeployed) {
|
|
58
55
|
results.push({ owner: ownerAddress, account: accountAddress });
|
|
59
56
|
continue;
|
|
@@ -67,7 +64,7 @@ async function deployAccountsForOwners(params) {
|
|
|
67
64
|
},
|
|
68
65
|
...sdkConfig,
|
|
69
66
|
};
|
|
70
|
-
const initCode = (
|
|
67
|
+
const initCode = getInitCodeInternal(userConfig);
|
|
71
68
|
if (!initCode || !('factory' in initCode)) {
|
|
72
69
|
throw new Error('Failed to get init code for account deployment');
|
|
73
70
|
}
|
|
@@ -76,3 +73,4 @@ async function deployAccountsForOwners(params) {
|
|
|
76
73
|
}
|
|
77
74
|
return results;
|
|
78
75
|
}
|
|
76
|
+
export { deployAccountsForOwners };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.removeOwner = removeOwner;
|
|
5
|
-
exports.changeThreshold = changeThreshold;
|
|
6
|
-
exports.disable = disable;
|
|
7
|
-
exports.enable = enable;
|
|
8
|
-
const viem_1 = require("viem");
|
|
9
|
-
const accounts_1 = require("../accounts");
|
|
10
|
-
const core_1 = require("../modules/validators/core");
|
|
1
|
+
import { encodeFunctionData } from 'viem';
|
|
2
|
+
import { getModuleInstallationCalls, getModuleUninstallationCalls, } from '../accounts/index.js';
|
|
3
|
+
import { getOwnableValidator, OWNABLE_VALIDATOR_ADDRESS, } from '../modules/validators/core.js';
|
|
11
4
|
/**
|
|
12
5
|
* Enable ECDSA authentication
|
|
13
6
|
* @param owners Owners to use for authentication
|
|
@@ -15,10 +8,10 @@ const core_1 = require("../modules/validators/core");
|
|
|
15
8
|
* @returns Calls to enable ECDSA authentication
|
|
16
9
|
*/
|
|
17
10
|
function enable(owners, threshold = 1) {
|
|
18
|
-
const module =
|
|
11
|
+
const module = getOwnableValidator(threshold, owners);
|
|
19
12
|
return {
|
|
20
13
|
async resolve({ config }) {
|
|
21
|
-
return
|
|
14
|
+
return getModuleInstallationCalls(config, module);
|
|
22
15
|
},
|
|
23
16
|
};
|
|
24
17
|
}
|
|
@@ -27,10 +20,10 @@ function enable(owners, threshold = 1) {
|
|
|
27
20
|
* @returns Calls to disable ECDSA authentication
|
|
28
21
|
*/
|
|
29
22
|
function disable() {
|
|
30
|
-
const module =
|
|
23
|
+
const module = getOwnableValidator(1, []);
|
|
31
24
|
return {
|
|
32
25
|
async resolve({ config }) {
|
|
33
|
-
return
|
|
26
|
+
return getModuleUninstallationCalls(config, module);
|
|
34
27
|
},
|
|
35
28
|
};
|
|
36
29
|
}
|
|
@@ -41,9 +34,9 @@ function disable() {
|
|
|
41
34
|
*/
|
|
42
35
|
function addOwner(owner) {
|
|
43
36
|
return {
|
|
44
|
-
to:
|
|
37
|
+
to: OWNABLE_VALIDATOR_ADDRESS,
|
|
45
38
|
value: 0n,
|
|
46
|
-
data:
|
|
39
|
+
data: encodeFunctionData({
|
|
47
40
|
abi: [
|
|
48
41
|
{
|
|
49
42
|
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
|
@@ -66,9 +59,9 @@ function addOwner(owner) {
|
|
|
66
59
|
*/
|
|
67
60
|
function removeOwner(prevOwner, ownerToRemove) {
|
|
68
61
|
return {
|
|
69
|
-
to:
|
|
62
|
+
to: OWNABLE_VALIDATOR_ADDRESS,
|
|
70
63
|
value: 0n,
|
|
71
|
-
data:
|
|
64
|
+
data: encodeFunctionData({
|
|
72
65
|
abi: [
|
|
73
66
|
{
|
|
74
67
|
inputs: [
|
|
@@ -93,9 +86,9 @@ function removeOwner(prevOwner, ownerToRemove) {
|
|
|
93
86
|
*/
|
|
94
87
|
function changeThreshold(newThreshold) {
|
|
95
88
|
return {
|
|
96
|
-
to:
|
|
89
|
+
to: OWNABLE_VALIDATOR_ADDRESS,
|
|
97
90
|
value: 0n,
|
|
98
|
-
data:
|
|
91
|
+
data: encodeFunctionData({
|
|
99
92
|
abi: [
|
|
100
93
|
{
|
|
101
94
|
inputs: [
|
|
@@ -112,3 +105,4 @@ function changeThreshold(newThreshold) {
|
|
|
112
105
|
}),
|
|
113
106
|
};
|
|
114
107
|
}
|
|
108
|
+
export { addOwner, removeOwner, changeThreshold, disable, enable };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RhinestoneAccount } from '../index';
|
|
2
|
-
import type { LazyCallInput, ModuleInput } from '../types';
|
|
1
|
+
import type { RhinestoneAccount } from '../index.js';
|
|
2
|
+
import type { LazyCallInput, ModuleInput } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Install a custom module
|
|
5
5
|
* @param module Module to install
|