Skip to content

Commit

Permalink
cli: bypass aptos simulation in devnet
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Dec 13, 2024
1 parent ead139c commit 685a157
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions clients/js/src/aptos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,24 @@ export async function callEntryFunc(
);

// simulate transaction before submitting
const sim = await client.simulateTransaction(accountFrom, rawTxn);
sim.forEach((tx) => {
if (!tx.success) {
console.error(JSON.stringify(tx, null, 2));
throw new Error(`Transaction failed: ${tx.vm_status}`);
}
});
if (network !== "Devnet") {
// TODO: determine why simulation is no longer working for devnet after 4.5.0 upgrade
const sim = await client.simulateTransaction(accountFrom, rawTxn);
sim.forEach((tx) => {
if (!tx.success) {
console.error(JSON.stringify(tx, null, 2));
throw new Error(`Transaction failed: ${tx.vm_status}`);
}
});
}

// simulation successful... let's do it
const bcsTxn = AptosClient.generateBCSTransaction(accountFrom, rawTxn);
const transactionRes = await client.submitSignedBCSTransaction(bcsTxn);

await client.waitForTransaction(transactionRes.hash);
await client.waitForTransaction(transactionRes.hash, {
checkSuccess: true,
});
return transactionRes.hash;
}

Expand Down

0 comments on commit 685a157

Please sign in to comment.