1.1.1 • Published 6 months ago

deployless-view v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

deployless-view

  • package name: deployless-view
  • build: yarn build

Install

npm i deployless-view

Usage

batchGetAllTokensByOwner

Specific use case for multicall.

The method batchGetAllTokensByOwner is just a wrapper for method multicall which calls DeploylessNFTViewer with easy interface.

nftType

1: ERC721Enumerable

2: CryptoPunks

3: ERC721 without ERC721Enumerable(rare case)

const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");

const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"

async function main () {
  const provider = new ethers.providers.JsonRpcProvider(rpc);
  let d = new DeploylessViewerClient(provider)
  let ret = await d.batchGetAllTokensByOwner('0x7a9fe22691c811ea339d9b73150e6911a5343dca', [
    {
      nftType: 2,
      nft: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb'
    }, {
      nftType: 1,
      nft: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d'
    }])
  console.log(`ret:`, ret)
}

main()

getTokensByOwnerInRange

Get the id owned by the user in the specified token id range.

const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");

const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"

async function main () {
  const provider = new ethers.providers.JsonRpcProvider(rpc);
  let d = new DeploylessViewerClient(provider)
  let ret = await d.getTokensByOwnerInRange(
    '0x7a9fe22691c811ea339d9b73150e6911a5343dca',   // owner
    "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb",   // nft address
    2,                                              // nftType
    1000,                                           // start id
    2000                                            // count or step (excluded)
  )
  console.log(`ret:`, ret)
}

main()

getAllTokensByOwner

const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");

const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"

async function main () {
  const provider = new ethers.providers.JsonRpcProvider(rpc);
  let d = new DeploylessViewerClient(provider)
  let ret = await d.getAllTokensByOwner(
    '0x7a9fe22691c811ea339d9b73150e6911a5343dca',   // owner
    "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb",   // nft address
    2,                                              // nftType
    2000                                            // step
  )
  console.log(`ret:`, ret)
}

main()

getUserTimeLocks

const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");

const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"

async function main () {
  const provider = new ethers.providers.JsonRpcProvider(rpc);
  let d = new DeploylessViewerClient(provider)
  let ret = await d.getUserTimeLocks(
    'timelock address',   // timelock contract address
    "user address",       // user address
    50,                   // The maximum number of requests in a single request. default and max:50
    2000                  // The minimum timelock agreement start id
  )
  console.log(`ret:`, ret)
}

main()

multicall

Accept an array of calls and call them all at once.

If 0x0 is passed as address to call, DeploylessNFTViewer will be called instead.

const {
  DeploylessViewerClient,
  NFTEnumerable__factory,
} = require('deployless-view')
const { ethers } = require('ethers')

const rpc = 'https://mainnet.infura.io/v3/af88d7776e3f4e1888ac935b9b16effd'

async function main () {
  const provider = new ethers.providers.JsonRpcProvider(rpc)
  let d = new DeploylessViewerClient(provider)
  let ret = await d.multicall([
    {
      target: ethers.constants.AddressZero,
      callData: d.deploylessNFTViewer.interface.encodeFunctionData('batchGetAllTokensByOwner', [
        '0x7a9fe22691c811ea339d9b73150e6911a5343dca', [
          {
            nftType: 2,
            nft: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb',
          }, {
            nftType: 1,
            nft: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
          }]]),
    },
    {
      target: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
      callData: NFTEnumerable__factory.createInterface()
        .encodeFunctionData('tokenURI', [999]),
    },
  ])
  let { blockNumber, resultsArray: [ret1, ret2] } = ret
  let ret1Value = d.deploylessNFTViewer.interface.decodeFunctionResult('batchGetAllTokensByOwner', ret1)
  let ret2Value = NFTEnumerable__factory.createInterface()
    .decodeFunctionResult('tokenURI', ret2)
  console.log(`ret1Value:`, ret1Value)
  console.log(`ret2Value:`, ret2Value)
}

main()
1.1.1

6 months ago

1.0.19

10 months ago

1.1.0

8 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.26

9 months ago

1.0.25

9 months ago

1.0.24

9 months ago

1.0.23

9 months ago

1.0.27

8 months ago

1.0.18

11 months ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.0

2 years ago