@xyo-network/crypto-nft-collection-witness-plugin 2.80.5 → 2.81.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/Plugin.d.cts +1 -1
- package/dist/browser/Plugin.d.mts +1 -1
- package/dist/browser/Plugin.d.ts +1 -1
- package/dist/browser/index.cjs +14 -12
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +14 -12
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/lib/contractHasFunctions.d.cts +1 -2
- package/dist/browser/lib/contractHasFunctions.d.cts.map +1 -1
- package/dist/browser/lib/contractHasFunctions.d.mts +1 -2
- package/dist/browser/lib/contractHasFunctions.d.mts.map +1 -1
- package/dist/browser/lib/contractHasFunctions.d.ts +1 -2
- package/dist/browser/lib/contractHasFunctions.d.ts.map +1 -1
- package/dist/browser/lib/getNftCollectionNfts.d.cts +2 -2
- package/dist/browser/lib/getNftCollectionNfts.d.cts.map +1 -1
- package/dist/browser/lib/getNftCollectionNfts.d.mts +2 -2
- package/dist/browser/lib/getNftCollectionNfts.d.mts.map +1 -1
- package/dist/browser/lib/getNftCollectionNfts.d.ts +2 -2
- package/dist/browser/lib/getNftCollectionNfts.d.ts.map +1 -1
- package/dist/browser/lib/tokenTypes.d.cts +1 -1
- package/dist/browser/lib/tokenTypes.d.cts.map +1 -1
- package/dist/browser/lib/tokenTypes.d.mts +1 -1
- package/dist/browser/lib/tokenTypes.d.mts.map +1 -1
- package/dist/browser/lib/tokenTypes.d.ts +1 -1
- package/dist/browser/lib/tokenTypes.d.ts.map +1 -1
- package/dist/node/Plugin.d.cts +1 -1
- package/dist/node/Plugin.d.mts +1 -1
- package/dist/node/Plugin.d.ts +1 -1
- package/dist/node/index.js +15 -12
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +15 -12
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/lib/contractHasFunctions.d.cts +1 -2
- package/dist/node/lib/contractHasFunctions.d.cts.map +1 -1
- package/dist/node/lib/contractHasFunctions.d.mts +1 -2
- package/dist/node/lib/contractHasFunctions.d.mts.map +1 -1
- package/dist/node/lib/contractHasFunctions.d.ts +1 -2
- package/dist/node/lib/contractHasFunctions.d.ts.map +1 -1
- package/dist/node/lib/getNftCollectionNfts.d.cts +2 -2
- package/dist/node/lib/getNftCollectionNfts.d.cts.map +1 -1
- package/dist/node/lib/getNftCollectionNfts.d.mts +2 -2
- package/dist/node/lib/getNftCollectionNfts.d.mts.map +1 -1
- package/dist/node/lib/getNftCollectionNfts.d.ts +2 -2
- package/dist/node/lib/getNftCollectionNfts.d.ts.map +1 -1
- package/dist/node/lib/tokenTypes.d.cts +1 -1
- package/dist/node/lib/tokenTypes.d.cts.map +1 -1
- package/dist/node/lib/tokenTypes.d.mts +1 -1
- package/dist/node/lib/tokenTypes.d.mts.map +1 -1
- package/dist/node/lib/tokenTypes.d.ts +1 -1
- package/dist/node/lib/tokenTypes.d.ts.map +1 -1
- package/package.json +14 -15
- package/src/Witness.ts +2 -2
- package/src/lib/contractHasFunctions.ts +4 -3
- package/src/lib/getNftCollectionNfts.ts +7 -7
- package/src/lib/tokenTypes.ts +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Provider } from '
|
|
1
|
+
import { assertEx } from '@xylabs/assert'
|
|
2
|
+
import { Interface, Provider } from 'ethers'
|
|
3
3
|
|
|
4
4
|
export const contractHasFunctions = async (provider: Provider, address: string, contractInterface: Interface, functionNames: string[]) => {
|
|
5
5
|
try {
|
|
6
6
|
const bytecode = await provider.getCode(address, 'latest')
|
|
7
7
|
for (let i = 0; i < functionNames.length; i++) {
|
|
8
|
-
|
|
8
|
+
contractInterface.getAbiCoder().encode
|
|
9
|
+
const nameSig = assertEx(contractInterface.getFunction(functionNames[i])?.selector, 'Function not found on interface')
|
|
9
10
|
if (!bytecode.includes(nameSig)) {
|
|
10
11
|
return false
|
|
11
12
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BaseProvider } from '@ethersproject/providers'
|
|
2
1
|
import { AxiosJson } from '@xylabs/axios'
|
|
3
2
|
import { BigNumber as XyBigNumber } from '@xylabs/bignumber'
|
|
4
3
|
import { exists } from '@xylabs/exists'
|
|
@@ -7,6 +6,7 @@ import { getErc1967Status } from '@xyo-network/blockchain-erc1967-witness'
|
|
|
7
6
|
import { NftInfo, NftMetadata, NftSchema, TokenType, toTokenType } from '@xyo-network/crypto-nft-payload-plugin'
|
|
8
7
|
import { ERC721Enumerable__factory, ERC721URIStorage__factory, ERC1155Supply__factory } from '@xyo-network/open-zeppelin-typechain'
|
|
9
8
|
import { checkIpfsUrl } from '@xyo-network/witness-blockchain-abstract'
|
|
9
|
+
import { Provider } from 'ethers'
|
|
10
10
|
|
|
11
11
|
import { tokenTypes } from './tokenTypes'
|
|
12
12
|
import { tryCall } from './tryCall'
|
|
@@ -33,7 +33,7 @@ export const getNftCollectionNfts = async (
|
|
|
33
33
|
/**
|
|
34
34
|
* The chain ID (1 = Ethereum Mainnet, 4 = Rinkeby, etc.) of the chain to search for NFTs on
|
|
35
35
|
*/
|
|
36
|
-
provider:
|
|
36
|
+
provider: Provider,
|
|
37
37
|
types?: TokenType[],
|
|
38
38
|
/**
|
|
39
39
|
* The maximum number of NFTs to return. Configurable to prevent
|
|
@@ -64,10 +64,10 @@ export const getNftCollectionNfts = async (
|
|
|
64
64
|
const result: NftInfo[] = (
|
|
65
65
|
await Promise.all(
|
|
66
66
|
maxNftsArray.map(async (_value, i) => {
|
|
67
|
-
const tokenId = (await tryCall(async () =>
|
|
67
|
+
const tokenId = (await tryCall(async () => await enumerable.tokenByIndex(i, { blockTag: block }))) ?? BigInt(i)
|
|
68
68
|
if (tokenId !== undefined) {
|
|
69
69
|
const supply = finalTypes.includes(toTokenType('ERC1155'))
|
|
70
|
-
? (await tryCall(async () =>
|
|
70
|
+
? (await tryCall(async () => await supply1155['totalSupply(uint256)'](tokenId))) ?? '0x01'
|
|
71
71
|
: '0x01'
|
|
72
72
|
const metadataUri = await tryCall(async () => await storage.tokenURI(tokenId, { blockTag: block }))
|
|
73
73
|
const checkedMetaDataUri = metadataUri ? checkIpfsUrl(metadataUri, ipfsGateway) : undefined
|
|
@@ -83,12 +83,12 @@ export const getNftCollectionNfts = async (
|
|
|
83
83
|
|
|
84
84
|
const info: NftInfo = {
|
|
85
85
|
address: contractAddress,
|
|
86
|
-
chainId: provider.
|
|
86
|
+
chainId: Number((await provider.getNetwork()).chainId),
|
|
87
87
|
metadata,
|
|
88
88
|
metadataUri,
|
|
89
89
|
schema: NftSchema,
|
|
90
|
-
supply
|
|
91
|
-
tokenId
|
|
90
|
+
supply: `0x${supply.toString(16)}`,
|
|
91
|
+
tokenId: `0x${tokenId.toString(16)}`,
|
|
92
92
|
type: finalTypes.at(0),
|
|
93
93
|
types: finalTypes,
|
|
94
94
|
}
|
package/src/lib/tokenTypes.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Provider } from '@ethersproject/providers'
|
|
2
1
|
import { TokenType } from '@xyo-network/crypto-nft-payload-plugin'
|
|
3
2
|
import { ERC1155URIStorage__factory, IERC721Metadata__factory } from '@xyo-network/open-zeppelin-typechain'
|
|
3
|
+
import { Provider } from 'ethers'
|
|
4
4
|
|
|
5
5
|
import { contractHasFunctions } from './contractHasFunctions'
|
|
6
6
|
|