-
Notifications
You must be signed in to change notification settings - Fork 133
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
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 9e85b29
fix: fixed type export for `SmartAccountSinger`
whatmanathinks e8a4255
Merge branch 'main' of https://github.com/alchemyplatform/aa-sdk
whatmanathinks dadd50a
feat: added signMessage method in `SmartAccountProvider`
whatmanathinks 95a9b62
feat: fixed lint errors
whatmanathinks 8515f17
feat: exported `alchemyPaymasterAndDataMiddleware` in alchemy package
whatmanathinks 19b5bef
feat: fixed core package build issues
whatmanathinks 3c6af33
feat: fixed estimation mismatch and implemented signMessage method fo…
whatmanathinks ea3315c
feat: fixed estimation mismatch and implemented signMessage method fo…
whatmanathinks 3ccc6e7
Merge branch 'alchemyplatform:main' into main
whatmanathinks a3d27b1
Merge branch 'main' of https://github.com/alchemyplatform/aa-sdk
whatmanathinks d2efcc4
Merge branch 'main' of https://github.com/0xpass/alchemy-sdk
whatmanathinks e1f0827
feat: added support for batch transfers
whatmanathinks cb771ff
feat: added support for batch transfers
whatmanathinks 542146d
feat: added support for batch transfers
whatmanathinks ecc6474
fix: lint errors fixes
whatmanathinks ebedd91
fix: lint errors fixes
whatmanathinks 2d76d61
fix: minor code enhancements
whatmanathinks 22cfdce
fix: few cleanup items and nits
whatmanathinks a39205a
fix: few cleanup items and nits
whatmanathinks 6da1bf4
fix: few cleanup items and nits
whatmanathinks 20eb681
fix: few cleanup items and nits
whatmanathinks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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, | ||
|
@@ -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; | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
return this.account.signWithEip6492(msg); | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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