Skip to content

Conversation

@gagdiez
Copy link
Collaborator

@gagdiez gagdiez commented Aug 22, 2025

This PR updates several files on the repo in order to better use new functionality fromnear-api-js (specifically around the Account class)

  • Updated the expected interface from signAndSendTransactions
  • Updated the sign function to use near-api-js Actions, which are now both supported by NAJ Accounts and Wallet Selector Wallets
  • Fixed all examples (and tested them locally)

I further needed to make other changes:

  • remove creating the typedoc on PRs (will still run after a merge)
  • moved the @contract/account getNearAccount function to an util, as it was only used internally and for testing
  • added ts-node as I needed it locally to run tests
  • replaced deprecated slice function by subarray as otherwise the tests were failing
  • removed sendTransactionUntil, it was no longer necessary as naj Accounts now implement a waitUntil? parameter when sending transactions

This commit fixes the action creation, now, instead of manually
creating an action we rely on `near-api-js` to create it for us,
which should make sure that now actions are compatible with all
tools in the ecosystem

Furthermore, I fixed a couple of small problems in the tests that
and types that were hampering using the library locally for me
@gagdiez gagdiez mentioned this pull request Aug 22, 2025
"jest-environment-node": "^29.7.0",
"prettier": "^3.2.5",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

needed this locally


const hash = createHash('sha512').update(signingData).digest()
const signingHash = new Uint8Array(hash.slice(0, 32))
const signingHash = new Uint8Array(hash.subarray(0, 32))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

slice is deprecated

@gagdiez gagdiez requested a review from GregProuty August 22, 2025 15:12
@gagdiez gagdiez marked this pull request as draft August 22, 2025 15:50
Copy link
Collaborator

@GregProuty GregProuty left a comment

Choose a reason for hiding this comment

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

Everything looks good, thanks for catching and fixing these issues. One concern, let’s avoid re-introducing near-api-js, we should stay standardized on the v2 @near-js/* packages to prevent mixing v1/v2 deps.

I ran into errors using near-api-js with ed25519 transactions in the Near adapter.

near-api-js v5 pulls in @near-js/* v1 as dependencies. This creates runtime conflicts where two different Borsh schemas try to serialize the same transactions, causing "Enum key not found" errors and breaking Ed25519 signing in the NEAR adapter.

We should be able to replace the near-api-js imports with v2 equivalents:

// Change these imports:
import { providers } from 'near-api-js'
import { getTransactionLastResult } from 'near-api-js/lib/providers'

// To these:
import { JsonRpcProvider } from '@near-js/providers'
import { getTransactionLastResult } from '@near-js/utils'

@gagdiez gagdiez marked this pull request as ready for review August 29, 2025 13:29
"import-local": "^3.2.0",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"near-api-js": "^6.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as devdependency for the tests that use it, ideally we remove it entirely in the future

@gagdiez gagdiez changed the title Fix actions and tests General updates to better utilize naj 6 / nearjs 2 Aug 29, 2025
@gagdiez gagdiez changed the title General updates to better utilize naj 6 / nearjs 2 Better utilize naj 6 / nearjs 2 Aug 29, 2025
@gagdiez gagdiez added this to DevRel Sep 1, 2025
@github-project-automation github-project-automation bot moved this to NEW❗ in DevRel Sep 1, 2025
Copy link
Collaborator

@GregProuty GregProuty left a comment

Choose a reason for hiding this comment

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

Looks great, just one nit, ChainSignatureContract.ts line 64: I'm getting a typescript error building the library src/contracts/ChainSignatureContract.ts(64,7): error TS2345: Argument of type 'JsonRpcProvider[]' is not assignable to parameter of type 'Provider[]'

should be easy to fix with a type assertion.

Other than that looks good to merge

@gagdiez gagdiez merged commit b492115 into NearDeFi:main Sep 10, 2025
@github-project-automation github-project-automation bot moved this from NEW❗ to Shipped 🚀 in DevRel Sep 10, 2025
@gagdiez gagdiez deleted the fix-actions branch September 10, 2025 14:13
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.

2 participants