diff --git a/packages/rpc-api/package.json b/packages/rpc-api/package.json index 9be40986d75e..e6c5970facef 100644 --- a/packages/rpc-api/package.json +++ b/packages/rpc-api/package.json @@ -72,6 +72,7 @@ "@solana/rpc-parsed-types": "workspace:*", "@solana/rpc-transformers": "workspace:*", "@solana/rpc-types": "workspace:*", + "@solana/transaction-messages": "workspace:*", "@solana/transactions": "workspace:*" }, "devDependencies": { diff --git a/packages/rpc-api/src/__tests__/get-fee-for-message-test.ts b/packages/rpc-api/src/__tests__/get-fee-for-message-test.ts index 7dd0059a32a8..7fc919917f60 100644 --- a/packages/rpc-api/src/__tests__/get-fee-for-message-test.ts +++ b/packages/rpc-api/src/__tests__/get-fee-for-message-test.ts @@ -7,7 +7,7 @@ import { } from '@solana/errors'; import type { Rpc } from '@solana/rpc-spec'; import type { Blockhash, Commitment } from '@solana/rpc-types'; -import type { SerializedMessageBytesBase64 } from '@solana/transactions'; +import type { TransactionMessageBytesBase64 } from '@solana/transactions'; import { GetFeeForMessageApi, GetLatestBlockhashApi } from '../index'; import { createLocalhostSolanaRpc } from './__setup__'; @@ -56,7 +56,7 @@ function getMockTransactionMessage(blockhash: Blockhash) { /** ADDRESS TABLE LOOKUPS */ 0x00, // Number of address table lookups ]); - return getBase64Decoder().decode(message) as SerializedMessageBytesBase64; + return getBase64Decoder().decode(message) as TransactionMessageBytesBase64; } describe('getFeeForMessage', () => { @@ -111,7 +111,7 @@ describe('getFeeForMessage', () => { describe('when called with an invalid message', () => { it('throws an error', async () => { expect.assertions(1); - const sendPromise = rpc.getFeeForMessage('someInvalidMessage' as SerializedMessageBytesBase64).send(); + const sendPromise = rpc.getFeeForMessage('someInvalidMessage' as TransactionMessageBytesBase64).send(); await expect(sendPromise).rejects.toThrow( new SolanaError(SOLANA_ERROR__JSON_RPC__INVALID_PARAMS, { __serverMessage: 'invalid base64 encoding: InvalidPadding', diff --git a/packages/rpc-api/src/__typetests__/get-block-type-test.ts b/packages/rpc-api/src/__typetests__/get-block-type-test.ts index d453aa3e0f86..6a9dd51d241e 100644 --- a/packages/rpc-api/src/__typetests__/get-block-type-test.ts +++ b/packages/rpc-api/src/__typetests__/get-block-type-test.ts @@ -12,7 +12,7 @@ import type { TransactionStatus, U64UnsafeBeyond2Pow53Minus1, } from '@solana/rpc-types'; -import { TransactionVersion } from '@solana/transactions'; +import { NewTransactionVersion } from '@solana/transaction-messages'; import { GetBlockApi } from '../getBlock'; @@ -292,7 +292,7 @@ async () => { }>[]; signatures: readonly Base58EncodedBytes[]; }; - version: TransactionVersion; + version: NewTransactionVersion; }; // Fifth overload @@ -543,7 +543,7 @@ async () => { }>) | null; transaction: Base58EncodedDataResponse; - version: TransactionVersion; + version: NewTransactionVersion; }; // Ninth overload @@ -767,7 +767,7 @@ async () => { }>) | null; transaction: Base64EncodedDataResponse; - version: TransactionVersion; + version: NewTransactionVersion; }; // Thirteenth overload @@ -991,7 +991,7 @@ async () => { }>[]; }>; }; - version: TransactionVersion; + version: NewTransactionVersion; }; // Seventeenth overload @@ -1139,7 +1139,7 @@ async () => { type ExpectedTransactionForFullJsonVersioned = { meta: (ExpectedMetaForFullJsonBase & ExpectedMetaForFullJsonLoadedAddresses) | null; transaction: ExpectedTransactionForFullJsonBase; - version: TransactionVersion; + version: NewTransactionVersion; }; // Twenty-first overload diff --git a/packages/rpc-api/src/getBlock.ts b/packages/rpc-api/src/getBlock.ts index 9e165ec33680..70965b5f7b92 100644 --- a/packages/rpc-api/src/getBlock.ts +++ b/packages/rpc-api/src/getBlock.ts @@ -13,7 +13,7 @@ import type { U64UnsafeBeyond2Pow53Minus1, UnixTimestamp, } from '@solana/rpc-types'; -import type { TransactionVersion } from '@solana/transactions'; +import type { NewTransactionVersion } from '@solana/transaction-messages'; // API response types @@ -60,7 +60,7 @@ type GetBlockEncoding = 'base58' | 'base64' | 'json' | 'jsonParsed'; // This will error if the block contains any transactions with a version greater than "legacy" (code -32015). // - Also, If `maxSupportedTransactionVersion` is not provided, the `version` field of each transaction is omitted. // - These rules apply to both "accounts" and "full" transaction details. -type GetBlockMaxSupportedTransactionVersion = Exclude; +type GetBlockMaxSupportedTransactionVersion = Exclude; export interface GetBlockApi extends RpcApiMethods { /** diff --git a/packages/rpc-api/src/getFeeForMessage.ts b/packages/rpc-api/src/getFeeForMessage.ts index 18b8fa92f7b5..7d7fdbdac5e6 100644 --- a/packages/rpc-api/src/getFeeForMessage.ts +++ b/packages/rpc-api/src/getFeeForMessage.ts @@ -1,6 +1,6 @@ import type { RpcApiMethods } from '@solana/rpc-spec'; import type { Commitment, Slot, SolanaRpcResponse, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; -import type { SerializedMessageBytesBase64 } from '@solana/transactions'; +import type { TransactionMessageBytesBase64 } from '@solana/transactions'; /** Fee corresponding to the message at the specified blockhash */ type GetFeeForMessageApiResponse = SolanaRpcResponse; @@ -10,7 +10,7 @@ export interface GetFeeForMessageApi extends RpcApiMethods { * Returns the fee the network will charge for a particular Message */ getFeeForMessage( - message: SerializedMessageBytesBase64, + message: TransactionMessageBytesBase64, config?: Readonly<{ commitment?: Commitment; minContextSlot?: Slot; diff --git a/packages/rpc-api/src/getTransaction.ts b/packages/rpc-api/src/getTransaction.ts index 8ea2585b44c3..1d9e95247d0e 100644 --- a/packages/rpc-api/src/getTransaction.ts +++ b/packages/rpc-api/src/getTransaction.ts @@ -16,7 +16,7 @@ import type { U64UnsafeBeyond2Pow53Minus1, UnixTimestamp, } from '@solana/rpc-types'; -import type { TransactionVersion } from '@solana/transactions'; +import type { NewTransactionVersion } from '@solana/transaction-messages'; type ReturnData = { /** the return data itself */ @@ -162,7 +162,7 @@ export interface GetTransactionApi extends RpcApiMethods { /** * Returns transaction details for a confirmed transaction */ - getTransaction( + getTransaction( signature: Signature, config: GetTransactionCommonConfig & Readonly<{ @@ -172,7 +172,7 @@ export interface GetTransactionApi extends RpcApiMethods { | (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record - : { version: TransactionVersion }) & { + : { version: NewTransactionVersion }) & { meta: (TransactionMetaBase & TransactionMetaInnerInstructionsParsed) | null; transaction: TransactionJsonParsed & (TMaxSupportedTransactionVersion extends void @@ -180,7 +180,7 @@ export interface GetTransactionApi extends RpcApiMethods { : TransactionAddressTableLookups); }) | null; - getTransaction( + getTransaction( signature: Signature, config: GetTransactionCommonConfig & Readonly<{ @@ -190,7 +190,7 @@ export interface GetTransactionApi extends RpcApiMethods { | (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record - : { version: TransactionVersion }) & { + : { version: NewTransactionVersion }) & { meta: | (TransactionMetaBase & TransactionMetaInnerInstructionsNotParsed & @@ -201,7 +201,7 @@ export interface GetTransactionApi extends RpcApiMethods { transaction: Base64EncodedDataResponse; }) | null; - getTransaction( + getTransaction( signature: Signature, config: GetTransactionCommonConfig & Readonly<{ @@ -211,7 +211,7 @@ export interface GetTransactionApi extends RpcApiMethods { | (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record - : { version: TransactionVersion }) & { + : { version: NewTransactionVersion }) & { meta: | (TransactionMetaBase & TransactionMetaInnerInstructionsNotParsed & @@ -222,7 +222,7 @@ export interface GetTransactionApi extends RpcApiMethods { transaction: Base58EncodedDataResponse; }) | null; - getTransaction( + getTransaction( signature: Signature, config?: GetTransactionCommonConfig & Readonly<{ @@ -232,7 +232,7 @@ export interface GetTransactionApi extends RpcApiMethods { | (GetTransactionApiResponseBase & (TMaxSupportedTransactionVersion extends void ? Record - : { version: TransactionVersion }) & { + : { version: NewTransactionVersion }) & { meta: | (TransactionMetaBase & TransactionMetaInnerInstructionsNotParsed & diff --git a/packages/rpc-subscriptions-api/package.json b/packages/rpc-subscriptions-api/package.json index 4ff27f1a3536..cd2dfcb92ec6 100644 --- a/packages/rpc-subscriptions-api/package.json +++ b/packages/rpc-subscriptions-api/package.json @@ -68,6 +68,7 @@ "@solana/rpc-types": "workspace:*", "@solana/rpc-subscriptions-spec": "workspace:*", "@solana/rpc-transformers": "workspace:*", + "@solana/transaction-messages": "workspace:*", "@solana/transactions": "workspace:*" }, "devDependencies": { 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 822b28e71160..21cbf3d38707 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 @@ -14,7 +14,7 @@ import type { TransactionStatus, U64UnsafeBeyond2Pow53Minus1, } from '@solana/rpc-types'; -import type { TransactionVersion } from '@solana/transactions'; +import type { NewTransactionVersion } from '@solana/transaction-messages'; import type { BlockNotificationsApi } from '../block-notifications'; @@ -447,7 +447,7 @@ type ExpectedTransactionForAccountsBaseVersioned = { }>[]; signatures: readonly Base58EncodedBytes[]; }; - version: TransactionVersion; + version: NewTransactionVersion; }; // Fifth overload @@ -755,7 +755,7 @@ type ExpectedTransactionForFullBase58Versioned = { }>) | null; transaction: Base58EncodedDataResponse; - version: TransactionVersion; + version: NewTransactionVersion; }; // Ninth overload @@ -1021,7 +1021,7 @@ type ExpectedTransactionForFullBase64Versioned = { }>) | null; transaction: Base64EncodedDataResponse; - version: TransactionVersion; + version: NewTransactionVersion; }; // Thirteenth overload @@ -1276,7 +1276,7 @@ type ExpectedTransactionForFullJsonParsedVersioned = { }>[]; }>; }; - version: TransactionVersion; + version: NewTransactionVersion; }; // Seventeenth overload @@ -1443,7 +1443,7 @@ type ExpectedTransactionForFullJsonLegacy = { type ExpectedTransactionForFullJsonVersioned = { meta: (ExpectedMetaForFullJsonBase & ExpectedMetaForFullJsonLoadedAddresses) | null; transaction: ExpectedTransactionForFullJsonBase; - version: TransactionVersion; + version: NewTransactionVersion; }; // Twenty-first overload diff --git a/packages/rpc-subscriptions-api/src/block-notifications.ts b/packages/rpc-subscriptions-api/src/block-notifications.ts index 72c19d4c934a..ba9813d91385 100644 --- a/packages/rpc-subscriptions-api/src/block-notifications.ts +++ b/packages/rpc-subscriptions-api/src/block-notifications.ts @@ -14,7 +14,7 @@ import type { U64UnsafeBeyond2Pow53Minus1, UnixTimestamp, } from '@solana/rpc-types'; -import type { TransactionVersion } from '@solana/transactions'; +import type { NewTransactionVersion } from '@solana/transaction-messages'; // Subscription notification types @@ -78,7 +78,7 @@ type BlockNotificationsEncoding = 'base58' | 'base64' | 'json' | 'jsonParsed'; // This will error if the block contains any transactions with a version greater than "legacy" (code -32015). // - Also, If `maxSupportedTransactionVersion` is not provided, the `version` field of each transaction is omitted. // - These rules apply to both "accounts" and "full" transaction details. -type BlockNotificationsMaxSupportedTransactionVersion = Exclude; +type BlockNotificationsMaxSupportedTransactionVersion = Exclude; export interface BlockNotificationsApi extends RpcSubscriptionsApiMethods { /** diff --git a/packages/transactions/src/index.ts b/packages/transactions/src/index.ts index ce4be2283034..5ad6d501751d 100644 --- a/packages/transactions/src/index.ts +++ b/packages/transactions/src/index.ts @@ -6,4 +6,3 @@ export * from './new-compile-transaction'; export * from './new-signatures'; export * from './new-wire-transaction'; export * from './transaction'; -export * from './types'; // some uses to clean up before removing diff --git a/packages/transactions/src/transaction.ts b/packages/transactions/src/transaction.ts index 39a1a30a0599..b83a757989be 100644 --- a/packages/transactions/src/transaction.ts +++ b/packages/transactions/src/transaction.ts @@ -3,6 +3,8 @@ import { ReadonlyUint8Array } from '@solana/codecs-core'; import { SignatureBytes } from '@solana/keys'; export type TransactionMessageBytes = ReadonlyUint8Array & { readonly __brand: unique symbol }; +export type TransactionMessageBytesBase64 = string & { readonly __serializedMessageBytesBase64: unique symbol }; + export type OrderedMap = Record; export type SignaturesMap = OrderedMap; diff --git a/packages/transactions/src/types.ts b/packages/transactions/src/types.ts index e037625daf32..345ac18cc4c2 100644 --- a/packages/transactions/src/types.ts +++ b/packages/transactions/src/types.ts @@ -1,9 +1,5 @@ import { IAccountMeta, IInstruction } from '@solana/instructions'; -/** A string of bytes that are definitely a serialized message */ -export type SerializedMessageBytes = Uint8Array & { readonly __serializedMessageBytes: unique symbol }; -export type SerializedMessageBytesBase64 = string & { readonly __serializedMessageBytesBase64: unique symbol }; - export type BaseTransaction< TVersion extends TransactionVersion = TransactionVersion, TInstruction extends IInstruction = IInstruction, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a95502be0cf..921e466eecfb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -646,6 +646,9 @@ importers: '@solana/rpc-types': specifier: workspace:* version: link:../rpc-types + '@solana/transaction-messages': + specifier: workspace:* + version: link:../transaction-messages '@solana/transactions': specifier: workspace:* version: link:../transactions @@ -755,6 +758,9 @@ importers: '@solana/rpc-types': specifier: workspace:* version: link:../rpc-types + '@solana/transaction-messages': + specifier: workspace:* + version: link:../transaction-messages '@solana/transactions': specifier: workspace:* version: link:../transactions diff --git a/turbo.json b/turbo.json index 1959551a7112..c04a6ead443b 100644 --- a/turbo.json +++ b/turbo.json @@ -10,21 +10,35 @@ "test:treeshakability:browser", "test:treeshakability:native", "test:treeshakability:node", - "test:typecheck", - "test:unit:browser", - "test:unit:node" + "test:typecheck" ], - "outputs": ["dist/**"] + "outputs": [ + "dist/**" + ] }, "compile:js": { - "dependsOn": ["^compile:js"], - "inputs": ["tsconfig.*", "src/**"], - "outputs": ["dist/**"] + "dependsOn": [ + "^compile:js" + ], + "inputs": [ + "tsconfig.*", + "src/**" + ], + "outputs": [ + "dist/**" + ] }, "compile:typedefs": { - "dependsOn": ["^compile:typedefs"], - "inputs": ["tsconfig.*", "src/**"], - "outputs": ["dist/**/*.d.ts"] + "dependsOn": [ + "^compile:typedefs" + ], + "inputs": [ + "tsconfig.*", + "src/**" + ], + "outputs": [ + "dist/**/*.d.ts" + ] }, "publish-packages": { "cache": false, @@ -55,41 +69,75 @@ ] }, "style:fix": { - "inputs": ["*"], - "outputs": ["*"] + "inputs": [ + "*" + ], + "outputs": [ + "*" + ] }, "test:lint": { - "dependsOn": ["^compile:typedefs"], - "inputs": ["src/**", "test/**"], + "dependsOn": [ + "^compile:typedefs" + ], + "inputs": [ + "src/**", + "test/**" + ], "outputs": [] }, "test:live-with-test-validator": { - "dependsOn": ["^compile:js"], - "inputs": ["src/**"] + "dependsOn": [ + "^compile:js" + ], + "inputs": [ + "src/**" + ] }, "test:prettier": { - "inputs": ["*"] + "inputs": [ + "*" + ] }, "test:typecheck": { - "dependsOn": ["^compile:typedefs"], - "inputs": ["tsconfig.*", "src/**"] + "dependsOn": [ + "^compile:typedefs" + ], + "inputs": [ + "tsconfig.*", + "src/**" + ] }, "test:unit:browser": { - "dependsOn": ["^compile:js"], - "inputs": ["src/**"] + "dependsOn": [ + "^compile:js" + ], + "inputs": [ + "src/**" + ] }, "test:unit:node": { - "dependsOn": ["^compile:js"], - "inputs": ["src/**"] + "dependsOn": [ + "^compile:js" + ], + "inputs": [ + "src/**" + ] }, "test:treeshakability:browser": { - "dependsOn": ["compile:js"] + "dependsOn": [ + "compile:js" + ] }, "test:treeshakability:native": { - "dependsOn": ["compile:js"] + "dependsOn": [ + "compile:js" + ] }, "test:treeshakability:node": { - "dependsOn": ["compile:js"] + "dependsOn": [ + "compile:js" + ] }, "@solana/web3.js#build": { "dependsOn": [ @@ -98,28 +146,53 @@ "compile:js", "compile:typedefs", "test:lint", - "test:live-with-test-validator", "test:prettier", - "test:typecheck", - "test:unit:node" + "test:typecheck" ], - "outputs": ["doc/**", "declarations/**", "lib/**"] + "outputs": [ + "doc/**", + "declarations/**", + "lib/**" + ] }, "@solana/web3.js#clean": { - "outputs": ["doc/**", "declarations/**", "lib/**"] + "outputs": [ + "doc/**", + "declarations/**", + "lib/**" + ] }, "@solana/web3.js#compile:docs": { - "dependsOn": ["clean"], - "inputs": ["src/**"], - "outputs": ["doc/**"] + "dependsOn": [ + "clean" + ], + "inputs": [ + "src/**" + ], + "outputs": [ + "doc/**" + ] }, "@solana/web3.js#compile:js": { - "dependsOn": ["clean", "^compile:js"], - "inputs": ["babel.config.json", "rollup.config.mjs", "tsconfig.*", "src/**"], - "outputs": ["lib/**"] + "dependsOn": [ + "clean", + "^compile:js" + ], + "inputs": [ + "babel.config.json", + "rollup.config.mjs", + "tsconfig.*", + "src/**" + ], + "outputs": [ + "lib/**" + ] }, "@solana/web3.js#compile:typedefs": { - "dependsOn": ["clean", "^compile:typedefs"], + "dependsOn": [ + "clean", + "^compile:typedefs" + ], "inputs": [ "rollup.config.types.mjs", "scripts/typegen.sh", @@ -127,25 +200,47 @@ "test/__shadow-jest-types.d.ts", "tsconfig.*" ], - "outputs": ["declarations/**", "lib/**/*.d.ts"] + "outputs": [ + "declarations/**", + "lib/**/*.d.ts" + ] }, "@solana/web3.js#test:lint": { - "inputs": ["src/**", "test/**"] + "inputs": [ + "src/**", + "test/**" + ] }, "@solana/web3.js#test:live-with-test-validator": { - "dependsOn": ["^compile:js"], - "inputs": ["src/**", "test/**"] + "dependsOn": [ + "^compile:js" + ], + "inputs": [ + "src/**", + "test/**" + ] }, "@solana/web3.js#test:typecheck": { - "dependsOn": ["^compile:typedefs"], - "inputs": ["src/**", "test/**", "tsconfig.*"] + "dependsOn": [ + "^compile:typedefs" + ], + "inputs": [ + "src/**", + "test/**", + "tsconfig.*" + ] }, "@solana/web3.js#test:unit:node": { - "dependsOn": ["^compile:js"], - "inputs": ["src/**", "test/**"] + "dependsOn": [ + "^compile:js" + ], + "inputs": [ + "src/**", + "test/**" + ] } }, "remoteCache": { "signature": true } -} +} \ No newline at end of file