Releases: near/near-api-js
Release list
v7.2.0
Minor Changes
-
#1877
eb345dfThanks @mikedotexe! - Replace Buffer usage with Uint8Array and Web Standard APIs (TextEncoder/TextDecoder, @scure/base) for CommonJS compatibility -
#1872
dd086d4Thanks @gagdiez! - Added a signer that knows how to use the legacy keystore -
#1877
eb345dfThanks @mikedotexe! - Replace secp256k1 native crypto dependency with @noble/curves/secp256k1, adapting to the v2 API (prehash option, signature byte ordering)
Patch Changes
v7.1.1
v7.1.0
v7.0.4
v7.0.3
v7.0.2
v7.0.1
Patch Changes
-
#1822
8493b36Thanks @denbite! - Explicitly declare the return type ofAccount.signAndSendTransactionso it doesn't fallback toany -
#1819
e6f4db2Thanks @gagdiez! - Correctly expose the newActionsinterface, which simplify creating actions, and hide the oldActionclass, which needs a lot of manual work and is incredibly confusing. Importantly,Action(and its different instances) are still being exported as a type, to devs can figure out how to distinguis between differentActions. -
#1818
a82e47fThanks @denbite! - Attach finalizedblockHashto transaction created usingAccount.createTransactionto preventTransactionExpiredErrorerrors.Previously, transactions could be created with a
blockHashthat had not yet fully propagated across the network. In some cases, receiver RPC nodes were unable to look up the referenced block, resulting inTransactionExpiredErrorfailures (often due to a small propagation delay of a few milliseconds).
v7.0.0
Major Changes
-
#1691
f8666a0Thanks @r-near! - UpdateparseNearAmountto only accept either a numeric string, or actual number, and not undefined, as well as throw error rather than silently returnnull -
#1691
f8666a0Thanks @r-near! - Rename stableviewValidatorsV2function back toviewValidators -
#1809
eee87c2Thanks @gagdiez! - Consolidate functionality of the@near-js/*packages into a single, tree-shakeablenear-api-jspackage -
#1805
9356419Thanks @denbite! - Remove no longer needed error utils likegetErrorTypeFromErrorMessage,parseRpcError,parseResultError, etc from the package as errors are now handled internally thanks to strongly typed RPC errors and end users can simply catch them in their application using specific error classes imported fromrpc-errorssub-path -
#1781
1caddf4Thanks @denbite! - ReplaceTypedErrorclass with a few specific errors created from fully type-safe RPC interfaces -
#1808
bf7c148Thanks @denbite! - RenameTypedContractback toContract -
#1669
683e1dbThanks @denbite! - Remove no longer maintained packages@near-js/iframe-rpc,@near-js/biometric-ed25519and@near-js/clientwith@near-js/cookbookexamples -
#1670
54e4d48Thanks @denbite! - Remove no longer maintained packages@near-js/keystores,@near-js/keystores-nodeand@near-js/keystores-browser -
#1673
5d86344Thanks @denbite! - Consolidate@near-js/*packages into a singlenear-api-jscodebase -
#1795
b96c604Thanks @denbite! - RenovateProvider.queryby removing the deprecated inline-argument overload and fully aligning the method with the nearcore RPC API spec.Previously supported (no longer works):
provider.query("view_account", JSON.stringify({ ... }));
New required usage (fully typed):
provider.query({ request_type: "view_account", ... });
Once
request_typeis specified, remaining parameters are inferred automatically by the IDE. -
#1668
20672fbThanks @denbite! - Remove deprecated functionality -
#1813
858783cThanks @gagdiez! - Renamed actionCreator helper object to simply "actions", and separated the helper addKey into addFullAccessKey and addFunctionCallKey -
#1589
5cfdab8Thanks @AlexKushnir1! - Refactor the abstract classSignerto implement every method, except forgetPublicKeyandsignBytes, which are intended for users
Minor Changes
-
#1790
2f7a30dThanks @denbite! - Introduce many specific errors based on generated response types from OpenAPI spec and which are thrown when callingProvider.sendJsonRpcmethod -
#1798
a52592bThanks @gagdiez! - Added a new multi-key signer which handles multiples keys and transparently rotates them as users ask to sign transactions -
#1751
85f279eThanks @denbite! - Addnep413module that implementssignMessageandverifyMessagefunctions -
#1748
917cceaThanks @denbite! - MakeAccountto takeKeyPairStringas third parameter -
#1761
9d8799bThanks @denbite! - IntroduceteraToGasandgigaToGashelper functions to convertGasamounts conviniently -
#1761
fcbb1feThanks @denbite! - IntroduceyoctoToNearandnearToYoctohelper functions -
#1796
c2601e2Thanks @denbite! - Add a newProvider.viewGlobalContractCodemethod for retrieving global contract code using either acodeHash, or anaccountIdidentifier.Example usage:
provider.viewGlobalContractCode({ identifier: { accountId: "global_contract.near" }, }); provider.viewGlobalContractCode({ identifier: { codeHash: "J1arLz48fgXcGyCPVckFwLnewNH6j1uw79thsvwqGYTY" }, });
-
#1799
a7c3cd9Thanks @denbite! - AddparseSeedPhrasemethod, exported via theseed-phrasesub-path, which converts a string seed phrase into aKeyPair.For example:
import { parseSeedPhrase } from "near-api-js/seed-phrase"; const keyPair = parseSeedPhrase("tag interest match ..."); keyPair.getPublicKey().toString(); // ed25519:9uMmkWHW... keyPair.toString(); // ed25519:3N6TYZVRrkQxh...
-
#1747
493d9e5Thanks @denbite! - Add sub-path exports for "tokens", "tokens/mainnet" and "tokens/testnet" to improve tree-shaking -
#1794
7b6ff4fThanks @denbite! - Extend theAccountconstructor to accept an RPC URL string in addition to aProvider, making account instantiation simpler and more ergonomic.New supported usage:
new Account("user.near", "https://rpc.testnet.near.org");
Previously, users had to always manually create a provider:
const provider = new JsonRpcProvider({ url: "https://rpc.testnet.near.org" }); new Account("user.near", provider);
-
#1803
9f3e14dThanks @denbite! - Export strongly typed RPC error classes behind therpc-errorssub-path, for end users to reliably handle specific RPC failures.For example, end users can now catch action-level errors (e.g. when a transaction fails because the recipient account does not exist):
import { AccountDoesNotExistActionError } from "near-api-js/rpc-errors"; try { await account.transfer({ amount: nearToYocto(0.01), receiverId: "unexisted_account_111.testnet", }); } catch (error) { if (error instanceof AccountDoesNotExistActionError) { console.error( `Transaction ${error.txHash} failed because recipient ${error.accountId} does not exist!` ); } }
Or, RPC request validation and parsing errors can also be handled explicitly (e.g. when an invalid account ID format is included in a transaction):
import { RpcRequestParseError } from "near-api-js/rpc-errors"; try { await account.transfer({ amount: nearToYocto(0.001), receiverId: "account_name_that_fail_validation%.testnet", }); } catch (error) {...
[email protected]
Patch Changes
-
#1662
aad9fd6Thanks @denbite! - Add duplicate ofkeyToImplicitAddressto@near-js/cryptoto prevent cycle dependency between packages -
#1663
8e9a81bThanks @denbite! - Remove a redundantassertcall in@near-js/providers -
#1661
5375dccThanks @denbite! - Add@near-js/keystoresas dependency to@near-js/accounts, not as dev-dep -
Updated dependencies [
aad9fd6,8e9a81b,5375dcc]:- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
- @near-js/[email protected]
@near-js/[email protected]
Patch Changes
-
#1662
aad9fd6Thanks @denbite! - Add duplicate ofkeyToImplicitAddressto@near-js/cryptoto prevent cycle dependency between packages -
Updated dependencies []:
- @near-js/[email protected]