@xyo-network/crypto-nft-collection-witness-plugin 2.80.5 → 2.81.0

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.
Files changed (55) hide show
  1. package/dist/browser/Plugin.d.cts +1 -1
  2. package/dist/browser/Plugin.d.mts +1 -1
  3. package/dist/browser/Plugin.d.ts +1 -1
  4. package/dist/browser/index.cjs +15 -14
  5. package/dist/browser/index.cjs.map +1 -1
  6. package/dist/browser/index.js +16 -15
  7. package/dist/browser/index.js.map +1 -1
  8. package/dist/browser/lib/contractHasFunctions.d.cts +1 -2
  9. package/dist/browser/lib/contractHasFunctions.d.cts.map +1 -1
  10. package/dist/browser/lib/contractHasFunctions.d.mts +1 -2
  11. package/dist/browser/lib/contractHasFunctions.d.mts.map +1 -1
  12. package/dist/browser/lib/contractHasFunctions.d.ts +1 -2
  13. package/dist/browser/lib/contractHasFunctions.d.ts.map +1 -1
  14. package/dist/browser/lib/getNftCollectionNfts.d.cts +2 -2
  15. package/dist/browser/lib/getNftCollectionNfts.d.cts.map +1 -1
  16. package/dist/browser/lib/getNftCollectionNfts.d.mts +2 -2
  17. package/dist/browser/lib/getNftCollectionNfts.d.mts.map +1 -1
  18. package/dist/browser/lib/getNftCollectionNfts.d.ts +2 -2
  19. package/dist/browser/lib/getNftCollectionNfts.d.ts.map +1 -1
  20. package/dist/browser/lib/tokenTypes.d.cts +1 -1
  21. package/dist/browser/lib/tokenTypes.d.cts.map +1 -1
  22. package/dist/browser/lib/tokenTypes.d.mts +1 -1
  23. package/dist/browser/lib/tokenTypes.d.mts.map +1 -1
  24. package/dist/browser/lib/tokenTypes.d.ts +1 -1
  25. package/dist/browser/lib/tokenTypes.d.ts.map +1 -1
  26. package/dist/node/Plugin.d.cts +1 -1
  27. package/dist/node/Plugin.d.mts +1 -1
  28. package/dist/node/Plugin.d.ts +1 -1
  29. package/dist/node/index.js +16 -14
  30. package/dist/node/index.js.map +1 -1
  31. package/dist/node/index.mjs +17 -15
  32. package/dist/node/index.mjs.map +1 -1
  33. package/dist/node/lib/contractHasFunctions.d.cts +1 -2
  34. package/dist/node/lib/contractHasFunctions.d.cts.map +1 -1
  35. package/dist/node/lib/contractHasFunctions.d.mts +1 -2
  36. package/dist/node/lib/contractHasFunctions.d.mts.map +1 -1
  37. package/dist/node/lib/contractHasFunctions.d.ts +1 -2
  38. package/dist/node/lib/contractHasFunctions.d.ts.map +1 -1
  39. package/dist/node/lib/getNftCollectionNfts.d.cts +2 -2
  40. package/dist/node/lib/getNftCollectionNfts.d.cts.map +1 -1
  41. package/dist/node/lib/getNftCollectionNfts.d.mts +2 -2
  42. package/dist/node/lib/getNftCollectionNfts.d.mts.map +1 -1
  43. package/dist/node/lib/getNftCollectionNfts.d.ts +2 -2
  44. package/dist/node/lib/getNftCollectionNfts.d.ts.map +1 -1
  45. package/dist/node/lib/tokenTypes.d.cts +1 -1
  46. package/dist/node/lib/tokenTypes.d.cts.map +1 -1
  47. package/dist/node/lib/tokenTypes.d.mts +1 -1
  48. package/dist/node/lib/tokenTypes.d.mts.map +1 -1
  49. package/dist/node/lib/tokenTypes.d.ts +1 -1
  50. package/dist/node/lib/tokenTypes.d.ts.map +1 -1
  51. package/package.json +13 -15
  52. package/src/Witness.ts +2 -2
  53. package/src/lib/contractHasFunctions.ts +4 -4
  54. package/src/lib/getNftCollectionNfts.ts +7 -7
  55. package/src/lib/tokenTypes.ts +3 -3
package/src/Witness.ts CHANGED
@@ -58,7 +58,7 @@ export class CryptoNftCollectionWitness<
58
58
  const [name, symbol, total, typesSettled, archivistSettled] = await Promise.allSettled([
59
59
  await erc721Enumerable.name(),
60
60
  await erc721Enumerable.symbol(),
61
- (await erc721Enumerable.totalSupply()).toNumber(),
61
+ await erc721Enumerable.totalSupply(),
62
62
  await tokenTypes(provider, address),
63
63
  await this.writeArchivist(),
64
64
  ])
@@ -80,7 +80,7 @@ export class CryptoNftCollectionWitness<
80
80
  schema: NftCollectionSchema,
81
81
  sources,
82
82
  symbol: resolvedValue(symbol, true),
83
- total: resolvedValue(total, true),
83
+ total: Number(resolvedValue(total, true)),
84
84
  type: types.at(0),
85
85
  types,
86
86
  }
@@ -1,12 +1,12 @@
1
- import { Interface } from '@ethersproject/abi'
2
- import { Provider } from '@ethersproject/providers'
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
- const nameSig = contractInterface.getSighash(functionNames[i]).substring(2)
9
- if (!bytecode.includes(nameSig)) {
8
+ const selector = assertEx(contractInterface.getFunction(functionNames[i])?.selector, 'Function not found on interface')
9
+ if (!bytecode.includes(selector.substring(2))) {
10
10
  return false
11
11
  }
12
12
  return true
@@ -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: BaseProvider,
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 () => (await enumerable.tokenByIndex(i, { blockTag: block })).toHexString())) ?? `${i}`
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 () => (await supply1155.totalSupply(tokenId, { blockTag: block })).toHexString())) ?? '0x01'
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.network.chainId,
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
  }
@@ -1,6 +1,6 @@
1
- import { Provider } from '@ethersproject/providers'
2
1
  import { TokenType } from '@xyo-network/crypto-nft-payload-plugin'
3
- import { ERC1155URIStorage__factory, IERC721Metadata__factory } from '@xyo-network/open-zeppelin-typechain'
2
+ import { ERC721__factory, ERC1155URIStorage__factory } from '@xyo-network/open-zeppelin-typechain'
3
+ import { Provider } from 'ethers'
4
4
 
5
5
  import { contractHasFunctions } from './contractHasFunctions'
6
6
 
@@ -9,7 +9,7 @@ export const isErc1155 = async (provider: Provider, address: string) => {
9
9
  }
10
10
 
11
11
  export const isErc721 = async (provider: Provider, address: string) => {
12
- return await contractHasFunctions(provider, address, IERC721Metadata__factory.createInterface(), ['name', 'symbol', 'tokenURI'])
12
+ return await contractHasFunctions(provider, address, ERC721__factory.createInterface(), ['name', 'symbol', 'tokenURI'])
13
13
  }
14
14
 
15
15
  export const tokenTypes = async (provider: Provider, address: string) => {