/** * Instruction compatibility shim for Web3.js v2 * Provides the missing interface types that generated code expects */ import type { Address } from '@solana/addresses'; import type { TransactionSigner } from '@solana/signers'; // Core instruction interfaces that generated code expects export interface IInstruction< TProgramAddress extends string = string, TAccounts extends readonly unknown[] = readonly unknown[] > { readonly programAddress: Address; readonly accounts: TAccounts; } export interface IInstructionWithData extends IInstruction { readonly data: TData; } export interface IInstructionWithAccounts extends IInstruction { readonly accounts: TAccounts; } // Account meta interfaces export interface IAccountMeta { readonly address: Address; readonly role: AccountRole; } export interface IAccountSignerMeta> extends IAccountMeta { readonly signer: TSigner; } export interface IAccountLookupMeta { readonly address: TAddress; readonly addressIndex: number; readonly lookupTableAddress: Address; readonly role: AccountRole; } // Account role type export type AccountRole = 'readonly' | 'writable' | 'readonly_signer' | 'writable_signer'; // Account role enum constants for compatibility export const AccountRole = { READONLY: 'readonly' as const, WRITABLE: 'writable' as const, READONLY_SIGNER: 'readonly_signer' as const, WRITABLE_SIGNER: 'writable_signer' as const } as const; // Utility function to upgrade role to signer equivalent export function upgradeRoleToSigner(role: AccountRole): AccountRole { switch (role) { case 'readonly': return 'readonly_signer'; case 'writable': return 'writable_signer'; case 'readonly_signer': case 'writable_signer': return role; default: return role; } } // Re-export for convenience export type { Address, TransactionSigner };