From 88011cfd587bcf376ea1bc0b2e286cd97d3e495a Mon Sep 17 00:00:00 2001 From: Callum Date: Thu, 18 Apr 2024 12:07:07 +0400 Subject: [PATCH] Rename newCompileTransactionMessage to compileTransactionMessage --- .../src/compile/__tests__/message-test.ts | 18 +++++++++--------- .../src/compile/message.ts | 6 +++--- .../src/__tests__/compile-transaction-test.ts | 6 +++--- .../transactions/src/compile-transaction.ts | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/transaction-messages/src/compile/__tests__/message-test.ts b/packages/transaction-messages/src/compile/__tests__/message-test.ts index b01545ec3cf6..c651bd05a6ab 100644 --- a/packages/transaction-messages/src/compile/__tests__/message-test.ts +++ b/packages/transaction-messages/src/compile/__tests__/message-test.ts @@ -6,7 +6,7 @@ import { getCompiledAddressTableLookups } from '../address-table-lookups'; import { getCompiledMessageHeader } from '../header'; import { getCompiledInstructions } from '../instructions'; import { getCompiledLifetimeToken } from '../lifetime-token'; -import { newCompileTransactionMessage } from '../message'; +import { compileTransactionMessage } from '../message'; import { getCompiledStaticAccounts } from '../static-accounts'; jest.mock('../address-table-lookups'); @@ -39,16 +39,16 @@ describe('compileTransactionMessage', () => { legacyBaseTx = { ...baseTx, version: 'legacy' }; }); it('does not set `addressTableLookups`', () => { - const message = newCompileTransactionMessage(legacyBaseTx); + const message = compileTransactionMessage(legacyBaseTx); expect(message).not.toHaveProperty('addressTableLookups'); }); it('does not call `getCompiledAddressTableLookups`', () => { - newCompileTransactionMessage(legacyBaseTx); + compileTransactionMessage(legacyBaseTx); expect(getCompiledAddressTableLookups).not.toHaveBeenCalled(); }); }); it('sets `addressTableLookups` to the return value of `getCompiledAddressTableLookups`', () => { - const message = newCompileTransactionMessage(baseTx); + const message = compileTransactionMessage(baseTx); expect(getCompiledAddressTableLookups).toHaveBeenCalled(); expect(message.addressTableLookups).toBe(expectedAddressTableLookups); }); @@ -63,7 +63,7 @@ describe('compileTransactionMessage', () => { jest.mocked(getCompiledMessageHeader).mockReturnValue(expectedCompiledMessageHeader); }); it('sets `header` to the return value of `getCompiledMessageHeader`', () => { - const message = newCompileTransactionMessage(baseTx); + const message = compileTransactionMessage(baseTx); expect(getCompiledMessageHeader).toHaveBeenCalled(); expect(message.header).toBe(expectedCompiledMessageHeader); }); @@ -74,7 +74,7 @@ describe('compileTransactionMessage', () => { jest.mocked(getCompiledInstructions).mockReturnValue(expectedInstructions); }); it('sets `instructions` to the return value of `getCompiledInstructions`', () => { - const message = newCompileTransactionMessage(baseTx); + const message = compileTransactionMessage(baseTx); console.log({ message }); expect(getCompiledInstructions).toHaveBeenCalledWith( baseTx.instructions, @@ -88,7 +88,7 @@ describe('compileTransactionMessage', () => { jest.mocked(getCompiledLifetimeToken).mockReturnValue('abc'); }); it('sets `lifetimeToken` to the return value of `getCompiledLifetimeToken`', () => { - const message = newCompileTransactionMessage(baseTx); + const message = compileTransactionMessage(baseTx); expect(getCompiledLifetimeToken).toHaveBeenCalledWith('SOME_CONSTRAINT'); expect(message.lifetimeToken).toBe('abc'); }); @@ -99,14 +99,14 @@ describe('compileTransactionMessage', () => { jest.mocked(getCompiledStaticAccounts).mockReturnValue(expectedStaticAccounts); }); it('sets `staticAccounts` to the return value of `getCompiledStaticAccounts`', () => { - const message = newCompileTransactionMessage(baseTx); + const message = compileTransactionMessage(baseTx); expect(getCompiledStaticAccounts).toHaveBeenCalled(); expect(message.staticAccounts).toBe(expectedStaticAccounts); }); }); describe('versions', () => { it('compiles the version', () => { - const message = newCompileTransactionMessage(baseTx); + const message = compileTransactionMessage(baseTx); expect(message).toHaveProperty('version', 0); }); }); diff --git a/packages/transaction-messages/src/compile/message.ts b/packages/transaction-messages/src/compile/message.ts index 649a86d26003..9fda71dc8131 100644 --- a/packages/transaction-messages/src/compile/message.ts +++ b/packages/transaction-messages/src/compile/message.ts @@ -26,13 +26,13 @@ type VersionedCompiledTransactionMessage = BaseCompiledTransactionMessage & version: number; }>; -export function newCompileTransactionMessage( +export function compileTransactionMessage( transaction: CompilableTransactionMessage & Readonly<{ version: 'legacy' }>, ): LegacyCompiledTransactionMessage; -export function newCompileTransactionMessage( +export function compileTransactionMessage( transaction: CompilableTransactionMessage, ): VersionedCompiledTransactionMessage; -export function newCompileTransactionMessage(transaction: CompilableTransactionMessage): CompiledTransactionMessage { +export function compileTransactionMessage(transaction: CompilableTransactionMessage): CompiledTransactionMessage { const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions); const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap); return { diff --git a/packages/transactions/src/__tests__/compile-transaction-test.ts b/packages/transactions/src/__tests__/compile-transaction-test.ts index 5124db97eb14..843ee0e6f3d9 100644 --- a/packages/transactions/src/__tests__/compile-transaction-test.ts +++ b/packages/transactions/src/__tests__/compile-transaction-test.ts @@ -4,8 +4,8 @@ import { Address } from '@solana/addresses'; import { Blockhash } from '@solana/rpc-types'; import { CompiledTransactionMessage, + compileTransactionMessage, getCompiledTransactionMessageEncoder, - newCompileTransactionMessage, NewNonce, } from '@solana/transaction-messages'; @@ -13,8 +13,8 @@ import { compileTransaction } from '../compile-transaction'; jest.mock('@solana/transaction-messages', () => ({ ...jest.requireActual('@solana/transaction-messages'), + compileTransactionMessage: jest.fn(), getCompiledTransactionMessageEncoder: jest.fn(), - newCompileTransactionMessage: jest.fn(), })); type TransactionMessage = Parameters[0]; @@ -35,7 +35,7 @@ describe('compileTransactionMessage', () => { } as CompiledTransactionMessage; const mockCompiledMessageBytes = new Uint8Array(Array(100)).fill(1); beforeEach(() => { - (newCompileTransactionMessage as jest.Mock).mockReturnValue(mockCompiledMessage); + (compileTransactionMessage as jest.Mock).mockReturnValue(mockCompiledMessage); (getCompiledTransactionMessageEncoder as jest.Mock).mockReturnValue({ encode: jest.fn().mockReturnValue(mockCompiledMessageBytes), }); diff --git a/packages/transactions/src/compile-transaction.ts b/packages/transactions/src/compile-transaction.ts index a69098abeb58..910c48633341 100644 --- a/packages/transactions/src/compile-transaction.ts +++ b/packages/transactions/src/compile-transaction.ts @@ -1,11 +1,11 @@ import { ReadonlyUint8Array } from '@solana/codecs-core'; import { CompilableTransactionMessage, + compileTransactionMessage, getCompiledTransactionMessageEncoder, IDurableNonceTransactionMessage, isTransactionMessageWithBlockhashLifetime, ITransactionMessageWithBlockhashLifetime, - newCompileTransactionMessage, } from '@solana/transaction-messages'; import { @@ -30,7 +30,7 @@ export function compileTransaction( export function compileTransaction( transactionMessage: CompilableTransactionMessage, ): Readonly { - const compiledMessage = newCompileTransactionMessage(transactionMessage); + const compiledMessage = compileTransactionMessage(transactionMessage); const messageBytes = getCompiledTransactionMessageEncoder().encode( compiledMessage, ) as ReadonlyUint8Array as TransactionMessageBytes;