diff --git a/package.json b/package.json index 0b254ab8b23f..8f16987ef9ec 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.1", "@solana/build-scripts": "workspace:*", - "@solana/eslint-config-solana": "^3.0.0", + "@solana/eslint-config-solana": "^3.0.3", "@solana/prettier-config-solana": "0.0.4", "@solana/test-config": "workspace:*", "@solana/test-matchers": "workspace:*", diff --git a/packages/addresses/src/__tests__/curve-test.ts b/packages/addresses/src/__tests__/curve-test.ts index b0fa01a7e7ab..b2344ba7d94a 100644 --- a/packages/addresses/src/__tests__/curve-test.ts +++ b/packages/addresses/src/__tests__/curve-test.ts @@ -22,15 +22,10 @@ const ON_CURVE_KEY_BYTES = [ ]; describe('compressedPointBytesAreOnCurve', () => { - it.each(OFF_CURVE_KEY_BYTES)( - 'returns false when a public key does not lie on the Ed25519 curve [%#]', - async bytes => { - expect.assertions(1); - await expect(compressedPointBytesAreOnCurve(bytes)).resolves.toBe(false); - }, - ); - it.each(ON_CURVE_KEY_BYTES)('returns true when a public key lies on the Ed25519 curve [%#]', async bytes => { - expect.assertions(1); - await expect(compressedPointBytesAreOnCurve(bytes)).resolves.toBe(true); + it.each(OFF_CURVE_KEY_BYTES)('returns false when a public key does not lie on the Ed25519 curve [%#]', bytes => { + expect(compressedPointBytesAreOnCurve(bytes)).toBe(false); + }); + it.each(ON_CURVE_KEY_BYTES)('returns true when a public key lies on the Ed25519 curve [%#]', bytes => { + expect(compressedPointBytesAreOnCurve(bytes)).toBe(true); }); }); diff --git a/packages/addresses/src/curve.ts b/packages/addresses/src/curve.ts index 1098caae875b..5bf7a96f4bbd 100644 --- a/packages/addresses/src/curve.ts +++ b/packages/addresses/src/curve.ts @@ -15,7 +15,7 @@ function decompressPointBytes(bytes: Uint8Array): bigint { return BigInt(integerLiteralString); } -export async function compressedPointBytesAreOnCurve(bytes: Uint8Array): Promise { +export function compressedPointBytesAreOnCurve(bytes: Uint8Array): boolean { if (bytes.byteLength !== 32) { return false; } diff --git a/packages/addresses/src/program-derived-address.ts b/packages/addresses/src/program-derived-address.ts index cc0f8e324f84..04781f3b53c7 100644 --- a/packages/addresses/src/program-derived-address.ts +++ b/packages/addresses/src/program-derived-address.ts @@ -114,7 +114,7 @@ async function createProgramDerivedAddress({ programAddress, seeds }: ProgramDer new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES]), ); const addressBytes = new Uint8Array(addressBytesBuffer); - if (await compressedPointBytesAreOnCurve(addressBytes)) { + if (compressedPointBytesAreOnCurve(addressBytes)) { throw new SolanaError(SOLANA_ERROR__ADDRESSES__INVALID_SEEDS_POINT_ON_CURVE); } return base58EncodedAddressCodec.decode(addressBytes); diff --git a/packages/compat/src/keypair.ts b/packages/compat/src/keypair.ts index ada2e7e800e7..17b5b387ed72 100644 --- a/packages/compat/src/keypair.ts +++ b/packages/compat/src/keypair.ts @@ -10,5 +10,5 @@ export async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean) const bytes = new Uint8Array(64); bytes.set(keypair.secretKey); bytes.set(keypair.publicKey.toBytes(), /* offset */ 32); - return createKeyPairFromBytes(bytes, extractable); + return await createKeyPairFromBytes(bytes, extractable); } diff --git a/packages/errors/src/__tests__/message-formatter-test.ts b/packages/errors/src/__tests__/message-formatter-test.ts index b1fa2f61cbbf..66fecd341b42 100644 --- a/packages/errors/src/__tests__/message-formatter-test.ts +++ b/packages/errors/src/__tests__/message-formatter-test.ts @@ -13,7 +13,7 @@ jest.mock('../messages', () => ({ describe('getErrorMessage', () => { describe('in production mode', () => { - beforeEach(async () => { + beforeEach(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any (globalThis as any).__DEV__ = false; }); @@ -49,8 +49,7 @@ describe('getErrorMessage', () => { ); expect(encodeContextObject).toHaveBeenCalledWith(context); }); - it('renders advice on where to decode an error with encoded context', async () => { - expect.assertions(1); + it('renders advice on where to decode an error with encoded context', () => { jest.mocked(encodeContextObject).mockReturnValue('ENCODED_CONTEXT'); const context = { foo: 'bar' }; const message = getErrorMessage(123 as SolanaErrorCode, context); @@ -58,8 +57,7 @@ describe('getErrorMessage', () => { "Solana error #123; Decode this error by running `npx @solana/errors decode -- 123 'ENCODED_CONTEXT'`", ); }); - it('renders no encoded context in the decoding advice when the context has no keys', async () => { - expect.assertions(1); + it('renders no encoded context in the decoding advice when the context has no keys', () => { jest.mocked(encodeContextObject).mockReturnValue('ENCODED_CONTEXT'); const context = {}; const message = getErrorMessage(123 as SolanaErrorCode, context); @@ -67,7 +65,7 @@ describe('getErrorMessage', () => { }); }); describe('in dev mode', () => { - beforeEach(async () => { + beforeEach(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any (globalThis as any).__DEV__ = true; }); diff --git a/packages/keys/src/__tests__/private-key-test.ts b/packages/keys/src/__tests__/private-key-test.ts index 9279cfc5260d..645786fb1a32 100644 --- a/packages/keys/src/__tests__/private-key-test.ts +++ b/packages/keys/src/__tests__/private-key-test.ts @@ -21,8 +21,7 @@ describe('createPrivateKeyFromBytes', () => { beforeEach(async () => { privateKey = await createPrivateKeyFromBytes(MOCK_PRIVATE_KEY_BYTES); }); - it('is non-extractable', async () => { - expect.assertions(1); + it('is non-extractable', () => { expect(privateKey).toHaveProperty('extractable', false); }); it('has the expected metadata', () => { diff --git a/packages/library/src/__tests__/airdrop-internal-test.ts b/packages/library/src/__tests__/airdrop-internal-test.ts index 04ef736b285e..b3446d947b9a 100644 --- a/packages/library/src/__tests__/airdrop-internal-test.ts +++ b/packages/library/src/__tests__/airdrop-internal-test.ts @@ -24,8 +24,7 @@ describe('requestAndConfirmAirdrop', () => { requestAirdrop, }; }); - it('aborts the `requestAirdrop` request when aborted', async () => { - expect.assertions(2); + it('aborts the `requestAirdrop` request when aborted', () => { const abortController = new AbortController(); requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({ abortSignal: abortController.signal, @@ -68,8 +67,7 @@ describe('requestAndConfirmAirdrop', () => { }), ); }); - it('passes the expected input to the airdrop request', async () => { - expect.assertions(1); + it('passes the expected input to the airdrop request', () => { sendAirdropRequest.mockResolvedValue('abc' as Signature); requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({ abortSignal: new AbortController().signal, diff --git a/packages/rpc-graphql/src/index.ts b/packages/rpc-graphql/src/index.ts index beade093ce54..7dd3b6972957 100644 --- a/packages/rpc-graphql/src/index.ts +++ b/packages/rpc-graphql/src/index.ts @@ -27,7 +27,7 @@ export function createRpcGraphQL( return { async query(source, variableValues?) { const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig); - return graphql({ + return await graphql({ contextValue, schema, source, diff --git a/packages/rpc-graphql/src/loaders/__tests__/account-loader-test.ts b/packages/rpc-graphql/src/loaders/__tests__/account-loader-test.ts index a00d327df558..96cda65ea775 100644 --- a/packages/rpc-graphql/src/loaders/__tests__/account-loader-test.ts +++ b/packages/rpc-graphql/src/loaders/__tests__/account-loader-test.ts @@ -9,6 +9,10 @@ import type { import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('account loader', () => { let rpc: { getAccountInfo: jest.MockedFunction['getAccountInfo']>; @@ -24,11 +28,11 @@ describe('account loader', () => { beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL( rpc as unknown as Rpc< @@ -431,48 +435,52 @@ describe('account loader', () => { // First we should see `getMultipleAccounts` used for the first two layers rpc.getMultipleAccounts .mockImplementationOnce(() => ({ - send: async () => - getMultipleAccountsMockResponse([ - { - data: ['AA', 'base64'], - owner: '11111111111111111111111111111111', - }, - { - data: ['AA', 'base64'], - owner: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - }, - { - data: ['AA', 'base64'], - owner: 'Stake11111111111111111111111111111111111111', - }, - { - data: ['AA', 'base64'], - owner: 'Vote111111111111111111111111111111111111111', - }, - ]), + send: () => + Promise.resolve( + getMultipleAccountsMockResponse([ + { + data: ['AA', 'base64'], + owner: '11111111111111111111111111111111', + }, + { + data: ['AA', 'base64'], + owner: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + }, + { + data: ['AA', 'base64'], + owner: 'Stake11111111111111111111111111111111111111', + }, + { + data: ['AA', 'base64'], + owner: 'Vote111111111111111111111111111111111111111', + }, + ]), + ), })) .mockImplementationOnce(() => ({ - send: async () => - getMultipleAccountsMockResponse([ - { - data: ['AA', 'base64'], - owner: 'NativeLoader1111111111111111111111111111111', - }, - { - data: ['AA', 'base64'], - owner: 'BPFLoader2111111111111111111111111111111111', - }, - { - data: ['AA', 'base64'], - owner: 'NativeLoader1111111111111111111111111111111', - }, - ]), + send: () => + Promise.resolve( + getMultipleAccountsMockResponse([ + { + data: ['AA', 'base64'], + owner: 'NativeLoader1111111111111111111111111111111', + }, + { + data: ['AA', 'base64'], + owner: 'BPFLoader2111111111111111111111111111111111', + }, + { + data: ['AA', 'base64'], + owner: 'NativeLoader1111111111111111111111111111111', + }, + ]), + ), })); // Then we should see `getAccountInfo` used for the single // account in the last layer rpc.getAccountInfo.mockReturnValue({ - send: jest.fn().mockReturnValueOnce({ + send: jest.fn().mockResolvedValueOnce({ context: { slot: 0, }, diff --git a/packages/rpc-graphql/src/loaders/__tests__/block-loader-test.ts b/packages/rpc-graphql/src/loaders/__tests__/block-loader-test.ts index ce5cc41081bd..292fd9f75a47 100644 --- a/packages/rpc-graphql/src/loaders/__tests__/block-loader-test.ts +++ b/packages/rpc-graphql/src/loaders/__tests__/block-loader-test.ts @@ -10,6 +10,10 @@ import type { Slot } from '@solana/rpc-types'; import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('account loader', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; @@ -19,11 +23,11 @@ describe('account loader', () => { beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-graphql/src/loaders/__tests__/program-accounts-loader-test.ts b/packages/rpc-graphql/src/loaders/__tests__/program-accounts-loader-test.ts index e8e7c91f1d90..bfbf5c4736e0 100644 --- a/packages/rpc-graphql/src/loaders/__tests__/program-accounts-loader-test.ts +++ b/packages/rpc-graphql/src/loaders/__tests__/program-accounts-loader-test.ts @@ -9,6 +9,10 @@ import type { import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('account loader', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; @@ -18,11 +22,11 @@ describe('account loader', () => { beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-graphql/src/loaders/__tests__/transaction-loader-test.ts b/packages/rpc-graphql/src/loaders/__tests__/transaction-loader-test.ts index 0e94df1130a9..056e9452dfdc 100644 --- a/packages/rpc-graphql/src/loaders/__tests__/transaction-loader-test.ts +++ b/packages/rpc-graphql/src/loaders/__tests__/transaction-loader-test.ts @@ -9,6 +9,10 @@ import type { import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('account loader', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; @@ -18,11 +22,11 @@ describe('account loader', () => { beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-graphql/src/loaders/account.ts b/packages/rpc-graphql/src/loaders/account.ts index 4b9ac5f797fa..f8c8ac4de848 100644 --- a/packages/rpc-graphql/src/loaders/account.ts +++ b/packages/rpc-graphql/src/loaders/account.ts @@ -93,7 +93,7 @@ async function loadMultipleAccounts( function createAccountBatchLoadFn(rpc: Rpc, config: Config) { const resolveAccountUsingRpc = loadAccount.bind(null, rpc); const resolveMultipleAccountsUsingRpc = loadMultipleAccounts.bind(null, rpc); - return async (accountQueryArgs: readonly AccountLoaderArgs[]): ReturnType => { + return (accountQueryArgs: readonly AccountLoaderArgs[]): ReturnType => { /** * Gather all the accounts that need to be fetched, grouped by address. */ @@ -182,7 +182,7 @@ export function createAccountLoader( ): AccountLoader { const loader = new DataLoader(createAccountBatchLoadFn(rpc, config), { cacheKeyFn }); return { - load: async args => loader.load(args), - loadMany: async args => loader.loadMany(args), + load: args => loader.load(args), + loadMany: args => loader.loadMany(args), }; } diff --git a/packages/rpc-graphql/src/loaders/block.ts b/packages/rpc-graphql/src/loaders/block.ts index dac335bb995f..5f54df787117 100644 --- a/packages/rpc-graphql/src/loaders/block.ts +++ b/packages/rpc-graphql/src/loaders/block.ts @@ -17,7 +17,7 @@ async function loadBlock(rpc: Rpc, { slot, ...config }: BlockLoader function createBlockBatchLoadFn(rpc: Rpc) { const resolveBlockUsingRpc = loadBlock.bind(null, rpc); - return async (blockQueryArgs: readonly BlockLoaderArgs[]): ReturnType => { + return (blockQueryArgs: readonly BlockLoaderArgs[]): ReturnType => { /** * Gather all the blocks that need to be fetched, grouped by slot. */ @@ -76,7 +76,7 @@ function createBlockBatchLoadFn(rpc: Rpc) { export function createBlockLoader(rpc: Rpc): BlockLoader { const loader = new DataLoader(createBlockBatchLoadFn(rpc), { cacheKeyFn }); return { - load: async args => loader.load({ ...args, maxSupportedTransactionVersion: 0 }), - loadMany: async args => loader.loadMany(args.map(a => ({ ...a, maxSupportedTransactionVersion: 0 }))), + load: args => loader.load({ ...args, maxSupportedTransactionVersion: 0 }), + loadMany: args => loader.loadMany(args.map(a => ({ ...a, maxSupportedTransactionVersion: 0 }))), }; } diff --git a/packages/rpc-graphql/src/loaders/program-accounts.ts b/packages/rpc-graphql/src/loaders/program-accounts.ts index 0f40f583a8b2..b6ceba91bfb1 100644 --- a/packages/rpc-graphql/src/loaders/program-accounts.ts +++ b/packages/rpc-graphql/src/loaders/program-accounts.ts @@ -31,9 +31,7 @@ async function loadProgramAccounts( function createProgramAccountsBatchLoadFn(rpc: Rpc, config: Config) { const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc); - return async ( - accountQueryArgs: readonly ProgramAccountsLoaderArgs[], - ): ReturnType => { + return (accountQueryArgs: readonly ProgramAccountsLoaderArgs[]): ReturnType => { /** * Gather all the program-accounts that need to be fetched, grouped by * program address. @@ -94,7 +92,7 @@ function createProgramAccountsBatchLoadFn(rpc: Rpc, confi export function createProgramAccountsLoader(rpc: Rpc, config: Config): ProgramAccountsLoader { const loader = new DataLoader(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn }); return { - load: async args => loader.load(args), - loadMany: async args => loader.loadMany(args), + load: args => loader.load(args), + loadMany: args => loader.loadMany(args), }; } diff --git a/packages/rpc-graphql/src/loaders/transaction.ts b/packages/rpc-graphql/src/loaders/transaction.ts index 13b7f7f3af95..58b687df6612 100644 --- a/packages/rpc-graphql/src/loaders/transaction.ts +++ b/packages/rpc-graphql/src/loaders/transaction.ts @@ -26,9 +26,7 @@ async function loadTransaction( function createTransactionBatchLoadFn(rpc: Rpc) { const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc); - return async ( - transactionQueryArgs: readonly TransactionLoaderArgs[], - ): ReturnType => { + return (transactionQueryArgs: readonly TransactionLoaderArgs[]): ReturnType => { /** * Gather all the transactions that need to be fetched, grouped by signature. */ @@ -83,7 +81,7 @@ function createTransactionBatchLoadFn(rpc: Rpc) { export function createTransactionLoader(rpc: Rpc): TransactionLoader { const loader = new DataLoader(createTransactionBatchLoadFn(rpc), { cacheKeyFn }); return { - load: async args => loader.load(args), - loadMany: async args => loader.loadMany(args), + load: args => loader.load(args), + loadMany: args => loader.loadMany(args), }; } diff --git a/packages/rpc-graphql/src/resolvers/__tests__/account-resolver-test.ts b/packages/rpc-graphql/src/resolvers/__tests__/account-resolver-test.ts index 8a04501d031f..f90949d2055b 100644 --- a/packages/rpc-graphql/src/resolvers/__tests__/account-resolver-test.ts +++ b/packages/rpc-graphql/src/resolvers/__tests__/account-resolver-test.ts @@ -10,6 +10,10 @@ import type { import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('account resolver', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; @@ -22,21 +26,22 @@ describe('account resolver', () => { ? 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' : 'BPFLoader2111111111111111111111111111111111'; return { - send: async () => ({ - context: { - slot: 0, - }, - value: { - data: ['AA', 'base64'], - owner, - }, - }), + send: () => + Promise.resolve({ + context: { + slot: 0, + }, + value: { + data: ['AA', 'base64'], + owner, + }, + }), }; }), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-graphql/src/resolvers/__tests__/block-resolver-test.ts b/packages/rpc-graphql/src/resolvers/__tests__/block-resolver-test.ts index 9ba04b34a066..032acd709d40 100644 --- a/packages/rpc-graphql/src/resolvers/__tests__/block-resolver-test.ts +++ b/packages/rpc-graphql/src/resolvers/__tests__/block-resolver-test.ts @@ -10,6 +10,10 @@ import type { Slot } from '@solana/rpc-types'; import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('block resolver', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; @@ -19,11 +23,11 @@ describe('block resolver', () => { beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-graphql/src/resolvers/__tests__/program-accounts-resolver-test.ts b/packages/rpc-graphql/src/resolvers/__tests__/program-accounts-resolver-test.ts index 93d03f46043e..85d6c49ec2ee 100644 --- a/packages/rpc-graphql/src/resolvers/__tests__/program-accounts-resolver-test.ts +++ b/packages/rpc-graphql/src/resolvers/__tests__/program-accounts-resolver-test.ts @@ -9,17 +9,21 @@ import type { import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('program accounts resolver', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-graphql/src/resolvers/__tests__/transaction-resolver-test.ts b/packages/rpc-graphql/src/resolvers/__tests__/transaction-resolver-test.ts index 375a1f1318e8..e0a7e94c1610 100644 --- a/packages/rpc-graphql/src/resolvers/__tests__/transaction-resolver-test.ts +++ b/packages/rpc-graphql/src/resolvers/__tests__/transaction-resolver-test.ts @@ -9,6 +9,10 @@ import type { import { createRpcGraphQL, RpcGraphQL } from '../../index'; +const FOREVER_PROMISE = new Promise(() => { + /* never resolve */ +}); + describe('transaction resolver', () => { let rpc: Rpc; let rpcGraphQL: RpcGraphQL; @@ -17,11 +21,11 @@ describe('transaction resolver', () => { beforeEach(() => { jest.useFakeTimers(); rpc = { - getAccountInfo: jest.fn(), - getBlock: jest.fn(), - getMultipleAccounts: jest.fn(), - getProgramAccounts: jest.fn(), - getTransaction: jest.fn(), + getAccountInfo: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getBlock: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getMultipleAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getProgramAccounts: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), + getTransaction: jest.fn().mockReturnValue({ send: jest.fn().mockReturnValue(FOREVER_PROMISE) }), }; rpcGraphQL = createRpcGraphQL(rpc); }); diff --git a/packages/rpc-subscriptions-api/src/__typetests__/account-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/account-notifications-type-test.ts index 836e70cdc4a8..116130349a01 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/account-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/account-notifications-type-test.ts @@ -14,118 +14,133 @@ import type { import type { AccountNotificationsApi } from '../account-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; - // See scripts/fixtures/GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G.json - // data is 'test data' - // Note: In type tests, it doesn't matter if the account is actually JSON-parseable - const pubkey = - 'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G' as Address<'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G'>; +const rpcSubscriptions = null as unknown as RpcSubscriptions; +// See scripts/fixtures/GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G.json +// data is 'test data' +// Note: In type tests, it doesn't matter if the account is actually JSON-parseable +const pubkey = + 'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G' as Address<'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G'>; - type TNotificationBase = Readonly<{ - executable: boolean; - lamports: LamportsUnsafeBeyond2Pow53Minus1; - owner: Address; - rentEpoch: U64UnsafeBeyond2Pow53Minus1; - }>; +type TNotificationBase = Readonly<{ + executable: boolean; + lamports: LamportsUnsafeBeyond2Pow53Minus1; + owner: Address; + rentEpoch: U64UnsafeBeyond2Pow53Minus1; +}>; - // No optional configs - rpcSubscriptions.accountNotifications(pubkey) satisfies PendingRpcSubscriptionsRequest< +// No optional configs +rpcSubscriptions.accountNotifications(pubkey) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + data: Base58EncodedBytes; + } + > +>; +rpcSubscriptions + .accountNotifications(pubkey) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { data: Base58EncodedBytes; } > - >; - rpcSubscriptions - .accountNotifications(pubkey) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - data: Base58EncodedBytes; - } - > - > - >; - // With optional configs - rpcSubscriptions.accountNotifications(pubkey, { commitment: 'confirmed' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// With optional configs +rpcSubscriptions.accountNotifications(pubkey, { commitment: 'confirmed' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + data: Base58EncodedBytes; + } + > +>; +rpcSubscriptions + .accountNotifications(pubkey, { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { data: Base58EncodedBytes; } > - >; - rpcSubscriptions - .accountNotifications(pubkey, { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - data: Base58EncodedBytes; - } - > - > - >; - // Base58 encoded data - rpcSubscriptions.accountNotifications(pubkey, { encoding: 'base58' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// Base58 encoded data +rpcSubscriptions.accountNotifications(pubkey, { encoding: 'base58' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + data: Base58EncodedDataResponse; + } + > +>; +rpcSubscriptions + .accountNotifications(pubkey, { encoding: 'base58' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { data: Base58EncodedDataResponse; } > - >; - rpcSubscriptions - .accountNotifications(pubkey, { encoding: 'base58' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - data: Base58EncodedDataResponse; - } - > - > - >; - // Base64 encoded data - rpcSubscriptions.accountNotifications(pubkey, { encoding: 'base64' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// Base64 encoded data +rpcSubscriptions.accountNotifications(pubkey, { encoding: 'base64' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + data: Base64EncodedDataResponse; + } + > +>; +rpcSubscriptions + .accountNotifications(pubkey, { encoding: 'base64' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { data: Base64EncodedDataResponse; } > - >; - rpcSubscriptions - .accountNotifications(pubkey, { encoding: 'base64' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - data: Base64EncodedDataResponse; - } - > - > - >; - // Base64 + ZSTD encoded data - rpcSubscriptions.accountNotifications(pubkey, { encoding: 'base64+zstd' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// Base64 + ZSTD encoded data +rpcSubscriptions.accountNotifications(pubkey, { encoding: 'base64+zstd' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + data: Base64EncodedZStdCompressedDataResponse; + } + > +>; +rpcSubscriptions + .accountNotifications(pubkey, { encoding: 'base64+zstd' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { data: Base64EncodedZStdCompressedDataResponse; } > - >; - rpcSubscriptions - .accountNotifications(pubkey, { encoding: 'base64+zstd' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - data: Base64EncodedZStdCompressedDataResponse; - } - > - > - >; - // JSON parsed data - rpcSubscriptions.accountNotifications(pubkey, { encoding: 'jsonParsed' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// JSON parsed data +rpcSubscriptions.accountNotifications(pubkey, { encoding: 'jsonParsed' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + data: + | Base64EncodedDataResponse + | Readonly<{ + parsed: unknown; + program: string; + space: U64UnsafeBeyond2Pow53Minus1; + }>; + } + > +>; +rpcSubscriptions + .accountNotifications(pubkey, { encoding: 'jsonParsed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { data: @@ -137,22 +152,5 @@ async () => { }>; } > - >; - rpcSubscriptions - .accountNotifications(pubkey, { encoding: 'jsonParsed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - data: - | Base64EncodedDataResponse - | Readonly<{ - parsed: unknown; - program: string; - space: U64UnsafeBeyond2Pow53Minus1; - }>; - } - > - > - >; -}; + > +>; diff --git a/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts index 3379eb17d063..822b28e71160 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/block-notifications-type-test.ts @@ -18,1572 +18,1568 @@ import type { TransactionVersion } from '@solana/transactions'; import type { BlockNotificationsApi } from '../block-notifications'; -async () => { - type BlockNotificationsApiNotificationBase = SolanaRpcResponse< - Readonly<{ - block: { - blockHeight: bigint; - blockTime: number; - blockhash: string; - parentSlot: bigint; - previousBlockhash: string; - } | null; - err: string | null; - slot: Slot; - }> - >; - type BlockNotificationsApiNotificationWithRewards = SolanaRpcResponse< - Readonly<{ - block: { - rewards: readonly Reward[]; - } | null; - }> - >; - type BlockNotificationsApiNotificationWithSignatures = SolanaRpcResponse< - Readonly<{ - block: { - signatures: readonly Base58EncodedBytes[]; - } | null; - }> - >; - type BlockNotificationsApiNotificationWithTransactions = SolanaRpcResponse< - Readonly<{ - block: { - transactions: readonly TTransactionType[]; - } | null; - }> - >; - - const rpcSubscriptions = null as unknown as RpcSubscriptions; - - // First overload - // Rewards set to `false` - rpcSubscriptions.blockNotifications('all', { +type BlockNotificationsApiNotificationBase = SolanaRpcResponse< + Readonly<{ + block: { + blockHeight: bigint; + blockTime: number; + blockhash: string; + parentSlot: bigint; + previousBlockhash: string; + } | null; + err: string | null; + slot: Slot; + }> +>; +type BlockNotificationsApiNotificationWithRewards = SolanaRpcResponse< + Readonly<{ + block: { + rewards: readonly Reward[]; + } | null; + }> +>; +type BlockNotificationsApiNotificationWithSignatures = SolanaRpcResponse< + Readonly<{ + block: { + signatures: readonly Base58EncodedBytes[]; + } | null; + }> +>; +type BlockNotificationsApiNotificationWithTransactions = SolanaRpcResponse< + Readonly<{ + block: { + transactions: readonly TTransactionType[]; + } | null; + }> +>; + +const rpcSubscriptions = null as unknown as RpcSubscriptions; + +// First overload +// Rewards set to `false` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: false, + transactionDetails: 'none', +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: false, transactionDetails: 'none', - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: false, - transactionDetails: 'none', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - // No rewards - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; +// No rewards +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: false, + transactionDetails: 'none', + // @ts-expect-error no rewards +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: false, transactionDetails: 'none', - // @ts-expect-error no rewards - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: false, - transactionDetails: 'none', - }) - // @ts-expect-error no rewards - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - - // First overload with configs - // Rewards set to `false` - rpcSubscriptions.blockNotifications('all', { + }) + // @ts-expect-error no rewards + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; + +// First overload with configs +// Rewards set to `false` +rpcSubscriptions.blockNotifications('all', { + commitment: 'processed', + encoding: 'base64', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'none', +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .blockNotifications('all', { commitment: 'processed', encoding: 'base64', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'none', - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'processed', - encoding: 'base64', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'none', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - // No rewards - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; +// No rewards +rpcSubscriptions.blockNotifications('all', { + commitment: 'processed', + encoding: 'base64', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'none', + // @ts-expect-error no rewards +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'processed', encoding: 'base64', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'none', - // @ts-expect-error no rewards - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'processed', - encoding: 'base64', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'none', - }) - // @ts-expect-error no rewards - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - - // Second overload - // Rewards defaults to `true` - rpcSubscriptions.blockNotifications('all', { + }) + // @ts-expect-error no rewards + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; + +// Second overload +// Rewards defaults to `true` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + transactionDetails: 'none', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs transactionDetails: 'none', - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - transactionDetails: 'none', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - - // Second overload with configs - // Rewards defaults to `true` - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; + +// Second overload with configs +// Rewards defaults to `true` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base58', + maxSupportedTransactionVersion: 0, + transactionDetails: 'none', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base58', maxSupportedTransactionVersion: 0, transactionDetails: 'none', - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base58', - maxSupportedTransactionVersion: 0, - transactionDetails: 'none', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - - // Second overload - // Rewards set to `true` - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; + +// Second overload +// Rewards set to `true` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: true, + transactionDetails: 'none', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: true, transactionDetails: 'none', - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: true, - transactionDetails: 'none', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - - // Second overload with configs - // Rewards set to `true` - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; + +// Second overload with configs +// Rewards set to `true` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base58', + maxSupportedTransactionVersion: 0, + showRewards: true, + transactionDetails: 'none', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base58', maxSupportedTransactionVersion: 0, showRewards: true, transactionDetails: 'none', - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base58', - maxSupportedTransactionVersion: 0, - showRewards: true, - transactionDetails: 'none', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - - // Third overload - // Rewards set to `false` - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; + +// Third overload +// Rewards set to `false` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: false, + transactionDetails: 'signatures', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: false, transactionDetails: 'signatures', - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: false, - transactionDetails: 'signatures', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - // No rewards - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; +// No rewards +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: false, + transactionDetails: 'signatures', + // @ts-expect-error no rewards +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: false, transactionDetails: 'signatures', - // @ts-expect-error no rewards - }) satisfies PendingRpcSubscriptionsRequest< + }) + // @ts-expect-error no rewards + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: false, - transactionDetails: 'signatures', - }) - // @ts-expect-error no rewards - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithSignatures - > - >; - - // Third overload with configs - // Rewards set to `false` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Third overload with configs +// Rewards set to `false` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'json', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'signatures', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'json', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'signatures', - }) satisfies PendingRpcSubscriptionsRequest< - BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'json', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'signatures', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - // No rewards - rpcSubscriptions.blockNotifications('all', { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; +// No rewards +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'json', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'signatures', + // @ts-expect-error no rewards +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'json', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'signatures', - // @ts-expect-error no rewards - }) satisfies PendingRpcSubscriptionsRequest< + }) + // @ts-expect-error no rewards + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'json', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'signatures', - }) - // @ts-expect-error no rewards - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithSignatures - > - >; - - // Fourth overload - // Rewards defaults to `true` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fourth overload +// Rewards defaults to `true` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + transactionDetails: 'signatures', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs transactionDetails: 'signatures', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - transactionDetails: 'signatures', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithSignatures - > - >; - - // Fourth overload with configs - // Rewards defaults to `true` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fourth overload with configs +// Rewards defaults to `true` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'jsonParsed', + maxSupportedTransactionVersion: 0, + transactionDetails: 'signatures', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'jsonParsed', maxSupportedTransactionVersion: 0, transactionDetails: 'signatures', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'jsonParsed', - maxSupportedTransactionVersion: 0, - transactionDetails: 'signatures', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithSignatures - > - >; - - // // Fourth overload - // // Rewards set to `true` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// // Fourth overload +// // Rewards set to `true` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: true, + transactionDetails: 'signatures', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: true, transactionDetails: 'signatures', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: true, - transactionDetails: 'signatures', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithSignatures - > - >; - - // Fourth overload with configs - // Rewards set to `true` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fourth overload with configs +// Rewards set to `true` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'jsonParsed', + maxSupportedTransactionVersion: 0, + transactionDetails: 'signatures', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithSignatures +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'jsonParsed', maxSupportedTransactionVersion: 0, transactionDetails: 'signatures', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithSignatures - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'jsonParsed', - maxSupportedTransactionVersion: 0, - transactionDetails: 'signatures', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithSignatures - > - >; - - type ExpectedMetaForAccountsBase = { - err: TransactionError | null; - fee: LamportsUnsafeBeyond2Pow53Minus1; - postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - postTokenBalances?: readonly TokenBalance[]; - preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - preTokenBalances?: readonly TokenBalance[]; - status: TransactionStatus; - }; + > +>; + +type ExpectedMetaForAccountsBase = { + err: TransactionError | null; + fee: LamportsUnsafeBeyond2Pow53Minus1; + postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + postTokenBalances?: readonly TokenBalance[]; + preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + preTokenBalances?: readonly TokenBalance[]; + status: TransactionStatus; +}; - type ExpectedTransactionForAccountsBaseLegacy = { - meta: ExpectedMetaForAccountsBase | null; - transaction: { - accountKeys: readonly Readonly<{ - pubkey: string; - signer: boolean; - source: 'transaction'; - writable: boolean; - }>[]; - signatures: readonly Base58EncodedBytes[]; - }; +type ExpectedTransactionForAccountsBaseLegacy = { + meta: ExpectedMetaForAccountsBase | null; + transaction: { + accountKeys: readonly Readonly<{ + pubkey: string; + signer: boolean; + source: 'transaction'; + writable: boolean; + }>[]; + signatures: readonly Base58EncodedBytes[]; }; +}; - type ExpectedTransactionForAccountsBaseVersioned = { - meta: ExpectedMetaForAccountsBase | null; - transaction: { - accountKeys: readonly Readonly<{ - pubkey: string; - signer: boolean; - source: 'lookupTable' | 'transaction'; - writable: boolean; - }>[]; - signatures: readonly Base58EncodedBytes[]; - }; - version: TransactionVersion; +type ExpectedTransactionForAccountsBaseVersioned = { + meta: ExpectedMetaForAccountsBase | null; + transaction: { + accountKeys: readonly Readonly<{ + pubkey: string; + signer: boolean; + source: 'lookupTable' | 'transaction'; + writable: boolean; + }>[]; + signatures: readonly Base58EncodedBytes[]; }; + version: TransactionVersion; +}; - // Fifth overload - // Rewards set to `false` - // Max supported transaction version set to 0 - rpcSubscriptions.blockNotifications('all', { +// Fifth overload +// Rewards set to `false` +// Max supported transaction version set to 0 +rpcSubscriptions.blockNotifications('all', { + // No extra configs + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Fifth overload with configs - // Rewards set to `false` - // Max supported transaction version set to 0 - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fifth overload with configs +// Rewards set to `false` +// Max supported transaction version set to 0 +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base64', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base64', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base64', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Sixth overload - // Rewards set to `false` - // Max supported transaction version defaults to `legacy` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Sixth overload +// Rewards set to `false` +// Max supported transaction version defaults to `legacy` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base64', + showRewards: false, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base64', showRewards: false, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base64', - showRewards: false, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Sixth overload with configs - // Rewards set to `false` - // Max supported transaction version defaults to `legacy` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Sixth overload with configs +// Rewards set to `false` +// Max supported transaction version defaults to `legacy` +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base64', + showRewards: false, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base64', showRewards: false, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base64', - showRewards: false, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Seventh overload - // Rewards defaults to `true` - // Max supported transaction version set to 0 - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Seventh overload +// Rewards defaults to `true` +// Max supported transaction version set to 0 +rpcSubscriptions.blockNotifications('all', { + // No extra configs + maxSupportedTransactionVersion: 0, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs maxSupportedTransactionVersion: 0, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - maxSupportedTransactionVersion: 0, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Seventh overload with configs - // Rewards defaults to `true` - // Max supported transaction version set to 0 - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Seventh overload with configs +// Rewards defaults to `true` +// Max supported transaction version set to 0 +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base64', + maxSupportedTransactionVersion: 0, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base64', maxSupportedTransactionVersion: 0, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base64', - maxSupportedTransactionVersion: 0, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Seventh overload - // Rewards set to `true` - // Max supported transaction version set to 0 - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Seventh overload +// Rewards set to `true` +// Max supported transaction version set to 0 +rpcSubscriptions.blockNotifications('all', { + // No extra configs + maxSupportedTransactionVersion: 0, + showRewards: true, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs maxSupportedTransactionVersion: 0, showRewards: true, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - maxSupportedTransactionVersion: 0, - showRewards: true, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Seventh overload with configs - // Rewards set to `true` - // Max supported transaction version set to 0 - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Seventh overload with configs +// Rewards set to `true` +// Max supported transaction version set to 0 +rpcSubscriptions.blockNotifications('all', { + commitment: 'confirmed', + encoding: 'base64', + maxSupportedTransactionVersion: 0, + showRewards: true, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed', encoding: 'base64', maxSupportedTransactionVersion: 0, showRewards: true, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - commitment: 'confirmed', - encoding: 'base64', - maxSupportedTransactionVersion: 0, - showRewards: true, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Eighth overload - // Rewards defaults to `true` - // Max supported transaction version defaults to `legacy` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Eighth overload +// Rewards defaults to `true` +// Max supported transaction version defaults to `legacy` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Eighth overload - // Rewards set to `true` - // Max supported transaction version defaults to `legacy` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Eighth overload +// Rewards set to `true` +// Max supported transaction version defaults to `legacy` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: true, + transactionDetails: 'accounts', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: true, transactionDetails: 'accounts', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: true, - transactionDetails: 'accounts', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - type ExpectedMetaForFullBase58 = { - computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; - err: TransactionError | null; - fee: LamportsUnsafeBeyond2Pow53Minus1; - innerInstructions: readonly Readonly<{ - index: number; - instructions: readonly Readonly<{ - accounts: readonly number[]; - data: Base58EncodedBytes; - programIdIndex: number; - }>[]; + > +>; + +type ExpectedMetaForFullBase58 = { + computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; + err: TransactionError | null; + fee: LamportsUnsafeBeyond2Pow53Minus1; + innerInstructions: readonly Readonly<{ + index: number; + instructions: readonly Readonly<{ + accounts: readonly number[]; + data: Base58EncodedBytes; + programIdIndex: number; }>[]; - logMessages: readonly string[] | null; - postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - postTokenBalances?: readonly TokenBalance[]; - preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - preTokenBalances?: readonly TokenBalance[]; - returnData?: Readonly<{ - data: Base64EncodedDataResponse; - programId: Address; - }>; - rewards: readonly Reward[] | null; - status: TransactionStatus; - }; + }>[]; + logMessages: readonly string[] | null; + postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + postTokenBalances?: readonly TokenBalance[]; + preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + preTokenBalances?: readonly TokenBalance[]; + returnData?: Readonly<{ + data: Base64EncodedDataResponse; + programId: Address; + }>; + rewards: readonly Reward[] | null; + status: TransactionStatus; +}; - type ExpectedTransactionForFullBase58Legacy = { - meta: ExpectedMetaForFullBase58 | null; - transaction: Base58EncodedDataResponse; - }; +type ExpectedTransactionForFullBase58Legacy = { + meta: ExpectedMetaForFullBase58 | null; + transaction: Base58EncodedDataResponse; +}; - type ExpectedTransactionForFullBase58Versioned = { - meta: - | (ExpectedMetaForFullBase58 & - Readonly<{ - loadedAddresses: { - readonly: readonly Address[]; - writable: readonly Address[]; - }; - }>) - | null; - transaction: Base58EncodedDataResponse; - version: TransactionVersion; - }; +type ExpectedTransactionForFullBase58Versioned = { + meta: + | (ExpectedMetaForFullBase58 & + Readonly<{ + loadedAddresses: { + readonly: readonly Address[]; + writable: readonly Address[]; + }; + }>) + | null; + transaction: Base58EncodedDataResponse; + version: TransactionVersion; +}; - // Ninth overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding set to `base58` - // Transaction details default to `full` - rpcSubscriptions.blockNotifications('all', { +// Ninth overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding set to `base58` +// Transaction details default to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + maxSupportedTransactionVersion: 0, + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', maxSupportedTransactionVersion: 0, showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - maxSupportedTransactionVersion: 0, - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Ninth overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding set to `base58` - // Transaction details set to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Ninth overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding set to `base58` +// Transaction details set to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'full', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'full', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'full', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Tenth overload - // Rewards set to `false` - // Max supported transaction defaults to `legacy` - // Encoding set to `base58` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Tenth overload +// Rewards set to `false` +// Max supported transaction defaults to `legacy` +// Encoding set to `base58` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Tenth overload - // Rewards set to `false` - // Max supported transaction defaults to `legacy` - // Encoding set to `base58` - // Transaction details set to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Tenth overload +// Rewards set to `false` +// Max supported transaction defaults to `legacy` +// Encoding set to `base58` +// Transaction details set to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + showRewards: false, + transactionDetails: 'full', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', showRewards: false, transactionDetails: 'full', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - showRewards: false, - transactionDetails: 'full', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Eleventh overload - // Rewards defaults to `true` - // Max supported transaction version set to 0 - // Encoding set to `base58` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Eleventh overload +// Rewards defaults to `true` +// Max supported transaction version set to 0 +// Encoding set to `base58` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + maxSupportedTransactionVersion: 0, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', maxSupportedTransactionVersion: 0, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - maxSupportedTransactionVersion: 0, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Eleventh overload - // Rewards set to `true` - // Max supported transaction version set to 0 - // Encoding set to `base58` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Eleventh overload +// Rewards set to `true` +// Max supported transaction version set to 0 +// Encoding set to `base58` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + maxSupportedTransactionVersion: 0, + showRewards: true, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', maxSupportedTransactionVersion: 0, showRewards: true, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - maxSupportedTransactionVersion: 0, - showRewards: true, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twelfth overload - // Rewards defaults to `true` - // Max supported transaction defaults to `legacy` - // Encoding set to `base58` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Twelfth overload +// Rewards defaults to `true` +// Max supported transaction defaults to `legacy` +// Encoding set to `base58` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twelfth overload - // Rewards set to `true` - // Max supported transaction defaults to `legacy` - // Encoding set to `base58` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Twelfth overload +// Rewards set to `true` +// Max supported transaction defaults to `legacy` +// Encoding set to `base58` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base58', + showRewards: true, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base58', showRewards: true, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base58', - showRewards: true, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - type ExpectedMetaForFullBase64 = { - computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; - err: TransactionError | null; - fee: LamportsUnsafeBeyond2Pow53Minus1; - innerInstructions: readonly Readonly<{ - index: number; - instructions: readonly Readonly<{ - accounts: readonly number[]; - data: Base58EncodedBytes; - programIdIndex: number; - }>[]; + > +>; + +type ExpectedMetaForFullBase64 = { + computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; + err: TransactionError | null; + fee: LamportsUnsafeBeyond2Pow53Minus1; + innerInstructions: readonly Readonly<{ + index: number; + instructions: readonly Readonly<{ + accounts: readonly number[]; + data: Base58EncodedBytes; + programIdIndex: number; }>[]; - logMessages: readonly string[] | null; - postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - postTokenBalances?: readonly TokenBalance[]; - preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - preTokenBalances?: readonly TokenBalance[]; - returnData?: Readonly<{ - data: Base64EncodedDataResponse; - programId: Address; - }>; - rewards: readonly Reward[] | null; - status: TransactionStatus; - }; + }>[]; + logMessages: readonly string[] | null; + postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + postTokenBalances?: readonly TokenBalance[]; + preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + preTokenBalances?: readonly TokenBalance[]; + returnData?: Readonly<{ + data: Base64EncodedDataResponse; + programId: Address; + }>; + rewards: readonly Reward[] | null; + status: TransactionStatus; +}; - type ExpectedTransactionForFullBase64Legacy = { - meta: ExpectedMetaForFullBase64 | null; - transaction: Base64EncodedDataResponse; - }; +type ExpectedTransactionForFullBase64Legacy = { + meta: ExpectedMetaForFullBase64 | null; + transaction: Base64EncodedDataResponse; +}; - type ExpectedTransactionForFullBase64Versioned = { - meta: - | (ExpectedMetaForFullBase64 & - Readonly<{ - loadedAddresses: { - readonly: readonly Address[]; - writable: readonly Address[]; - }; - }>) - | null; - transaction: Base64EncodedDataResponse; - version: TransactionVersion; - }; +type ExpectedTransactionForFullBase64Versioned = { + meta: + | (ExpectedMetaForFullBase64 & + Readonly<{ + loadedAddresses: { + readonly: readonly Address[]; + writable: readonly Address[]; + }; + }>) + | null; + transaction: Base64EncodedDataResponse; + version: TransactionVersion; +}; - // Thirteenth overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding set to `base64` - // Transaction details default to `full` - rpcSubscriptions.blockNotifications('all', { +// Thirteenth overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding set to `base64` +// Transaction details default to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base64', + maxSupportedTransactionVersion: 0, + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base64', maxSupportedTransactionVersion: 0, showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base64', - maxSupportedTransactionVersion: 0, - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Thirteenth overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding set to `base64` - // Transaction details set to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Thirteenth overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding set to `base64` +// Transaction details set to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base64', + maxSupportedTransactionVersion: 0, + showRewards: false, + transactionDetails: 'full', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base64', maxSupportedTransactionVersion: 0, showRewards: false, transactionDetails: 'full', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base64', - maxSupportedTransactionVersion: 0, - showRewards: false, - transactionDetails: 'full', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Fourteenth overload - // Rewards set to `false` - // Max supported transaction defaults to `legacy` - // Encoding set to `base64` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fourteenth overload +// Rewards set to `false` +// Max supported transaction defaults to `legacy` +// Encoding set to `base64` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base64', + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base64', showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base64', - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Fourteenth overload - // Rewards set to `false` - // Max supported transaction defaults to `legacy` - // Encoding set to `base64` - // Transaction details set to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fourteenth overload +// Rewards set to `false` +// Max supported transaction defaults to `legacy` +// Encoding set to `base64` +// Transaction details set to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base64', + showRewards: false, + transactionDetails: 'full', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base64', showRewards: false, transactionDetails: 'full', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base64', - showRewards: false, - transactionDetails: 'full', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Fifteenth overload - // Rewards defaults to `true` - // Max supported transaction version set to 0 - // Encoding set to `base64` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Fifteenth overload +// Rewards defaults to `true` +// Max supported transaction version set to 0 +// Encoding set to `base64` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base64', + maxSupportedTransactionVersion: 0, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base64', maxSupportedTransactionVersion: 0, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base64', - maxSupportedTransactionVersion: 0, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // // Sixteenth overload - // // Rewards defaults to `true` - // // Max supported transaction defaults to `legacy` - // // Encoding set to `base64` - // // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// // Sixteenth overload +// // Rewards defaults to `true` +// // Max supported transaction defaults to `legacy` +// // Encoding set to `base64` +// // Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'base64', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'base64', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'base64', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - type ExpectedParsedTransactionInstruction = Readonly<{ - parsed: { - info?: object; - type: string; - }; - program: string; - programId: Address; - }>; + > +>; - type ExpectedPartiallyDecodedTransactionInstruction = Readonly<{ - accounts: readonly Address[]; - data: Base58EncodedBytes; +type ExpectedParsedTransactionInstruction = Readonly<{ + parsed: { + info?: object; + type: string; + }; + program: string; + programId: Address; +}>; + +type ExpectedPartiallyDecodedTransactionInstruction = Readonly<{ + accounts: readonly Address[]; + data: Base58EncodedBytes; + programId: Address; +}>; + +type ExpectedTransactionInstructionForFullJsonParsed = + | ExpectedParsedTransactionInstruction + | ExpectedPartiallyDecodedTransactionInstruction; + +type ExpectedMetaForFullJsonParsedBase = { + computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; + err: TransactionError | null; + fee: LamportsUnsafeBeyond2Pow53Minus1; + innerInstructions: readonly Readonly<{ + index: number; + instructions: readonly ExpectedTransactionInstructionForFullJsonParsed[]; + }>[]; + logMessages: readonly string[] | null; + postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + postTokenBalances?: readonly TokenBalance[]; + preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + preTokenBalances?: readonly TokenBalance[]; + returnData?: Readonly<{ + data: Base64EncodedDataResponse; programId: Address; }>; + rewards: readonly Reward[] | null; + status: TransactionStatus; +}; - type ExpectedTransactionInstructionForFullJsonParsed = - | ExpectedParsedTransactionInstruction - | ExpectedPartiallyDecodedTransactionInstruction; - - type ExpectedMetaForFullJsonParsedBase = { - computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; - err: TransactionError | null; - fee: LamportsUnsafeBeyond2Pow53Minus1; - innerInstructions: readonly Readonly<{ - index: number; - instructions: readonly ExpectedTransactionInstructionForFullJsonParsed[]; - }>[]; - logMessages: readonly string[] | null; - postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - postTokenBalances?: readonly TokenBalance[]; - preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - preTokenBalances?: readonly TokenBalance[]; - returnData?: Readonly<{ - data: Base64EncodedDataResponse; - programId: Address; - }>; - rewards: readonly Reward[] | null; - status: TransactionStatus; +type ExpectedMetaForFullJsonParsedLoadedAddresses = Readonly<{ + loadedAddresses: { + readonly: readonly Address[]; + writable: readonly Address[]; }; - - type ExpectedMetaForFullJsonParsedLoadedAddresses = Readonly<{ - loadedAddresses: { - readonly: readonly Address[]; - writable: readonly Address[]; - }; - }>; - - type ExpectedTransactionForFullJsonParsedBase = { - message: { - header: { - numReadonlySignedAccounts: number; - numReadonlyUnsignedAccounts: number; - numRequiredSignatures: number; - }; - instructions: readonly ExpectedTransactionInstructionForFullJsonParsed[]; - recentBlockhash: Blockhash; +}>; + +type ExpectedTransactionForFullJsonParsedBase = { + message: { + header: { + numReadonlySignedAccounts: number; + numReadonlyUnsignedAccounts: number; + numRequiredSignatures: number; }; - signatures: readonly Base58EncodedBytes[]; + instructions: readonly ExpectedTransactionInstructionForFullJsonParsed[]; + recentBlockhash: Blockhash; }; + signatures: readonly Base58EncodedBytes[]; +}; - type ExpectedTransactionForFullJsonParsedLegacy = { - meta: ExpectedMetaForFullJsonParsedBase | null; - transaction: ExpectedTransactionForFullJsonParsedBase & { - message: Readonly<{ - accountKeys: readonly Readonly<{ - pubkey: string; - signer: boolean; - source: 'transaction'; - writable: boolean; - }>[]; - }>; - }; +type ExpectedTransactionForFullJsonParsedLegacy = { + meta: ExpectedMetaForFullJsonParsedBase | null; + transaction: ExpectedTransactionForFullJsonParsedBase & { + message: Readonly<{ + accountKeys: readonly Readonly<{ + pubkey: string; + signer: boolean; + source: 'transaction'; + writable: boolean; + }>[]; + }>; }; +}; - type ExpectedTransactionForFullJsonParsedVersioned = { - meta: (ExpectedMetaForFullJsonParsedBase & ExpectedMetaForFullJsonParsedLoadedAddresses) | null; - transaction: ExpectedTransactionForFullJsonParsedBase & { - message: Readonly<{ - accountKeys: readonly Readonly<{ - pubkey: string; - signer: boolean; - source: 'lookupTable' | 'transaction'; - writable: boolean; - }>[]; - }>; - }; - version: TransactionVersion; +type ExpectedTransactionForFullJsonParsedVersioned = { + meta: (ExpectedMetaForFullJsonParsedBase & ExpectedMetaForFullJsonParsedLoadedAddresses) | null; + transaction: ExpectedTransactionForFullJsonParsedBase & { + message: Readonly<{ + accountKeys: readonly Readonly<{ + pubkey: string; + signer: boolean; + source: 'lookupTable' | 'transaction'; + writable: boolean; + }>[]; + }>; }; + version: TransactionVersion; +}; - // Seventeenth overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding set to `jsonParsed` - // Transaction details default to `full` - rpcSubscriptions.blockNotifications('all', { +// Seventeenth overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding set to `jsonParsed` +// Transaction details default to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'jsonParsed', + maxSupportedTransactionVersion: 0, + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'jsonParsed', maxSupportedTransactionVersion: 0, showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'jsonParsed', - maxSupportedTransactionVersion: 0, - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Eighteenth overload - // Rewards set to `false` - // Max supported transaction defaults to `legacy` - // Encoding set to `jsonParsed` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Eighteenth overload +// Rewards set to `false` +// Max supported transaction defaults to `legacy` +// Encoding set to `jsonParsed` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'jsonParsed', + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'jsonParsed', showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'jsonParsed', - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Nineteenth overload - // Rewards defaults to `true` - // Max supported transaction version set to 0 - // Encoding set to `jsonParsed` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Nineteenth overload +// Rewards defaults to `true` +// Max supported transaction version set to 0 +// Encoding set to `jsonParsed` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'jsonParsed', + maxSupportedTransactionVersion: 0, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'jsonParsed', maxSupportedTransactionVersion: 0, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'jsonParsed', - maxSupportedTransactionVersion: 0, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twentieth overload - // Rewards defaults to `true` - // Max supported transaction defaults to `legacy` - // Encoding set to `jsonParsed` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Twentieth overload +// Rewards defaults to `true` +// Max supported transaction defaults to `legacy` +// Encoding set to `jsonParsed` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'jsonParsed', +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'jsonParsed', - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'jsonParsed', - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - type ExpectedTransactionInstructionForFullJson = { - accounts: readonly number[]; - data: Base58EncodedBytes; - programIdIndex: number; - }; + > +>; - type ExpectedMetaForFullJsonBase = { - computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; - err: TransactionError | null; - fee: LamportsUnsafeBeyond2Pow53Minus1; - innerInstructions: readonly Readonly<{ - index: number; - instructions: readonly ExpectedTransactionInstructionForFullJson[]; - }>[]; - logMessages: readonly string[] | null; - postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - postTokenBalances?: readonly TokenBalance[]; - preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; - preTokenBalances?: readonly TokenBalance[]; - returnData?: Readonly<{ - data: Base64EncodedDataResponse; - programId: Address; - }>; - rewards: readonly Reward[] | null; - status: TransactionStatus; - }; +type ExpectedTransactionInstructionForFullJson = { + accounts: readonly number[]; + data: Base58EncodedBytes; + programIdIndex: number; +}; - type ExpectedMetaForFullJsonLoadedAddresses = Readonly<{ - loadedAddresses: { - readonly: readonly Address[]; - writable: readonly Address[]; - }; +type ExpectedMetaForFullJsonBase = { + computeUnitsConsumed?: U64UnsafeBeyond2Pow53Minus1; + err: TransactionError | null; + fee: LamportsUnsafeBeyond2Pow53Minus1; + innerInstructions: readonly Readonly<{ + index: number; + instructions: readonly ExpectedTransactionInstructionForFullJson[]; + }>[]; + logMessages: readonly string[] | null; + postBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + postTokenBalances?: readonly TokenBalance[]; + preBalances: readonly LamportsUnsafeBeyond2Pow53Minus1[]; + preTokenBalances?: readonly TokenBalance[]; + returnData?: Readonly<{ + data: Base64EncodedDataResponse; + programId: Address; }>; + rewards: readonly Reward[] | null; + status: TransactionStatus; +}; - type ExpectedTransactionForFullJsonBase = { - message: { - accountKeys: readonly Address[]; - header: { - numReadonlySignedAccounts: number; - numReadonlyUnsignedAccounts: number; - numRequiredSignatures: number; - }; - instructions: readonly ExpectedTransactionInstructionForFullJson[]; - recentBlockhash: Blockhash; +type ExpectedMetaForFullJsonLoadedAddresses = Readonly<{ + loadedAddresses: { + readonly: readonly Address[]; + writable: readonly Address[]; + }; +}>; + +type ExpectedTransactionForFullJsonBase = { + message: { + accountKeys: readonly Address[]; + header: { + numReadonlySignedAccounts: number; + numReadonlyUnsignedAccounts: number; + numRequiredSignatures: number; }; - signatures: readonly Base58EncodedBytes[]; + instructions: readonly ExpectedTransactionInstructionForFullJson[]; + recentBlockhash: Blockhash; }; + signatures: readonly Base58EncodedBytes[]; +}; - type ExpectedTransactionForFullJsonLegacy = { - meta: ExpectedMetaForFullJsonBase | null; - transaction: ExpectedTransactionForFullJsonBase; - }; +type ExpectedTransactionForFullJsonLegacy = { + meta: ExpectedMetaForFullJsonBase | null; + transaction: ExpectedTransactionForFullJsonBase; +}; - type ExpectedTransactionForFullJsonVersioned = { - meta: (ExpectedMetaForFullJsonBase & ExpectedMetaForFullJsonLoadedAddresses) | null; - transaction: ExpectedTransactionForFullJsonBase; - version: TransactionVersion; - }; +type ExpectedTransactionForFullJsonVersioned = { + meta: (ExpectedMetaForFullJsonBase & ExpectedMetaForFullJsonLoadedAddresses) | null; + transaction: ExpectedTransactionForFullJsonBase; + version: TransactionVersion; +}; - // Twenty-first overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding defaults to `json` - // Transaction details default to `full` - rpcSubscriptions.blockNotifications('all', { +// Twenty-first overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding defaults to `json` +// Transaction details default to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + maxSupportedTransactionVersion: 0, + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs maxSupportedTransactionVersion: 0, showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - maxSupportedTransactionVersion: 0, - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twenty-first overload - // Rewards set to `false` - // Max supported transaction version set to 0 - // Encoding set to `json` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Twenty-first overload +// Rewards set to `false` +// Max supported transaction version set to 0 +// Encoding set to `json` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + encoding: 'json', + maxSupportedTransactionVersion: 0, + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs encoding: 'json', maxSupportedTransactionVersion: 0, showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - encoding: 'json', - maxSupportedTransactionVersion: 0, - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twenty-second overload - // Rewards set to `false` - // Max supported transaction defaults to `legacy` - // Encoding defaults to `json` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Twenty-second overload +// Rewards set to `false` +// Max supported transaction defaults to `legacy` +// Encoding defaults to `json` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + showRewards: false, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs showRewards: false, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - showRewards: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twenty-third overload - // Rewards defaults to `true` - // Max supported transaction version set to 0 - // Encoding defaults to `json` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all', { + > +>; + +// Twenty-third overload +// Rewards defaults to `true` +// Max supported transaction version set to 0 +// Encoding defaults to `json` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all', { + // No extra configs + maxSupportedTransactionVersion: 0, +}) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { // No extra configs maxSupportedTransactionVersion: 0, - }) satisfies PendingRpcSubscriptionsRequest< + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { - // No extra configs - maxSupportedTransactionVersion: 0, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twenty-fourth overload - // Rewards defaults to `true` - // Max supported transaction defaults to `legacy` - // Encoding defaults to `json` - // Transaction details defaults to `full` - rpcSubscriptions.blockNotifications('all') satisfies PendingRpcSubscriptionsRequest< + > +>; + +// Twenty-fourth overload +// Rewards defaults to `true` +// Max supported transaction defaults to `legacy` +// Encoding defaults to `json` +// Transaction details defaults to `full` +rpcSubscriptions.blockNotifications('all') satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions.blockNotifications('all').subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all') - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; - - // Twenty-fourth overload with configs - rpcSubscriptions.blockNotifications('all', { commitment: 'confirmed' }) satisfies PendingRpcSubscriptionsRequest< + > +>; + +// Twenty-fourth overload with configs +rpcSubscriptions.blockNotifications('all', { commitment: 'confirmed' }) satisfies PendingRpcSubscriptionsRequest< + BlockNotificationsApiNotificationBase & + BlockNotificationsApiNotificationWithRewards & + BlockNotificationsApiNotificationWithTransactions +>; +rpcSubscriptions + .blockNotifications('all', { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< BlockNotificationsApiNotificationBase & BlockNotificationsApiNotificationWithRewards & BlockNotificationsApiNotificationWithTransactions - >; - rpcSubscriptions - .blockNotifications('all', { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - BlockNotificationsApiNotificationBase & - BlockNotificationsApiNotificationWithRewards & - BlockNotificationsApiNotificationWithTransactions - > - >; -}; + > +>; diff --git a/packages/rpc-subscriptions-api/src/__typetests__/logs-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/logs-notifications-type-test.ts index 629b84af1f4f..aac8da0a576b 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/logs-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/logs-notifications-type-test.ts @@ -7,49 +7,47 @@ import type { SolanaRpcResponse, TransactionError } from '@solana/rpc-types'; import type { LogsNotificationsApi } from '../logs-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; +const rpcSubscriptions = null as unknown as RpcSubscriptions; - type TNotification = SolanaRpcResponse< - Readonly<{ - err: TransactionError | null; - logs: readonly string[] | null; - signature: Signature; - }> - >; - rpcSubscriptions.logsNotifications('all') satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .logsNotifications('all') - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.logsNotifications('all', { - commitment: 'confirmed', - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .logsNotifications('all', { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; +type TNotification = SolanaRpcResponse< + Readonly<{ + err: TransactionError | null; + logs: readonly string[] | null; + signature: Signature; + }> +>; +rpcSubscriptions.logsNotifications('all') satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions.logsNotifications('all').subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; +rpcSubscriptions.logsNotifications('all', { + commitment: 'confirmed', +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .logsNotifications('all', { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.logsNotifications('allWithVotes') satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .logsNotifications('allWithVotes') - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.logsNotifications('allWithVotes', { - commitment: 'confirmed', - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .logsNotifications('allWithVotes', { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; +rpcSubscriptions.logsNotifications('allWithVotes') satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .logsNotifications('allWithVotes') + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; +rpcSubscriptions.logsNotifications('allWithVotes', { + commitment: 'confirmed', +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .logsNotifications('allWithVotes', { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.logsNotifications({ - mentions: ['11111111111111111111111111111111' as Address], - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .logsNotifications({ mentions: ['11111111111111111111111111111111' as Address] }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.logsNotifications( - { mentions: ['11111111111111111111111111111111' as Address] }, - { commitment: 'confirmed' }, - ) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .logsNotifications({ mentions: ['11111111111111111111111111111111' as Address] }, { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; -}; +rpcSubscriptions.logsNotifications({ + mentions: ['11111111111111111111111111111111' as Address], +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .logsNotifications({ mentions: ['11111111111111111111111111111111' as Address] }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; +rpcSubscriptions.logsNotifications( + { mentions: ['11111111111111111111111111111111' as Address] }, + { commitment: 'confirmed' }, +) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .logsNotifications({ mentions: ['11111111111111111111111111111111' as Address] }, { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; diff --git a/packages/rpc-subscriptions-api/src/__typetests__/program-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/program-notifications-type-test.ts index d15f17fe49d7..f85c81b4a01a 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/program-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/program-notifications-type-test.ts @@ -15,25 +15,36 @@ import type { import type { ProgramNotificationsApi } from '../program-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; - // See scripts/fixtures/GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G.json - // Note: Only using this address for type tests. It's not actually a program. - const programId = - 'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G' as Address<'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G'>; +const rpcSubscriptions = null as unknown as RpcSubscriptions; +// See scripts/fixtures/GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G.json +// Note: Only using this address for type tests. It's not actually a program. +const programId = + 'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G' as Address<'GQE2yjns7SKKuMc89tveBDpzYHwXfeuB2PGAbGaPWc6G'>; - type TNotificationBase = Readonly<{ - account: Readonly<{ - executable: boolean; - lamports: LamportsUnsafeBeyond2Pow53Minus1; - owner: Address; - rentEpoch: U64UnsafeBeyond2Pow53Minus1; - }>; - pubkey: Address; +type TNotificationBase = Readonly<{ + account: Readonly<{ + executable: boolean; + lamports: LamportsUnsafeBeyond2Pow53Minus1; + owner: Address; + rentEpoch: U64UnsafeBeyond2Pow53Minus1; }>; + pubkey: Address; +}>; - // No optional configs - rpcSubscriptions.programNotifications(programId) satisfies PendingRpcSubscriptionsRequest< +// No optional configs +rpcSubscriptions.programNotifications(programId) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + account: { + data: Base58EncodedBytes; + }; + } + > +>; +rpcSubscriptions + .programNotifications(programId) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { account: { @@ -41,24 +52,24 @@ async () => { }; } > - >; - rpcSubscriptions - .programNotifications(programId) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - account: { - data: Base58EncodedBytes; - }; - } - > - > - >; - // With optional configs - rpcSubscriptions.programNotifications(programId, { - commitment: 'confirmed', - }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// With optional configs +rpcSubscriptions.programNotifications(programId, { + commitment: 'confirmed', +}) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + account: { + data: Base58EncodedBytes; + }; + } + > +>; +rpcSubscriptions + .programNotifications(programId, { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { account: { @@ -66,22 +77,22 @@ async () => { }; } > - >; - rpcSubscriptions - .programNotifications(programId, { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - account: { - data: Base58EncodedBytes; - }; - } - > - > - >; - // Base58 encoded data - rpcSubscriptions.programNotifications(programId, { encoding: 'base58' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// Base58 encoded data +rpcSubscriptions.programNotifications(programId, { encoding: 'base58' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + account: { + data: Base58EncodedDataResponse; + }; + } + > +>; +rpcSubscriptions + .programNotifications(programId, { encoding: 'base58' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { account: { @@ -89,22 +100,22 @@ async () => { }; } > - >; - rpcSubscriptions - .programNotifications(programId, { encoding: 'base58' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - account: { - data: Base58EncodedDataResponse; - }; - } - > - > - >; - // Base64 encoded data - rpcSubscriptions.programNotifications(programId, { encoding: 'base64' }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// Base64 encoded data +rpcSubscriptions.programNotifications(programId, { encoding: 'base64' }) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + account: { + data: Base64EncodedDataResponse; + }; + } + > +>; +rpcSubscriptions + .programNotifications(programId, { encoding: 'base64' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { account: { @@ -112,24 +123,24 @@ async () => { }; } > - >; - rpcSubscriptions - .programNotifications(programId, { encoding: 'base64' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - account: { - data: Base64EncodedDataResponse; - }; - } - > - > - >; - // Base64 + ZSTD encoded data - rpcSubscriptions.programNotifications(programId, { - encoding: 'base64+zstd', - }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// Base64 + ZSTD encoded data +rpcSubscriptions.programNotifications(programId, { + encoding: 'base64+zstd', +}) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + account: { + data: Base64EncodedZStdCompressedDataResponse; + }; + } + > +>; +rpcSubscriptions + .programNotifications(programId, { encoding: 'base64+zstd' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { account: { @@ -137,24 +148,30 @@ async () => { }; } > - >; - rpcSubscriptions - .programNotifications(programId, { encoding: 'base64+zstd' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - account: { - data: Base64EncodedZStdCompressedDataResponse; - }; - } - > - > - >; - // JSON parsed data - rpcSubscriptions.programNotifications(programId, { - encoding: 'jsonParsed', - }) satisfies PendingRpcSubscriptionsRequest< + > +>; +// JSON parsed data +rpcSubscriptions.programNotifications(programId, { + encoding: 'jsonParsed', +}) satisfies PendingRpcSubscriptionsRequest< + SolanaRpcResponse< + TNotificationBase & { + account: { + data: + | Base64EncodedDataResponse + | Readonly<{ + parsed: unknown; + program: string; + space: U64UnsafeBeyond2Pow53Minus1; + }>; + }; + } + > +>; +rpcSubscriptions + .programNotifications(programId, { encoding: 'jsonParsed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable< SolanaRpcResponse< TNotificationBase & { account: { @@ -168,66 +185,47 @@ async () => { }; } > - >; - rpcSubscriptions - .programNotifications(programId, { encoding: 'jsonParsed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable< - SolanaRpcResponse< - TNotificationBase & { - account: { - data: - | Base64EncodedDataResponse - | Readonly<{ - parsed: unknown; - program: string; - space: U64UnsafeBeyond2Pow53Minus1; - }>; - }; - } - > - > - >; + > +>; - // Filters - ({ - filters: [ - { - bytes: 'bytes' as Base58EncodedBytes, - encoding: 'base58', - offset: 0n as U64UnsafeBeyond2Pow53Minus1, - }, - ], - }) satisfies Parameters['programNotifications']>[1]; - // Can't flop them - ({ - filters: [ - { - // @ts-expect-error Can't flop them - bytes: 'bytes' as Base58EncodedBytes, - encoding: 'base64', - offset: 0n as U64UnsafeBeyond2Pow53Minus1, - }, - ], - }) satisfies Parameters['programNotifications']>[1]; - ({ - filters: [ - { - bytes: 'bytes' as Base64EncodedBytes, - encoding: 'base64', - offset: 0n as U64UnsafeBeyond2Pow53Minus1, - }, - ], - }) satisfies Parameters['programNotifications']>[1]; - // Can't flop them - ({ - filters: [ - { - // @ts-expect-error Can't flop them - bytes: 'bytes' as Base64EncodedBytes, - encoding: 'base58', - offset: 0n as U64UnsafeBeyond2Pow53Minus1, - }, - ], - }) satisfies Parameters['programNotifications']>[1]; -}; +// Filters +({ + filters: [ + { + bytes: 'bytes' as Base58EncodedBytes, + encoding: 'base58', + offset: 0n as U64UnsafeBeyond2Pow53Minus1, + }, + ], +}) satisfies Parameters['programNotifications']>[1]; +// Can't flop them +({ + filters: [ + { + // @ts-expect-error Can't flop them + bytes: 'bytes' as Base58EncodedBytes, + encoding: 'base64', + offset: 0n as U64UnsafeBeyond2Pow53Minus1, + }, + ], +}) satisfies Parameters['programNotifications']>[1]; +({ + filters: [ + { + bytes: 'bytes' as Base64EncodedBytes, + encoding: 'base64', + offset: 0n as U64UnsafeBeyond2Pow53Minus1, + }, + ], +}) satisfies Parameters['programNotifications']>[1]; +// Can't flop them +({ + filters: [ + { + // @ts-expect-error Can't flop them + bytes: 'bytes' as Base64EncodedBytes, + encoding: 'base58', + offset: 0n as U64UnsafeBeyond2Pow53Minus1, + }, + ], +}) satisfies Parameters['programNotifications']>[1]; diff --git a/packages/rpc-subscriptions-api/src/__typetests__/root-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/root-notifications-type-test.ts index 9ad57e44874b..1de4714ce333 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/root-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/root-notifications-type-test.ts @@ -5,15 +5,13 @@ import type { Slot } from '@solana/rpc-types'; import type { RootNotificationsApi } from '../root-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; +const rpcSubscriptions = null as unknown as RpcSubscriptions; - type TNotification = Slot; - rpcSubscriptions.rootNotifications() satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions.rootNotifications().subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; +type TNotification = Slot; +rpcSubscriptions.rootNotifications() satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions.rootNotifications().subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; - // @ts-expect-error Takes no params. - rpcSubscriptions.rootNotifications({ commitment: 'finalized' }); -}; +// @ts-expect-error Takes no params. +rpcSubscriptions.rootNotifications({ commitment: 'finalized' }); diff --git a/packages/rpc-subscriptions-api/src/__typetests__/signature-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/signature-notifications-type-test.ts index e0419995aa76..d48d115618d2 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/signature-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/signature-notifications-type-test.ts @@ -6,71 +6,61 @@ import type { SolanaRpcResponse, TransactionError } from '@solana/rpc-types'; import type { SignatureNotificationsApi } from '../signature-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; +const rpcSubscriptions = null as unknown as RpcSubscriptions; - type TNotificationReceived = SolanaRpcResponse>; - type TNotificationProcessed = SolanaRpcResponse< - Readonly<{ - err: TransactionError | null; - }> - >; +type TNotificationReceived = SolanaRpcResponse>; +type TNotificationProcessed = SolanaRpcResponse< + Readonly<{ + err: TransactionError | null; + }> +>; - rpcSubscriptions.signatureNotifications( - 'xxxxx' as Signature, - ) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .signatureNotifications('xxxxx' as Signature) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; +rpcSubscriptions.signatureNotifications( + 'xxxxx' as Signature, +) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .signatureNotifications('xxxxx' as Signature) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { - commitment: 'confirmed', - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .signatureNotifications('xxxxx' as Signature, { commitment: 'confirmed' }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; +rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { + commitment: 'confirmed', +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .signatureNotifications('xxxxx' as Signature, { commitment: 'confirmed' }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { +rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { + commitment: 'confirmed', + enableReceivedNotification: false, +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .signatureNotifications('xxxxx' as Signature, { commitment: 'confirmed', enableReceivedNotification: false, - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .signatureNotifications('xxxxx' as Signature, { - commitment: 'confirmed', - enableReceivedNotification: false, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; - rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { +rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { + commitment: 'confirmed', + enableReceivedNotification: true, +}) satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions + .signatureNotifications('xxxxx' as Signature, { commitment: 'confirmed', enableReceivedNotification: true, - }) satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .signatureNotifications('xxxxx' as Signature, { - commitment: 'confirmed', - enableReceivedNotification: true, - }) - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; - rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { + }) + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; +rpcSubscriptions.signatureNotifications('xxxxx' as Signature, { + commitment: 'confirmed', + enableReceivedNotification: true, + // @ts-expect-error Should have both notification types +}) satisfies PendingRpcSubscription; +rpcSubscriptions + .signatureNotifications('xxxxx' as Signature, { commitment: 'confirmed', enableReceivedNotification: true, - // @ts-expect-error Should have both notification types - }) satisfies PendingRpcSubscription; - rpcSubscriptions - .signatureNotifications('xxxxx' as Signature, { - commitment: 'confirmed', - enableReceivedNotification: true, - }) - // @ts-expect-error Should have both notification types - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; -}; + }) + // @ts-expect-error Should have both notification types + .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; diff --git a/packages/rpc-subscriptions-api/src/__typetests__/slots-updates-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/slots-updates-notifications-type-test.ts index 3ec941df0d1f..3269effcbd1e 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/slots-updates-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/slots-updates-notifications-type-test.ts @@ -5,27 +5,18 @@ import type { Slot, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; import type { SlotsUpdatesNotificationsApi } from '../slots-updates-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; +const rpcSubscriptions = null as unknown as RpcSubscriptions; - type TNotification = Readonly<{ - parent?: Slot; - slot: Slot; - timestamp: U64UnsafeBeyond2Pow53Minus1; - type: - | 'completed' - | 'createdBank' - | 'dead' - | 'firstShredReceived' - | 'frozen' - | 'optimisticConfirmation' - | 'root'; - }>; - rpcSubscriptions.slotsUpdatesNotifications() satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions - .slotsUpdatesNotifications() - .subscribe({ abortSignal: new AbortController().signal }) satisfies Promise>; +type TNotification = Readonly<{ + parent?: Slot; + slot: Slot; + timestamp: U64UnsafeBeyond2Pow53Minus1; + type: 'completed' | 'createdBank' | 'dead' | 'firstShredReceived' | 'frozen' | 'optimisticConfirmation' | 'root'; +}>; +rpcSubscriptions.slotsUpdatesNotifications() satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions.slotsUpdatesNotifications().subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; - // @ts-expect-error Takes no params. - rpcSubscriptions.slotsUpdatesNotifications({ commitment: 'finalized' }); -}; +// @ts-expect-error Takes no params. +rpcSubscriptions.slotsUpdatesNotifications({ commitment: 'finalized' }); diff --git a/packages/rpc-subscriptions-api/src/__typetests__/vote-notifications-type-test.ts b/packages/rpc-subscriptions-api/src/__typetests__/vote-notifications-type-test.ts index 011056c9cc86..7ff0a958b705 100644 --- a/packages/rpc-subscriptions-api/src/__typetests__/vote-notifications-type-test.ts +++ b/packages/rpc-subscriptions-api/src/__typetests__/vote-notifications-type-test.ts @@ -7,21 +7,19 @@ import type { Blockhash, Slot, UnixTimestamp } from '@solana/rpc-types'; import { VoteNotificationsApi } from '../vote-notifications'; -async () => { - const rpcSubscriptions = null as unknown as RpcSubscriptions; +const rpcSubscriptions = null as unknown as RpcSubscriptions; - type VoteNotificationsApiNotification = Readonly<{ - hash: Blockhash; - signature: Signature; - slots: readonly Slot[]; - timestamp: UnixTimestamp | null; - votePubkey: Address; - }>; - rpcSubscriptions.voteNotifications() satisfies PendingRpcSubscriptionsRequest; - rpcSubscriptions.voteNotifications().subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< - AsyncIterable - >; +type VoteNotificationsApiNotification = Readonly<{ + hash: Blockhash; + signature: Signature; + slots: readonly Slot[]; + timestamp: UnixTimestamp | null; + votePubkey: Address; +}>; +rpcSubscriptions.voteNotifications() satisfies PendingRpcSubscriptionsRequest; +rpcSubscriptions.voteNotifications().subscribe({ abortSignal: new AbortController().signal }) satisfies Promise< + AsyncIterable +>; - // @ts-expect-error Takes no params. - rpcSubscriptions.voteNotifications({ commitment: 'finalized' }); -}; +// @ts-expect-error Takes no params. +rpcSubscriptions.voteNotifications({ commitment: 'finalized' }); diff --git a/packages/rpc-subscriptions-spec/src/__tests__/rpc-subscription-test.ts b/packages/rpc-subscriptions-spec/src/__tests__/rpc-subscription-test.ts index 7e0330d2426a..9f0a3bd7e756 100644 --- a/packages/rpc-subscriptions-spec/src/__tests__/rpc-subscription-test.ts +++ b/packages/rpc-subscriptions-spec/src/__tests__/rpc-subscription-test.ts @@ -65,7 +65,7 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('returns from the iterator when the connection iterator returns', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: 42 /* subscription id */ }; + yield Promise.resolve({ id: 0, result: 42 /* subscription id */ }); return; }); const thingNotifications = await rpc @@ -81,7 +81,7 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('throws from the iterator when the connection iterator throws', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: 42 /* subscription id */ }; + yield Promise.resolve({ id: 0, result: 42 /* subscription id */ }); throw new Error('o no'); }); const thingNotifications = await rpc @@ -142,8 +142,7 @@ describe('JSON-RPC 2.0 Subscriptions', () => { }), ); }); - it('does not send an unsubscribe request to the transport when aborted if the subscription has not yet been established', async () => { - expect.assertions(1); + it('does not send an unsubscribe request to the transport when aborted if the subscription has not yet been established', () => { jest.useFakeTimers(); const abortController = new AbortController(); rpc.thingNotifications(123).subscribe({ abortSignal: abortController.signal }); @@ -209,9 +208,9 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('delivers only messages destined for a particular subscription', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: 42 /* subscription id */ }; - yield { params: { result: 123, subscription: 41 } }; - yield { params: { result: 456, subscription: 42 } }; + yield Promise.resolve({ id: 0, result: 42 /* subscription id */ }); + yield Promise.resolve({ params: { result: 123, subscription: 41 } }); + yield Promise.resolve({ params: { result: 456, subscription: 42 } }); }); const thingNotifications = await rpc .thingNotifications() @@ -224,7 +223,7 @@ describe('JSON-RPC 2.0 Subscriptions', () => { async subscriptionId => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: subscriptionId /* subscription id */ }; + yield Promise.resolve({ id: 0, result: subscriptionId /* subscription id */ }); }); const thingNotificationsPromise = rpc .thingNotifications() @@ -253,7 +252,7 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('fatals when the server fails to respond with a subscription id', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: undefined /* subscription id */ }; + yield Promise.resolve({ id: 0, result: undefined /* subscription id */ }); }); const subscribePromise = rpc.thingNotifications().subscribe({ abortSignal: new AbortController().signal }); await expect(subscribePromise).rejects.toThrow( @@ -263,10 +262,10 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('fatals when the server responds with an error', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { + yield Promise.resolve({ error: { code: 123, message: 'o no' }, id: 0, - }; + }); }); const subscribePromise = rpc.thingNotifications().subscribe({ abortSignal: new AbortController().signal }); await expect(subscribePromise).rejects.toThrow(new SolanaError(123 as SolanaErrorCode, undefined)); @@ -342,8 +341,8 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('calls the response processor with the response from the JSON-RPC 2.0 endpoint', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: 42 /* subscription id */ }; - yield { params: { result: 123, subscription: 42 } }; + yield Promise.resolve({ id: 0, result: 42 /* subscription id */ }); + yield Promise.resolve({ params: { result: 123, subscription: 42 } }); }); const thingNotifications = await rpc .thingNotifications() @@ -354,8 +353,8 @@ describe('JSON-RPC 2.0 Subscriptions', () => { it('returns the processed response', async () => { expect.assertions(1); iterable.mockImplementation(async function* () { - yield { id: 0, result: 42 /* subscription id */ }; - yield { params: { result: 123, subscription: 42 } }; + yield Promise.resolve({ id: 0, result: 42 /* subscription id */ }); + yield Promise.resolve({ params: { result: 123, subscription: 42 } }); }); const thingNotifications = await rpc .thingNotifications() diff --git a/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-connection-test.ts b/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-connection-test.ts index 6fda72019746..05fcb9f5af70 100644 --- a/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-connection-test.ts +++ b/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-connection-test.ts @@ -16,7 +16,7 @@ describe('createWebSocketConnection', () => { const clients = ws.server.clients(); return clients[clients.length - 1]; } - beforeEach(async () => { + beforeEach(() => { ws = new WS('wss://fake', { jsonProtocol: true, }); @@ -76,7 +76,7 @@ describe('RpcWebSocketConnection', () => { const clients = ws.server.clients(); return clients[clients.length - 1]; } - beforeEach(async () => { + beforeEach(() => { abortController = new AbortController(); ws = new WS('wss://fake', { jsonProtocol: true, diff --git a/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-transport-test.ts b/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-transport-test.ts index 099c35cd1dbd..febf2d04d2ca 100644 --- a/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-transport-test.ts +++ b/packages/rpc-subscriptions-transport-websocket/src/__tests__/websocket-transport-test.ts @@ -40,7 +40,7 @@ describe('RpcSubscriptionsTransport', () => { let iterator: jest.Mock; let send: jest.Mock; let sendWebSocketMessage: RpcSubscriptionsTransport; - beforeEach(async () => { + beforeEach(() => { abortController = new AbortController(); iterator = jest.fn(); send = jest.fn(); @@ -95,12 +95,12 @@ describe('RpcSubscriptionsTransport', () => { }); it('throws if the signal is aborted after the socket connects but before the message is sent', async () => { expect.assertions(1); - jest.mocked(createWebSocketConnection).mockImplementation(async () => { + jest.mocked(createWebSocketConnection).mockImplementation(() => { abortController.abort(); - return { + return Promise.resolve({ [Symbol.asyncIterator]: iterator, send, - }; + }); }); const sendPromise = sendWebSocketMessage({ payload: 'hello', signal: abortController.signal }); await expect(sendPromise).rejects.toThrow('operation was aborted'); diff --git a/packages/rpc-subscriptions-transport-websocket/src/websocket-connection.ts b/packages/rpc-subscriptions-transport-websocket/src/websocket-connection.ts index 1f0a98dc43b0..aad56fbabe29 100644 --- a/packages/rpc-subscriptions-transport-websocket/src/websocket-connection.ts +++ b/packages/rpc-subscriptions-transport-websocket/src/websocket-connection.ts @@ -40,7 +40,7 @@ export async function createWebSocketConnection({ signal, url, }: Config): Promise { - return new Promise((resolve, reject) => { + return await new Promise((resolve, reject) => { signal.addEventListener('abort', handleAbort, { once: true }); const iteratorState: Map = new Map(); function errorAndClearAllIteratorStates(reason: unknown) { diff --git a/packages/rpc-subscriptions/src/__tests__/cached-abortable-iterable-test.ts b/packages/rpc-subscriptions/src/__tests__/cached-abortable-iterable-test.ts index becc7e478f9f..07822d3bf3da 100644 --- a/packages/rpc-subscriptions/src/__tests__/cached-abortable-iterable-test.ts +++ b/packages/rpc-subscriptions/src/__tests__/cached-abortable-iterable-test.ts @@ -208,8 +208,7 @@ describe('getCachedAbortableIterableFactory', () => { await jest.runAllTimersAsync(); expect(onCacheHit).toHaveBeenCalledWith(iterable, 'B'); }); - it('calls `onCacheHit` in the same runloop when the cached iterable is already resolved', async () => { - expect.assertions(1); + it('calls `onCacheHit` in the same runloop when the cached iterable is already resolved', () => { const iterable = asyncGenerator(); onCreateIterable.mockReturnValue(iterable); Promise.all([factory('A'), factory('B')]); diff --git a/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-autopinger-test.ts b/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-autopinger-test.ts index f6379c15b777..bd3488cb8e80 100644 --- a/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-autopinger-test.ts +++ b/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-autopinger-test.ts @@ -18,6 +18,7 @@ describe('getWebSocketTransportWithAutoping', () => { send = jest.fn(); let resultPromise; mockInnerTransport = jest.fn(() => ({ + // eslint-disable-next-line @typescript-eslint/require-await async *[Symbol.asyncIterator]() { try { while (true) { diff --git a/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-coalescer-test.ts b/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-coalescer-test.ts index 6a65a4a03a17..f88dbce1855b 100644 --- a/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-coalescer-test.ts +++ b/packages/rpc-subscriptions/src/__tests__/rpc-subscriptions-coalescer-test.ts @@ -99,7 +99,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { it('publishes the same messages through both iterables', async () => { expect.assertions(2); asyncGenerator.mockImplementation(async function* () { - yield 'hello'; + yield Promise.resolve('hello'); }); const iterableA = await rpcSubscriptions .thingNotifications({ payload: 'hello' }) @@ -118,7 +118,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { it('aborting a subscription causes it to return', async () => { expect.assertions(1); asyncGenerator.mockImplementation(async function* () { - yield 'hello'; + yield Promise.resolve('hello'); }); const abortController = new AbortController(); const iterable = await rpcSubscriptions @@ -132,7 +132,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { it('aborting one subscription does not abort the other', async () => { expect.assertions(1); asyncGenerator.mockImplementation(async function* () { - yield 'hello'; + yield Promise.resolve('hello'); }); const abortControllerA = new AbortController(); await rpcSubscriptions @@ -219,7 +219,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { expect.assertions(2); subscribe.mockResolvedValueOnce({ async *[Symbol.asyncIterator]() { - yield 'hello'; + yield Promise.resolve('hello'); }, }); const iterableA = await rpcSubscriptions @@ -227,7 +227,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { .subscribe({ abortSignal: new AbortController().signal }); subscribe.mockResolvedValueOnce({ async *[Symbol.asyncIterator]() { - yield 'world'; + yield Promise.resolve('world'); }, }); const iterableB = await rpcSubscriptions @@ -244,7 +244,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { it('aborting a subscription causes it to return', async () => { expect.assertions(1); asyncGenerator.mockImplementation(async function* () { - yield 'hello'; + yield Promise.resolve('hello'); }); const abortController = new AbortController(); const iterable = await rpcSubscriptions @@ -258,7 +258,7 @@ describe('getRpcSubscriptionsWithSubscriptionCoalescing', () => { it('aborting one subscription does not abort the other', async () => { expect.assertions(1); asyncGenerator.mockImplementation(async function* () { - yield 'hello'; + yield Promise.resolve('hello'); }); const abortControllerA = new AbortController(); await rpcSubscriptions diff --git a/packages/rpc-transport-http/src/__tests__/http-transport-abort-test.ts b/packages/rpc-transport-http/src/__tests__/http-transport-abort-test.ts index 68df91c120ea..07779f87e636 100644 --- a/packages/rpc-transport-http/src/__tests__/http-transport-abort-test.ts +++ b/packages/rpc-transport-http/src/__tests__/http-transport-abort-test.ts @@ -71,7 +71,7 @@ describe('createHttpTransport and `AbortSignal`', () => { it('resolves with the response', async () => { expect.assertions(1); jest.mocked(fetchSpy).mockResolvedValueOnce({ - json: async () => ({ ok: true }), + json: () => ({ ok: true }), ok: true, } as unknown as Response); const sendPromise = makeHttpRequest({ payload: 123, signal: abortSignal }); diff --git a/packages/rpc-transport-http/src/__tests__/http-transport-test.ts b/packages/rpc-transport-http/src/__tests__/http-transport-test.ts index a3476f1aef17..74551ff7eed8 100644 --- a/packages/rpc-transport-http/src/__tests__/http-transport-test.ts +++ b/packages/rpc-transport-http/src/__tests__/http-transport-test.ts @@ -45,7 +45,7 @@ describe('createHttpTransport', () => { describe('when the endpoint returns a well-formed JSON response', () => { beforeEach(() => { fetchSpy.mockResolvedValue({ - json: async () => ({ ok: true }), + json: () => ({ ok: true }), ok: true, }); }); diff --git a/packages/signers/src/__tests__/keypair-signer-test.ts b/packages/signers/src/__tests__/keypair-signer-test.ts index 8bd196f3f0c1..f7728fe348a3 100644 --- a/packages/signers/src/__tests__/keypair-signer-test.ts +++ b/packages/signers/src/__tests__/keypair-signer-test.ts @@ -37,8 +37,8 @@ describe('isKeyPairSigner', () => { const mySigner = { address: myAddress, keyPair: getMockCryptoKeyPair(), - signMessages: async () => [], - signTransactions: async () => [], + signMessages: () => Promise.resolve([]), + signTransactions: () => Promise.resolve([]), } satisfies KeyPairSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isKeyPairSigner(mySigner)).toBe(true); @@ -55,8 +55,8 @@ describe('assertIsKeyPairSigner', () => { const mySigner = { address: myAddress, keyPair: getMockCryptoKeyPair(), - signMessages: async () => [], - signTransactions: async () => [], + signMessages: () => Promise.resolve([]), + signTransactions: () => Promise.resolve([]), } satisfies KeyPairSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, { diff --git a/packages/signers/src/__tests__/message-modifying-signer-test.ts b/packages/signers/src/__tests__/message-modifying-signer-test.ts index c79d602f6b28..c1a589a23c73 100644 --- a/packages/signers/src/__tests__/message-modifying-signer-test.ts +++ b/packages/signers/src/__tests__/message-modifying-signer-test.ts @@ -12,7 +12,7 @@ describe('isMessageModifyingSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - modifyAndSignMessages: async () => [], + modifyAndSignMessages: () => Promise.resolve([]), } satisfies MessageModifyingSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isMessageModifyingSigner(mySigner)).toBe(true); @@ -26,7 +26,7 @@ describe('assertIsMessageModifyingSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - modifyAndSignMessages: async () => [], + modifyAndSignMessages: () => Promise.resolve([]), } satisfies MessageModifyingSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_MODIFYING_SIGNER, { diff --git a/packages/signers/src/__tests__/message-partial-signer-test.ts b/packages/signers/src/__tests__/message-partial-signer-test.ts index 0a59adb1b812..4f58808e3f92 100644 --- a/packages/signers/src/__tests__/message-partial-signer-test.ts +++ b/packages/signers/src/__tests__/message-partial-signer-test.ts @@ -8,7 +8,7 @@ describe('isMessagePartialSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - signMessages: async () => [], + signMessages: () => Promise.resolve([]), } satisfies MessagePartialSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isMessagePartialSigner(mySigner)).toBe(true); @@ -22,7 +22,7 @@ describe('assertIsMessagePartialSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - signMessages: async () => [], + signMessages: () => Promise.resolve([]), } satisfies MessagePartialSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_PARTIAL_SIGNER, { diff --git a/packages/signers/src/__tests__/message-signer-test.ts b/packages/signers/src/__tests__/message-signer-test.ts index 2f8be1316fce..7c0e87dd6699 100644 --- a/packages/signers/src/__tests__/message-signer-test.ts +++ b/packages/signers/src/__tests__/message-signer-test.ts @@ -8,11 +8,11 @@ describe('isMessageSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const myPartialSigner = { address: myAddress, - signMessages: async () => [], + signMessages: () => Promise.resolve([]), } satisfies MessageSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const myModifyingSigner = { address: myAddress, - modifyAndSignMessages: async () => [], + modifyAndSignMessages: () => Promise.resolve([]), } satisfies MessageSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isMessageSigner(myPartialSigner)).toBe(true); @@ -29,11 +29,11 @@ describe('assertIsMessageSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const myPartialSigner = { address: myAddress, - signMessages: async () => [], + signMessages: () => Promise.resolve([]), } satisfies MessageSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const myModifyingSigner = { address: myAddress, - modifyAndSignMessages: async () => [], + modifyAndSignMessages: () => Promise.resolve([]), } satisfies MessageSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_MESSAGE_SIGNER, { diff --git a/packages/signers/src/__tests__/sign-transaction-test.ts b/packages/signers/src/__tests__/sign-transaction-test.ts index f4fa6bf71dfc..20cc42850630 100644 --- a/packages/signers/src/__tests__/sign-transaction-test.ts +++ b/packages/signers/src/__tests__/sign-transaction-test.ts @@ -62,11 +62,11 @@ describe('partiallySignTransactionWithSigners', () => { // And mock implementations for both signers such that they append events to an array. const events: string[] = []; - signerA.modifyAndSignTransactions.mockImplementation(async (transactions: CompilableTransaction[]) => { + signerA.modifyAndSignTransactions.mockImplementation((transactions: CompilableTransaction[]) => { events.push('signerA'); return transactions.map(tx => ({ ...tx, signatures: { '1111': '1111_signature' } })); }); - signerB.signTransactions.mockImplementation(async (transactions: CompilableTransaction[]) => { + signerB.signTransactions.mockImplementation((transactions: CompilableTransaction[]) => { events.push('signerB'); return transactions.map(() => ({ '2222': '2222_signature' })); }); diff --git a/packages/signers/src/__tests__/transaction-modifying-signer-test.ts b/packages/signers/src/__tests__/transaction-modifying-signer-test.ts index 95294157fc3b..221d89323bfb 100644 --- a/packages/signers/src/__tests__/transaction-modifying-signer-test.ts +++ b/packages/signers/src/__tests__/transaction-modifying-signer-test.ts @@ -12,7 +12,7 @@ describe('isTransactionModifyingSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - modifyAndSignTransactions: async () => [], + modifyAndSignTransactions: () => Promise.resolve([]), } satisfies TransactionModifyingSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isTransactionModifyingSigner(mySigner)).toBe(true); @@ -26,7 +26,7 @@ describe('assertIsTransactionModifyingSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - modifyAndSignTransactions: async () => [], + modifyAndSignTransactions: () => Promise.resolve([]), } satisfies TransactionModifyingSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, { diff --git a/packages/signers/src/__tests__/transaction-partial-signer-test.ts b/packages/signers/src/__tests__/transaction-partial-signer-test.ts index 5e4d0bd43cc7..6db748c20ef2 100644 --- a/packages/signers/src/__tests__/transaction-partial-signer-test.ts +++ b/packages/signers/src/__tests__/transaction-partial-signer-test.ts @@ -12,7 +12,7 @@ describe('isTransactionPartialSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - signTransactions: async () => [], + signTransactions: () => Promise.resolve([]), } satisfies TransactionPartialSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isTransactionPartialSigner(mySigner)).toBe(true); @@ -26,7 +26,7 @@ describe('assertIsTransactionPartialSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - signTransactions: async () => [], + signTransactions: () => Promise.resolve([]), } satisfies TransactionPartialSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, { diff --git a/packages/signers/src/__tests__/transaction-sending-signer-test.ts b/packages/signers/src/__tests__/transaction-sending-signer-test.ts index 35a69502df06..7dc56e1309c0 100644 --- a/packages/signers/src/__tests__/transaction-sending-signer-test.ts +++ b/packages/signers/src/__tests__/transaction-sending-signer-test.ts @@ -12,7 +12,7 @@ describe('isTransactionSendingSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - signAndSendTransactions: async () => [], + signAndSendTransactions: () => Promise.resolve([]), } satisfies TransactionSendingSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isTransactionSendingSigner(mySigner)).toBe(true); @@ -26,7 +26,7 @@ describe('assertIsTransactionSendingSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const mySigner = { address: myAddress, - signAndSendTransactions: async () => [], + signAndSendTransactions: () => Promise.resolve([]), } satisfies TransactionSendingSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, { diff --git a/packages/signers/src/__tests__/transaction-signer-test.ts b/packages/signers/src/__tests__/transaction-signer-test.ts index d4ce07427178..b51fe6ffa25a 100644 --- a/packages/signers/src/__tests__/transaction-signer-test.ts +++ b/packages/signers/src/__tests__/transaction-signer-test.ts @@ -8,15 +8,15 @@ describe('isTransactionSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const myPartialSigner = { address: myAddress, - signTransactions: async () => [], + signTransactions: () => Promise.resolve([]), } satisfies TransactionSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const myModifyingSigner = { address: myAddress, - modifyAndSignTransactions: async () => [], + modifyAndSignTransactions: () => Promise.resolve([]), } satisfies TransactionSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const mySendingSigner = { address: myAddress, - signAndSendTransactions: async () => [], + signAndSendTransactions: () => Promise.resolve([]), } satisfies TransactionSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; expect(isTransactionSigner(myPartialSigner)).toBe(true); @@ -38,15 +38,15 @@ describe('assertIsTransactionSigner', () => { const myAddress = address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'); const myPartialSigner = { address: myAddress, - signTransactions: async () => [], + signTransactions: () => Promise.resolve([]), } satisfies TransactionSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const myModifyingSigner = { address: myAddress, - modifyAndSignTransactions: async () => [], + modifyAndSignTransactions: () => Promise.resolve([]), } satisfies TransactionSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const mySendingSigner = { address: myAddress, - signAndSendTransactions: async () => [], + signAndSendTransactions: () => Promise.resolve([]), } satisfies TransactionSigner<'Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'>; const expectedError = new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, { diff --git a/packages/signers/src/keypair-signer.ts b/packages/signers/src/keypair-signer.ts index 6545dfcfc72e..a8b7c6794d9e 100644 --- a/packages/signers/src/keypair-signer.ts +++ b/packages/signers/src/keypair-signer.ts @@ -61,10 +61,10 @@ export async function createSignerFromKeyPair(keyPair: CryptoKeyPair): Promise { - return createSignerFromKeyPair(await generateKeyPair()); + return await createSignerFromKeyPair(await generateKeyPair()); } /** Creates a signer capable of signing messages and transactions using the 64 bytes of a KeyPair. */ export async function createKeyPairSignerFromBytes(bytes: Uint8Array, extractable?: boolean): Promise { - return createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable)); + return await createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable)); } diff --git a/packages/signers/src/noop-signer.ts b/packages/signers/src/noop-signer.ts index 7f4e9fa87e81..0c743fb72ea0 100644 --- a/packages/signers/src/noop-signer.ts +++ b/packages/signers/src/noop-signer.ts @@ -11,8 +11,8 @@ export type NoopSigner = MessagePartialSigner< export function createNoopSigner(address: Address): NoopSigner { const out: NoopSigner = { address, - signMessages: async messages => messages.map(() => Object.freeze({})), - signTransactions: async transactions => transactions.map(() => Object.freeze({})), + signMessages: messages => Promise.resolve(messages.map(() => Object.freeze({}))), + signTransactions: transactions => Promise.resolve(transactions.map(() => Object.freeze({}))), }; return Object.freeze(out); diff --git a/packages/signers/src/sign-transaction.ts b/packages/signers/src/sign-transaction.ts index 52271a975498..d242ef5e0278 100644 --- a/packages/signers/src/sign-transaction.ts +++ b/packages/signers/src/sign-transaction.ts @@ -35,7 +35,12 @@ export async function partiallySignTransactionWithSigners< { identifySendingSigner: false }, ); - return signModifyingAndPartialTransactionSigners(transaction, modifyingSigners, partialSigners, config.abortSignal); + return await signModifyingAndPartialTransactionSigners( + transaction, + modifyingSigners, + partialSigners, + config.abortSignal, + ); } /** diff --git a/packages/sysvars/src/sysvar.ts b/packages/sysvars/src/sysvar.ts index c3cc7bb496bc..3353c5f1b60e 100644 --- a/packages/sysvars/src/sysvar.ts +++ b/packages/sysvars/src/sysvar.ts @@ -57,7 +57,7 @@ export async function fetchEncodedSysvarAccount( address: TAddress, config?: FetchAccountConfig, ): Promise> { - return fetchEncodedAccount(rpc, address, config); + return await fetchEncodedAccount(rpc, address, config); } /** @@ -71,5 +71,5 @@ export async function fetchJsonParsedSysvarAccount | MaybeEncodedAccount> { - return fetchJsonParsedAccount(rpc, address, config); + return await fetchJsonParsedAccount(rpc, address, config); } diff --git a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-blockheight-test.ts b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-blockheight-test.ts index 90e95582d72c..b392114f0c32 100644 --- a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-blockheight-test.ts +++ b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-blockheight-test.ts @@ -160,8 +160,7 @@ describe('createBlockHeightExceedencePromiseFactory', () => { expect(getEpochInfoMock).toHaveBeenCalledWith({ commitment }); }, ); - it('calls the abort signal passed to the epoch info fetcher when aborted', async () => { - expect.assertions(2); + it('calls the abort signal passed to the epoch info fetcher when aborted', () => { const abortController = new AbortController(); (async () => { try { @@ -181,8 +180,7 @@ describe('createBlockHeightExceedencePromiseFactory', () => { abortSignal: expect.objectContaining({ aborted: true }), }); }); - it('calls the abort signal passed to the slot subscription when aborted', async () => { - expect.assertions(2); + it('calls the abort signal passed to the slot subscription when aborted', () => { const abortController = new AbortController(); (async () => { try { diff --git a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-nonce-test.ts b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-nonce-test.ts index fd6257f1a560..654a3bee7933 100644 --- a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-nonce-test.ts +++ b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-nonce-test.ts @@ -68,8 +68,7 @@ describe('createNonceInvalidationPromiseFactory', () => { abortSignal: expect.objectContaining({ aborted: true }), }); }); - it('calls the abort signal passed to the account subscription when aborted', async () => { - expect.assertions(2); + it('calls the abort signal passed to the account subscription when aborted', () => { const abortController = new AbortController(); getNonceInvalidationPromise({ abortSignal: abortController.signal, diff --git a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-racer-test.ts b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-racer-test.ts index 9434be90e262..b4d5ff20a542 100644 --- a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-racer-test.ts +++ b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-racer-test.ts @@ -31,8 +31,7 @@ describe('raceStrategies', () => { expect.objectContaining({ abortSignal: expect.objectContaining({ aborted: true }) }), ); }); - it('aborts the `AbortController` passed to `getRecentSignatureConfirmationPromise` when the caller-supplied `AbortSignal` aborts', async () => { - expect.assertions(2); + it('aborts the `AbortController` passed to `getRecentSignatureConfirmationPromise` when the caller-supplied `AbortSignal` aborts', () => { const getRecentSignatureConfirmationPromise = jest.fn().mockReturnValue(FOREVER_PROMISE); const abortController = new AbortController(); raceStrategies( @@ -73,8 +72,7 @@ describe('raceStrategies', () => { expect.objectContaining({ abortSignal: expect.objectContaining({ aborted: true }) }), ); }); - it('aborts the `AbortController` passed to the specific strategies when the caller-supplied `AbortSignal` aborts', async () => { - expect.assertions(2); + it('aborts the `AbortController` passed to the specific strategies when the caller-supplied `AbortSignal` aborts', () => { const getSpecificStrategiesForRace = jest.fn().mockReturnValue([]); const abortController = new AbortController(); raceStrategies( diff --git a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-signature-test.ts b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-signature-test.ts index ade78ace9166..38e433593c98 100644 --- a/packages/transaction-confirmation/src/__tests__/confirmation-strategy-signature-test.ts +++ b/packages/transaction-confirmation/src/__tests__/confirmation-strategy-signature-test.ts @@ -158,8 +158,7 @@ describe('createSignatureConfirmationPromiseFactory', () => { abortSignal: expect.objectContaining({ aborted: true }), }); }); - it('calls the abort signal passed to the signature subscription when aborted', async () => { - expect.assertions(2); + it('calls the abort signal passed to the signature subscription when aborted', () => { const abortController = new AbortController(); getSignatureConfirmationPromise({ abortSignal: abortController.signal, diff --git a/packages/transaction-confirmation/src/__tests__/waiters-test.ts b/packages/transaction-confirmation/src/__tests__/waiters-test.ts index 33a6f5007057..f1b38c61216d 100644 --- a/packages/transaction-confirmation/src/__tests__/waiters-test.ts +++ b/packages/transaction-confirmation/src/__tests__/waiters-test.ts @@ -61,8 +61,7 @@ describe('waitForDurableNonceTransactionConfirmation', () => { }); await expect(commitmentPromise).rejects.toThrow('aborted'); }); - it('calls `getNonceInvalidationPromise` with the necessary input', async () => { - expect.assertions(1); + it('calls `getNonceInvalidationPromise` with the necessary input', () => { waitForDurableNonceTransactionConfirmation({ abortSignal: new AbortController().signal, commitment: 'finalized', @@ -77,8 +76,7 @@ describe('waitForDurableNonceTransactionConfirmation', () => { nonceAccountAddress: '5'.repeat(44), }); }); - it('calls the abort signal passed to `getBlockHeightExceededPromise` when aborted', async () => { - expect.assertions(1); + it('calls the abort signal passed to `getBlockHeightExceededPromise` when aborted', () => { const handleAbortOnBlockHeightExceedencePromise = jest.fn(); getNonceInvalidationPromise.mockImplementation(async ({ abortSignal }) => { abortSignal.addEventListener('abort', handleAbortOnBlockHeightExceedencePromise); @@ -95,8 +93,7 @@ describe('waitForDurableNonceTransactionConfirmation', () => { abortController.abort(); expect(handleAbortOnBlockHeightExceedencePromise).toHaveBeenCalled(); }); - it('calls the abort signal passed to `getRecentSignatureConfirmationPromise` when aborted', async () => { - expect.assertions(1); + it('calls the abort signal passed to `getRecentSignatureConfirmationPromise` when aborted', () => { const handleAbortOnSignatureConfirmationPromise = jest.fn(); getRecentSignatureConfirmationPromise.mockImplementation(async ({ abortSignal }) => { abortSignal.addEventListener('abort', handleAbortOnSignatureConfirmationPromise); @@ -113,8 +110,7 @@ describe('waitForDurableNonceTransactionConfirmation', () => { abortController.abort(); expect(handleAbortOnSignatureConfirmationPromise).toHaveBeenCalled(); }); - it('calls `getRecentSignatureConfirmationPromise` with the necessary input', async () => { - expect.assertions(1); + it('calls `getRecentSignatureConfirmationPromise` with the necessary input', () => { waitForDurableNonceTransactionConfirmation({ abortSignal: new AbortController().signal, commitment: 'finalized', @@ -214,8 +210,7 @@ describe('waitForRecentTransactionConfirmation', () => { }); await expect(commitmentPromise).rejects.toThrow('aborted'); }); - it('calls `getBlockHeightExceededPromise` with the necessary input', async () => { - expect.assertions(1); + it('calls `getBlockHeightExceededPromise` with the necessary input', () => { waitForRecentTransactionConfirmation({ abortSignal: new AbortController().signal, commitment: 'finalized', @@ -229,8 +224,7 @@ describe('waitForRecentTransactionConfirmation', () => { lastValidBlockHeight: MOCK_TRANSACTION.lifetimeConstraint.lastValidBlockHeight, }); }); - it('calls `getRecentSignatureConfirmationPromise` with the necessary input', async () => { - expect.assertions(1); + it('calls `getRecentSignatureConfirmationPromise` with the necessary input', () => { waitForRecentTransactionConfirmation({ abortSignal: new AbortController().signal, commitment: 'finalized', @@ -301,8 +295,7 @@ describe('waitForRecentTransactionConfirmation', () => { }); await expect(commitmentPromise).rejects.toThrow('o no'); }); - it('calls the abort signal passed to `getBlockHeightExceededPromise` when aborted', async () => { - expect.assertions(1); + it('calls the abort signal passed to `getBlockHeightExceededPromise` when aborted', () => { const handleAbortOnBlockHeightExceedencePromise = jest.fn(); getBlockHeightExceedencePromise.mockImplementation(async ({ abortSignal }) => { abortSignal.addEventListener('abort', handleAbortOnBlockHeightExceedencePromise); @@ -319,8 +312,7 @@ describe('waitForRecentTransactionConfirmation', () => { abortController.abort(); expect(handleAbortOnBlockHeightExceedencePromise).toHaveBeenCalled(); }); - it('calls the abort signal passed to `getRecentSignatureConfirmationPromise` when aborted', async () => { - expect.assertions(1); + it('calls the abort signal passed to `getRecentSignatureConfirmationPromise` when aborted', () => { const handleAbortOnSignatureConfirmationPromise = jest.fn(); getRecentSignatureConfirmationPromise.mockImplementation(async ({ abortSignal }) => { abortSignal.addEventListener('abort', handleAbortOnSignatureConfirmationPromise); @@ -360,8 +352,7 @@ describe('waitForRecentTransactionConfirmationUntilTimeout', () => { }); await expect(commitmentPromise).rejects.toThrow('aborted'); }); - it('calls `getTimeoutPromise` with the necessary input', async () => { - expect.assertions(1); + it('calls `getTimeoutPromise` with the necessary input', () => { waitForRecentTransactionConfirmationUntilTimeout({ abortSignal: new AbortController().signal, commitment: 'finalized', @@ -374,8 +365,7 @@ describe('waitForRecentTransactionConfirmationUntilTimeout', () => { commitment: 'finalized', }); }); - it('calls `getRecentSignatureConfirmationPromise` with the necessary input', async () => { - expect.assertions(1); + it('calls `getRecentSignatureConfirmationPromise` with the necessary input', () => { waitForRecentTransactionConfirmationUntilTimeout({ abortSignal: new AbortController().signal, commitment: 'finalized', @@ -426,8 +416,7 @@ describe('waitForRecentTransactionConfirmationUntilTimeout', () => { }); await expect(commitmentPromise).rejects.toThrow('o no'); }); - it('calls the abort signal passed to `getTimeoutPromise` when aborted', async () => { - expect.assertions(1); + it('calls the abort signal passed to `getTimeoutPromise` when aborted', () => { const handleAbortOnTimeoutPromise = jest.fn(); getTimeoutPromise.mockImplementation(async ({ abortSignal }) => { abortSignal.addEventListener('abort', handleAbortOnTimeoutPromise); @@ -444,8 +433,7 @@ describe('waitForRecentTransactionConfirmationUntilTimeout', () => { abortController.abort(); expect(handleAbortOnTimeoutPromise).toHaveBeenCalled(); }); - it('calls the abort signal passed to `getRecentSignatureConfirmationPromise` when aborted', async () => { - expect.assertions(1); + it('calls the abort signal passed to `getRecentSignatureConfirmationPromise` when aborted', () => { const handleAbortOnSignatureConfirmationPromise = jest.fn(); getRecentSignatureConfirmationPromise.mockImplementation(async ({ abortSignal }) => { abortSignal.addEventListener('abort', handleAbortOnSignatureConfirmationPromise); diff --git a/packages/transactions/src/__tests__/signatures-test.ts b/packages/transactions/src/__tests__/signatures-test.ts index d2cad9ebbe35..ce507892e6ad 100644 --- a/packages/transactions/src/__tests__/signatures-test.ts +++ b/packages/transactions/src/__tests__/signatures-test.ts @@ -67,7 +67,7 @@ describe('partiallySignTransaction', () => { const mockPublicKeyAddressA = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' as Address<'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'>; const mockPublicKeyAddressB = 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB' as Address<'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'>; const mockPublicKeyAddressC = 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC' as Address<'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'>; - beforeEach(async () => { + beforeEach(() => { (compileMessage as jest.Mock).mockReturnValue({ header: { numReadonlyNonSignerAccounts: 2, @@ -89,7 +89,7 @@ describe('partiallySignTransaction', () => { ], version: 0, } as CompiledMessage); - (getAddressFromPublicKey as jest.Mock).mockImplementation(async publicKey => { + (getAddressFromPublicKey as jest.Mock).mockImplementation(publicKey => { switch (publicKey) { case mockKeyPairA.publicKey: return mockPublicKeyAddressA; @@ -101,7 +101,7 @@ describe('partiallySignTransaction', () => { return '99999999999999999999999999999999' as Address<'99999999999999999999999999999999'>; } }); - (signBytes as jest.Mock).mockImplementation(async secretKey => { + (signBytes as jest.Mock).mockImplementation(secretKey => { switch (secretKey) { case mockKeyPairA.privateKey: return MOCK_SIGNATURE_A; @@ -226,7 +226,7 @@ describe('signTransaction', () => { const MOCK_SIGNATURE_B = new Uint8Array(Array(64).fill(2)); const mockKeyPairA = { privateKey: {} as CryptoKey, publicKey: {} as CryptoKey } as CryptoKeyPair; const mockKeyPairB = { privateKey: {} as CryptoKey, publicKey: {} as CryptoKey } as CryptoKeyPair; - beforeEach(async () => { + beforeEach(() => { (compileMessage as jest.Mock).mockReturnValue({ header: { numReadonlyNonSignerAccounts: 1, @@ -247,7 +247,7 @@ describe('signTransaction', () => { ], version: 0, } as CompiledMessage); - (getAddressFromPublicKey as jest.Mock).mockImplementation(async publicKey => { + (getAddressFromPublicKey as jest.Mock).mockImplementation(publicKey => { switch (publicKey) { case mockKeyPairA.publicKey: return mockPublicKeyAddressA; @@ -257,7 +257,7 @@ describe('signTransaction', () => { return '99999999999999999999999999999999' as Address<'99999999999999999999999999999999'>; } }); - (signBytes as jest.Mock).mockImplementation(async secretKey => { + (signBytes as jest.Mock).mockImplementation(secretKey => { switch (secretKey) { case mockKeyPairA.privateKey: return MOCK_SIGNATURE_A; diff --git a/packages/transactions/src/__typetests__/transaction-typetests.ts b/packages/transactions/src/__typetests__/transaction-typetests.ts index 6e8b10810209..ca1a50d3e3dd 100644 --- a/packages/transactions/src/__typetests__/transaction-typetests.ts +++ b/packages/transactions/src/__typetests__/transaction-typetests.ts @@ -40,550 +40,547 @@ const mockInstruction = { programAddress: null as unknown as Address<'program'>, } as Transaction['instructions'][number]; -async () => { - // createTransaction - createTransaction({ version: 'legacy' }) satisfies Extract; - // @ts-expect-error version should match - createTransaction({ version: 0 }) satisfies Extract; - createTransaction({ version: 0 }) satisfies Extract; - // @ts-expect-error version should match - createTransaction({ version: 'legacy' }) satisfies Extract; +// createTransaction +createTransaction({ version: 'legacy' }) satisfies Extract; +// @ts-expect-error version should match +createTransaction({ version: 0 }) satisfies Extract; +createTransaction({ version: 0 }) satisfies Extract; +// @ts-expect-error version should match +createTransaction({ version: 'legacy' }) satisfies Extract; - // setTransactionLifetimeUsingBlockhash - setTransactionLifetimeUsingBlockhash( - mockBlockhashLifetime, - null as unknown as Extract, - ) satisfies Extract & ITransactionWithBlockhashLifetime; - setTransactionLifetimeUsingBlockhash( - mockBlockhashLifetime, - null as unknown as Extract, - // @ts-expect-error Version should match - ) satisfies Extract & ITransactionWithBlockhashLifetime; - setTransactionLifetimeUsingBlockhash( - mockBlockhashLifetime, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithSignatures; - setTransactionLifetimeUsingBlockhash( - mockBlockhashLifetime, - null as unknown as Extract, - ) satisfies Extract & ITransactionWithBlockhashLifetime; - setTransactionLifetimeUsingBlockhash( - mockBlockhashLifetime, - null as unknown as Extract, - // @ts-expect-error Version should match - ) satisfies Extract & ITransactionWithBlockhashLifetime; - setTransactionLifetimeUsingBlockhash( - mockBlockhashLifetime, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & ITransactionWithBlockhashLifetime & ITransactionWithSignatures; +// setTransactionLifetimeUsingBlockhash +setTransactionLifetimeUsingBlockhash( + mockBlockhashLifetime, + null as unknown as Extract, +) satisfies Extract & ITransactionWithBlockhashLifetime; +setTransactionLifetimeUsingBlockhash( + mockBlockhashLifetime, + null as unknown as Extract, + // @ts-expect-error Version should match +) satisfies Extract & ITransactionWithBlockhashLifetime; +setTransactionLifetimeUsingBlockhash( + mockBlockhashLifetime, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithSignatures; +setTransactionLifetimeUsingBlockhash( + mockBlockhashLifetime, + null as unknown as Extract, +) satisfies Extract & ITransactionWithBlockhashLifetime; +setTransactionLifetimeUsingBlockhash( + mockBlockhashLifetime, + null as unknown as Extract, + // @ts-expect-error Version should match +) satisfies Extract & ITransactionWithBlockhashLifetime; +setTransactionLifetimeUsingBlockhash( + mockBlockhashLifetime, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & ITransactionWithBlockhashLifetime & ITransactionWithSignatures; + +// setTransactionLifetimeUsingDurableNonce +setTransactionLifetimeUsingDurableNonce( + mockNonceConfig, + null as unknown as Extract, +) satisfies Extract & IDurableNonceTransaction; +setTransactionLifetimeUsingDurableNonce( + mockNonceConfig, + null as unknown as Extract, + // @ts-expect-error Version should match +) satisfies Extract & IDurableNonceTransaction; +setTransactionLifetimeUsingDurableNonce( + mockNonceConfig, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & IDurableNonceTransaction & ITransactionWithSignatures; +setTransactionLifetimeUsingDurableNonce( + mockNonceConfig, + null as unknown as Extract, +) satisfies Extract & IDurableNonceTransaction; +setTransactionLifetimeUsingDurableNonce( + mockNonceConfig, + null as unknown as Extract, + // @ts-expect-error Version should match +) satisfies Extract & IDurableNonceTransaction; +setTransactionLifetimeUsingDurableNonce( + mockNonceConfig, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & IDurableNonceTransaction & ITransactionWithSignatures; + +// setTransactionFeePayer - // setTransactionLifetimeUsingDurableNonce - setTransactionLifetimeUsingDurableNonce( - mockNonceConfig, - null as unknown as Extract, - ) satisfies Extract & IDurableNonceTransaction; - setTransactionLifetimeUsingDurableNonce( - mockNonceConfig, - null as unknown as Extract, - // @ts-expect-error Version should match - ) satisfies Extract & IDurableNonceTransaction; - setTransactionLifetimeUsingDurableNonce( - mockNonceConfig, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & IDurableNonceTransaction & ITransactionWithSignatures; - setTransactionLifetimeUsingDurableNonce( - mockNonceConfig, - null as unknown as Extract, - ) satisfies Extract & IDurableNonceTransaction; - setTransactionLifetimeUsingDurableNonce( - mockNonceConfig, - null as unknown as Extract, - // @ts-expect-error Version should match - ) satisfies Extract & IDurableNonceTransaction; - setTransactionLifetimeUsingDurableNonce( - mockNonceConfig, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & IDurableNonceTransaction & ITransactionWithSignatures; +// (base) +setTransactionFeePayer(mockFeePayer, null as unknown as Extract) satisfies Extract< + Transaction, + { version: 'legacy' } +> & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & ITransactionWithFeePayer<'NOTfeePayer'>, +) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract, + // @ts-expect-error Version should match +) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; +setTransactionFeePayer(mockFeePayer, null as unknown as Extract) satisfies Extract< + Transaction, + { version: 0 } +> & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & ITransactionWithFeePayer<'feePayer'> & ITransactionWithSignatures; + +// (blockhash) +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & ITransactionWithBlockhashLifetime, +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'NOTfeePayer'>, +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & ITransactionWithBlockhashLifetime, + // @ts-expect-error Version should match +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & ITransactionWithBlockhashLifetime, +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; - // setTransactionFeePayer +// (durable nonce) +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & IDurableNonceTransaction, +) satisfies Extract & + IDurableNonceTransaction & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & + IDurableNonceTransaction & + ITransactionWithFeePayer<'NOTfeePayer'>, +) satisfies Extract & + IDurableNonceTransaction & + ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & IDurableNonceTransaction, + // @ts-expect-error Version should match +) satisfies Extract & IDurableNonceTransaction & ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & + IDurableNonceTransaction & + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + IDurableNonceTransaction & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & IDurableNonceTransaction, +) satisfies Extract & IDurableNonceTransaction & ITransactionWithFeePayer<'feePayer'>; +setTransactionFeePayer( + mockFeePayer, + null as unknown as Extract & IDurableNonceTransaction & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + IDurableNonceTransaction & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; - // (base) - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract, - ) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & ITransactionWithFeePayer<'NOTfeePayer'>, - ) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract, - // @ts-expect-error Version should match - ) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & +// partiallySignTransaction +// (blockhash) +partiallySignTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, +) satisfies Promise< + Extract & + ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; - setTransactionFeePayer(mockFeePayer, null as unknown as Extract) satisfies Extract< - Transaction, - { version: 0 } - > & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & + ITransactionWithSignatures +>; +partiallySignTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, + // @ts-expect-error Version should match +) satisfies Promise< + Extract & + ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; - - // (blockhash) - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & ITransactionWithBlockhashLifetime, - ) satisfies Extract & + ITransactionWithSignatures +>; +partiallySignTransaction( + [mockSigner], + null as unknown as Extract & ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'NOTfeePayer'>, - ) satisfies Extract & + ITransactionWithFeePayer<'feePayer'>, +) satisfies Promise< + Extract & ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & ITransactionWithBlockhashLifetime, - // @ts-expect-error Version should match - ) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures +>; +partiallySignTransaction( + [mockSigner], + null as unknown as Extract & ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, +) satisfies Promise< + Extract & ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & ITransactionWithBlockhashLifetime, - ) satisfies Extract & + ITransactionWithSignatures +>; +partiallySignTransaction( + [mockSigner], + null as unknown as Extract & ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, + // @ts-expect-error Version should match +) satisfies Promise< + Extract & ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; - - // (durable nonce) - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & IDurableNonceTransaction, - ) satisfies Extract & - IDurableNonceTransaction & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & - IDurableNonceTransaction & - ITransactionWithFeePayer<'NOTfeePayer'>, - ) satisfies Extract & - IDurableNonceTransaction & - ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & IDurableNonceTransaction, - // @ts-expect-error Version should match - ) satisfies Extract & IDurableNonceTransaction & ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & - IDurableNonceTransaction & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & - IDurableNonceTransaction & + ITransactionWithSignatures +>; +partiallySignTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & IDurableNonceTransaction, - ) satisfies Extract & IDurableNonceTransaction & ITransactionWithFeePayer<'feePayer'>; - setTransactionFeePayer( - mockFeePayer, - null as unknown as Extract & IDurableNonceTransaction & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & - IDurableNonceTransaction & + ITransactionWithSignatures, +) satisfies Promise< + Extract & + ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; + ITransactionWithSignatures +>; - // partiallySignTransaction - // (blockhash) - partiallySignTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - ) satisfies Promise< - Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures - >; - partiallySignTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - // @ts-expect-error Version should match - ) satisfies Promise< - Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures - >; - partiallySignTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - ) satisfies Promise< - Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures - >; - partiallySignTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Promise< - Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures - >; - partiallySignTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - // @ts-expect-error Version should match - ) satisfies Promise< - Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures - >; - partiallySignTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Promise< - Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures - >; +// signTransaction +// (checks) +signTransaction( + [mockSigner], + // @ts-expect-error Type error on missing fee payer and lifetime + null as unknown as Extract, +); +signTransaction( + [mockSigner], + // @ts-expect-error Type error on missing lifetime + null as unknown as Extract & ITransactionWithFeePayer<'feePayer'>, +); +signTransaction( + [mockSigner], + // @ts-expect-error Type error on missing fee payer (blockhash) + null as unknown as Extract & ITransactionWithBlockhashLifetime, +); +signTransaction( + [mockSigner], + // @ts-expect-error Type error on missing fee payer (durable nonce) + null as unknown as Extract & IDurableNonceTransaction, +); - // signTransaction - // (checks) - signTransaction( - [mockSigner], - // @ts-expect-error Type error on missing fee payer and lifetime - null as unknown as Extract, - ); - signTransaction( - [mockSigner], - // @ts-expect-error Type error on missing lifetime - null as unknown as Extract & ITransactionWithFeePayer<'feePayer'>, - ); - signTransaction( - [mockSigner], - // @ts-expect-error Type error on missing fee payer (blockhash) - null as unknown as Extract & ITransactionWithBlockhashLifetime, - ); - signTransaction( - [mockSigner], - // @ts-expect-error Type error on missing fee payer (durable nonce) - null as unknown as Extract & IDurableNonceTransaction, - ); - - // (blockhash) - signTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - ) satisfies Promise< - Extract & - IFullySignedTransaction & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> - >; - signTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - // @ts-expect-error Version should match - ) satisfies Promise< - Extract & - IFullySignedTransaction & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> - >; - signTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - ) satisfies Promise< - Extract & - IFullySignedTransaction & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> - >; - signTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Promise< - Extract & - IFullySignedTransaction & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> - >; - signTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - // @ts-expect-error Version should match - ) satisfies Promise< - Extract & - IFullySignedTransaction & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> - >; - signTransaction( - [mockSigner], - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Promise< - Extract & - IFullySignedTransaction & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> - >; +// (blockhash) +signTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, +) satisfies Promise< + Extract & + IFullySignedTransaction & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> +>; +signTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, + // @ts-expect-error Version should match +) satisfies Promise< + Extract & + IFullySignedTransaction & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> +>; +signTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, +) satisfies Promise< + Extract & + IFullySignedTransaction & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> +>; +signTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, +) satisfies Promise< + Extract & + IFullySignedTransaction & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> +>; +signTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, + // @ts-expect-error Version should match +) satisfies Promise< + Extract & + IFullySignedTransaction & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> +>; +signTransaction( + [mockSigner], + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, +) satisfies Promise< + Extract & + IFullySignedTransaction & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> +>; - // compileMessage - compileMessage( - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - ) satisfies Extract; - compileMessage( - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>, - ) satisfies Extract; +// compileMessage +compileMessage( + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, +) satisfies Extract; +compileMessage( + null as unknown as Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>, +) satisfies Extract; - // getUnsignedTransaction - getUnsignedTransaction( - null as unknown as Extract & ITransactionWithSignatures, - ) satisfies Extract; - getUnsignedTransaction( - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & ITransactionWithSignatures; - getUnsignedTransaction( - null as unknown as Extract & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; - getUnsignedTransaction( - null as unknown as Extract & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & +// getUnsignedTransaction +getUnsignedTransaction( + null as unknown as Extract & ITransactionWithSignatures, +) satisfies Extract; +getUnsignedTransaction( + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & ITransactionWithSignatures; +getUnsignedTransaction( + null as unknown as Extract & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; - getUnsignedTransaction( - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Extract & + ITransactionWithSignatures, +) satisfies Extract & ITransactionWithFeePayer<'feePayer'>; +getUnsignedTransaction( + null as unknown as Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; +getUnsignedTransaction( + null as unknown as Extract & ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'>; - getUnsignedTransaction( - null as unknown as Extract & - ITransactionWithBlockhashLifetime & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'>; +getUnsignedTransaction( + null as unknown as Extract & ITransactionWithBlockhashLifetime & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures; + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithBlockhashLifetime & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures; - // appendTransactionInstruction - appendTransactionInstruction( - mockInstruction, - null as unknown as Extract, - ) satisfies Extract & { +// appendTransactionInstruction +appendTransactionInstruction( + mockInstruction, + null as unknown as Extract, +) satisfies Extract & { + instructions: Transaction['instructions']; +}; +appendTransactionInstruction( + mockInstruction, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithSignatures & { instructions: Transaction['instructions']; }; - appendTransactionInstruction( - mockInstruction, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & - ITransactionWithSignatures & { - instructions: Transaction['instructions']; - }; - appendTransactionInstruction( - mockInstruction, - null as unknown as Extract & ITransactionWithFeePayer<'feePayer'>, - ) satisfies Extract & - ITransactionWithFeePayer<'feePayer'> & { - instructions: Transaction['instructions']; - }; - appendTransactionInstruction( - mockInstruction, - null as unknown as Extract & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Extract & - ITransactionWithFeePayer<'feePayer'> & { - instructions: Transaction['instructions']; - }; - appendTransactionInstruction( - mockInstruction, - null as unknown as Extract & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & +appendTransactionInstruction( + mockInstruction, + null as unknown as Extract & ITransactionWithFeePayer<'feePayer'>, +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & { + instructions: Transaction['instructions']; + }; +appendTransactionInstruction( + mockInstruction, + null as unknown as Extract & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures & { - instructions: Transaction['instructions']; - }; + ITransactionWithSignatures, +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & { + instructions: Transaction['instructions']; + }; +appendTransactionInstruction( + mockInstruction, + null as unknown as Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures & { + instructions: Transaction['instructions']; + }; - // prependTransactionInstruction - prependTransactionInstruction( - mockInstruction, - null as unknown as Extract, - ) satisfies Extract & { +// prependTransactionInstruction +prependTransactionInstruction( + mockInstruction, + null as unknown as Extract, +) satisfies Extract & { + instructions: Transaction['instructions']; +}; +prependTransactionInstruction( + mockInstruction, + null as unknown as Extract & ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithSignatures & { instructions: Transaction['instructions']; }; - prependTransactionInstruction( - mockInstruction, - null as unknown as Extract & ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & - ITransactionWithSignatures & { - instructions: Transaction['instructions']; - }; - prependTransactionInstruction( - mockInstruction, - null as unknown as Extract & ITransactionWithFeePayer<'feePayer'>, - ) satisfies Extract & - ITransactionWithFeePayer<'feePayer'> & { - instructions: Transaction['instructions']; - }; - prependTransactionInstruction( - mockInstruction, - null as unknown as Extract & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - ) satisfies Extract & - ITransactionWithFeePayer<'feePayer'> & { - instructions: Transaction['instructions']; - }; - prependTransactionInstruction( - mockInstruction, - null as unknown as Extract & - ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures, - // @ts-expect-error Should not have signatures - ) satisfies Extract & +prependTransactionInstruction( + mockInstruction, + null as unknown as Extract & ITransactionWithFeePayer<'feePayer'>, +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & { + instructions: Transaction['instructions']; + }; +prependTransactionInstruction( + mockInstruction, + null as unknown as Extract & ITransactionWithFeePayer<'feePayer'> & - ITransactionWithSignatures & { - instructions: Transaction['instructions']; - }; + ITransactionWithSignatures, +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & { + instructions: Transaction['instructions']; + }; +prependTransactionInstruction( + mockInstruction, + null as unknown as Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures, + // @ts-expect-error Should not have signatures +) satisfies Extract & + ITransactionWithFeePayer<'feePayer'> & + ITransactionWithSignatures & { + instructions: Transaction['instructions']; + }; - { - // assertTransactionIsFullySigned - const transaction = {} as Parameters[0]; - // @ts-expect-error Should not be fully signed - transaction satisfies IFullySignedTransaction; - assertTransactionIsFullySigned(transaction); - transaction satisfies IFullySignedTransaction; - } +{ + // assertTransactionIsFullySigned + const transaction = {} as Parameters[0]; + // @ts-expect-error Should not be fully signed + transaction satisfies IFullySignedTransaction; + assertTransactionIsFullySigned(transaction); + transaction satisfies IFullySignedTransaction; +} - { - // assertIsBlockhashLifetimeTransaction - const transaction = null as unknown as BaseTransaction; - // @ts-expect-error Should not be blockhash lifetime - transaction satisfies ITransactionWithBlockhashLifetime; - // @ts-expect-error Should not satisfy has blockhash - transaction satisfies { - lifetimeConstraint: { - blockhash: Blockhash; - }; +{ + // assertIsBlockhashLifetimeTransaction + const transaction = null as unknown as BaseTransaction; + // @ts-expect-error Should not be blockhash lifetime + transaction satisfies ITransactionWithBlockhashLifetime; + // @ts-expect-error Should not satisfy has blockhash + transaction satisfies { + lifetimeConstraint: { + blockhash: Blockhash; }; - // @ts-expect-error Should not satisfy has lastValidBlockHeight - transaction satisfies { - lifetimeConstraint: { - lastValidBlockHeight: bigint; - }; + }; + // @ts-expect-error Should not satisfy has lastValidBlockHeight + transaction satisfies { + lifetimeConstraint: { + lastValidBlockHeight: bigint; }; - assertIsTransactionWithBlockhashLifetime(transaction); - transaction satisfies ITransactionWithBlockhashLifetime; - transaction satisfies { - lifetimeConstraint: { - blockhash: Blockhash; - }; + }; + assertIsTransactionWithBlockhashLifetime(transaction); + transaction satisfies ITransactionWithBlockhashLifetime; + transaction satisfies { + lifetimeConstraint: { + blockhash: Blockhash; }; - transaction satisfies { - lifetimeConstraint: { - lastValidBlockHeight: bigint; - }; + }; + transaction satisfies { + lifetimeConstraint: { + lastValidBlockHeight: bigint; }; - } -}; + }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3fb8b7a998f9..93a2771f7405 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,8 +28,8 @@ importers: specifier: workspace:* version: link:packages/build-scripts '@solana/eslint-config-solana': - specifier: ^3.0.0 - version: 3.0.0(@typescript-eslint/eslint-plugin@6.21.0)(@typescript-eslint/parser@6.8.0)(eslint-plugin-jest@27.9.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-simple-import-sort@10.0.0)(eslint-plugin-sort-keys-fix@1.1.2)(eslint-plugin-typescript-sort-keys@3.2.0)(eslint@8.57.0)(typescript@5.2.2) + specifier: ^3.0.3 + version: 3.0.3(@typescript-eslint/eslint-plugin@6.21.0)(@typescript-eslint/parser@6.8.0)(eslint-plugin-jest@27.9.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-simple-import-sort@10.0.0)(eslint-plugin-sort-keys-fix@1.1.2)(eslint-plugin-typescript-sort-keys@3.2.0)(eslint@8.57.0)(typescript@5.2.2) '@solana/prettier-config-solana': specifier: 0.0.4 version: 0.0.4(prettier@3.1.0) @@ -4136,8 +4136,8 @@ packages: fastestsmallesttextencoderdecoder: 1.0.22 dev: true - /@solana/eslint-config-solana@3.0.0(@typescript-eslint/eslint-plugin@6.21.0)(@typescript-eslint/parser@6.8.0)(eslint-plugin-jest@27.9.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-simple-import-sort@10.0.0)(eslint-plugin-sort-keys-fix@1.1.2)(eslint-plugin-typescript-sort-keys@3.2.0)(eslint@8.57.0)(typescript@5.2.2): - resolution: {integrity: sha512-K8qBl5LQRET4H0+JHEfawA5qB9bjkkgOUB0fUHJ6B8bPAvMkzfQ5f5U7udyFeDMH0LsJuL9XRUZuXU4h/l6HNw==} + /@solana/eslint-config-solana@3.0.3(@typescript-eslint/eslint-plugin@6.21.0)(@typescript-eslint/parser@6.8.0)(eslint-plugin-jest@27.9.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-simple-import-sort@10.0.0)(eslint-plugin-sort-keys-fix@1.1.2)(eslint-plugin-typescript-sort-keys@3.2.0)(eslint@8.57.0)(typescript@5.2.2): + resolution: {integrity: sha512-yTaeCbOBwjmK4oUkknixOpwOzzAK8+4YWvJEJFNHuueESetieDnAeEHV7rzJllFgHEWa9nXps9Q3aD4/XJp71A==} peerDependencies: '@typescript-eslint/eslint-plugin': ^6.0.0 '@typescript-eslint/parser': ^6.0.0 diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/turbo.json b/turbo.json index 143bda2efd88..a5ca82f35c9d 100644 --- a/turbo.json +++ b/turbo.json @@ -65,7 +65,9 @@ "outputMode": "errors-only" }, "test:lint": { - "inputs": ["src/**"], + "dependsOn": ["^compile:typedefs"], + "inputs": ["src/**", "test/**"], + "outputs": [], "outputMode": "errors-only" }, "test:live-with-test-validator": {