import type { Account } from "@near-js/accounts"; import type { FinalExecutionOutcome } from "@near-js/types"; import { BitcoinService } from "../services/bitcoin.js"; import { ZcashService } from "../services/zcash.js"; import { type AccountId, type BtcConnectorConfig, type BtcDepositArgs, ChainKind, type EvmVerifyProofArgs, type FastFinTransferArgs, type InitTransferEvent, type LogMetadataEvent, type OmniAddress, type OmniTransferMessage, ProofKind, type SignTransferEvent, type U128, type UTXO, type UtxoChain } from "../types/index.js"; import type { EvmBridgeClient } from "./evm.js"; /** * NEAR blockchain implementation of the bridge client. * Handles token deployment, binding, and transfer operations on the NEAR blockchain. */ export declare class NearBridgeClient { private wallet; private lockerAddress; bitcoinService: BitcoinService; zcashService?: ZcashService; private readonly utxoServices; /** * Creates a new NEAR bridge client instance * @param wallet - NEAR account instance for transaction signing * @param lockerAddress - Address of the token locker contract * @throws {Error} If locker address is not configured */ constructor(wallet: Account, lockerAddress?: string, options?: { zcashApiKey?: string; } | string); /** * Get the network ID from the wallet connection */ get networkId(): string; /** * Get the bridge contract ID (locker address) */ get bridgeContractId(): string; /** * Logs metadata for a token on the NEAR blockchain * @param tokenAddress - Omni address of the token * @throws {Error} If token address is not on NEAR chain * @returns Promise resolving to the transaction hash */ logMetadata(tokenAddress: OmniAddress): Promise; /** * Deploys a token to the specified destination chain * @param destinationChain - Target chain where the token will be deployed * @param vaa - Verified Action Approval containing deployment information * @returns Promise resolving to the transaction hash */ deployToken(destinationChain: ChainKind, vaa?: string, evmProof?: EvmVerifyProofArgs): Promise; /** * Binds a token on the NEAR chain using either a VAA (Wormhole) or EVM proof * @param sourceChain - Source chain where the original token comes from * @param vaa - Verified Action Approval for Wormhole verification * @param evmProof - EVM proof for Ethereum or EVM chain verification * @throws {Error} If VAA or EVM proof is not provided * @throws {Error} If EVM proof is provided for non-EVM chain * @returns Promise resolving to the transaction hash */ bindToken(sourceChain: ChainKind, vaa?: string, evmProof?: EvmVerifyProofArgs): Promise; /** * Transfers NEP-141 tokens to the token locker contract on NEAR. * This transaction generates a proof that is subsequently used to mint * corresponding tokens on the destination chain. * * @param token - Omni address of the NEP-141 token to transfer * @param recipient - Recipient's Omni address on the destination chain where tokens will be minted * @param amount - Amount of NEP-141 tokens to transfer * @throws {Error} If token address is not on NEAR chain * @returns Promise resolving to InitTransferEvent */ initTransfer(transfer: OmniTransferMessage): Promise; parseSignTransferEvent(json: string): SignTransferEvent; /** * Signs transfer using the token locker * @param initTransferEvent - Transfer event of the previously-initiated transfer * @param feeRecipient - Address of the fee recipient, can be the original sender or a relayer * @returns Promise resolving to the transaction hash */ signTransfer(initTransferEvent: InitTransferEvent, feeRecipient: AccountId): Promise; /** * Finalizes a cross-chain token transfer on NEAR by processing the transfer proof and managing storage deposits. * Supports both Wormhole VAA and EVM proof verification for transfers from supported chains. * * @param token - The token identifier on NEAR where transferred tokens will be minted * @param account - The recipient account ID on NEAR * @param storageDepositAmount - Amount of NEAR tokens for storage deposit (in yoctoNEAR) * @param sourceChain - The originating chain of the transfer * @param vaa - Optional Wormhole Verified Action Approval containing transfer information, encoded as a hex string * @param evmProof - Optional proof data for transfers from EVM-compatible chains * * @throws {Error} When neither VAA nor EVM proof is provided * @throws {Error} When EVM proof is provided for non-EVM chains (only valid for Ethereum, Arbitrum, or Base) * * @returns Promise resolving to the finalization transaction hash * */ finalizeTransfer(token: AccountId, account: AccountId, storageDepositAmount: U128, sourceChain: ChainKind, vaa?: string, evmProof?: EvmVerifyProofArgs, proofKind?: ProofKind): Promise; /** * Retrieves various balance information for the current account * @private * @returns Promise resolving to object containing required balances and storage information * @throws {Error} If balance fetching fails */ private getBalances; private getUtxoService; private getUtxoChainLabel; private getUtxoConnector; getUtxoDepositAddress(chain: UtxoChain, recipientId: string, amount?: bigint, fee?: bigint): Promise<{ depositAddress: string; depositArgs: BtcDepositArgs; }>; finalizeUtxoDeposit(chain: UtxoChain, txHash: string, vout: number, depositArgs: BtcDepositArgs): Promise; initUtxoWithdrawal(chain: UtxoChain, targetAddress: string, amount: bigint): Promise<{ pendingId: string; nearTxHash: string; }>; /** * Creates NEAR -> UTXO chain transfer (NEAR -> BTC/Zcash flow start, option #2) * To be called after initTransfer() that sends tokens to UTXO chain receiver address */ submitBitcoinTransfer(initTransferEvent: InitTransferEvent): Promise; signUtxoTransaction(chain: UtxoChain, pendingId: string, signIndex: number): Promise; finalizeUtxoWithdrawal(chain: UtxoChain, nearTxHash: string): Promise; waitForUtxoTransactionSigning(chain: UtxoChain, nearTxHash: string, maxAttempts?: number, delayMs?: number): Promise; executeUtxoWithdrawal(chain: UtxoChain, targetAddress: string, amount: bigint, maxWaitAttempts?: number, waitDelayMs?: number): Promise; verifyUtxoWithdrawal(chain: UtxoChain, txHash: string): Promise; getUtxoAvailableOutputs(chain: UtxoChain): Promise; getUtxoBridgeConfig(chain: UtxoChain): Promise; private buildUtxoWithdrawalPlan; private parseConfigBigInt; private storageDepositForToken; /** * Gets the required balance for fast transfer operations * @private * @returns Promise resolving to the required balance amount in yoctoNEAR */ getRequiredBalanceForFastTransfer(): Promise; /** * Performs a fast finalize transfer on NEAR chain. * * This method enables relayers to "front" tokens to users immediately upon detecting * an InitTransfer event on an EVM chain, without waiting for full cryptographic finality. * The relayer provides their own tokens to the user instantly, and later gets reimbursed * when the original cross-chain proof is processed. * * The process: * 1. Relayer transfers their own tokens from their NEAR account to the bridge contract * 2. Bridge contract immediately sends tokens to the final recipient * 3. Bridge marks the transfer as completed and records the relayer as owed reimbursement * 4. Later, when the slow cryptographic proof arrives, the relayer gets reimbursed * * @param args - Fast finalize transfer arguments containing token, amount, recipient, transfer_id, relayer info, etc. * @returns Promise resolving to the NEAR transaction hash * @throws {Error} If the transaction fails or required storage deposit fails */ fastFinTransfer(args: FastFinTransferArgs): Promise; /** * Performs a complete fast transfer from EVM to NEAR. * This function orchestrates the entire fast transfer process: * 1. Fetches and parses the InitTransfer event from the EVM transaction * 2. Gets the corresponding NEAR token ID using getBridgedToken * 3. Executes the fast finalize transfer on NEAR * * @param originChain - The EVM chain where the original transfer was initiated * @param evmTxHash - Transaction hash of the InitTransfer on the EVM chain * @param evmClient - EVM bridge client for parsing the transaction * @param storageDepositAmount - Optional storage deposit amount in yoctoNEAR * @returns Promise resolving to the NEAR transaction hash * @throws {Error} If the origin chain is not supported for fast transfers * @throws {Error} If the EVM transaction or event cannot be found/parsed * @throws {Error} If the fast transfer execution fails */ nearFastTransfer(originChain: ChainKind, evmTxHash: string, evmClient: EvmBridgeClient, storageDepositAmount?: string): Promise; } //# sourceMappingURL=near.d.ts.map