Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/(app)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const isValidPublicKey = async (multisigString: string) => {
const connection = new Connection(rpcUrl || clusterApiUrl("mainnet-beta"));
await multisig.accounts.Multisig.fromAccountAddress(
connection,
multisigPubkey
multisigPubkey,
);
return true;
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion components/CreateTransactionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const CreateTransaction = ({
),
}),
],
payerKey: vaultAddress,
payerKey: wallet.publicKey as PublicKey,
recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
});

Expand Down
44 changes: 39 additions & 5 deletions components/ExecuteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ const ExecuteButton = ({
}

const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: priorityFeeLamports,
microLamports: priorityFeeLamports > 0 ? priorityFeeLamports : 1,
});
const computeUnitInstruction = ComputeBudgetProgram.setComputeUnitLimit({
units: computeUnitBudget,
units: computeUnitBudget > 0 ? computeUnitBudget : 200_000,
});

let blockhash = (await connection.getLatestBlockhash()).blockhash;
Expand All @@ -147,15 +147,49 @@ const ExecuteButton = ({

const execTx = new VersionedTransaction(executeMessage);

const signature = await wallet.sendTransaction(execTx, connection, {
try {
const { value } = await connection.simulateTransaction(execTx, {
commitment: "confirmed",
sigVerify: false,
});

console.info("Simulation result:", value);
} catch (error) {
console.error(error);
}

if (!wallet.signTransaction) {
throw new Error("Wallet does not support signing transactions");
}

const signed = await wallet.signTransaction?.(execTx);

if (!signed) {
throw new Error("Failed to sign transaction");
}

const signature = await connection.sendTransaction(signed, {
skipPreflight: true,
});
console.log("Transaction signature", signature);
toast.loading("Confirming...", {
id: "transaction",
});
await connection.getSignatureStatuses([signature]);
await new Promise((resolve) => setTimeout(resolve, 1000));

let sent = false;
const maxAttempts = 15;
const delayMs = 1500;

for (let attempt = 0; attempt <= maxAttempts && !sent; attempt++) {
const status = await connection.getSignatureStatus(signature);
if (status?.value?.confirmationStatus === "confirmed") {
await new Promise((resolve) => setTimeout(resolve, delayMs));
sent = true;
} else {
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
}

router.refresh();
};
return (
Expand Down