{"version":3,"file":"types.cjs","sources":["../../../../src/transactions/types.ts"],"sourcesContent":["import {\n  TransactionVersion,\n  Address,\n  TransactionSigner,\n  Instruction,\n  Blockhash,\n  Commitment,\n  BaseTransactionMessage,\n  TransactionMessageWithFeePayer,\n  Rpc,\n  SolanaRpcApi,\n  signTransactionMessageWithSigners,\n  RpcSubscriptions,\n  SolanaRpcSubscriptionsApi,\n  Signature,\n  Base64EncodedWireTransaction,\n} from \"@solana/kit\";\n\nimport { GetPriorityFeeEstimateFn } from \"../rpc/methods/getPriorityFeeEstimate\";\nimport { GetComputeUnitsFn } from \"./getComputeUnits\";\n\n/** Options for the compute-unit simulation step. */\nexport interface GetComputeUnitsOpts {\n  /** Minimum CU floor for very small transactions. Defaults to 1,000. */\n  min?: number;\n  /** Buffer percentage added on top of simulated CU. Defaults to 0.1 (10%). */\n  bufferPct?: number;\n}\n\n/** A fully signed transaction ready to be sent over the wire. */\nexport type SignedTx = Awaited<\n  ReturnType<typeof signTransactionMessageWithSigners>\n>;\n\n/** A blockhash and its expiry height, used as a transaction lifetime. */\nexport type BlockhashLifetime = Readonly<{\n  blockhash: Blockhash;\n  lastValidBlockHeight: bigint;\n}>;\n\n/** Input for building a raw transaction message. */\nexport type CreateTxMessageInput = Readonly<{\n  version: TransactionVersion;\n  feePayer: Address | TransactionSigner<string>;\n  lifetime?: BlockhashLifetime;\n  instructions: readonly Instruction<string, readonly any[]>[];\n}>;\n\n/**\n * Input for `createSmartTransaction`. The SDK automatically simulates\n * compute units, fetches priority fees, and prepends compute-budget\n * instructions before signing.\n */\nexport type CreateSmartTxInput = Readonly<{\n  /** All required signers. First signer is the default fee-payer. */\n  signers: readonly TransactionSigner<string>[];\n  /** Program instructions (no compute-budget ixs needed — we'll add them). */\n  instructions: readonly Instruction<string, readonly any[]>[];\n  /** Optional fee-payer override (Address or TransactionSigner). */\n  feePayer?: Address | TransactionSigner<string>;\n  /** Tx version. Default: 0. */\n  version?: TransactionVersion;\n  /** Optional cap (microlamports per CU) applied to Helius' recommendation. */\n  priorityFeeCap?: number;\n  /** CU floor & simulation buffer. Defaults: 1_000 / 10%. */\n  minUnits?: number;\n  bufferPct?: number;\n  /** Commitment for fetching the blockhash. Default: \"confirmed\". */\n  commitment?: Commitment;\n}>;\n\n/** Result from `createSmartTransaction` — a signed transaction with metadata. */\nexport type CreateSmartTxResult = Readonly<{\n  /** Final signed transaction (ready to send). */\n  signed: SignedTx;\n  /** Base-64 wire transaction of the final signed tx. */\n  base64: string;\n  /** Final compute-unit limit set by the SDK. */\n  units: number;\n  /** Final microLamports-per-CU set by the SDK. */\n  priorityFee: number;\n  /** Final blockhash + lastValidBlockHeight used for the message. */\n  lifetime: BlockhashLifetime;\n  /** Final message (after compute-budget ixs are prepended). */\n  message: BaseTransactionMessage & TransactionMessageWithFeePayer;\n}>;\n\n/** Internal dependencies for `createSmartTransaction`. */\nexport type CreateSmartTxDeps = Readonly<{\n  raw: Rpc<SolanaRpcApi>;\n  getComputeUnits: GetComputeUnitsFn;\n  getPriorityFeeEstimate: GetPriorityFeeEstimateFn;\n}>;\n\n/** Build, simulate, and sign a smart transaction. */\nexport type CreateSmartTransactionFn = (\n  args: CreateSmartTxInput\n) => Promise<CreateSmartTxResult>;\n\n/**\n * Input for `sendSmartTransaction`. Extends `CreateSmartTxInput` with\n * send-and-confirm options.\n */\nexport type SendSmartTransactionInput = CreateSmartTxInput & {\n  /** Confirmation commitment for the send+confirm step. Defaults to `\"confirmed\"`. */\n  confirmCommitment?: Commitment; // \"processed\" | \"confirmed\" | \"finalized\"\n  /** Maximum number of automatic retry attempts. Should be `0n` for Sender. */\n  maxRetries?: bigint;\n  /** Bypasses preflight transaction validation for faster submission. Must be `true` for Sender. Defaults to `true`. */\n  skipPreflight?: boolean;\n};\n\n/** Build, sign, send, and confirm a smart transaction. Returns the signature. */\nexport type SendSmartTransactionFn = (\n  args: SendSmartTransactionInput\n) => Promise<string>;\n\n/** Internal dependencies for `sendSmartTransaction`. */\nexport type SendSmartTxDeps = Readonly<{\n  raw: Rpc<SolanaRpcApi>;\n  /** Optional but recommended — enables WS-backed confirmation */\n  rpcSubscriptions?: RpcSubscriptions<SolanaRpcSubscriptionsApi>;\n  /** We compose on top of the creator to reuse your smart build/sign logic */\n  createSmartTransaction: CreateSmartTransactionFn;\n}>;\n\n/** Options for `broadcastTransaction` — submit to the Helius Sender and poll for confirmation. */\nexport interface BroadcastOptions {\n  /** Number of slots to add to the current block height when computing the transaction expiry. */\n  lastValidBlockHeightOffset?: number;\n  /** Overall polling timeout in milliseconds. Defaults to 60,000. */\n  pollTimeoutMs?: number;\n  /** Polling cadence in milliseconds. Defaults to 2,000. */\n  pollIntervalMs?: number;\n  /**\n   * Bypasses Solana's preflight transaction validation for faster submission.\n   * **Must be `true` when submitting via Helius Sender.** Defaults to `true`.\n   */\n  skipPreflight?: boolean;\n  /** Maximum number of automatic retry attempts. Should be set to `0` for Sender. */\n  maxRetries?: bigint;\n  /** Confirmation commitment level to wait for. */\n  commitment?: \"processed\" | \"confirmed\" | \"finalized\";\n  /**\n   * When `true`, routes exclusively through SWQOS infrastructure.\n   * Has a lower minimum tip requirement than the default dual-routing mode.\n   */\n  swqosOnly?: boolean;\n}\n\n/** Options for polling transaction confirmation status. */\nexport interface PollTxOptions {\n  /** Commitment levels to poll for. */\n  confirmationStatuses?: (\"processed\" | \"confirmed\" | \"finalized\")[];\n  /** Timeout in milliseconds before giving up. */\n  timeout?: number;\n  /** Polling interval in milliseconds. */\n  interval?: number;\n  /** Stop polling if the block height exceeds this. */\n  lastValidBlockHeight?: bigint | number;\n}\n\n/** Poll for a transaction's confirmation status. Returns the signature once confirmed. */\nexport type PollTransactionConfirmationFn = (\n  signature: Signature,\n  options?: PollTxOptions\n) => Promise<Signature>;\n\n/** Broadcast a base-64 wire transaction and poll until confirmed. */\nexport type BroadcastTransactionFn = (\n  wireTx64: string | Base64EncodedWireTransaction,\n  options?: BroadcastOptions\n) => Promise<string>;\n\n/**\n * Regional Helius sender endpoints for SWQOS transaction submission.\n *\n * `Default` uses HTTPS and is suitable for frontend/browser applications.\n * All other regions use HTTP and are intended for server-side use.\n */\nexport const SENDER_ENDPOINTS = {\n  /** Global HTTPS endpoint — suitable for frontend applications. */\n  Default: \"https://sender.helius-rpc.com\",\n  /** Salt Lake City, USA. */\n  US_SLC: \"http://slc-sender.helius-rpc.com\",\n  /** Newark, USA. */\n  US_EAST: \"http://ewr-sender.helius-rpc.com\",\n  /** London, UK. */\n  EU_WEST: \"http://lon-sender.helius-rpc.com\",\n  /** Frankfurt, Germany. */\n  EU_CENTRAL: \"http://fra-sender.helius-rpc.com\",\n  /** Amsterdam, Netherlands. */\n  EU_NORTH: \"http://ams-sender.helius-rpc.com\",\n  /** Singapore. */\n  AP_SINGAPORE: \"http://sg-sender.helius-rpc.com\",\n  /** Tokyo, Japan. */\n  AP_TOKYO: \"http://tyo-sender.helius-rpc.com\",\n} as const;\n\n/** A region key for the Helius sender infrastructure. */\nexport type SenderRegion = keyof typeof SENDER_ENDPOINTS;\n\n/** Build the `/fast` endpoint URL for a sender region. */\nexport const senderFastUrl = (region: SenderRegion) =>\n  `${SENDER_ENDPOINTS[region]}/fast`;\n\n/** Build the `/ping` endpoint URL for a sender region. GET this URL to keep the connection warm. */\nexport const senderPingUrl = (region: SenderRegion) =>\n  `${SENDER_ENDPOINTS[region]}/ping`;\n\n/** Input for `createSmartTransactionWithTip` — adds a Jito/sender tip instruction. */\nexport interface CreateSmartTxWithTipInput extends CreateSmartTxInput {\n  /** Tip amount in lamports. Defaults to 500,000. */\n  tipAmount?: number;\n}\n\n/** Build a smart transaction that includes a tip instruction. */\nexport type CreateSmartTransactionWithTipFn = (\n  args: CreateSmartTxWithTipInput\n) => Promise<CreateSmartTxResult>;\n\n/** Options for `sendTransactionWithSender` — route through Helius sender infra. */\nexport interface SendViaSenderOptions {\n  /** Sender region to route through. */\n  region: SenderRegion;\n  /** Route only through SWQOS infrastructure. */\n  swqosOnly?: boolean;\n  /** Overall polling timeout in milliseconds. */\n  pollTimeoutMs?: number;\n  /** Polling cadence in milliseconds. */\n  pollIntervalMs?: number;\n  /** Explicit lamport tip override. */\n  tipAmount?: number;\n}\n\n/** Build, tip, and send a transaction via the Helius sender infrastructure. */\nexport type SendTransactionWithSenderFn = (\n  args: Omit<CreateSmartTxWithTipInput, \"tipAmount\"> & SendViaSenderOptions\n) => Promise<string>;\n\n/** Internal dependencies for `sendTransactionWithSender`. */\nexport interface SendSmartTxSenderDeps {\n  raw: Rpc<SolanaRpcApi>;\n  createSmartTransactionWithTip: (\n    i: CreateSmartTxWithTipInput\n  ) => Promise<CreateSmartTxResult>;\n}\n\n/** Tip account addresses used by the Helius sender infrastructure. */\nexport const SENDER_TIP_ACCOUNTS: Address[] = [\n  \"4ACfpUFoaSD9bfPdeu6DBt89gB6ENTeHBXCAi87NhDEE\" as Address,\n  \"D2L6yPZ2FmmmTKPgzaMKdhu6EWZcTpLy1Vhx8uvZe7NZ\" as Address,\n  \"9bnz4RShgq1hAnLnZbP8kbgBg1kEmcJBYQq3gQbmnSta\" as Address,\n  \"5VY91ws6B2hMmBFRsXkoAAdsPHBJwRfBht4DXox3xkwn\" as Address,\n  \"2nyhqdwKcJZR2vcqCyrYsaPVdAnFoJjiksCXJ7hfEYgD\" as Address,\n  \"2q5pghRs6arqVjRvT5gfgWfWcHWmw1ZuCzphgd5KfWGJ\" as Address,\n  \"wyvPkWjVZz1M8fHQnMMCDTQDbkManefNNhweYk5WkcF\" as Address,\n  \"3KCKozbAaF75qEU33jtzozcJ29yJuaLJTy2jFdzUY8bT\" as Address,\n  \"4vieeGHPYPG2MmyPRcYjdiDmmhN3ww7hsFNap8pVN3Ey\" as Address,\n  \"4TQLFNWK8AovT1gFvda5jfw2oJeRMKEmw7aH6MGBJ3or\" as Address,\n] as const;\n\n/** Minimum tip for dual (SWQOS + Jito) submission — 0.001 SOL. */\nexport const MIN_TIP_LAMPORTS_DUAL = 1_000_000n;\n/** Minimum tip for SWQOS-only submission — 0.0005 SOL. */\nexport const MIN_TIP_LAMPORTS_SWQOS = 500_000n;\n\n/** Options for the low-level `sendTransaction` helper. */\nexport interface HeliusSendOptions {\n  skipPreflight?: boolean;\n  maxRetries?: number;\n  minContextSlot?: number;\n  preflightCommitment?: string;\n  validatorAcls?: string[];\n}\n\n/** A transaction in any supported format that can be sent. */\nexport type SendableTransaction =\n  | Base64EncodedWireTransaction\n  | { serialize(): Uint8Array }\n  | { base64: string }\n  | { signed: unknown };\n\n/** Send a pre-signed transaction. Returns the signature. */\nexport type SendTransactionFn = (\n  tx: SendableTransaction,\n  opts?: HeliusSendOptions\n) => Promise<Signature>;\n\n/** URL for the SFDP rejects list. */\nexport const SFDP_REJECTS_URL =\n  \"https://helius-docs.s3.us-east-2.amazonaws.com/sfdp_rejects.json\";\n"],"names":[],"mappings":";;AA8KA;;;;;AAKG;AACI,MAAM,gBAAgB,GAAG;;AAE9B,IAAA,OAAO,EAAE,+BAA+B;;AAExC,IAAA,MAAM,EAAE,kCAAkC;;AAE1C,IAAA,OAAO,EAAE,kCAAkC;;AAE3C,IAAA,OAAO,EAAE,kCAAkC;;AAE3C,IAAA,UAAU,EAAE,kCAAkC;;AAE9C,IAAA,QAAQ,EAAE,kCAAkC;;AAE5C,IAAA,YAAY,EAAE,iCAAiC;;AAE/C,IAAA,QAAQ,EAAE,kCAAkC;;AAM9C;AACO,MAAM,aAAa,GAAG,CAAC,MAAoB,KAChD,GAAG,gBAAgB,CAAC,MAAM,CAAC;AAE7B;AACO,MAAM,aAAa,GAAG,CAAC,MAAoB,KAChD,GAAG,gBAAgB,CAAC,MAAM,CAAC;AAwC7B;AACO,MAAM,mBAAmB,GAAc;IAC5C,8CAAyD;IACzD,8CAAyD;IACzD,8CAAyD;IACzD,8CAAyD;IACzD,8CAAyD;IACzD,8CAAyD;IACzD,6CAAwD;IACxD,8CAAyD;IACzD,8CAAyD;IACzD,8CAAyD;;AAG3D;AACO,MAAM,qBAAqB,GAAG;AACrC;AACO,MAAM,sBAAsB,GAAG;AAwBtC;AACO,MAAM,gBAAgB,GAC3B;;;;;;;;;;"}