Skip to content

Commit 23420ec

Browse files
authored
Fix return type of getTokenAccountsByDelegate/Owner (#2027)
1 parent acab173 commit 23420ec

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Address } from '@solana/addresses';
2+
import { Rpc } from '@solana/rpc-transport';
3+
4+
import { SolanaRpcMethods } from '..';
5+
6+
const rpc = {} as unknown as Rpc<SolanaRpcMethods>;
7+
8+
// getTokenAccountsByDelegate
9+
async () => {
10+
const tokenAccountsByDelegate = await rpc
11+
.getTokenAccountsByDelegate(
12+
'delegate' as Address,
13+
{ programId: 'program' as Address },
14+
{ encoding: 'jsonParsed' },
15+
)
16+
.send();
17+
18+
const firstAccount = tokenAccountsByDelegate.value[0];
19+
firstAccount.pubkey satisfies Address;
20+
firstAccount.account.data.program satisfies Address;
21+
firstAccount.account.data.parsed.type satisfies 'account';
22+
firstAccount.account.data.parsed.info.mint satisfies Address;
23+
};
24+
25+
// getTokenAccountsByOwner
26+
async () => {
27+
const tokenAccountsByOwner = await rpc
28+
.getTokenAccountsByOwner('owner' as Address, { programId: 'program' as Address }, { encoding: 'jsonParsed' })
29+
.send();
30+
31+
const firstAccount = tokenAccountsByOwner.value[0];
32+
firstAccount.pubkey satisfies Address;
33+
firstAccount.account.data.program satisfies Address;
34+
firstAccount.account.data.parsed.type satisfies 'account';
35+
firstAccount.account.data.parsed.info.mint satisfies Address;
36+
};

packages/rpc-core/src/rpc-methods/getTokenAccountsByDelegate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import {
1919
type TokenAccountInfoWithJsonData = Readonly<{
2020
data: Readonly<{
2121
/** Name of the program that owns this account. */
22-
program: {
22+
program: Address;
23+
parsed: {
2324
info: TokenAccount;
2425
type: 'account';
2526
};
26-
parsed: unknown;
2727
space: U64UnsafeBeyond2Pow53Minus1;
2828
}>;
2929
}>;

packages/rpc-core/src/rpc-methods/getTokenAccountsByOwner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import {
1919
type TokenAccountInfoWithJsonData = Readonly<{
2020
data: Readonly<{
2121
/** Name of the program that owns this account. */
22-
program: {
22+
program: Address;
23+
parsed: {
2324
info: TokenAccount;
2425
type: 'account';
2526
};
26-
parsed: unknown;
2727
space: U64UnsafeBeyond2Pow53Minus1;
2828
}>;
2929
}>;

0 commit comments

Comments
 (0)