import { Transaction } from '../core/tx'; import { HexString, NonNil } from '../utils/types'; import { Kwil } from '../client/kwil'; import { ActionBuilder, SignerSupplier } from '../core/builders'; import { ActionInput } from '../core/action'; import { EnvironmentType } from '../core/enums'; import { AnySignatureType } from '../core/signature'; import { Message } from '../core/message'; /** * `ActionBuilderImpl` class is an implementation of the `ActionBuilder` interface. * It helps in building and transactions to execute database actions on the Kwil network. */ export declare class ActionBuilderImpl implements ActionBuilder { private readonly client; private _signer; private _identifier; private _actions; private _signatureType; private _name; private _dbid; private _chainId; private _description; /** * Initializes a new `ActionBuilder` instance. * * @param {Kwil} client - The Kwil client, used to call higher level methods on the Kwil class. * @returns {ActionBuilder} A new `ActionBuilder` instance. */ private constructor(); /** * Creates a new `ActionBuilder` instance. * * @param {Kwil} client - The Kwil client, used to call higher level methods on the Kwil class. * @returns {ActionBuilder} A new `ActionBuilder` instance. */ static of(client: NonNil>): NonNil; /** * Specifies the name of the action to be executed. * * @param {string} actionName - The name of the action to be executed. * @returns {ActionBuilder} The current `ActionBuilder` instance for chaining. * @throws Will throw an error if the value is specified while the action is being built. * @throws Will throw an error if the action name is null or undefined. */ name(actionName: string): NonNil; /** * Specifies the database identifier (DBID) of the database that contains the action to be executed. * * @param {string} dbid - The database identifier. * @returns {ActionBuilder} The current `ActionBuilder` instance for chaining. * @throws Will throw an error if the value is specified while the action is being built. * @throws Will throw an error if the dbid is null or undefined. */ dbid(dbid: string): NonNil; /** * Specifies the signer for the action operation. * * @param {SignerSupplier} signer - The signer for the database operation. This can be a signer from Ethers v5 or Ethers v6 or a custom signer function of the form `(message: Uint8Array, ...args: any[]) => Promise`. * @param {AnySignatureType} signatureType - The signature type for the database operation. This can be a `SignatureType` enum value or a string for a network-specific signature type. Ethers v5 and Ethers v6 signers will have the signature type inferred from the signer. * @returns {ActionBuilder} The current `ActionBuilder` instance for chaining. * @throws Will throw an error if the value is specified while the action is being built. * @throws Will throw an error if the signer is null or undefined. * @throws Will throw an error if the signature type is null or undefined. * @throws Will throw an error if it cannot infer the signature type from the signer. */ signer(signer: SignerSupplier, signatureType?: AnySignatureType): NonNil; /** * Specifies the identifier (e.g. wallet, public key, etc) of the signer for the action. * * @param {HexString | Uint8Array} identifier - The identifier of the wallet signing for the database operation. * @returns {ActionBuilder} The current `ActionBuilder` instance for chaining. * @throws Will throw an error if the value is specified while the action is being built. * @throws Will throw an error if the identifier is null or undefined. */ publicKey(identifier: HexString | Uint8Array): NonNil; /** * Specifies the description to be included in the message that is signed. * * @param {string} description - The description to be included in the message that is signed. * @returns {ActionBuilder} The current `ActionBuilder` instance for chaining. * @throws Will throw an error if the value is specified while the action is being built. * @throws Will throw an error if the description is null or undefined. */ description(description: string): ActionBuilder; /** * Adds actionInputs to the list of inputs to be executed in the action. * * @param {ActionInput | ActionInput[]} actions - The actions to add. This should be from the `ActionInput` class. * @returns The current `ActionBuilder` instance for chaining. * @throws Will throw an error if the value is specified while the action is being built. * @throws Will throw an error if the action is null or undefined. */ concat(actions: ActionInput[] | ActionInput): NonNil; /** * Specifies the chain ID for the network being used. * * @param {string} chainId - The chain ID for the network being used. * @returns {ActionBuilder} The current `ActionBuilder` instance for chaining. */ chainId(chainId: string): NonNil; /** * Builds a transaction. This will call the kwil network to retrieve the schema and the signer's account. * * @returns {Promise} - A promise that resolves to a Transaction object. This transaction can be broadcasted to the Kwil network with the `kwil.broadcast()` api. * @throws Will throw an error if the action is being built or if there's an issue with the schema or account retrieval. * @throws Will throw an error if the action is not a update action. */ buildTx(): Promise; /** * Builds the message structure for view actions. This can be provided to the `kwil.call()` api. * * @returns {Promise} - A message object that can be sent to the Kwil network. * @throws Will throw an error if the action is being built or if there's an issue with the schema or account retrieval. * @throws Will throw an error if the action is not a view action. */ buildMsg(): Promise; /** * Executes all the required logic in the TxnBuildImpl class to build a transaction. * * @param {ActionInput[]} actions - The actions to be executed. * @returns {Transaction} A transaction object that can be broadcasted to the Kwil network. * @throws Will throw an error if there's an issue with the schema or account retrieval & validation. */ private dobuildTx; /** * Executes all of the required logic in the TxnBuildImpl class to build a view action for the call endpoint. * * @param {ActionInput[]} actions - The actions to be executed. * @returns {Message} A message object that can be sent to the Kwil network. * @throws Will throw an error if there's an issue with the schema or account retrieval & validation. */ private doBuildMsg; /** * Checks the schema and validates the actions. * * @param {ActionInput[]} actions - The values of the actions to be executed. * @returns {CheckSchema} - An object containing the database identifier, action name, action schema, and prepared actions. */ private checkSchema; /** * Validates that the action is not missing any inputs. * * @param {ActionInput[]} actions - The values of the actions to be executed. * @param {ActionSchema} actionSchema - The schema of the action to be executed. * @param {string} actionName - The name of the action to be executed. * @returns {ValueType[][]} - An array of arrays of values to be executed. */ private prepareActions; private assertNotBuilding; }