Skip to content

Releases: wpdas/naxios

v1.3.0

04 Feb 01:21
Compare
Choose a tag to compare

Wallet API Reference [New Feature]

  • accountId: Main/first signed-in account ID in the accounts list.

Utils [New Features]

buildTransaction

The buildTransaction method is useful when you need to build a contract's Transaction body, mainly when you want to make multiple contract calls. E.g.:

import { buildTransaction } from '@wpdas/naxios'
import { contractApi } from './web3Api'

// Using the default instance's contract
const transactionA = buildTransaction('set_greeting', { args: { greeting: 'Hello my dear!' } })
const transactionB = buildTransaction('set_age', { args: { age: 22 } })
// Using diff contract
const transactionC = buildTransaction('update_state', {
  receiverId: 'my-state-contract.testnet',
  args: { allowed: true },
})

// Optional
const callbackUrl = 'https://my-page.com/callback-success'

// [payable]
contractApi.callMultiple([transactionA, transactionB, transactionC], callbackUrl).then(() => console.log('Done!'))

validateNearAddress

This is used to check if an address is a valid NEAR address.

import { validateNearAddress } from '@wpdas/naxios'

console.log(validateNearAddress('fake.near')) // true
console.log(validateNearAddress('fake.nears')) // false
console.log(validateNearAddress('fake.testnet')) // true
console.log(validateNearAddress('fake')) // false

calculateDepositByDataSize

Calculate required deposit for data being stored. (~0.00001N per byte) with a bit extra for buffer

import { calculateDepositByDataSize } from '@wpdas/naxios'

const myData = { age: 22, name: 'user name' }
console.log(calculateDepositByDataSize(myData)) // 0.00087 Near (not yocto NEAR)

v1.2.1

02 Feb 02:37
Compare
Choose a tag to compare
  • fix args type for Transaction type

v1.2.0

02 Feb 02:10
Compare
Choose a tag to compare
  • added contract.callMultiple(...) feature: Call multiple methods that changes the contract s state

As well as the call, you will need to pay for every request you make. This is going to change data and store it within the blockchain.

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

const contractApi = new naxios({
  contractId: CONTRACT_ID,
  network: "testnet",
}).contractApi();

// Using the default instance's contract
const transactionA = buildTransaction('set_greeting', { args: { greeting: 'Hello my dear!' } })
const transactionB = buildTransaction('set_age', { args: { age: 22 } })
// Using diff contract
const transactionC = buildTransaction('update_state', {
  receiverId: 'my-state-contract.testnet',
  args: { allowed: true },
})

// Optional
const callbackUrl = 'https://my-page.com/callback-success'

// [payable]
contractApi.callMultiple([transactionA, transactionB, transactionC], callbackUrl).then(() => console.log('Done!'))

v1.1.1

24 Jan 01:58
Compare
Choose a tag to compare
  • insert callbackUrl for contractApi.call(...)

v1.1.0

12 Jan 03:15
Compare
Choose a tag to compare
  • Added getContractApi and getWalletApi features

Invoking a Contract / Wallet API anytime with different setup:

// Invoking a Contract API
import { getContractApi } from '@wpdas/naxios'

// New contract instance
const contract = await getContractApi({
  contractId: ANOTHER_CONTRACT_ID,
  network: 'testnet',
})

const response = await contract.view('get_users', {
  args: { limit: 5 },
})
// Invoking a Wallet API
import { getWalletApi } from '@wpdas/naxios'

// New wallet instance
const walletApi = await getWalletApi({
  contractId: ANOTHER_CONTRACT_ID,
  network: 'testnet',
})

// Open up the Signin Wallet Modal
walletApi.signInModal()

v1.0.2

11 Jan 13:45
Compare
Choose a tag to compare
  • Fix issue with wallet icons
  • Fix module path

v1.0.1

11 Jan 13:21
Compare
Choose a tag to compare
  • Fix main directory path

v1.0.0

11 Jan 13:12
Compare
Choose a tag to compare

First stable version.

v0.1.2

09 Jan 05:54
Compare
Choose a tag to compare
  • Fix issue with package.json where the type was not module;
  • @near-wallet-selector/modal-ui/styles.css should not be imported by the lib;
  • readme update.

v0.1.1

09 Jan 05:29
Compare
Choose a tag to compare
  • Small fixes