@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
61 lines (60 loc) • 2.24 kB
TypeScript
import { Optional } from '../utils/other.js';
import { BuildTxOptions } from '../tx/builder/index.js';
import { Tag } from '../tx/builder/constants.js';
import { Encoded } from '../utils/encoder.js';
import { _getPollInterval } from '../chain.js';
import { sendTransaction } from '../send-transaction.js';
import Node from '../Node.js';
import AccountBase from '../account/Base.js';
import OracleBase from './OracleBase.js';
/**
* @category oracle
*/
interface OracleClientPostQueryOptions extends Optional<Parameters<typeof sendTransaction>[1], 'onNode' | 'onAccount'>, BuildTxOptions<Tag.OracleQueryTx, 'oracleId' | 'senderId' | 'query'> {
}
/**
* @category oracle
*/
export default class OracleClient extends OracleBase {
options: {
onAccount: AccountBase;
onNode: Node;
} & Parameters<OracleClient['query']>[1];
/**
* @param address - Oracle public key
* @param options - Options object
* @param options.onAccount - Account to use
* @param options.onNode - Node to use
*/
constructor(address: Encoded.OracleAddress, options: {
onAccount: AccountBase;
onNode: Node;
} & Parameters<OracleClient['query']>[1]);
/**
* Post query to oracle
* @param query - Query to oracle
* @param options - Options object
* @returns Transaction details and query ID
*/
postQuery(query: string, options?: OracleClientPostQueryOptions): Promise<Awaited<ReturnType<typeof sendTransaction>> & {
queryId: Encoded.OracleQueryId;
}>;
/**
* Poll for oracle response to query
* @param queryId - Oracle Query id
* @param options - Options object
* @param options.interval - Poll interval
* @returns Oracle response
*/
pollForResponse(queryId: Encoded.OracleQueryId, options?: {
interval?: number;
} & Partial<Parameters<typeof _getPollInterval>[1]>): Promise<string>;
/**
* Post query to oracle and wait for response
* @param query - Query to oracle
* @param options - Options object
* @returns Oracle response
*/
query(query: string, options?: OracleClientPostQueryOptions & Parameters<OracleClient['pollForResponse']>[1]): Promise<string>;
}
export {};