/** * NEAR transaction builder for Omni Bridge */ import { ChainKind, type NearUnsignedTransaction, type Network, type ValidatedTransfer } from "@omni-bridge/core"; import { type EvmVerifyProofArgs, type FastFinTransferParams, type FinalizationParams, type TransferId, type UTXO, type UtxoConnectorConfig, type UtxoDepositFinalizationParams, type UtxoWithdrawalInitParams, type UtxoWithdrawalSignParams, type UtxoWithdrawalSubmitParams, type UtxoWithdrawalVerifyParams, type WormholeVerifyProofArgs } from "./types.js"; export interface NearBuilderConfig { network: Network; /** * Custom NEAR RPC URL. If not provided, uses the default RPC for the network. */ rpcUrl?: string; } /** * NEAR transaction builder interface */ export interface NearBuilder { /** * Build an unsigned transfer transaction */ buildTransfer(validated: ValidatedTransfer, signerId: string): NearUnsignedTransaction; /** * Build a storage deposit transaction */ buildStorageDeposit(signerId: string, amount: bigint): NearUnsignedTransaction; /** * Build a finalization transaction */ buildFinalization(params: FinalizationParams): NearUnsignedTransaction; /** * Build a log metadata transaction */ buildLogMetadata(token: string, signerId: string): NearUnsignedTransaction; /** * Build a deploy token transaction */ buildDeployToken(destinationChain: ChainKind, proverArgs: Uint8Array, signerId: string, deposit: bigint): NearUnsignedTransaction; /** * Build a bind token transaction */ buildBindToken(sourceChain: ChainKind, proverArgs: Uint8Array, signerId: string, deposit: bigint): NearUnsignedTransaction; /** * Build a sign transfer transaction */ buildSignTransfer(transferId: TransferId, feeRecipient: string, fee: { fee: string; native_fee: string; }, signerId: string): NearUnsignedTransaction; /** * Build a fast finalization transfer transaction */ buildFastFinTransfer(params: FastFinTransferParams, signerId: string): NearUnsignedTransaction; /** * Serialize EVM proof arguments for prover */ serializeEvmProofArgs(args: EvmVerifyProofArgs): Uint8Array; /** * Serialize Wormhole VAA proof arguments for prover */ serializeWormholeProofArgs(args: WormholeVerifyProofArgs): Uint8Array; /** * Get required storage deposit for an account on the bridge contract. * Makes view calls to check current balance vs required amounts. * * @param accountId - Account to check storage for * @returns Amount of additional storage deposit needed (0n if sufficient) */ getRequiredStorageDeposit(accountId: string): Promise; /** * Check if a token has storage registered for the bridge contract. * If not, the bridge contract needs storage_deposit on the token before transfers. * * @param tokenId - Token contract to check * @returns true if bridge has storage, false if storage_deposit needed */ isTokenStorageRegistered(tokenId: string): Promise; /** * Build a storage deposit transaction on a token contract for the bridge. * This is needed before the bridge can receive tokens. * * @param tokenId - Token contract to register storage on * @param signerId - Account paying for storage * @returns Unsigned transaction for storage_deposit */ buildTokenStorageDeposit(tokenId: string, signerId: string): Promise; /** * Build a transaction to finalize a UTXO deposit on NEAR. * This calls `verify_deposit_v2` on the BTC/Zcash connector contract. * * @param params - Deposit finalization parameters including proof data * @returns Unsigned transaction for verify_deposit_v2 */ buildUtxoDepositFinalization(params: UtxoDepositFinalizationParams): NearUnsignedTransaction; /** * Build a transaction to initiate a UTXO withdrawal from NEAR. * This calls `ft_transfer_call` on the nBTC/nZEC token to the connector. * * @param params - Withdrawal parameters including target address and UTXO plan * @returns Unsigned transaction for ft_transfer_call */ buildUtxoWithdrawalInit(params: UtxoWithdrawalInitParams): NearUnsignedTransaction; /** * Build a transaction to submit a UTXO withdrawal to the chain connector. * Use this to "unstuck" a withdrawal when the relayer fails to submit it * after the user called init_transfer on the omni bridge. * * @param params - Submit parameters including transfer ID and UTXO plan * @returns Unsigned transaction for submit_transfer_to_utxo_chain_connector */ buildUtxoWithdrawalSubmit(params: UtxoWithdrawalSubmitParams): NearUnsignedTransaction; /** * Build a transaction to manually trigger MPC signing for a UTXO withdrawal input. * Use this to "unstuck" a withdrawal when the relayer fails to sign. * Must be called once per input in the pending transaction. * * @param params - Signing parameters including the pending sign ID and input index * @returns Unsigned transaction for sign_btc_transaction */ buildUtxoWithdrawalSign(params: UtxoWithdrawalSignParams): NearUnsignedTransaction; /** * Build a transaction to verify a UTXO withdrawal on NEAR. * This calls `verify_withdraw_v2` on the connector after broadcasting. * * @param params - Verification parameters including the transaction inclusion proof * @returns Unsigned transaction for verify_withdraw_v2 */ buildUtxoWithdrawalVerify(params: UtxoWithdrawalVerifyParams): NearUnsignedTransaction; /** * Get the UTXO connector contract address for a chain. * * @param chain - The UTXO chain ("btc" or "zcash") * @returns The connector contract address */ getUtxoConnectorAddress(chain: "btc" | "zcash"): string; /** * Get the UTXO token contract address for a chain. * * @param chain - The UTXO chain ("btc" or "zcash") * @returns The token contract address (nBTC or nZEC) */ getUtxoTokenAddress(chain: "btc" | "zcash"): string; /** * Get the UTXO connector configuration from the contract. * * @param chain - The UTXO chain ("btc" or "zcash") * @returns The connector configuration */ getUtxoConnectorConfig(chain: "btc" | "zcash"): Promise; /** * Get available UTXOs from the connector contract. * * @param chain - The UTXO chain ("btc" or "zcash") * @returns Array of available UTXOs for withdrawal */ getUtxoAvailableOutputs(chain: "btc" | "zcash"): Promise; /** * Get the nBTC/nZEC token balance for an account. * * @param chain - The UTXO chain ("btc" or "zcash") * @param accountId - NEAR account to check balance for * @returns Token balance in satoshis/zatoshis */ getUtxoTokenBalance(chain: "btc" | "zcash", accountId: string): Promise; /** * Calculate the bridge fee for a UTXO withdrawal. * * @param chain - The UTXO chain ("btc" or "zcash") * @param amount - Withdrawal amount in satoshis/zatoshis * @returns Bridge fee amount */ calculateUtxoWithdrawalFee(chain: "btc" | "zcash", amount: bigint): Promise; } /** * Create a NEAR transaction builder */ export declare function createNearBuilder(config: NearBuilderConfig): NearBuilder; //# sourceMappingURL=builder.d.ts.map