-
Notifications
You must be signed in to change notification settings - Fork 767
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(experimental): fix a few RPC methods
This change simply fixes a handful of incorrect RPC method signatures, as per the RPC docs. Stems from errors found in #2087.
- Loading branch information
1 parent
db105a6
commit bb65ba9
Showing
5 changed files
with
132 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/rpc-core/src/rpc-methods/__typetests__/get-leader-schedule-type-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Address } from '@solana/addresses'; | ||
import { Rpc, Slot } from '@solana/rpc-types'; | ||
|
||
import { GetLeaderScheduleApi } from '../getLeaderSchedule'; | ||
|
||
const rpc = null as unknown as Rpc<GetLeaderScheduleApi>; | ||
const slot = 0n as Slot; | ||
const identity = 'Joe11111111111111111111111111111' as Address<'Joe11111111111111111111111111111'>; | ||
|
||
async () => { | ||
{ | ||
const result = await rpc.getLeaderSchedule(slot).send(); | ||
// Can be null if the slot corresponds to an epoch that does not exist | ||
result satisfies Record<Address, Slot[]> | null; | ||
} | ||
|
||
{ | ||
const result = await rpc.getLeaderSchedule(null).send(); | ||
// Won't be null | ||
result satisfies Record<Address, Slot[]>; | ||
} | ||
|
||
{ | ||
const result = await rpc.getLeaderSchedule(slot, { identity }).send(); | ||
// Can be null if the slot corresponds to an epoch that does not exist | ||
result satisfies Readonly<{ [key: Address]: Slot[] | undefined }> | null; | ||
} | ||
|
||
{ | ||
const result = await rpc.getLeaderSchedule(null, { identity }).send(); | ||
// Won't be null | ||
result satisfies Readonly<{ [key: Address]: Slot[] | undefined }>; | ||
} | ||
}; |
47 changes: 47 additions & 0 deletions
47
packages/rpc-core/src/rpc-methods/__typetests__/get-supply-type-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Address } from '@solana/addresses'; | ||
import { Rpc } from '@solana/rpc-types'; | ||
|
||
import { GetSupplyApi } from '../getSupply'; | ||
|
||
const rpc = null as unknown as Rpc<GetSupplyApi>; | ||
|
||
async () => { | ||
{ | ||
const result = await rpc.getSupply({ excludeNonCirculatingAccountsList: true }).send(); | ||
result satisfies Readonly<{ | ||
value: Readonly<{ | ||
nonCirculatingAccounts: never[]; | ||
}>; | ||
}>; | ||
} | ||
|
||
{ | ||
const result = await rpc.getSupply().send(); | ||
result satisfies Readonly<{ | ||
value: Readonly<{ | ||
nonCirculatingAccounts: Address[]; | ||
}>; | ||
}>; | ||
// @ts-expect-error should not be `never` | ||
result satisfies Readonly<{ | ||
value: Readonly<{ | ||
nonCirculatingAccounts: never[]; | ||
}>; | ||
}>; | ||
} | ||
|
||
{ | ||
const result = await rpc.getSupply({ excludeNonCirculatingAccountsList: false }).send(); | ||
result satisfies Readonly<{ | ||
value: Readonly<{ | ||
nonCirculatingAccounts: Address[]; | ||
}>; | ||
}>; | ||
// @ts-expect-error should not be `never` | ||
result satisfies Readonly<{ | ||
value: Readonly<{ | ||
nonCirculatingAccounts: never[]; | ||
}>; | ||
}>; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters