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

Commit

Permalink
Rename NewTransaction to Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyre94 committed Apr 18, 2024
1 parent 978d75e commit b2bbe56
Show file tree
Hide file tree
Showing 22 changed files with 131 additions and 136 deletions.
4 changes: 2 additions & 2 deletions packages/compat/src/__typetests__/transaction-typetests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NewTransaction } from '@solana/transactions';
import { Transaction } from '@solana/transactions';
import { VersionedTransaction } from '@solana/web3.js';

import { fromVersionedTransaction } from '../transaction';

const transaction = null as unknown as VersionedTransaction;
fromVersionedTransaction(transaction) satisfies NewTransaction;
fromVersionedTransaction(transaction) satisfies Transaction;
4 changes: 2 additions & 2 deletions packages/compat/src/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors';
import type { SignatureBytes } from '@solana/keys';
import { NewTransaction, type SignaturesMap, TransactionMessageBytes } from '@solana/transactions';
import { type SignaturesMap, Transaction, TransactionMessageBytes } from '@solana/transactions';
import type { PublicKey, VersionedTransaction } from '@solana/web3.js';

import { ReadonlyUint8Array } from '../../codecs-core/dist/types';
Expand All @@ -19,7 +19,7 @@ function convertSignatures(transaction: VersionedTransaction, staticAccountKeys:
);
}

