Skip to content

Commit

Permalink
feat: add initConfig support to createKernelAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilVasava committed Aug 2, 2024
1 parent abac820 commit a7c2351
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @zerodev/sdk

## 5.3.8

### Patch Changes

- Added initConfig support in createKernelAccount

## 5.3.7

### Patch Changes
Expand Down
28 changes: 20 additions & 8 deletions packages/core/accounts/kernel/createKernelAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export type KernelSmartAccount<
encodeModuleInstallCallData: () => Promise<Hex>
}

export type CreateKernelAccountParameters<entryPoint extends EntryPoint> = {
export type CreateKernelAccountParameters<
entryPoint extends EntryPoint,
KernelVerion extends GetKernelVersion<entryPoint>
> = {
plugins:
| Omit<
KernelPluginManagerParams<entryPoint>,
Expand All @@ -82,6 +85,7 @@ export type CreateKernelAccountParameters<entryPoint extends EntryPoint> = {
metaFactoryAddress?: Address
deployedAccountAddress?: Address
kernelVersion: GetKernelVersion<entryPoint>
initConfig?: KernelVerion extends "0.3.1" ? Hex[] : never
}

/**
Expand Down Expand Up @@ -140,12 +144,14 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
entryPoint: entryPointAddress,
kernelPluginManager,
initHook,
kernelVersion
kernelVersion,
initConfig
}: {
entryPoint: entryPoint
kernelPluginManager: KernelPluginManager<entryPoint>
initHook: boolean
kernelVersion: GetKernelVersion<entryPoint>
initConfig?: GetKernelVersion<entryPoint> extends "0.3.1" ? Hex[] : never
}) => {
const entryPointVersion = getEntryPointVersion(entryPointAddress)
const { enableData, identifier, validatorAddress } =
Expand Down Expand Up @@ -187,7 +193,7 @@ const getKernelInitData = async <entryPoint extends EntryPoint>({
initHook && kernelPluginManager.hook
? await kernelPluginManager.hook?.getEnableData()
: "0x",
[]
initConfig ?? []
]
})
}
Expand All @@ -207,7 +213,8 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
entryPoint: entryPointAddress,
kernelPluginManager,
initHook,
kernelVersion
kernelVersion,
initConfig
}: {
index: bigint
factoryAddress: Address
Expand All @@ -217,13 +224,15 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
kernelPluginManager: KernelPluginManager<entryPoint>
initHook: boolean
kernelVersion: GetKernelVersion<entryPoint>
initConfig?: GetKernelVersion<entryPoint> extends "0.3.1" ? Hex[] : never
}): Promise<Hex> => {
// Build the account initialization data
const initialisationData = await getKernelInitData<entryPoint>({
entryPoint: entryPointAddress,
kernelPluginManager,
initHook,
kernelVersion
kernelVersion,
initConfig
})
const entryPointVersion = getEntryPointVersion(entryPointAddress)

Expand Down Expand Up @@ -336,6 +345,7 @@ const getDefaultAddresses = <entryPoint extends EntryPoint>(
*/
export async function createKernelAccount<
entryPoint extends EntryPoint,
KernelVersion extends GetKernelVersion<entryPoint>,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
>(
Expand All @@ -348,8 +358,9 @@ export async function createKernelAccount<
accountImplementationAddress: _accountImplementationAddress,
metaFactoryAddress: _metaFactoryAddress,
deployedAccountAddress,
kernelVersion
}: CreateKernelAccountParameters<entryPoint>
kernelVersion,
initConfig
}: CreateKernelAccountParameters<entryPoint, KernelVersion>
): Promise<KernelSmartAccount<entryPoint, TTransport, TChain>> {
const entryPointVersion = getEntryPointVersion(entryPointAddress)
const { accountImplementationAddress, factoryAddress, metaFactoryAddress } =
Expand Down Expand Up @@ -393,7 +404,8 @@ export async function createKernelAccount<
entryPoint: entryPointAddress,
kernelPluginManager,
initHook,
kernelVersion
kernelVersion,
initConfig
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zerodev/sdk",
"version": "5.3.7",
"version": "5.3.8",
"author": "ZeroDev",
"main": "./_cjs/index.js",
"module": "./_esm/index.js",
Expand Down

0 comments on commit a7c2351

Please sign in to comment.