import { AccountInfo, AccountSigner, AccountTransactionSignature, MakeRequired } from '../../index.js';
import { AccountTransactionV0, AccountTransactionV1, Payload, Transaction } from '../index.js';
import { Header, HeaderJSON } from './shared.js';
export type Signable
= SignableV0
| SignableV1
;
export type SignableV0
= {
version: 0;
/**
* The transaction input header of the v0 _signable_ transaction stage, i.e. with everything required to finalize the
* transaction.
*/
header: Required>;
/**
* The transaction payload, defining the transaction type and type specific data.
*/
payload: P;
/**
* The map of signatures for the credentials associated with the account.
*/
signature: AccountTransactionV0.Signature;
};
export type SignableV1 = {
version: 1;
/**
* The transaction input header of the v1 _signable_ transaction stage, i.e. with everything required to finalize the
* transaction.
*/
header: MakeRequired;
/**
* The transaction payload, defining the transaction type and type specific data.
*/
payload: P;
/**
* The signatures for both `sender` and `sponsor`.
*/
signatures: AccountTransactionV1.Signatures;
};
type V0JSON = {
version: 0;
header: HeaderJSON;
payload: Payload.JSON;
signature: AccountTransactionSignature;
};
type V1JSON = {
version: 1;
header: HeaderJSON;
payload: Payload.JSON;
signatures: AccountTransactionV1.Signatures;
};
export type SignableJSON = V0JSON | V1JSON;
export declare function isSignable(transaction: Transaction.Type): transaction is Signable;
/**
* Adds a pre-computed signature to a _signable_ transaction.
*
* @template P - the payload type
* @template T - the transaction type
*
* @param transaction - the transaction to add a signature to
* @param signature - the sender signature on the transaction to add
*
* @returns the signed transaction with the signature attached
* @throws Error if the number of signatures exceeds the allowed number specified in the transaction header
*/
export declare function addSignature(transaction: Signable
, signature: AccountTransactionSignature): Signable
;
/**
* Signs a _signable_ transaction using the provided account signer.
*
* @template P - the payload type
* @template T - the transaction type
*
* @param transaction - the signable transaction to sign
* @param signer - the account signer to use for signing
*
* @returns a promise that resolves to the signed transaction
* @throws Error if the number of signatures exceeds the allowed number specified in the transaction header
*/
export declare function sign
(transaction: Signable
, signer: AccountSigner): Promise>;
/**
* Adds a pre-computed sponsor signature to a _signable_ transaction.
*
* @template P - the payload type
* @template T - the transaction type
*
* @param transaction - the transaction to add a sponsor signature to
* @param signature - the sponsor signature on the transaction to add
*
* @returns the signed transaction with the sponsor signature attached
* @throws Error if the number of signatures exceeds the allowed number specified in the transaction header
*/
export declare function addSponsorSignature(transaction: SignableV1
, signature: AccountTransactionSignature): Signable
;
/**
* Signs a _signable_ transaction as a sponsor using the provided account signer.
*
* @template P - the payload type
* @template T - the transaction type
*
* @param transaction - the signable transaction to sign
* @param signer - the account signer to use for signing
*
* @returns a promise that resolves to the signed transaction
* @throws Error if the number of signatures exceeds the allowed number specified in the transaction header
*/
export declare function sponsor
(transaction: SignableV1
, signer: AccountSigner): Promise>;
/**
* Verify an account signature on a transaction.
*
* @param transaction the transaction to verify the signature for.
* @param signature the signature on the transaction, from a specific account.
* @param accountInfo the address and credentials of the account.
*
* @returns whether the signature is valid.
*/
export declare function verifySignature(transaction: Signable, signature: AccountTransactionSignature, accountInfo: Pick): Promise;
/**
* Merges signatures from _signable_ transaction `other` into _signable_ transaction `target`.
* Used for multi-signature scenarios where multiple parties sign the same transaction.
*
* @template P - the payload type
* @template T - the signed transaction type
*
* @param target - the signed transaction to merge signatures into
* @param other - the signed transaction from which the signatures are merged into `target`
*
* @returns `target` with the signatures from `other` added into it.
* @throws Error if duplicate signatures are found for the same credential and key index
* @throws Error if the number of signatures exceeds the allowed number specified in the transaction header
*/
export declare function mergeSignaturesInto = Signable
>(target: T, other: T): T;
export declare function signableToJSON(transaction: Signable): SignableJSON;
export declare function signableFromJSON(json: unknown): Signable;
export {};