Skip to content
Merged
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
3 changes: 2 additions & 1 deletion clients/js/src/estimateComputeLimitInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Commitment,
compileTransaction,
getBase64EncodedWireTransaction,
getSolanaErrorFromTransactionError,
isSolanaError,
isTransactionMessageWithDurableNonceLifetime,
pipe,
Expand Down Expand Up @@ -158,7 +159,7 @@ async function simulateTransactionAndGetConsumedUnits({
const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);
if (transactionError) {
throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {
cause: transactionError,
cause: getSolanaErrorFromTransactionError(transactionError),
unitsConsumed: downcastUnitsConsumed,
});
}
Expand Down
5 changes: 3 additions & 2 deletions clients/js/test/estimateComputeLimitInternal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SOLANA_ERROR__INSTRUCTION_ERROR__INSUFFICIENT_FUNDS,
SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,
SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,
SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND,
SolanaError,
TransactionError,
TransactionMessageWithFeePayer,
Expand Down Expand Up @@ -235,7 +236,7 @@ describe('estimateComputeUnitLimit', () => {
await expect(estimatePromise).resolves.toBe(1400000);
});

it('throws with the transaction error as cause when the transaction fails in simulation', async () => {
it('throws with the transaction SolanaError as cause when the transaction fails in simulation', async () => {
expect.assertions(1);
const transactionError: TransactionError = 'AccountNotFound';
sendSimulateTransactionRequest.mockResolvedValue({
Expand All @@ -249,7 +250,7 @@ describe('estimateComputeUnitLimit', () => {

await expect(estimatePromise).rejects.toThrow(
new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {
cause: transactionError,
cause: new SolanaError(SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND),
unitsConsumed: 42,
}),
);
Expand Down