import BigNumber from 'bignumber.js'; import { AffirmationStatus, InstructionAffirmation, InstructionDetails, InstructionRelockStatus, InstructionStatus, InstructionStatusResult, Leg, LegStatus, MediatorAffirmation, OffChainAffirmation } from '../../../api/entities/Instruction/types'; import { Account, Context, Entity } from '../../../internal'; import { AffirmAsMediatorParams, AffirmInstructionParams, DefaultPortfolio, ExecuteManualInstructionParams, InstructionLockedInfo, MiddlewarePaginationOptions, NoArgsProcedureMethod, NumberedPortfolio, OffChainAffirmationReceipt, OptionalArgsProcedureMethod, PaginationOptions, RejectInstructionParams, ResultSet, SignerKeyRingType, SubCallback, UnsubCallback } from '../../../types'; export interface UniqueIdentifiers { id: BigNumber; } /** * Represents a settlement Instruction to be executed on a certain Venue */ export declare class Instruction extends Entity { /** * @hidden * Check if a value is of type {@link UniqueIdentifiers} */ static isUniqueIdentifiers(identifier: unknown): identifier is UniqueIdentifiers; /** * Unique identifier number of the instruction */ id: BigNumber; /** * @hidden */ constructor(identifiers: UniqueIdentifiers, context: Context); /** * Retrieve whether the Instruction has already been executed and pruned from * the chain. */ isExecuted(): Promise; /** * Get the number of affirmations pending before instruction can be executed * * @note The count is returned as 0 for pruned instructions as well */ getPendingAffirmationCount(): Promise; /** * Retrieve whether the Instruction is still pending on chain */ isPending(): Promise; /** * Retrieve whether the Instruction is locked for execution on chain */ getLockedInfo(): Promise; /** * Retrieve the relock cooldown status of the Instruction * * @note After a mediator unlocks an Instruction, they must wait for the relock cooldown period to * end before locking it again. `maxRelockCount` limits the total number of times an Instruction can be relocked. */ getRelockStatus(): Promise; /** * Retrieve current status of the Instruction. This can be subscribed to know if instruction fails * * @note can be subscribed to, if connected to node using a web socket * @note current status as `Executed` means that the Instruction has been executed/rejected and pruned from * the chain. */ onStatusChange(callback: SubCallback): Promise; /** * Determine whether this Instruction exists on chain (or existed and was pruned) */ exists(): Promise; /** * This method verifies whether the instruction exists and returns if middleware is available. * * @throws if instruction does not exists */ private getMiddlewareInfoAndCheckIfInstructionExists; /** * Fetches the instruction details from middleware * * @throws if instruction data is not yet processed by the middleware */ private getInstructionFromMiddleware; /** * Asserts that start value of pagination options based on middleware availability */ private assertPaginationStart; /** * @hidden * * Retrieve information specific to this Instruction from chain * * @throws if instruction is executed/rejected and was pruned from chain */ detailsFromChain(): Promise; /** * Retrieve information specific to this Instruction * * @note uses middleware (if available) to retrieve information, otherwise directly queries from the chain * * @throws if * - instruction does not exists * - instruction is not yet processed by the middleware (when querying from middleware) * - instruction is executed/rejected and was pruned from chain (when querying from chain) */ details(): Promise; /** * Retrieve every authorization generated by this Instruction (status and authorizing Identity or Account) * * @note supports pagination. * @note uses middleware (if available) to retrieve information, otherwise directly queries from the chain * * @throws if * - instruction does not exists * - instruction is executed/rejected and was pruned from chain (when querying from chain) */ getAffirmations(paginationOpts?: PaginationOptions | MiddlewarePaginationOptions): Promise>; /** * @hidden * * Retrieve all legs of this Instruction from chain * * @note supports pagination * * @throws if the instruction is executed/rejected and was pruned from chain */ getLegsFromChain(paginationOpts?: PaginationOptions): Promise>; /** * Retrieve all legs of this Instruction * * @note supports pagination * @note uses middleware (if available) to retrieve information, otherwise directly queries from the chain * * @throws if * - instruction does not exists * - instruction is not yet processed by the middleware (when querying from middleware) * - instruction is executed/rejected and was pruned from chain (when querying from chain) */ getLegs(paginationOpts?: PaginationOptions | MiddlewarePaginationOptions): Promise>; /** * Retrieve current status of this Instruction * * @note uses the middlewareV2 */ getStatus(): Promise; /** * Reject this instruction * * @note reject on `SettleOnAffirmation` will execute the settlement and it will fail immediately. * @note reject on `SettleOnBlock` behaves just like unauthorize * @note reject on `SettleManual` behaves just like unauthorize */ reject: OptionalArgsProcedureMethod; /** * Affirm this instruction (authorize) */ affirm: OptionalArgsProcedureMethod; /** * Reject this instruction as a mediator * * @note reject on `SettleOnAffirmation` will execute the settlement and it will fail immediately. * @note reject on `SettleOnBlock` behaves just like unauthorize * @note reject on `SettleManual` behaves just like unauthorize */ rejectAsMediator: NoArgsProcedureMethod; /** * Affirm this instruction as a mediator (authorize) */ affirmAsMediator: OptionalArgsProcedureMethod; /** * Executes an Instruction either of type `SettleManual` or a `Failed` instruction */ executeManually: OptionalArgsProcedureMethod; /** * Locks an Instruction of type `SettleAfterLock` for execution. Only a mediator of the instruction can lock the instruction. * * @note An Instruction can only be locked if * - it has been affirmed by all parties * - it is pending or has failed at least one time * - all mediator affirmations are valid * - all assets are in allowed venue list * - all senders have the right amount of assets being transferred * - all senders and receivers are compliant * - all assets' statistics are still valid * - there are no frozen assets * * @throws if any of the above conditions are not met */ lockForExecution: NoArgsProcedureMethod; /** * Unlocks an Instruction that is currently `LockedForExecution`, moving it back to `Pending`. Only a mediator of the instruction can unlock it. * * @note After unlocking, the mediator must wait for the relock cooldown period (see {@link getRelockStatus}) before locking the instruction again. This gives other parties time to reject the instruction if they wish to back out. */ unlockForExecution: NoArgsProcedureMethod; /** * @hidden * Retrieve Instruction status event from middleware V2 */ private getInstructionEventFromMiddleware; /** * Return the Instruction's ID */ toHuman(): string; /** * Retrieve all the involved portfolios in this Instruction where the given identity is a custodian of */ getInvolvedPortfolios(args: { did: string; }): Promise<(DefaultPortfolio | NumberedPortfolio)[]>; /** * Returns the mediators for the Instruction, along with their affirmation status * * @note uses middleware (if available) to retrieve information, otherwise directly queries from the chain * * @throws if * - instruction does not exists * - instruction is not yet processed by the middleware (when querying from middleware) * - instruction is executed/rejected and was pruned from chain (when querying from chain) */ getMediators(): Promise; /** * Returns affirmation statuses for offchain legs in this Instruction * * @note uses middleware (if available) to retrieve information, otherwise directly queries from the chain * * @throws if * - instruction does not exists * - instruction is not yet processed by the middleware (when querying from middleware) * - instruction is executed/rejected and was pruned from chain (when querying from chain) */ getOffChainAffirmations(): Promise; /** * Returns affirmation status for a specific offchain leg in this Instruction * * @param args.legId index of the leg whose affirmation status is to be fetched * * @note uses middleware (if available) to retrieve information, otherwise directly queries from the chain * * @throws if * - instruction does not exists * - legId provided is not an off-chain leg * - instruction is not yet processed by the middleware (when querying from middleware) * - instruction is executed/rejected and was pruned from chain (when querying from chain) */ getOffChainAffirmationForLeg(args: { legId: BigNumber; }): Promise; /** * Returns the execution status of a specific leg in this Instruction * * @param args.legId index of the leg whose status is to be fetched */ getLegStatus(args: { legId: BigNumber; }): Promise; /** * @hidden */ private internalToExternalStatus; /** * Generate an offchain affirmation receipt for a specific leg and UID * * @param args.legId index of the offchain leg in this instruction * @param args.uid UID of the receipt * @param args.metadata (optional) metadata to be associated with the receipt * @param args.signer (optional) Signer to be used to generate receipt signature. Defaults to signing Account associated with the SDK * @param args.signerKeyRingType (optional) keyring type of the signer. Defaults to 'Sr25519' * @param args.expiresAt timestamp at which the receipt expires and can no longer be used to affirm */ generateOffChainAffirmationReceipt(args: { legId: BigNumber; uid: BigNumber; metadata?: string; signer?: string | Account; signerKeyRingType?: SignerKeyRingType; expiresAt: Date; }): Promise; } //# sourceMappingURL=index.d.ts.map