UNPKG

@solana/kit

Version:

Solana Javascript API

1 lines 66 kB
{"version":3,"sources":["../src/create-async-generator-with-initial-value-and-slot-tracking.ts","../src/create-reactive-store-with-initial-value-and-slot-tracking.ts","../src/airdrop-internal.ts","../src/airdrop.ts","../src/compute-unit-limit-estimation.ts","../src/fetch-lookup-tables.ts","../src/decompile-transaction-message-fetching-lookup-tables.ts","../src/get-minimum-balance-for-rent-exemption.ts","../src/send-transaction-internal.ts","../src/send-and-confirm-durable-nonce-transaction.ts","../src/send-and-confirm-transaction.ts","../src/send-transaction-without-confirming.ts"],"names":["getBase64EncodedWireTransaction","createRecentSignatureConfirmationPromiseFactory","isSolanaError","commitmentComparator","getSolanaErrorFromTransactionError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,gBAAuB,mDAAA,CAA0F;AAAA,EAC7G,WAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,sBAAA;AAAA,EACA;AACJ,CAAA,EAEE;AACE,EAAA,IAAI,YAAY,OAAA,EAAS;AAEzB,EAAA,IAAI,iBAAiB,CAAC,EAAA;AAGtB,EAAA,MAAM,QAAoC,EAAC;AAC3C,EAAA,IAAI,cAAA,GAAqF,IAAA;AACzF,EAAA,IAAI,aAAA,GAAoD,IAAA;AACxD,EAAA,IAAI,OAAA,GAAU,KAAA;AACd,EAAA,IAAI,gBAAA,GAAmB,KAAA;AACvB,EAAA,IAAI,IAAA,GAAO,KAAA;AACX,EAAA,IAAI,YAAA;AAEJ,EAAA,SAAS,eAAA,GAAkB;AACvB,IAAA,IAAA,GAAO,IAAA;AACP,IAAA,IAAI,cAAA,EAAgB;AAChB,MAAA,MAAM,OAAA,GAAU,cAAA;AAChB,MAAA,cAAA,GAAiB,IAAA;AACjB,MAAA,aAAA,GAAgB,IAAA;AAChB,MAAA,OAAA,CAAQ,EAAE,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,QAAW,CAAA;AAAA,IAC5C;AAAA,EACJ;AAEA,E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AA,MACH,wBAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,EACL,CAAA;AACJ;;;ACrDO,SAAS,uCAAA,CAAwC;AAAA,EACpD;AACJ,CAAA,EAA4F;AACxF,EAAA,OAAO,eAAe,gCAAA,CAAiC,WAAA,EAAa,MAAA,EAAQ;AACxE,IAAA,MAAM,2CAAA,CAA4C;AAAA,MAC9C,GAAG,MAAA;AAAA,MACH,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,EACL,CAAA;AACJ","file":"index.browser.mjs","sourcesContent":["import type { PendingRpcRequest } from '@solana/rpc';\nimport type { PendingRpcSubscriptionsRequest } from '@solana/rpc-subscriptions';\nimport type { SolanaRpcResponse } from '@solana/rpc-types';\n\ntype CreateAsyncGeneratorWithInitialValueAndSlotTrackingConfig<TRpcValue, TSubscriptionValue, TItem> = Readonly<{\n /**\n * Triggering this abort signal will cancel the pending RPC request and subscription, and\n * cause the async generator to return (complete without error).\n */\n abortSignal: AbortSignal;\n /**\n * A pending RPC request whose response will be yielded as the generator's first value\n * (unless a subscription notification with a newer slot arrives first).\n * The response must be a {@link SolanaRpcResponse} so that its slot can be compared with\n * subscription notifications.\n */\n rpcRequest: PendingRpcRequest<SolanaRpcResponse<TRpcValue>>;\n /**\n * A pending RPC subscription request whose notifications will be yielded as they arrive.\n * Each notification must be a {@link SolanaRpcResponse} so that its slot can be compared\n * with the initial RPC response and other notifications.\n */\n rpcSubscriptionRequest: PendingRpcSubscriptionsRequest<SolanaRpcResponse<TSubscriptionValue>>;\n /**\n * Maps the value from a subscription notification to the item type yielded by the generator.\n */\n rpcSubscriptionValueMapper: (value: TSubscriptionValue) => TItem;\n /**\n * Maps the value from the RPC response to the item type yielded by the generator.\n */\n rpcValueMapper: (value: TRpcValue) => TItem;\n}>;\n\n/**\n * Creates an async generator that combines an initial RPC fetch with an ongoing subscription,\n * yielding values as they arrive from either source.\n *\n * The generator uses slot-based comparison to ensure that only the most recent values are yielded.\n * Any value at a slot older than a previously yielded value is silently dropped.\n * This prevents stale data from appearing when the RPC response and subscription notifications\n * arrive out of order.\n *\n * Things to note:\n *\n * - The generator yields {@link SolanaRpcResponse} values from both the RPC response and\n * subscription notifications, each containing the slot context and the mapped value.\n * - Out-of-order values (by slot) are silently dropped — they are never yielded.\n * - On error from either source, the generator throws the error.\n * - Triggering the caller's abort signal causes the generator to return (complete without error).\n * - The generator completes when the subscription ends, an error occurs, or the abort signal fires.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * address,\n * createAsyncGeneratorWithInitialValueAndSlotTracking,\n * createSolanaRpc,\n * createSolanaRpcSubscriptions,\n * } from '@solana/kit';\n *\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const rpcSubscriptions = createSolanaRpcSubscriptions('ws://127.0.0.1:8900');\n * const myAddress = address('FnHyam9w4NZoWR6mKN1CuGBritdsEWZQa4Z4oawLZGxa');\n *\n * const abortController = new AbortController();\n * for await (const balance of createAsyncGeneratorWithInitialValueAndSlotTracking({\n * abortSignal: abortController.signal,\n * rpcRequest: rpc.getBalance(myAddress, { commitment: 'confirmed' }),\n * rpcValueMapper: lamports => lamports,\n * rpcSubscriptionRequest: rpcSubscriptions.accountNotifications(myAddress),\n * rpcSubscriptionValueMapper: ({ lamports }) => lamports,\n * })) {\n * console.log(`Balance at slot ${balance.context.slot}:`, balance.value);\n * }\n * ```\n */\nexport async function* createAsyncGeneratorWithInitialValueAndSlotTracking<TRpcValue, TSubscriptionValue, TItem>({\n abortSignal,\n rpcRequest,\n rpcValueMapper,\n rpcSubscriptionRequest,\n rpcSubscriptionValueMapper,\n}: CreateAsyncGeneratorWithInitialValueAndSlotTrackingConfig<TRpcValue, TSubscriptionValue, TItem>): AsyncGenerator<\n SolanaRpcResponse<TItem>\n> {\n if (abortSignal.aborted) return;\n\n let lastUpdateSlot = -1n;\n\n // Shared queue for merging values from the RPC response and subscription notifications.\n const queue: SolanaRpcResponse<TItem>[] = [];\n let waitingResolve: ((value: IteratorResult<SolanaRpcResponse<TItem>>) => void) | null = null;\n let waitingReject: ((reason: unknown) => void) | null = null;\n let rpcDone = false;\n let subscriptionDone = false;\n let done = false;\n let pendingError: unknown;\n\n function markSourcesDone() {\n done = true;\n if (waitingResolve) {\n const resolve = waitingResolve;\n waitingResolve = null;\n waitingReject = null;\n resolve({ done: true, value: undefined });\n }\n }\n\n const abortController = new AbortController();\n const signal = abortController.signal;\n\n function onAbort() {\n done = true;\n abortController.abort(abortSignal.reason);\n if (waitingResolve) {\n const resolve = waitingResolve;\n waitingResolve = null;\n waitingReject = null;\n resolve({ done: true, value: undefined });\n }\n }\n abortSignal.addEventListener('abort', onAbort);\n\n function enqueue(item: SolanaRpcResponse<TItem>) {\n if (done || signal.aborted) return;\n if (waitingResolve) {\n // generator is waiting for a value, so resolve immediately\n const resolve = waitingResolve;\n waitingResolve = null;\n waitingReject = null;\n resolve({ done: false, value: item });\n } else {\n // No pending generator pull, so enqueue the item for future delivery\n queue.push(item);\n }\n }\n\n function handleError(err: unknown) {\n if (signal.aborted) return;\n done = true;\n pendingError = err;\n abortController.abort(err);\n if (waitingReject) {\n // generator is waiting for a value, so reject immediately\n const reject = waitingReject;\n waitingResolve = null;\n waitingReject = null;\n reject(err);\n }\n }\n\n // Start both sources concurrently.\n rpcRequest\n .send({ abortSignal: signal })\n .then(({ context: { slot }, value }) => {\n if (signal.aborted) return;\n if (slot < lastUpdateSlot) return;\n lastUpdateSlot = slot;\n enqueue({ context: { slot }, value: rpcValueMapper(value) });\n })\n .then(() => {\n rpcDone = true;\n if (subscriptionDone) markSourcesDone();\n })\n .catch(handleError);\n\n rpcSubscriptionRequest\n .subscribe({ abortSignal: signal })\n .then(async notifications => {\n for await (const {\n context: { slot },\n value,\n } of notifications) {\n if (signal.aborted) return;\n if (slot < lastUpdateSlot) continue;\n lastUpdateSlot = slot;\n enqueue({ context: { slot }, value: rpcSubscriptionValueMapper(value) });\n }\n // Subscription completed normally.\n subscriptionDone = true;\n if (rpcDone) markSourcesDone();\n })\n .catch(handleError);\n\n try {\n while (true) {\n if (pendingError) throw pendingError;\n if (queue.length > 0) {\n yield queue.shift()!;\n } else if (done) {\n return;\n } else {\n // if no value queued or error, wait for the next value or error\n const result: IteratorResult<SolanaRpcResponse<TItem>> = await new Promise((resolve, reject) => {\n waitingResolve = resolve;\n waitingReject = reject;\n });\n if (result.done) return;\n yield result.value;\n }\n }\n } finally {\n abortSignal.removeEventListener('abort', onAbort);\n if (!signal.aborted) {\n abortController.abort();\n }\n }\n}\n","import type { PendingRpcRequest } from '@solana/rpc';\nimport type { PendingRpcSubscriptionsRequest } from '@solana/rpc-subscriptions';\nimport type { SolanaRpcResponse } from '@solana/rpc-types';\nimport type { ReactiveStore } from '@solana/subscribable';\n\ntype CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<TRpcValue, TSubscriptionValue, TItem> = Readonly<{\n /**\n * Triggering this abort signal will cancel the pending RPC request and subscription, and\n * disconnect the store from further updates.\n */\n abortSignal: AbortSignal;\n /**\n * A pending RPC request whose response will be used to set the store's initial state.\n * The response must be a {@link SolanaRpcResponse} so that its slot can be compared with\n * subscription notifications.\n */\n rpcRequest: PendingRpcRequest<SolanaRpcResponse<TRpcValue>>;\n /**\n * A pending RPC subscription request whose notifications will be used to keep the store\n * up to date. Each notification must be a {@link SolanaRpcResponse} so that its slot can be\n * compared with the initial RPC response and other notifications.\n */\n rpcSubscriptionRequest: PendingRpcSubscriptionsRequest<SolanaRpcResponse<TSubscriptionValue>>;\n /**\n * Maps the value from a subscription notification to the item type stored in the reactive store.\n */\n rpcSubscriptionValueMapper: (value: TSubscriptionValue) => TItem;\n /**\n * Maps the value from the RPC response to the item type stored in the reactive store.\n */\n rpcValueMapper: (value: TRpcValue) => TItem;\n}>;\n\n/**\n * Creates a {@link ReactiveStore} that combines an initial RPC fetch with an ongoing subscription\n * to keep its state up to date.\n *\n * The store uses slot-based comparison to ensure that only the most recent value is kept,\n * regardless of whether it came from the initial RPC response or a subscription notification.\n * This prevents stale data from overwriting newer data when the RPC response and subscription\n * notifications arrive out of order.\n *\n * Things to note:\n *\n * - `getState()` returns `undefined` until the first response or notification arrives. Once\n * data arrives, it returns a {@link SolanaRpcResponse} containing the value and the slot\n * context at which it was observed.\n * - On error from either source, `getState()` continues to return the last known value and\n * `getError()` returns the error. Only the first error is captured.\n * - When an error occurs, the abort signal is triggered, cancelling both the RPC request and\n * the subscription.\n * - Triggering the caller's abort signal disconnects the store from both sources.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * address,\n * createReactiveStoreWithInitialValueAndSlotTracking,\n * createSolanaRpc,\n * createSolanaRpcSubscriptions,\n * } from '@solana/kit';\n *\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const rpcSubscriptions = createSolanaRpcSubscriptions('ws://127.0.0.1:8900');\n * const myAddress = address('FnHyam9w4NZoWR6mKN1CuGBritdsEWZQa4Z4oawLZGxa');\n *\n * const balanceStore = createReactiveStoreWithInitialValueAndSlotTracking({\n * abortSignal: AbortSignal.timeout(60_000),\n * rpcRequest: rpc.getBalance(myAddress, { commitment: 'confirmed' }),\n * rpcValueMapper: lamports => lamports,\n * rpcSubscriptionRequest: rpcSubscriptions.accountNotifications(myAddress),\n * rpcSubscriptionValueMapper: ({ lamports }) => lamports,\n * });\n *\n * const unsubscribe = balanceStore.subscribe(() => {\n * const error = balanceStore.getError();\n * if (error) console.error('Error:', error);\n * else {\n * const state = balanceStore.getState();\n * if (state) console.log(`Balance at slot ${state.context.slot}:`, state.value);\n * }\n * });\n * ```\n *\n * @see {@link ReactiveStore}\n */\nexport function createReactiveStoreWithInitialValueAndSlotTracking<TRpcValue, TSubscriptionValue, TItem>({\n abortSignal,\n rpcRequest,\n rpcValueMapper,\n rpcSubscriptionRequest,\n rpcSubscriptionValueMapper,\n}: CreateReactiveStoreWithInitialValueAndSlotTrackingConfig<TRpcValue, TSubscriptionValue, TItem>): ReactiveStore<\n SolanaRpcResponse<TItem>\n> {\n let currentState: SolanaRpcResponse<TItem> | undefined;\n let currentError: unknown;\n let lastUpdateSlot = -1n;\n const subscribers = new Set<() => void>();\n\n const abortController = new AbortController();\n abortSignal.addEventListener('abort', () => abortController.abort(abortSignal.reason));\n const signal = abortController.signal;\n\n function notifySubscribers() {\n subscribers.forEach(cb => cb());\n }\n\n function handleError(err: unknown) {\n // Ignore if the signal has already been aborted\n if (signal.aborted) return;\n // Only capture the first error\n if (currentError !== undefined) return;\n currentError = err;\n abortController.abort(err);\n notifySubscribers();\n }\n\n rpcRequest\n .send({ abortSignal: signal })\n .then(({ context: { slot }, value }) => {\n if (signal.aborted) return;\n if (slot < lastUpdateSlot) return;\n lastUpdateSlot = slot;\n currentState = { context: { slot }, value: rpcValueMapper(value) };\n notifySubscribers();\n })\n .catch(handleError);\n\n rpcSubscriptionRequest\n .subscribe({ abortSignal: signal })\n .then(async notifications => {\n for await (const {\n context: { slot },\n value,\n } of notifications) {\n if (signal.aborted) return;\n if (slot < lastUpdateSlot) continue;\n lastUpdateSlot = slot;\n currentState = {\n context: { slot },\n value: rpcSubscriptionValueMapper(value),\n };\n notifySubscribers();\n }\n })\n .catch(handleError);\n\n return {\n getError(): unknown {\n return currentError;\n },\n getState(): SolanaRpcResponse<TItem> | undefined {\n return currentState;\n },\n subscribe(callback: () => void): () => void {\n subscribers.add(callback);\n return () => {\n subscribers.delete(callback);\n };\n },\n };\n}\n","import type { Address } from '@solana/addresses';\nimport type { Signature } from '@solana/keys';\nimport type { RequestAirdropApi, Rpc } from '@solana/rpc';\nimport type { Commitment, Lamports } from '@solana/rpc-types';\nimport { waitForRecentTransactionConfirmationUntilTimeout } from '@solana/transaction-confirmation';\n\ntype RequestAndConfirmAirdropConfig = Readonly<{\n abortSignal?: AbortSignal;\n commitment: Commitment;\n confirmSignatureOnlyTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmationUntilTimeout>[0],\n 'getRecentSignatureConfirmationPromise' | 'getTimeoutPromise'\n >,\n ) => Promise<void>;\n lamports: Lamports;\n recipientAddress: Address;\n rpc: Rpc<RequestAirdropApi>;\n}>;\n\nexport async function requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmSignatureOnlyTransaction,\n lamports,\n recipientAddress,\n rpc,\n}: RequestAndConfirmAirdropConfig): Promise<Signature> {\n const airdropTransactionSignature = await rpc\n .requestAirdrop(recipientAddress, lamports, { commitment })\n .send({ abortSignal });\n await confirmSignatureOnlyTransaction({\n abortSignal,\n commitment,\n signature: airdropTransactionSignature,\n });\n return airdropTransactionSignature;\n}\n","import type { Signature } from '@solana/keys';\nimport type { GetSignatureStatusesApi, RequestAirdropApi, Rpc } from '@solana/rpc';\nimport type { RpcSubscriptions, SignatureNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createRecentSignatureConfirmationPromiseFactory,\n getTimeoutPromise,\n waitForRecentTransactionConfirmationUntilTimeout,\n} from '@solana/transaction-confirmation';\n\nimport { requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT } from './airdrop-internal';\n\ntype AirdropFunction = (\n config: Omit<\n Parameters<typeof requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmSignatureOnlyTransaction' | 'rpc'\n >,\n) => Promise<Signature>;\n\ntype AirdropFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link RequestAirdropApi} of the Solana RPC API */\n rpc: Rpc<GetSignatureStatusesApi & RequestAirdropApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link SignatureNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to airdrop a certain amount of {@link Lamports} to a Solana\n * address.\n *\n * > [!NOTE] This only works on test clusters.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { address, airdropFactory, createSolanaRpc, createSolanaRpcSubscriptions, devnet, lamports } from '@solana/kit';\n *\n * const rpc = createSolanaRpc(devnet('http://127.0.0.1:8899'));\n * const rpcSubscriptions = createSolanaRpcSubscriptions(devnet('ws://127.0.0.1:8900'));\n *\n * const airdrop = airdropFactory({ rpc, rpcSubscriptions });\n *\n * await airdrop({\n * commitment: 'confirmed',\n * recipientAddress: address('FnHyam9w4NZoWR6mKN1CuGBritdsEWZQa4Z4oawLZGxa'),\n * lamports: lamports(10_000_000n),\n * });\n * ```\n */\nexport function airdropFactory({ rpc, rpcSubscriptions }: AirdropFactoryConfig<'devnet'>): AirdropFunction;\nexport function airdropFactory({ rpc, rpcSubscriptions }: AirdropFactoryConfig<'mainnet'>): AirdropFunction;\nexport function airdropFactory({ rpc, rpcSubscriptions }: AirdropFactoryConfig<'testnet'>): AirdropFunction;\nexport function airdropFactory<TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void>({\n rpc,\n rpcSubscriptions,\n}: AirdropFactoryConfig<TCluster>): AirdropFunction {\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmSignatureOnlyTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmationUntilTimeout>[0],\n 'getRecentSignatureConfirmationPromise' | 'getTimeoutPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmationUntilTimeout({\n ...config,\n getRecentSignatureConfirmationPromise,\n getTimeoutPromise,\n });\n }\n return async function airdrop(config) {\n return await requestAndConfirmAirdrop_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmSignatureOnlyTransaction,\n rpc,\n });\n };\n}\n","import {\n getSolanaErrorFromTransactionError,\n isSolanaError,\n type RpcSimulateTransactionResult,\n SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,\n SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,\n SolanaError,\n} from '@solana/errors';\nimport { pipe } from '@solana/functional';\nimport type { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport type { Commitment, Slot } from '@solana/rpc-types';\nimport {\n getTransactionMessageComputeUnitLimit,\n isTransactionMessageWithDurableNonceLifetime,\n setTransactionMessageComputeUnitLimit,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n} from '@solana/transaction-messages';\nimport { compileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';\n\nconst PROVISORY_COMPUTE_UNIT_LIMIT = 0;\nconst MAX_COMPUTE_UNIT_LIMIT = 1_400_000;\n\ntype EstimateComputeUnitLimitFactoryConfig = Readonly<{\n rpc: Rpc<SimulateTransactionApi>;\n}>;\n\ntype EstimateComputeUnitLimitConfig = Readonly<{\n abortSignal?: AbortSignal;\n commitment?: Commitment;\n minContextSlot?: Slot;\n}>;\n\ntype EstimateComputeUnitLimitFunction = (\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n config?: EstimateComputeUnitLimitConfig,\n) => Promise<number>;\n\n/**\n * Returns a function that estimates the compute units consumed by a transaction message by\n * simulating it.\n *\n * The estimator sets the compute unit limit to the maximum (1,400,000) before simulating, so the\n * simulation does not fail due to compute unit exhaustion. For blockhash-lifetime transactions, the\n * RPC is asked to replace the blockhash during simulation, so any blockhash value will work. For\n * durable nonce transactions, the actual nonce value is used.\n *\n * @param factoryConfig - An object containing the RPC instance to use for simulation.\n * @return A function that accepts a transaction message and returns the estimated compute units.\n *\n * @example\n * ```ts\n * import { estimateComputeUnitLimitFactory } from '@solana/kit';\n *\n * const estimateComputeUnitLimit = estimateComputeUnitLimitFactory({ rpc });\n * const estimatedUnits = await estimateComputeUnitLimit(transactionMessage);\n * ```\n */\nexport function estimateComputeUnitLimitFactory({\n rpc,\n}: EstimateComputeUnitLimitFactoryConfig): EstimateComputeUnitLimitFunction {\n return async function estimateComputeUnitLimit(transactionMessage, config) {\n const { abortSignal, ...simulateConfig } = config ?? {};\n const replaceRecentBlockhash = !isTransactionMessageWithDurableNonceLifetime(transactionMessage);\n\n const transaction = pipe(\n transactionMessage,\n m => setTransactionMessageComputeUnitLimit(MAX_COMPUTE_UNIT_LIMIT, m),\n compileTransaction,\n );\n const wireTransactionBytes = getBase64EncodedWireTransaction(transaction);\n\n try {\n const response = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n replaceRecentBlockhash,\n sigVerify: false,\n })\n .send({ abortSignal });\n // The API response type varies based on config (eg. `replacementBlockhash` is only\n // present when `replaceRecentBlockhash` is true), but `RpcSimulateTransactionResult`\n // is a flat superset. Cast through `unknown` to bridge the structural gap.\n const { err: transactionError, ...simulationResult } =\n response.value as unknown as RpcSimulateTransactionResult;\n\n if (simulationResult.unitsConsumed == null) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n ...simulationResult,\n cause: getSolanaErrorFromTransactionError(transactionError),\n });\n }\n\n // Downcast from bigint to number, capping at u32 max.\n return simulationResult.unitsConsumed > 4_294_967_295n\n ? 4_294_967_295\n : Number(simulationResult.unitsConsumed);\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) {\n throw e;\n }\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: e,\n });\n }\n };\n}\n\n/**\n * Returns a function that estimates the compute unit limit for a transaction message and sets it on\n * the message. If the message already has an explicit compute unit limit set (one that is not the\n * provisory value of 0, and not the maximum of 1,400,000), the message is returned unchanged.\n *\n * This is designed to work with {@link fillTransactionMessageProvisoryComputeUnitLimit}: first add a provisory limit\n * during transaction construction, then later estimate and replace it before sending.\n *\n * @param estimateComputeUnitLimit - The estimator function, typically created by\n * {@link estimateComputeUnitLimitFactory}. You can also pass a custom wrapper that adds a buffer\n * (e.g. multiply the estimate by 1.1).\n * @return A function that accepts a transaction message and returns it with the compute unit limit\n * set to the estimated value.\n *\n * @example\n * ```ts\n * import { estimateAndSetComputeUnitLimitFactory, estimateComputeUnitLimitFactory } from '@solana/kit';\n *\n * const estimator = estimateComputeUnitLimitFactory({ rpc });\n * const estimateAndSet = estimateAndSetComputeUnitLimitFactory(estimator);\n * const updatedMessage = await estimateAndSet(transactionMessage);\n * ```\n */\nexport function estimateAndSetComputeUnitLimitFactory(\n estimateComputeUnitLimit: EstimateComputeUnitLimitFunction,\n): <TTransactionMessage extends TransactionMessage & TransactionMessageWithFeePayer>(\n transactionMessage: TTransactionMessage,\n config?: EstimateComputeUnitLimitConfig,\n) => Promise<TTransactionMessage> {\n return async function estimateAndSetComputeUnitLimit(transactionMessage, config) {\n const existingLimit = getTransactionMessageComputeUnitLimit(transactionMessage);\n\n // If a non-provisory, non-max CU limit is already set, leave it as-is.\n if (existingLimit && existingLimit !== MAX_COMPUTE_UNIT_LIMIT) {\n return transactionMessage;\n }\n\n const estimatedUnits = await estimateComputeUnitLimit(transactionMessage, config);\n return setTransactionMessageComputeUnitLimit(estimatedUnits, transactionMessage);\n };\n}\n\n/**\n * Sets the compute unit limit to a provisory value of 0 if no compute unit limit is currently set\n * on the transaction message. If a limit is already set (any value, including 0), the message is\n * returned unchanged.\n *\n * This is useful during transaction construction to reserve space for a compute unit limit that\n * will later be replaced with an actual estimate via\n * {@link estimateAndSetComputeUnitLimitFactory}.\n *\n * @param transactionMessage - The transaction message to add a provisory limit to.\n * @return The transaction message with a provisory compute unit limit set, or unchanged if one was\n * already present.\n *\n * @example\n * ```ts\n * import { fillTransactionMessageProvisoryComputeUnitLimit } from '@solana/kit';\n *\n * const messageWithProvisoryLimit = fillTransactionMessageProvisoryComputeUnitLimit(transactionMessage);\n * ```\n */\nexport function fillTransactionMessageProvisoryComputeUnitLimit<TTransactionMessage extends TransactionMessage>(\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n if (getTransactionMessageComputeUnitLimit(transactionMessage) !== undefined) {\n return transactionMessage;\n }\n return setTransactionMessageComputeUnitLimit(PROVISORY_COMPUTE_UNIT_LIMIT, transactionMessage);\n}\n","import {\n assertAccountsDecoded,\n assertAccountsExist,\n type FetchAccountsConfig,\n fetchJsonParsedAccounts,\n} from '@solana/accounts';\nimport type { Address } from '@solana/addresses';\nimport type { GetMultipleAccountsApi, Rpc } from '@solana/rpc';\nimport { type AddressesByLookupTableAddress } from '@solana/transaction-messages';\n\ntype FetchedAddressLookup = {\n addresses: Address[];\n};\n\n/**\n * Given a list of addresses belonging to address lookup tables, returns a map of lookup table\n * addresses to an ordered array of the addresses they contain.\n *\n * @param rpc An object that supports the {@link GetMultipleAccountsApi} of the Solana RPC API\n * @param config\n */\nexport async function fetchAddressesForLookupTables(\n lookupTableAddresses: Address[],\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: FetchAccountsConfig,\n): Promise<AddressesByLookupTableAddress> {\n if (lookupTableAddresses.length === 0) {\n return {};\n }\n\n const fetchedLookupTables = await fetchJsonParsedAccounts<FetchedAddressLookup[]>(\n rpc,\n lookupTableAddresses,\n config,\n );\n\n assertAccountsDecoded(fetchedLookupTables);\n assertAccountsExist(fetchedLookupTables);\n\n return fetchedLookupTables.reduce<AddressesByLookupTableAddress>((acc, lookup) => {\n return {\n ...acc,\n [lookup.address]: lookup.data.addresses,\n };\n }, {});\n}\n","import { type FetchAccountsConfig } from '@solana/accounts';\nimport type { GetMultipleAccountsApi, Rpc } from '@solana/rpc';\nimport {\n CompiledTransactionMessage,\n CompiledTransactionMessageWithLifetime,\n decompileTransactionMessage,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n TransactionMessageWithLifetime,\n} from '@solana/transaction-messages';\n\nimport { fetchAddressesForLookupTables } from './fetch-lookup-tables';\n\ntype DecompileTransactionMessageFetchingLookupTablesConfig = FetchAccountsConfig & {\n lastValidBlockHeight?: bigint;\n};\n\n/**\n * Returns a {@link TransactionMessage} from a {@link CompiledTransactionMessage}. If any of the\n * accounts in the compiled message require an address lookup table to find their address, this\n * function will use the supplied RPC instance to fetch the contents of the address lookup table\n * from the network.\n *\n * @param rpc An object that supports the {@link GetMultipleAccountsApi} of the Solana RPC API\n * @param config\n */\nexport async function decompileTransactionMessageFetchingLookupTables(\n compiledTransactionMessage: CompiledTransactionMessage & CompiledTransactionMessageWithLifetime,\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: DecompileTransactionMessageFetchingLookupTablesConfig,\n): Promise<TransactionMessage & TransactionMessageWithFeePayer & TransactionMessageWithLifetime> {\n const lookupTables =\n 'addressTableLookups' in compiledTransactionMessage &&\n compiledTransactionMessage.addressTableLookups !== undefined &&\n compiledTransactionMessage.addressTableLookups.length > 0\n ? compiledTransactionMessage.addressTableLookups\n : [];\n const lookupTableAddresses = lookupTables.map(l => l.lookupTableAddress);\n\n const { lastValidBlockHeight, ...fetchAccountsConfig } = config ?? {};\n const addressesByLookupTableAddress =\n lookupTableAddresses.length > 0\n ? await fetchAddressesForLookupTables(lookupTableAddresses, rpc, fetchAccountsConfig)\n : {};\n\n return decompileTransactionMessage(compiledTransactionMessage, {\n addressesByLookupTableAddress,\n lastValidBlockHeight,\n });\n}\n","import type { Lamports } from '@solana/rpc-types';\n\n/**\n * Calculates the minimum {@link Lamports | lamports} required to make an account rent exempt for a\n * given data size, without performing an RPC call.\n *\n * Values are sourced from the on-chain rent parameters in the Solana runtime:\n * https://github.com/anza-xyz/solana-sdk/blob/c07f692e41d757057c8700211a9300cdcd6d33b1/rent/src/lib.rs#L93-L97\n *\n * Note that this logic may change, or be incorrect depending on the cluster you are connected to.\n * You can always use the RPC method `getMinimumBalanceForRentExemption` to get the current value.\n *\n * @deprecated The minimum balance for an account is being actively reduced\n * (see {@link https://github.com/solana-foundation/solana-improvement-documents/pull/437 | SIMD-0437})\n * and is expected to become dynamic in future Solana upgrades\n * (see {@link https://github.com/solana-foundation/solana-improvement-documents/pull/194 | SIMD-0194}\n * and {@link https://github.com/solana-foundation/solana-improvement-documents/pull/389 | SIMD-0389}),\n * meaning a hardcoded local computation will no longer return accurate results. Use the\n * {@link GetMinimumBalanceForRentExemptionApi.getMinimumBalanceForRentExemption | getMinimumBalanceForRentExemption}\n * RPC method or a `ClientWithGetMinimumBalance` plugin instead. This function will be removed in v7.\n *\n * @param space The number of bytes of account data.\n */\nexport function getMinimumBalanceForRentExemption(space: bigint): Lamports {\n const RENT = {\n ACCOUNT_STORAGE_OVERHEAD: 128n,\n DEFAULT_EXEMPTION_THRESHOLD: 2n,\n DEFAULT_LAMPORTS_PER_BYTE_YEAR: 3_480n,\n } as const;\n const requiredLamports =\n (RENT.ACCOUNT_STORAGE_OVERHEAD + space) *\n RENT.DEFAULT_LAMPORTS_PER_BYTE_YEAR *\n RENT.DEFAULT_EXEMPTION_THRESHOLD;\n return requiredLamports as Lamports;\n}\n","import type { Signature } from '@solana/keys';\nimport type { Rpc, SendTransactionApi } from '@solana/rpc';\nimport { Commitment, commitmentComparator } from '@solana/rpc-types';\nimport {\n TransactionWithLastValidBlockHeight,\n waitForDurableNonceTransactionConfirmation,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport {\n getBase64EncodedWireTransaction,\n SendableTransaction,\n Transaction,\n TransactionWithDurableNonceLifetime,\n} from '@solana/transactions';\n\ninterface SendAndConfirmDurableNonceTransactionConfig\n extends SendTransactionBaseConfig, SendTransactionConfigWithoutEncoding {\n confirmDurableNonceTransaction: (\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: SendableTransaction & Transaction & TransactionWithDurableNonceLifetime;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeConfig\n extends SendTransactionBaseConfig, SendTransactionConfigWithoutEncoding {\n confirmRecentTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: SendableTransaction & Transaction & TransactionWithLastValidBlockHeight;\n}\n\ninterface SendTransactionBaseConfig extends SendTransactionConfigWithoutEncoding {\n abortSignal?: AbortSignal;\n commitment: Commitment;\n rpc: Rpc<SendTransactionApi>;\n transaction: SendableTransaction & Transaction;\n}\n\ntype SendTransactionConfigWithoutEncoding = Omit<\n NonNullable<Parameters<SendTransactionApi['sendTransaction']>[1]>,\n 'encoding'\n>;\n\nfunction getSendTransactionConfigWithAdjustedPreflightCommitment(\n commitment: Commitment,\n config?: SendTransactionConfigWithoutEncoding,\n): SendTransactionConfigWithoutEncoding | void {\n if (\n // The developer has supplied no value for `preflightCommitment`.\n !config?.preflightCommitment &&\n // The value of `commitment` is lower than the server default of `preflightCommitment`.\n commitmentComparator(commitment, 'finalized' /* default value of `preflightCommitment` */) < 0\n ) {\n return {\n ...config,\n // In the common case, it is unlikely that you want to simulate a transaction at\n // `finalized` commitment when your standard of commitment for confirming the\n // transaction is lower. Cap the simulation commitment level to the level of the\n // confirmation commitment.\n preflightCommitment: commitment,\n };\n }\n // The commitment at which the developer wishes to confirm the transaction is at least as\n // high as the commitment at which they want to simulate it. Honour the config as-is.\n return config;\n}\n\nexport async function sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n comm