Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: kernel batch transactions and gas estimation fixes #39

Merged
merged 22 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
db0a691
feat: `ISmartAccountProvider` accepts `BaseSmartContractAccount` as g…
whatmanathinks Jun 17, 2023
9e85b29
fix: fixed type export for `SmartAccountSinger`
whatmanathinks Jun 19, 2023
e8a4255
Merge branch 'main' of https://github.com/alchemyplatform/aa-sdk
whatmanathinks Jun 28, 2023
dadd50a
feat: added signMessage method in `SmartAccountProvider`
whatmanathinks Jun 28, 2023
95a9b62
feat: fixed lint errors
whatmanathinks Jun 28, 2023
8515f17
feat: exported `alchemyPaymasterAndDataMiddleware` in alchemy package
whatmanathinks Jun 28, 2023
19b5bef
feat: fixed core package build issues
whatmanathinks Jun 28, 2023
3c6af33
feat: fixed estimation mismatch and implemented signMessage method fo…
whatmanathinks Jun 28, 2023
ea3315c
feat: fixed estimation mismatch and implemented signMessage method fo…
whatmanathinks Jun 28, 2023
3ccc6e7
Merge branch 'alchemyplatform:main' into main
whatmanathinks Jun 28, 2023
a3d27b1
Merge branch 'main' of https://github.com/alchemyplatform/aa-sdk
whatmanathinks Jun 29, 2023
d2efcc4
Merge branch 'main' of https://github.com/0xpass/alchemy-sdk
whatmanathinks Jun 29, 2023
e1f0827
feat: added support for batch transfers
whatmanathinks Jun 30, 2023
cb771ff
feat: added support for batch transfers
whatmanathinks Jun 30, 2023
542146d
feat: added support for batch transfers
whatmanathinks Jun 30, 2023
ecc6474
fix: lint errors fixes
whatmanathinks Jun 30, 2023
ebedd91
fix: lint errors fixes
whatmanathinks Jun 30, 2023
2d76d61
fix: minor code enhancements
whatmanathinks Jul 1, 2023
22cfdce
fix: few cleanup items and nits
whatmanathinks Jul 4, 2023
a39205a
fix: few cleanup items and nits
whatmanathinks Jul 4, 2023
6da1bf4
fix: few cleanup items and nits
whatmanathinks Jul 4, 2023
20eb681
fix: few cleanup items and nits
whatmanathinks Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"test:run": "vitest run"
},
"devDependencies": {
"@alchemy/aa-core": "^0.1.0-alpha.11",
"@alchemy/aa-core": "^0.1.0-alpha.12",
"typescript": "^5.0.4",
"typescript-template": "*",
"viem": "^1.1.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts/src/kernel-zerodev/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class KernelSmartContractAccount<
}

getDummySignature(): Hex {
return "0x4046ab7d9c387d7a5ef5ca0777eded29767fd9863048946d35b3042d2f7458ff7c62ade2903503e15973a63a296313eab15b964a18d79f4b06c8c01c7028143c1c";
return "0x00000000b650d28e51cf39d5c0bb7db6d81cce5f0a77baba8bf8de587c0bc83fa70e374f3bfef2afb697dc5627c669de7dc13e96c85697e0f6aae2f2ebe227552d00cb181c";
}

async encodeExecute(target: Hex, value: bigint, data: Hex): Promise<Hex> {
Expand Down
41 changes: 6 additions & 35 deletions packages/accounts/src/kernel-zerodev/provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HttpTransport } from "viem";
import type { Hash, HttpTransport } from "viem";
import {
type AccountMiddlewareFn,
deepHexlify,
Expand All @@ -7,40 +7,11 @@ import {
} from "@alchemy/aa-core";

export class KernelAccountProvider extends SmartAccountProvider<HttpTransport> {
gasEstimator: AccountMiddlewareFn = async (struct) => {
const request = deepHexlify(await resolveProperties(struct));
const estimates = await this.rpcClient.estimateUserOperationGas(
request,
this.entryPointAddress
);

estimates.verificationGasLimit =
(BigInt(estimates.verificationGasLimit) * 130n) / 100n;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moldy530

I didn't have accurate answer to your question about requiring 30% extra gas usage for kernel. Turns out, it was because i added an inaccurate dummy signature which leads to underestimation of gas. Fixed in this update


return {
...struct,
...estimates,
};
};

request: (args: { method: string; params?: any[] }) => Promise<any> = async (
args
) => {
const { method, params } = args;
if (method === "personal_sign") {
if (!this.account) {
throw new Error("account not connected!");
}
const [data, address] = params!;
if (address !== (await this.getAddress())) {
throw new Error(
"cannot sign for address that is not the current account"
);
}
// @ts-ignore
return this.account.signWithEip6492(data);
} else {
return super.request(args);
signMessage = async (msg: string | Uint8Array): Promise<Hash> => {
if (!this.account) {
throw new Error("account not connected!");
}
// @ts-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this @ts-ignore: <reason for ignore> also we shouldn't use @ts-ignore and instead use @ts-expect-error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return this.account.signWithEip6492(msg);
};
}