Open
Description
Prerequisites
- I'm using the latest version of
near-api-js
. - I have tried to start with a fresh project and reproduce the defect with minimal code changes.
- I have read the console error messages carefully (if applicable).
Description
When running some test code for my NEAR DEX app, I ran into some issues with signing and sending transactions with an UnencryptedFileSystemKeyStore
object.
Reproducible demo
No response
Steps to reproduce
- Setup:
const keystore = new keyStores.UnencryptedFileSystemKeyStore(`${homedir()}/.near-credentials/`)
const nearTest = await connect({
networkId: 'testnet',
keyStore: keystore,
nodeUrl: 'https://rpc.testnet.near.org',
helperUrl: 'https://helper.nearprotocol.com'
})
const account = await nearTest.account(TEST_ACCOUNT_ID);
let res = await account.signAndSendTransaction({...});
- run
near create TEST_ACCOUNT_ID --useFaucet
- verify key exists manually
- run code
Expected behavior
transaction should execute and res should resolve to a transaction result
Actual behavior
instead, Near spits out this error:
/Users/metatron/Documents/degendevs/node_modules/@near-js/accounts/lib/commonjs/account.cjs:50
throw new types_1.TypedError(`Can not sign transactions for account ${this.accountId} on network ${this.connection.networkId}, no matching key pair exists for this account`, 'KeyNotFound');
^
TypedError: Can not sign transactions for account bta-251494586 on network testnet, no matching key pair exists for this account
at Account.signTransaction (/Users/metatron/Documents/degendevs/node_modules/@near-js/accounts/lib/commonjs/account.cjs:50:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/metatron/Documents/degendevs/node_modules/@near-js/accounts/lib/commonjs/account.cjs:72:34
at async exponentialBackoff (/Users/metatron/Documents/degendevs/node_modules/@near-js/providers/lib/commonjs/exponential-backoff.cjs:8:24)
at async Account.signAndSendTransaction (/Users/metatron/Documents/degendevs/node_modules/@near-js/accounts/lib/commonjs/account.cjs:71:24)
at async /Users/metatron/Documents/degendevs/index.js:92:16
at async Promise.all (index 1)
at async Object.swapToken (/Users/metatron/Documents/degendevs/index.js:91:15)
at async main (/Users/metatron/Documents/degendevs/test.js:61:18) {
type: 'KeyNotFound',
context: undefined
}
again, i have verified the key file exists at $HOME/.near-credentials/testnet/bta-251494586.json
and is valid.
Your environment
- NEAR JavaScript API version used: 5.0.1
- Frontend framework (if applicable): N/A
- Relevant dependencies (if applicable): N/A
Self-service
- I'd be willing to fix this bug myself.
Metadata
Assignees
Labels
Type
Projects
Status
NEW❗