Reference / Modules / client / VaultState
Class: VaultState
client.VaultState
A State instance is a state in the "state machine" sense. It comes with some behavior and state transition methods. A state transition method returns an instance of the next state given the executed operation, which discards current object.
This class should be extended by client class. It provides method enabling the client class to query if it was already discarded or not as well as methods actually discarding the state.
Hierarchy
-
↳
VaultState
Table of contents
Constructors
Properties
Accessors
- acceptedVaultTransferRequests
- balances
- cancelledVaultTransferRequests
- discarded
- pendingVaultTransferRequests
- rejectedVaultTransferRequests
- transactions
- vaultAccount
- vaultTransferRequestsHistory
Methods
- _cancelVaultTransferRequest
- _createVaultTransferRequest
- _refresh
- _resubmitVaultTransferRequest
- cancelVaultTransferRequest
- createVaultTransferRequest
- discard
- discardOnSuccess
- ensureCurrent
- finalizeOnSuccess
- getCurrentState
- getCurrentStateOrThrow
- recoveryTransferSubmittable
- refresh
- regularTransferSubmittable
- resubmitVaultTransferRequest
- syncDiscardOnSuccess
- create
- getDefinedRecoveredAddress
- getVault
- newTransactionClient
Constructors
constructor
• new VaultState(state
): VaultState
Parameters
Name | Type |
---|---|
state | VaultSharedState |
Returns
Overrides
Defined in
packages/client/src/Vault.ts:102
Properties
sharedState
• Private
sharedState: VaultSharedState
Defined in
packages/client/src/Vault.ts:107
Accessors
acceptedVaultTransferRequests
• get
acceptedVaultTransferRequests(): VaultTransferRequest
[]
Returns
Defined in
packages/client/src/Vault.ts:121
balances
• get
balances(): CoinBalance
[]
Returns
CoinBalance
[]
Defined in
packages/client/src/Vault.ts:346
cancelledVaultTransferRequests
• get
cancelledVaultTransferRequests(): VaultTransferRequest
[]
Returns
Defined in
packages/client/src/Vault.ts:113
discarded
• get
discarded(): boolean
Returns
boolean
Description
True if this state was discarded
Inherited from
State.discarded
Defined in
packages/client/src/State.ts:24
pendingVaultTransferRequests
• get
pendingVaultTransferRequests(): VaultTransferRequest
[]
Returns
Defined in
packages/client/src/Vault.ts:109
rejectedVaultTransferRequests
• get
rejectedVaultTransferRequests(): VaultTransferRequest
[]
Returns
Defined in
packages/client/src/Vault.ts:117
transactions
• get
transactions(): Transaction
[]
Returns
Defined in
packages/client/src/Vault.ts:342
vaultAccount
• get
vaultAccount(): ValidAccountId
Returns
ValidAccountId
Defined in
packages/client/src/Vault.ts:338
vaultTransferRequestsHistory
• get
vaultTransferRequestsHistory(): VaultTransferRequest
[]
Returns
Defined in
packages/client/src/Vault.ts:125
Methods
_cancelVaultTransferRequest
▸ _cancelVaultTransferRequest(legalOfficer
, request
, signer
, callback?
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
legalOfficer | LegalOfficer |
request | VaultTransferRequest |
signer | Signer |
callback? | SignCallback |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:226
_createVaultTransferRequest
▸ _createVaultTransferRequest(params
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
params | Object |
params.amount | Lgnt |
params.callback? | SignCallback |
params.destination | ValidAccountId |
params.legalOfficer | LegalOfficer |
params.signer | Signer |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:142
_refresh
▸ _refresh(): Promise
<VaultState
>
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:325
_resubmitVaultTransferRequest
▸ _resubmitVaultTransferRequest(legalOfficer
, request
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
legalOfficer | LegalOfficer |
request | VaultTransferRequest |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:296
cancelVaultTransferRequest
▸ cancelVaultTransferRequest(legalOfficer
, request
, signer
, callback?
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
legalOfficer | LegalOfficer |
request | VaultTransferRequest |
signer | Signer |
callback? | SignCallback |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:217
createVaultTransferRequest
▸ createVaultTransferRequest(params
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
params | Object |
params.amount | Lgnt |
params.callback? | SignCallback |
params.destination | ValidAccountId |
params.legalOfficer | LegalOfficer |
params.signer | Signer |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:132
discard
▸ discard(next
): void
Parameters
Name | Type |
---|---|
next | undefined | State |
Returns
void
Description
Discards current state. One must discard the state only
if the state transition was successfully executed. It may be safer to
use discardOnSuccess
.
Inherited from
Defined in
packages/client/src/State.ts:43
discardOnSuccess
▸ discardOnSuccess<T
, U
>(action
): Promise
<U
>
Type parameters
Name | Type |
---|---|
T | extends State |
U | extends State = T |
Parameters
Name | Type | Description |
---|---|---|
action | (current : T ) => Promise <U > | The state transition logic producing next state |
Returns
Promise
<U
>
Next state if state transition logic execution did not throw
Descripiton
Discards current state only if given state transition logic executed successfully (i.e. without throwing an error).
Inherited from
Defined in
packages/client/src/State.ts:55
ensureCurrent
▸ ensureCurrent(): void
Returns
void
Description
Throws an error if this state was discarded. This should be called by all public methods of client class.
Inherited from
Defined in
packages/client/src/State.ts:32
finalizeOnSuccess
▸ finalizeOnSuccess<T
>(action
): Promise
<void
>
Type parameters
Name | Type |
---|---|
T | extends State |
Parameters
Name | Type | Description |
---|---|---|
action | (current : T ) => Promise <void > | The state transition logic producing next state |
Returns
Promise
<void
>
Next state if state transition logic execution did not throw
Descripiton
Finalizes (i.e. replaces with no new state) current state only if given state transition logic executed successfully (i.e. without throwing an error).
Inherited from
Defined in
packages/client/src/State.ts:117
getCurrentState
▸ getCurrentState(): undefined
| State
Returns
undefined
| State
This state if not discareded or the current state or undefined when there is no current state.
Description
If the state has been discarded, provides the replacing current state if any.
Inherited from
Defined in
packages/client/src/State.ts:90
getCurrentStateOrThrow
▸ getCurrentStateOrThrow(): State
Returns
Inherited from
Defined in
packages/client/src/State.ts:102
recoveryTransferSubmittable
▸ recoveryTransferSubmittable(params
): Promise
<SubmittableExtrinsic
>
Parameters
Name | Type |
---|---|
params | Object |
params.amount | Lgnt |
params.destination | ValidAccountId |
Returns
Promise
<SubmittableExtrinsic
>
Defined in
packages/client/src/Vault.ts:191
refresh
▸ refresh(): Promise
<VaultState
>
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:321
regularTransferSubmittable
▸ regularTransferSubmittable(params
): Promise
<SubmittableExtrinsic
>
Parameters
Name | Type |
---|---|
params | Object |
params.amount | Lgnt |
params.destination | ValidAccountId |
Returns
Promise
<SubmittableExtrinsic
>
Defined in
packages/client/src/Vault.ts:206
resubmitVaultTransferRequest
▸ resubmitVaultTransferRequest(legalOfficer
, request
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
legalOfficer | LegalOfficer |
request | VaultTransferRequest |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:289
syncDiscardOnSuccess
▸ syncDiscardOnSuccess<T
, U
>(action
): U
Type parameters
Name | Type |
---|---|
T | extends State |
U | extends State = T |
Parameters
Name | Type | Description |
---|---|---|
action | (current : T ) => U | The state transition logic producing next state |
Returns
U
Next state if state transition logic execution did not throw
Descripiton
Same as discardOnSuccess
but with a synchronous action.
Inherited from
Defined in
packages/client/src/State.ts:73
create
▸ create(sharedState
): Promise
<VaultState
>
Parameters
Name | Type |
---|---|
sharedState | VaultStateCreationParameters |
Returns
Promise
<VaultState
>
Defined in
packages/client/src/Vault.ts:39
getDefinedRecoveredAddress
▸ getDefinedRecoveredAddress(sharedState
): ValidAccountId
Parameters
Name | Type |
---|---|
sharedState | VaultStateCreationParameters |
Returns
ValidAccountId
Defined in
packages/client/src/Vault.ts:95
getVault
▸ getVault(sharedState
): Vault
Parameters
Name | Type |
---|---|
sharedState | VaultStateCreationParameters |
Returns
Vault
Defined in
packages/client/src/Vault.ts:75
newTransactionClient
▸ newTransactionClient(vaultAddress
, sharedState
): TransactionClient
Parameters
Name | Type |
---|---|
vaultAddress | ValidAccountId |
sharedState | VaultStateCreationParameters |