From ed8b7123f6081ec1ea5ca61ac29326a330672d1e Mon Sep 17 00:00:00 2001 From: Callum Date: Thu, 18 Apr 2024 11:55:01 +0400 Subject: [PATCH] Rename NewTransaction to Transaction --- .../__typetests__/transaction-typetests.ts | 4 +- packages/compat/src/transaction.ts | 4 +- .../src/__tests__/keypair-signer-test.ts | 4 +- .../signers/src/__tests__/noop-signer-test.ts | 6 +- .../src/__tests__/sign-transaction-test.ts | 57 +++++++++---------- .../sign-transaction-typetest.ts | 8 +-- packages/signers/src/sign-transaction.ts | 16 +++--- .../src/transaction-modifying-signer.ts | 4 +- .../signers/src/transaction-partial-signer.ts | 4 +- .../signers/src/transaction-sending-signer.ts | 4 +- .../src/__tests__/waiters-test.ts | 6 +- .../transaction-confirmation/src/waiters.ts | 6 +- .../src/__tests__/signatures-test.ts | 54 +++++++++--------- .../src/__tests__/wire-transaction-test.ts | 4 +- .../compile-transaction-typetests.ts | 16 +++--- .../src/__typetests__/signatures-typetests.ts | 12 ++-- .../__tests__/transaction-codec-test.ts | 18 +++--- .../src/codecs/transaction-codec.ts | 10 ++-- .../transactions/src/compile-transaction.ts | 12 ++-- packages/transactions/src/signatures.ts | 12 ++-- packages/transactions/src/transaction.ts | 2 +- packages/transactions/src/wire-transaction.ts | 4 +- 22 files changed, 131 insertions(+), 136 deletions(-) diff --git a/packages/compat/src/__typetests__/transaction-typetests.ts b/packages/compat/src/__typetests__/transaction-typetests.ts index 192c3f88a52e..a12f5828c8d3 100644 --- a/packages/compat/src/__typetests__/transaction-typetests.ts +++ b/packages/compat/src/__typetests__/transaction-typetests.ts @@ -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; diff --git a/packages/compat/src/transaction.ts b/packages/compat/src/transaction.ts index b9060df66eb2..d215624c2067 100644 --- a/packages/compat/src/transaction.ts +++ b/packages/compat/src/transaction.ts @@ -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'; @@ -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(); diff --git a/packages/signers/src/__tests__/keypair-signer-test.ts b/packages/signers/src/__tests__/keypair-signer-test.ts index 5b0cb89e1dc9..dcbcf0888d68 100644 --- a/packages/signers/src/__tests__/keypair-signer-test.ts +++ b/packages/signers/src/__tests__/keypair-signer-test.ts @@ -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, @@ -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[]; diff --git a/packages/signers/src/__tests__/noop-signer-test.ts b/packages/signers/src/__tests__/noop-signer-test.ts index dd0443f6f8ff..f61a40d0fcee 100644 --- a/packages/signers/src/__tests__/noop-signer-test.ts +++ b/packages/signers/src/__tests__/noop-signer-test.ts @@ -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'; @@ -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); @@ -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); diff --git a/packages/signers/src/__tests__/sign-transaction-test.ts b/packages/signers/src/__tests__/sign-transaction-test.ts index 8eb2d6b81b78..027503e7bef7 100644 --- a/packages/signers/src/__tests__/sign-transaction-test.ts +++ b/packages/signers/src/__tests__/sign-transaction-test.ts @@ -7,12 +7,7 @@ import { SolanaError, } from '@solana/errors'; import { Blockhash } from '@solana/rpc-types'; -import { - compileTransaction, - FullySignedTransaction, - NewTransaction, - TransactionMessageBytes, -} from '@solana/transactions'; +import { compileTransaction, FullySignedTransaction, Transaction, TransactionMessageBytes } from '@solana/transactions'; import { TransactionWithLifetime } from '@solana/transactions/dist/types/lifetime'; import { ReadonlyUint8Array } from '../../../codecs-core/dist/types'; @@ -46,7 +41,7 @@ describe('partiallySignTransactionWithSigners', () => { const signerA = createMockTransactionModifyingSigner('1111' as Address); const signerB = createMockTransactionPartialSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -86,18 +81,18 @@ describe('partiallySignTransactionWithSigners', () => { // And mock implementations for both signers such that they append events to an array. const events: string[] = []; - signerA.modifyAndSignTransactions.mockImplementation((transactions: NewTransaction[]) => { + signerA.modifyAndSignTransactions.mockImplementation((transactions: Transaction[]) => { events.push('signerA'); return transactions.map(tx => ({ ...tx, signatures: { '1111': '1111_signature' } })); }); - signerB.signTransactions.mockImplementation((transactions: NewTransaction[]) => { + signerB.signTransactions.mockImplementation((transactions: Transaction[]) => { events.push('signerB'); return transactions.map(() => ({ '2222': '2222_signature' })); }); // And given a transaction that contains theses signers in its account metas (in any order). const transactionMessage = createMockTransactionMessageWithSigners([signerB, signerA]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -129,7 +124,7 @@ describe('partiallySignTransactionWithSigners', () => { // And mock implementations for both signers such that they append events to an array. const events: string[] = []; - const mockImplementation = (signerId: string, address: string) => async (transactions: NewTransaction[]) => { + const mockImplementation = (signerId: string, address: string) => async (transactions: Transaction[]) => { events.push(`${signerId} starts`); await new Promise(r => setTimeout(r, 500)); events.push(`${signerId} ends`); @@ -143,7 +138,7 @@ describe('partiallySignTransactionWithSigners', () => { // And given a transaction that contains theses two signers in its account metas. const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -176,7 +171,7 @@ describe('partiallySignTransactionWithSigners', () => { // And mock implementations for both signers such that they append events to an array. const events: string[] = []; const mockImplementation = - (signerId: string, address: string, timeout: number) => async (transactions: NewTransaction[]) => { + (signerId: string, address: string, timeout: number) => async (transactions: Transaction[]) => { events.push(`${signerId} starts`); await new Promise(r => setTimeout(r, timeout)); events.push(`${signerId} ends`); @@ -187,7 +182,7 @@ describe('partiallySignTransactionWithSigners', () => { // And given a transaction that contains theses two signers in its account metas. const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -221,7 +216,7 @@ describe('partiallySignTransactionWithSigners', () => { ...createMockTransactionPartialSigner('2222' as Address), }; const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -256,7 +251,7 @@ describe('partiallySignTransactionWithSigners', () => { }; const signerB = createMockTransactionPartialSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -298,7 +293,7 @@ describe('partiallySignTransactionWithSigners', () => { }; const signerB = createMockTransactionModifyingSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -336,7 +331,7 @@ describe('partiallySignTransactionWithSigners', () => { // Given a transaction with a mocked partial signer. const signer = createMockTransactionPartialSigner('1111' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signer]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -363,7 +358,7 @@ describe('partiallySignTransactionWithSigners', () => { const signer = createMockTransactionPartialSigner('1111' as Address); signer.signTransactions.mockResolvedValueOnce([{ '1111': '1111_signature' }]); const transactionMessage = createMockTransactionMessageWithSigners([signer]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -391,7 +386,7 @@ describe('partiallySignTransactionWithSigners', () => { // Given a transaction const transactionMessage = createMockTransactionMessageWithSigners([]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: {}, @@ -414,7 +409,7 @@ describe('signTransactionWithSigners', () => { const signerA = createMockTransactionModifyingSigner('1111' as Address); const signerB = createMockTransactionPartialSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -455,7 +450,7 @@ describe('signTransactionWithSigners', () => { const signerA = createMockTransactionPartialSigner('1111' as Address); const signerB = createMockTransactionSendingSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -487,7 +482,7 @@ describe('signTransactionWithSigners', () => { const signer = createMockTransactionPartialSigner('1111' as Address); signer.signTransactions.mockResolvedValueOnce([{ '1111': '1111_signature' }]); const transactionMessage = createMockTransactionMessageWithSigners([signer]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -515,7 +510,7 @@ describe('signTransactionWithSigners', () => { // Given a transaction const transactionMessage = createMockTransactionMessageWithSigners([]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: {}, @@ -538,7 +533,7 @@ describe('signAndSendTransactionWithSigners', () => { const signerA = createMockTransactionPartialSigner('1111' as Address); const signerB = createMockTransactionSendingSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -574,7 +569,7 @@ describe('signAndSendTransactionWithSigners', () => { const signer = createMockTransactionPartialSigner('1111' as Address); signer.signTransactions.mockResolvedValueOnce([{ '1111': '1111_signature' }]); const transactionMessage = createMockTransactionMessageWithSigners([signer]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -602,7 +597,7 @@ describe('signAndSendTransactionWithSigners', () => { const signerA = createMockTransactionCompositeSigner('1111' as Address); const signerB = createMockTransactionPartialSigner('2222' as Address); const transactionMessage = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -638,7 +633,7 @@ describe('signAndSendTransactionWithSigners', () => { const signerA = createMockTransactionCompositeSigner('1111' as Address); const signerB = createMockTransactionSendingSigner('2222' as Address); const transaction = createMockTransactionMessageWithSigners([signerA, signerB]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -680,7 +675,7 @@ describe('signAndSendTransactionWithSigners', () => { const signerB = createMockTransactionSendingSigner('2222' as Address); const signerC = createMockTransactionModifyingSigner('3333' as Address); const transaction = createMockTransactionMessageWithSigners([signerA, signerB, signerC]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -732,7 +727,7 @@ describe('signAndSendTransactionWithSigners', () => { const signer = createMockTransactionSendingSigner('1111' as Address); signer.signAndSendTransactions.mockResolvedValueOnce([new Uint8Array([1, 2, 3])]); const transactionMessage = createMockTransactionMessageWithSigners([signer]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { @@ -762,7 +757,7 @@ describe('signAndSendTransactionWithSigners', () => { const signer = createMockTransactionSendingSigner('1111' as Address); signer.signAndSendTransactions.mockResolvedValueOnce([new Uint8Array([1, 2, 3])]); const transactionMessage = createMockTransactionMessageWithSigners([signer]); - const unsignedTransaction: NewTransaction & TransactionWithLifetime = { + const unsignedTransaction: Transaction & TransactionWithLifetime = { lifetimeConstraint: { blockhash: 'a' as Blockhash, lastValidBlockHeight: 1n }, messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { diff --git a/packages/signers/src/__typetests__/sign-transaction-typetest.ts b/packages/signers/src/__typetests__/sign-transaction-typetest.ts index 8ae10434aa04..1d2ab19246b0 100644 --- a/packages/signers/src/__typetests__/sign-transaction-typetest.ts +++ b/packages/signers/src/__typetests__/sign-transaction-typetest.ts @@ -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, @@ -26,7 +26,7 @@ type CompilableTransactionMessageWithSigners = CompilableTransactionMessage & IT const transactionMessage = null as unknown as CompilableTransactionMessageWithSigners & ITransactionMessageWithBlockhashLifetime; partiallySignTransactionMessageWithSigners(transactionMessage) satisfies Promise< - Readonly + Readonly >; } @@ -35,7 +35,7 @@ type CompilableTransactionMessageWithSigners = CompilableTransactionMessage & IT const transactionMessage = null as unknown as CompilableTransactionMessageWithSigners & IDurableNonceTransactionMessage; partiallySignTransactionMessageWithSigners(transactionMessage) satisfies Promise< - Readonly + Readonly >; } @@ -43,7 +43,7 @@ type CompilableTransactionMessageWithSigners = CompilableTransactionMessage & IT // [partiallySignTransactionMessageWithSigners]: returns a transaction with an unknown lifetime const transactionMessage = null as unknown as CompilableTransactionMessageWithSigners; partiallySignTransactionMessageWithSigners(transactionMessage) satisfies Promise< - Readonly + Readonly >; } diff --git a/packages/signers/src/sign-transaction.ts b/packages/signers/src/sign-transaction.ts index 726e98a66a7c..c9fc9b07a167 100644 --- a/packages/signers/src/sign-transaction.ts +++ b/packages/signers/src/sign-transaction.ts @@ -9,7 +9,7 @@ import { assertTransactionIsFullySigned, compileTransaction, FullySignedTransaction, - NewTransaction, + Transaction, } from '@solana/transactions'; import { TransactionWithBlockhashLifetime, @@ -39,7 +39,7 @@ export async function partiallySignTransactionMessageWithSigners< >( transactionMessage: TTransactionMessage, config?: { abortSignal?: AbortSignal }, -): Promise; +): Promise; export async function partiallySignTransactionMessageWithSigners< TTransactionMessage extends CompilableTransactionMessageWithSigners & @@ -47,21 +47,21 @@ export async function partiallySignTransactionMessageWithSigners< >( transactionMessage: TTransactionMessage, config?: { abortSignal?: AbortSignal }, -): Promise>; +): Promise>; export async function partiallySignTransactionMessageWithSigners< TTransactionMessage extends CompilableTransactionMessageWithSigners = CompilableTransactionMessageWithSigners, >( transactionMessage: TTransactionMessage, config?: { abortSignal?: AbortSignal }, -): Promise>; +): Promise>; export async function partiallySignTransactionMessageWithSigners< TTransactionMessage extends CompilableTransactionMessageWithSigners = CompilableTransactionMessageWithSigners, >( transactionMessage: TTransactionMessage, config: { abortSignal?: AbortSignal } = {}, -): Promise> { +): Promise> { const { partialSigners, modifyingSigners } = categorizeTransactionSigners( deduplicateSigners(getSignersFromTransactionMessage(transactionMessage).filter(isTransactionSigner)), { identifySendingSigner: false }, @@ -235,7 +235,7 @@ async function signModifyingAndPartialTransactionSigners< modifyingSigners: readonly TransactionModifyingSigner[] = [], partialSigners: readonly TransactionPartialSigner[] = [], abortSignal?: AbortSignal, -): Promise> { +): Promise> { // serialize the transaction const transaction = compileTransaction(transactionMessage); @@ -246,7 +246,7 @@ async function signModifyingAndPartialTransactionSigners< const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction], { abortSignal }); return Object.freeze(tx); }, - Promise.resolve(transaction) as Promise>, + Promise.resolve(transaction) as Promise>, ); // Handle partial signers in parallel. @@ -257,7 +257,7 @@ async function signModifyingAndPartialTransactionSigners< return signatures; }), ); - const signedTransaction: Readonly = { + const signedTransaction: Readonly = { ...modifiedTransaction, signatures: Object.freeze( signatureDictionaries.reduce((signatures, signatureDictionary) => { diff --git a/packages/signers/src/transaction-modifying-signer.ts b/packages/signers/src/transaction-modifying-signer.ts index eb9e6a8ceaf7..765eeb190f08 100644 --- a/packages/signers/src/transaction-modifying-signer.ts +++ b/packages/signers/src/transaction-modifying-signer.ts @@ -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'; @@ -9,7 +9,7 @@ export type TransactionModifyingSignerConfig = BaseSignerConfig; /** Defines a signer capable of signing transactions. */ export type TransactionModifyingSigner = Readonly<{ address: Address; - modifyAndSignTransactions( + modifyAndSignTransactions( transactions: readonly T[], config?: TransactionModifyingSignerConfig, ): Promise; diff --git a/packages/signers/src/transaction-partial-signer.ts b/packages/signers/src/transaction-partial-signer.ts index a6f72e6f104d..fa021f3151ce 100644 --- a/packages/signers/src/transaction-partial-signer.ts +++ b/packages/signers/src/transaction-partial-signer.ts @@ -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'; @@ -10,7 +10,7 @@ export type TransactionPartialSignerConfig = BaseSignerConfig; export type TransactionPartialSigner = Readonly<{ address: Address; signTransactions( - transactions: readonly NewTransaction[], + transactions: readonly Transaction[], config?: TransactionPartialSignerConfig, ): Promise; }>; diff --git a/packages/signers/src/transaction-sending-signer.ts b/packages/signers/src/transaction-sending-signer.ts index 1e34d1d88e39..acfab84db736 100644 --- a/packages/signers/src/transaction-sending-signer.ts +++ b/packages/signers/src/transaction-sending-signer.ts @@ -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'; @@ -11,7 +11,7 @@ export type TransactionSendingSignerConfig = BaseSignerConfig; export type TransactionSendingSigner = Readonly<{ address: Address; signAndSendTransactions( - transactions: readonly NewTransaction[], + transactions: readonly Transaction[], config?: TransactionSendingSignerConfig, ): Promise; }>; diff --git a/packages/transaction-confirmation/src/__tests__/waiters-test.ts b/packages/transaction-confirmation/src/__tests__/waiters-test.ts index eb6fc7e5dc3b..e4d235d6a943 100644 --- a/packages/transaction-confirmation/src/__tests__/waiters-test.ts +++ b/packages/transaction-confirmation/src/__tests__/waiters-test.ts @@ -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, @@ -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: { @@ -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: { diff --git a/packages/transaction-confirmation/src/waiters.ts b/packages/transaction-confirmation/src/waiters.ts index abc0a202e323..a2213f4c0868 100644 --- a/packages/transaction-confirmation/src/waiters.ts +++ b/packages/transaction-confirmation/src/waiters.ts @@ -1,5 +1,5 @@ import { Signature } from '@solana/keys'; -import { getSignatureFromTransaction, NewTransaction } from '@solana/transactions'; +import { getSignatureFromTransaction, Transaction } from '@solana/transactions'; import { TransactionWithBlockhashLifetime, TransactionWithDurableNonceLifetime, @@ -12,13 +12,13 @@ import { getTimeoutPromise } from './confirmation-strategy-timeout'; interface WaitForDurableNonceTransactionConfirmationConfig extends BaseTransactionConfirmationStrategyConfig { getNonceInvalidationPromise: ReturnType; - transaction: Readonly; + transaction: Readonly; } interface WaitForRecentTransactionWithBlockhashLifetimeConfirmationConfig extends BaseTransactionConfirmationStrategyConfig { getBlockHeightExceedencePromise: ReturnType; - transaction: Readonly; + transaction: Readonly; } interface WaitForRecentTransactionWithTimeBasedLifetimeConfirmationConfig diff --git a/packages/transactions/src/__tests__/signatures-test.ts b/packages/transactions/src/__tests__/signatures-test.ts index 6251df7f425e..1b68eb906045 100644 --- a/packages/transactions/src/__tests__/signatures-test.ts +++ b/packages/transactions/src/__tests__/signatures-test.ts @@ -16,7 +16,7 @@ import { partiallySignTransaction, signTransaction, } from '../signatures'; -import { NewTransaction, OrderedMap, TransactionMessageBytes } from '../transaction'; +import { OrderedMap, Transaction, TransactionMessageBytes } from '../transaction'; jest.mock('@solana/addresses'); jest.mock('@solana/keys'); @@ -25,7 +25,7 @@ describe('getSignatureFromTransaction', () => { it("returns the signature associated with a transaction's fee payer", () => { const signatures: OrderedMap = {}; signatures['123' as Address] = new Uint8Array(new Array(64).fill(9)) as SignatureBytes; - const transactionWithFeePayerSignature: NewTransaction = { + const transactionWithFeePayerSignature: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures, }; @@ -34,7 +34,7 @@ describe('getSignatureFromTransaction', () => { ); }); it('throws when supplied a transaction that has not been signed by the fee payer', () => { - const transactionWithoutFeePayerSignature: NewTransaction = { + const transactionWithoutFeePayerSignature: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: {}, }; @@ -83,7 +83,7 @@ describe('partiallySignTransaction', () => { }); it("returns a signed transaction object having the first signer's signature", async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -101,7 +101,7 @@ describe('partiallySignTransaction', () => { it('returns unchanged compiled message bytes', async () => { expect.assertions(1); const messageBytes = new Uint8Array([1, 2, 3]) as ReadonlyUint8Array as TransactionMessageBytes; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: messageBytes as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -112,7 +112,7 @@ describe('partiallySignTransaction', () => { }); it('returns a signed transaction object having null for the missing signers', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -131,7 +131,7 @@ describe('partiallySignTransaction', () => { }); it("returns a transaction object having the second signer's signature", async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -148,7 +148,7 @@ describe('partiallySignTransaction', () => { }); it('returns a transaction object having multiple signatures', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -171,7 +171,7 @@ describe('partiallySignTransaction', () => { }); it('stores the signatures in the order specified on the compiled message', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -185,7 +185,7 @@ describe('partiallySignTransaction', () => { }); it('does not modify an existing signature when the signature is the same', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: MOCK_SIGNATURE_A, @@ -202,7 +202,7 @@ describe('partiallySignTransaction', () => { }); it('produces a new signature for an existing signer', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: MOCK_SIGNATURE_A, @@ -213,7 +213,7 @@ describe('partiallySignTransaction', () => { }); it('modifies the existing signature when the signature is different', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: new Uint8Array([1, 2, 3, 4]) as ReadonlyUint8Array as SignatureBytes, @@ -229,7 +229,7 @@ describe('partiallySignTransaction', () => { }); it('produces a signature for a new signer when there is an existing one', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: MOCK_SIGNATURE_A, @@ -246,7 +246,7 @@ describe('partiallySignTransaction', () => { }); it('freezes the object', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -256,7 +256,7 @@ describe('partiallySignTransaction', () => { }); it('returns the input transaction object if no signatures changed', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: MOCK_SIGNATURE_A, @@ -266,7 +266,7 @@ describe('partiallySignTransaction', () => { }); it('throws if a keypair is for an address that is not in the signatures of the transaction', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -281,7 +281,7 @@ describe('partiallySignTransaction', () => { }); it('throws with multiple addresses if there are multiple keypairs that are not in the signatures', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -327,7 +327,7 @@ describe('signTransaction', () => { }); it('fatals when missing a signer', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -343,7 +343,7 @@ describe('signTransaction', () => { }); it('returns a signed transaction object with multiple signatures', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -362,7 +362,7 @@ describe('signTransaction', () => { it('returns a signed transaction object with the compiled message bytes', async () => { expect.assertions(1); const messageBytes = new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -374,7 +374,7 @@ describe('signTransaction', () => { }); it('stores the signatures in the order specified on the compiled message', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -387,7 +387,7 @@ describe('signTransaction', () => { }); it('freezes the object', async () => { expect.assertions(1); - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures: { [mockPublicKeyAddressA]: null, @@ -407,7 +407,7 @@ describe('assertTransactionIsFullySigned', () => { it('throws if the transaction has no signature for the fee payer', () => { const signatures: OrderedMap = {}; signatures[mockPublicKeyAddressA] = null; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures, }; @@ -423,7 +423,7 @@ describe('assertTransactionIsFullySigned', () => { const signatures: OrderedMap = {}; signatures[mockPublicKeyAddressA] = null; signatures[mockPublicKeyAddressB] = null; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures, }; @@ -438,7 +438,7 @@ describe('assertTransactionIsFullySigned', () => { it('does not throw if the transaction is signed by its only signer', () => { const signatures: OrderedMap = {}; signatures[mockPublicKeyAddressA] = mockSignatureA; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures, }; @@ -450,7 +450,7 @@ describe('assertTransactionIsFullySigned', () => { const signatures: OrderedMap = {}; signatures[mockPublicKeyAddressA] = mockSignatureA; signatures[mockPublicKeyAddressB] = mockSignatureB; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures, }; @@ -460,7 +460,7 @@ describe('assertTransactionIsFullySigned', () => { it('does not throw if the transaction has no signatures', () => { const signatures: OrderedMap = {}; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes, signatures, }; diff --git a/packages/transactions/src/__tests__/wire-transaction-test.ts b/packages/transactions/src/__tests__/wire-transaction-test.ts index bd9a42677708..15fd42577e33 100644 --- a/packages/transactions/src/__tests__/wire-transaction-test.ts +++ b/packages/transactions/src/__tests__/wire-transaction-test.ts @@ -2,7 +2,7 @@ import { Address } from '@solana/addresses'; import { ReadonlyUint8Array } from '@solana/codecs-core'; import { SignatureBytes } from '@solana/keys'; -import { NewTransaction, TransactionMessageBytes } from '../transaction'; +import { Transaction, TransactionMessageBytes } from '../transaction'; import { getBase64EncodedWireTransaction } from '../wire-transaction'; describe('getBase64EncodedWireTransaction', () => { @@ -41,7 +41,7 @@ describe('getBase64EncodedWireTransaction', () => { } */ - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes: new Uint8Array([ 128, 2, 1, 1, 3, 15, 30, 107, 20, 33, 192, 74, 7, 4, 49, 38, 92, 25, 197, 187, 238, 25, 146, 186, 232, 175, 209, 205, 7, 142, 248, 175, 112, 71, 220, 17, 247, 45, 91, 65, 60, 101, 64, 222, 21, 12, 147, 115, diff --git a/packages/transactions/src/__typetests__/compile-transaction-typetests.ts b/packages/transactions/src/__typetests__/compile-transaction-typetests.ts index ab9b72e83346..7d89904b67e9 100644 --- a/packages/transactions/src/__typetests__/compile-transaction-typetests.ts +++ b/packages/transactions/src/__typetests__/compile-transaction-typetests.ts @@ -16,19 +16,19 @@ import { TransactionWithDurableNonceLifetime, TransactionWithLifetime, } from '../lifetime'; -import { NewTransaction } from '../transaction'; +import { Transaction } from '../transaction'; // transaction message with blockhash lifetime compileTransaction( null as unknown as BaseTransactionMessage & ITransactionMessageWithBlockhashLifetime & ITransactionMessageWithFeePayer, -) satisfies Readonly; +) satisfies Readonly; compileTransaction( null as unknown as BaseTransactionMessage & ITransactionMessageWithBlockhashLifetime & ITransactionMessageWithFeePayer, -) satisfies Readonly; +) satisfies Readonly; compileTransaction( null as unknown as BaseTransactionMessage & ITransactionMessageWithBlockhashLifetime & @@ -38,25 +38,25 @@ compileTransaction( // transaction message with durable nonce lifetime compileTransaction( null as unknown as BaseTransactionMessage & IDurableNonceTransactionMessage & ITransactionMessageWithFeePayer, -) satisfies Readonly; +) satisfies Readonly; compileTransaction( null as unknown as BaseTransactionMessage & IDurableNonceTransactionMessage & ITransactionMessageWithFeePayer, -) satisfies Readonly; +) satisfies Readonly; compileTransaction( null as unknown as BaseTransactionMessage & IDurableNonceTransactionMessage & ITransactionMessageWithFeePayer, ).lifetimeConstraint.nonce satisfies NewNonce; // transaction message with unknown lifetime compileTransaction(null as unknown as CompilableTransactionMessage) satisfies Readonly< - NewTransaction & TransactionWithLifetime + Transaction & TransactionWithLifetime >; // @ts-expect-error not known to have blockhash lifetime compileTransaction(null as unknown as CompilableTransactionMessage) satisfies Readonly< - NewTransaction & TransactionBlockhashLifetime + Transaction & TransactionBlockhashLifetime >; // @ts-expect-error not known to have durable nonce lifetime compileTransaction(null as unknown as CompilableTransactionMessage) satisfies Readonly< - NewTransaction & TransactionDurableNonceLifetime + Transaction & TransactionDurableNonceLifetime >; compileTransaction(null as unknown as CompilableTransactionMessage).lifetimeConstraint satisfies | { blockhash: Blockhash } diff --git a/packages/transactions/src/__typetests__/signatures-typetests.ts b/packages/transactions/src/__typetests__/signatures-typetests.ts index 237b2b264954..1deb80bca873 100644 --- a/packages/transactions/src/__typetests__/signatures-typetests.ts +++ b/packages/transactions/src/__typetests__/signatures-typetests.ts @@ -7,29 +7,29 @@ import { partiallySignTransaction, signTransaction, } from '..'; -import { NewTransaction } from '../transaction'; +import { Transaction } from '../transaction'; // getSignatureFromTransaction { - const transaction = null as unknown as NewTransaction & { some: 1 }; + const transaction = null as unknown as Transaction & { some: 1 }; getSignatureFromTransaction(transaction) satisfies Signature; } // partiallySignTransaction { - const transaction = null as unknown as NewTransaction & { some: 1 }; - partiallySignTransaction([], transaction) satisfies Promise; + const transaction = null as unknown as Transaction & { some: 1 }; + partiallySignTransaction([], transaction) satisfies Promise; } // signTransaction { - const transaction = null as unknown as NewTransaction & { some: 1 }; + const transaction = null as unknown as Transaction & { some: 1 }; signTransaction([], transaction) satisfies Promise; } // assertTransactionIsFullySigned { - const transaction = null as unknown as NewTransaction & { some: 1 }; + const transaction = null as unknown as Transaction & { some: 1 }; assertTransactionIsFullySigned(transaction); transaction satisfies FullySignedTransaction & { some: 1 }; } diff --git a/packages/transactions/src/codecs/__tests__/transaction-codec-test.ts b/packages/transactions/src/codecs/__tests__/transaction-codec-test.ts index 44790c0fc29c..c32c1a75ddca 100644 --- a/packages/transactions/src/codecs/__tests__/transaction-codec-test.ts +++ b/packages/transactions/src/codecs/__tests__/transaction-codec-test.ts @@ -5,7 +5,7 @@ import { ReadonlyUint8Array, VariableSizeDecoder, VariableSizeEncoder } from '@s import { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } from '@solana/errors'; import { SignatureBytes } from '@solana/keys'; -import { NewTransaction, TransactionMessageBytes } from '../../transaction'; +import { Transaction, TransactionMessageBytes } from '../../transaction'; import { getSignaturesEncoder } from '../signatures-encoder'; import { getTransactionCodec, getTransactionDecoder, getTransactionEncoder } from '../transaction-codec'; @@ -13,7 +13,7 @@ jest.mock('../signatures-encoder'); describe.each([getTransactionEncoder, getTransactionCodec])('Transaction encoder %p', encoderFactory => { const mockEncodedSignatures = new Uint8Array([1, 2, 3]); - let encoder: VariableSizeEncoder; + let encoder: VariableSizeEncoder; beforeEach(() => { (getSignaturesEncoder as jest.Mock).mockReturnValue({ getSizeFromValue: jest.fn().mockReturnValue(mockEncodedSignatures.length), @@ -28,7 +28,7 @@ describe.each([getTransactionEncoder, getTransactionCodec])('Transaction encoder it('should encode the transaction correctly', () => { const messageBytes = new Uint8Array([4, 5, 6]) as ReadonlyUint8Array as TransactionMessageBytes; - const transaction: NewTransaction = { + const transaction: Transaction = { messageBytes, signatures: {}, }; @@ -45,7 +45,7 @@ describe.each([getTransactionEncoder, getTransactionCodec])('Transaction encoder }); describe.each([getTransactionDecoder, getTransactionCodec])('Transaction decoder %p', decoderFactory => { - let decoder: VariableSizeDecoder; + let decoder: VariableSizeDecoder; beforeEach(() => { (getSignaturesEncoder as jest.Mock).mockReturnValue({ getSizeFromValue: jest.fn().mockReturnValue(0), @@ -87,7 +87,7 @@ describe.each([getTransactionDecoder, getTransactionCodec])('Transaction decoder ...messageBytes, ]); - const expectedTransaction: NewTransaction = { + const expectedTransaction: Transaction = { messageBytes: messageBytes, signatures: { [address]: signature, @@ -126,7 +126,7 @@ describe.each([getTransactionDecoder, getTransactionCodec])('Transaction decoder ]); const address = 'k7FaK87WHGVXzkaoHb7CdVPgkKDQhZ29VLDeBVbDfYn' as Address; - const expectedTransaction: NewTransaction = { + const expectedTransaction: Transaction = { messageBytes: messageBytes, signatures: { [address]: null, @@ -215,7 +215,7 @@ describe.each([getTransactionDecoder, getTransactionCodec])('Transaction decoder ...messageBytes, ]); - const expectedTransaction: NewTransaction = { + const expectedTransaction: Transaction = { messageBytes: messageBytes, signatures: { [address1]: signature1, @@ -258,7 +258,7 @@ describe.each([getTransactionDecoder, getTransactionCodec])('Transaction decoder ...messageBytes, ]); - const expectedTransaction: NewTransaction = { + const expectedTransaction: Transaction = { messageBytes: messageBytes, signatures: { [address1]: null, @@ -301,7 +301,7 @@ describe.each([getTransactionDecoder, getTransactionCodec])('Transaction decoder ...messageBytes, ]); - const expectedTransaction: NewTransaction = { + const expectedTransaction: Transaction = { messageBytes: messageBytes, signatures: { [address1]: signature1, diff --git a/packages/transactions/src/codecs/transaction-codec.ts b/packages/transactions/src/codecs/transaction-codec.ts index 6efe98b34745..f9d8652934f7 100644 --- a/packages/transactions/src/codecs/transaction-codec.ts +++ b/packages/transactions/src/codecs/transaction-codec.ts @@ -22,17 +22,17 @@ import { SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, SolanaError } f import { SignatureBytes } from '@solana/keys'; import { getTransactionVersionDecoder } from '@solana/transaction-messages'; -import { NewTransaction, SignaturesMap, TransactionMessageBytes } from '../transaction'; +import { SignaturesMap, Transaction, TransactionMessageBytes } from '../transaction'; import { getSignaturesEncoder } from './signatures-encoder'; -export function getTransactionEncoder(): VariableSizeEncoder { +export function getTransactionEncoder(): VariableSizeEncoder { return getStructEncoder([ ['signatures', getSignaturesEncoder()], ['messageBytes', getBytesEncoder()], ]); } -export function getTransactionDecoder(): VariableSizeDecoder { +export function getTransactionDecoder(): VariableSizeDecoder { return transformDecoder( getStructDecoder([ ['signatures', getArrayDecoder(fixDecoderSize(getBytesDecoder(), 64), { size: getShortU16Decoder() })], @@ -42,7 +42,7 @@ export function getTransactionDecoder(): VariableSizeDecoder { ); } -export function getTransactionCodec(): VariableSizeCodec { +export function getTransactionCodec(): VariableSizeCodec { return combineCodec(getTransactionEncoder(), getTransactionDecoder()); } @@ -51,7 +51,7 @@ type PartiallyDecodedTransaction = { signatures: ReadonlyUint8Array[]; }; -function decodePartiallyDecodedTransaction(transaction: PartiallyDecodedTransaction): NewTransaction { +function decodePartiallyDecodedTransaction(transaction: PartiallyDecodedTransaction): Transaction { const { messageBytes, signatures } = transaction; /* diff --git a/packages/transactions/src/compile-transaction.ts b/packages/transactions/src/compile-transaction.ts index cf15cc411f2d..d725c25379c3 100644 --- a/packages/transactions/src/compile-transaction.ts +++ b/packages/transactions/src/compile-transaction.ts @@ -15,23 +15,23 @@ import { TransactionWithDurableNonceLifetime, TransactionWithLifetime, } from './lifetime'; -import { NewTransaction, OrderedMap, TransactionMessageBytes } from './transaction'; +import { OrderedMap, Transaction, TransactionMessageBytes } from './transaction'; export function compileTransaction( transactionMessage: CompilableTransactionMessage & ITransactionMessageWithBlockhashLifetime, -): Readonly; +): Readonly; export function compileTransaction( transactionMessage: CompilableTransactionMessage & IDurableNonceTransactionMessage, -): Readonly; +): Readonly; export function compileTransaction( transactionMessage: CompilableTransactionMessage, -): Readonly; +): Readonly; export function compileTransaction( transactionMessage: CompilableTransactionMessage, -): Readonly { +): Readonly { const compiledMessage = newCompileTransactionMessage(transactionMessage); const messageBytes = getCompiledTransactionMessageEncoder().encode( compiledMessage, @@ -56,7 +56,7 @@ export function compileTransaction( }; } - const transaction: NewTransaction & TransactionWithLifetime = { + const transaction: Transaction & TransactionWithLifetime = { lifetimeConstraint, messageBytes: messageBytes as TransactionMessageBytes, signatures: Object.freeze(signatures), diff --git a/packages/transactions/src/signatures.ts b/packages/transactions/src/signatures.ts index 33e65e44c6b3..aea05f8cbcde 100644 --- a/packages/transactions/src/signatures.ts +++ b/packages/transactions/src/signatures.ts @@ -9,15 +9,15 @@ import { } from '@solana/errors'; import { Signature, SignatureBytes, signBytes } from '@solana/keys'; -import { NewTransaction } from './transaction'; +import { Transaction } from './transaction'; -export interface FullySignedTransaction extends NewTransaction { +export interface FullySignedTransaction extends Transaction { readonly __brand: unique symbol; } let base58Decoder: Decoder | undefined; -export function getSignatureFromTransaction(transaction: NewTransaction): Signature { +export function getSignatureFromTransaction(transaction: Transaction): Signature { if (!base58Decoder) base58Decoder = getBase58Decoder(); // We have ordered signatures from the compiled message accounts @@ -34,7 +34,7 @@ function uint8ArraysEqual(arr1: Uint8Array, arr2: Uint8Array) { return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]); } -export async function partiallySignTransaction( +export async function partiallySignTransaction( keyPairs: CryptoKeyPair[], transaction: T, ): Promise { @@ -92,7 +92,7 @@ export async function partiallySignTransaction( }); } -export async function signTransaction( +export async function signTransaction( keyPairs: CryptoKeyPair[], transaction: T, ): Promise { @@ -103,7 +103,7 @@ export async function signTransaction( } export function assertTransactionIsFullySigned( - transaction: NewTransaction, + transaction: Transaction, ): asserts transaction is FullySignedTransaction { const missingSigs: Address[] = []; Object.entries(transaction.signatures).forEach(([address, signatureBytes]) => { diff --git a/packages/transactions/src/transaction.ts b/packages/transactions/src/transaction.ts index b83a757989be..b1f9e35beb1b 100644 --- a/packages/transactions/src/transaction.ts +++ b/packages/transactions/src/transaction.ts @@ -8,7 +8,7 @@ export type TransactionMessageBytesBase64 = string & { readonly __serializedMess export type OrderedMap = Record; export type SignaturesMap = OrderedMap; -export type NewTransaction = Readonly<{ +export type Transaction = Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }>; diff --git a/packages/transactions/src/wire-transaction.ts b/packages/transactions/src/wire-transaction.ts index 60d6bcfd95f8..e8df8b52c334 100644 --- a/packages/transactions/src/wire-transaction.ts +++ b/packages/transactions/src/wire-transaction.ts @@ -1,13 +1,13 @@ import { getBase64Decoder } from '@solana/codecs-strings'; import { getTransactionEncoder } from './codecs'; -import { NewTransaction } from './transaction'; +import { Transaction } from './transaction'; export type Base64EncodedWireTransaction = string & { readonly __brand: unique symbol; }; -export function getBase64EncodedWireTransaction(transaction: NewTransaction): Base64EncodedWireTransaction { +export function getBase64EncodedWireTransaction(transaction: Transaction): Base64EncodedWireTransaction { const wireTransactionBytes = getTransactionEncoder().encode(transaction); return getBase64Decoder().decode(wireTransactionBytes) as Base64EncodedWireTransaction; }