diff --git a/packages/rpc-core/src/rpc-methods/__typetests__/rpc-methods-test.ts b/packages/rpc-core/src/rpc-methods/__typetests__/rpc-methods-test.ts new file mode 100644 index 00000000000..d38874b4368 --- /dev/null +++ b/packages/rpc-core/src/rpc-methods/__typetests__/rpc-methods-test.ts @@ -0,0 +1,36 @@ +import { Address } from '@solana/addresses'; +import { Rpc } from '@solana/rpc-transport'; + +import { SolanaRpcMethods } from '..'; + +const rpc = {} as unknown as Rpc; + +// getTokenAccountsByDelegate +async () => { + const tokenAccountsByDelegate = await rpc + .getTokenAccountsByDelegate( + 'delegate' as Address, + { programId: 'program' as Address }, + { encoding: 'jsonParsed' }, + ) + .send(); + + const firstAccount = tokenAccountsByDelegate.value[0]; + firstAccount.pubkey satisfies Address; + firstAccount.account.data.program satisfies Address; + firstAccount.account.data.parsed.type satisfies 'account'; + firstAccount.account.data.parsed.info.mint satisfies Address; +}; + +// getTokenAccountsByOwner +async () => { + const tokenAccountsByOwner = await rpc + .getTokenAccountsByOwner('owner' as Address, { programId: 'program' as Address }, { encoding: 'jsonParsed' }) + .send(); + + const firstAccount = tokenAccountsByOwner.value[0]; + firstAccount.pubkey satisfies Address; + firstAccount.account.data.program satisfies Address; + firstAccount.account.data.parsed.type satisfies 'account'; + firstAccount.account.data.parsed.info.mint satisfies Address; +}; diff --git a/packages/rpc-core/src/rpc-methods/getTokenAccountsByDelegate.ts b/packages/rpc-core/src/rpc-methods/getTokenAccountsByDelegate.ts index ba2d86596b8..5e99e72f1d3 100644 --- a/packages/rpc-core/src/rpc-methods/getTokenAccountsByDelegate.ts +++ b/packages/rpc-core/src/rpc-methods/getTokenAccountsByDelegate.ts @@ -19,11 +19,11 @@ import { type TokenAccountInfoWithJsonData = Readonly<{ data: Readonly<{ /** Name of the program that owns this account. */ - program: { + program: Address; + parsed: { info: TokenAccount; type: 'account'; }; - parsed: unknown; space: U64UnsafeBeyond2Pow53Minus1; }>; }>; diff --git a/packages/rpc-core/src/rpc-methods/getTokenAccountsByOwner.ts b/packages/rpc-core/src/rpc-methods/getTokenAccountsByOwner.ts index e2938b706c2..62ec4b5e406 100644 --- a/packages/rpc-core/src/rpc-methods/getTokenAccountsByOwner.ts +++ b/packages/rpc-core/src/rpc-methods/getTokenAccountsByOwner.ts @@ -19,11 +19,11 @@ import { type TokenAccountInfoWithJsonData = Readonly<{ data: Readonly<{ /** Name of the program that owns this account. */ - program: { + program: Address; + parsed: { info: TokenAccount; type: 'account'; }; - parsed: unknown; space: U64UnsafeBeyond2Pow53Minus1; }>; }>;