Skip to content

Releases: wpdas/naxios

v2.2.3

11 Oct 16:34
Compare
Choose a tag to compare
  • update naxios.walletSelectorModules type to support the new wallet selector core function

v2.2.2

11 Oct 16:24
Compare
Choose a tag to compare
  • fix the StorageCache reference path;
  • fix walletApi method's type

v2.2.1

11 Oct 14:47
Compare
Choose a tag to compare
  • update near-wallet-selector core, modal-ui, my-near-wallet to version 8.9.13;
  • update near-api-js to version 5.0.1.

These changes were made to support @near-wallet-selector/ethereum-wallets

v2.2.0

12 Aug 19:30
63823dd
Compare
Choose a tag to compare

Example of usage:

import naxios, { isClient } from "@wpdas/naxios";

const naxiosInstance = new naxios({
  contractId: CONTRACT_ID,
  network: 'mainnet',
});

/**
 * NEAR RPC API
 */
const rpcApi = naxiosInstance.rpcApi();

rpcApi
    .query({
      request_type: "view_account",
      finality: "final",
      account_id: "wendersonpires.near",
    })
    .then((data) => console.log("Account data:", data))
    .catch((err) => console.log(err));

v2.1.1

29 Jul 21:18
6e272e3
Compare
Choose a tag to compare
  • Ensure Naxios runs on the client side only - 6e272e3

v2.1.0

25 Apr 17:49
292a990
Compare
Choose a tag to compare

v2.0.1

09 Feb 06:21
Compare
Choose a tag to compare

v2.0.0

09 Feb 06:11
Compare
Choose a tag to compare

v1.4.1

07 Feb 02:47
Compare
Choose a tag to compare
  • fix: additional args key removed from view method
  • fix: validateNearAddress issue with validation
  • tests added
  • new feature: auto cache clean-up

v1.4.0

06 Feb 14:57
Compare
Choose a tag to compare
  • feature: Cache System

Cache System

There are two kinds of cache systems to be used. They are Memory Cache and Storage Cache.

Memory Cache: will be cleared when the app refreshes, as its data lives in memory only.
Storage Cache: The data will remain even when the browser tab is refreshed. Data is persisted using Local Storage.

When instantiating a cache, you need to provide the expirationTime (in seconds). This is used to know when the cache should be returned instead of making a real contract call. When the cache expires, a real call to the contract is made. Each contract's method has its own time of expiration.

// web3Api.ts with cache
import naxios, { StorageCache } from '@wpdas/naxios'

const naxiosInstance = new naxios({
  contractId: CONTRACT_ID,
  network: 'testnet',
  cache: new StorageCache({ expirationTime: 60 }),
})

export const contractApi = naxiosInstance.contractApi()

Then, to use cached view, you can just pass the configuration object saying you want to use cached data.

import { contractApi } from './web3Api'

const args: {}
const config: { useCache: true }

contractApi.view('get_greeting', args, config).then((response) => console.log(response))