In @0x/abi-gen-templates: Add awaitTransactionSuccessAsync() to transaction template.

This commit is contained in:
Lawrence Forman
2019-04-26 13:58:23 -04:00
parent a59cd67acf
commit 6d835f5cc1
3 changed files with 33 additions and 2 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "2.1.0",
"changes": [
{
"note": "add `awaitTransactionSuccessAsync()` to `tx.handlebars`",
"pr": TODO
}
]
},
{
"version": "2.0.2",
"changes": [

View File

@@ -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';

View File

@@ -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> = {},