gill
Version:
a modern javascript/typescript client library for interacting with the Solana blockchain
1 lines • 53.8 kB
Source Map (JSON)
{"version":3,"sources":["../src/core/debug.ts","../src/core/const.ts","../src/core/utils.ts","../src/core/rpc.ts","../src/core/explorer.ts","../src/core/create-transaction.ts","../src/core/send-and-confirm-transaction-with-signers.ts","../src/programs/compute-budget/utils.ts","../src/core/base64-to-transaction.ts","../src/core/prepare-transaction.ts","../src/core/simulate-transaction.ts","../src/core/create-solana-client.ts","../src/core/accounts.ts","../src/core/keypairs-extractable.ts","../src/core/keypairs-base58.ts","../src/core/base64-from-transaction.ts","../src/core/get-oldest-signature.ts","../src/core/insert-reference-key.ts","../src/core/create-codama-config.ts"],"names":["isTransactionSigner","pipe","getBase64EncodedWireTransaction","COMPUTE_BUDGET_PROGRAM_ADDRESS","getSetComputeUnitLimitInstruction","appendTransactionMessageInstruction","setTransactionMessageLifetimeUsingBlockhash","partiallySignTransactionMessageWithSigners","err","createSignerFromKeyPair","SolanaError"],"mappings":";;;;;;;;AAMA,IAAM,eAA4C,GAAA;AAAA,EAChD,KAAO,EAAA,CAAA;AAAA,EACP,IAAM,EAAA,CAAA;AAAA,EACN,IAAM,EAAA,CAAA;AAAA,EACN,KAAO,EAAA;AACT,CAAA;AAgBA,IAAM,cAAA,GAAiB,MACpB,OAAA,CAAQ,GAAI,CAAA,gBAAA,IACb,MAAO,CAAA,oBAAA,IACN,OAAO,MAAA,KAAW,WAAgB,IAAA,MAAA,CAAe,oBAClD,IAAA,MAAA;AAKK,IAAM,iBAAiB,MAC5B,OAAA;AAAA,EACE,OAAA,CAAQ,IAAI,gBACV,IAAA,MAAA,CAAO,wBACP,OAAQ,CAAA,GAAA,CAAI,eAAe,MAC3B,IAAA,OAAA,CAAQ,IAAI,UAAe,KAAA,GAAA,IAC3B,OAAO,cAAmB,KAAA,IAAA,IACzB,OAAO,MAAW,KAAA,WAAA,IAAgB,OAAe,cAAmB,KAAA;AACzE;AAmBK,SAAS,KAAM,CAAA,OAAA,EA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A,QACN,IAAM,EAAA;AAAA,UACJ,UAAA;AAAA,UACA;AAAA,YACE,WAAa,EAAA,cAAA;AAAA,YACb,UAAY,EAAA;AAAA;AACd;AACF,OAEF,GAAA,KAAA;AAAA;AACN,GACF;AACF","file":"index.native.mjs","sourcesContent":["/**\n *\n */\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst GILL_LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n};\n\ndeclare global {\n /**\n * Whether or not to enable debug mode. When enabled, default log level of `info`\n */\n var __GILL_DEBUG__: boolean | undefined;\n /**\n * Set the a desired level of logs to be output in the application\n *\n * - Default: `info`\n * - Options: `debug` | `info` | `warn` | `error`\n */\n var __GILL_DEBUG_LEVEL__: LogLevel | undefined;\n}\n\nconst getMinLogLevel = (): LogLevel =>\n (process.env.GILL_DEBUG_LEVEL as LogLevel) ||\n global.__GILL_DEBUG_LEVEL__ ||\n (typeof window !== \"undefined\" && (window as any).__GILL_DEBUG_LEVEL__) ||\n \"info\";\n\n/**\n * Check if the `gill` debug logger is enabled or not\n */\nexport const isDebugEnabled = (): boolean =>\n Boolean(\n process.env.GILL_DEBUG_LEVEL ||\n global.__GILL_DEBUG_LEVEL__ ||\n process.env.GILL_DEBUG === \"true\" ||\n process.env.GILL_DEBUG === \"1\" ||\n global.__GILL_DEBUG__ === true ||\n (typeof window !== \"undefined\" && (window as any).__GILL_DEBUG__ === true),\n );\n\n/**\n * Log debug messages based on the desired application's logging level.\n *\n * @param message - the message contents to be logged\n * @param level - default: `info` (see: {@link GILL_LOG_LEVELS})\n * @param prefix - default: `[GILL]`\n *\n * To enable gill's debug logger, set any of the following to `true`:\n * - `process.env.GILL_DEBUG`\n * - `global.__GILL_DEBUG__`\n * - `window.__GILL_DEBUG__`\n *\n * To set a desired level of logs to be output in the application, set the value of one of the following:\n * - `process.env.GILL_DEBUG_LEVEL`\n * - `global.__GILL_DEBUG_LEVEL__`\n * - `window.__GILL_DEBUG_LEVEL__`\n */\nexport function debug(message: unknown, level: LogLevel = \"info\", prefix: string = \"[GILL]\") {\n if (!isDebugEnabled()) return;\n\n if (GILL_LOG_LEVELS[level] < GILL_LOG_LEVELS[getMinLogLevel()]) return;\n\n const formattedMessage = typeof message === \"string\" ? message : JSON.stringify(message, null, 2);\n\n switch (level) {\n case \"debug\":\n console.log(prefix, formattedMessage);\n break;\n case \"info\":\n console.info(prefix, formattedMessage);\n break;\n case \"warn\":\n console.warn(prefix, formattedMessage);\n break;\n case \"error\":\n console.error(prefix, formattedMessage);\n break;\n }\n}\n","/** 1 billion lamports per SOL */\nexport const LAMPORTS_PER_SOL = 1_000_000_000;\n\n/**\n * Genesis hash for Solana network clusters\n */\nexport const GENESIS_HASH = {\n mainnet: \"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d\",\n devnet: \"EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG\",\n testnet: \"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY\",\n};\n","import {\n assertIsTransactionSigner,\n createNoopSigner,\n isTransactionSigner,\n type Address,\n type TransactionSigner,\n} from \"@solana/kit\";\nimport type { SolanaClusterMoniker } from \"../types\";\nimport { GENESIS_HASH } from \"./const\";\n\n/**\n * Determine the Solana moniker from its genesis hash\n *\n * If the hash is NOT known, returns `unknown`\n */\nexport function getMonikerFromGenesisHash(hash: string): SolanaClusterMoniker | \"unknown\" {\n switch (hash) {\n case GENESIS_HASH.mainnet:\n return \"mainnet\";\n case GENESIS_HASH.devnet:\n return \"devnet\";\n case GENESIS_HASH.testnet:\n return \"testnet\";\n default:\n return \"unknown\";\n }\n}\n\nexport function checkedAddress<TAddress extends string = string>(\n input: Address<TAddress> | TransactionSigner<TAddress>,\n): Address<TAddress> {\n return typeof input == \"string\" ? input : input.address;\n}\n\nexport function checkedTransactionSigner<TAddress extends string = string>(\n input: Address<TAddress> | TransactionSigner<TAddress>,\n): TransactionSigner<TAddress> {\n if (typeof input === \"string\" || \"address\" in input == false) input = createNoopSigner(input);\n if (!isTransactionSigner(input)) throw new Error(\"A signer or address is required\");\n assertIsTransactionSigner(input);\n return input;\n}\n\n/**\n * Convert a lamport number to the human readable string of a SOL value\n */\nexport function lamportsToSol(lamports: bigint | number): string {\n // @ts-expect-error This format is valid\n return new Intl.NumberFormat(\"en-US\", { maximumFractionDigits: 9 }).format(`${lamports}E-9`);\n}\n","import type { DevnetUrl, MainnetUrl, TestnetUrl } from \"@solana/kit\";\nimport type { LocalnetUrl, ModifiedClusterUrl, SolanaClusterMoniker } from \"../types/rpc\";\n\nexport function localnet(putativeString: string): LocalnetUrl {\n return putativeString as LocalnetUrl;\n}\n\n/**\n * Get a public Solana RPC endpoint for a cluster based on its moniker\n *\n * Note: These RPC URLs are rate limited and not suitable for production applications.\n */\nexport function getPublicSolanaRpcUrl(\n cluster: SolanaClusterMoniker | \"mainnet-beta\" | \"localhost\",\n): ModifiedClusterUrl {\n switch (cluster) {\n case \"devnet\":\n return \"https://api.devnet.solana.com\" as DevnetUrl;\n case \"testnet\":\n return \"https://api.testnet.solana.com\" as TestnetUrl;\n case \"mainnet-beta\":\n case \"mainnet\":\n return \"https://api.mainnet-beta.solana.com\" as MainnetUrl;\n case \"localnet\":\n case \"localhost\":\n return \"http://127.0.0.1:8899\" as LocalnetUrl;\n default:\n throw new Error(\"Invalid cluster moniker\");\n }\n}\n","import type { GetExplorerLinkArgs } from \"../types\";\n\n/**\n * Craft a Solana Explorer link on any cluster\n */\nexport function getExplorerLink(props: GetExplorerLinkArgs = {}): string {\n let url = new URL(\"https://explorer.solana.com\");\n\n // default to mainnet / mainnet-beta\n if (!props.cluster || props.cluster == \"mainnet\") props.cluster = \"mainnet-beta\";\n\n if (\"address\" in props) {\n url.pathname = `/address/${props.address}`;\n } else if (\"transaction\" in props) {\n url.pathname = `/tx/${props.transaction}`;\n } else if (\"block\" in props) {\n url.pathname = `/block/${props.block}`;\n }\n\n if (props.cluster !== \"mainnet-beta\") {\n if (props.cluster === \"localnet\" || props.cluster === \"localhost\") {\n // localnet technically isn't a cluster, so requires special handling\n url.searchParams.set(\"cluster\", \"custom\");\n url.searchParams.set(\"customUrl\", \"http://localhost:8899\");\n } else {\n url.searchParams.set(\"cluster\", props.cluster);\n }\n }\n\n return url.toString();\n}\n","import type { Simplify } from \"../types\";\n\nimport { getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction } from \"@solana-program/compute-budget\";\nimport type {\n Address,\n ITransactionMessageWithFeePayer,\n ITransactionMessageWithFeePayerSigner,\n TransactionMessageWithBlockhashLifetime,\n TransactionSigner,\n TransactionVersion,\n} from \"@solana/kit\";\nimport {\n appendTransactionMessageInstruction,\n appendTransactionMessageInstructions,\n createTransactionMessage,\n isTransactionSigner,\n pipe,\n setTransactionMessageFeePayer,\n setTransactionMessageFeePayerSigner,\n setTransactionMessageLifetimeUsingBlockhash,\n} from \"@solana/kit\";\n\nimport type { CreateTransactionInput, FullTransaction } from \"../types/transactions\";\n\n/**\n * Simple interface for creating a Solana transaction\n */\nexport function createTransaction<TVersion extends TransactionVersion, TFeePayer extends TransactionSigner>(\n props: CreateTransactionInput<TVersion, TFeePayer>,\n): FullTransaction<TVersion, ITransactionMessageWithFeePayerSigner>;\nexport function createTransaction<TVersion extends TransactionVersion, TFeePayer extends Address>(\n props: CreateTransactionInput<TVersion, TFeePayer>,\n): FullTransaction<TVersion, ITransactionMessageWithFeePayer>;\nexport function createTransaction<\n TVersion extends TransactionVersion,\n TFeePayer extends TransactionSigner,\n TLifetimeConstraint extends TransactionMessageWithBlockhashLifetime[\"lifetimeConstraint\"],\n>(\n props: CreateTransactionInput<TVersion, TFeePayer, TLifetimeConstraint>,\n): Simplify<FullTransaction<TVersion, ITransactionMessageWithFeePayerSigner, TransactionMessageWithBlockhashLifetime>>;\nexport function createTransaction<\n TVersion extends TransactionVersion,\n TFeePayer extends Address,\n TLifetimeConstraint extends TransactionMessageWithBlockhashLifetime[\"lifetimeConstraint\"],\n>(\n props: CreateTransactionInput<TVersion, TFeePayer, TLifetimeConstraint>,\n): Simplify<FullTransaction<TVersion, ITransactionMessageWithFeePayer, TransactionMessageWithBlockhashLifetime>>;\nexport function createTransaction<\n TVersion extends TransactionVersion,\n TFeePayer extends Address | TransactionSigner,\n TLifetimeConstraint extends TransactionMessageWithBlockhashLifetime[\"lifetimeConstraint\"],\n>(\n props: CreateTransactionInput<TVersion, TFeePayer, TLifetimeConstraint>,\n): Simplify<FullTransaction<TVersion, ITransactionMessageWithFeePayer, TransactionMessageWithBlockhashLifetime>>;\nexport function createTransaction<TVersion extends TransactionVersion, TFeePayer extends Address | TransactionSigner>({\n version,\n feePayer,\n instructions,\n latestBlockhash,\n computeUnitLimit,\n computeUnitPrice,\n}: CreateTransactionInput<TVersion, TFeePayer>): FullTransaction<\n TVersion,\n ITransactionMessageWithFeePayer | ITransactionMessageWithFeePayerSigner\n> {\n return pipe(\n createTransactionMessage({ version }),\n (tx) => {\n const withLifetime = latestBlockhash ? setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx) : tx;\n if (typeof feePayer !== \"string\" && \"address\" in feePayer && isTransactionSigner(feePayer)) {\n return setTransactionMessageFeePayerSigner(feePayer, withLifetime);\n } else return setTransactionMessageFeePayer(feePayer, withLifetime);\n },\n (tx) => {\n const withComputeLimit = typeof computeUnitLimit !== \"undefined\" \n ? appendTransactionMessageInstruction(\n getSetComputeUnitLimitInstruction({ units: Number(computeUnitLimit) }),\n tx,\n )\n : tx;\n\n const withComputePrice = typeof computeUnitPrice !== \"undefined\"\n ? appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({ microLamports: Number(computeUnitPrice) }),\n withComputeLimit,\n )\n : withComputeLimit;\n\n return appendTransactionMessageInstructions(instructions, withComputePrice);\n },\n );\n}\n","import type {\n CompilableTransactionMessage,\n FullySignedTransaction,\n GetEpochInfoApi,\n GetSignatureStatusesApi,\n Rpc,\n RpcSubscriptions,\n SendTransactionApi,\n Signature,\n SignatureNotificationsApi,\n SlotNotificationsApi,\n TransactionWithBlockhashLifetime,\n} from \"@solana/kit\";\nimport {\n Commitment,\n getBase64EncodedWireTransaction,\n getSignatureFromTransaction,\n sendAndConfirmTransactionFactory,\n signTransactionMessageWithSigners,\n} from \"@solana/kit\";\nimport { type waitForRecentTransactionConfirmation } from \"@solana/transaction-confirmation\";\nimport { debug } from \"./debug\";\nimport { getExplorerLink } from \"./explorer\";\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 & TransactionWithBlockhashLifetime;\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\nexport type SendAndConfirmTransactionWithSignersFunction = (\n transaction: (FullySignedTransaction & TransactionWithBlockhashLifetime) | CompilableTransactionMessage,\n config?: Omit<\n SendAndConfirmTransactionWithBlockhashLifetimeConfig,\n \"confirmRecentTransaction\" | \"rpc\" | \"transaction\"\n >,\n) => Promise<Signature>;\n\ntype SendAndConfirmTransactionWithSignersFactoryConfig<TCluster> = {\n rpc: Rpc<GetEpochInfoApi & GetSignatureStatusesApi & SendTransactionApi> & {\n \"~cluster\"?: TCluster;\n };\n rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi> & {\n \"~cluster\"?: TCluster;\n };\n};\n\nexport function sendAndConfirmTransactionWithSignersFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithSignersFactoryConfig<\"devnet\">): SendAndConfirmTransactionWithSignersFunction;\nexport function sendAndConfirmTransactionWithSignersFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithSignersFactoryConfig<\"testnet\">): SendAndConfirmTransactionWithSignersFunction;\nexport function sendAndConfirmTransactionWithSignersFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithSignersFactoryConfig<\"mainnet\">): SendAndConfirmTransactionWithSignersFunction;\nexport function sendAndConfirmTransactionWithSignersFactory({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithSignersFactoryConfig<\"localnet\">): SendAndConfirmTransactionWithSignersFunction;\nexport function sendAndConfirmTransactionWithSignersFactory<\n TCluster extends \"devnet\" | \"mainnet\" | \"testnet\" | \"localnet\" | undefined = undefined,\n>({\n rpc,\n rpcSubscriptions,\n}: SendAndConfirmTransactionWithSignersFactoryConfig<TCluster>): SendAndConfirmTransactionWithSignersFunction {\n // @ts-ignore - TODO(FIXME)\n const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });\n return async function sendAndConfirmTransactionWithSigners(transaction, config = { commitment: \"confirmed\" }) {\n if (\"messageBytes\" in transaction == false) {\n transaction = (await signTransactionMessageWithSigners(transaction)) as Readonly<\n FullySignedTransaction & TransactionWithBlockhashLifetime\n >;\n }\n debug(`Sending transaction: ${getExplorerLink({ transaction: getSignatureFromTransaction(transaction) })}`);\n debug(`Transaction as base64: ${getBase64EncodedWireTransaction(transaction)}`, \"debug\");\n await sendAndConfirmTransaction(transaction, config);\n return getSignatureFromTransaction(transaction);\n };\n}\n","import { COMPUTE_BUDGET_PROGRAM_ADDRESS, ComputeBudgetInstruction } from \"@solana-program/compute-budget\";\nimport type { IInstruction, IInstructionWithData, TransactionMessage } from \"@solana/kit\";\nimport { isInstructionForProgram, isInstructionWithData } from \"@solana/kit\";\n\n/**\n * Check if a given instruction is a `SetComputeUnitLimit` instruction\n */\nexport function 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] === ComputeBudgetInstruction.SetComputeUnitLimit\n );\n}\n\n/**\n * Check if a given transaction contains a `SetComputeUnitLimit` instruction\n */\nexport function hasSetComputeLimitInstruction(tx: TransactionMessage): boolean {\n return tx.instructions.filter(isSetComputeLimitInstruction).length == 1;\n}\n\n/**\n * Check if a given instruction is a `SetComputeUnitPrice` instruction\n */\nexport function isSetComputeUnitPriceInstruction(\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] === ComputeBudgetInstruction.SetComputeUnitPrice\n );\n}\n\n/**\n * Check if a given transaction contains a `SetComputeUnitPrice` instruction\n */\nexport function hasSetComputeUnitPriceInstruction(tx: TransactionMessage): boolean {\n return tx.instructions.filter(isSetComputeUnitPriceInstruction).length == 1;\n}\n","import type { Base64EncodedWireTransaction, CompilableTransactionMessage, Transaction } from \"@solana/kit\";\nimport {\n compileTransaction,\n getBase64EncodedWireTransaction,\n partiallySignTransactionMessageWithSigners,\n pipe,\n} from \"@solana/kit\";\n\n/**\n * Compile a transaction to a base64 string\n *\n * Note: This will NOT attempt to sign the transaction,\n * so it will be missing `signatures` from any of the attached Signers\n *\n * Use {@link transactionToBase64WithSignatures} sign and base64 encode\n */\nexport function transactionToBase64(tx: CompilableTransactionMessage | Transaction): Base64EncodedWireTransaction {\n if (\"messageBytes\" in tx) return pipe(tx, getBase64EncodedWireTransaction);\n else return pipe(tx, compileTransaction, getBase64EncodedWireTransaction);\n}\n\n/**\n * Compile a transaction to a base64 string and sign it with all attached Signers\n *\n * See also {@link partiallySignTransactionMessageWithSigners}\n */\nexport async function transactionToBase64WithSigners(\n tx: CompilableTransactionMessage | Transaction,\n): Promise<Base64EncodedWireTransaction> {\n if (\"messageBytes\" in tx) return transactionToBase64(tx);\n else return transactionToBase64(await partiallySignTransactionMessageWithSigners(tx));\n}\n","import { COMPUTE_BUDGET_PROGRAM_ADDRESS, getSetComputeUnitLimitInstruction } from \"@solana-program/compute-budget\";\nimport type {\n CompilableTransactionMessage,\n GetLatestBlockhashApi,\n ITransactionMessageWithFeePayer,\n Rpc,\n SimulateTransactionApi,\n TransactionMessage,\n TransactionMessageWithBlockhashLifetime,\n} from \"@solana/kit\";\nimport {\n appendTransactionMessageInstruction,\n assertIsTransactionMessageWithBlockhashLifetime,\n getComputeUnitEstimateForTransactionMessageFactory,\n setTransactionMessageLifetimeUsingBlockhash,\n} from \"@solana/kit\";\nimport { isSetComputeLimitInstruction } from \"../programs/compute-budget\";\nimport { transactionToBase64WithSigners } from \"./base64-to-transaction\";\nimport { debug, isDebugEnabled } from \"./debug\";\n\ntype PrepareCompilableTransactionMessage =\n | CompilableTransactionMessage\n | (ITransactionMessageWithFeePayer & TransactionMessage);\n\nexport type PrepareTransactionConfig<TMessage extends PrepareCompilableTransactionMessage> = {\n /**\n * Transaction to prepare for sending to the blockchain\n */\n transaction: TMessage;\n /**\n * RPC client capable of simulating transactions and getting the latest blockhash\n **/\n rpc: Rpc<GetLatestBlockhashApi & SimulateTransactionApi>;\n /**\n * Multiplier applied to the simulated compute unit value obtained from simulation\n *\n * Default: `1.1`\n **/\n computeUnitLimitMultiplier?: number;\n /**\n * Whether or not you wish to force reset the compute unit limit value (if one is already set)\n * using the simulation response and `computeUnitLimitMultiplier`\n **/\n computeUnitLimitReset?: boolean;\n /**\n * Whether or not you wish to force reset the latest blockhash (if one is already set)\n *\n * Default: `true`\n **/\n blockhashReset?: boolean;\n};\n\n/**\n * Prepare a Transaction to be signed and sent to the network. Including:\n * - setting a compute unit limit (if not already set)\n * - fetching the latest blockhash (if not already set)\n * - (optional) simulating and resetting the compute unit limit\n * - (optional) resetting latest blockhash to the most recent\n */\nexport async function prepareTransaction<TMessage extends PrepareCompilableTransactionMessage>(\n config: PrepareTransactionConfig<TMessage>,\n): Promise<TMessage & TransactionMessageWithBlockhashLifetime> {\n // set the config defaults\n if (!config.computeUnitLimitMultiplier) config.computeUnitLimitMultiplier = 1.1;\n if (config.blockhashReset !== false) config.blockhashReset = true;\n\n const computeBudgetIndex = {\n limit: -1,\n price: -1,\n };\n\n config.transaction.instructions.map((ix, index) => {\n if (ix.programAddress != COMPUTE_BUDGET_PROGRAM_ADDRESS) return;\n\n if (isSetComputeLimitInstruction(ix)) {\n computeBudgetIndex.limit = index;\n }\n // else if (isSetComputeUnitPriceInstruction(ix)) {\n // computeBudgetIndex.price = index;\n // }\n });\n\n // set a compute unit limit instruction\n if (computeBudgetIndex.limit < 0 || config.computeUnitLimitReset) {\n const units = await getComputeUnitEstimateForTransactionMessageFactory({ rpc: config.rpc })(config.transaction);\n debug(`Obtained compute units from simulation: ${units}`, \"debug\");\n const ix = getSetComputeUnitLimitInstruction({\n units: units * config.computeUnitLimitMultiplier,\n });\n\n if (computeBudgetIndex.limit < 0) {\n config.transaction = appendTransactionMessageInstruction(ix, config.transaction) as unknown as TMessage;\n } else if (config.computeUnitLimitReset) {\n const nextInstructions = [...config.transaction.instructions];\n nextInstructions.splice(computeBudgetIndex.limit, 1, ix);\n config.transaction = Object.freeze({\n ...config.transaction,\n instructions: nextInstructions,\n } as TMessage);\n }\n }\n\n // update the latest blockhash\n if (config.blockhashReset || \"lifetimeConstraint\" in config.transaction == false) {\n const { value: latestBlockhash } = await config.rpc.getLatestBlockhash().send();\n if (\"lifetimeConstraint\" in config.transaction == false) {\n debug(\"Transaction missing latest blockhash, fetching one.\", \"debug\");\n config.transaction = setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, config.transaction) as unknown as TMessage;\n } else if (config.blockhashReset) {\n debug(\"Auto resetting the latest blockhash.\", \"debug\");\n config.transaction = Object.freeze({\n ...config.transaction,\n lifetimeConstraint: latestBlockhash,\n } as TransactionMessageWithBlockhashLifetime & typeof config.transaction);\n }\n }\n\n assertIsTransactionMessageWithBlockhashLifetime(config.transaction);\n\n // skip the async call if debugging is off\n if (isDebugEnabled()) {\n debug(`Transaction as base64: ${await transactionToBase64WithSigners(config.transaction)}`, \"debug\");\n }\n\n return config.transaction;\n}\n","import type { CompilableTransactionMessage, Rpc, SimulateTransactionApi, Transaction } from \"@solana/kit\";\nimport { getBase64EncodedWireTransaction, partiallySignTransactionMessageWithSigners } from \"@solana/kit\";\nimport type { Simplify } from \"./../types/index\";\n\nexport type SimulateTransactionFunction = (\n transaction: Transaction | CompilableTransactionMessage,\n config?: Simplify<Omit<Parameters<SimulateTransactionApi[\"simulateTransaction\"]>[1], \"encoding\" | \"sigVerify\">>,\n) => Promise<ReturnType<SimulateTransactionApi[\"simulateTransaction\"]>>;\n\ntype SimulateTransactionFactoryConfig<TCluster> = {\n rpc: Rpc<SimulateTransactionApi> & {\n \"~cluster\"?: TCluster;\n };\n};\n\nexport function simulateTransactionFactory({\n rpc,\n}: SimulateTransactionFactoryConfig<\"devnet\">): SimulateTransactionFunction;\nexport function simulateTransactionFactory({\n rpc,\n}: SimulateTransactionFactoryConfig<\"testnet\">): SimulateTransactionFunction;\nexport function simulateTransactionFactory({\n rpc,\n}: SimulateTransactionFactoryConfig<\"mainnet\">): SimulateTransactionFunction;\nexport function simulateTransactionFactory({\n rpc,\n}: SimulateTransactionFactoryConfig<\"localnet\">): SimulateTransactionFunction;\nexport function simulateTransactionFactory<\n TCluster extends \"devnet\" | \"mainnet\" | \"testnet\" | \"localnet\" | void = void,\n>({ rpc }: SimulateTransactionFactoryConfig<TCluster>): SimulateTransactionFunction {\n return async function simulateTransaction(transaction, config) {\n if (\"messageBytes\" in transaction == false) {\n transaction = await partiallySignTransactionMessageWithSigners(transaction);\n }\n\n return rpc\n .simulateTransaction(getBase64EncodedWireTransaction(transaction), {\n replaceRecentBlockhash: true,\n // innerInstructions: true,\n ...config,\n sigVerify: false,\n encoding: \"base64\",\n })\n .send();\n };\n}\n","import type { DevnetUrl, MainnetUrl, TestnetUrl } from \"@solana/kit\";\nimport { createSolanaRpc, createSolanaRpcSubscriptions } from \"@solana/kit\";\n\nimport type { CreateSolanaClientArgs, LocalnetUrl, ModifiedClusterUrl, SolanaClient } from \"../types/rpc\";\nimport { getPublicSolanaRpcUrl } from \"./rpc\";\nimport { sendAndConfirmTransactionWithSignersFactory } from \"./send-and-confirm-transaction-with-signers\";\nimport { simulateTransactionFactory } from \"./simulate-transaction\";\n\n/**\n * Create a Solana `rpc` and `rpcSubscriptions` client\n */\nexport function createSolanaClient(\n props: Omit<CreateSolanaClientArgs<MainnetUrl | \"mainnet\">, \"urlOrMoniker\"> & {\n urlOrMoniker: \"mainnet\";\n },\n): SolanaClient<MainnetUrl>;\nexport function createSolanaClient(\n props: Omit<CreateSolanaClientArgs<DevnetUrl | \"devnet\">, \"urlOrMoniker\"> & {\n urlOrMoniker: \"devnet\";\n },\n): SolanaClient<DevnetUrl>;\nexport function createSolanaClient(\n props: Omit<CreateSolanaClientArgs<TestnetUrl | \"testnet\">, \"urlOrMoniker\"> & {\n urlOrMoniker: \"testnet\";\n },\n): SolanaClient<TestnetUrl>;\nexport function createSolanaClient(\n props: Omit<CreateSolanaClientArgs<LocalnetUrl | \"localnet\">, \"urlOrMoniker\"> & {\n urlOrMoniker: \"localnet\";\n },\n): SolanaClient<LocalnetUrl>;\nexport function createSolanaClient<TClusterUrl extends ModifiedClusterUrl>(\n props: CreateSolanaClientArgs<TClusterUrl>,\n): SolanaClient<TClusterUrl>;\nexport function createSolanaClient<TCluster extends ModifiedClusterUrl>({\n urlOrMoniker,\n rpcConfig,\n rpcSubscriptionsConfig,\n}: CreateSolanaClientArgs<TCluster>) {\n if (!urlOrMoniker) throw new Error(\"Cluster url or moniker is required\");\n if (urlOrMoniker instanceof URL == false) {\n try {\n urlOrMoniker = new URL(urlOrMoniker.toString());\n } catch (err) {\n try {\n urlOrMoniker = new URL(getPublicSolanaRpcUrl(urlOrMoniker.toString() as any));\n } catch (err) {\n throw new Error(\"Invalid URL or cluster moniker\");\n }\n }\n }\n\n if (!urlOrMoniker.protocol.match(/^https?/i)) {\n throw new Error(\"Unsupported protocol. Only HTTP and HTTPS are supported\");\n }\n\n if (rpcConfig?.port) {\n urlOrMoniker.port = rpcConfig.port.toString();\n }\n\n const rpc = createSolanaRpc<TCluster>(urlOrMoniker.toString() as TCluster, rpcConfig);\n\n urlOrMoniker.protocol = urlOrMoniker.protocol.replace('http', 'ws');\n\n if (rpcSubscriptionsConfig?.port) {\n urlOrMoniker.port = rpcSubscriptionsConfig.port.toString();\n } else if (urlOrMoniker.hostname == \"localhost\" || urlOrMoniker.hostname.startsWith(\"127\")) {\n urlOrMoniker.port = \"8900\";\n }\n\n const rpcSubscriptions = createSolanaRpcSubscriptions<TCluster>(\n urlOrMoniker.toString() as TCluster,\n rpcSubscriptionsConfig,\n );\n\n return {\n rpc,\n rpcSubscriptions,\n sendAndConfirmTransaction: sendAndConfirmTransactionWithSignersFactory({\n // @ts-ignore - TODO(FIXME:nick)\n rpc,\n // @ts-ignore - TODO(FIXME:nick)\n rpcSubscriptions,\n }),\n // @ts-ignore\n simulateTransaction: simulateTransactionFactory({ rpc }),\n };\n}\n","/**\n * Calculate the total rent needed for to create an account, with or without extra data stored in it\n */\nexport function getMinimumBalanceForRentExemption(space: bigint | number = 0) {\n /**\n * Default values for Rent calculations\n *\n * Values taken from: https://github.com/anza-xyz/solana-sdk/blob/c07f692e41d757057c8700211a9300cdcd6d33b1/rent/src/lib.rs#L93-L97\n * \n */\n const RENT = {\n /**\n * Account storage overhead for calculation of base rent. (aka the number of bytes required to store an account with no data.\n */\n ACCOUNT_STORAGE_OVERHEAD: 128n,\n /**\n * Amount of time (in years) a balance must include rent for the account to\n * be rent exempt.\n */\n DEFAULT_EXEMPTION_THRESHOLD: BigInt(Math.floor(2.0 * 1000)) / 1000n,\n /**\n * Default rental rate in lamports/byte-year. This calculation is based on:\n * - 10^9 lamports per SOL\n * - $1 per SOL\n * - $0.01 per megabyte day\n * - $3.65 per megabyte year\n */\n DEFAULT_LAMPORTS_PER_BYTE_YEAR: BigInt(\n Math.floor(((1_000_000_000 / 100) * 365) / (1024 * 1024)),\n ),\n };\n\n return (\n ((RENT.ACCOUNT_STORAGE_OVERHEAD + BigInt(space)) *\n RENT.DEFAULT_LAMPORTS_PER_BYTE_YEAR *\n RENT.DEFAULT_EXEMPTION_THRESHOLD) /\n 1n\n );\n}\n","import { assertKeyExporterIsAvailable, assertKeyGenerationIsAvailable } from \"@solana/assertions\";\nimport type { KeyPairSigner, createKeyPairFromBytes, createKeyPairSignerFromBytes } from \"@solana/kit\";\nimport { createSignerFromKeyPair } from \"@solana/kit\";\n\nexport function assertKeyPairIsExtractable(keyPair: CryptoKeyPair): asserts keyPair is ExtractableCryptoKeyPair {\n assertKeyExporterIsAvailable();\n\n if (!keyPair.privateKey) {\n throw new Error(\"Keypair is missing private key\");\n }\n\n if (!keyPair.publicKey) {\n throw new Error(\"Keypair is missing public key\");\n }\n\n if (!keyPair.privateKey.extractable) {\n throw new Error(\"Private key is not extractable\");\n }\n}\n\ntype Extractable = { \"~extractable\": true };\n\ntype ExtractableCryptoKeyPair = CryptoKeyPair & Extractable;\ntype ExtractableKeyPairSigner = KeyPairSigner & Extractable;\n\n/**\n * Generates an extractable Ed25519 `CryptoKeyPair` capable of signing messages and transactions\n * */\nexport async function generateExtractableKeyPair(): Promise<ExtractableCryptoKeyPair> {\n await assertKeyGenerationIsAvailable();\n return crypto.subtle.generateKey(\n /* algorithm */ \"Ed25519\", // Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20\n /* extractable */ true,\n /* allowed uses */ [\"sign\", \"verify\"],\n ) as Promise<ExtractableCryptoKeyPair>;\n}\n\n/**\n * Generates an extractable signer capable of signing messages and transactions using a Crypto KeyPair.\n * */\nexport async function generateExtractableKeyPairSigner(): Promise<ExtractableKeyPairSigner> {\n return createSignerFromKeyPair(await generateExtractableKeyPair()) as Promise<ExtractableKeyPairSigner>;\n}\n\n/**\n * Extracts the raw key material from an extractable Ed25519 CryptoKeyPair.\n *\n * @remarks\n * - Requires a keypair generated with extractable=true. See {@link generateExtractableKeyPair}.\n * - The extracted bytes can be used to reconstruct the `CryptoKeyPair` with {@link createKeyPairFromBytes}.\n *\n * @param keypair An extractable Ed25519 `CryptoKeyPair`\n * @returns Raw key bytes as `Uint8Array`\n */\nexport async function extractBytesFromKeyPair(keypair: ExtractableCryptoKeyPair | CryptoKeyPair): Promise<Uint8Array> {\n assertKeyPairIsExtractable(keypair);\n\n const [publicKeyBytes, privateKeyJwk] = await Promise.all([\n crypto.subtle.exportKey(\"raw\", keypair.publicKey),\n crypto.subtle.exportKey(\"jwk\", keypair.privateKey),\n ]);\n\n if (!privateKeyJwk.d) throw new Error(\"Failed to get private key bytes\");\n\n return new Uint8Array([...Buffer.from(privateKeyJwk.d, \"base64\"), ...new Uint8Array(publicKeyBytes)]);\n}\n\n/**\n * Extracts the raw key material from an extractable Ed25519 KeyPairSigner.\n *\n * @remarks\n * - Requires a keypair generated with extractable=true. See {@link generateExtractableKeyPairSigner}.\n * - The extracted bytes can be used to reconstruct the `CryptoKeyPair` with {@link createKeyPairSignerFromBytes}.\n *\n * @param keypairSigner An extractable Ed25519 `KeyPairSigner`\n * @returns Raw key bytes as `Uint8Array`\n */\nexport async function extractBytesFromKeyPairSigner(\n keypairSigner: ExtractableKeyPairSigner | KeyPairSigner,\n): Promise<Uint8Array> {\n return extractBytesFromKeyPair(keypairSigner.keyPair);\n}\n","import { createKeyPairFromBytes, createSignerFromKeyPair, getBase58Encoder, type KeyPairSigner } from \"@solana/kit\";\n\n/**\n * Create a `CryptoKeyPair` from as base58 encoded secret key\n */\nexport async function createKeypairFromBase58(punitiveSecretKey: string): Promise<CryptoKeyPair> {\n return createKeyPairFromBytes(getBase58Encoder().encode(punitiveSecretKey));\n}\n\n/**\n * Create a `KeyPairSigner` from as base58 encoded secret key\n */\nexport async function createKeypairSignerFromBase58(punitiveSecretKey: string): Promise<KeyPairSigner> {\n return createSignerFromKeyPair(await createKeypairFromBase58(punitiveSecretKey));\n}\n","import { getBase64Encoder, getTransactionDecoder, type Transaction } from \"@solana/kit\";\nimport type { transactionToBase64, transactionToBase64WithSigners } from \"./base64-to-transaction\";\n\n/**\n * Convert a base64 encoded transaction string into compiled transaction\n *\n * Use {@link transactionToBase64} or {@link transactionToBase64WithSigners} to create the base64 encoded transaction string\n */\nexport function transactionFromBase64(base64EncodedTransaction: string): Transaction {\n return getTransactionDecoder().decode(getBase64Encoder().encode(base64EncodedTransaction));\n}\n","import type { Simplify } from \"../types/index\";\n\nimport type { Address, GetSignaturesForAddressApi, Rpc } from \"@solana/kit\";\nimport { isSolanaError, SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN, SolanaError } from \"@solana/kit\";\n\ntype GetOldestSignatureForAddressRpc<TCluster> = Rpc<GetSignaturesForAddressApi> & {\n \"~cluster\"?: TCluster;\n};\n\ntype GetOldestSignatureForAddressConfig = Simplify<\n Parameters<GetSignaturesForAddressApi[\"getSignaturesForAddress\"]>[1]\n> & { abortSignal?: AbortSignal };\n\n/**\n * Get the oldest signature for the provided `address`\n */\nexport async function getOldestSignatureForAddress<TCluster>(\n rpc: GetOldestSignatureForAddressRpc<TCluster>,\n address: Address,\n config?: GetOldestSignatureForAddressConfig,\n): Promise<ReturnType<GetSignaturesForAddressApi[\"getSignaturesForAddress\"]>[0]> {\n const signatures = await rpc.getSignaturesForAddress(address, config).send({ abortSignal: config?.abortSignal });\n\n if (!signatures.length) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN, {\n errorName: \"OldestSignatureNotFound\",\n });\n }\n\n const oldest = signatures[signatures.length - 1];\n if (signatures.length < (config?.limit || 1000)) return oldest;\n\n try {\n // if signatures are found to the limit, recurse for find the oldest\n return await getOldestSignatureForAddress(rpc, address, { ...config, before: oldest.signature });\n } catch (err) {\n // if signatures found were exactly at the limit, there will be no more to find, so we return the oldest\n if (isSolanaError(err, SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN)) return oldest;\n throw err;\n }\n}\n","import type { Address, BaseTransactionMessage } from \"@solana/kit\";\nimport { Acco