-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added getUpgradeKernelCall util
- Loading branch information
1 parent
9776f74
commit ce9c082
Showing
5 changed files
with
41 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# @zerodev/sdk | ||
|
||
## 5.4.8 | ||
|
||
### Patch Changes | ||
|
||
- Added getUpgradeKernelCall util | ||
|
||
## 5.4.7 | ||
|
||
### Patch Changes | ||
|
29 changes: 29 additions & 0 deletions
29
packages/core/accounts/kernel/utils/common/getUpgradeKernelCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { Hex } from "viem" | ||
import { encodeFunctionData } from "viem" | ||
import type { SmartAccount } from "viem/account-abstraction" | ||
import { KernelVersionToAddressesMap } from "../../../../constants.js" | ||
import type { KERNEL_VERSION_TYPE } from "../../../../types/kernel.js" | ||
import { validateKernelVersionWithEntryPoint } from "../../../../utils.js" | ||
import { KernelV3AccountAbi } from "../../abi/kernel_v_3_0_0/KernelAccountAbi.js" | ||
|
||
export function getUpgradeKernelCall( | ||
account: SmartAccount, | ||
kernelVersion: KERNEL_VERSION_TYPE | ||
): { to: string; data: Hex; value: bigint } { | ||
validateKernelVersionWithEntryPoint( | ||
account.entryPoint.version, | ||
kernelVersion | ||
) | ||
const implementation = | ||
KernelVersionToAddressesMap[kernelVersion].accountImplementationAddress | ||
|
||
return { | ||
to: account.address, | ||
data: encodeFunctionData({ | ||
abi: KernelV3AccountAbi, | ||
functionName: "upgradeTo", | ||
args: [implementation] | ||
}), | ||
value: 0n | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters