@solana/kit 2.1.1 → 2.2.0-canary-20250514101537
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.development.js +47 -2
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.production.min.js +556 -546
- package/dist/types/compute-limit-internal.d.ts +2 -2
- package/dist/types/compute-limit-internal.d.ts.map +1 -1
- package/dist/types/compute-limit.d.ts +2 -2
- package/dist/types/compute-limit.d.ts.map +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/airdrop-internal.ts","../src/airdrop.ts","../src/compute-limit-internal.ts","../src/compute-limit.ts","../src/fetch-lookup-tables.ts","../src/decompile-transaction-message-fetching-lookup-tables.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":["createRecentSignatureConfirmationPromiseFactory","waitForRecentTransactionConfirmationUntilTimeout","getTimeoutPromise","getU32Encoder","isInstructionForProgram","isInstructionWithData","isDurableNonceTransaction","isTransactionMessageWithBlockhashLifetime","setTransactionMessageLifetimeUsingBlockhash","appendTransactionMessageInstruction","compileTransaction","getBase64EncodedWireTransaction","SolanaError","SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT","SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT","isSolanaError","fetchJsonParsedAccounts","assertAccountsDecoded","assertAccountsExist","decompileTransactionMessage","commitmentComparator","createNonceInvalidationPromiseFactory","waitForDurableNonceTransactionConfirmation","createBlockHeightExceedencePromiseFactory","waitForRecentTransactionConfirmation"],"mappings":";;;;;;;;;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AAAA,IACA;AAAA,GACgE,CAAA;AACpE,EAAA,MAAM,wCAAwCvB,uEAAgD,CAAA;AAAA,IAC1F,GAAA;AAAA,IACA;AAAA,GACsE,CAAA;AAC1E,EAAA,eAAe,yBACX,MAIF,EAAA;AACE,IAAA,MAAMwB,4DAAqC,CAAA;AAAA,MACvC,GAAG,MAAA;AAAA,MACH,+BAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA;AAEL,EAAO,OAAA,eAAe,yBAA0B,CAAA,WAAA,EAAa,MAAQ,EAAA;AACjE,IAAA,MAAM,0EAA2E,CAAA;AAAA,MAC7E,GAAG,MAAA;AAAA,MACH,wBAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ;;;ACrDO,SAAS,uCAAwC,CAAA;AAAA,EACpD;AACJ,CAA4F,EAAA;AACxF,EAAO,OAAA,eAAe,gCAAiC,CAAA,WAAA,EAAa,MAAQ,EAAA;AACxE,IAAA,MAAM,2CAA4C,CAAA;AAAA,MAC9C,GAAG,MAAA;AAAA,MACH,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ","file":"index.browser.cjs","sourcesContent":["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 { Address } from '@solana/addresses';\nimport { getU32Encoder } from '@solana/codecs';\nimport {\n isSolanaError,\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 {\n IInstruction,\n IInstructionWithData,\n isInstructionForProgram,\n isInstructionWithData,\n} from '@solana/instructions';\nimport { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport { Blockhash, Commitment, Slot } from '@solana/rpc-types';\nimport {\n appendTransactionMessageInstruction,\n CompilableTransactionMessage,\n isDurableNonceTransaction,\n isTransactionMessageWithBlockhashLifetime,\n ITransactionMessageWithFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n TransactionMessage,\n} from '@solana/transaction-messages';\nimport { compileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';\n\ntype ComputeUnitEstimateForTransactionMessageConfig = Readonly<{\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: CompilableTransactionMessage | (ITransactionMessageWithFeePayer & TransactionMessage);\n}>;\n\nconst COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n// HACK: Since the `compileTransaction()` method will not compile a transaction with no lifetime we\n// supply a dummy lifetime.\nconst INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH = {\n blockhash: '11111111111111111111111111111111' as Blockhash,\n lastValidBlockHeight: 0n, // This is not included in compiled transactions; it can be anything.\n} as const;\nconst SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX = 0x02;\n\nfunction createComputeUnitLimitInstruction(units: number): IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> {\n const data = new Uint8Array(5);\n data[0] = SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX;\n getU32Encoder().write(units, data, 1 /* offset */);\n return Object.freeze({\n data,\n programAddress: COMPUTE_BUDGET_PROGRAM_ADDRESS,\n });\n}\n\nfunction isSetComputeLimitInstruction(\n instruction: IInstruction,\n): instruction is IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> & IInstructionWithData<Uint8Array> {\n return (\n isInstructionForProgram(instruction, COMPUTE_BUDGET_PROGRAM_ADDRESS) &&\n isInstructionWithData(instruction) &&\n instruction.data[0] === SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX\n );\n}\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that – an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n rpc,\n transactionMessage,\n ...simulateConfig\n}: ComputeUnitEstimateForTransactionMessageConfig): Promise<number> {\n /**\n * STEP 1: Make sure the transaction message will not fail in simulation for lack of a lifetime\n * - either a recent blockhash lifetime or a nonce.\n */\n const isDurableNonceTransactionMessage = isDurableNonceTransaction(transactionMessage);\n let compilableTransactionMessage;\n if (isDurableNonceTransactionMessage || isTransactionMessageWithBlockhashLifetime(transactionMessage)) {\n compilableTransactionMessage = transactionMessage;\n } else {\n compilableTransactionMessage = setTransactionMessageLifetimeUsingBlockhash(\n INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH,\n transactionMessage,\n );\n }\n /**\n * STEP 2: Ensure that the message has a `SetComputeLimit` instruction. The set compute limit\n * instruction itself consumes compute units, so it must be included in the simulation.\n */\n const existingSetComputeUnitLimitInstructionIndex =\n transactionMessage.instructions.findIndex(isSetComputeLimitInstruction);\n const maxComputeUnitLimitInstruction = createComputeUnitLimitInstruction(1_400_000 /* MAX_COMPUTE_UNIT_LIMIT */);\n if (existingSetComputeUnitLimitInstructionIndex === -1) {\n compilableTransactionMessage = appendTransactionMessageInstruction(\n maxComputeUnitLimitInstruction,\n compilableTransactionMessage,\n );\n } else {\n const nextInstructions = [...compilableTransactionMessage.instructions];\n nextInstructions.splice(existingSetComputeUnitLimitInstructionIndex, 1, maxComputeUnitLimitInstruction);\n compilableTransactionMessage = Object.freeze({\n ...compilableTransactionMessage,\n instructions: nextInstructions,\n } as typeof compilableTransactionMessage);\n }\n /**\n * STEP 3: Simulate the transaction to measure its compute unit consumption.\n */\n const compiledTransaction = compileTransaction(compilableTransactionMessage);\n const wireTransactionBytes = getBase64EncodedWireTransaction(compiledTransaction);\n try {\n const {\n value: { err: transactionError, unitsConsumed },\n } = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n replaceRecentBlockhash: !isDurableNonceTransactionMessage,\n sigVerify: false,\n })\n .send({ abortSignal });\n if (unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: transactionError,\n unitsConsumed: downcastUnitsConsumed,\n });\n }\n return downcastUnitsConsumed;\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: e,\n });\n }\n}\n","import { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport {\n CompilableTransactionMessage,\n ITransactionMessageWithFeePayer,\n TransactionMessage,\n} from '@solana/transaction-messages';\n\nimport { getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT } from './compute-limit-internal';\n\ntype ComputeUnitEstimateForTransactionMessageFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\ntype ComputeUnitEstimateForTransactionMessageFunction = (\n transactionMessage: CompilableTransactionMessage | (ITransactionMessageWithFeePayer & TransactionMessage),\n config?: Omit<\n Parameters<typeof getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'rpc' | 'transactionMessage'\n >,\n) => Promise<number>;\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage = getComputeUnitEstimateForTransactionMessageFactory({\n * rpc,\n * });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const computeUnitsEstimate = await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n */\nexport function getComputeUnitEstimateForTransactionMessageFactory({\n rpc,\n}: ComputeUnitEstimateForTransactionMessageFactoryConfig): ComputeUnitEstimateForTransactionMessageFunction {\n return async function getComputeUnitEstimateForTransactionMessage(transactionMessage, config) {\n return await getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transactionMessage,\n });\n };\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 CompilableTransactionMessage,\n CompiledTransactionMessage,\n decompileTransactionMessage,\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,\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: DecompileTransactionMessageFetchingLookupTablesConfig,\n): Promise<CompilableTransactionMessage> {\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 { 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 FullySignedTransaction,\n getBase64EncodedWireTransaction,\n TransactionWithDurableNonceLifetime,\n} from '@solana/transactions';\n\ninterface SendAndConfirmDurableNonceTransactionConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmDurableNonceTransaction: (\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmRecentTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight;\n}\n\ninterface SendTransactionBaseConfig extends SendTransactionConfigWithoutEncoding {\n abortSignal?: AbortSignal;\n commitment: Commitment;\n rpc: Rpc<SendTransactionApi>;\n transaction: FullySignedTransaction;\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 commitment,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendTransactionBaseConfig): Promise<Signature> {\n const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);\n return await rpc\n .sendTransaction(base64EncodedWireTransaction, {\n ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),\n encoding: 'base64',\n })\n .send({ abortSignal });\n}\n\nexport async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmDurableNonceTransactionConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmDurableNonceTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n\nexport async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmRecentTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmTransactionWithBlockhashLifetimeConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmRecentTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n","import type { GetAccountInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { AccountNotificationsApi, RpcSubscriptions, SignatureNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createNonceInvalidationPromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n waitForDurableNonceTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction, TransactionWithDurableNonceLifetime } from '@solana/transactions';\n\nimport { sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmDurableNonceTransactionFunction = (\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime,\n config: Omit<\n Parameters<typeof sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmDurableNonceTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetAccountInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link AccountNotificationsApi} and the {@link SignatureNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<AccountNotificationsApi & SignatureNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a nonce-based transaction to the network and to wait\n * until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * isSolanaError,\n * sendAndConfirmDurableNonceTransactionFactory,\n * SOLANA_ERROR__INVALID_NONCE,\n * SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n * } from '@solana/kit';\n *\n * const sendAndConfirmNonceTransaction = sendAndConfirmDurableNonceTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmNonceTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {\n * console.error(\n * 'The lifetime specified by this transaction refers to a nonce account ' +\n * `\\`${e.context.nonceAccountAddress}\\` that does not exist`,\n * );\n * } else if (isSolanaError(e, SOLANA_ERROR__INVALID_NONCE)) {\n * console.error('This transaction depends on a nonce that is no longer valid');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'devnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'testnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'mainnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory<\n TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void,\n>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster>): SendAndConfirmDurableNonceTransactionFunction {\n const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({ rpc, rpcSubscriptions } as Parameters<\n typeof createNonceInvalidationPromiseFactory\n >[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmDurableNonceTransaction(\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForDurableNonceTransactionConfirmation({\n ...config,\n getNonceInvalidationPromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmDurableNonceTransaction(transaction, config) {\n await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { GetEpochInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { RpcSubscriptions, SignatureNotificationsApi, SlotNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createBlockHeightExceedencePromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n TransactionWithLastValidBlockHeight,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFunction = (\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight,\n config: Omit<\n Parameters<typeof sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmRecentTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetEpochInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link SignatureNotificationsApi} and the {@link SlotNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a blockhash-based transaction to the network and to\n * wait until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { isSolanaError, sendAndConfirmTransactionFactory, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED } from '@solana/kit';\n *\n * const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {\n * console.error('This transaction depends on a blockhash that has expired');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'devnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'testnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'mainnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory<TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster>): SendAndConfirmTransactionWithBlockhashLifetimeFunction {\n const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createBlockHeightExceedencePromiseFactory>[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmRecentTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmation({\n ...config,\n getBlockHeightExceedencePromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmTransaction(transaction, config) {\n await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmRecentTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { Rpc, SendTransactionApi } from '@solana/rpc';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendTransactionWithoutConfirmingFunction = (\n transaction: FullySignedTransaction,\n config: Omit<Parameters<typeof sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0], 'rpc' | 'transaction'>,\n) => Promise<void>;\n\ninterface SendTransactionWithoutConfirmingFactoryConfig {\n /** An object that supports the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<SendTransactionApi>;\n}\n\n/**\n * Returns a function that you can call to send a transaction with any kind of lifetime to the\n * network without waiting for it to be confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * sendTransactionWithoutConfirmingFactory,\n * SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE,\n * } from '@solana/kit';\n *\n * const sendTransaction = sendTransactionWithoutConfirmingFactory({ rpc });\n *\n * try {\n * await sendTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE)) {\n * console.error('The transaction failed in simulation', e.cause);\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendTransactionWithoutConfirmingFactory({\n rpc,\n}: SendTransactionWithoutConfirmingFactoryConfig): SendTransactionWithoutConfirmingFunction {\n return async function sendTransactionWithoutConfirming(transaction, config) {\n await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transaction,\n });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/airdrop-internal.ts","../src/airdrop.ts","../src/compute-limit-internal.ts","../src/compute-limit.ts","../src/fetch-lookup-tables.ts","../src/decompile-transaction-message-fetching-lookup-tables.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":["createRecentSignatureConfirmationPromiseFactory","waitForRecentTransactionConfirmationUntilTimeout","getTimeoutPromise","getU32Encoder","isInstructionForProgram","isInstructionWithData","isDurableNonceTransaction","isTransactionMessageWithBlockhashLifetime","setTransactionMessageLifetimeUsingBlockhash","appendTransactionMessageInstruction","compileTransaction","getBase64EncodedWireTransaction","SolanaError","SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT","SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT","isSolanaError","fetchJsonParsedAccounts","assertAccountsDecoded","assertAccountsExist","decompileTransactionMessage","commitmentComparator","createNonceInvalidationPromiseFactory","waitForDurableNonceTransactionConfirmation","createBlockHeightExceedencePromiseFactory","waitForRecentTransactionConfirmation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,oDAAqD,CAAA;AAAA,EACvE,WAAA;AAAA,EACA,UAAA;AAAA,EACA,+BAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACJ,CAAuD,EAAA;AACnD,EAAA,MAAM,2BAA8B,GAAA,MAAM,GACrC,CAAA,cAAA,CAAe,gBAAkB,EAAA,QAAA,EAAU,EAAE,UAAA,EAAY,CAAA,CACzD,IAAK,CAAA,EAAE,aAAa,CAAA;AACzB,EAAA,MAAM,+BAAgC,CAAA;AAAA,IAClC,WAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAW,EAAA;AAAA,GACd,CAAA;AACD,EAAO,OAAA,2BAAA;AACX;;;ACeO,SAAS,cAAgF,CAAA;AAAA,EAC5F,GAAA;AAAA,EACA;AACJ,CAAoD,EAAA;AAChD,EAAA,MAAM,wCAAwC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e,gCAAiC,CAAA,WAAA,EAAa,MAAQ,EAAA;AACxE,IAAA,MAAM,2CAA4C,CAAA;AAAA,MAC9C,GAAG,MAAA;AAAA,MACH,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ","file":"index.browser.cjs","sourcesContent":["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 { Address } from '@solana/addresses';\nimport { getU32Encoder } from '@solana/codecs';\nimport {\n isSolanaError,\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 {\n IInstruction,\n IInstructionWithData,\n isInstructionForProgram,\n isInstructionWithData,\n} from '@solana/instructions';\nimport { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport { Blockhash, Commitment, Slot } from '@solana/rpc-types';\nimport {\n appendTransactionMessageInstruction,\n CompilableTransactionMessage,\n isDurableNonceTransaction,\n isTransactionMessageWithBlockhashLifetime,\n setTransactionMessageLifetimeUsingBlockhash,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n} from '@solana/transaction-messages';\nimport { compileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';\n\ntype ComputeUnitEstimateForTransactionMessageConfig = Readonly<{\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: CompilableTransactionMessage | (TransactionMessage & TransactionMessageWithFeePayer);\n}>;\n\nconst COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n// HACK: Since the `compileTransaction()` method will not compile a transaction with no lifetime we\n// supply a dummy lifetime.\nconst INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH = {\n blockhash: '11111111111111111111111111111111' as Blockhash,\n lastValidBlockHeight: 0n, // This is not included in compiled transactions; it can be anything.\n} as const;\nconst SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX = 0x02;\n\nfunction createComputeUnitLimitInstruction(units: number): IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> {\n const data = new Uint8Array(5);\n data[0] = SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX;\n getU32Encoder().write(units, data, 1 /* offset */);\n return Object.freeze({\n data,\n programAddress: COMPUTE_BUDGET_PROGRAM_ADDRESS,\n });\n}\n\nfunction isSetComputeLimitInstruction(\n instruction: IInstruction,\n): instruction is IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> & IInstructionWithData<Uint8Array> {\n return (\n isInstructionForProgram(instruction, COMPUTE_BUDGET_PROGRAM_ADDRESS) &&\n isInstructionWithData(instruction) &&\n instruction.data[0] === SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX\n );\n}\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that – an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n rpc,\n transactionMessage,\n ...simulateConfig\n}: ComputeUnitEstimateForTransactionMessageConfig): Promise<number> {\n /**\n * STEP 1: Make sure the transaction message will not fail in simulation for lack of a lifetime\n * - either a recent blockhash lifetime or a nonce.\n */\n const isDurableNonceTransactionMessage = isDurableNonceTransaction(transactionMessage);\n let compilableTransactionMessage;\n if (isDurableNonceTransactionMessage || isTransactionMessageWithBlockhashLifetime(transactionMessage)) {\n compilableTransactionMessage = transactionMessage;\n } else {\n compilableTransactionMessage = setTransactionMessageLifetimeUsingBlockhash(\n INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH,\n transactionMessage,\n );\n }\n /**\n * STEP 2: Ensure that the message has a `SetComputeLimit` instruction. The set compute limit\n * instruction itself consumes compute units, so it must be included in the simulation.\n */\n const existingSetComputeUnitLimitInstructionIndex =\n transactionMessage.instructions.findIndex(isSetComputeLimitInstruction);\n const maxComputeUnitLimitInstruction = createComputeUnitLimitInstruction(1_400_000 /* MAX_COMPUTE_UNIT_LIMIT */);\n if (existingSetComputeUnitLimitInstructionIndex === -1) {\n compilableTransactionMessage = appendTransactionMessageInstruction(\n maxComputeUnitLimitInstruction,\n compilableTransactionMessage,\n );\n } else {\n const nextInstructions = [...compilableTransactionMessage.instructions];\n nextInstructions.splice(existingSetComputeUnitLimitInstructionIndex, 1, maxComputeUnitLimitInstruction);\n compilableTransactionMessage = Object.freeze({\n ...compilableTransactionMessage,\n instructions: nextInstructions,\n } as typeof compilableTransactionMessage);\n }\n /**\n * STEP 3: Simulate the transaction to measure its compute unit consumption.\n */\n const compiledTransaction = compileTransaction(compilableTransactionMessage);\n const wireTransactionBytes = getBase64EncodedWireTransaction(compiledTransaction);\n try {\n const {\n value: { err: transactionError, unitsConsumed },\n } = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n replaceRecentBlockhash: !isDurableNonceTransactionMessage,\n sigVerify: false,\n })\n .send({ abortSignal });\n if (unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: transactionError,\n unitsConsumed: downcastUnitsConsumed,\n });\n }\n return downcastUnitsConsumed;\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: e,\n });\n }\n}\n","import { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport {\n CompilableTransactionMessage,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n} from '@solana/transaction-messages';\n\nimport { getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT } from './compute-limit-internal';\n\ntype ComputeUnitEstimateForTransactionMessageFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\ntype ComputeUnitEstimateForTransactionMessageFunction = (\n transactionMessage: CompilableTransactionMessage | (TransactionMessage & TransactionMessageWithFeePayer),\n config?: Omit<\n Parameters<typeof getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'rpc' | 'transactionMessage'\n >,\n) => Promise<number>;\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage = getComputeUnitEstimateForTransactionMessageFactory({\n * rpc,\n * });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const computeUnitsEstimate = await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n */\nexport function getComputeUnitEstimateForTransactionMessageFactory({\n rpc,\n}: ComputeUnitEstimateForTransactionMessageFactoryConfig): ComputeUnitEstimateForTransactionMessageFunction {\n return async function getComputeUnitEstimateForTransactionMessage(transactionMessage, config) {\n return await getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transactionMessage,\n });\n };\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 CompilableTransactionMessage,\n CompiledTransactionMessage,\n decompileTransactionMessage,\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,\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: DecompileTransactionMessageFetchingLookupTablesConfig,\n): Promise<CompilableTransactionMessage> {\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 { 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 FullySignedTransaction,\n getBase64EncodedWireTransaction,\n TransactionWithDurableNonceLifetime,\n} from '@solana/transactions';\n\ninterface SendAndConfirmDurableNonceTransactionConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmDurableNonceTransaction: (\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmRecentTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight;\n}\n\ninterface SendTransactionBaseConfig extends SendTransactionConfigWithoutEncoding {\n abortSignal?: AbortSignal;\n commitment: Commitment;\n rpc: Rpc<SendTransactionApi>;\n transaction: FullySignedTransaction;\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 commitment,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendTransactionBaseConfig): Promise<Signature> {\n const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);\n return await rpc\n .sendTransaction(base64EncodedWireTransaction, {\n ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),\n encoding: 'base64',\n })\n .send({ abortSignal });\n}\n\nexport async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmDurableNonceTransactionConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmDurableNonceTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n\nexport async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmRecentTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmTransactionWithBlockhashLifetimeConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmRecentTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n","import type { GetAccountInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { AccountNotificationsApi, RpcSubscriptions, SignatureNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createNonceInvalidationPromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n waitForDurableNonceTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction, TransactionWithDurableNonceLifetime } from '@solana/transactions';\n\nimport { sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmDurableNonceTransactionFunction = (\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime,\n config: Omit<\n Parameters<typeof sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmDurableNonceTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetAccountInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link AccountNotificationsApi} and the {@link SignatureNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<AccountNotificationsApi & SignatureNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a nonce-based transaction to the network and to wait\n * until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * isSolanaError,\n * sendAndConfirmDurableNonceTransactionFactory,\n * SOLANA_ERROR__INVALID_NONCE,\n * SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n * } from '@solana/kit';\n *\n * const sendAndConfirmNonceTransaction = sendAndConfirmDurableNonceTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmNonceTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {\n * console.error(\n * 'The lifetime specified by this transaction refers to a nonce account ' +\n * `\\`${e.context.nonceAccountAddress}\\` that does not exist`,\n * );\n * } else if (isSolanaError(e, SOLANA_ERROR__INVALID_NONCE)) {\n * console.error('This transaction depends on a nonce that is no longer valid');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'devnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'testnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'mainnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory<\n TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void,\n>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster>): SendAndConfirmDurableNonceTransactionFunction {\n const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({ rpc, rpcSubscriptions } as Parameters<\n typeof createNonceInvalidationPromiseFactory\n >[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmDurableNonceTransaction(\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForDurableNonceTransactionConfirmation({\n ...config,\n getNonceInvalidationPromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmDurableNonceTransaction(transaction, config) {\n await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { GetEpochInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { RpcSubscriptions, SignatureNotificationsApi, SlotNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createBlockHeightExceedencePromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n TransactionWithLastValidBlockHeight,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFunction = (\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight,\n config: Omit<\n Parameters<typeof sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmRecentTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetEpochInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link SignatureNotificationsApi} and the {@link SlotNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a blockhash-based transaction to the network and to\n * wait until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { isSolanaError, sendAndConfirmTransactionFactory, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED } from '@solana/kit';\n *\n * const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {\n * console.error('This transaction depends on a blockhash that has expired');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'devnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'testnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'mainnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory<TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster>): SendAndConfirmTransactionWithBlockhashLifetimeFunction {\n const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createBlockHeightExceedencePromiseFactory>[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmRecentTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmation({\n ...config,\n getBlockHeightExceedencePromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmTransaction(transaction, config) {\n await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmRecentTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { Rpc, SendTransactionApi } from '@solana/rpc';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendTransactionWithoutConfirmingFunction = (\n transaction: FullySignedTransaction,\n config: Omit<Parameters<typeof sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0], 'rpc' | 'transaction'>,\n) => Promise<void>;\n\ninterface SendTransactionWithoutConfirmingFactoryConfig {\n /** An object that supports the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<SendTransactionApi>;\n}\n\n/**\n * Returns a function that you can call to send a transaction with any kind of lifetime to the\n * network without waiting for it to be confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * sendTransactionWithoutConfirmingFactory,\n * SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE,\n * } from '@solana/kit';\n *\n * const sendTransaction = sendTransactionWithoutConfirmingFactory({ rpc });\n *\n * try {\n * await sendTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE)) {\n * console.error('The transaction failed in simulation', e.cause);\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendTransactionWithoutConfirmingFactory({\n rpc,\n}: SendTransactionWithoutConfirmingFactoryConfig): SendTransactionWithoutConfirmingFunction {\n return async function sendTransactionWithoutConfirming(transaction, config) {\n await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transaction,\n });\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/airdrop-internal.ts","../src/airdrop.ts","../src/compute-limit-internal.ts","../src/compute-limit.ts","../src/fetch-lookup-tables.ts","../src/decompile-transaction-message-fetching-lookup-tables.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,oDAAqD,CAAA;AAAA,EACvE,WAAA;AAAA,EACA,UAAA;AAAA,EACA,+BAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACJ,CAAuD,EAAA;AACnD,EAAA,MAAM,2BAA8B,GAAA,MAAM,GACrC,CAAA,cAAA,CAAe,gBAAkB,EAAA,QAAA,EAAU,EAAE,UAAA,EAAY,CAAA,CACzD,IAAK,CAAA,EAAE,aAA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EAA2E,CAAA;AAAA,MAC7E,GAAG,MAAA;AAAA,MACH,wBAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ;;;ACrDO,SAAS,uCAAwC,CAAA;AAAA,EACpD;AACJ,CAA4F,EAAA;AACxF,EAAO,OAAA,eAAe,gCAAiC,CAAA,WAAA,EAAa,MAAQ,EAAA;AACxE,IAAA,MAAM,2CAA4C,CAAA;AAAA,MAC9C,GAAG,MAAA;AAAA,MACH,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ","file":"index.browser.mjs","sourcesContent":["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 { Address } from '@solana/addresses';\nimport { getU32Encoder } from '@solana/codecs';\nimport {\n isSolanaError,\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 {\n IInstruction,\n IInstructionWithData,\n isInstructionForProgram,\n isInstructionWithData,\n} from '@solana/instructions';\nimport { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport { Blockhash, Commitment, Slot } from '@solana/rpc-types';\nimport {\n appendTransactionMessageInstruction,\n CompilableTransactionMessage,\n isDurableNonceTransaction,\n isTransactionMessageWithBlockhashLifetime,\n ITransactionMessageWithFeePayer,\n setTransactionMessageLifetimeUsingBlockhash,\n TransactionMessage,\n} from '@solana/transaction-messages';\nimport { compileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';\n\ntype ComputeUnitEstimateForTransactionMessageConfig = Readonly<{\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: CompilableTransactionMessage | (ITransactionMessageWithFeePayer & TransactionMessage);\n}>;\n\nconst COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n// HACK: Since the `compileTransaction()` method will not compile a transaction with no lifetime we\n// supply a dummy lifetime.\nconst INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH = {\n blockhash: '11111111111111111111111111111111' as Blockhash,\n lastValidBlockHeight: 0n, // This is not included in compiled transactions; it can be anything.\n} as const;\nconst SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX = 0x02;\n\nfunction createComputeUnitLimitInstruction(units: number): IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> {\n const data = new Uint8Array(5);\n data[0] = SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX;\n getU32Encoder().write(units, data, 1 /* offset */);\n return Object.freeze({\n data,\n programAddress: COMPUTE_BUDGET_PROGRAM_ADDRESS,\n });\n}\n\nfunction isSetComputeLimitInstruction(\n instruction: IInstruction,\n): instruction is IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> & IInstructionWithData<Uint8Array> {\n return (\n isInstructionForProgram(instruction, COMPUTE_BUDGET_PROGRAM_ADDRESS) &&\n isInstructionWithData(instruction) &&\n instruction.data[0] === SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX\n );\n}\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that – an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n rpc,\n transactionMessage,\n ...simulateConfig\n}: ComputeUnitEstimateForTransactionMessageConfig): Promise<number> {\n /**\n * STEP 1: Make sure the transaction message will not fail in simulation for lack of a lifetime\n * - either a recent blockhash lifetime or a nonce.\n */\n const isDurableNonceTransactionMessage = isDurableNonceTransaction(transactionMessage);\n let compilableTransactionMessage;\n if (isDurableNonceTransactionMessage || isTransactionMessageWithBlockhashLifetime(transactionMessage)) {\n compilableTransactionMessage = transactionMessage;\n } else {\n compilableTransactionMessage = setTransactionMessageLifetimeUsingBlockhash(\n INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH,\n transactionMessage,\n );\n }\n /**\n * STEP 2: Ensure that the message has a `SetComputeLimit` instruction. The set compute limit\n * instruction itself consumes compute units, so it must be included in the simulation.\n */\n const existingSetComputeUnitLimitInstructionIndex =\n transactionMessage.instructions.findIndex(isSetComputeLimitInstruction);\n const maxComputeUnitLimitInstruction = createComputeUnitLimitInstruction(1_400_000 /* MAX_COMPUTE_UNIT_LIMIT */);\n if (existingSetComputeUnitLimitInstructionIndex === -1) {\n compilableTransactionMessage = appendTransactionMessageInstruction(\n maxComputeUnitLimitInstruction,\n compilableTransactionMessage,\n );\n } else {\n const nextInstructions = [...compilableTransactionMessage.instructions];\n nextInstructions.splice(existingSetComputeUnitLimitInstructionIndex, 1, maxComputeUnitLimitInstruction);\n compilableTransactionMessage = Object.freeze({\n ...compilableTransactionMessage,\n instructions: nextInstructions,\n } as typeof compilableTransactionMessage);\n }\n /**\n * STEP 3: Simulate the transaction to measure its compute unit consumption.\n */\n const compiledTransaction = compileTransaction(compilableTransactionMessage);\n const wireTransactionBytes = getBase64EncodedWireTransaction(compiledTransaction);\n try {\n const {\n value: { err: transactionError, unitsConsumed },\n } = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n replaceRecentBlockhash: !isDurableNonceTransactionMessage,\n sigVerify: false,\n })\n .send({ abortSignal });\n if (unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: transactionError,\n unitsConsumed: downcastUnitsConsumed,\n });\n }\n return downcastUnitsConsumed;\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: e,\n });\n }\n}\n","import { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport {\n CompilableTransactionMessage,\n ITransactionMessageWithFeePayer,\n TransactionMessage,\n} from '@solana/transaction-messages';\n\nimport { getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT } from './compute-limit-internal';\n\ntype ComputeUnitEstimateForTransactionMessageFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\ntype ComputeUnitEstimateForTransactionMessageFunction = (\n transactionMessage: CompilableTransactionMessage | (ITransactionMessageWithFeePayer & TransactionMessage),\n config?: Omit<\n Parameters<typeof getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'rpc' | 'transactionMessage'\n >,\n) => Promise<number>;\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage = getComputeUnitEstimateForTransactionMessageFactory({\n * rpc,\n * });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const computeUnitsEstimate = await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n */\nexport function getComputeUnitEstimateForTransactionMessageFactory({\n rpc,\n}: ComputeUnitEstimateForTransactionMessageFactoryConfig): ComputeUnitEstimateForTransactionMessageFunction {\n return async function getComputeUnitEstimateForTransactionMessage(transactionMessage, config) {\n return await getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transactionMessage,\n });\n };\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 CompilableTransactionMessage,\n CompiledTransactionMessage,\n decompileTransactionMessage,\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,\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: DecompileTransactionMessageFetchingLookupTablesConfig,\n): Promise<CompilableTransactionMessage> {\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 { 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 FullySignedTransaction,\n getBase64EncodedWireTransaction,\n TransactionWithDurableNonceLifetime,\n} from '@solana/transactions';\n\ninterface SendAndConfirmDurableNonceTransactionConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmDurableNonceTransaction: (\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmRecentTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight;\n}\n\ninterface SendTransactionBaseConfig extends SendTransactionConfigWithoutEncoding {\n abortSignal?: AbortSignal;\n commitment: Commitment;\n rpc: Rpc<SendTransactionApi>;\n transaction: FullySignedTransaction;\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 commitment,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendTransactionBaseConfig): Promise<Signature> {\n const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);\n return await rpc\n .sendTransaction(base64EncodedWireTransaction, {\n ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),\n encoding: 'base64',\n })\n .send({ abortSignal });\n}\n\nexport async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmDurableNonceTransactionConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmDurableNonceTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n\nexport async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmRecentTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmTransactionWithBlockhashLifetimeConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmRecentTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n","import type { GetAccountInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { AccountNotificationsApi, RpcSubscriptions, SignatureNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createNonceInvalidationPromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n waitForDurableNonceTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction, TransactionWithDurableNonceLifetime } from '@solana/transactions';\n\nimport { sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmDurableNonceTransactionFunction = (\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime,\n config: Omit<\n Parameters<typeof sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmDurableNonceTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetAccountInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link AccountNotificationsApi} and the {@link SignatureNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<AccountNotificationsApi & SignatureNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a nonce-based transaction to the network and to wait\n * until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * isSolanaError,\n * sendAndConfirmDurableNonceTransactionFactory,\n * SOLANA_ERROR__INVALID_NONCE,\n * SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n * } from '@solana/kit';\n *\n * const sendAndConfirmNonceTransaction = sendAndConfirmDurableNonceTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmNonceTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {\n * console.error(\n * 'The lifetime specified by this transaction refers to a nonce account ' +\n * `\\`${e.context.nonceAccountAddress}\\` that does not exist`,\n * );\n * } else if (isSolanaError(e, SOLANA_ERROR__INVALID_NONCE)) {\n * console.error('This transaction depends on a nonce that is no longer valid');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'devnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'testnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'mainnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory<\n TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void,\n>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster>): SendAndConfirmDurableNonceTransactionFunction {\n const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({ rpc, rpcSubscriptions } as Parameters<\n typeof createNonceInvalidationPromiseFactory\n >[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmDurableNonceTransaction(\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForDurableNonceTransactionConfirmation({\n ...config,\n getNonceInvalidationPromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmDurableNonceTransaction(transaction, config) {\n await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { GetEpochInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { RpcSubscriptions, SignatureNotificationsApi, SlotNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createBlockHeightExceedencePromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n TransactionWithLastValidBlockHeight,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFunction = (\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight,\n config: Omit<\n Parameters<typeof sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmRecentTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetEpochInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link SignatureNotificationsApi} and the {@link SlotNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a blockhash-based transaction to the network and to\n * wait until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { isSolanaError, sendAndConfirmTransactionFactory, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED } from '@solana/kit';\n *\n * const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {\n * console.error('This transaction depends on a blockhash that has expired');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'devnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'testnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'mainnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory<TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster>): SendAndConfirmTransactionWithBlockhashLifetimeFunction {\n const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createBlockHeightExceedencePromiseFactory>[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmRecentTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmation({\n ...config,\n getBlockHeightExceedencePromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmTransaction(transaction, config) {\n await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmRecentTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { Rpc, SendTransactionApi } from '@solana/rpc';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendTransactionWithoutConfirmingFunction = (\n transaction: FullySignedTransaction,\n config: Omit<Parameters<typeof sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0], 'rpc' | 'transaction'>,\n) => Promise<void>;\n\ninterface SendTransactionWithoutConfirmingFactoryConfig {\n /** An object that supports the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<SendTransactionApi>;\n}\n\n/**\n * Returns a function that you can call to send a transaction with any kind of lifetime to the\n * network without waiting for it to be confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * sendTransactionWithoutConfirmingFactory,\n * SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE,\n * } from '@solana/kit';\n *\n * const sendTransaction = sendTransactionWithoutConfirmingFactory({ rpc });\n *\n * try {\n * await sendTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE)) {\n * console.error('The transaction failed in simulation', e.cause);\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendTransactionWithoutConfirmingFactory({\n rpc,\n}: SendTransactionWithoutConfirmingFactoryConfig): SendTransactionWithoutConfirmingFunction {\n return async function sendTransactionWithoutConfirming(transaction, config) {\n await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transaction,\n });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/airdrop-internal.ts","../src/airdrop.ts","../src/compute-limit-internal.ts","../src/compute-limit.ts","../src/fetch-lookup-tables.ts","../src/decompile-transaction-message-fetching-lookup-tables.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,oDAAqD,CAAA;AAAA,EACvE,WAAA;AAAA,EACA,UAAA;AAAA,EACA,+BAAA;AAAA,EACA,QAAA;AAAA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AAA,MAAM,oCAAqC,CAAA;AAAA,MACvC,GAAG,MAAA;AAAA,MACH,+BAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA;AAEL,EAAO,OAAA,eAAe,yBAA0B,CAAA,WAAA,EAAa,MAAQ,EAAA;AACjE,IAAA,MAAM,0EAA2E,CAAA;AAAA,MAC7E,GAAG,MAAA;AAAA,MACH,wBAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ;;;ACrDO,SAAS,uCAAwC,CAAA;AAAA,EACpD;AACJ,CAA4F,EAAA;AACxF,EAAO,OAAA,eAAe,gCAAiC,CAAA,WAAA,EAAa,MAAQ,EAAA;AACxE,IAAA,MAAM,2CAA4C,CAAA;AAAA,MAC9C,GAAG,MAAA;AAAA,MACH,GAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,GACL;AACJ","file":"index.browser.mjs","sourcesContent":["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 { Address } from '@solana/addresses';\nimport { getU32Encoder } from '@solana/codecs';\nimport {\n isSolanaError,\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 {\n IInstruction,\n IInstructionWithData,\n isInstructionForProgram,\n isInstructionWithData,\n} from '@solana/instructions';\nimport { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport { Blockhash, Commitment, Slot } from '@solana/rpc-types';\nimport {\n appendTransactionMessageInstruction,\n CompilableTransactionMessage,\n isDurableNonceTransaction,\n isTransactionMessageWithBlockhashLifetime,\n setTransactionMessageLifetimeUsingBlockhash,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n} from '@solana/transaction-messages';\nimport { compileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';\n\ntype ComputeUnitEstimateForTransactionMessageConfig = Readonly<{\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: CompilableTransactionMessage | (TransactionMessage & TransactionMessageWithFeePayer);\n}>;\n\nconst COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n// HACK: Since the `compileTransaction()` method will not compile a transaction with no lifetime we\n// supply a dummy lifetime.\nconst INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH = {\n blockhash: '11111111111111111111111111111111' as Blockhash,\n lastValidBlockHeight: 0n, // This is not included in compiled transactions; it can be anything.\n} as const;\nconst SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX = 0x02;\n\nfunction createComputeUnitLimitInstruction(units: number): IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> {\n const data = new Uint8Array(5);\n data[0] = SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX;\n getU32Encoder().write(units, data, 1 /* offset */);\n return Object.freeze({\n data,\n programAddress: COMPUTE_BUDGET_PROGRAM_ADDRESS,\n });\n}\n\nfunction isSetComputeLimitInstruction(\n instruction: IInstruction,\n): instruction is IInstruction<typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> & IInstructionWithData<Uint8Array> {\n return (\n isInstructionForProgram(instruction, COMPUTE_BUDGET_PROGRAM_ADDRESS) &&\n isInstructionWithData(instruction) &&\n instruction.data[0] === SET_COMPUTE_UNIT_LIMIT_INSTRUCTION_INDEX\n );\n}\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that – an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n rpc,\n transactionMessage,\n ...simulateConfig\n}: ComputeUnitEstimateForTransactionMessageConfig): Promise<number> {\n /**\n * STEP 1: Make sure the transaction message will not fail in simulation for lack of a lifetime\n * - either a recent blockhash lifetime or a nonce.\n */\n const isDurableNonceTransactionMessage = isDurableNonceTransaction(transactionMessage);\n let compilableTransactionMessage;\n if (isDurableNonceTransactionMessage || isTransactionMessageWithBlockhashLifetime(transactionMessage)) {\n compilableTransactionMessage = transactionMessage;\n } else {\n compilableTransactionMessage = setTransactionMessageLifetimeUsingBlockhash(\n INVALID_BUT_SUFFICIENT_FOR_COMPILATION_BLOCKHASH,\n transactionMessage,\n );\n }\n /**\n * STEP 2: Ensure that the message has a `SetComputeLimit` instruction. The set compute limit\n * instruction itself consumes compute units, so it must be included in the simulation.\n */\n const existingSetComputeUnitLimitInstructionIndex =\n transactionMessage.instructions.findIndex(isSetComputeLimitInstruction);\n const maxComputeUnitLimitInstruction = createComputeUnitLimitInstruction(1_400_000 /* MAX_COMPUTE_UNIT_LIMIT */);\n if (existingSetComputeUnitLimitInstructionIndex === -1) {\n compilableTransactionMessage = appendTransactionMessageInstruction(\n maxComputeUnitLimitInstruction,\n compilableTransactionMessage,\n );\n } else {\n const nextInstructions = [...compilableTransactionMessage.instructions];\n nextInstructions.splice(existingSetComputeUnitLimitInstructionIndex, 1, maxComputeUnitLimitInstruction);\n compilableTransactionMessage = Object.freeze({\n ...compilableTransactionMessage,\n instructions: nextInstructions,\n } as typeof compilableTransactionMessage);\n }\n /**\n * STEP 3: Simulate the transaction to measure its compute unit consumption.\n */\n const compiledTransaction = compileTransaction(compilableTransactionMessage);\n const wireTransactionBytes = getBase64EncodedWireTransaction(compiledTransaction);\n try {\n const {\n value: { err: transactionError, unitsConsumed },\n } = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n replaceRecentBlockhash: !isDurableNonceTransactionMessage,\n sigVerify: false,\n })\n .send({ abortSignal });\n if (unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: transactionError,\n unitsConsumed: downcastUnitsConsumed,\n });\n }\n return downcastUnitsConsumed;\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: e,\n });\n }\n}\n","import { Rpc, SimulateTransactionApi } from '@solana/rpc';\nimport {\n CompilableTransactionMessage,\n TransactionMessage,\n TransactionMessageWithFeePayer,\n} from '@solana/transaction-messages';\n\nimport { getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT } from './compute-limit-internal';\n\ntype ComputeUnitEstimateForTransactionMessageFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\ntype ComputeUnitEstimateForTransactionMessageFunction = (\n transactionMessage: CompilableTransactionMessage | (TransactionMessage & TransactionMessageWithFeePayer),\n config?: Omit<\n Parameters<typeof getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'rpc' | 'transactionMessage'\n >,\n) => Promise<number>;\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage = getComputeUnitEstimateForTransactionMessageFactory({\n * rpc,\n * });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const computeUnitsEstimate = await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n */\nexport function getComputeUnitEstimateForTransactionMessageFactory({\n rpc,\n}: ComputeUnitEstimateForTransactionMessageFactoryConfig): ComputeUnitEstimateForTransactionMessageFunction {\n return async function getComputeUnitEstimateForTransactionMessage(transactionMessage, config) {\n return await getComputeUnitEstimateForTransactionMessage_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transactionMessage,\n });\n };\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 CompilableTransactionMessage,\n CompiledTransactionMessage,\n decompileTransactionMessage,\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,\n rpc: Rpc<GetMultipleAccountsApi>,\n config?: DecompileTransactionMessageFetchingLookupTablesConfig,\n): Promise<CompilableTransactionMessage> {\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 { 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 FullySignedTransaction,\n getBase64EncodedWireTransaction,\n TransactionWithDurableNonceLifetime,\n} from '@solana/transactions';\n\ninterface SendAndConfirmDurableNonceTransactionConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmDurableNonceTransaction: (\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime;\n}\n\ninterface SendAndConfirmTransactionWithBlockhashLifetimeConfig\n extends SendTransactionBaseConfig,\n SendTransactionConfigWithoutEncoding {\n confirmRecentTransaction: (\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) => Promise<void>;\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight;\n}\n\ninterface SendTransactionBaseConfig extends SendTransactionConfigWithoutEncoding {\n abortSignal?: AbortSignal;\n commitment: Commitment;\n rpc: Rpc<SendTransactionApi>;\n transaction: FullySignedTransaction;\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 commitment,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendTransactionBaseConfig): Promise<Signature> {\n const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);\n return await rpc\n .sendTransaction(base64EncodedWireTransaction, {\n ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),\n encoding: 'base64',\n })\n .send({ abortSignal });\n}\n\nexport async function sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmDurableNonceTransactionConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmDurableNonceTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n\nexport async function sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n abortSignal,\n commitment,\n confirmRecentTransaction,\n rpc,\n transaction,\n ...sendTransactionConfig\n}: SendAndConfirmTransactionWithBlockhashLifetimeConfig): Promise<Signature> {\n const transactionSignature = await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...sendTransactionConfig,\n abortSignal,\n commitment,\n rpc,\n transaction,\n });\n await confirmRecentTransaction({\n abortSignal,\n commitment,\n transaction,\n });\n return transactionSignature;\n}\n","import type { GetAccountInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { AccountNotificationsApi, RpcSubscriptions, SignatureNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createNonceInvalidationPromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n waitForDurableNonceTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction, TransactionWithDurableNonceLifetime } from '@solana/transactions';\n\nimport { sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmDurableNonceTransactionFunction = (\n transaction: FullySignedTransaction & TransactionWithDurableNonceLifetime,\n config: Omit<\n Parameters<typeof sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmDurableNonceTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetAccountInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link AccountNotificationsApi} and the {@link SignatureNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<AccountNotificationsApi & SignatureNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a nonce-based transaction to the network and to wait\n * until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * isSolanaError,\n * sendAndConfirmDurableNonceTransactionFactory,\n * SOLANA_ERROR__INVALID_NONCE,\n * SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND,\n * } from '@solana/kit';\n *\n * const sendAndConfirmNonceTransaction = sendAndConfirmDurableNonceTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmNonceTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND)) {\n * console.error(\n * 'The lifetime specified by this transaction refers to a nonce account ' +\n * `\\`${e.context.nonceAccountAddress}\\` that does not exist`,\n * );\n * } else if (isSolanaError(e, SOLANA_ERROR__INVALID_NONCE)) {\n * console.error('This transaction depends on a nonce that is no longer valid');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'devnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'testnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<'mainnet'>): SendAndConfirmDurableNonceTransactionFunction;\nexport function sendAndConfirmDurableNonceTransactionFactory<\n TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void,\n>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmDurableNonceTransactionFactoryConfig<TCluster>): SendAndConfirmDurableNonceTransactionFunction {\n const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory({ rpc, rpcSubscriptions } as Parameters<\n typeof createNonceInvalidationPromiseFactory\n >[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmDurableNonceTransaction(\n config: Omit<\n Parameters<typeof waitForDurableNonceTransactionConfirmation>[0],\n 'getNonceInvalidationPromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForDurableNonceTransactionConfirmation({\n ...config,\n getNonceInvalidationPromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmDurableNonceTransaction(transaction, config) {\n await sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmDurableNonceTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { GetEpochInfoApi, GetSignatureStatusesApi, Rpc, SendTransactionApi } from '@solana/rpc';\nimport type { RpcSubscriptions, SignatureNotificationsApi, SlotNotificationsApi } from '@solana/rpc-subscriptions';\nimport {\n createBlockHeightExceedencePromiseFactory,\n createRecentSignatureConfirmationPromiseFactory,\n TransactionWithLastValidBlockHeight,\n waitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFunction = (\n transaction: FullySignedTransaction & TransactionWithLastValidBlockHeight,\n config: Omit<\n Parameters<typeof sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT>[0],\n 'confirmRecentTransaction' | 'rpc' | 'transaction'\n >,\n) => Promise<void>;\n\ntype SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster> = {\n /** An object that supports the {@link GetSignatureStatusesApi} and the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<GetEpochInfoApi & GetSignatureStatusesApi & SendTransactionApi> & { '~cluster'?: TCluster };\n /** An object that supports the {@link SignatureNotificationsApi} and the {@link SlotNotificationsApi} of the Solana RPC Subscriptions API */\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi> & { '~cluster'?: TCluster };\n};\n\n/**\n * Returns a function that you can call to send a blockhash-based transaction to the network and to\n * wait until it has been confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { isSolanaError, sendAndConfirmTransactionFactory, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED } from '@solana/kit';\n *\n * const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });\n *\n * try {\n * await sendAndConfirmTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED)) {\n * console.error('This transaction depends on a blockhash that has expired');\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'devnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'testnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<'mainnet'>): SendAndConfirmTransactionWithBlockhashLifetimeFunction;\nexport function sendAndConfirmTransactionFactory<TCluster extends 'devnet' | 'mainnet' | 'testnet' | void = void>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithBlockhashLifetimeFactoryConfig<TCluster>): SendAndConfirmTransactionWithBlockhashLifetimeFunction {\n const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createBlockHeightExceedencePromiseFactory>[0]);\n const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n rpc,\n rpcSubscriptions,\n } as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]);\n async function confirmRecentTransaction(\n config: Omit<\n Parameters<typeof waitForRecentTransactionConfirmation>[0],\n 'getBlockHeightExceedencePromise' | 'getRecentSignatureConfirmationPromise'\n >,\n ) {\n await waitForRecentTransactionConfirmation({\n ...config,\n getBlockHeightExceedencePromise,\n getRecentSignatureConfirmationPromise,\n });\n }\n return async function sendAndConfirmTransaction(transaction, config) {\n await sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n confirmRecentTransaction,\n rpc,\n transaction,\n });\n };\n}\n","import type { Rpc, SendTransactionApi } from '@solana/rpc';\nimport { FullySignedTransaction } from '@solana/transactions';\n\nimport { sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';\n\ntype SendTransactionWithoutConfirmingFunction = (\n transaction: FullySignedTransaction,\n config: Omit<Parameters<typeof sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT>[0], 'rpc' | 'transaction'>,\n) => Promise<void>;\n\ninterface SendTransactionWithoutConfirmingFactoryConfig {\n /** An object that supports the {@link SendTransactionApi} of the Solana RPC API */\n rpc: Rpc<SendTransactionApi>;\n}\n\n/**\n * Returns a function that you can call to send a transaction with any kind of lifetime to the\n * network without waiting for it to be confirmed.\n *\n * @param config\n *\n * @example\n * ```ts\n * import {\n * sendTransactionWithoutConfirmingFactory,\n * SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE,\n * } from '@solana/kit';\n *\n * const sendTransaction = sendTransactionWithoutConfirmingFactory({ rpc });\n *\n * try {\n * await sendTransaction(transaction, { commitment: 'confirmed' });\n * } catch (e) {\n * if (isSolanaError(e, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE)) {\n * console.error('The transaction failed in simulation', e.cause);\n * } else {\n * throw e;\n * }\n * }\n * ```\n */\nexport function sendTransactionWithoutConfirmingFactory({\n rpc,\n}: SendTransactionWithoutConfirmingFactoryConfig): SendTransactionWithoutConfirmingFunction {\n return async function sendTransactionWithoutConfirming(transaction, config) {\n await sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT({\n ...config,\n rpc,\n transaction,\n });\n };\n}\n"]}
|
|
@@ -158,6 +158,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
158
158
|
var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
|
|
159
159
|
var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
|
|
160
160
|
var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
|
|
161
|
+
var SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT = 5663020;
|
|
161
162
|
var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
|
|
162
163
|
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
|
|
163
164
|
var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
|
|
@@ -390,7 +391,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
390
391
|
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER]: "The provided value does not implement the `TransactionSendingSigner` interface",
|
|
391
392
|
[SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER]: "The provided value does not implement any of the `TransactionSigner` interfaces",
|
|
392
393
|
[SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
|
|
393
|
-
[SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `
|
|
394
|
+
[SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",
|
|
394
395
|
[SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
|
|
395
396
|
[SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY]: "Cannot export a non-extractable key.",
|
|
396
397
|
[SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
|
|
@@ -441,6 +442,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
441
442
|
[SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION]: "Attempted to sign a transaction with an address that is not a signer for it",
|
|
442
443
|
[SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING]: "Transaction is missing an address at index: $index.",
|
|
443
444
|
[SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES]: "Transaction has no expected signers therefore it cannot be encoded",
|
|
445
|
+
[SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT]: "Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",
|
|
444
446
|
[SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME]: "Transaction does not have a blockhash lifetime",
|
|
445
447
|
[SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME]: "Transaction is not a durable nonce transaction",
|
|
446
448
|
[SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING]: "Contents of these address lookup tables unknown: $lookupTableAddresses",
|
|
@@ -4248,7 +4250,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
4248
4250
|
...config.headers ? normalizeHeaders2(config.headers) : void 0,
|
|
4249
4251
|
...{
|
|
4250
4252
|
// Keep these headers lowercase so they will override any user-supplied headers above.
|
|
4251
|
-
"solana-client": `js/${"2.
|
|
4253
|
+
"solana-client": `js/${"2.2.0-canary-20250514101537"}`
|
|
4252
4254
|
}
|
|
4253
4255
|
}
|
|
4254
4256
|
}),
|
|
@@ -6685,6 +6687,39 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
6685
6687
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
6686
6688
|
return getBase64Decoder().decode(wireTransactionBytes);
|
|
6687
6689
|
}
|
|
6690
|
+
var TRANSACTION_PACKET_SIZE = 1280;
|
|
6691
|
+
var TRANSACTION_PACKET_HEADER = 40 + 8;
|
|
6692
|
+
var TRANSACTION_SIZE_LIMIT = TRANSACTION_PACKET_SIZE - TRANSACTION_PACKET_HEADER;
|
|
6693
|
+
function getTransactionSize(transaction) {
|
|
6694
|
+
return getTransactionEncoder().getSizeFromValue(transaction);
|
|
6695
|
+
}
|
|
6696
|
+
function isTransactionWithinSizeLimit(transaction) {
|
|
6697
|
+
return getTransactionSize(transaction) <= TRANSACTION_SIZE_LIMIT;
|
|
6698
|
+
}
|
|
6699
|
+
function assertIsTransactionWithinSizeLimit(transaction) {
|
|
6700
|
+
const transactionSize = getTransactionSize(transaction);
|
|
6701
|
+
if (transactionSize > TRANSACTION_SIZE_LIMIT) {
|
|
6702
|
+
throw new SolanaError(SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT, {
|
|
6703
|
+
transactionSize,
|
|
6704
|
+
transactionSizeLimit: TRANSACTION_SIZE_LIMIT
|
|
6705
|
+
});
|
|
6706
|
+
}
|
|
6707
|
+
}
|
|
6708
|
+
function getTransactionMessageSize(transactionMessage) {
|
|
6709
|
+
return getTransactionSize(compileTransaction(transactionMessage));
|
|
6710
|
+
}
|
|
6711
|
+
function isTransactionMessageWithinSizeLimit(transactionMessage) {
|
|
6712
|
+
return getTransactionMessageSize(transactionMessage) <= TRANSACTION_SIZE_LIMIT;
|
|
6713
|
+
}
|
|
6714
|
+
function assertIsTransactionMessageWithinSizeLimit(transactionMessage) {
|
|
6715
|
+
const transactionSize = getTransactionMessageSize(transactionMessage);
|
|
6716
|
+
if (transactionSize > TRANSACTION_SIZE_LIMIT) {
|
|
6717
|
+
throw new SolanaError(SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT, {
|
|
6718
|
+
transactionSize,
|
|
6719
|
+
transactionSizeLimit: TRANSACTION_SIZE_LIMIT
|
|
6720
|
+
});
|
|
6721
|
+
}
|
|
6722
|
+
}
|
|
6688
6723
|
|
|
6689
6724
|
// ../signers/dist/index.browser.mjs
|
|
6690
6725
|
function deduplicateSigners(signers) {
|
|
@@ -7798,6 +7833,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7798
7833
|
exports.SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION = SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION;
|
|
7799
7834
|
exports.SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING;
|
|
7800
7835
|
exports.SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES;
|
|
7836
|
+
exports.SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT = SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT;
|
|
7801
7837
|
exports.SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME;
|
|
7802
7838
|
exports.SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME = SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME;
|
|
7803
7839
|
exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING = SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_ADDRESS_LOOKUP_TABLE_CONTENTS_MISSING;
|
|
@@ -7816,6 +7852,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7816
7852
|
exports.SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING;
|
|
7817
7853
|
exports.SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE;
|
|
7818
7854
|
exports.SolanaError = SolanaError;
|
|
7855
|
+
exports.TRANSACTION_PACKET_HEADER = TRANSACTION_PACKET_HEADER;
|
|
7856
|
+
exports.TRANSACTION_PACKET_SIZE = TRANSACTION_PACKET_SIZE;
|
|
7857
|
+
exports.TRANSACTION_SIZE_LIMIT = TRANSACTION_SIZE_LIMIT;
|
|
7819
7858
|
exports.addCodecSentinel = addCodecSentinel;
|
|
7820
7859
|
exports.addCodecSizePrefix = addCodecSizePrefix;
|
|
7821
7860
|
exports.addDecoderSentinel = addDecoderSentinel;
|
|
@@ -7853,10 +7892,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
7853
7892
|
exports.assertIsStringifiedNumber = assertIsStringifiedNumber;
|
|
7854
7893
|
exports.assertIsTransactionMessageWithBlockhashLifetime = assertIsTransactionMessageWithBlockhashLifetime;
|
|
7855
7894
|
exports.assertIsTransactionMessageWithSingleSendingSigner = assertIsTransactionMessageWithSingleSendingSigner;
|
|
7895
|
+
exports.assertIsTransactionMessageWithinSizeLimit = assertIsTransactionMessageWithinSizeLimit;
|
|
7856
7896
|
exports.assertIsTransactionModifyingSigner = assertIsTransactionModifyingSigner;
|
|
7857
7897
|
exports.assertIsTransactionPartialSigner = assertIsTransactionPartialSigner;
|
|
7858
7898
|
exports.assertIsTransactionSendingSigner = assertIsTransactionSendingSigner;
|
|
7859
7899
|
exports.assertIsTransactionSigner = assertIsTransactionSigner;
|
|
7900
|
+
exports.assertIsTransactionWithinSizeLimit = assertIsTransactionWithinSizeLimit;
|
|
7860
7901
|
exports.assertIsUnixTimestamp = assertIsUnixTimestamp;
|
|
7861
7902
|
exports.assertIsVariableSize = assertIsVariableSize;
|
|
7862
7903
|
exports.assertNumberIsBetweenForCodec = assertNumberIsBetweenForCodec;
|
|
@@ -8046,6 +8087,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8046
8087
|
exports.getTransactionCodec = getTransactionCodec;
|
|
8047
8088
|
exports.getTransactionDecoder = getTransactionDecoder;
|
|
8048
8089
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
8090
|
+
exports.getTransactionMessageSize = getTransactionMessageSize;
|
|
8091
|
+
exports.getTransactionSize = getTransactionSize;
|
|
8049
8092
|
exports.getTransactionVersionCodec = getTransactionVersionCodec;
|
|
8050
8093
|
exports.getTransactionVersionDecoder = getTransactionVersionDecoder;
|
|
8051
8094
|
exports.getTransactionVersionEncoder = getTransactionVersionEncoder;
|
|
@@ -8102,10 +8145,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
8102
8145
|
exports.isStringifiedNumber = isStringifiedNumber;
|
|
8103
8146
|
exports.isTransactionMessageWithBlockhashLifetime = isTransactionMessageWithBlockhashLifetime;
|
|
8104
8147
|
exports.isTransactionMessageWithSingleSendingSigner = isTransactionMessageWithSingleSendingSigner;
|
|
8148
|
+
exports.isTransactionMessageWithinSizeLimit = isTransactionMessageWithinSizeLimit;
|
|
8105
8149
|
exports.isTransactionModifyingSigner = isTransactionModifyingSigner;
|
|
8106
8150
|
exports.isTransactionPartialSigner = isTransactionPartialSigner;
|
|
8107
8151
|
exports.isTransactionSendingSigner = isTransactionSendingSigner;
|
|
8108
8152
|
exports.isTransactionSigner = isTransactionSigner;
|
|
8153
|
+
exports.isTransactionWithinSizeLimit = isTransactionWithinSizeLimit;
|
|
8109
8154
|
exports.isUnixTimestamp = isUnixTimestamp;
|
|
8110
8155
|
exports.isVariableSize = isVariableSize;
|
|
8111
8156
|
exports.isWritableRole = isWritableRole;
|