From 2bb7181f647e67fc709e93b055eda412fdebc9f0 Mon Sep 17 00:00:00 2001 From: AdriGeorge Date: Tue, 29 Sep 2026 10:26:43 +0300 Subject: [PATCH] Refactor ERC-1271 validation --- src/components/core/utils/nonceHandler.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/core/utils/nonceHandler.ts b/src/components/core/utils/nonceHandler.ts index 816215671..ac8e954b2 100644 --- a/src/components/core/utils/nonceHandler.ts +++ b/src/components/core/utils/nonceHandler.ts @@ -284,13 +284,15 @@ async function verifySignatureForConsumer( // Continue to smart account check } - // Try ERC-1271 (smart account) validation - try { - const targetChainId = chainId || Object.keys(config?.supportedNetworks || {})[0] - if (targetChainId && config?.supportedNetworks?.[targetChainId]) { - const provider = new ethers.JsonRpcProvider( - config.supportedNetworks[targetChainId].rpc - ) + // An explicit chain restricts validation; otherwise try every configured network. + const targetChainIds = chainId + ? [chainId] + : Object.keys(config?.supportedNetworks || {}) + for (const targetChainId of targetChainIds) { + const network = config?.supportedNetworks?.[targetChainId] + if (!network) continue + try { + const provider = new ethers.JsonRpcProvider(network.rpc) // Try custom hash format (for backward compatibility) if (await isERC1271Valid(consumer, consumerMessage, signature, provider)) { @@ -302,9 +304,9 @@ async function verifySignatureForConsumer( if (await isERC1271Valid(consumer, eip191Hash, signature, provider)) { return true } + } catch (error) { + CORE_LOGGER.error(`ERC-1271 signature validation error: ${error?.message}`) } - } catch (error) { - CORE_LOGGER.error(`ERC-1271 signature validation error: ${error?.message}`) } return false