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

fix: add parseEip712Transaction util function #2948

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nikola-bozin-txfusion
Copy link
Contributor

@nikola-bozin-txfusion nikola-bozin-txfusion commented Oct 31, 2024

PR-Codex overview

This PR introduces the parseEip712Transaction function to handle EIP-712 transactions in the zksync project. It includes validation for transaction types, parsing of paymaster parameters, and tests for various scenarios, ensuring robust handling of serialized transactions.

Detailed summary

  • Added parseEip712Transaction function in src/zksync/utils/parseEip712Transaction.ts.
  • Implemented validation for EIP-712 transaction type.
  • Created helper functions: validHex and parsePaymasterArray.
  • Parsed transaction details from RLP-encoded data.
  • Added tests in src/zksync/utils/parseEip712Transaction.test.ts for:
    • Default transaction parsing.
    • Transactions with paymaster parameters.
    • Error handling for non-EIP-712 transactions.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Oct 31, 2024

⚠️ No Changeset found

Latest commit: 5f8b1d3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 31, 2024

@nikola-bozin-txfusion is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

export function parseEip712Transaction(
transaction: Hex,
): ZksyncTransactionSerializableEIP712 {
{
Copy link
Member

Choose a reason for hiding this comment

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

Is the scope required here (L14 + L21)?

Choose a reason for hiding this comment

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

The scope is removed.

src/zksync/utils/parseEip712Transaction.ts Outdated Show resolved Hide resolved
src/zksync/utils/parseEip712Transaction.ts Outdated Show resolved Hide resolved
throw new BaseError('transaction type must be eip712')
}

return constructEip712Transaction(payload)
Copy link
Member

Choose a reason for hiding this comment

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

Can we inline the contents of constructEip712Transaction into here?

Choose a reason for hiding this comment

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

The constructEip712Transaction method is inlined.

Comment on lines 27 to 30
type PaymasterParams = {
paymaster: Hex
paymasterInput: Hex
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to explicitly define this type? The handleArrayToPaymaster return type should be inferred.

Choose a reason for hiding this comment

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

PaymasterParams is not needed and it has been removed.

src/zksync/utils/parseEip712Transaction.ts Outdated Show resolved Hide resolved
src/zksync/utils/parseEip712Transaction.ts Outdated Show resolved Hide resolved
src/zksync/utils/parseEip712Transaction.ts Outdated Show resolved Hide resolved
@jxom
Copy link
Member

jxom commented Nov 3, 2024

Can we please add an export & docs for this? Also needs a changeset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants