api.entities.Instruction - PolymeshAssociation/polymesh-sdk GitHub Wiki

@polymeshassociation/polymesh-sdk / api/entities/Instruction

api/entities/Instruction

Classes

Instruction

Defined in: api/entities/Instruction/index.ts:117

Represents a settlement Instruction to be executed on a certain Venue

Extends

Properties

id

id: BigNumber

Defined in: api/entities/Instruction/index.ts:131

Unique identifier number of the instruction

uuid

uuid: string

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

Inherited from

Entity.uuid

Methods

affirm()

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

Defined in: api/entities/Instruction/index.ts:949

Affirm this instruction (authorize)

Parameters
Parameter Type
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?, opts?): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: api/entities/Instruction/index.ts:963

Affirm this instruction as a mediator (authorize)

Parameters
Parameter Type
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: api/entities/Instruction/index.ts:589

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?, opts?): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: api/entities/Instruction/index.ts:968

Executes an Instruction either of type SettleManual or a Failed instruction

Parameters
Parameter Type
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: api/entities/Instruction/index.ts:430

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

Returns

Promise<boolean>

Overrides

Entity.exists

generateOffChainAffirmationReceipt()

generateOffChainAffirmationReceipt(args): Promise<OffChainAffirmationReceipt>

Defined in: api/entities/Instruction/index.ts:1348

Generate an offchain affirmation receipt for a specific leg and UID

Parameters
Parameter Type Description
args { expiresAt: Date; legId: BigNumber; metadata?: string; signer?: string | Account; signerKeyRingType?: SignerKeyRingType; uid: BigNumber; } -
args.expiresAt Date timestamp at which the receipt expires and can no longer be used to affirm
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?): Promise<ResultSet<InstructionAffirmation>>

Defined in: api/entities/Instruction/index.ts:625

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

Parameters
Parameter Type
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): Promise<(DefaultPortfolio | NumberedPortfolio)[]>

Defined in: api/entities/Instruction/index.ts:1041

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

Parameters
Parameter Type
args { did: string; }
args.did string
Returns

Promise<(DefaultPortfolio | NumberedPortfolio)[]>

getLegs()

getLegs(paginationOpts?): Promise<ResultSet<Leg>>

Defined in: api/entities/Instruction/index.ts:828

Retrieve all legs of this Instruction

Parameters
Parameter Type
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)
getLegStatus()

getLegStatus(args): Promise<LegStatus>

Defined in: api/entities/Instruction/index.ts:1296

Returns the execution status of a specific leg in this Instruction

Parameters
Parameter Type Description
args { legId: BigNumber; } -
args.legId BigNumber index of the leg whose status is to be fetched
Returns

Promise<LegStatus>

getLockedInfo()

getLockedInfo(): Promise<InstructionLockedInfo>

Defined in: api/entities/Instruction/index.ts:289

Retrieve whether the Instruction is locked for execution on chain

Returns

Promise<InstructionLockedInfo>

getMediators()

getMediators(): Promise<MediatorAffirmation[]>

Defined in: api/entities/Instruction/index.ts:1093

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): Promise<AffirmationStatus>

Defined in: api/entities/Instruction/index.ts:1238

Returns affirmation status for a specific offchain leg in this Instruction

Parameters
Parameter Type Description
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: api/entities/Instruction/index.ts:1173

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: api/entities/Instruction/index.ts:247

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

getRelockStatus()

getRelockStatus(): Promise<InstructionRelockStatus>

Defined in: api/entities/Instruction/index.ts:342

Retrieve the relock cooldown status of the Instruction

Returns

Promise<InstructionRelockStatus>

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.

getStatus()

getStatus(): Promise<InstructionStatusResult>

Defined in: api/entities/Instruction/index.ts:873

Retrieve current status of this Instruction

Returns

Promise<InstructionStatusResult>

Note

uses the middlewareV2

isEqual()

isEqual(entity): boolean

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

Determine whether this Entity is the same as another one

Parameters
Parameter Type
entity Entity<unknown, unknown>
Returns

boolean

Inherited from

Entity.isEqual

isExecuted()

isExecuted(): Promise<boolean>

Defined in: api/entities/Instruction/index.ts:216

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

Returns

Promise<boolean>

isPending()

isPending(): Promise<boolean>

Defined in: api/entities/Instruction/index.ts:268

Retrieve whether the Instruction is still pending on chain

Returns

Promise<boolean>

lockForExecution()

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

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

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

Parameters
Parameter Type
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
  • 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): Promise<UnsubCallback>

Defined in: api/entities/Instruction/index.ts:396

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

Parameters
Parameter Type
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?, opts?): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: api/entities/Instruction/index.ts:944

Reject this instruction

Parameters
Parameter Type
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?): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: api/entities/Instruction/index.ts:958

Reject this instruction as a mediator

Parameters
Parameter Type
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: api/entities/Instruction/index.ts:1034

Return the Instruction's ID

Returns

string

Overrides

Entity.toHuman

unlockForExecution()

unlockForExecution(opts?): Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Defined in: api/entities/Instruction/index.ts:992

Unlocks an Instruction that is currently LockedForExecution, moving it back to Pending. Only a mediator of the instruction can unlock it.

Parameters
Parameter Type
opts? ProcedureOpts
Returns

Promise<GenericPolymeshTransaction<Instruction, Instruction>>

Note

After unlocking, the mediator must wait for the relock cooldown period (see getRelockStatus) before locking the instruction again. This gives other parties time to reject the instruction if they wish to back out.

Note

this method is of type NoArgsProcedureMethod, which means you can call unlockForExecution.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): string

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

Generate the Entity's UUID from its identifying properties

Type Parameters
Type Parameter
Identifiers
Parameters
Parameter Type Description
identifiers Identifiers -
Returns

string

Inherited from

Entity.generateUuid

unserialize()

static unserialize<Identifiers>(serialized): Identifiers

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

Unserialize a UUID into its Unique Identifiers

Type Parameters
Type Parameter
Identifiers
Parameters
Parameter Type Description
serialized string UUID to unserialize
Returns

Identifiers

Inherited from

Entity.unserialize

Interfaces

UniqueIdentifiers

Defined in: api/entities/Instruction/index.ts:107

Properties

id

id: BigNumber

Defined in: api/entities/Instruction/index.ts:108

⚠️ **GitHub.com Fallback** ⚠️