UNPKG

@witnet/ethers

Version:

Wit/Oracle SDK Framework package for Solidity projects

383 lines 20 kB
import { BlockTag, Contract, ContractTransactionReceipt, Interface, InterfaceAbi, JsonRpcApiProvider, JsonRpcSigner, TransactionReceipt } from "ethers"; import { Witnet } from "@witnet/sdk"; import { PriceFeed, PriceFeedUpdate, DataPushReport, RandomizeStatus, WitOracleQueryParams, WitOracleQueryStatus, WitOracleResultDataTypes } from "./types"; declare abstract class ContractWrapper { constructor(signer: JsonRpcSigner, network: string, abi: Interface | InterfaceAbi, target: string); /** * The address of the underlying Wit/Oracle Framework artifact. */ readonly address: string; /** * The underlying Ethers' contract wrapper. */ readonly contract: Contract; /** * The EVM network currently connected to. */ readonly network: string; /** * The ETH/RPC provider used of contract interactions. */ readonly provider: JsonRpcApiProvider; /** * The EVM address that will sign contract interaction transactions, when required. */ readonly signer: JsonRpcSigner; /** * Name of the underlying logic implementation contract. * @returns Contract name. */ getEvmImplClass(): Promise<string>; /** * Get specs identifier of the underlying logic implementation contract. * @returns 4-byte hex string. */ getEvmImplSpecs(): Promise<string>; /** * Version tag of the underlying logic implementation contract. * @returns Version tag. */ getEvmImplVersion(): Promise<string>; } declare abstract class WitArtifactWrapper extends ContractWrapper { constructor(signer: JsonRpcSigner, network: string, artifact: string, at?: string); } declare abstract class WitApplianceWrapper extends ContractWrapper { readonly witOracle: WitOracle; constructor(witOracle: WitOracle, artifact: string, at?: string); } /** * Wrapper class for the Wit/Oracle contract as deployed in some specified EVM network. * It provides wrappers to other main artifacts of the Wit/Oracle Framework, as well * as factory methods for wrapping existing `WitOracleRadonRequestTemplate` and `WitOracleConsumer` * compliant contracts, provably bound to the Wit/Oracle core contract. * */ export declare class WitOracle extends WitArtifactWrapper { constructor(signer: JsonRpcSigner, network: string); /** * Create a WitOracle attached to the Wit/Oracle main address on the connected EVM network. * Fails if the EVM network served at the specified JSON ETH/RPC endpoint, is not currently bridged * to the Witnet blockchain. * @param url ETH/RPC endpoint URL. * @param signer Specific signer address, other than default, to use for signing EVM transactions. */ static fromJsonRpcUrl(url: string, signerId?: number | string): Promise<WitOracle>; estimateBaseFee(evmGasPrice: bigint): Promise<bigint>; estimateBaseFeeWithCallback(evmGasPrice: bigint, evmCallbackGas: number): Promise<bigint>; estimateExtraFee(evmGasPrice: bigint, evmWitPrice: bigint, queryParams: WitOracleQueryParams): Promise<bigint>; filterWitOracleQueryEvents(options: { fromBlock: BlockTag; toBlock?: BlockTag; where?: { evmRequester?: string; queryRadHash?: Witnet.Hash; }; }): Promise<Array<{ evmBlockNumber: bigint; evmRequester: string; evmTransactionHash: string; queryId: bigint; queryRadHash: Witnet.Hash; queryParams: WitOracleQueryParams; }>>; filterWitOracleReportEvents(options: { fromBlock: BlockTag; toBlock?: BlockTag; where?: { evmOrigin?: string; evmConsumer?: string; queryRadHash?: Witnet.Hash; }; }): Promise<Array<{ evmBlockNumber: bigint; evmOrigin: string; evmConsumer: string; evmReporter: string; evmTransactionHash: string; witDrTxHash: Witnet.Hash; queryRadHash: Witnet.Hash; queryParams: WitOracleQueryParams; resultCborBytes: Witnet.HexString; resultTimestamp: number; }>>; getEvmChainId(): Promise<number>; getEvmChannel(): Promise<Witnet.HexString>; getNextQueryId(): Promise<bigint>; getQueryResultStatusDescription(queryId: bigint): Promise<string>; getQueryStatuses(queryIds: bigint[]): Promise<Array<WitOracleQueryStatus>>; getWitOracleConsumerAt(target: string): Promise<WitOracleConsumer>; /** * Wrapper class for the Wit/Oracle Radon Registry core contract as deployed in some supported EVM network. * It allows formal verification of Radon Requests and Witnet-compliant data sources into such network, * as to be securely referred on both Wit/Oracle queries pulled from within smart contracts, * or Wit/Oracle query results pushed into smart contracts from offchain workflows. */ getWitOracleRadonRegistry(): Promise<WitOracleRadonRegistry>; /** * Wrapper class for the Wit/Oracle Request Factory core contract as deployed in some supported EVM network. * It allows construction of `WitOracleRadonRequestTemplate` minimal-proxy contracts out of one ore more * parameterized Radon Retievals (Witnet-compliant data sources). Template addresses are counter-factual to * the set of data sources they are built on. */ getWitOracleRadonRequestFactory(): Promise<WitOracleRadonRequestFactory>; /** * Wrapper class for Wit/Oracle Radon Template artifacts as deployed in some supported EVM network. * `IWitOracleRadonRequestTemplate` contracts enable smart contracts to formally verify Radon Requests * built out out of a set of parameterized Witnet-compliant data sources, on the fly. */ getWitOracleRadonRequestTemplateAt(target: string): Promise<WitOracleRadonRequestTemplate>; /** * Wrapper class for Wit/Oracle Radon Modal artifacts as deployed in some supported EVM network. * `IWitOracleRadonRequestModal` contracts enable smart contracts to formally verify Radon Requests * built out out of a single Radon Retrieval and multiple data providers, all of them expected to * provided exactly the same data. */ getWitOracleRadonRequestModalAt(target: string): Promise<WitOracleRadonRequestModal>; getWitPriceFeedsAt(target: string): Promise<WitPriceFeeds>; getWitPriceFeedsLegacyAt(target: string): Promise<WitPriceFeedsLegacy>; getWitRandomnessAt(target: string): Promise<WitRandomness>; } declare class WitOracleConsumer extends WitApplianceWrapper { protected constructor(witOracle: WitOracle, target: string); static at(witOracle: WitOracle, target: string): Promise<WitOracleConsumer>; pushDataReport(report: DataPushReport, options?: { confirmations?: number; gasPrice?: bigint; gasLimit?: bigint; onDataPushReportTransaction?: (txHash: string) => any; timeout?: number; }): Promise<ContractTransactionReceipt | TransactionReceipt | null>; } /** * Wrapper class for the Wit/Oracle Radon Registry core contract as deployed in some supported EVM network. * It allows formal verification of Radon Requests and Witnet-compliant data sources into such network, * as to be securely referred on both Wit/Oracle queries pulled from within smart contracts, * or Wit/Oracle query results pushed into smart contracts from offchain workflows. */ declare class WitOracleRadonRegistry extends WitArtifactWrapper { constructor(signer: JsonRpcSigner, network: string); /** * Determines the unique hash that would identify the given Radon Retrieval, if it was * formally verified into the connected EVM network. * @param retrieval Instance of a Radon Retrieval object. */ determineRadonRetrievalHash(retrieval: Witnet.Radon.RadonRetrieval): Promise<string>; /** * Returns information related to some previously verified Radon Request, on the connected EVM network. * @param radHash The RAD hash that uniquely identifies the Radon Request. */ lookupRadonRequest(radHash: string): Promise<Witnet.Radon.RadonRequest>; /** * Returns the bytecode of some previously verified Radon Request, on the connected EVM network. * @param radHash The RAD hash that uniquely identifies the Radon Request. */ lookupRadonRequestBytecode(radHash: string): Promise<Witnet.HexString>; /** * Returns information about some previously verified Radon Retrieval on the connected EVM network. * This information includes retrieval the method, URL, body, headers and the Radon script in charge * to transform data before delivery, on the connected EVM network. * @param radHash The RAD hash that uniquely identifies the Radon Request. */ lookupRadonRetrieval(hash: string): Promise<Witnet.Radon.RadonRetrieval>; /** * Formally verify the given Radon Request object into the connected EVM network. * It also verifies all the Radon Retrieval scripts (i.e. data source) the Request * relies on, if not yet done before. * * Verifying Radon assets modifies the EVM storage and therefore requires * spending gas in proportion to the number and complexity of the data sources, * and whether these had been previously verified before or not. * * If the given Radon Request happened to be already verified, no gas would be actually consumed. * * @param request Instance of a Radon Request object. * @param options Async EVM transaction handlers. * @returns The RAD hash of the Radon Request, as verified on the connected EVM network. */ verifyRadonRequest(request: Witnet.Radon.RadonRequest, options?: { /** * Number of block confirmations to wait for after verifying transaction gets mined (defaults to 1). */ confirmations?: number; /** * Callback handler called just in case a `verifyRadonRequest` transaction is ultimately required. */ onVerifyRadonRequest: (radHash: string) => any; /** * Callback handler called once the `verifyRadonRequest` transaction gets confirmed. * @param receipt The `verifyRadonRequest` transaction receipt. */ onVerifyRadonRequestReceipt?: (receipt: ContractTransactionReceipt | null) => any; /** * Callback handler called for every involved `verifyRadonRetrieval` transaction. */ onVerifyRadonRetrieval?: (hash: string) => any; /** * Callback handler called after every involved `verifyRadonRetrieval` transaction gets confirmed. * @param receipt The `verifyRadonRetrieval` transaction receipt. */ onVerifyRadonRetrievalReceipt?: (receipt: ContractTransactionReceipt | null) => any; }): Promise<string>; /** * Formally verify the given Radon Retrieval script (i.e. data source), into the connected EVM network. * * Verifying Radon assets modifies the EVM storage and therefore requires * spending gas in proportion to the size of the data source parameters (e.g. URL, body, headers, or Radon script). * * If the given Radon Retrieval object happened to be already verified, no EVM gas would be actually consumed. * * @param request Instance of a Radon Retrieval object. * @param options Async EVM transaction handlers. * @returns The unique hash of the Radon Retrieval object, as verified on the connected EVM network. */ verifyRadonRetrieval(retrieval: Witnet.Radon.RadonRetrieval, options?: { /** * Number of block confirmations to wait for after verifying transaction gets mined (defaults to 1). */ confirmations?: number; /** * Callback handler called just in case a `verifyRadonRequest` transaction is ultimately required. */ onVerifyRadonRetrieval?: (hash: string) => any; /** * Callback handler called once the `verifyRadonRetrieval` transaction gets confirmed. * @param receipt The `verifyRadonRetrieval` transaction receipt. */ onVerifyRadonRetrievalReceipt?: (receipt: ContractTransactionReceipt | null) => any; }): Promise<string>; } declare class WitOracleRadonRequestFactory extends WitApplianceWrapper { readonly registry: WitOracleRadonRegistry; protected constructor(witOracle: WitOracle, registry: WitOracleRadonRegistry, at?: string); static deployed(witOracle: WitOracle, registry: WitOracleRadonRegistry): Promise<WitOracleRadonRequestFactory>; deployRadonRequestTemplate(template: Witnet.Radon.RadonTemplate, options?: { confirmations?: number; onDeployRadonRequestTemplate?: (address: string) => any; onDeployRadonRequestTemplateReceipt?: (receipt: ContractTransactionReceipt | null) => any; /** * Callback handler called just in case a `verifyRadonRetrieval` transaction is ultimately required. */ onVerifyRadonRetrieval?: (hash: string) => any; /** * Callback handler called once the `verifyRadonRetrieval` transaction gets confirmed. * @param receipt The `verifyRadonRetrieval` transaction receipt. * @param hash The unique hash of the Radon Retrieval, as verified on the connected network. */ onVerifyRadonRetrievalReceipt?: (receipt: ContractTransactionReceipt | null) => any; }): Promise<WitOracleRadonRequestTemplate>; deployRadonRequestModal(modal: Witnet.Radon.RadonModal, options?: { confirmations?: number; onDeployRadonRequestModal?: (address: string) => any; onDeployRadonRequestModalReceipt?: (receipt: ContractTransactionReceipt | null) => any; /** * Callback handler called just in case a `verifyRadonRetrieval` transaction is ultimately required. */ onVerifyRadonRetrieval?: (hash: string) => any; /** * Callback handler called once the `verifyRadonRetrieval` transaction gets confirmed. * @param receipt The `verifyRadonRetrieval` transaction receipt. * @param hash The unique hash of the Radon Retrieval, as verified on the connected network. */ onVerifyRadonRetrievalReceipt?: (receipt: ContractTransactionReceipt | null) => any; }): Promise<WitOracleRadonRequestModal>; verifyRadonRequest(request: Witnet.Radon.RadonRequest, _options?: { confirmations?: number; onVerifyRadonRequest?: (address: string) => any; onVerifyRadonRequestReceipt?: (receipt: ContractTransactionReceipt | null) => any; /** * Callback handler called just in case a `verifyRadonRetrieval` transaction is ultimately required. */ onVerifyRadonRetrieval?: (hash: string) => any; /** * Callback handler called once the `verifyRadonRetrieval` transaction gets confirmed. * @param receipt The `verifyRadonRetrieval` transaction receipt. * @param hash The unique hash of the Radon Retrieval, as verified on the connected network. */ onVerifyRadonRetrievalReceipt?: (receipt: ContractTransactionReceipt | null) => any; }): Promise<Witnet.Hash>; } declare class WitOracleRadonRequestModal extends WitApplianceWrapper { protected constructor(witOracle: WitOracle, at: string); static at(witOracle: WitOracle, target: string): Promise<WitOracleRadonRequestModal>; getDataResultType(): Promise<WitOracleResultDataTypes>; getDataSourcesArgsCount(): Promise<number>; getRadonModalRetrieval(): Promise<Witnet.Radon.RadonRetrieval>; verifyRadonRequest(dataProviders: string[], commonRetrievalArgs?: string[], options?: { confirmations?: number; onVerifyRadonRequest: (radHash: string) => any; onVerifyRadonRequestReceipt: (receipt: ContractTransactionReceipt | null) => any; }): Promise<Witnet.Hash>; } declare class WitOracleRadonRequestTemplate extends WitApplianceWrapper { protected constructor(witOracle: WitOracle, at: string); static at(witOracle: WitOracle, target: string): Promise<WitOracleRadonRequestTemplate>; getDataResultType(): Promise<WitOracleResultDataTypes>; getDataSources(): Promise<Array<Witnet.Radon.RadonRetrieval>>; getDataSourcesArgsCount(): Promise<Array<number>>; verifyRadonRequest(args: string | string[] | Array<string[]>, options?: { confirmations?: number; onVerifyRadonRequest: (radHash: string) => any; onVerifyRadonRequestReceipt: (receipt: ContractTransactionReceipt | null) => any; }): Promise<Witnet.HexString>; } declare class WitPriceFeeds extends WitApplianceWrapper { protected constructor(witOracle: WitOracle, at: string); static at(witOracle: WitOracle, target: string): Promise<WitPriceFeeds>; createChainlinkAggregator(id4: Witnet.HexString, options?: { evmConfirmations?: number; evmGasPrice?: bigint; evmTimeout?: number; onCreateChainlinkAggregatorTransaction?: (txHash: Witnet.Hash) => any; onCreateChainlinkAggregatorTransactionReceipt?: (receipt: TransactionReceipt | null) => any; }): Promise<ContractTransactionReceipt | TransactionReceipt | null>; determineChainlinkAggregatorAddress(id4: Witnet.HexString): Promise<string>; getEvmFootprint(): Promise<string>; getPrice(id4: Witnet.HexString, ema: boolean): Promise<PriceFeedUpdate>; getPriceNotOlderThan(id4: Witnet.HexString, ema: boolean, age: number): Promise<PriceFeedUpdate>; getPriceUnsafe(id4: Witnet.HexString, ema: boolean): Promise<PriceFeedUpdate>; isCaptionSupported(caption: string): Promise<boolean>; lookupPriceFeed(id4: Witnet.HexString): Promise<PriceFeed>; lookupPriceFeedCaption(id4: Witnet.HexString): Promise<string>; lookupPriceFeedExponent(id4: Witnet.HexString): Promise<number>; lookupPriceFeedID(id4: Witnet.HexString): Promise<Witnet.Hash>; lookupPriceFeeds(): Promise<Array<PriceFeed>>; } declare class WitPriceFeedsLegacy extends WitApplianceWrapper { protected constructor(witOracle: WitOracle, at: string); static at(witOracle: WitOracle, target: string): Promise<WitPriceFeedsLegacy>; getEvmFootprint(): Promise<string>; isCaptionSupported(caption: string): Promise<boolean>; lookupPriceFeedCaption(id4: Witnet.HexString): Promise<string>; lookupPriceFeedExponent(id4: Witnet.HexString): Promise<number>; lookupPriceFeeds(): Promise<Array<PriceFeed>>; } declare class WitRandomness extends WitApplianceWrapper { protected _legacy: Contract; protected constructor(witOracle: WitOracle, at: string); static at(witOracle: WitOracle, target: string): Promise<WitRandomness>; estimateRandomizeFee(evmGasPrice: bigint): Promise<bigint>; getRandomnessAfter(evmBlockNumber: bigint): Promise<Witnet.HexString | undefined>; fetchRandomnessAfterProof(evmBlockNumber: bigint): Promise<[Witnet.Hash, number]>; getLastRandomizeBlock(): Promise<bigint>; getRandomizePrevBlock(evmBlockNumber: bigint): Promise<bigint>; getRandomizeStatus(evmBlockNumber: bigint): Promise<RandomizeStatus>; getRandomizeStatusDescription(evmBlockNumber: bigint): Promise<string>; getRandomizeHistory(limit?: number): Promise<Array<{ evmBlockNumber: bigint; evmRandomizeStatus: RandomizeStatus; witResult: Witnet.HexString | undefined; witResultDrTxHash: Witnet.Hash | undefined; witResultTimestamp: number | undefined; }>>; isRandomized(evmBlockNumber: bigint): Promise<boolean>; randomize(options?: { evmConfirmations?: number; evmGasPrice?: bigint; evmTimeout?: number; onRandomizeTransaction?: (txHash: Witnet.Hash) => any; onRandomizeTransactionReceipt?: (receipt: TransactionReceipt | null) => any; }): Promise<ContractTransactionReceipt | TransactionReceipt | null>; } export {}; //# sourceMappingURL=wrappers.d.ts.map