Decode log arguments in awaitTransactionSuccessAsync
, when ABI is recognized.
This commit is contained in:
parent
aa29526ae4
commit
df746c5ff4
@ -51,6 +51,8 @@ import {
|
|||||||
TestStaticCallReceiverContract,
|
TestStaticCallReceiverContract,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
@ -136,17 +138,20 @@ describe('Exchange core', () => {
|
|||||||
artifacts.Exchange,
|
artifacts.Exchange,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||||
);
|
);
|
||||||
maliciousWallet = maliciousValidator = await TestStaticCallReceiverContract.deployFrom0xArtifactAsync(
|
maliciousWallet = maliciousValidator = await TestStaticCallReceiverContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.TestStaticCallReceiver,
|
artifacts.TestStaticCallReceiver,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
);
|
);
|
||||||
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
|
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.ReentrantERC20Token,
|
artifacts.ReentrantERC20Token,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -379,7 +384,7 @@ describe('Exchange core', () => {
|
|||||||
const initialTakerZrxBalance = await zrxToken.balanceOf.callAsync(takerAddress);
|
const initialTakerZrxBalance = await zrxToken.balanceOf.callAsync(takerAddress);
|
||||||
const initialFeeRecipientZrxBalance = await zrxToken.balanceOf.callAsync(feeRecipientAddress);
|
const initialFeeRecipientZrxBalance = await zrxToken.balanceOf.callAsync(feeRecipientAddress);
|
||||||
|
|
||||||
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
const txReceipt = await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
|
||||||
|
|
||||||
const finalMakerBalanceA = await noReturnErc20Token.balanceOf.callAsync(makerAddress);
|
const finalMakerBalanceA = await noReturnErc20Token.balanceOf.callAsync(makerAddress);
|
||||||
const finalMakerBalanceB = await erc20TokenB.balanceOf.callAsync(makerAddress);
|
const finalMakerBalanceB = await erc20TokenB.balanceOf.callAsync(makerAddress);
|
||||||
|
@ -29,6 +29,8 @@ import {
|
|||||||
TestAssetProxyDispatcherContract,
|
TestAssetProxyDispatcherContract,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
@ -72,6 +74,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
artifacts.TestAssetProxyDispatcher,
|
artifacts.TestAssetProxyDispatcher,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
);
|
);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
|
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
|
||||||
|
@ -18,6 +18,8 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import { artifacts, TestExchangeInternalsContract } from '../src';
|
import { artifacts, TestExchangeInternalsContract } from '../src';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
artifacts.TestExchangeInternals,
|
artifacts.TestExchangeInternals,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
);
|
);
|
||||||
overflowErrorForSendTransaction = new Error(
|
overflowErrorForSendTransaction = new Error(
|
||||||
await getRevertReasonOrErrorMessageForSendTransactionAsync(RevertReason.Uint256Overflow),
|
await getRevertReasonOrErrorMessageForSendTransactionAsync(RevertReason.Uint256Overflow),
|
||||||
|
@ -29,6 +29,8 @@ import {
|
|||||||
TestExchangeInternalsContract,
|
TestExchangeInternalsContract,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -118,6 +120,7 @@ describe('matchOrders', () => {
|
|||||||
artifacts.Exchange,
|
artifacts.Exchange,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||||
);
|
);
|
||||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||||
@ -141,6 +144,7 @@ describe('matchOrders', () => {
|
|||||||
artifacts.ReentrantERC20Token,
|
artifacts.ReentrantERC20Token,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -175,6 +179,7 @@ describe('matchOrders', () => {
|
|||||||
artifacts.TestExchangeInternals,
|
artifacts.TestExchangeInternals,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -25,6 +25,8 @@ import {
|
|||||||
WalletContract,
|
WalletContract,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
@ -59,23 +61,27 @@ describe('MixinSignatureValidator', () => {
|
|||||||
artifacts.TestSignatureValidator,
|
artifacts.TestSignatureValidator,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
);
|
);
|
||||||
testWallet = await WalletContract.deployFrom0xArtifactAsync(
|
testWallet = await WalletContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.Wallet,
|
artifacts.Wallet,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
);
|
);
|
||||||
testValidator = await ValidatorContract.deployFrom0xArtifactAsync(
|
testValidator = await ValidatorContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.Validator,
|
artifacts.Validator,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
);
|
);
|
||||||
maliciousWallet = maliciousValidator = await TestStaticCallReceiverContract.deployFrom0xArtifactAsync(
|
maliciousWallet = maliciousValidator = await TestStaticCallReceiverContract.deployFrom0xArtifactAsync(
|
||||||
artifacts.TestStaticCallReceiver,
|
artifacts.TestStaticCallReceiver,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
);
|
);
|
||||||
signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts);
|
signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
|
@ -21,6 +21,8 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import { artifacts, ExchangeContract, ExchangeWrapper, ExchangeWrapperContract, WhitelistContract } from '../src/';
|
import { artifacts, ExchangeContract, ExchangeWrapper, ExchangeWrapperContract, WhitelistContract } from '../src/';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
@ -87,6 +89,7 @@ describe('Exchange transactions', () => {
|
|||||||
artifacts.Exchange,
|
artifacts.Exchange,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||||
);
|
);
|
||||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||||
@ -219,6 +222,7 @@ describe('Exchange transactions', () => {
|
|||||||
artifacts.ExchangeWrapper,
|
artifacts.ExchangeWrapper,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -333,6 +337,7 @@ describe('Exchange transactions', () => {
|
|||||||
artifacts.Whitelist,
|
artifacts.Whitelist,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
);
|
);
|
||||||
const isApproved = true;
|
const isApproved = true;
|
||||||
|
9
contracts/exchange/test/utils/dependency_artifacts.ts
Normal file
9
contracts/exchange/test/utils/dependency_artifacts.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { artifacts as erc1155Artifacts } from '@0x/contracts-erc1155';
|
||||||
|
import { artifacts as erc20Artifacts } from '@0x/contracts-erc20';
|
||||||
|
import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
|
||||||
|
|
||||||
|
export const dependencyArtifacts = {
|
||||||
|
...erc20Artifacts,
|
||||||
|
...erc721Artifacts,
|
||||||
|
...erc1155Artifacts,
|
||||||
|
};
|
@ -4,7 +4,6 @@ import { artifacts as erc721Artifacts } from '@0x/contracts-erc721';
|
|||||||
import {
|
import {
|
||||||
FillResults,
|
FillResults,
|
||||||
formatters,
|
formatters,
|
||||||
LogDecoder,
|
|
||||||
OrderInfo,
|
OrderInfo,
|
||||||
orderUtils,
|
orderUtils,
|
||||||
Web3ProviderEngine,
|
Web3ProviderEngine,
|
||||||
@ -22,16 +21,9 @@ import { AbiDecodedFillOrderData } from './types';
|
|||||||
export class ExchangeWrapper {
|
export class ExchangeWrapper {
|
||||||
private readonly _exchange: ExchangeContract;
|
private readonly _exchange: ExchangeContract;
|
||||||
private readonly _web3Wrapper: Web3Wrapper;
|
private readonly _web3Wrapper: Web3Wrapper;
|
||||||
private readonly _logDecoder: LogDecoder;
|
|
||||||
constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) {
|
constructor(exchangeContract: ExchangeContract, provider: Web3ProviderEngine | ZeroExProvider) {
|
||||||
this._exchange = exchangeContract;
|
this._exchange = exchangeContract;
|
||||||
this._web3Wrapper = new Web3Wrapper(provider);
|
this._web3Wrapper = new Web3Wrapper(provider);
|
||||||
this._logDecoder = new LogDecoder(this._web3Wrapper, {
|
|
||||||
...artifacts,
|
|
||||||
...erc20Artifacts,
|
|
||||||
...erc721Artifacts,
|
|
||||||
...erc1155Artifacts,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
public async fillOrderAsync(
|
public async fillOrderAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
@ -39,20 +31,18 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmount?: BigNumber } = {},
|
opts: { takerAssetFillAmount?: BigNumber } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount);
|
const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount);
|
||||||
const txHash = await this._exchange.fillOrder.sendTransactionAsync(
|
const txReceipt = await this._exchange.fillOrder.awaitTransactionSuccessAsync(
|
||||||
params.order,
|
params.order,
|
||||||
params.takerAssetFillAmount,
|
params.takerAssetFillAmount,
|
||||||
params.signature,
|
params.signature,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const txReceipt = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
|
||||||
return txReceipt;
|
return txReceipt;
|
||||||
}
|
}
|
||||||
public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
public async cancelOrderAsync(signedOrder: SignedOrder, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = orderUtils.createCancel(signedOrder);
|
const params = orderUtils.createCancel(signedOrder);
|
||||||
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(params.order, { from });
|
const txReceipt = await this._exchange.cancelOrder.awaitTransactionSuccessAsync(params.order, { from });
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async fillOrKillOrderAsync(
|
public async fillOrKillOrderAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
@ -60,14 +50,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmount?: BigNumber } = {},
|
opts: { takerAssetFillAmount?: BigNumber } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount);
|
const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount);
|
||||||
const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
|
const txReceipt = await this._exchange.fillOrKillOrder.awaitTransactionSuccessAsync(
|
||||||
params.order,
|
params.order,
|
||||||
params.takerAssetFillAmount,
|
params.takerAssetFillAmount,
|
||||||
params.signature,
|
params.signature,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async fillOrderNoThrowAsync(
|
public async fillOrderNoThrowAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
@ -75,14 +64,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmount?: BigNumber; gas?: number } = {},
|
opts: { takerAssetFillAmount?: BigNumber; gas?: number } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount);
|
const params = orderUtils.createFill(signedOrder, opts.takerAssetFillAmount);
|
||||||
const txHash = await this._exchange.fillOrderNoThrow.sendTransactionAsync(
|
const txReceipt = await this._exchange.fillOrderNoThrow.awaitTransactionSuccessAsync(
|
||||||
params.order,
|
params.order,
|
||||||
params.takerAssetFillAmount,
|
params.takerAssetFillAmount,
|
||||||
params.signature,
|
params.signature,
|
||||||
{ from, gas: opts.gas },
|
{ from, gas: opts.gas },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async batchFillOrdersAsync(
|
public async batchFillOrdersAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -90,14 +78,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmounts?: BigNumber[] } = {},
|
opts: { takerAssetFillAmounts?: BigNumber[] } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts);
|
const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts);
|
||||||
const txHash = await this._exchange.batchFillOrders.sendTransactionAsync(
|
const txReceipt = await this._exchange.batchFillOrders.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.takerAssetFillAmounts,
|
params.takerAssetFillAmounts,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async batchFillOrKillOrdersAsync(
|
public async batchFillOrKillOrdersAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -105,14 +92,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmounts?: BigNumber[] } = {},
|
opts: { takerAssetFillAmounts?: BigNumber[] } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts);
|
const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts);
|
||||||
const txHash = await this._exchange.batchFillOrKillOrders.sendTransactionAsync(
|
const txReceipt = await this._exchange.batchFillOrKillOrders.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.takerAssetFillAmounts,
|
params.takerAssetFillAmounts,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async batchFillOrdersNoThrowAsync(
|
public async batchFillOrdersNoThrowAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -120,14 +106,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmounts?: BigNumber[]; gas?: number } = {},
|
opts: { takerAssetFillAmounts?: BigNumber[]; gas?: number } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts);
|
const params = formatters.createBatchFill(orders, opts.takerAssetFillAmounts);
|
||||||
const txHash = await this._exchange.batchFillOrdersNoThrow.sendTransactionAsync(
|
const txReceipt = await this._exchange.batchFillOrdersNoThrow.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.takerAssetFillAmounts,
|
params.takerAssetFillAmounts,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from, gas: opts.gas },
|
{ from, gas: opts.gas },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async marketSellOrdersAsync(
|
public async marketSellOrdersAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -135,14 +120,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmount: BigNumber },
|
opts: { takerAssetFillAmount: BigNumber },
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount);
|
const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount);
|
||||||
const txHash = await this._exchange.marketSellOrders.sendTransactionAsync(
|
const txReceipt = await this._exchange.marketSellOrders.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.takerAssetFillAmount,
|
params.takerAssetFillAmount,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async marketSellOrdersNoThrowAsync(
|
public async marketSellOrdersNoThrowAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -150,14 +134,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { takerAssetFillAmount: BigNumber; gas?: number },
|
opts: { takerAssetFillAmount: BigNumber; gas?: number },
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount);
|
const params = formatters.createMarketSellOrders(orders, opts.takerAssetFillAmount);
|
||||||
const txHash = await this._exchange.marketSellOrdersNoThrow.sendTransactionAsync(
|
const txReceipt = await this._exchange.marketSellOrdersNoThrow.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.takerAssetFillAmount,
|
params.takerAssetFillAmount,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from, gas: opts.gas },
|
{ from, gas: opts.gas },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async marketBuyOrdersAsync(
|
public async marketBuyOrdersAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -165,14 +148,13 @@ export class ExchangeWrapper {
|
|||||||
opts: { makerAssetFillAmount: BigNumber },
|
opts: { makerAssetFillAmount: BigNumber },
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount);
|
const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount);
|
||||||
const txHash = await this._exchange.marketBuyOrders.sendTransactionAsync(
|
const txReceipt = await this._exchange.marketBuyOrders.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.makerAssetFillAmount,
|
params.makerAssetFillAmount,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async marketBuyOrdersNoThrowAsync(
|
public async marketBuyOrdersNoThrowAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
@ -180,50 +162,45 @@ export class ExchangeWrapper {
|
|||||||
opts: { makerAssetFillAmount: BigNumber; gas?: number },
|
opts: { makerAssetFillAmount: BigNumber; gas?: number },
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount);
|
const params = formatters.createMarketBuyOrders(orders, opts.makerAssetFillAmount);
|
||||||
const txHash = await this._exchange.marketBuyOrdersNoThrow.sendTransactionAsync(
|
const txReceipt = await this._exchange.marketBuyOrdersNoThrow.awaitTransactionSuccessAsync(
|
||||||
params.orders,
|
params.orders,
|
||||||
params.makerAssetFillAmount,
|
params.makerAssetFillAmount,
|
||||||
params.signatures,
|
params.signatures,
|
||||||
{ from, gas: opts.gas },
|
{ from, gas: opts.gas },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async batchCancelOrdersAsync(
|
public async batchCancelOrdersAsync(
|
||||||
orders: SignedOrder[],
|
orders: SignedOrder[],
|
||||||
from: string,
|
from: string,
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = formatters.createBatchCancel(orders);
|
const params = formatters.createBatchCancel(orders);
|
||||||
const txHash = await this._exchange.batchCancelOrders.sendTransactionAsync(params.orders, { from });
|
const txReceipt = await this._exchange.batchCancelOrders.awaitTransactionSuccessAsync(params.orders, { from });
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const txHash = await this._exchange.cancelOrdersUpTo.sendTransactionAsync(salt, { from });
|
const txReceipt = await this._exchange.cancelOrdersUpTo.awaitTransactionSuccessAsync(salt, { from });
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async registerAssetProxyAsync(
|
public async registerAssetProxyAsync(
|
||||||
assetProxyAddress: string,
|
assetProxyAddress: string,
|
||||||
from: string,
|
from: string,
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const txHash = await this._exchange.registerAssetProxy.sendTransactionAsync(assetProxyAddress, { from });
|
const txReceipt = await this._exchange.registerAssetProxy.awaitTransactionSuccessAsync(assetProxyAddress, { from });
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async executeTransactionAsync(
|
public async executeTransactionAsync(
|
||||||
signedTx: SignedZeroExTransaction,
|
signedTx: SignedZeroExTransaction,
|
||||||
from: string,
|
from: string,
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const txHash = await this._exchange.executeTransaction.sendTransactionAsync(
|
const txReceipt = await this._exchange.executeTransaction.awaitTransactionSuccessAsync(
|
||||||
signedTx.salt,
|
signedTx.salt,
|
||||||
signedTx.signerAddress,
|
signedTx.signerAddress,
|
||||||
signedTx.data,
|
signedTx.data,
|
||||||
signedTx.signature,
|
signedTx.signature,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise<BigNumber> {
|
public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise<BigNumber> {
|
||||||
const filledAmount = await this._exchange.filled.callAsync(orderHashHex);
|
const filledAmount = await this._exchange.filled.callAsync(orderHashHex);
|
||||||
@ -251,15 +228,14 @@ export class ExchangeWrapper {
|
|||||||
from: string,
|
from: string,
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight);
|
const params = orderUtils.createMatchOrders(signedOrderLeft, signedOrderRight);
|
||||||
const txHash = await this._exchange.matchOrders.sendTransactionAsync(
|
const txReceipt = await this._exchange.matchOrders.awaitTransactionSuccessAsync(
|
||||||
params.left,
|
params.left,
|
||||||
params.right,
|
params.right,
|
||||||
params.leftSignature,
|
params.leftSignature,
|
||||||
params.rightSignature,
|
params.rightSignature,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
return txReceipt;
|
||||||
return tx;
|
|
||||||
}
|
}
|
||||||
public async getFillOrderResultsAsync(
|
public async getFillOrderResultsAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
|
@ -37,6 +37,7 @@ import 'make-promises-safe';
|
|||||||
import { artifacts, ExchangeContract, ExchangeFillEventArgs } from '../../src';
|
import { artifacts, ExchangeContract, ExchangeFillEventArgs } from '../../src';
|
||||||
|
|
||||||
import { AssetWrapper } from './asset_wrapper';
|
import { AssetWrapper } from './asset_wrapper';
|
||||||
|
import { dependencyArtifacts } from './dependency_artifacts';
|
||||||
import { ExchangeWrapper } from './exchange_wrapper';
|
import { ExchangeWrapper } from './exchange_wrapper';
|
||||||
import { OrderFactoryFromScenario } from './order_factory_from_scenario';
|
import { OrderFactoryFromScenario } from './order_factory_from_scenario';
|
||||||
import { SimpleAssetBalanceAndProxyAllowanceFetcher } from './simple_asset_balance_and_proxy_allowance_fetcher';
|
import { SimpleAssetBalanceAndProxyAllowanceFetcher } from './simple_asset_balance_and_proxy_allowance_fetcher';
|
||||||
@ -101,6 +102,7 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
|
|||||||
artifacts.Exchange,
|
artifacts.Exchange,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
);
|
);
|
||||||
const exchangeWrapper = new ExchangeWrapper(exchangeContract, provider);
|
const exchangeWrapper = new ExchangeWrapper(exchangeContract, provider);
|
||||||
|
@ -24,6 +24,8 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import { artifacts, ExchangeContract, ExchangeWrapper, ReentrantERC20TokenContract } from '../src';
|
import { artifacts, ExchangeContract, ExchangeWrapper, ReentrantERC20TokenContract } from '../src';
|
||||||
|
|
||||||
|
import { dependencyArtifacts } from './utils/dependency_artifacts';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||||
@ -87,6 +89,7 @@ describe('Exchange wrappers', () => {
|
|||||||
artifacts.Exchange,
|
artifacts.Exchange,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||||
);
|
);
|
||||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||||
@ -110,6 +113,7 @@ describe('Exchange wrappers', () => {
|
|||||||
artifacts.ReentrantERC20Token,
|
artifacts.ReentrantERC20Token,
|
||||||
provider,
|
provider,
|
||||||
txDefaults,
|
txDefaults,
|
||||||
|
dependencyArtifacts,
|
||||||
exchange.address,
|
exchange.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import { SimpleContractArtifact } from '@0x/types';
|
|||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
import { assert } from '@0x/assert';
|
import { assert } from '@0x/assert';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
|
import * as _ from 'lodash';
|
||||||
// tslint:enable:no-unused-variable
|
// tslint:enable:no-unused-variable
|
||||||
|
|
||||||
{{#if events}}
|
{{#if events}}
|
||||||
@ -63,6 +64,7 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
artifact: ContractArtifact | SimpleContractArtifact,
|
artifact: ContractArtifact | SimpleContractArtifact,
|
||||||
supportedProvider: SupportedProvider,
|
supportedProvider: SupportedProvider,
|
||||||
txDefaults: Partial<TxData>,
|
txDefaults: Partial<TxData>,
|
||||||
|
artifactDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
|
||||||
{{> typed_params inputs=ctor.inputs}}
|
{{> typed_params inputs=ctor.inputs}}
|
||||||
): Promise<{{contractName}}Contract> {
|
): Promise<{{contractName}}Contract> {
|
||||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||||
@ -76,13 +78,15 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||||
const abi = artifact.compilerOutput.abi;
|
const abi = artifact.compilerOutput.abi;
|
||||||
return {{contractName}}Contract.deployAsync(bytecode, abi, provider, txDefaults, {{> params inputs=ctor.inputs}});
|
const abiDependencies = _.mapValues(artifactDependencies, (artifactDependency: ContractArtifact | SimpleContractArtifact) => {return artifactDependency.compilerOutput.abi});
|
||||||
|
return {{contractName}}Contract.deployAsync(bytecode, abi, provider, txDefaults, abiDependencies, {{> params inputs=ctor.inputs}});
|
||||||
}
|
}
|
||||||
public static async deployAsync(
|
public static async deployAsync(
|
||||||
bytecode: string,
|
bytecode: string,
|
||||||
abi: ContractAbi,
|
abi: ContractAbi,
|
||||||
supportedProvider: SupportedProvider,
|
supportedProvider: SupportedProvider,
|
||||||
txDefaults: Partial<TxData>,
|
txDefaults: Partial<TxData>,
|
||||||
|
abiDependencies: { [contractName: string]: ContractAbi },
|
||||||
{{> typed_params inputs=ctor.inputs}}
|
{{> typed_params inputs=ctor.inputs}}
|
||||||
): Promise<{{contractName}}Contract> {
|
): Promise<{{contractName}}Contract> {
|
||||||
assert.isHexString('bytecode', bytecode);
|
assert.isHexString('bytecode', bytecode);
|
||||||
@ -111,7 +115,7 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
logUtils.log(`transactionHash: ${txHash}`);
|
logUtils.log(`transactionHash: ${txHash}`);
|
||||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
logUtils.log(`{{contractName}} successfully deployed at ${txReceipt.contractAddress}`);
|
logUtils.log(`{{contractName}} successfully deployed at ${txReceipt.contractAddress}`);
|
||||||
const contractInstance = new {{contractName}}Contract(txReceipt.contractAddress as string, provider, txDefaults);
|
const contractInstance = new {{contractName}}Contract(txReceipt.contractAddress as string, provider, txDefaults, abiDependencies);
|
||||||
contractInstance.constructorArgs = [{{> params inputs=ctor.inputs}}];
|
contractInstance.constructorArgs = [{{> params inputs=ctor.inputs}}];
|
||||||
return contractInstance;
|
return contractInstance;
|
||||||
}
|
}
|
||||||
@ -213,8 +217,8 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
);
|
);
|
||||||
return logs;
|
return logs;
|
||||||
}{{/if}}
|
}{{/if}}
|
||||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
|
||||||
super('{{contractName}}', {{contractName}}Contract.ABI(), address, supportedProvider, txDefaults);
|
super('{{contractName}}', {{contractName}}Contract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
|
||||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);{{#if events}}
|
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);{{#if events}}
|
||||||
this._subscriptionManager = new SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>(
|
this._subscriptionManager = new SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>(
|
||||||
{{contractName}}Contract.ABI(),
|
{{contractName}}Contract.ABI(),
|
||||||
|
@ -186,6 +186,7 @@ export class BaseContract {
|
|||||||
address: string,
|
address: string,
|
||||||
supportedProvider: SupportedProvider,
|
supportedProvider: SupportedProvider,
|
||||||
callAndTxnDefaults?: Partial<CallData>,
|
callAndTxnDefaults?: Partial<CallData>,
|
||||||
|
abiDependencies?: { [contractName: string]: ContractAbi },
|
||||||
) {
|
) {
|
||||||
assert.isString('contractName', contractName);
|
assert.isString('contractName', contractName);
|
||||||
assert.isETHAddressHex('address', address);
|
assert.isETHAddressHex('address', address);
|
||||||
@ -209,6 +210,10 @@ export class BaseContract {
|
|||||||
const abiEncoder = new AbiEncoder.Method(methodAbi);
|
const abiEncoder = new AbiEncoder.Method(methodAbi);
|
||||||
const functionSignature = abiEncoder.getSignature();
|
const functionSignature = abiEncoder.getSignature();
|
||||||
this._abiEncoderByFunctionSignature[functionSignature] = abiEncoder;
|
this._abiEncoderByFunctionSignature[functionSignature] = abiEncoder;
|
||||||
|
this._web3Wrapper.abiDecoder.addABI(abi, contractName);
|
||||||
|
});
|
||||||
|
_.each(abiDependencies, (abi, name) => {
|
||||||
|
this._web3Wrapper.abiDecoder.addABI(abi, name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user