@@ -34,7 +34,7 @@ import {
3434 validateParameters ,
3535 getClientForChain ,
3636} from "@/registry/mini-app/blocks/nft-mint-flow/lib/provider-detector" ;
37- import { getChainById } from "@/registry/mini-app/lib/chains" ;
37+ import { getChainById , findChainByName } from "@/registry/mini-app/lib/chains" ;
3838import { getProviderConfig } from "@/registry/mini-app/blocks/nft-mint-flow/lib/provider-configs" ;
3939import { fetchPriceData } from "@/registry/mini-app/blocks/nft-mint-flow/lib/price-optimizer" ;
4040import {
@@ -52,36 +52,27 @@ import {
5252 * NFTMintButton - Universal NFT minting button with automatic provider detection and ERC20 approval handling
5353 *
5454 * The button automatically detects the NFT provider (Manifold, OpenSea, Zora, etc.) by analyzing
55- * the contract. You only need to specify the provider if auto-detection fails or you want to
56- * override the detection.
55+ * the contract. Provider detection is fully automatic - no need to specify the provider manually.
5756 *
5857 * @example
5958 * ```tsx
6059 * // Basic mint - auto-detects provider and handles everything
6160 * <NFTMintButton
6261 * contractAddress="0x5b97886E4e1fC0F7d19146DEC03C917994b3c3a4"
63- * chainId={1}
62+ * network="ethereum"
6463 * />
6564 *
6665 * // Manifold NFT - auto-detected, just provide the required params
6766 * <NFTMintButton
6867 * contractAddress="0x32dd0a7190b5bba94549a0d04659a9258f5b1387"
69- * chainId={8453}
68+ * network="base"
7069 * manifoldParams={{ instanceId: "4293509360" }}
7170 * />
7271 *
73- * // Force specific provider (only if auto-detection is wrong)
74- * <NFTMintButton
75- * contractAddress="0x..."
76- * chainId={8453}
77- * forceProvider="manifold"
78- * manifoldParams={{ instanceId: "123" }}
79- * />
80- *
8172 * // Multiple NFTs with success callback
8273 * <NFTMintButton
8374 * contractAddress="0x..."
84- * chainId={8453}
75+ * network="base"
8576 * amount={5}
8677 * buttonText="Mint 5 NFTs"
8778 * onMintSuccess={(txHash) => console.log("Minted!", txHash)}
@@ -96,25 +87,11 @@ type NFTMintFlowProps = {
9687 contractAddress : Address ;
9788
9889 /**
99- * Blockchain network ID
100- * Supports any valid chain ID
101- */
102- chainId : number ;
103-
104- /**
105- * Force a specific NFT provider instead of auto-detection
106- *
107- * By default, the component auto-detects the provider by analyzing the contract.
108- * Only use this prop if:
109- * - Auto-detection is returning the wrong provider
110- * - You need to test a specific provider's flow
111- * - The contract has non-standard implementation
112- *
113- * Note: "generic" is not an option here - it's used internally as a fallback.
114- *
115- * @default undefined (auto-detect)
90+ * Blockchain network name (e.g., "ethereum", "base", "arbitrum", "optimism", "polygon", "zora")
91+ * This matches the network prop used by NFTCard for consistency.
92+ * @default "ethereum"
11693 */
117- forceProvider ?: "manifold" | "opensea" | "zora" ;
94+ network ?: string ;
11895
11996 /**
12097 * Number of NFTs to mint. Defaults to 1.
@@ -125,8 +102,8 @@ type NFTMintFlowProps = {
125102 /**
126103 * Manifold-specific parameters
127104 *
128- * Required when minting Manifold NFTs (auto-detected or forced) .
129- * The component will show an error if these are missing for Manifold contracts .
105+ * These are auto-detected when possible, but can be provided if known .
106+ * The component will show helpful error messages if required params are missing.
130107 *
131108 * @example
132109 * // For claim-based mints (most common)
@@ -176,8 +153,7 @@ type NFTMintFlowProps = {
176153
177154export function NFTMintButton ( {
178155 contractAddress,
179- chainId,
180- forceProvider,
156+ network = "ethereum" ,
181157 amount = 1 ,
182158 manifoldParams,
183159 className,
@@ -194,32 +170,26 @@ export function NFTMintButton({
194170 null ,
195171 ) ;
196172
197- // Prop validation with helpful errors
198- React . useEffect ( ( ) => {
199- if (
200- forceProvider === "manifold" &&
201- ! manifoldParams ?. instanceId &&
202- ! manifoldParams ?. tokenId
203- ) {
204- console . error (
205- "NFTMintButton: When forceProvider=\"manifold\", you must provide manifoldParams with either instanceId or tokenId. " +
206- "Example: manifoldParams={{ instanceId: \"4293509360\" }}" ,
207- ) ;
173+ // Convert network name to chainId
174+ const chain = React . useMemo ( ( ) => {
175+ const foundChain = findChainByName ( network ) ;
176+ if ( ! foundChain ) {
177+ console . warn ( `NFTMintButton: Network "${ network } " not recognized, defaulting to Ethereum mainnet` ) ;
178+ return getChainById ( 1 ) ; // Default to Ethereum mainnet
208179 }
180+ return foundChain ;
181+ } , [ network ] ) ;
209182
210- if ( manifoldParams && forceProvider && forceProvider !== "manifold" ) {
211- console . warn (
212- "NFTMintButton: manifoldParams provided but forceProvider is not \"manifold\". " +
213- "These params will be ignored for non-Manifold providers." ,
214- ) ;
215- }
183+ const chainId = chain . id ;
216184
185+ // Prop validation with helpful errors
186+ React . useEffect ( ( ) => {
217187 if ( ! contractAddress || ! contractAddress . match ( / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / ) ) {
218188 console . error (
219189 "NFTMintButton: Invalid contract address. Must be a valid Ethereum address (0x...)" ,
220190 ) ;
221191 }
222- } , [ forceProvider , manifoldParams , chainId , contractAddress ] ) ;
192+ } , [ contractAddress ] ) ;
223193
224194 // Destructure commonly used values
225195 const {
@@ -250,13 +220,13 @@ export function NFTMintButton({
250220 ( ) => ( {
251221 contractAddress,
252222 chainId,
253- provider : forceProvider ,
223+ provider : undefined , // Let auto-detection handle this
254224 amount,
255225 instanceId : manifoldParams ?. instanceId ,
256226 tokenId : manifoldParams ?. tokenId ,
257227 recipient : address ,
258228 } ) ,
259- [ contractAddress , chainId , forceProvider , amount , manifoldParams , address ] ,
229+ [ contractAddress , chainId , amount , manifoldParams , address ] ,
260230 ) ;
261231
262232 // Watch for transaction completion
@@ -1069,13 +1039,13 @@ NFTMintButton.presets = {
10691039 * ```tsx
10701040 * <NFTMintButton {...NFTMintButton.presets.auto({
10711041 * contractAddress: "0x5b97886E4e1fC0F7d19146DEC03C917994b3c3a4",
1072- * chainId: 1
1042+ * network: "ethereum"
10731043 * })} />
10741044 * ```
10751045 */
10761046 auto : ( props : {
10771047 contractAddress : Address ;
1078- chainId : number ;
1048+ network : string ;
10791049 amount ?: number ;
10801050 buttonText ?: string ;
10811051 manifoldParams ?: { instanceId ?: string ; tokenId ?: string } ;
@@ -1092,14 +1062,14 @@ NFTMintButton.presets = {
10921062 * ```tsx
10931063 * <NFTMintButton {...NFTMintButton.presets.manifold({
10941064 * contractAddress: "0x32dd0a7190b5bba94549a0d04659a9258f5b1387",
1095- * chainId: 8453 ,
1065+ * network: "base" ,
10961066 * instanceId: "4293509360"
10971067 * })} />
10981068 * ```
10991069 */
11001070 manifold : ( props : {
11011071 contractAddress : Address ;
1102- chainId : number ;
1072+ network : string ;
11031073 instanceId : string ;
11041074 tokenId ?: string ;
11051075 amount ?: number ;
@@ -1108,8 +1078,7 @@ NFTMintButton.presets = {
11081078 onMintError ?: ( error : string ) => void ;
11091079 } ) : NFTMintFlowProps => ( {
11101080 contractAddress : props . contractAddress ,
1111- chainId : props . chainId ,
1112- forceProvider : "manifold" ,
1081+ network : props . network ,
11131082 manifoldParams : {
11141083 instanceId : props . instanceId ,
11151084 tokenId : props . tokenId ,
@@ -1119,35 +1088,4 @@ NFTMintButton.presets = {
11191088 onMintSuccess : props . onMintSuccess ,
11201089 onMintError : props . onMintError ,
11211090 } ) ,
1122-
1123- /**
1124- * Force a specific provider (only use if auto-detection fails)
1125- * @example
1126- * ```tsx
1127- * <NFTMintButton {...NFTMintButton.presets.forceProvider({
1128- * contractAddress: "0x...",
1129- * chainId: 8453,
1130- * provider: "opensea"
1131- * })} />
1132- * ```
1133- */
1134- forceProvider : ( props : {
1135- contractAddress : Address ;
1136- chainId : number ;
1137- provider : "manifold" | "opensea" | "zora" ;
1138- amount ?: number ;
1139- buttonText ?: string ;
1140- manifoldParams ?: { instanceId ?: string ; tokenId ?: string } ;
1141- onMintSuccess ?: ( txHash : string ) => void ;
1142- onMintError ?: ( error : string ) => void ;
1143- } ) : NFTMintFlowProps => ( {
1144- contractAddress : props . contractAddress ,
1145- chainId : props . chainId ,
1146- forceProvider : props . provider ,
1147- amount : props . amount || 1 ,
1148- buttonText : props . buttonText ,
1149- manifoldParams : props . manifoldParams ,
1150- onMintSuccess : props . onMintSuccess ,
1151- onMintError : props . onMintError ,
1152- } ) ,
11531091} ;
0 commit comments