Skip to content

Releases: near/near-api-js

v7.2.0

Choose a tag to compare

@github-actions github-actions released this 08 Mar 13:06
caba323

Minor Changes

  • #1877 eb345df Thanks @mikedotexe! - Replace Buffer usage with Uint8Array and Web Standard APIs (TextEncoder/TextDecoder, @scure/base) for CommonJS compatibility

  • #1872 dd086d4 Thanks @gagdiez! - Added a signer that knows how to use the legacy keystore

  • #1877 eb345df Thanks @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

Choose a tag to compare

@github-actions github-actions released this 13 Feb 21:36
c655916

Patch Changes

v7.1.0

Choose a tag to compare

@github-actions github-actions released this 04 Feb 13:36
2ec404d

Minor Changes

v7.0.4

Choose a tag to compare

@github-actions github-actions released this 25 Jan 16:59
30d06b3

Patch Changes

v7.0.3

Choose a tag to compare

@github-actions github-actions released this 22 Jan 17:43
4b316b3

Patch Changes

v7.0.2

Choose a tag to compare

@github-actions github-actions released this 22 Jan 13:31
9e825ea

Patch Changes

v7.0.1

Choose a tag to compare

@github-actions github-actions released this 21 Jan 19:34
69c8ce1

Patch Changes

  • #1822 8493b36 Thanks @denbite! - Explicitly declare the return type of Account.signAndSendTransaction so it doesn't fallback to any

  • #1819 e6f4db2 Thanks @gagdiez! - Correctly expose the new Actions interface, which simplify creating actions, and hide the old Action class, 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 different Actions.

  • #1818 a82e47f Thanks @denbite! - Attach finalized blockHash to transaction created using Account.createTransaction to prevent TransactionExpiredError errors.

    Previously, transactions could be created with a blockHash that had not yet fully propagated across the network. In some cases, receiver RPC nodes were unable to look up the referenced block, resulting in TransactionExpiredError failures (often due to a small propagation delay of a few milliseconds).

v7.0.0

Choose a tag to compare

@github-actions github-actions released this 19 Jan 16:59
d108352

Major Changes

  • #1691 f8666a0 Thanks @r-near! - Update parseNearAmount to only accept either a numeric string, or actual number, and not undefined, as well as throw error rather than silently return null

  • #1691 f8666a0 Thanks @r-near! - Rename stable viewValidatorsV2 function back to viewValidators

  • #1809 eee87c2 Thanks @gagdiez! - Consolidate functionality of the @near-js/* packages into a single, tree-shakeable near-api-js package

  • #1805 9356419 Thanks @denbite! - Remove no longer needed error utils like getErrorTypeFromErrorMessage, 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 from rpc-errors sub-path

  • #1781 1caddf4 Thanks @denbite! - Replace TypedError class with a few specific errors created from fully type-safe RPC interfaces

  • #1808 bf7c148 Thanks @denbite! - Rename TypedContract back to Contract

  • #1669 683e1db Thanks @denbite! - Remove no longer maintained packages @near-js/iframe-rpc, @near-js/biometric-ed25519 and @near-js/client with @near-js/cookbook examples

  • #1670 54e4d48 Thanks @denbite! - Remove no longer maintained packages @near-js/keystores, @near-js/keystores-node and @near-js/keystores-browser

  • #1673 5d86344 Thanks @denbite! - Consolidate @near-js/* packages into a single near-api-js codebase

  • #1795 b96c604 Thanks @denbite! - Renovate Provider.query by 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_type is specified, remaining parameters are inferred automatically by the IDE.

  • #1668 20672fb Thanks @denbite! - Remove deprecated functionality

  • #1813 858783c Thanks @gagdiez! - Renamed actionCreator helper object to simply "actions", and separated the helper addKey into addFullAccessKey and addFunctionCallKey

  • #1589 5cfdab8 Thanks @AlexKushnir1! - Refactor the abstract class Signer to implement every method, except for getPublicKey and signBytes, which are intended for users

Minor Changes

  • #1790 2f7a30d Thanks @denbite! - Introduce many specific errors based on generated response types from OpenAPI spec and which are thrown when calling Provider.sendJsonRpc method

  • #1798 a52592b Thanks @gagdiez! - Added a new multi-key signer which handles multiples keys and transparently rotates them as users ask to sign transactions

  • #1751 85f279e Thanks @denbite! - Add nep413 module that implements signMessage and verifyMessage functions

  • #1748 917ccea Thanks @denbite! - Make Account to take KeyPairString as third parameter

  • #1761 9d8799b Thanks @denbite! - Introduce teraToGas and gigaToGas helper functions to convert Gas amounts conviniently

  • #1761 fcbb1fe Thanks @denbite! - Introduce yoctoToNear and nearToYocto helper functions

  • #1796 c2601e2 Thanks @denbite! - Add a new Provider.viewGlobalContractCode method for retrieving global contract code using either a codeHash, or an accountId identifier.

    Example usage:

    provider.viewGlobalContractCode({
      identifier: { accountId: "global_contract.near" },
    });
    provider.viewGlobalContractCode({
      identifier: { codeHash: "J1arLz48fgXcGyCPVckFwLnewNH6j1uw79thsvwqGYTY" },
    });
  • #1799 a7c3cd9 Thanks @denbite! - Add parseSeedPhrase method, exported via the seed-phrase sub-path, which converts a string seed phrase into a KeyPair.

    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 493d9e5 Thanks @denbite! - Add sub-path exports for "tokens", "tokens/mainnet" and "tokens/testnet" to improve tree-shaking

  • #1794 7b6ff4f Thanks @denbite! - Extend the Account constructor to accept an RPC URL string in addition to a Provider, 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 9f3e14d Thanks @denbite! - Export strongly typed RPC error classes behind the rpc-errors sub-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) {...
Read more

[email protected]

Choose a tag to compare

@github-actions github-actions released this 06 Nov 14:11
345de7c

Patch Changes

@near-js/[email protected]

Choose a tag to compare

@github-actions github-actions released this 06 Nov 14:11
345de7c

Patch Changes