UNPKG

web3-api-utils

Version:

utility funtions to get api names for different api providers

53 lines (47 loc) 2.51 kB
// import { expect, assert } from "cha import { getChainsArray, getApiSlug, getChainData, getChainId, getChainBySlug, getChainByChainId, lookupIdBySlug , getWebsiteItemUrl, getWebsiteContractUrl } from '../main.mjs'; const doChainIds = false; const doWebsiteUrls = true // async function getData(id){ // const result = await getChainByChainId(id) // console.log('result', result) // } if(doChainIds){ console.log('****** EXAMPLE CHAIN ID CALLS ******') // console.log('slug, rarible, undefined', getChainsArray('slug', 'rarible', undefined)) // console.log('slug, rarible, true', getChainsArray('slug', 'rarible', true)) // console.log('id, rarible, true', getChainsArray('id', 'rarible', true)) // console.log('object, rarible, true', getChainsArray('object', 'rarible', true)) // console.log('getApiSlug 137, rarible, false', getApiSlug(11155420, 'rarible', undefined)) // console.log('getApiSlug 137, alchemy, false', getApiSlug(137, 'alchemy', false)) console.log('getChainId (base)', getChainId('base')) console.log('getChainId (BASE)', getChainId('BASE')) // console.log('getChainId (sepolia)', getChainId('sepolia')) // console.log('getChainId (SEPOLIA)', getChainId('SEPOLIA')) // console.log('getChainId (137)', getChainId('137')) console.log('getChainIdBySlug', getChainBySlug('sepolia')) // console.log('getChainIdByChainId', getChainByChainId(137)) // console.log('getChainIdByChainId', getChainByChainId(11155420)) // console.log('getChainData', getChainData(137)) // console.log('lookupIdBySlug', lookupIdBySlug('POLYGON', 'rarible', true)) // console.log('lookupIdBySlug', lookupIdBySlug('BASE', 'rarible', true)) // getData(1) } if(doWebsiteUrls){ console.log('should be : ') console.log('https://testnet.rarible.com/collection/base/0xaDe9A2129398518697207c1ec222Bb8d4Bcb5f8D') console.log('getWebsiteContractUrl, ', getWebsiteContractUrl({apiName: "rarible", chainId: 84532, contractAddress: "0xaDe9A2129398518697207c1ec222Bb8d4Bcb5f8D"})); console.log('getWebsiteContractUrl, ', getWebsiteContractUrl({apiName: "opensea", chainId: 84532, contractAddress: "0xaDe9A2129398518697207c1ec222Bb8d4Bcb5f8D"})); console.log('getWebsiteItemUrl, ', getWebsiteItemUrl({apiName: "rarible", chainId: 84532, contractAddress: "0xaDe9A2129398518697207c1ec222Bb8d4Bcb5f8D", tokenId: 3})); console.log('getWebsiteItemUrl, ', getWebsiteItemUrl({apiName: "opensea", chainId: 84532, contractAddress: "0xaDe9A2129398518697207c1ec222Bb8d4Bcb5f8D", tokenId: 3})); }