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: "Cannot mix BigInt and other types" for signing transaction with explicitly provided nonce #1492

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

frol
Copy link
Collaborator

@frol frol commented Mar 13, 2025

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • Commit messages follow the conventional commits spec
  • If this is a code change: I have written unit tests.
  • If this changes code in a published package: I have run pnpm changeset to create a changeset JSON document appropriate for this change.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Test Plan

Related issues/PRs

Copy link

changeset-bot bot commented Mar 13, 2025

🦋 Changeset detected

Latest commit: ed4404f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@near-js/client Patch

Not sure what this means? Click here to learn what changesets are.

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

@frol frol marked this pull request as ready for review March 13, 2025 15:04
@frol
Copy link
Collaborator Author

frol commented Mar 13, 2025

@gagdiez May I ask for your review? We have discovered this issue today with @BenKurrek since he was manually controlling nonce and NAJ was crashing his app since undefined += 1n did not work.

@gagdiez
Copy link
Contributor

gagdiez commented Mar 14, 2025

why not just initializing the nonce as 0n? I'm quite sure that leaving it as undefined will break something further down the line, specially with borsh serialization

What is the issue / code that originated this PR?

@frol
Copy link
Collaborator Author

frol commented Mar 19, 2025

@gagdiez I considered that, but initializing it with 0 will create other bugs - if you first sign a transaction with explicit nonce and next time without explicit nonce, it will use nonce=1, which is wrong. Also, just on the conceptual level it is not a right move to initialize it with invalid value.

Regarding you concern that this fix might bite us elsewhere, I don’t believe so as this value is tied to this internal state and not used directly anywhere else.

@gagdiez
Copy link
Contributor

gagdiez commented Mar 20, 2025

I have no better solution for now, so I will not block this, approved

@frol frol merged commit 518e3c6 into master Mar 20, 2025
1 check passed
@frol frol deleted the fix/signing-explicit-nonce branch March 20, 2025 11:41
@github-actions github-actions bot mentioned this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Shipped 🚀
Development

Successfully merging this pull request may close these issues.

3 participants