Skip to main content
Version: 29.0.x

Class: Instruction

Defined in: src/api/entities/Instruction/index.ts:110

Represents a settlement Instruction to be executed on a certain Venue

Extends

Properties

id

id: BigNumber

Defined in: src/api/entities/Instruction/index.ts:124

Unique identifier number of the instruction


uuid

uuid: string

Defined in: src/api/entities/Entity.ts:46

Inherited from

Entity.uuid

Methods

affirm()

affirm(args?: AffirmInstructionParams, opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:889

Affirm this instruction (authorize)

Parameters

ParameterType

args?

AffirmInstructionParams

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Note

this method is of type OptionalArgsProcedureMethod, which means you can call affirm.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


affirmAsMediator()

affirmAsMediator(args?: AffirmAsMediatorParams, opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:908

Affirm this instruction as a mediator (authorize)

Parameters

ParameterType

args?

AffirmAsMediatorParams

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Note

this method is of type OptionalArgsProcedureMethod, which means you can call affirmAsMediator.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


details()

details(): Promise<InstructionDetails>

Defined in: src/api/entities/Instruction/index.ts:543

Retrieve information specific to this Instruction

Returns

Promise<InstructionDetails>

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)

executeManually()

executeManually(args?: ExecuteManualInstructionParams, opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:918

Executes an Instruction either of type SettleManual or a Failed instruction

Parameters

ParameterType

args?

ExecuteManualInstructionParams

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Note

this method is of type OptionalArgsProcedureMethod, which means you can call executeManually.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


exists()

exists(): Promise<boolean>

Defined in: src/api/entities/Instruction/index.ts:384

Determine whether this Instruction exists on chain (or existed and was pruned)

Returns

Promise<boolean>

Overrides

Entity.exists


generateOffChainAffirmationReceipt()

generateOffChainAffirmationReceipt(args: object): Promise<OffChainAffirmationReceipt>

Defined in: src/api/entities/Instruction/index.ts:1264

Generate an offchain affirmation receipt for a specific leg and UID

Parameters

ParameterTypeDescription

args

{ legId: BigNumber; metadata?: string; signer?: string | Account; signerKeyRingType?: SignerKeyRingType; uid: BigNumber; }

args.legId

BigNumber

index of the offchain leg in this instruction

args.metadata?

string

(optional) metadata to be associated with the receipt

args.signer?

string | Account

(optional) Signer to be used to generate receipt signature. Defaults to signing Account associated with the SDK

args.signerKeyRingType?

SignerKeyRingType

(optional) keyring type of the signer. Defaults to 'Sr25519'

args.uid

BigNumber

UID of the receipt

Returns

Promise<OffChainAffirmationReceipt>


getAffirmations()

getAffirmations(paginationOpts?: PaginationOptions | MiddlewarePaginationOptions): Promise<ResultSet<InstructionAffirmation>>

Defined in: src/api/entities/Instruction/index.ts:579

Retrieve every authorization generated by this Instruction (status and authorizing Identity)

Parameters

ParameterType

paginationOpts?

PaginationOptions | MiddlewarePaginationOptions

Returns

Promise<ResultSet<InstructionAffirmation>>

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)

getInvolvedPortfolios()

getInvolvedPortfolios(args: object): Promise<(DefaultPortfolio | NumberedPortfolio)[]>

Defined in: src/api/entities/Instruction/index.ts:985

Retrieve all the involved portfolios in this Instruction where the given identity is a custodian of

Parameters

ParameterType

args

{ did: string; }

args.did

string

Returns

Promise<(DefaultPortfolio | NumberedPortfolio)[]>


getLegs()

getLegs(paginationOpts?: PaginationOptions | MiddlewarePaginationOptions): Promise<ResultSet<Leg>>

Defined in: src/api/entities/Instruction/index.ts:768

Retrieve all legs of this Instruction

Parameters

ParameterType

paginationOpts?

PaginationOptions | MiddlewarePaginationOptions

Returns

Promise<ResultSet<Leg>>

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)

getLockedInfo()

getLockedInfo(): Promise<InstructionLockedInfo>

Defined in: src/api/entities/Instruction/index.ts:296

Retrieve whether the Instruction is locked for execution on chain

Returns

Promise<InstructionLockedInfo>


getMediators()

getMediators(): Promise<MediatorAffirmation[]>

Defined in: src/api/entities/Instruction/index.ts:1037

Returns the mediators for the Instruction, along with their affirmation status

Returns

Promise<MediatorAffirmation[]>

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)

getOffChainAffirmationForLeg()

getOffChainAffirmationForLeg(args: object): Promise<AffirmationStatus>

Defined in: src/api/entities/Instruction/index.ts:1182

Returns affirmation status for a specific offchain leg in this Instruction

Parameters

ParameterTypeDescription

args

{ legId: BigNumber; }

args.legId

BigNumber

index of the leg whose affirmation status is to be fetched

Returns

Promise<AffirmationStatus>

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)

getOffChainAffirmations()

getOffChainAffirmations(): Promise<OffChainAffirmation[]>

Defined in: src/api/entities/Instruction/index.ts:1117

Returns affirmation statuses for offchain legs in this Instruction

Returns

Promise<OffChainAffirmation[]>

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)

getPendingAffirmationCount()

getPendingAffirmationCount(): Promise<BigNumber>

Defined in: src/api/entities/Instruction/index.ts:254

Get the number of affirmations pending before instruction can be executed

Returns

Promise<BigNumber>

Note

The count is returned as 0 for pruned instructions as well


getStatus()

getStatus(): Promise<InstructionStatusResult>

Defined in: src/api/entities/Instruction/index.ts:813

Retrieve current status of this Instruction

Returns

Promise<InstructionStatusResult>

Note

uses the middlewareV2


isEqual()

isEqual(entity: Entity<unknown, unknown>): boolean

Defined in: src/api/entities/Entity.ts:61

Determine whether this Entity is the same as another one

Parameters

ParameterType

entity

Entity<unknown, unknown>

Returns

boolean

Inherited from

Entity.isEqual


isExecuted()

isExecuted(): Promise<boolean>

Defined in: src/api/entities/Instruction/index.ts:223

Retrieve whether the Instruction has already been executed and pruned from the chain.

Returns

Promise<boolean>


isPending()

isPending(): Promise<boolean>

Defined in: src/api/entities/Instruction/index.ts:275

Retrieve whether the Instruction is still pending on chain

Returns

Promise<boolean>


lockForExecution()

lockForExecution(opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:935

Locks an Instruction of type SettleAfterLock for execution. Only a mediator of the instruction can lock the instruction.

Parameters

ParameterType

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, 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 and have valid CDD claims
  • all assets' statistics are still valid
  • there are no frozen assets

Throws

if any of the above conditions are not met

Note

this method is of type NoArgsProcedureMethod, which means you can call lockForExecution.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


onStatusChange()

onStatusChange(callback: SubCallback<InstructionStatus>): Promise<UnsubCallback>

Defined in: src/api/entities/Instruction/index.ts:350

Retrieve current status of the Instruction. This can be subscribed to know if instruction fails

Parameters

ParameterType

callback

SubCallback<InstructionStatus>

Returns

Promise<UnsubCallback>

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.


reject()

reject(args?: RejectInstructionParams, opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:884

Reject this instruction

Parameters

ParameterType

args?

RejectInstructionParams

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, 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

Note

this method is of type OptionalArgsProcedureMethod, which means you can call reject.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


rejectAsMediator()

rejectAsMediator(opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:903

Reject this instruction as a mediator

Parameters

ParameterType

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, 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

Note

this method is of type NoArgsProcedureMethod, which means you can call rejectAsMediator.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


toHuman()

toHuman(): string

Defined in: src/api/entities/Instruction/index.ts:978

Return the Instruction's ID

Returns

string

Overrides

Entity.toHuman


withdraw()

withdraw(args?: WithdrawInstructionParams, opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:894

Withdraw affirmation from this instruction (unauthorize)

Parameters

ParameterType

args?

WithdrawInstructionParams

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Note

this method is of type OptionalArgsProcedureMethod, which means you can call withdraw.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


withdrawAsMediator()

withdrawAsMediator(opts?: ProcedureOpts): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: src/api/entities/Instruction/index.ts:913

Withdraw affirmation from this instruction as a mediator (unauthorize)

Parameters

ParameterType

opts?

ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Note

this method is of type NoArgsProcedureMethod, which means you can call withdrawAsMediator.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it


generateUuid()

static generateUuid<Identifiers>(identifiers: Identifiers): string

Defined in: src/api/entities/Entity.ts:14

Generate the Entity's UUID from its identifying properties

Type Parameters

Type Parameter

Identifiers

Parameters

ParameterTypeDescription

identifiers

Identifiers

Returns

string

Inherited from

Entity.generateUuid


unserialize()

static unserialize<Identifiers>(serialized: string): Identifiers

Defined in: src/api/entities/Entity.ts:23

Unserialize a UUID into its Unique Identifiers

Type Parameters

Type Parameter

Identifiers

Parameters

ParameterTypeDescription

serialized

string

UUID to unserialize

Returns

Identifiers

Inherited from

Entity.unserialize