Skip to content

Instantly share code, notes, and snippets.

@arcticmatt
Created August 6, 2022 21:56
Show Gist options
  • Save arcticmatt/cabac0b209d9c82d892a13db4c698b12 to your computer and use it in GitHub Desktop.
Save arcticmatt/cabac0b209d9c82d892a13db4c698b12 to your computer and use it in GitHub Desktop.
// Old code
pub fn print_accounts<'info>(
ctx: Context<'_, '_, '_, 'info, PrintAccounts<'info>>,
) -> Result<()> {
Ok(())
}
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
foo_account: Account<'info, FooAccount>,
bar_account: Account<'info, BarAccount>,
}
// New code
#[derive(Accounts)]
pub struct PrintAccounts<'info> {
bar_account: Account<'info, BarAccount>,
foo_account: Account<'info, FooAccount>,
}
// Error
// backwards-compat-examples
// AnchorError: AnchorError caused by account: bar_account. Error Code: AccountDiscriminatorMismatch. Error Number: 3002. Error Message: 8 byte discriminator did not match what was expected.
// at Function.parse (/Users/mlim/Documents/software/crypto/solana/formfn/backwards-compat-examples/node_modules/@project-serum/anchor/src/error.ts:167:14)
// at translateError (/Users/mlim/Documents/software/crypto/solana/formfn/backwards-compat-examples/node_modules/@project-serum/anchor/src/error.ts:276:35)
// at MethodsBuilder.rpc [as _rpcFn] (/Users/mlim/Documents/software/crypto/solana/formfn/backwards-compat-examples/node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:35:29)
// at processTicksAndRejections (node:internal/process/task_queues:96:5) {
// errorLogs: [
// 'Program log: AnchorError caused by account: bar_account. Error Code: AccountDiscriminatorMismatch. Error Number: 3002. Error Message: 8 byte discriminator did not match what was expected.'
// ],
// logs: [
// 'Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS invoke [1]',
// 'Program log: Instruction: PrintAccounts',
// 'Program log: AnchorError caused by account: bar_account. Error Code: AccountDiscriminatorMismatch. Error Number: 3002. Error Message: 8 byte discriminator did not match what was expected.',
// 'Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS consumed 4292 of 200000 compute units',
// 'Program Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS failed: custom program error: 0xbba'
// ],
// error: {
// errorCode: { code: 'AccountDiscriminatorMismatch', number: 3002 },
// errorMessage: '8 byte discriminator did not match what was expected',
// comparedValues: undefined,
// origin: 'bar_account'
// },
// _pr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment