import { HexString, Nillable, NonNil } from '../utils/types'; import { Transaction } from '../core/tx'; import { Kwil } from '../client/kwil'; import { SignerSupplier, PayloadBuilder as PayloadBuilder } from '../core/builders'; import { EnvironmentType, PayloadType } from '../core/enums'; import { AnySignatureType } from '../core/signature'; import { Message } from '../core/message'; import { AllPayloads } from '../core/payload'; /** * PayloadBuilderImpl is the default implementation of PayloadBuilder. It allows for building transaction and call payloads that can be sent over GRPC. * See the proto files for more information on the structure of the payloads. {@link https://github.com/kwilteam/proto/tree/main/kwil/tx/v1} */ export declare class PayloadBuilderImpl implements PayloadBuilder { private readonly client; private _payloadType; private _payload; private _signer; private _identifier; private _signatureType; private _chainId; private _description; /** * Initializes a new `PayloadBuilder` instance. * * @param {Kwil} client - The Kwil client, used to call higher level methods on the Kwil class. * @returns {PayloadBuilderImpl} - A new `PayloadBuilder` instance. */ private constructor(); /** * Creates a new `PayloadBuilder` instance. * * @param {Kwil} client - The Kwil client, used to call higher level methods on the Kwil class. * @returns {PayloadBuilder} - A new `PayloadBuilder` instance. */ static of(client: NonNil>): NonNil; /** * Specify the payload type to be built. * * @param {PayloadType} payloadType - The payload type to be built. See {@link PayloadType} for more information. * @returns {PayloadBuilder} - The current `PayloadBuilder` instance for chaining. * @throws {Error} - If the payload type is null or undefined. */ payloadType(payloadType: NonNil): PayloadBuilder; /** * Specify the signer and the signature type. * * @param {SignerSupplier} signer - The signer to be used to sign the transaction. * @param {AnySignatureType} sigType - The signature type to be used to sign the transaction. See {@link SignatureType} for more information. * @returns The current `PayloadBuilder` instance for chaining. * @throws {Error} - If the signer is null or undefined. * @throws {Error} - If the signature type is null or undefined. */ signer(signer: SignerSupplier, sigType: AnySignatureType): NonNil; /** * Sets the content for the body of the payload object. * * @param {() => NonNil | NonNil} payload - The payload to be built. This can be a function that returns an object or an object. * @returns {PayloadBuilder} - The current `PayloadBuilder` instance for chaining. * @throws {Error} - If the payload is null or undefined. */ payload(payload: (() => NonNil) | NonNil): NonNil; /** * Specifies the identifier (e.g. wallet, public key, etc) for the payload signer. * * @param {HexString | Uint8Array} identifier - The identifier to be used to sign the transaction. This can be a hex string or a Uint8Array. * @returns {PayloadBuilder} - The current `PayloadBuilder` instance for chaining. * @throws {Error} - If the identifier is null or undefined. */ publicKey(identifier: Nillable): NonNil; /** * Set the description to be included in the payload signature. * * @param {string | null} description - The description to be included in the payload signature. * @returns {PayloadBuilder} - The current `PayloadBuilder` instance for chaining. */ description(description: Nillable): NonNil; /** * Specifies the chain ID for the network being used. * * @param {string} chainId - The chain ID for the network being used. * @returns {PayloadBuilder} The current `PayloadBuilder` instance for chaining. */ chainId(chainId: string): NonNil; /** * Builds the payload for the `kwil.broadcast()` method (i.e. the broadcast GRPC endpoint - see {@link https://github.com/kwilteam/proto/blob/main/kwil/tx/v1/tx.proto}) * * @returns {BaseTransaction} - A promise that resolves to the signed transaction. * @throws {Error} - If the required fields in the builder are null or undefined. */ buildTx(): Promise; /** * Build the payload structure for message to the `kwil.call()` method (i.e. the call GRPC endpoint - see {@link https://github.com/kwilteam/proto/blob/main/kwil/tx/v1/call.proto}) * * @returns {Message} - A promise that resolves to the built message, with signature if provided. * @throws {Error} - If the required fields in the builder are null or undefined. */ buildMsg(): Promise; /** * Execute lazy evaluation of payload. * * @returns {AllPayloads} - A promise that resolves to the provided payload object. */ private resolvePayload; /** * Signs the payload of a transaction / request to the broadcast GRPC endpoint. * * @param {BaseTransaction} tx - The transaction to sign. See {@link BaseTransaction} for more information. * @param {SignerSupplier} signer - The signer to be used to sign the transaction. * @param {Uint8Array} identifier - The identifier (e.g. wallet address, public key, etc) for the signature, represented as bytes. * @param {AnySignatureType} signatureType - The signature type being used. See {@link SignatureType} for more information. * @param {string} description - The description to be included in the signature. * @returns {BaseTransaction} - A promise that resolves to the signed transaction. * @throws {Error} - If the the signer is not an Ethers Signer or a function that accepts and returns a Uint8Array. */ private static signTx; /** * Adds the caller's sender address to the message. * * @param {Message} msg - The message to sign. See {@link Message} for more information. * @param {Uint8Array} identifier - The identifier (e.g. wallet address, public key, etc) for the signature, represented as bytes. * @param {AnySignatureType} signatureType - The signature type being used. See {@link SignatureType} for more information. * @param {string} description - The description to be included in the signature. * @returns Message - A promise that resolves to the signed message. * @throws {Error} - If the the signer is not an Ethers Signer or a function that accepts and returns a Uint8Array. */ private static authMsg; }