@charterlabs/rhinestone-sdk 0.0.3 → 0.0.4
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 +6 -0
- package/dist/src/accounts/index.d.ts +10 -6
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +100 -4
- package/dist/src/accounts/kernel.d.ts +22 -0
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/src/accounts/kernel.js +252 -0
- package/dist/src/accounts/kernel.test.d.ts +2 -0
- package/dist/src/accounts/kernel.test.d.ts.map +1 -0
- package/dist/src/accounts/kernel.test.js +103 -0
- package/dist/src/accounts/nexus.d.ts +7 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +59 -10
- package/dist/src/accounts/nexus.test.js +50 -4
- package/dist/src/accounts/safe.d.ts +7 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +51 -2
- package/dist/src/accounts/safe.test.js +50 -4
- package/dist/src/accounts/utils.d.ts +5 -0
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/actions/index.d.ts +12 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +165 -0
- package/dist/src/actions/index.test.d.ts +2 -0
- package/dist/src/actions/index.test.d.ts.map +1 -0
- package/dist/src/actions/index.test.js +170 -0
- package/dist/src/execution/index.d.ts +5 -15
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +30 -149
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +7 -2
- package/dist/src/execution/smart-session.test.js +3 -0
- package/dist/src/execution/utils.d.ts +68 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +355 -0
- package/dist/src/index.d.ts +20 -24
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +24 -0
- package/dist/src/modules/index.d.ts +2 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +9 -1
- package/dist/src/modules/registry.d.ts +9 -0
- package/dist/src/modules/registry.d.ts.map +1 -0
- package/dist/src/modules/registry.js +60 -0
- package/dist/src/modules/validators/core.d.ts +4 -2
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +24 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.d.ts +1 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +76 -1
- package/dist/src/orchestrator/types.d.ts +24 -3
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +3 -0
- package/dist/src/types.d.ts +12 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -1
- package/dist/test/consts.d.ts.map +1 -1
- package/dist/test/consts.js +3 -1
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Address, Client, Hex } from 'viem';
|
|
2
2
|
import type { RhinestoneAccountConfig } from '../types';
|
|
3
3
|
type CallType = 'call' | 'delegatecall' | 'batchcall';
|
|
4
|
+
interface ValidatorConfig {
|
|
5
|
+
address: Address;
|
|
6
|
+
isRoot: boolean;
|
|
7
|
+
}
|
|
4
8
|
interface ExecutionMode<callType extends CallType> {
|
|
5
9
|
type: callType;
|
|
6
10
|
revertOnError?: boolean;
|
|
@@ -24,4 +28,5 @@ declare function encode7579Calls<callType extends CallType>({ mode, callData, }:
|
|
|
24
28
|
declare function getAccountNonce(client: Client, args: GetAccountNonceParams): Promise<bigint>;
|
|
25
29
|
declare function getBundlerClient(config: RhinestoneAccountConfig, client: Client): import("viem/account-abstraction").BundlerClient<import("viem").HttpTransport<undefined, false>, undefined, undefined, Client, undefined>;
|
|
26
30
|
export { encode7579Calls, getAccountNonce, getBundlerClient };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,MAAM,EACd,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAmCjB;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,6IAyBxE;AAyBD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA;AAC7D,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Address, Chain } from 'viem';
|
|
2
|
+
import { RhinestoneAccount } from '..';
|
|
3
|
+
import { Call, OwnerSet, Recovery } from '../types';
|
|
4
|
+
declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
|
|
5
|
+
rhinestoneAccount: RhinestoneAccount;
|
|
6
|
+
} & Recovery): Call[];
|
|
7
|
+
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain): Promise<Call[]>;
|
|
8
|
+
declare function addOwner(owner: Address): Call;
|
|
9
|
+
declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
|
|
10
|
+
declare function setThreshold(newThreshold: bigint): Call;
|
|
11
|
+
export { addOwner, removeOwner, setThreshold, recover, setUpRecovery };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAIN,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAMtC,OAAO,EAAE,IAAI,EAA0B,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE3E,iBAAS,aAAa,CAAC,EACrB,iBAAiB,EACjB,SAAS,EACT,SAAa,GACd,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,QAAQ,UAIX;AAED,iBAAe,OAAO,CACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,IAAI,EAAE,CAAC,CASjB;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAiBtC;AAED,iBAAS,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAoBrE;AAED,iBAAS,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAmBhD;AAqGD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addOwner = addOwner;
|
|
4
|
+
exports.removeOwner = removeOwner;
|
|
5
|
+
exports.setThreshold = setThreshold;
|
|
6
|
+
exports.recover = recover;
|
|
7
|
+
exports.setUpRecovery = setUpRecovery;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
const accounts_1 = require("../accounts");
|
|
10
|
+
const core_1 = require("../modules/validators/core");
|
|
11
|
+
function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
|
|
12
|
+
const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
|
|
13
|
+
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
14
|
+
return calls;
|
|
15
|
+
}
|
|
16
|
+
async function recover(address, newOwners, chain) {
|
|
17
|
+
switch (newOwners.type) {
|
|
18
|
+
case 'ecdsa': {
|
|
19
|
+
return recoverEcdsaOwnership(address, newOwners, chain);
|
|
20
|
+
}
|
|
21
|
+
case 'passkey': {
|
|
22
|
+
throw new Error('Passkey ownership recovery is not yet supported');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function addOwner(owner) {
|
|
27
|
+
return {
|
|
28
|
+
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
29
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
30
|
+
abi: [
|
|
31
|
+
{
|
|
32
|
+
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
|
33
|
+
name: 'addOwner',
|
|
34
|
+
outputs: [],
|
|
35
|
+
stateMutability: 'nonpayable',
|
|
36
|
+
type: 'function',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
functionName: 'addOwner',
|
|
40
|
+
args: [owner],
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function removeOwner(prevOwner, ownerToRemove) {
|
|
45
|
+
return {
|
|
46
|
+
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
47
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
48
|
+
abi: [
|
|
49
|
+
{
|
|
50
|
+
inputs: [
|
|
51
|
+
{ internalType: 'address', name: 'prevOwner', type: 'address' },
|
|
52
|
+
{ internalType: 'address', name: 'owner', type: 'address' },
|
|
53
|
+
],
|
|
54
|
+
name: 'removeOwner',
|
|
55
|
+
outputs: [],
|
|
56
|
+
stateMutability: 'nonpayable',
|
|
57
|
+
type: 'function',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
functionName: 'removeOwner',
|
|
61
|
+
args: [prevOwner, ownerToRemove],
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function setThreshold(newThreshold) {
|
|
66
|
+
return {
|
|
67
|
+
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
68
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
69
|
+
abi: [
|
|
70
|
+
{
|
|
71
|
+
inputs: [
|
|
72
|
+
{ internalType: 'uint256', name: '_threshold', type: 'uint256' },
|
|
73
|
+
],
|
|
74
|
+
name: 'setThreshold',
|
|
75
|
+
outputs: [],
|
|
76
|
+
stateMutability: 'nonpayable',
|
|
77
|
+
type: 'function',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
functionName: 'setThreshold',
|
|
81
|
+
args: [newThreshold],
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function recoverEcdsaOwnership(address, newOwners, chain) {
|
|
86
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
87
|
+
chain,
|
|
88
|
+
transport: (0, viem_1.http)(),
|
|
89
|
+
});
|
|
90
|
+
// Read the existing config
|
|
91
|
+
const [existingOwners, existingThreshold] = await Promise.all([
|
|
92
|
+
publicClient.readContract({
|
|
93
|
+
address: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
94
|
+
abi: [
|
|
95
|
+
{
|
|
96
|
+
inputs: [
|
|
97
|
+
{ internalType: 'address', name: 'account', type: 'address' },
|
|
98
|
+
],
|
|
99
|
+
name: 'getOwners',
|
|
100
|
+
outputs: [
|
|
101
|
+
{
|
|
102
|
+
internalType: 'address[]',
|
|
103
|
+
name: 'ownersArray',
|
|
104
|
+
type: 'address[]',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
stateMutability: 'view',
|
|
108
|
+
type: 'function',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
functionName: 'getOwners',
|
|
112
|
+
args: [address],
|
|
113
|
+
}),
|
|
114
|
+
publicClient.readContract({
|
|
115
|
+
address: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
116
|
+
abi: [
|
|
117
|
+
{
|
|
118
|
+
inputs: [
|
|
119
|
+
{ internalType: 'address', name: 'account', type: 'address' },
|
|
120
|
+
],
|
|
121
|
+
name: 'threshold',
|
|
122
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
123
|
+
stateMutability: 'view',
|
|
124
|
+
type: 'function',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
functionName: 'threshold',
|
|
128
|
+
args: [address],
|
|
129
|
+
}),
|
|
130
|
+
]);
|
|
131
|
+
const normalizedExistingOwners = existingOwners.map((owner) => owner.toLowerCase());
|
|
132
|
+
const calls = [];
|
|
133
|
+
// Convert new owners config to addresses and threshold
|
|
134
|
+
const newOwnerAddresses = newOwners.accounts
|
|
135
|
+
.map((account) => account.address.toLowerCase())
|
|
136
|
+
.sort();
|
|
137
|
+
const newThreshold = BigInt(newOwners.threshold ?? 1);
|
|
138
|
+
// Check if threshold needs to be updated
|
|
139
|
+
if (existingThreshold !== newThreshold) {
|
|
140
|
+
calls.push(setThreshold(newThreshold));
|
|
141
|
+
}
|
|
142
|
+
const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
|
|
143
|
+
const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
|
|
144
|
+
// Maintain the list as making changes to keep track of the previous owner for removals
|
|
145
|
+
// Note: new owners are added to the START of the linked list
|
|
146
|
+
let currentOwners = [...normalizedExistingOwners];
|
|
147
|
+
for (const owner of ownersToAdd) {
|
|
148
|
+
calls.push(addOwner(owner));
|
|
149
|
+
currentOwners.unshift(owner);
|
|
150
|
+
}
|
|
151
|
+
for (const ownerToRemove of ownersToRemove) {
|
|
152
|
+
const ownerIndex = currentOwners.indexOf(ownerToRemove);
|
|
153
|
+
let prevOwner;
|
|
154
|
+
if (ownerIndex === 0) {
|
|
155
|
+
// If it's the first owner, use the sentinel address
|
|
156
|
+
prevOwner = '0x0000000000000000000000000000000000000001';
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
prevOwner = currentOwners[ownerIndex - 1];
|
|
160
|
+
}
|
|
161
|
+
calls.push(removeOwner(prevOwner, ownerToRemove));
|
|
162
|
+
currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
|
|
163
|
+
}
|
|
164
|
+
return calls;
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../actions/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const viem_1 = require("viem");
|
|
4
|
+
const chains_1 = require("viem/chains");
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const consts_1 = require("../../test/consts");
|
|
7
|
+
const __1 = require("..");
|
|
8
|
+
const _1 = require(".");
|
|
9
|
+
const MOCK_OWNER_A = '0xd1aefebdceefc094f1805b241fa5e6db63a9181a';
|
|
10
|
+
const MOCK_OWNER_B = '0xeddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817';
|
|
11
|
+
const MOCK_ACCOUNT_ADDRESS = '0x1234567890123456789012345678901234567890';
|
|
12
|
+
// Mock viem
|
|
13
|
+
vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
14
|
+
const actual = await importOriginal();
|
|
15
|
+
return {
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
...actual,
|
|
18
|
+
createPublicClient: vitest_1.vi.fn(),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.describe)('Actions', () => {
|
|
22
|
+
(0, vitest_1.describe)('Add Owner', () => {
|
|
23
|
+
(0, vitest_1.test)('', () => {
|
|
24
|
+
(0, vitest_1.expect)((0, _1.addOwner)(MOCK_OWNER_A)).toEqual({
|
|
25
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
26
|
+
data: '0x7065cb48000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.describe)('Remove Owner', () => {
|
|
31
|
+
(0, vitest_1.test)('', () => {
|
|
32
|
+
(0, vitest_1.expect)((0, _1.removeOwner)(MOCK_OWNER_A, MOCK_OWNER_B)).toEqual({
|
|
33
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
34
|
+
data: '0xfbe5ce0a000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.describe)('Set Threshold', () => {
|
|
39
|
+
(0, vitest_1.test)('', () => {
|
|
40
|
+
(0, vitest_1.expect)((0, _1.setThreshold)(1n)).toEqual({
|
|
41
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
42
|
+
data: '0x960bfe040000000000000000000000000000000000000000000000000000000000000001',
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.describe)('Set Up Recovery', async () => {
|
|
47
|
+
const rhinestoneAccount = await (0, __1.createRhinestoneAccount)({
|
|
48
|
+
owners: {
|
|
49
|
+
type: 'ecdsa',
|
|
50
|
+
accounts: [consts_1.accountA],
|
|
51
|
+
},
|
|
52
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.test)('Single Guardian', () => {
|
|
55
|
+
(0, vitest_1.expect)((0, _1.setUpRecovery)({
|
|
56
|
+
rhinestoneAccount,
|
|
57
|
+
guardians: [consts_1.accountB],
|
|
58
|
+
threshold: 1,
|
|
59
|
+
})).toEqual([
|
|
60
|
+
{
|
|
61
|
+
to: '0x27d66c2e6b33579ee108206c4bc8f66bb655e69f',
|
|
62
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
(0, vitest_1.test)('Guardian Multi-Sig', () => {
|
|
67
|
+
(0, vitest_1.expect)((0, _1.setUpRecovery)({
|
|
68
|
+
rhinestoneAccount,
|
|
69
|
+
guardians: [consts_1.accountB, consts_1.accountC, consts_1.accountD],
|
|
70
|
+
threshold: 2,
|
|
71
|
+
})).toEqual([
|
|
72
|
+
{
|
|
73
|
+
to: '0x27d66c2e6b33579ee108206c4bc8f66bb655e69f',
|
|
74
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
75
|
+
},
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.describe)('Recover', () => {
|
|
80
|
+
const mockPublicClient = {
|
|
81
|
+
readContract: vitest_1.vi.fn(),
|
|
82
|
+
};
|
|
83
|
+
(0, vitest_1.beforeEach)(() => {
|
|
84
|
+
const createPublicClientMock = viem_1.createPublicClient;
|
|
85
|
+
createPublicClientMock.mockReturnValue(mockPublicClient);
|
|
86
|
+
vitest_1.vi.clearAllMocks();
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.test)('1/1 Owners - Single owner to different single owner', async () => {
|
|
89
|
+
// Initial state
|
|
90
|
+
mockPublicClient.readContract
|
|
91
|
+
.mockResolvedValueOnce([consts_1.accountA.address.toLowerCase()])
|
|
92
|
+
.mockResolvedValueOnce(1n);
|
|
93
|
+
const newOwners = {
|
|
94
|
+
type: 'ecdsa',
|
|
95
|
+
accounts: [consts_1.accountB],
|
|
96
|
+
threshold: 1,
|
|
97
|
+
};
|
|
98
|
+
const result = await (0, _1.recover)(MOCK_ACCOUNT_ADDRESS, newOwners, chains_1.base);
|
|
99
|
+
(0, vitest_1.expect)(mockPublicClient.readContract).toHaveBeenCalledTimes(2);
|
|
100
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
101
|
+
{
|
|
102
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
103
|
+
data: '0x7065cb480000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
107
|
+
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
(0, vitest_1.test)('1/N Owners - Single owner to multiple owners', async () => {
|
|
112
|
+
// Initial state
|
|
113
|
+
mockPublicClient.readContract
|
|
114
|
+
.mockResolvedValueOnce([
|
|
115
|
+
consts_1.accountA.address.toLowerCase(),
|
|
116
|
+
consts_1.accountB.address.toLowerCase(),
|
|
117
|
+
consts_1.accountC.address.toLowerCase(),
|
|
118
|
+
])
|
|
119
|
+
.mockResolvedValueOnce(1n);
|
|
120
|
+
const newOwners = {
|
|
121
|
+
type: 'ecdsa',
|
|
122
|
+
accounts: [consts_1.accountB, consts_1.accountC, consts_1.accountD],
|
|
123
|
+
threshold: 1,
|
|
124
|
+
};
|
|
125
|
+
const result = await (0, _1.recover)(MOCK_ACCOUNT_ADDRESS, newOwners, chains_1.base);
|
|
126
|
+
(0, vitest_1.expect)(mockPublicClient.readContract).toHaveBeenCalledTimes(2);
|
|
127
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
128
|
+
{
|
|
129
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
130
|
+
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
134
|
+
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
(0, vitest_1.test)('M/N Owners - Multiple owners to different multiple owners', async () => {
|
|
139
|
+
// Initial state
|
|
140
|
+
mockPublicClient.readContract
|
|
141
|
+
.mockResolvedValueOnce([
|
|
142
|
+
consts_1.accountA.address.toLowerCase(),
|
|
143
|
+
consts_1.accountB.address.toLowerCase(),
|
|
144
|
+
consts_1.accountC.address.toLowerCase(),
|
|
145
|
+
])
|
|
146
|
+
.mockResolvedValueOnce(2n);
|
|
147
|
+
const newOwners = {
|
|
148
|
+
type: 'ecdsa',
|
|
149
|
+
accounts: [consts_1.accountB, consts_1.accountD],
|
|
150
|
+
threshold: 2,
|
|
151
|
+
};
|
|
152
|
+
const result = await (0, _1.recover)(MOCK_ACCOUNT_ADDRESS, newOwners, chains_1.base);
|
|
153
|
+
(0, vitest_1.expect)(mockPublicClient.readContract).toHaveBeenCalledTimes(2);
|
|
154
|
+
(0, vitest_1.expect)(result).toEqual([
|
|
155
|
+
{
|
|
156
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
157
|
+
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
161
|
+
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
165
|
+
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596',
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { type Address, type Chain
|
|
1
|
+
import { type Address, type Chain } from 'viem';
|
|
2
2
|
import type { BundleResult } from '../orchestrator';
|
|
3
3
|
import type { RhinestoneAccountConfig, Transaction } from '../types';
|
|
4
|
-
type TransactionResult
|
|
5
|
-
type: 'userop';
|
|
6
|
-
hash: Hex;
|
|
7
|
-
sourceChain: number;
|
|
8
|
-
targetChain: number;
|
|
9
|
-
} | {
|
|
10
|
-
type: 'bundle';
|
|
11
|
-
id: bigint;
|
|
12
|
-
sourceChain?: number;
|
|
13
|
-
targetChain: number;
|
|
14
|
-
};
|
|
4
|
+
import type { BundleData, TransactionResult } from './utils';
|
|
15
5
|
declare function sendTransaction(config: RhinestoneAccountConfig, transaction: Transaction): Promise<TransactionResult>;
|
|
16
|
-
declare function waitForExecution(config: RhinestoneAccountConfig, result: TransactionResult, acceptsPreconfirmations: boolean): Promise<
|
|
6
|
+
declare function waitForExecution(config: RhinestoneAccountConfig, result: TransactionResult, acceptsPreconfirmations: boolean): Promise<{
|
|
17
7
|
actualGasCost: bigint;
|
|
18
8
|
actualGasUsed: bigint;
|
|
19
9
|
entryPoint: Address;
|
|
@@ -25,9 +15,9 @@ declare function waitForExecution(config: RhinestoneAccountConfig, result: Trans
|
|
|
25
15
|
sender: Address;
|
|
26
16
|
success: boolean;
|
|
27
17
|
userOpHash: import("viem").Hash;
|
|
28
|
-
}>;
|
|
18
|
+
} | BundleResult>;
|
|
29
19
|
declare function getMaxSpendableAmount(config: RhinestoneAccountConfig, chain: Chain, tokenAddress: Address, gasUnits: bigint): Promise<bigint>;
|
|
30
20
|
declare function getPortfolio(config: RhinestoneAccountConfig, onTestnets: boolean): Promise<import("../orchestrator").UserTokenBalance[]>;
|
|
31
21
|
export { sendTransaction, waitForExecution, getMaxSpendableAmount, getPortfolio, };
|
|
32
|
-
export type { TransactionResult };
|
|
22
|
+
export type { BundleData, TransactionResult };
|
|
33
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIX,MAAM,MAAM,CAAA;AAKb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAYnD,OAAO,KAAK,EAEV,uBAAuB,EAGvB,WAAW,EACZ,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAe5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BAyBzB;AAsLD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,EACzB,uBAAuB,EAAE,OAAO;;;;;;;;;;;;kBAwCjC;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,iBAAe,YAAY,CACzB,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,OAAO,yDAMpB;AAED,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,GACb,CAAA;AACD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
|