UNPKG

@eversurf/dengine-js

Version:

Debot engine for Java Script

1,338 lines 37.3 kB
import { ResponseHandler } from "./bin"; interface IClient { request(functionName: string, functionParams?: any, responseHandler?: ResponseHandler): Promise<any>; requestSync(functionName: string, functionParams?: any): any; resolve_app_request(app_request_id: number | null, result: any): Promise<void>; reject_app_request(app_request_id: number | null, error: any): Promise<void>; } export declare enum ClientErrorCode { NotImplemented = 1, InvalidHex = 2, InvalidBase64 = 3, InvalidAddress = 4, CallbackParamsCantBeConvertedToJson = 5, WebsocketConnectError = 6, WebsocketReceiveError = 7, WebsocketSendError = 8, HttpClientCreateError = 9, HttpRequestCreateError = 10, HttpRequestSendError = 11, HttpRequestParseError = 12, CallbackNotRegistered = 13, NetModuleNotInit = 14, InvalidConfig = 15, CannotCreateRuntime = 16, InvalidContextHandle = 17, CannotSerializeResult = 18, CannotSerializeError = 19, CannotConvertJsValueToJson = 20, CannotReceiveSpawnedResult = 21, SetTimerError = 22, InvalidParams = 23, ContractsAddressConversionFailed = 24, UnknownFunction = 25, AppRequestError = 26, NoSuchRequest = 27, CanNotSendRequestResult = 28, CanNotReceiveRequestResult = 29, CanNotParseRequestResult = 30, UnexpectedCallbackResponse = 31, CanNotParseNumber = 32, InternalError = 33, InvalidHandle = 34, LocalStorageError = 35, InvalidData = 36, DebotStartFailed = 801, DebotFetchFailed = 802, DebotExecutionFailed = 803, DebotInvalidHandle = 804, DebotInvalidJsonParams = 805, DebotInvalidFunctionId = 806, DebotInvalidAbi = 807, DebotGetMethodFailed = 808, DebotInvalidMsg = 809, DebotExternalCallFailed = 810, DebotBrowserCallbackFailed = 811, DebotOperationRejected = 812, DebotNoCode = 813 } export declare type ClientError = { code: number; message: string; data: any; }; export declare type BindingConfig = { library?: string; version?: string; }; export declare type ClientConfig = { endpoints?: string[]; access_key?: string; }; export declare type ParamsOfAppRequest = { /** * Request ID. * * @remarks * Should be used in `resolve_app_request` call */ app_request_id: number; /** * Request describing data */ request_data: any; }; /** * Error occurred during request processing */ export declare type AppRequestResultErrorVariant = { /** * Error description */ text: string; }; /** * Request processed successfully */ export declare type AppRequestResultOkVariant = { /** * Request processing result */ result: any; }; /** * * Depends on `type` field. * * * ### `Error` * * Error occurred during request processing * * ### `Ok` * * Request processed successfully */ export declare type AppRequestResult = ({ type: 'Error'; } & AppRequestResultErrorVariant) | ({ type: 'Ok'; } & AppRequestResultOkVariant); export declare function appRequestResultError(text: string): AppRequestResult; export declare function appRequestResultOk(result: any): AppRequestResult; export declare type ResultOfGetApiReference = { api: any; }; export declare type ParamsOfResolveAppRequest = { /** * Request ID received from SDK */ app_request_id: number; /** * Result of request processing */ result: AppRequestResult; }; /** * Provides information about library. */ export declare class ClientModule { client: IClient; constructor(client: IClient); /** * Returns Core Library API reference * @returns ResultOfGetApiReference */ get_api_reference(): Promise<ResultOfGetApiReference>; /** * Returns Core Library API reference * * NOTE: Available only for `lib-node` binding. * * * @returns ResultOfGetApiReference */ get_api_reference_sync(): ResultOfGetApiReference; /** * Resolves application request processing result * * @param {ParamsOfResolveAppRequest} params * @returns */ resolve_app_request(params: ParamsOfResolveAppRequest): Promise<void>; /** * Resolves application request processing result * * NOTE: Available only for `lib-node` binding. * * * * @param {ParamsOfResolveAppRequest} params * @returns */ resolve_app_request_sync(params: ParamsOfResolveAppRequest): void; } export declare enum DebotErrorCode { DebotStartFailed = 801, DebotFetchFailed = 802, DebotExecutionFailed = 803, DebotInvalidHandle = 804, DebotInvalidJsonParams = 805, DebotInvalidFunctionId = 806, DebotInvalidAbi = 807, DebotGetMethodFailed = 808, DebotInvalidMsg = 809, DebotExternalCallFailed = 810, DebotBrowserCallbackFailed = 811, DebotOperationRejected = 812, DebotNoCode = 813 } export declare type DebotHandle = number; /** * Describes `Debot` metadata. */ export declare type DebotInfo = { /** * DeBot short name. */ name?: string; /** * DeBot semantic version. */ version?: string; /** * The name of DeBot deployer. */ publisher?: string; /** * Short info about DeBot. */ caption?: string; /** * The name of DeBot developer. */ author?: string; /** * TON address of author for questions and donations. */ support?: string; /** * String with the first messsage from DeBot. */ hello?: string; /** * String with DeBot interface language (ISO-639). */ language?: string; /** * String with DeBot ABI. */ dabi?: string; /** * DeBot icon. */ icon?: string; /** * Vector with IDs of DInterfaces used by DeBot. */ interfaces: string[]; /** * ABI version ("x.y") supported by DeBot */ dabiVersion: string; }; /** * DeBot wants to create new transaction in blockchain. */ export declare type DebotActivityTransactionVariant = { /** * External inbound message BOC. */ msg: string; /** * Target smart contract address. */ dst: string; /** * List of spendings as a result of transaction. */ out: Spending[]; /** * Transaction total fee. */ fee: bigint; /** * Indicates if target smart contract updates its code. */ setcode: boolean; /** * Public key from keypair that was used to sign external message. */ signkey: string; /** * Signing box handle used to sign external message. */ signing_box_handle: number; }; /** * Describes the operation that the `DeBot` wants to perform. * * Depends on `type` field. * * * ### `Transaction` * * DeBot wants to create new transaction in blockchain. */ export declare type DebotActivity = ({ type: 'Transaction'; } & DebotActivityTransactionVariant); export declare function debotActivityTransaction(msg: string, dst: string, out: Spending[], fee: bigint, setcode: boolean, signkey: string, signing_box_handle: number): DebotActivity; export declare type FetchResponse = { status: number; headers: FetchHeader[]; content: string; }; export declare type FetchHeader = { key: string; value: string; }; /** * Describes how much funds will be debited from the target contract balance as a result of the transaction. */ export declare type Spending = { /** * Amount of nanotokens that will be sent to `dst` address. */ amount: bigint; /** * Destination address of recipient of funds. */ dst: string; }; export declare type EncryptionBoxHandle = number; export declare type SigningBoxHandle = number; export declare type ParamsOfQuery = { /** * GraphQL query text. */ query: string; /** * Variables used in query. * * @remarks * Must be a map with named values that can be used in query. */ variables?: any; }; export declare type ParamsOfQueryCollection = { /** * Collection name (accounts, blocks, transactions, messages, block_signatures) */ collection: string; /** * Collection filter */ filter?: any; /** * Projection (result) string */ result: string; /** * Sorting order */ order?: OrderBy[]; /** * Number of documents to return */ limit?: number; }; export declare type ResultOfQuery = { /** * Result provided by DAppServer. */ result: any; }; export declare type ResultOfQueryCollection = { /** * Objects that match the provided criteria */ result: any[]; }; export declare type OrderBy = { path: string; direction: SortDirection; }; export declare enum SortDirection { ASC = "ASC", DESC = "DESC" } export declare type ParamsOfWaitForCollection = { /** * Collection name (accounts, blocks, transactions, messages, block_signatures) */ collection: string; /** * Collection filter */ filter?: any; /** * Projection (result) string */ result: string; /** * Query timeout */ timeout?: number; }; export declare type ResultOfWaitForCollection = { /** * First found object that matches the provided criteria */ result: any; }; /** * Encryption box information. */ export declare type EncryptionBoxInfo = { /** * Derivation path, for instance "m/44'/396'/0'/0/0" */ hdpath?: string; /** * Cryptographic algorithm, used by this encryption box */ algorithm?: string; /** * Options, depends on algorithm and specific encryption box implementation */ options?: any; /** * Public information, depends on algorithm */ public?: any; }; export declare type MessageNode = { /** * Message id. */ id: string; /** * Source transaction id. * * @remarks * This field is missing for an external inbound messages. */ src_transaction_id?: string; /** * Destination transaction id. * * @remarks * This field is missing for an external outbound messages. */ dst_transaction_id?: string; /** * Source address. */ src?: string; /** * Destination address. */ dst?: string; /** * Transferred tokens value. */ value?: string; /** * Bounce flag. */ bounce: boolean; /** * Decoded body. * * @remarks * Library tries to decode message body using provided `params.abi_registry`. * This field will be missing if none of the provided abi can be used to decode. */ decoded_body?: DecodedMessageBody; }; export declare type TransactionNode = { /** * Transaction id. */ id: string; /** * In message id. */ in_msg: string; /** * Out message ids. */ out_msgs: string[]; /** * Account address. */ account_addr: string; /** * Transactions total fees. */ total_fees: string; /** * Aborted flag. */ aborted: boolean; /** * Compute phase exit code. */ exit_code?: number; }; export declare type ParamsOfQueryTransactionTree = { /** * Input message id. */ in_msg: string; /** * List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry. */ abi_registry?: Abi[]; /** * Timeout used to limit waiting time for the missing messages and transaction. * * @remarks * If some of the following messages and transactions are missing yet * The maximum waiting time is regulated by this option. * * Default value is 60000 (1 min). If `timeout` is set to 0 then function will wait infinitely * until the whole transaction tree is executed */ timeout?: number; /** * Maximum transaction count to wait. * * @remarks * If transaction tree contains more transaction then this parameter then only first `transaction_max_count` transaction are awaited and returned. * * Default value is 50. If `transaction_max_count` is set to 0 then no limitation on * transaction count is used and all transaction are returned. */ transaction_max_count?: number; }; export declare type ResultOfQueryTransactionTree = { /** * Messages. */ messages: MessageNode[]; /** * Transactions. */ transactions: TransactionNode[]; }; export declare type ResultOfProcessMessage = { /** * Parsed transaction. * * @remarks * In addition to the regular transaction fields there is a * `boc` field encoded with `base64` which contains source * transaction BOC. */ transaction: any; /** * List of output messages' BOCs. * * @remarks * Encoded as `base64` */ out_messages: string[]; /** * Optional decoded message bodies according to the optional `abi` parameter. */ decoded?: DecodedOutput; /** * Transaction fees */ fees: TransactionFees; }; export declare type WaitForTransactionParams = { abi?: Abi; message: string; shard_block_id: string; send_events?: boolean; sending_endpoints?: string[]; }; export declare type DecodedMessageBody = { /** * Type of the message body content. */ body_type: MessageBodyType; /** * Function or event name. */ name: string; /** * Parameters or result value. */ value?: any; /** * Function header. */ header?: FunctionHeader; }; export declare type TransactionFees = { /** * Deprecated. * * @remarks * Contains the same data as ext_in_msg_fee field */ in_msg_fwd_fee: bigint; /** * Fee for account storage */ storage_fee: bigint; /** * Fee for processing */ gas_fee: bigint; /** * Deprecated. * * @remarks * Contains the same data as total_fwd_fees field. Deprecated because of its confusing name, that is not the same with GraphQL API Transaction type's field. */ out_msgs_fwd_fee: bigint; /** * Deprecated. * * @remarks * Contains the same data as account_fees field */ total_account_fees: bigint; /** * Deprecated because it means total value sent in the transaction, which does not relate to any fees. */ total_output: bigint; /** * Fee for inbound external message import. */ ext_in_msg_fee: bigint; /** * Total fees the account pays for message forwarding */ total_fwd_fees: bigint; /** * Total account fees for the transaction execution. Compounds of storage_fee + gas_fee + ext_in_msg_fee + total_fwd_fees */ account_fees: bigint; }; export declare type DecodedOutput = { /** * Decoded bodies of the out messages. * * @remarks * If the message can't be decoded, then `None` will be stored in * the appropriate position. */ out_messages: DecodedMessageBody | null[]; /** * Decoded body of the function output message. */ output?: any; }; export declare type AbiContractVariant = { value: AbiContract; }; export declare type AbiJsonVariant = { value: string; }; export declare type AbiHandleVariant = { value: AbiHandle; }; export declare type AbiSerializedVariant = { value: AbiContract; }; /** * * Depends on `type` field. * * * ### `Contract` * * * ### `Json` * * * ### `Handle` * * * ### `Serialized` * */ export declare type Abi = ({ type: 'Contract'; } & AbiContractVariant) | ({ type: 'Json'; } & AbiJsonVariant) | ({ type: 'Handle'; } & AbiHandleVariant) | ({ type: 'Serialized'; } & AbiSerializedVariant); export declare function abiContract(value: AbiContract): Abi; export declare function abiJson(value: string): Abi; export declare function abiHandle(value: AbiHandle): Abi; export declare function abiSerialized(value: AbiContract): Abi; export declare type AbiContract = { 'ABI version'?: number; abi_version?: number; version?: string | null; header?: string[]; functions?: AbiFunction[]; events?: AbiEvent[]; data?: AbiData[]; fields?: AbiParam[]; }; export declare type AbiEvent = { name: string; inputs: AbiParam[]; id?: string | null; }; export declare type AbiFunction = { name: string; inputs: AbiParam[]; outputs: AbiParam[]; id?: string | null; }; export declare type AbiParam = { name: string; type: string; components?: AbiParam[]; }; export declare type AbiData = { key: number; name: string; type: string; components?: AbiParam[]; }; export declare type AbiHandle = number; export declare enum MessageBodyType { Input = "Input", Output = "Output", InternalOutput = "InternalOutput", Event = "Event" } /** * The ABI function header. * * @remarks * Includes several hidden function parameters that contract * uses for security, message delivery monitoring and replay protection reasons. * * The actual set of header fields depends on the contract's ABI. * If a contract's ABI does not include some headers, then they are not filled. */ export declare type FunctionHeader = { /** * Message expiration timestamp (UNIX time) in seconds. * * @remarks * If not specified - calculated automatically from message_expiration_timeout(), * try_index and message_expiration_timeout_grow_factor() (if ABI includes `expire` header). */ expire?: number; /** * Message creation time in milliseconds. * * @remarks * If not specified, `now` is used (if ABI includes `time` header). */ time?: bigint; /** * Public key is used by the contract to check the signature. * * @remarks * Encoded in `hex`. If not specified, method fails with exception (if ABI includes `pubkey` header).. */ pubkey?: string; }; export declare enum LogLevel { User = "User", Error = "Error", Warn = "Warn", Debug = "Debug", Trace = "Trace" } /** * Parameters to init DeBot. */ export declare type ParamsOfInit = { /** * Debot smart contract address */ address: string; }; /** * Structure for storing debot handle returned from `init` function. */ export declare type RegisteredDebot = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; /** * Debot abi as json string. */ debot_abi: string; /** * Debot metadata. */ info: DebotInfo; }; /** * Print message to user. */ export declare type ParamsOfAppDebotBrowserLogVariant = { level: LogLevel; /** * A string that must be printed to user. */ msg: string; }; /** * Get signing box to sign data. * * @remarks * Signing box returned is owned and disposed by debot engine */ export declare type ParamsOfAppDebotBrowserGetSigningBoxVariant = {}; /** * Used by Debot to call DInterface implemented by Debot Browser. */ export declare type ParamsOfAppDebotBrowserSendVariant = { /** * Internal message to DInterface address. * * @remarks * Message body contains interface function and parameters. */ message: string; }; /** * Requests permission from DeBot Browser to execute DeBot operation. */ export declare type ParamsOfAppDebotBrowserApproveVariant = { /** * DeBot activity details. */ activity: DebotActivity; }; export declare type ParamsOfAppDebotBrowserFetchVariant = { url: string; method: string; headers: FetchHeader[]; body?: string; }; export declare type ParamsOfAppDebotBrowserEncryptVariant = { handle: EncryptionBoxHandle; data: string; }; export declare type ParamsOfAppDebotBrowserDecryptVariant = { handle: EncryptionBoxHandle; data: string; }; export declare type ParamsOfAppDebotBrowserSignVariant = { handle: SigningBoxHandle; data: string; }; export declare type ParamsOfAppDebotBrowserSendMessageVariant = { message: string; }; export declare type ParamsOfAppDebotBrowserQueryVariant = { params: ParamsOfQuery; }; export declare type ParamsOfAppDebotBrowserQueryCollectionVariant = { params: ParamsOfQueryCollection; }; export declare type ParamsOfAppDebotBrowserWaitForCollectionVariant = { params: ParamsOfWaitForCollection; }; export declare type ParamsOfAppDebotBrowserWaitForTransactionVariant = { params: WaitForTransactionParams; }; export declare type ParamsOfAppDebotBrowserQueryTransactionTreeVariant = { params: ParamsOfQueryTransactionTree; }; export declare type ParamsOfAppDebotBrowserGetSigningBoxInfoVariant = { handle: SigningBoxHandle; }; export declare type ParamsOfAppDebotBrowserGetEncryptionBoxInfoVariant = { handle: EncryptionBoxHandle; }; /** * [DEPRECATED](DEPRECATED.md) Debot Browser callbacks * * @remarks * Called by debot engine to communicate with debot browser. * * Depends on `type` field. * * * ### `Log` * * Print message to user. * * ### `GetSigningBox` * * Get signing box to sign data. * * ### `Send` * * Used by Debot to call DInterface implemented by Debot Browser. * * ### `Approve` * * Requests permission from DeBot Browser to execute DeBot operation. * * ### `Fetch` * * * ### `Encrypt` * * * ### `Decrypt` * * * ### `Sign` * * * ### `SendMessage` * * * ### `Query` * * * ### `QueryCollection` * * * ### `WaitForCollection` * * * ### `WaitForTransaction` * * * ### `QueryTransactionTree` * * * ### `GetSigningBoxInfo` * * * ### `GetEncryptionBoxInfo` * */ export declare type ParamsOfAppDebotBrowser = ({ type: 'Log'; } & ParamsOfAppDebotBrowserLogVariant) | ({ type: 'GetSigningBox'; } & ParamsOfAppDebotBrowserGetSigningBoxVariant) | ({ type: 'Send'; } & ParamsOfAppDebotBrowserSendVariant) | ({ type: 'Approve'; } & ParamsOfAppDebotBrowserApproveVariant) | ({ type: 'Fetch'; } & ParamsOfAppDebotBrowserFetchVariant) | ({ type: 'Encrypt'; } & ParamsOfAppDebotBrowserEncryptVariant) | ({ type: 'Decrypt'; } & ParamsOfAppDebotBrowserDecryptVariant) | ({ type: 'Sign'; } & ParamsOfAppDebotBrowserSignVariant) | ({ type: 'SendMessage'; } & ParamsOfAppDebotBrowserSendMessageVariant) | ({ type: 'Query'; } & ParamsOfAppDebotBrowserQueryVariant) | ({ type: 'QueryCollection'; } & ParamsOfAppDebotBrowserQueryCollectionVariant) | ({ type: 'WaitForCollection'; } & ParamsOfAppDebotBrowserWaitForCollectionVariant) | ({ type: 'WaitForTransaction'; } & ParamsOfAppDebotBrowserWaitForTransactionVariant) | ({ type: 'QueryTransactionTree'; } & ParamsOfAppDebotBrowserQueryTransactionTreeVariant) | ({ type: 'GetSigningBoxInfo'; } & ParamsOfAppDebotBrowserGetSigningBoxInfoVariant) | ({ type: 'GetEncryptionBoxInfo'; } & ParamsOfAppDebotBrowserGetEncryptionBoxInfoVariant); export declare function paramsOfAppDebotBrowserLog(level: LogLevel, msg: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserGetSigningBox(): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserSend(message: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserApprove(activity: DebotActivity): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserFetch(url: string, method: string, headers: FetchHeader[], body?: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserEncrypt(handle: EncryptionBoxHandle, data: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserDecrypt(handle: EncryptionBoxHandle, data: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserSign(handle: SigningBoxHandle, data: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserSendMessage(message: string): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserQuery(params: ParamsOfQuery): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserQueryCollection(params: ParamsOfQueryCollection): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserWaitForCollection(params: ParamsOfWaitForCollection): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserWaitForTransaction(params: WaitForTransactionParams): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserQueryTransactionTree(params: ParamsOfQueryTransactionTree): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserGetSigningBoxInfo(handle: SigningBoxHandle): ParamsOfAppDebotBrowser; export declare function paramsOfAppDebotBrowserGetEncryptionBoxInfo(handle: EncryptionBoxHandle): ParamsOfAppDebotBrowser; /** * Result of getting signing box. */ export declare type ResultOfAppDebotBrowserGetSigningBoxVariant = { /** * Signing box for signing data requested by debot engine. * * @remarks * Signing box is owned and disposed by debot engine */ signing_box: SigningBoxHandle; }; /** * Result of `approve` callback. */ export declare type ResultOfAppDebotBrowserApproveVariant = { /** * Indicates whether the DeBot is allowed to perform the specified operation. */ approved: boolean; }; export declare type ResultOfAppDebotBrowserFetchVariant = { response: FetchResponse; }; export declare type ResultOfAppDebotBrowserEncryptVariant = { encrypted: string; }; export declare type ResultOfAppDebotBrowserDecryptVariant = { decrypted: string; }; export declare type ResultOfAppDebotBrowserSignVariant = { signature: string; }; export declare type ResultOfAppDebotBrowserSendMessageVariant = { shard_block_id: string; sending_endpoints: string[]; }; export declare type ResultOfAppDebotBrowserQueryVariant = { result: ResultOfQuery; }; export declare type ResultOfAppDebotBrowserQueryCollectionVariant = { result: ResultOfQueryCollection; }; export declare type ResultOfAppDebotBrowserWaitForCollectionVariant = { result: ResultOfWaitForCollection; }; export declare type ResultOfAppDebotBrowserWaitForTransactionVariant = { result: ResultOfProcessMessage; }; export declare type ResultOfAppDebotBrowserQueryTransactionTreeVariant = { result: ResultOfQueryTransactionTree; }; export declare type ResultOfAppDebotBrowserGetSigningBoxInfoVariant = { pubkey: string; }; export declare type ResultOfAppDebotBrowserGetEncryptionBoxInfoVariant = { result: EncryptionBoxInfo; }; /** * Returning values from Debot Browser callbacks. * * Depends on `type` field. * * * ### `GetSigningBox` * * Result of getting signing box. * * ### `Approve` * * Result of `approve` callback. * * ### `Fetch` * * * ### `Encrypt` * * * ### `Decrypt` * * * ### `Sign` * * * ### `SendMessage` * * * ### `Query` * * * ### `QueryCollection` * * * ### `WaitForCollection` * * * ### `WaitForTransaction` * * * ### `QueryTransactionTree` * * * ### `GetSigningBoxInfo` * * * ### `GetEncryptionBoxInfo` * */ export declare type ResultOfAppDebotBrowser = ({ type: 'GetSigningBox'; } & ResultOfAppDebotBrowserGetSigningBoxVariant) | ({ type: 'Approve'; } & ResultOfAppDebotBrowserApproveVariant) | ({ type: 'Fetch'; } & ResultOfAppDebotBrowserFetchVariant) | ({ type: 'Encrypt'; } & ResultOfAppDebotBrowserEncryptVariant) | ({ type: 'Decrypt'; } & ResultOfAppDebotBrowserDecryptVariant) | ({ type: 'Sign'; } & ResultOfAppDebotBrowserSignVariant) | ({ type: 'SendMessage'; } & ResultOfAppDebotBrowserSendMessageVariant) | ({ type: 'Query'; } & ResultOfAppDebotBrowserQueryVariant) | ({ type: 'QueryCollection'; } & ResultOfAppDebotBrowserQueryCollectionVariant) | ({ type: 'WaitForCollection'; } & ResultOfAppDebotBrowserWaitForCollectionVariant) | ({ type: 'WaitForTransaction'; } & ResultOfAppDebotBrowserWaitForTransactionVariant) | ({ type: 'QueryTransactionTree'; } & ResultOfAppDebotBrowserQueryTransactionTreeVariant) | ({ type: 'GetSigningBoxInfo'; } & ResultOfAppDebotBrowserGetSigningBoxInfoVariant) | ({ type: 'GetEncryptionBoxInfo'; } & ResultOfAppDebotBrowserGetEncryptionBoxInfoVariant); export declare function resultOfAppDebotBrowserGetSigningBox(signing_box: SigningBoxHandle): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserApprove(approved: boolean): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserFetch(response: FetchResponse): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserEncrypt(encrypted: string): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserDecrypt(decrypted: string): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserSign(signature: string): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserSendMessage(shard_block_id: string, sending_endpoints: string[]): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserQuery(result: ResultOfQuery): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserQueryCollection(result: ResultOfQueryCollection): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserWaitForCollection(result: ResultOfWaitForCollection): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserWaitForTransaction(result: ResultOfProcessMessage): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserQueryTransactionTree(result: ResultOfQueryTransactionTree): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserGetSigningBoxInfo(pubkey: string): ResultOfAppDebotBrowser; export declare function resultOfAppDebotBrowserGetEncryptionBoxInfo(result: EncryptionBoxInfo): ResultOfAppDebotBrowser; /** * Parameters to start DeBot. DeBot must be already initialized with init() function. */ export declare type ParamsOfStart = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; }; /** * Parameters to fetch DeBot metadata. */ export declare type ParamsOfFetch = { /** * Debot smart contract address. */ address: string; }; export declare type ResultOfFetch = { /** * Debot metadata. */ info: DebotInfo; }; /** * Parameters of `send` function. */ export declare type ParamsOfSend = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; /** * BOC of internal message to debot encoded in base64 format. */ message: string; }; export declare type ParamsOfRemove = { /** * Debot handle which references an instance of debot engine. */ debot_handle: DebotHandle; }; export interface AppDebotBrowser { log(params: ParamsOfAppDebotBrowserLogVariant): void; get_signing_box(): Promise<ResultOfAppDebotBrowserGetSigningBoxVariant>; send(params: ParamsOfAppDebotBrowserSendVariant): void; approve(params: ParamsOfAppDebotBrowserApproveVariant): Promise<ResultOfAppDebotBrowserApproveVariant>; fetch(params: ParamsOfAppDebotBrowserFetchVariant): Promise<ResultOfAppDebotBrowserFetchVariant>; encrypt(params: ParamsOfAppDebotBrowserEncryptVariant): Promise<ResultOfAppDebotBrowserEncryptVariant>; decrypt(params: ParamsOfAppDebotBrowserDecryptVariant): Promise<ResultOfAppDebotBrowserDecryptVariant>; sign(params: ParamsOfAppDebotBrowserSignVariant): Promise<ResultOfAppDebotBrowserSignVariant>; send_message(params: ParamsOfAppDebotBrowserSendMessageVariant): Promise<ResultOfAppDebotBrowserSendMessageVariant>; query(params: ParamsOfAppDebotBrowserQueryVariant): Promise<ResultOfAppDebotBrowserQueryVariant>; query_collection(params: ParamsOfAppDebotBrowserQueryCollectionVariant): Promise<ResultOfAppDebotBrowserQueryCollectionVariant>; wait_for_collection(params: ParamsOfAppDebotBrowserWaitForCollectionVariant): Promise<ResultOfAppDebotBrowserWaitForCollectionVariant>; wait_for_transaction(params: ParamsOfAppDebotBrowserWaitForTransactionVariant): Promise<ResultOfAppDebotBrowserWaitForTransactionVariant>; query_transaction_tree(params: ParamsOfAppDebotBrowserQueryTransactionTreeVariant): Promise<ResultOfAppDebotBrowserQueryTransactionTreeVariant>; get_signing_box_info(params: ParamsOfAppDebotBrowserGetSigningBoxInfoVariant): Promise<ResultOfAppDebotBrowserGetSigningBoxInfoVariant>; get_encryption_box_info(params: ParamsOfAppDebotBrowserGetEncryptionBoxInfoVariant): Promise<ResultOfAppDebotBrowserGetEncryptionBoxInfoVariant>; } /** * [DEPRECATED](DEPRECATED.md) Module for working with debot. */ export declare class DebotModule { client: IClient; constructor(client: IClient); /** * Creates and instance of DeBot. * * @remarks * Downloads debot smart contract (code and data) from blockchain and creates * an instance of Debot Engine for it. * * # Remarks * It does not switch debot to context 0. Browser Callbacks are not called. * * @param {ParamsOfInit} params * @returns RegisteredDebot */ init(params: ParamsOfInit, obj: AppDebotBrowser): Promise<RegisteredDebot>; /** * Creates and instance of DeBot. * * @remarks * Downloads debot smart contract (code and data) from blockchain and creates * an instance of Debot Engine for it. * * # Remarks * It does not switch debot to context 0. Browser Callbacks are not called. * * NOTE: Available only for `lib-node` binding. * * * * @param {ParamsOfInit} params * @returns RegisteredDebot */ init_sync(params: ParamsOfInit): RegisteredDebot; /** * Starts the DeBot. * * @remarks * This function must be used by Debot Browser to start a dialog with debot. * While the function is executing, several Browser Callbacks can be called. * * When the debot starts SDK registers `BrowserCallbacks` AppObject. * Therefore when `debote.remove` is called the debot is being deleted and the callback is called * with `finish`=`true` which indicates that it will never be used again. * * @param {ParamsOfStart} params * @returns */ start(params: ParamsOfStart): Promise<void>; /** * Starts the DeBot. * * @remarks * This function must be used by Debot Browser to start a dialog with debot. * While the function is executing, several Browser Callbacks can be called. * * When the debot starts SDK registers `BrowserCallbacks` AppObject. * Therefore when `debote.remove` is called the debot is being deleted and the callback is called * with `finish`=`true` which indicates that it will never be used again. * * NOTE: Available only for `lib-node` binding. * * * * @param {ParamsOfStart} params * @returns */ start_sync(params: ParamsOfStart): void; /** * Fetches DeBot metadata from blockchain. * * @remarks * Downloads DeBot from blockchain and creates and fetches its metadata. * * @param {ParamsOfFetch} params * @returns ResultOfFetch */ fetch(params: ParamsOfFetch): Promise<ResultOfFetch>; /** * Fetches DeBot metadata from blockchain. * * @remarks * Downloads DeBot from blockchain and creates and fetches its metadata. * * NOTE: Available only for `lib-node` binding. * * * * @param {ParamsOfFetch} params * @returns ResultOfFetch */ fetch_sync(params: ParamsOfFetch): ResultOfFetch; /** * Sends message to Debot. * * @remarks * Used by Debot Browser to send response on Dinterface call or from other Debots. * * @param {ParamsOfSend} params * @returns */ send(params: ParamsOfSend): Promise<void>; /** * Sends message to Debot. * * @remarks * Used by Debot Browser to send response on Dinterface call or from other Debots. * * NOTE: Available only for `lib-node` binding. * * * * @param {ParamsOfSend} params * @returns */ send_sync(params: ParamsOfSend): void; /** * Destroys debot handle. * * @remarks * Removes handle from Client Context and drops debot engine referenced by that handle. * * @param {ParamsOfRemove} params * @returns */ remove(params: ParamsOfRemove): Promise<void>; /** * Destroys debot handle. * * @remarks * Removes handle from Client Context and drops debot engine referenced by that handle. * * NOTE: Available only for `lib-node` binding. * * * * @param {ParamsOfRemove} params * @returns */ remove_sync(params: ParamsOfRemove): void; } export {}; //# sourceMappingURL=modules.d.ts.map