Skip to content

Commit

Permalink
Fix return type of getTokenAccountsByDelegate/Owner (#2027)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyre94 committed Jan 11, 2024
1 parent acab173 commit 23420ec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Address } from '@solana/addresses';
import { Rpc } from '@solana/rpc-transport';

import { SolanaRpcMethods } from '..';

const rpc = {} as unknown as Rpc<SolanaRpcMethods>;

// 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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>;
}>;
Expand Down
4 changes: 2 additions & 2 deletions packages/rpc-core/src/rpc-methods/getTokenAccountsByOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>;
}>;
Expand Down

0 comments on commit 23420ec

Please sign in to comment.