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
6 changes: 6 additions & 0 deletions .changeset/moody-masks-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@solana/rpc-types': major
'@solana/errors': major
---

`BorshIoErrors` from the RPC no longer contain an `encodedData` property. This property used to hold the underlying error from the serialization library used on the server. This message was always subject to changes in the version of that library, or changes in the choice of library itself. New versions of the server no longer throw the underlying error, so for consistency it has been removed everywhere in Kit.
4 changes: 2 additions & 2 deletions packages/errors/src/__tests__/instruction-error-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const EXPECTED_ERROR_CODES = [
['ProgramFailedToCompile', 4615042],
['Immutable', 4615043],
['IncorrectAuthority', 4615044],
['BorshIoError', 4615045],
['AccountNotRentExempt', 4615046],
['InvalidAccountOwner', 4615047],
['ArithmeticOverflow', 4615048],
Expand Down Expand Up @@ -95,11 +96,10 @@ describe('getSolanaErrorFromInstructionError', () => {
}),
);
});
it('produces the correct `SolanaError` for a `BorshIoError` error', () => {
it('produces the correct `SolanaError` for a `BorshIoError` error (pre SDK 3.0 newtype style)', () => {
const error = getSolanaErrorFromInstructionError(123, { BorshIoError: 'abc' });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means that we need to make two tests, right: one that handles the error being { BorshIoError: 'abc' } and a second test that handles it being "BorshIoError"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it on line 54 as part of the generic test -- shouldn't that do what you're suggesting?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dumb.

expect(error).toEqual(
new SolanaError(SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR, {
encodedData: 'abc',
index: 123,
}),
);
Expand Down
1 change: 0 additions & 1 deletion packages/errors/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ export type SolanaErrorContext = DefaultUnspecifiedErrorContextToUndefined<
variant: number;
};
[SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR]: {
encodedData: string;
index: number;
};
[SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM]: {
Expand Down
11 changes: 1 addition & 10 deletions packages/errors/src/instruction-error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR,
SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN,
} from './codes';
import { SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN } from './codes';
import { SolanaError } from './error';
import { getSolanaErrorFromRpcError } from './rpc-enum-errors';

Expand Down Expand Up @@ -89,11 +85,6 @@ export function getSolanaErrorFromInstructionError(
code: Number(rpcErrorContext as bigint | number),
index: numberIndex,
};
} else if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR) {
return {
encodedData: rpcErrorContext as string,
index: numberIndex,
};
}
return { index: numberIndex };
},
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-types/src/transaction-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type InstructionError =
| 'AccountNotExecutable'
| 'AccountNotRentExempt'
| 'ArithmeticOverflow'
| 'BorshIoError' // SDKv3 has a fieldless `BorshIoError`
| 'BuiltinProgramsMustConsumeComputeUnits'
| 'CallDepth'
| 'ComputationalBudgetExceeded'
Expand Down Expand Up @@ -54,7 +55,6 @@ type InstructionError =
| 'UninitializedAccount'
| 'UnsupportedProgramId'
| 'UnsupportedSysvar'
| { BorshIoError: string }
| { Custom: CustomProgramError };

type InstructionIndex = number;
Expand Down
Loading