Releases: wpdas/naxios
Releases · wpdas/naxios
v2.2.3
v2.2.2
v2.2.1
v2.2.0
- Added NEAR RPC API Provider. Now it's possible to use the same Naxios setup to use NEAR RPC API. NEAR RPC Docs can be visited here: https://docs.near.org/api/rpc/introduction
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
v2.1.0
v2.0.1
v2.0.0
v1.4.1
v1.4.0
- 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))