Skip to content

Commit 005667c

Browse files
committed
feat: enhance adding multiple validators or modules while preparing BootStrapConfig entries
1 parent f6454f1 commit 005667c

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/sdk/base/Bootstrap.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,35 @@ export function makeBootstrapConfig(module: string, data: string): BootstrapConf
3737
config.push(newConfig);
3838
return config;
3939
}
40+
41+
export function makeBootstrapConfigForModules(modules: string[], moduleInitDataItems: string[]): BootstrapConfig[] {
42+
const config: BootstrapConfig[] = [];
43+
44+
for (const [index, moduleEntry] of modules.entries()) {
45+
46+
if (!moduleEntry) {
47+
throw new Error(`Module name is not provided for index ${index}.`);
48+
}
49+
50+
const data = moduleInitDataItems[index];
51+
52+
if (!data) {
53+
throw new Error(`Module init data for module ${moduleEntry} is not provided.`);
54+
}
55+
56+
const encodedFunctionData = encodeFunctionData({
57+
functionName: 'onInstall',
58+
abi: parseAbi(modulesAbi),
59+
args: [data],
60+
});
61+
62+
const newConfig: BootstrapConfig = {
63+
module: moduleEntry,
64+
data: encodedFunctionData,
65+
};
66+
67+
config.push(newConfig);
68+
}
69+
70+
return config;
71+
}

src/sdk/base/EtherspotWalletAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getViemAddress } from '../common/utils/viem-utils.js';
66
import { DEFAULT_BOOTSTRAP_ADDRESS, DEFAULT_QUERY_PAGE_SIZE, Networks } from '../network/constants.js';
77
import { BigNumber, BigNumberish } from '../types/bignumber.js';
88
import { BaseAccountAPI, BaseApiParams } from './BaseAccountAPI.js';
9-
import { BootstrapConfig, _makeBootstrapConfig, makeBootstrapConfig } from './Bootstrap.js';
9+
import { BootstrapConfig, _makeBootstrapConfig, makeBootstrapConfig, makeBootstrapConfigForModules } from './Bootstrap.js';
1010
import { getHookMultiPlexerInitData } from '../../../examples/pulse/utils.js';
1111

1212
// Creating a constant for the sentinel address using viem
@@ -233,7 +233,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI {
233233
if (!this.validatorAddress) {
234234
throw new Error('Validator address not found');
235235
}
236-
const validators: BootstrapConfig[] = makeBootstrapConfig(this.validatorAddress, '0x');
236+
const validators: BootstrapConfig[] = makeBootstrapConfigForModules([this.validatorAddress, this.credibleAccountModuleAddress as Hex] , ['0x', '0x']);
237237
const executors: BootstrapConfig[] = makeBootstrapConfig(ADDRESS_ZERO, '0x');
238238

239239
//Get HookMultiPlexer init data with CredibleAccountHook as global subhook

0 commit comments

Comments
 (0)