@@ -12,7 +12,7 @@ async function main() {
1212 const NFT_ADDRESS = deploymentsNFT . address
1313 const network = hre . network . name
1414
15- // Setup provider and signer for target chain
15+ // Setup provider and signer
1616 const provider = new ethers . JsonRpcProvider ( getRpcUrl ( network ) )
1717 const signer = new ethers . Wallet ( process . env . SIGNER_PRIVATE_KEY , provider )
1818
@@ -21,20 +21,7 @@ async function main() {
2121
2222 const nft = NFT__factory . connect ( NFT_ADDRESS , signer )
2323
24- // Get current nonce state on target chain
25- const OPERATION_TYPE = 0 // MINT operation
26- const proofSlot = ethers . keccak256 (
27- ethers . solidityPacked (
28- [ "uint8" , "uint256" ] ,
29- [ OPERATION_TYPE , 0 ] // mapping key and base slot
30- )
31- )
32- const nonceData = await provider . getStorage ( nft . target , proofSlot )
33- const currentNonce = parseInt ( nonceData , 16 )
34- console . log ( "\nCurrent nonce on target chain:" , currentNonce )
35- const nextNonce = currentNonce + 1
36-
37- // Load proofs from file
24+ // Load proof from file
3825 const proofsPath = path . resolve ( __dirname , "../proofs.json" )
3926 if ( ! fs . existsSync ( proofsPath ) ) {
4027 throw new Error (
@@ -43,24 +30,8 @@ async function main() {
4330 }
4431 const proofs = JSON . parse ( fs . readFileSync ( proofsPath , "utf8" ) )
4532
46- // Check which tokens already exist on target chain
47- const existingTokens = new Set ( )
48- for ( const proof of proofs ) {
49- try {
50- const owner = await nft . ownerOf ( proof . tokenId )
51- existingTokens . add ( proof . tokenId )
52- console . log (
53- `Token ${ proof . tokenId } already exists, owned by ${ owner } `
54- )
55- } catch ( e ) {
56- // Token doesn't exist
57- }
58- }
59-
60- // Claim tokens that don't exist yet
33+ // Try to claim each proof
6134 for ( const proof of proofs ) {
62- if ( existingTokens . has ( proof . tokenId ) ) continue
63-
6435 console . log ( `\nClaiming token ${ proof . tokenId } ...` )
6536 try {
6637 // Simulate first
@@ -89,39 +60,28 @@ async function main() {
8960 } catch ( error : any ) {
9061 console . error ( `\nFailed to claim token ${ proof . tokenId } :` )
9162 if ( error . data ) {
92- const decodedError = nft . interface . parseError ( error . data )
93- console . error ( "Error reason:" , decodedError ?. args [ 0 ] )
94- } else {
95- console . error ( error )
63+ try {
64+ const decodedError = nft . interface . parseError ( error . data )
65+ console . error ( "Error reason:" , decodedError )
66+ } catch ( e ) {
67+ console . error ( error )
68+ }
9669 }
9770 }
9871 }
9972}
10073
74+ // Helper to get RPC URL
10175function getRpcUrl ( network : string ) : string {
10276 switch ( network ) {
10377 case "opSepolia" :
104- if ( ! process . env . OP_SEPOLIA_RPC_ENDPOINT_URL ) {
105- throw new Error ( "OP_SEPOLIA_RPC_ENDPOINT_URL not set in .env" )
106- }
107- return process . env . OP_SEPOLIA_RPC_ENDPOINT_URL
78+ return process . env . OP_SEPOLIA_RPC_ENDPOINT_URL || ""
10879 case "baseSepolia" :
109- if ( ! process . env . BASE_SEPOLIA_RPC_ENDPOINT_URL ) {
110- throw new Error ( "BASE_SEPOLIA_RPC_ENDPOINT_URL not set in .env" )
111- }
112- return process . env . BASE_SEPOLIA_RPC_ENDPOINT_URL
80+ return process . env . BASE_SEPOLIA_RPC_ENDPOINT_URL || ""
11381 case "arbitrumSepolia" :
114- if ( ! process . env . ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL ) {
115- throw new Error (
116- "ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL not set in .env"
117- )
118- }
119- return process . env . ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL
82+ return process . env . ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL || ""
12083 case "sepolia" :
121- if ( ! process . env . SEPOLIA_RPC_ENDPOINT_URL ) {
122- throw new Error ( "SEPOLIA_RPC_ENDPOINT_URL not set in .env" )
123- }
124- return process . env . SEPOLIA_RPC_ENDPOINT_URL
84+ return process . env . SEPOLIA_RPC_ENDPOINT_URL || ""
12585 default :
12686 throw new Error ( `Unsupported network: ${ network } ` )
12787 }
0 commit comments