In @0x/abi-gen-templates: Add awaitTransactionSuccessAsync() to transaction template.
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "2.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "add `awaitTransactionSuccessAsync()` to `tx.handlebars`",
|
||||
"pr": TODO
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2.0.2",
|
||||
"changes": [
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, TxData, TxDataPayable, SupportedProvider } from 'ethereum-types';
|
||||
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract';
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
CallData,
|
||||
ContractAbi,
|
||||
ContractArtifact,
|
||||
DecodedLogArgs,
|
||||
MethodAbi,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
SupportedProvider,
|
||||
} from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
|
||||
@@ -25,6 +25,16 @@ public {{this.tsName}} = {
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
async awaitTransactionSuccessAsync(
|
||||
{{> typed_params inputs=inputs}}
|
||||
pollingIntervalMs?: number,
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
const self = this as any as {{contractName}}Contract;
|
||||
const txHash = await self.{{this.tsName}}.sendTransactionAsync({{> params input=inputs}});
|
||||
const receiptPromise = self._web3Wrapper.awaitTransactionSuccessAsync(txHash, pollingIntervalMs) as PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>;
|
||||
receiptPromise.txHash = txHash;
|
||||
return receiptPromise;
|
||||
},
|
||||
async estimateGasAsync(
|
||||
{{> typed_params inputs=inputs}}
|
||||
txData: Partial<TxData> = {},
|
||||
|
||||
Reference in New Issue
Block a user