@@ -1307,6 +1307,16 @@ async function lookupByTxHash() {
13071307 const data = await response . json ( ) ;
13081308
13091309 if ( data . messages && data . messages . length > 0 ) {
1310+ // Auto-detect destination chain from first result
1311+ const firstMsg = data . messages [ 0 ] ;
1312+ const destDomain = firstMsg . destinationDomain ?? firstMsg . destination ?. domain ;
1313+ if ( destDomain !== undefined ) {
1314+ const chainKey = DOMAIN_TO_CHAIN [ destDomain ] ;
1315+ if ( chainKey ) {
1316+ log ( `Detected destination: ${ getDestChainLabel ( chainKey ) } (domain ${ destDomain } )` , 'info' ) ;
1317+ setDestChain ( chainKey ) ;
1318+ }
1319+ }
13101320 displayLookupResults ( data . messages , 'tx' ) ;
13111321 } else {
13121322 showNoResults ( 'No CCTP transfer found for this transaction hash.' ) ;
@@ -1320,17 +1330,17 @@ async function lookupByTxHash() {
13201330async function lookupByAddress ( ) {
13211331 const address = elements . lookupAddress ?. value . trim ( ) ;
13221332 if ( ! address ) {
1323- log ( 'Please enter a Solana address' , 'warning' ) ;
1333+ log ( 'Please enter a destination address' , 'warning' ) ;
13241334 return ;
13251335 }
13261336
13271337 log ( `Searching pending transfers for: ${ address . slice ( 0 , 8 ) } ...` , 'info' ) ;
13281338 showLookupLoading ( ) ;
13291339
13301340 try {
1331- // Query Circle's CCTP API for pending messages to this address
1332- const destDomain = selectedDestChain === 'base' ? 6 : 5 ;
1333- const response = await fetch ( `${ CCTP_LOOKUP_API } ?destinationDomain= ${ destDomain } &status=pending ` ) ;
1341+ // Circle's API supports sourceDomain + recipient filtering
1342+ // Source is always Noble (domain 4)
1343+ const response = await fetch ( `${ CCTP_LOOKUP_API } ?sourceDomain=4 ` ) ;
13341344
13351345 if ( ! response . ok ) {
13361346 throw new Error ( `API returned ${ response . status } ` ) ;
@@ -1339,38 +1349,40 @@ async function lookupByAddress() {
13391349 const data = await response . json ( ) ;
13401350
13411351 if ( data . messages && data . messages . length > 0 ) {
1342- // Filter for messages going to this address (if the API returns all pending)
1343- // The API might already filter, but we double-check
1352+ // Filter for messages going to this address
13441353 const relevantMessages = data . messages . filter ( msg => {
1345- // Try to match the mint recipient (base64 encoded Solana address)
13461354 try {
1355+ // Check the mint recipient field
13471356 const mintRecipient = msg . message ?. mintRecipient ;
1348- if ( mintRecipient ) {
1349- const decoded = atob ( mintRecipient ) ;
1350- // Compare with Solana address bytes
1351- return decoded . includes ( address ) || mintRecipient === address ;
1357+ if ( ! mintRecipient ) return false ;
1358+
1359+ // For EVM addresses (0x...), compare against the hex-encoded recipient
1360+ if ( address . startsWith ( '0x' ) ) {
1361+ const addrLower = address . toLowerCase ( ) . replace ( / ^ 0 x / , '' ) ;
1362+ // mintRecipient is 32-byte hex; EVM address is in the last 20 bytes
1363+ const recipientHex = mintRecipient . replace ( / ^ 0 x / , '' ) . toLowerCase ( ) ;
1364+ return recipientHex . endsWith ( addrLower ) ;
13521365 }
1366+
1367+ // For Solana addresses (base58), compare via base64 decoded bytes
1368+ const decoded = atob ( mintRecipient ) ;
1369+ return decoded . includes ( address ) || mintRecipient === address ;
13531370 } catch ( e ) {
1354- // Ignore decode errors
1371+ return false ;
13551372 }
1356- return false ;
13571373 } ) ;
13581374
13591375 if ( relevantMessages . length > 0 ) {
13601376 displayLookupResults ( relevantMessages , 'address' ) ;
1361- } else if ( data . messages . length > 0 ) {
1362- // Show all pending if we can't filter
1363- displayLookupResults ( data . messages . slice ( 0 , 10 ) , 'address' ) ;
1364- log ( 'Showing recent pending transfers. Click one to auto-fill.' , 'info' ) ;
13651377 } else {
1366- showNoResults ( 'No pending transfers found.' ) ;
1378+ showNoResults ( 'No CCTP transfers found for this address. Try searching by Noble tx hash instead .' ) ;
13671379 }
13681380 } else {
1369- showNoResults ( 'No pending CCTP transfers found for this address .' ) ;
1381+ showNoResults ( 'No recent CCTP transfers found from Noble .' ) ;
13701382 }
13711383 } catch ( error ) {
13721384 log ( `Lookup failed: ${ error . message } ` , 'error' ) ;
1373- showNoResults ( `Error: ${ error . message } ` ) ;
1385+ showNoResults ( `Error: ${ error . message } . Try searching by Noble tx hash instead. ` ) ;
13741386 }
13751387}
13761388
@@ -1399,11 +1411,15 @@ function displayLookupResults(messages, searchType) {
13991411 const statusLabel = status === 'complete' ? 'Ready to relay' :
14001412 status === 'pending_confirmations' ? 'Awaiting attestation' : status ;
14011413
1414+ const destDomain = msg . destinationDomain ?? msg . destination ?. domain ;
1415+ const destChainKey = destDomain !== undefined ? DOMAIN_TO_CHAIN [ destDomain ] : null ;
1416+ const destLabel = destChainKey ? getDestChainLabel ( destChainKey ) : `Domain ${ destDomain ?? '?' } ` ;
1417+
14021418 return `
14031419 <div class="lookup-result-item" onclick="selectLookupResult('${ txHash } ', ${ JSON . stringify ( msg ) . replace ( / ' / g, "\\'" ) } )">
14041420 <div class="tx-hash">${ txHash . slice ( 0 , 20 ) } ...${ txHash . slice ( - 8 ) } </div>
14051421 <div class="tx-details">
1406- ${ amount } USDC
1422+ ${ amount } USDC → ${ destLabel }
14071423 <span class="tx-status ${ statusClass } ">${ statusLabel } </span>
14081424 </div>
14091425 </div>
@@ -1427,6 +1443,16 @@ function selectLookupResult(txHash, msgData) {
14271443
14281444 // If we have message data, try to pre-fill
14291445 if ( msgData ) {
1446+ // Auto-detect destination chain from API response
1447+ const destDomain = msgData . destinationDomain ?? msgData . destination ?. domain ;
1448+ if ( destDomain !== undefined ) {
1449+ const chainKey = DOMAIN_TO_CHAIN [ destDomain ] ;
1450+ if ( chainKey ) {
1451+ log ( `Detected destination: ${ getDestChainLabel ( chainKey ) } (domain ${ destDomain } )` , 'info' ) ;
1452+ setDestChain ( chainKey ) ;
1453+ }
1454+ }
1455+
14301456 // If attestation is complete, we might have the attestation
14311457 if ( msgData . attestation && elements . attestation ) {
14321458 elements . attestation . value = msgData . attestation ;
@@ -1435,7 +1461,6 @@ function selectLookupResult(txHash, msgData) {
14351461
14361462 // Try to extract message hex
14371463 if ( msgData . message && elements . messageHex ) {
1438- // The API might return the message in different formats
14391464 const messageBytes = msgData . messageBytes || msgData . message ;
14401465 if ( typeof messageBytes === 'string' && messageBytes . startsWith ( '0x' ) ) {
14411466 elements . messageHex . value = messageBytes ;
@@ -2595,9 +2620,9 @@ if (sections.relay) sections.relay.classList.add('card-collapsed');
25952620// Initialize button states
25962621updatePhantomButtonText ( ) ;
25972622
2598- // Initialize destination chain from relay dropdown (default: solana )
2623+ // Initialize destination chain visibility (default to Solana section visible, heading stays generic )
25992624if ( elements . relayDestChain ) {
2600- setDestChain ( elements . relayDestChain . value ) ;
2625+ selectedDestChain = elements . relayDestChain . value ;
26012626}
26022627
26032628log ( 'CCTP Relayer initialized. Use the lookup above or paste a Noble tx hash to begin.' , 'info' ) ;
0 commit comments