Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Evict all transaction confirmation methods into `@solana/transaction-…
Browse files Browse the repository at this point in the history
…confirmation`
  • Loading branch information
steveluscher committed Feb 17, 2024
1 parent 33dd151 commit 2666449
Show file tree
Hide file tree
Showing 32 changed files with 604 additions and 368 deletions.
1 change: 1 addition & 0 deletions packages/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@solana/rpc-transport": "workspace:*",
"@solana/rpc-types": "workspace:*",
"@solana/signers": "workspace:*",
"@solana/transaction-confirmation": "workspace:*",
"@solana/transactions": "workspace:*",
"fast-stable-stringify": "^1.0.0"
},
Expand Down
132 changes: 0 additions & 132 deletions packages/library/src/__tests__/airdrop-confirmer-test.ts

This file was deleted.

59 changes: 0 additions & 59 deletions packages/library/src/airdrop-confirmer.ts

This file was deleted.

10 changes: 7 additions & 3 deletions packages/library/src/airdrop-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { Address } from '@solana/addresses';
import { Signature } from '@solana/keys';
import { RequestAirdropApi } from '@solana/rpc-core';
import { Commitment, LamportsUnsafeBeyond2Pow53Minus1, Rpc } from '@solana/rpc-types';

import { createDefaultSignatureOnlyRecentTransactionConfirmer } from './airdrop-confirmer';
import { waitForRecentTransactionConfirmationUntilTimeout } from '@solana/transaction-confirmation';

type RequestAndConfirmAirdropConfig = Readonly<{
abortSignal?: AbortSignal;
commitment: Commitment;
confirmSignatureOnlyTransaction: ReturnType<typeof createDefaultSignatureOnlyRecentTransactionConfirmer>;
confirmSignatureOnlyTransaction: (
config: Omit<
Parameters<typeof waitForRecentTransactionConfirmationUntilTimeout>[0],
'getRecentSignatureConfirmationPromise' | 'getTimeoutPromise'
>,
) => Promise<void>;
lamports: LamportsUnsafeBeyond2Pow53Minus1;
recipientAddress: Address;
rpc: Rpc<RequestAirdropApi>;
Expand Down
22 changes: 19 additions & 3 deletions packages/library/src/airdrop.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Signature } from '@solana/keys';
import type { GetSignatureStatusesApi, RequestAirdropApi, SignatureNotificationsApi } from '@solana/rpc-core';
import type { Rpc, RpcSubscriptions } from '@solana/rpc-types';
import {
createRecentSignatureConfirmationPromiseFactory,
getTimeoutPromise,
waitForRecentTransactionConfirmationUntilTimeout,
} from '@solana/transaction-confirmation';

import { createDefaultSignatureOnlyRecentTransactionConfirmer } from './airdrop-confirmer';
import { requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT } from './airdrop-internal';

type AirdropFunction = (
Expand All @@ -18,10 +22,22 @@ type AirdropFactoryConfig = Readonly<{
}>;

export function airdropFactory({ rpc, rpcSubscriptions }: AirdropFactoryConfig): AirdropFunction {
const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
rpc,
rpcSubscriptions,
});
);
async function confirmSignatureOnlyTransaction(
config: Omit<
Parameters<typeof waitForRecentTransactionConfirmationUntilTimeout>[0],
'getRecentSignatureConfirmationPromise' | 'getTimeoutPromise'
>,
) {
await waitForRecentTransactionConfirmationUntilTimeout({
...config,
getRecentSignatureConfirmationPromise,
getTimeoutPromise,
});
}
return async function airdrop(config) {
return await requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({
...config,
Expand Down
4 changes: 0 additions & 4 deletions packages/library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ export * from './rpc';
export * from './rpc-transport';
export * from './rpc-websocket-transport';
export * from './send-transaction';
export * from './transaction-confirmation';
export * from './transaction-confirmation-strategy-blockheight';
export * from './transaction-confirmation-strategy-nonce';
export * from './transaction-confirmation-strategy-recent-signature';
23 changes: 16 additions & 7 deletions packages/library/src/send-transaction-internal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Signature } from '@solana/keys';
import { SendTransactionApi } from '@solana/rpc-core';
import { Commitment, commitmentComparator, Rpc } from '@solana/rpc-types';
import {
waitForDurableNonceTransactionConfirmation,
waitForRecentTransactionConfirmation,
} from '@solana/transaction-confirmation';
import {
BaseTransaction,
getBase64EncodedWireTransaction,
Expand All @@ -10,22 +14,27 @@ import {
ITransactionWithFeePayer,
} from '@solana/transactions';

import {
createDefaultDurableNonceTransactionConfirmer,
createDefaultRecentTransactionConfirmer,
} from './transaction-confirmation';

interface SendAndConfirmDurableNonceTransactionConfig
extends SendTransactionBaseConfig,
SendTransactionConfigWithoutEncoding {
confirmDurableNonceTransaction: ReturnType<typeof createDefaultDurableNonceTransactionConfirmer>;
confirmDurableNonceTransaction: (
config: Omit<
Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],
'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'
>,
) => Promise<void>;
transaction: SendableTransaction & IDurableNonceTransaction;
}

interface SendAndConfirmTransactionWithBlockhashLifetimeConfig
extends SendTransactionBaseConfig,
SendTransactionConfigWithoutEncoding {
confirmRecentTransaction: ReturnType<typeof createDefaultRecentTransactionConfirmer>;
confirmRecentTransaction: (
config: Omit<
Parameters<typeof waitForRecentTransactionConfirmation>[0],
'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'
>,
) => Promise<void>;
transaction: SendableTransaction & ITransactionWithBlockhashLifetime;
}

Expand Down
Loading

0 comments on commit 2666449

Please sign in to comment.