-
Notifications
You must be signed in to change notification settings - Fork 11
base.PolymeshTransactionBatch.PolymeshTransactionBatch
base/PolymeshTransactionBatch.PolymeshTransactionBatch
Wrapper class for a batch of Polymesh Transactions
Name | Type |
---|---|
ReturnValue |
ReturnValue |
TransformedReturnValue |
ReturnValue |
Args |
extends unknown [][] = unknown [][] |
-
PolymeshTransactionBase
<ReturnValue
,TransformedReturnValue
>↳
PolymeshTransactionBatch
• Optional
blockHash: string
hash of the block where this transaction resides (status: Succeeded
, Failed
)
PolymeshTransactionBase.blockHash
base/PolymeshTransactionBase.ts:90
• Optional
blockNumber: BigNumber
number of the block where this transaction resides (status: Succeeded
, Failed
)
PolymeshTransactionBase.blockNumber
base/PolymeshTransactionBase.ts:95
• Optional
error: PolymeshError
stores errors thrown while running the transaction (status: Failed
, Aborted
)
base/PolymeshTransactionBase.ts:70
• Optional
receipt: ISubmittableResult
stores the transaction receipt (if successful)
PolymeshTransactionBase.receipt
base/PolymeshTransactionBase.ts:75
• status: TransactionStatus
= TransactionStatus.Idle
current status of the transaction
PolymeshTransactionBase.status
base/PolymeshTransactionBase.ts:65
• Optional
txHash: string
transaction hash (status: Running
, Succeeded
, Failed
)
PolymeshTransactionBase.txHash
base/PolymeshTransactionBase.ts:80
• Optional
txIndex: BigNumber
transaction index within its block (status: Succeeded
, Failed
)
PolymeshTransactionBase.txIndex
base/PolymeshTransactionBase.ts:85
• get
isSuccess(): boolean
returns true if transaction has completed successfully
boolean
PolymeshTransactionBase.isSuccess
• get
result(): TransformedReturnValue
returns the transaction result - this is the same value as the Promise run returns
Note
it is generally preferable to await
the Promise
returned by transaction.run() instead of reading this property
Throws
if the transaction.isSuccess property is false — be sure to check that before accessing!
TransformedReturnValue
PolymeshTransactionBase.result
• get
transactions(): MapTxData
<Args
>
transactions in the batch with their respective arguments
MapTxData
<Args
>
▸ getTotalFees(): Promise
<PayingAccountFees
>
Retrieve a breakdown of the fees required to run this transaction, as well as the Account responsible for paying them
Note
these values might be inaccurate if the transaction is run at a later time. This can be due to a governance vote or other chain related factors (like modifications to a specific subsidizer relationship or a chain upgrade)
Promise
<PayingAccountFees
>
PolymeshTransactionBase.getTotalFees
▸ onProcessedByMiddleware(listener
): UnsubCallback
Subscribe to the results of this transaction being processed by the indexing service (and as such, available to the middleware)
Note
this event will be fired even if the queue fails
Throws
if the middleware wasn't enabled when instantiating the SDK client
Name | Type | Description |
---|---|---|
listener |
(err? : PolymeshError ) => void
|
callback function that will be called whenever the middleware is updated with the latest data. If there is an error (timeout or middleware offline) it will be passed to this callback |
unsubscribe function
PolymeshTransactionBase.onProcessedByMiddleware
▸ onStatusChange(listener
): UnsubCallback
Subscribe to status changes
Name | Type | Description |
---|---|---|
listener |
(transaction : GenericPolymeshTransaction <ReturnValue , TransformedReturnValue >) => void
|
callback function that will be called whenever the status changes |
unsubscribe function
PolymeshTransactionBase.onStatusChange
▸ run(): Promise
<TransformedReturnValue
>
Run the transaction, update its status and return a result if applicable. Certain transactions create Entities on the blockchain, and those Entities are returned for convenience. For example, when running a transaction that creates an Asset, the Asset itself is returned
Promise
<TransformedReturnValue
>
▸ splitTransactions(): (PolymeshTransaction
<void
, void
, unknown
[]> | PolymeshTransaction
<ReturnValue
, TransformedReturnValue
, unknown
[]>)[]
Splits this batch into its individual transactions to be run separately. This is useful if the caller is being subsidized, since batches cannot be run by subsidized Accounts
Note
the transactions returned by this method must be run in the same order they appear in the array to guarantee the same behavior. If run out of order, an error will be thrown. The result that would be obtained by running the batch is returned by running the last transaction in the array
Example
const createAssetTx = await sdk.assets.createAsset(...);
let ticker: string;
if (isPolymeshTransactionBatch<Asset>(createAssetTx)) {
const transactions = createAssetTx.splitTransactions();
for (let i = 0; i < length; i += 1) {
const result = await transactions[i].run();
if (isAsset(result)) {
({ticker} = result)
}
}
} else {
({ ticker } = await createAssetTx.run());
}
console.log(`New Asset created! Ticker: ${ticker}`);
(PolymeshTransaction
<void
, void
, unknown
[]> | PolymeshTransaction
<ReturnValue
, TransformedReturnValue
, unknown
[]>)[]
▸ supportsSubsidy(): boolean
Note
batches can't be subsidized. If the caller is subsidized, they should use splitTransactions
and
run each transaction separately
boolean
Entities
- Account
- Asset
- Authorization Request
- Checkpoint
- Checkpoint Schedule
- Corporate Action
- Corporate Action Base
- Custom Permission Group
- Default Portfolio
- Default Trusted Claim Issuer
- Dividend Distribution
- Entity
- Identity
- Instruction
- Known Permission Group
- Metadata Entry
- Multi Sig Proposal
- Numbered Portfolio
- Offering
- Permission Group
- Portfolio
- Subsidies
- Subsidy
- Ticker Reservation
- Venue
- Authorizations