diff --git a/README.md b/README.md index f41ee925e..58830c48c 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,11 @@ A complete suite of Flair reusable components and clients for frontend and backe ## Packages -| Name | Description | -| :----------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | -| [@flair-sdk/react](./packages/react) | React hooks and components for features like Wallet, NFT Collections, Token Streams, etc. (browser only) | -| [@flair-sdk/metatx](./packages/metatx) | Extension to ether.js `Contract` classm to make all functions compatible with native meta transactions standard. (node.js and browser) | -| [@flair-sdk/registry](./packages/registry) | Compiled registry of Flair contract ABIs, bytecodes, addresses, and metadata for easy usage. (node.js and browser) | -| [@flair-sdk/ipfs](./packages/ipfs) | Utility functions to interact with IPFS, useful for NFT metadata storage. (node.js and browser) | +| Name | Description | +| :------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [@flair-sdk/react](./packages/react) | React hooks and components for features like Wallet, NFT Collections, Token Streams, etc. (browser only) | +| [@flair-sdk/metatx](./packages/metatx) | Extension to ether.js `Contract` class to make all functions compatible with native meta transactions standard ([ERC 2771](https://eips.ethereum.org/EIPS/eip-2771)). (node.js and browser) | +| [@flair-sdk/ipfs](./packages/ipfs) | Utility functions to interact with IPFS, useful for NFT metadata storage. (node.js and browser) | ## Documentation diff --git a/packages/metatx/README.md b/packages/metatx/README.md index 6159a234e..67b614a08 100644 --- a/packages/metatx/README.md +++ b/packages/metatx/README.md @@ -1,9 +1,13 @@ # `@flair-sdk/metatx` -A typescript (and Node.js) library to help construct and submit meta transactions using Flair's forwarder contracts. +A typescript (and Node.js) library to help construct and submit ([EIP-2771](https://eips.ethereum.org/EIPS/eip-2771)) meta transactions using Flair's forwarder contracts. ## Getting Started +#### Requirements + +Your contracts need to have ERC-2771 support. [Flair](https://flair.dev) provides out-of-box support based on OpenZeppelin's ERC2771Context for contracts deployed. + ### Installation Install the package using NPM or Yarn: diff --git a/packages/react/src/common/hooks/useContractRead.ts b/packages/react/src/common/hooks/useContractRead.ts index 08e0576ab..73cedb259 100644 --- a/packages/react/src/common/hooks/useContractRead.ts +++ b/packages/react/src/common/hooks/useContractRead.ts @@ -56,10 +56,20 @@ export const useContractRead = ({ enabled && contractAddress && contractAddress !== ZERO_ADDRESS, ); + const finalContractInterface = useMemo( + () => + contractDefinition?.artifact?.abi || + contractInterface || [ + `function ${ + functionName.endsWith(')') ? functionName : `${functionName}()` + } view`, + ], + [contractDefinition?.artifact?.abi, contractInterface, functionName], + ); + const result = useContractReadWagmi({ addressOrName: contractAddress as string, - contractInterface: contractDefinition?.artifact?.abi || - contractInterface || [`function ${functionName}`], + contractInterface: finalContractInterface, functionName, args, enabled: readyToRead, @@ -78,15 +88,10 @@ export const useContractRead = ({ return new ethers.Contract( contractAddress, - contractDefinition?.artifact?.abi || ['function ' + functionName], + finalContractInterface, provider, ); - }, [ - contractAddress, - contractDefinition?.artifact?.abi, - functionName, - provider, - ]); + }, [contractAddress, finalContractInterface, provider]); const call = useCallback( async (overrides?: { args?: ArgsType }) => { diff --git a/packages/react/src/modules/finance/tiered-sales/hooks/useTieredSalesWalletMints.ts b/packages/react/src/modules/finance/tiered-sales/hooks/useTieredSalesWalletMints.ts index 4d0f2620c..df7a050db 100644 --- a/packages/react/src/modules/finance/tiered-sales/hooks/useTieredSalesWalletMints.ts +++ b/packages/react/src/modules/finance/tiered-sales/hooks/useTieredSalesWalletMints.ts @@ -22,7 +22,7 @@ export const useTieredSalesWalletMints = ({ contractInterface: [ 'function walletMintedByTier(uint256 tierId, address wallet) external view returns (uint256)', ], - functionName: 'walletMintedByTier(uint256)', + functionName: 'walletMintedByTier(uint256,address)', chainId, contractAddress, args: [tierId, walletAddress] as ArgsType,