Skip to content

Commit

Permalink
Merge branch 'feat/kernel-v3-ep-v0_7-integration' into feat/2d-nonces
Browse files Browse the repository at this point in the history
  • Loading branch information
adnpark authored Apr 8, 2024
2 parents 5c88498 + 64098e2 commit 5b9583e
Show file tree
Hide file tree
Showing 17 changed files with 329 additions and 144 deletions.
153 changes: 99 additions & 54 deletions packages/core/accounts/kernel/abi/kernel_v_3_0_0/KernelAccountAbi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ export const KernelV3ExecuteAbi = [
name: "execute",
inputs: [
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
{
name: "executionCalldata",
type: "bytes",
internalType: "bytes"
}
{ name: "executionCalldata", type: "bytes", internalType: "bytes" }
],
outputs: [],
stateMutability: "payable"
Expand All @@ -37,11 +33,7 @@ export const KernelV3ExecuteAbi = [
name: "executeFromExecutor",
inputs: [
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
{
name: "executionCalldata",
type: "bytes",
internalType: "bytes"
}
{ name: "executionCalldata", type: "bytes", internalType: "bytes" }
],
outputs: [
{ name: "returnData", type: "bytes[]", internalType: "bytes[]" }
Expand Down Expand Up @@ -144,11 +136,7 @@ export const KernelV3AccountAbi = [
internalType: "address"
},
{ name: "salt", type: "bytes32", internalType: "bytes32" },
{
name: "extensions",
type: "uint256[]",
internalType: "uint256[]"
}
{ name: "extensions", type: "uint256[]", internalType: "uint256[]" }
],
stateMutability: "view"
},
Expand All @@ -157,11 +145,7 @@ export const KernelV3AccountAbi = [
name: "entrypoint",
inputs: [],
outputs: [
{
name: "",
type: "address",
internalType: "contract IEntryPoint"
}
{ name: "", type: "address", internalType: "contract IEntryPoint" }
],
stateMutability: "view"
},
Expand All @@ -170,11 +154,7 @@ export const KernelV3AccountAbi = [
name: "execute",
inputs: [
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
{
name: "executionCalldata",
type: "bytes",
internalType: "bytes"
}
{ name: "executionCalldata", type: "bytes", internalType: "bytes" }
],
outputs: [],
stateMutability: "payable"
Expand All @@ -184,11 +164,7 @@ export const KernelV3AccountAbi = [
name: "executeFromExecutor",
inputs: [
{ name: "execMode", type: "bytes32", internalType: "ExecMode" },
{
name: "executionCalldata",
type: "bytes",
internalType: "bytes"
}
{ name: "executionCalldata", type: "bytes", internalType: "bytes" }
],
outputs: [
{ name: "returnData", type: "bytes[]", internalType: "bytes[]" }
Expand Down Expand Up @@ -266,16 +242,6 @@ export const KernelV3AccountAbi = [
],
stateMutability: "view"
},
{
type: "function",
name: "fallbackConfig",
inputs: [],
outputs: [
{ name: "", type: "address", internalType: "contract IFallback" },
{ name: "", type: "address", internalType: "contract IHook" }
],
stateMutability: "view"
},
{
type: "function",
name: "initialize",
Expand Down Expand Up @@ -303,6 +269,34 @@ export const KernelV3AccountAbi = [
outputs: [],
stateMutability: "payable"
},
{
type: "function",
name: "installValidations",
inputs: [
{ name: "vIds", type: "bytes21[]", internalType: "ValidationId[]" },
{
name: "configs",
type: "tuple[]",
internalType: "struct ValidationManager.ValidationConfig[]",
components: [
{ name: "nonce", type: "uint32", internalType: "uint32" },
{
name: "hook",
type: "address",
internalType: "contract IHook"
}
]
},
{
name: "validationData",
type: "bytes[]",
internalType: "bytes[]"
},
{ name: "hookData", type: "bytes[]", internalType: "bytes[]" }
],
outputs: [],
stateMutability: "nonpayable"
},
{
type: "function",
name: "invalidateNonce",
Expand All @@ -326,11 +320,7 @@ export const KernelV3AccountAbi = [
inputs: [
{ name: "moduleType", type: "uint256", internalType: "uint256" },
{ name: "module", type: "address", internalType: "address" },
{
name: "additionalContext",
type: "bytes",
internalType: "bytes"
}
{ name: "additionalContext", type: "bytes", internalType: "bytes" }
],
outputs: [{ name: "", type: "bool", internalType: "bool" }],
stateMutability: "view"
Expand Down Expand Up @@ -399,7 +389,16 @@ export const KernelV3AccountAbi = [
type: "address",
internalType: "contract IHook"
},
{ name: "target", type: "address", internalType: "address" }
{
name: "target",
type: "address",
internalType: "address"
},
{
name: "callType",
type: "bytes1",
internalType: "CallType"
}
]
}
],
Expand All @@ -425,7 +424,7 @@ export const KernelV3AccountAbi = [
type: "function",
name: "uninstallModule",
inputs: [
{ name: "", type: "uint256", internalType: "uint256" },
{ name: "moduleType", type: "uint256", internalType: "uint256" },
{ name: "module", type: "address", internalType: "address" },
{ name: "deInitData", type: "bytes", internalType: "bytes" }
],
Expand All @@ -437,7 +436,21 @@ export const KernelV3AccountAbi = [
name: "uninstallValidation",
inputs: [
{ name: "vId", type: "bytes21", internalType: "ValidationId" },
{ name: "deinitData", type: "bytes", internalType: "bytes" }
{ name: "deinitData", type: "bytes", internalType: "bytes" },
{ name: "hookDeinitData", type: "bytes", internalType: "bytes" }
],
outputs: [],
stateMutability: "payable"
},
{
type: "function",
name: "upgradeTo",
inputs: [
{
name: "_newImplementation",
type: "address",
internalType: "address"
}
],
outputs: [],
stateMutability: "payable"
Expand Down Expand Up @@ -507,7 +520,7 @@ export const KernelV3AccountAbi = [
},
{
type: "function",
name: "validatorConfig",
name: "validationConfig",
inputs: [
{ name: "vId", type: "bytes21", internalType: "ValidationId" }
],
Expand Down Expand Up @@ -547,6 +560,25 @@ export const KernelV3AccountAbi = [
],
anonymous: false
},
{
type: "event",
name: "ModuleUninstallResult",
inputs: [
{
name: "module",
type: "address",
indexed: false,
internalType: "address"
},
{
name: "result",
type: "bool",
indexed: false,
internalType: "bool"
}
],
anonymous: false
},
{
type: "event",
name: "ModuleUninstalled",
Expand Down Expand Up @@ -674,6 +706,19 @@ export const KernelV3AccountAbi = [
],
anonymous: false
},
{
type: "event",
name: "Upgraded",
inputs: [
{
name: "implementation",
type: "address",
indexed: true,
internalType: "address"
}
],
anonymous: false
},
{
type: "event",
name: "ValidatorInstalled",
Expand Down Expand Up @@ -715,15 +760,15 @@ export const KernelV3AccountAbi = [
{ type: "error", name: "InvalidMode", inputs: [] },
{ type: "error", name: "InvalidModuleType", inputs: [] },
{ type: "error", name: "InvalidNonce", inputs: [] },
{ type: "error", name: "InvalidSelector", inputs: [] },
{ type: "error", name: "InvalidSignature", inputs: [] },
{ type: "error", name: "InvalidValidationType", inputs: [] },
{ type: "error", name: "InvalidValidator", inputs: [] },
{ type: "error", name: "NonceInvalidationError", inputs: [] },
{ type: "error", name: "NotSupportedCallType", inputs: [] },
{ type: "error", name: "OnlyExecuteUserOp", inputs: [] },
{
type: "error",
name: "PermissionNotAlllowedForSignature",
inputs: []
},
{ type: "error", name: "PermissionDataLengthMismatch", inputs: [] },
{ type: "error", name: "PermissionNotAlllowedForSignature", inputs: [] },
{ type: "error", name: "PermissionNotAlllowedForUserOp", inputs: [] },
{ type: "error", name: "PolicyDataTooLarge", inputs: [] },
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/accounts/kernel/createKernelAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const KERNEL_ADDRESSES: {
ENTRYPOINT_V0_6: Address
} = {
ACCOUNT_LOGIC_V0_6: "0xd3082872F8B06073A021b4602e022d5A070d7cfC",
ACCOUNT_LOGIC_V0_7: "0x079D5D8A3275A230AF743cB59c341Ff74B82488D",
ACCOUNT_LOGIC_V0_7: "0x541E811D24A54745619a5B9f0c1d4B08D5740144",
FACTORY_ADDRESS: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
ENTRYPOINT_V0_6: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export const getKernelV3Nonce = async (
})
return nonce
} catch (error) {
return 2
return 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export const getEncodedPluginsData = async <
[
enableData,
"0x",
concat([action.selector, action.address, zeroAddress, "0x"]),
// [TODO]: Integrate custom target contract and hook
concat([
action.selector /*, action.address, zeroAddress, "0x"*/
]),
enableSignature,
userOpSignature
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ export const getPluginsEnableTypedData = async <
validatorData: await validator.getEnableData(accountAddress),
hookData: "0x",
selectorData: concat([
action.selector,
action.selector
/*
action.address,
zeroAddress,
"0x"
*/
])
},
primaryType: "Enable"
Expand Down
4 changes: 1 addition & 3 deletions packages/core/actions/paymaster/sponsorUserOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {
import { ENTRYPOINT_ADDRESS_V06, deepHexlify } from "permissionless/utils"
import type { Address, Hex } from "viem"
import type { PartialBy } from "viem/types/utils"
import { KERNEL_ADDRESSES } from "../../accounts/index.js"
import type { ZeroDevPaymasterClient } from "../../clients/paymasterClient.js"

export type SponsorUserOperationParameters<entryPoint extends EntryPoint> = {
Expand Down Expand Up @@ -70,8 +69,7 @@ export const sponsorUserOperation = async <entryPoint extends EntryPoint>(
) as UserOperationWithBigIntAsHex<
GetEntryPointVersion<entryPoint>
>,
entryPointAddress:
args.entryPoint ?? KERNEL_ADDRESSES.ENTRYPOINT_V0_6,
entryPointAddress: args.entryPoint,
gasTokenData: args.gasToken && {
tokenAddress: args.gasToken
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const KernelImplToVersionMap: { [key: Address]: string } = {
"0xD3F582F6B4814E989Ee8E96bc3175320B5A540ab": "0.2.3",
"0x5FC0236D6c88a65beD32EECDC5D60a5CAb377717": "0.2.3",
"0xd3082872F8B06073A021b4602e022d5A070d7cfC": "0.2.4",
"0x079D5D8A3275A230AF743cB59c341Ff74B82488D": "0.3.0-beta"
"0x541E811D24A54745619a5B9f0c1d4B08D5740144": "0.3.0-beta"
}
export const TOKEN_ACTION = "0x2087C7FfD0d0DAE80a00EE74325aBF3449e0eaf1"
export const KERNEL_NAME = "Kernel"
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.2.1-alpha-2",
"version": "5.2.1-alpha-3",
"author": "ZeroDev",
"main": "./_cjs/index.js",
"module": "./_esm/index.js",
Expand Down
37 changes: 37 additions & 0 deletions packages/test/abis/TokenActionsAbi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const TokenActionsAbi = [
{
type: "function",
name: "transferERC1155Action",
inputs: [
{ name: "_token", type: "address", internalType: "address" },
{ name: "_id", type: "uint256", internalType: "uint256" },
{ name: "_to", type: "address", internalType: "address" },
{ name: "amount", type: "uint256", internalType: "uint256" },
{ name: "data", type: "bytes", internalType: "bytes" }
],
outputs: [],
stateMutability: "nonpayable"
},
{
type: "function",
name: "transferERC20Action",
inputs: [
{ name: "_token", type: "address", internalType: "address" },
{ name: "_amount", type: "uint256", internalType: "uint256" },
{ name: "_to", type: "address", internalType: "address" }
],
outputs: [],
stateMutability: "nonpayable"
},
{
type: "function",
name: "transferERC721Action",
inputs: [
{ name: "_token", type: "address", internalType: "address" },
{ name: "_id", type: "uint256", internalType: "uint256" },
{ name: "_to", type: "address", internalType: "address" }
],
outputs: [],
stateMutability: "nonpayable"
}
] as const
2 changes: 2 additions & 0 deletions packages/test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ export const config: {
}
}
}

export const TOKEN_ACTION_ADDRESS = "0xA015bd458DbAc61c254104099f544dB6ef570c7C"
Loading

0 comments on commit 5b9583e

Please sign in to comment.