opnet
Version:
The perfect library for building Bitcoin-based applications.
110 lines (109 loc) • 4.95 kB
TypeScript
import { QuantumBIP32Interface } from '../../node_modules/@btc-vision/bip32/src/cjs/index.cjs';
import { Network, PsbtOutputExtended, Signer } from '../../node_modules/@btc-vision/bitcoin/build/index.js';
import { Address, BinaryReader, IP2WSHAddress, LoadedStorage, RawChallenge, SupportedTransactionVersion } from '../../node_modules/@btc-vision/transaction/build/index.js';
import { ECPairInterface } from 'ecpair';
import { UTXO } from '../bitcoin/UTXOs.js';
import { BitcoinFees } from '../block/BlockGasParameters.js';
import { IAccessList } from './interfaces/IAccessList.js';
import { EventList, ICallResultData } from './interfaces/ICallResult.js';
import { IProviderForCallResult } from './interfaces/IProviderForCallResult.js';
import { OPNetEvent } from './OPNetEvent.js';
import { ContractDecodedObjectResult, DecodedOutput } from './types/ContractTypes.js';
export interface TransactionParameters {
readonly signer: Signer | ECPairInterface | null;
readonly mldsaSigner: QuantumBIP32Interface | null;
readonly refundTo: string;
readonly sender?: string;
readonly priorityFee?: bigint;
feeRate?: number;
readonly utxos?: UTXO[];
readonly maximumAllowedSatToSpend: bigint;
readonly network: Network;
readonly extraInputs?: UTXO[];
readonly extraOutputs?: PsbtOutputExtended[];
readonly minGas?: bigint;
readonly note?: string | Buffer;
readonly p2wda?: boolean;
readonly from?: Address;
readonly txVersion?: SupportedTransactionVersion;
readonly anchor?: boolean;
readonly dontUseCSVUtxos?: boolean;
readonly maxUTXOs?: number;
readonly throwIfUTXOsLimitReached?: boolean;
readonly linkMLDSAPublicKeyToAddress?: boolean;
readonly revealMLDSAPublicKey?: boolean;
}
export interface UTXOTrackingInfo {
readonly csvUTXOs: UTXO[];
readonly p2wdaUTXOs: UTXO[];
readonly regularUTXOs: UTXO[];
readonly refundAddress: string;
readonly refundToAddress: string;
readonly csvAddress?: IP2WSHAddress;
readonly p2wdaAddress?: {
readonly address: string;
readonly witnessScript: Buffer;
};
readonly isP2WDA: boolean;
}
export interface SignedInteractionTransactionReceipt {
readonly fundingTransactionRaw: string | null;
readonly interactionTransactionRaw: string;
readonly nextUTXOs: UTXO[];
readonly estimatedFees: bigint;
readonly challengeSolution: RawChallenge;
readonly interactionAddress: string | null;
readonly fundingUTXOs: UTXO[];
readonly fundingInputUtxos: UTXO[];
readonly compiledTargetScript: string | null;
readonly utxoTracking: UTXOTrackingInfo;
}
export interface InteractionTransactionReceipt {
readonly transactionId: string;
readonly newUTXOs: UTXO[];
readonly peerAcknowledgements: number;
readonly estimatedFees: bigint;
readonly challengeSolution: RawChallenge;
readonly rawTransaction: string;
readonly interactionAddress: string | null;
readonly fundingUTXOs: UTXO[];
readonly fundingInputUtxos: UTXO[];
readonly compiledTargetScript: string | null;
}
export declare class CallResult<T extends ContractDecodedObjectResult = {}, U extends OPNetEvent<ContractDecodedObjectResult>[] = OPNetEvent<ContractDecodedObjectResult>[]> implements Omit<ICallResultData, 'estimatedGas' | 'events' | 'specialGas'> {
#private;
readonly result: BinaryReader;
readonly accessList: IAccessList;
readonly revert: string | undefined;
calldata: Buffer | undefined;
loadedStorage: LoadedStorage | undefined;
readonly estimatedGas: bigint | undefined;
readonly refundedGas: bigint | undefined;
properties: T;
estimatedSatGas: bigint;
estimatedRefundedGasInSat: bigint;
events: U;
to: string | undefined;
address: Address | undefined;
fromAddress: Address | undefined;
csvAddress: IP2WSHAddress | undefined;
constructor(callResult: ICallResultData, provider: IProviderForCallResult);
get rawEvents(): EventList;
static decodeRevertData(revertDataBytes: Uint8Array | Buffer): string;
setTo(to: string, address: Address): void;
setFromAddress(from?: Address): void;
signTransaction(interactionParams: TransactionParameters, amountAddition?: bigint): Promise<SignedInteractionTransactionReceipt>;
sendPresignedTransaction(signedTx: SignedInteractionTransactionReceipt): Promise<InteractionTransactionReceipt>;
sendTransaction(interactionParams: TransactionParameters, amountAddition?: bigint): Promise<InteractionTransactionReceipt>;
setGasEstimation(estimatedGas: bigint, refundedGas: bigint): void;
setBitcoinFee(fees: BitcoinFees): void;
setDecoded(decoded: DecodedOutput): void;
setEvents(events: U): void;
setCalldata(calldata: Buffer): void;
private acquire;
private bigintMax;
private getValuesFromAccessList;
private contractToString;
private parseEvents;
private base64ToUint8Array;
}