export function fromVersionedTransaction(transaction: VersionedTransaction): NewTransaction {
export function fromVersionedTransaction(transaction: VersionedTransaction): Transaction {
const { message } = transaction;
const { staticAccountKeys } = message.getAccountKeys();

Expand Down
4 changes: 2 additions & 2 deletions packages/signers/src/__tests__/keypair-signer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@solana/test-matchers/toBeFrozenObject';
import { address, getAddressFromPublicKey } from '@solana/addresses';
import { SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, SolanaError } from '@solana/errors';
import { generateKeyPair, SignatureBytes, signBytes } from '@solana/keys';
import { NewTransaction, partiallySignTransaction } from '@solana/transactions';
import { partiallySignTransaction, Transaction } from '@solana/transactions';

import {
assertIsKeyPairSigner,
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('createSignerFromKeyPair', () => {
const mySigner = await createSignerFromKeyPair(myKeyPair);

// And given we have a couple of mock transactions to sign.
const mockTransactions = [{} as NewTransaction, {} as NewTransaction];
const mockTransactions = [{} as Transaction, {} as Transaction];

// And given we mock the next two calls of the partiallySignTransaction function.
const mockSignatures = [new Uint8Array([101, 101, 101]), new Uint8Array([201, 201, 201])] as SignatureBytes[];
Expand Down
6 changes: 3 additions & 3 deletions packages/signers/src/__tests__/noop-signer-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@solana/test-matchers/toBeFrozenObject';

import { address } from '@solana/addresses';
import { NewTransaction } from '@solana/transactions';
import { Transaction } from '@solana/transactions';

import { createNoopSigner, NoopSigner } from '../noop-signer';
import { createSignableMessage } from '../signable-message';
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('createNoopSigner', () => {
const mySigner = createNoopSigner(address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'));

// And given we have a couple of mock transactions to sign.
const mockTransactions = [{} as NewTransaction, {} as NewTransaction];
const mockTransactions = [{} as Transaction, {} as Transaction];

// When we sign both transactions using that signer.
const signatureDictionaries = await mySigner.signTransactions(mockTransactions);
Expand All @@ -71,7 +71,7 @@ describe('createNoopSigner', () => {
const mySigner = createNoopSigner(address('Gp7YgHcJciP4px5FdFnywUiMG4UcfMZV9UagSAZzDxdy'));

// And given we have a couple of mock transactions to sign.
const mockTransactions = [{} as NewTransaction, {} as NewTransaction];
const mockTransactions = [{} as Transaction, {} as Transaction];

// When we sign both transactions using that signer.
const signatureDictionaries = await mySigner.signTransactions(mockTransactions);
Expand Down
57 changes: 26 additions & 31 deletions packages/signers/src/__tests__/sign-transaction-test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
IDurableNonceTransactionMessage,
ITransactionMessageWithBlockhashLifetime,
} from '@solana/transaction-messages';
import { FullySignedTransaction, NewTransaction } from '@solana/transactions';
import { FullySignedTransaction, Transaction } from '@solana/transactions';
import {
TransactionWithBlockhashLifetime,
TransactionWithDurableNonceLifetime,
Expand All @@ -26,7 +26,7 @@ type CompilableTransactionMessageWithSigners = CompilableTransactionMessage & IT
const transactionMessage = null as unknown as CompilableTransactionMessageWithSigners &
ITransactionMessageWithBlockhashLifetime;
partiallySignTransactionMessageWithSigners(transactionMessage) satisfies Promise<
Readonly<NewTransaction & TransactionWithBlockhashLifetime>
Readonly<Transaction & TransactionWithBlockhashLifetime>
>;
}

Expand All @@ -35,15 +35,15 @@ type CompilableTransactionMessageWithSigners = CompilableTransactionMessage & IT
const transactionMessage = null as unknown as CompilableTransactionMessageWithSigners &
IDurableNonceTransactionMessage;
partiallySignTransactionMessageWithSigners(transactionMessage) satisfies Promise<
Readonly<NewTransaction & TransactionWithDurableNonceLifetime>
Readonly<Transaction & TransactionWithDurableNonceLifetime>
>;
}

{
// [partiallySignTransactionMessageWithSigners]: returns a transaction with an unknown lifetime
const transactionMessage = null as unknown as CompilableTransactionMessageWithSigners;
partiallySignTransactionMessageWithSigners(transactionMessage) satisfies Promise<
Readonly<NewTransaction & TransactionWithLifetime>
Readonly<Transaction & TransactionWithLifetime>
>;
}

Expand Down
16 changes: 8 additions & 8 deletions packages/signers/src/sign-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
assertTransactionIsFullySigned,
compileTransaction,
FullySignedTransaction,
NewTransaction,
Transaction,
} from '@solana/transactions';
import {
TransactionWithBlockhashLifetime,
Expand Down Expand Up @@ -39,29 +39,29 @@ export async function partiallySignTransactionMessageWithSigners<
>(
transactionMessage: TTransactionMessage,
config?: { abortSignal?: AbortSignal },
): Promise<NewTransaction & TransactionWithBlockhashLifetime>;
): Promise<Transaction & TransactionWithBlockhashLifetime>;

export async function partiallySignTransactionMessageWithSigners<
TTransactionMessage extends CompilableTransactionMessageWithSigners &
IDurableNonceTransactionMessage = CompilableTransactionMessageWithSigners & IDurableNonceTransactionMessage,
>(
transactionMessage: TTransactionMessage,
config?: { abortSignal?: AbortSignal },
): Promise<Readonly<NewTransaction & TransactionWithDurableNonceLifetime>>;
): Promise<Readonly<Transaction & TransactionWithDurableNonceLifetime>>;

export async function partiallySignTransactionMessageWithSigners<
TTransactionMessage extends CompilableTransactionMessageWithSigners = CompilableTransactionMessageWithSigners,
>(
transactionMessage: TTransactionMessage,
config?: { abortSignal?: AbortSignal },
): Promise<Readonly<NewTransaction & TransactionWithLifetime>>;
): Promise<Readonly<Transaction & TransactionWithLifetime>>;

export async function partiallySignTransactionMessageWithSigners<
TTransactionMessage extends CompilableTransactionMessageWithSigners = CompilableTransactionMessageWithSigners,
>(
transactionMessage: TTransactionMessage,
config: { abortSignal?: AbortSignal } = {},
): Promise<Readonly<NewTransaction & TransactionWithLifetime>> {
): Promise<Readonly<Transaction & TransactionWithLifetime>> {
const { partialSigners, modifyingSigners } = categorizeTransactionSigners(
deduplicateSigners(getSignersFromTransactionMessage(transactionMessage).filter(isTransactionSigner)),
{ identifySendingSigner: false },
Expand Down Expand Up @@ -235,7 +235,7 @@ async function signModifyingAndPartialTransactionSigners<
modifyingSigners: readonly TransactionModifyingSigner[] = [],
partialSigners: readonly TransactionPartialSigner[] = [],
abortSignal?: AbortSignal,
): Promise<Readonly<NewTransaction & TransactionWithLifetime>> {
): Promise<Readonly<Transaction & TransactionWithLifetime>> {
// serialize the transaction
const transaction = compileTransaction(transactionMessage);

Expand All @@ -246,7 +246,7 @@ async function signModifyingAndPartialTransactionSigners<
const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction], { abortSignal });
return Object.freeze(tx);
},
Promise.resolve(transaction) as Promise<Readonly<NewTransaction & TransactionWithLifetime>>,
Promise.resolve(transaction) as Promise<Readonly<Transaction & TransactionWithLifetime>>,
);

// Handle partial signers in parallel.
Expand All @@ -257,7 +257,7 @@ async function signModifyingAndPartialTransactionSigners<
return signatures;
}),
);
const signedTransaction: Readonly<NewTransaction & TransactionWithLifetime> = {
const signedTransaction: Readonly<Transaction & TransactionWithLifetime> = {
...modifiedTransaction,
signatures: Object.freeze(
signatureDictionaries.reduce((signatures, signatureDictionary) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/signers/src/transaction-modifying-signer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address } from '@solana/addresses';
import { SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, SolanaError } from '@solana/errors';
import { NewTransaction } from '@solana/transactions';
import { Transaction } from '@solana/transactions';

import { BaseSignerConfig } from './types';

Expand All @@ -9,7 +9,7 @@ export type TransactionModifyingSignerConfig = BaseSignerConfig;
/** Defines a signer capable of signing transactions. */
export type TransactionModifyingSigner<TAddress extends string = string> = Readonly<{
address: Address<TAddress>;
modifyAndSignTransactions<T extends NewTransaction>(
modifyAndSignTransactions<T extends Transaction>(
transactions: readonly T[],
config?: TransactionModifyingSignerConfig,
): Promise<readonly T[]>;
Expand Down
4 changes: 2 additions & 2 deletions packages/signers/src/transaction-partial-signer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address } from '@solana/addresses';
import { SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, SolanaError } from '@solana/errors';
import { NewTransaction } from '@solana/transactions';
import { Transaction } from '@solana/transactions';

import { BaseSignerConfig, SignatureDictionary } from './types';

Expand All @@ -10,7 +10,7 @@ export type TransactionPartialSignerConfig = BaseSignerConfig;
export type TransactionPartialSigner<TAddress extends string = string> = Readonly<{
address: Address<TAddress>;
signTransactions(
transactions: readonly NewTransaction[],
transactions: readonly Transaction[],
config?: TransactionPartialSignerConfig,
): Promise<readonly SignatureDictionary[]>;
}>;
Expand Down
4 changes: 2 additions & 2 deletions packages/signers/src/transaction-sending-signer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from '@solana/addresses';
import { SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, SolanaError } from '@solana/errors';
import { SignatureBytes } from '@solana/keys';
import { NewTransaction } from '@solana/transactions';
import { Transaction } from '@solana/transactions';

import { BaseSignerConfig } from './types';

Expand All @@ -11,7 +11,7 @@ export type TransactionSendingSignerConfig = BaseSignerConfig;
export type TransactionSendingSigner<TAddress extends string = string> = Readonly<{
address: Address<TAddress>;
signAndSendTransactions(
transactions: readonly NewTransaction[],
transactions: readonly Transaction[],
config?: TransactionSendingSignerConfig,
): Promise<readonly SignatureBytes[]>;
}>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING, SolanaError } f
import { Signature, SignatureBytes } from '@solana/keys';
import type { Blockhash } from '@solana/rpc-types';
import { NewNonce } from '@solana/transaction-messages';
import { NewTransaction, TransactionMessageBytes } from '@solana/transactions';
import { Transaction, TransactionMessageBytes } from '@solana/transactions';
import {
TransactionWithBlockhashLifetime,
TransactionWithDurableNonceLifetime,
Expand All @@ -21,7 +21,7 @@ const FOREVER_PROMISE = new Promise(() => {
});

describe('waitForDurableNonceTransactionConfirmation', () => {
const MOCK_DURABLE_NONCE_TRANSACTION: NewTransaction & TransactionWithDurableNonceLifetime = {
const MOCK_DURABLE_NONCE_TRANSACTION: Transaction & TransactionWithDurableNonceLifetime = {
lifetimeConstraint: { nonce: 'xyz' as NewNonce, nonceAccountAddress: '5'.repeat(44) as Address },
messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes,
signatures: {
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('waitForDurableNonceTransactionConfirmation', () => {
});

describe('waitForRecentTransactionConfirmation', () => {
const MOCK_TRANSACTION: NewTransaction & TransactionWithBlockhashLifetime = {
const MOCK_TRANSACTION: Transaction & TransactionWithBlockhashLifetime = {
lifetimeConstraint: { blockhash: '4'.repeat(44) as Blockhash, lastValidBlockHeight: 123n },
messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes,
signatures: {
Expand Down
6 changes: 3 additions & 3 deletions packages/transaction-confirmation/src/waiters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Signature } from '@solana/keys';
import { getSignatureFromTransaction, NewTransaction } from '@solana/transactions';
import { getSignatureFromTransaction, Transaction } from '@solana/transactions';
import {
TransactionWithBlockhashLifetime,
TransactionWithDurableNonceLifetime,
Expand All @@ -12,13 +12,13 @@ import { getTimeoutPromise } from './confirmation-strategy-timeout';

interface WaitForDurableNonceTransactionConfirmationConfig extends BaseTransactionConfirmationStrategyConfig {
getNonceInvalidationPromise: ReturnType<typeof createNonceInvalidationPromiseFactory>;
transaction: Readonly<NewTransaction & TransactionWithDurableNonceLifetime>;
transaction: Readonly<Transaction & TransactionWithDurableNonceLifetime>;
}

interface WaitForRecentTransactionWithBlockhashLifetimeConfirmationConfig
extends BaseTransactionConfirmationStrategyConfig {
getBlockHeightExceedencePromise: ReturnType<typeof createBlockHeightExceedencePromiseFactory>;
transaction: Readonly<NewTransaction & TransactionWithBlockhashLifetime>;
transaction: Readonly<Transaction & TransactionWithBlockhashLifetime>;
}

interface WaitForRecentTransactionWithTimeBasedLifetimeConfirmationConfig
Expand Down
Loading

0 comments on commit b2bbe56

Please sign in to comment.