Skip to content

feat: support signing multiple transactions without reload #16

@mablr

Description

@mablr

forge script support enabled by #15 and foundry-rs/foundry#12952 is great! However, now the current limiting factor is the webapp UX when signing multiple transactions. After signing a transaction, the app displays the receipt and requires a page reload and wallet reconnection to sign the next tx request generated by the script.

I guess the root cause is that pendingTx state persists after a successful signature/send

// Sign and send the current pending transaction.
const signAndSendCurrentTx = async () => {
if (!selected || !pendingTx?.request) return;
const walletClient = createWalletClient({
transport: custom(selected.provider),
chain: chain ?? undefined,
});
try {
const hash = (await selected.provider.request({
method: "eth_sendTransaction",
params: [pendingTx.request],
})) as `0x${string}`;
setLastTxHash(hash);
await api("/api/transaction/response", "POST", { id: pendingTx.id, hash, error: null });
const receipt = await waitForTransactionReceipt(walletClient, { hash });
setLastTxReceipt(receipt);
} catch (e: unknown) {
const msg =
typeof e === "object" &&
e &&
"message" in e &&
typeof (e as { message?: unknown }).message === "string"
? (e as { message: string }).message
: String(e);
console.error("send failed:", msg);
try {
await api("/api/transaction/response", "POST", {
id: pendingTx.id,
hash: null,
error: msg,
});
} catch {}
}
};

which prevents the polling from restarting. I think we need a way to clear completed request and resume polling for the next request.

I would be happy to contribute, lmk wdyt!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions