Skip to content

Commit

Permalink
fix: local signer strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki committed Dec 26, 2024
1 parent fb3d672 commit a48cf21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
9 changes: 3 additions & 6 deletions api/relay/_strategies/local-signers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down
20 changes: 14 additions & 6 deletions scripts/tests/swap-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));
}
}
}

Expand Down

0 comments on commit a48cf21

Please sign in to comment.