From a48cf217a190b43074d8efb7b92e0255c95147dc Mon Sep 17 00:00:00 2001 From: Dong-Ha Kim Date: Thu, 26 Dec 2024 15:31:43 +0100 Subject: [PATCH] fix: local signer strategy --- api/relay/_strategies/local-signers.ts | 9 +++------ scripts/tests/swap-permit.ts | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/api/relay/_strategies/local-signers.ts b/api/relay/_strategies/local-signers.ts index 1bda8caa7..d230783a0 100644 --- a/api/relay/_strategies/local-signers.ts +++ b/api/relay/_strategies/local-signers.ts @@ -23,10 +23,8 @@ export function getLocalSignersStrategy(): RelayStrategy { } for (const signerPrivateKey of localSignerPrivateKeys) { - const wallet = new Wallet( - signerPrivateKey, - getProvider(request.chainId) - ); + const provider = getProvider(request.chainId); + const wallet = new Wallet(signerPrivateKey, provider); try { await lockSigner(wallet.address, request.chainId); @@ -36,12 +34,11 @@ export function getLocalSignersStrategy(): RelayStrategy { } const txRequest = { + chainId: request.chainId, to: request.to, data: encodedCalldata, from: wallet.address, }; - await wallet.estimateGas(txRequest); - const tx = await wallet.sendTransaction(txRequest); const receipt = await tx.wait(); return receipt.transactionHash; diff --git a/scripts/tests/swap-permit.ts b/scripts/tests/swap-permit.ts index ecc9a9ea3..ab052e48e 100644 --- a/scripts/tests/swap-permit.ts +++ b/scripts/tests/swap-permit.ts @@ -13,12 +13,6 @@ async function swapWithPermit() { getProvider(swapQuote.swapTx.chainId) ); - console.log("EIP712 Permit:", swapQuote.eip712.permit); - console.log( - "EIP712 Deposit:", - swapQuote.eip712.deposit.message.submissionFees - ); - // sign permit + deposit const permitSig = await wallet._signTypedData( swapQuote.eip712.permit.domain, @@ -40,6 +34,20 @@ async function swapWithPermit() { signatures: { permit: permitSig, deposit: depositSig }, }); console.log("Relay response:", relayResponse.data); + + // track relay + while (true) { + const relayStatusResponse = await axios.get( + `${SWAP_API_BASE_URL}/api/relay/status?requestHash=${relayResponse.data.requestHash}` + ); + console.log("Relay status response:", relayStatusResponse.data); + + if (relayStatusResponse.data.status === "success") { + break; + } + + await new Promise((resolve) => setTimeout(resolve, 1_000)); + } } }