updated contract wrappers

This commit is contained in:
Greg Hysen 2019-07-29 12:24:19 +02:00
parent c2f34baee0
commit 048e48b03a
20 changed files with 10166 additions and 11067 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,11 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { import { BaseContract,
BaseContract,
BlockRange, BlockRange,
EventCallback, EventCallback,
IndexedFilterValues, IndexedFilterValues,
SubscriptionManager, SubscriptionManager,PromiseWithTransactionHash } from '@0x/base-contract';
PromiseWithTransactionHash,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -31,7 +28,8 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
export type CoordinatorRegistryEventArgs = CoordinatorRegistryCoordinatorEndpointSetEventArgs; export type CoordinatorRegistryEventArgs =
| CoordinatorRegistryCoordinatorEndpointSetEventArgs;
export enum CoordinatorRegistryEvents { export enum CoordinatorRegistryEvents {
CoordinatorEndpointSet = 'CoordinatorEndpointSet', CoordinatorEndpointSet = 'CoordinatorEndpointSet',
@ -42,30 +40,38 @@ export interface CoordinatorRegistryCoordinatorEndpointSetEventArgs extends Deco
coordinatorEndpoint: string; coordinatorEndpoint: string;
} }
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
export class CoordinatorRegistryContract extends BaseContract { export class CoordinatorRegistryContract extends BaseContract {
public setCoordinatorEndpoint = { public setCoordinatorEndpoint = {
async sendTransactionAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
assert.isString('coordinatorEndpoint', coordinatorEndpoint); coordinatorEndpoint: string,
const self = (this as any) as CoordinatorRegistryContract; txData?: Partial<TxData> | undefined,
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); ): Promise<string> {
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( assert.isString('coordinatorEndpoint', coordinatorEndpoint);
{ const self = this as any as CoordinatorRegistryContract;
to: self.address, const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
...txData, ]);
data: encodedData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
}, {
self._web3Wrapper.getContractDefaults(), to: self.address,
self.setCoordinatorEndpoint.estimateGasAsync.bind(self, coordinatorEndpoint), ...txData,
); data: encodedData,
if (txDataWithDefaults.from !== undefined) { },
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self._web3Wrapper.getContractDefaults(),
} self.setCoordinatorEndpoint.estimateGasAsync.bind(
self,
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); coordinatorEndpoint
return txHash; ),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
coordinatorEndpoint: string, coordinatorEndpoint: string,
@ -73,45 +79,51 @@ export class CoordinatorRegistryContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData); const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( , txData);
txHashPromise, return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
(async (): Promise<TransactionReceiptWithDecodedLogs> => { txHashPromise,
// When the transaction hash resolves, wait for it to be mined. (async (): Promise<TransactionReceiptWithDecodedLogs> => {
return self._web3Wrapper.awaitTransactionSuccessAsync( // When the transaction hash resolves, wait for it to be mined.
await txHashPromise, return self._web3Wrapper.awaitTransactionSuccessAsync(
pollingIntervalMs, await txHashPromise,
timeoutMs, pollingIntervalMs,
); timeoutMs,
})(), );
); })(),
);
}, },
async estimateGasAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
assert.isString('coordinatorEndpoint', coordinatorEndpoint); coordinatorEndpoint: string,
const self = (this as any) as CoordinatorRegistryContract; txData?: Partial<TxData> | undefined,
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); ): Promise<number> {
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( assert.isString('coordinatorEndpoint', coordinatorEndpoint);
{ const self = this as any as CoordinatorRegistryContract;
to: self.address, const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
...txData, ]);
data: encodedData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
}, {
self._web3Wrapper.getContractDefaults(), to: self.address,
); ...txData,
if (txDataWithDefaults.from !== undefined) { data: encodedData,
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); },
} self._web3Wrapper.getContractDefaults(),
);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); if (txDataWithDefaults.from !== undefined) {
return gas; txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
}, },
async callAsync( async callAsync(
coordinatorEndpoint: string, coordinatorEndpoint: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -121,8 +133,9 @@ export class CoordinatorRegistryContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]); const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -131,24 +144,24 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)'); const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<void>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<void
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(coordinatorEndpoint: string): string { getABIEncodedTransactionData(
coordinatorEndpoint: string,
): string {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [ const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
coordinatorEndpoint, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -157,7 +170,8 @@ export class CoordinatorRegistryContract extends BaseContract {
coordinatorOperator: string, coordinatorOperator: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isString('coordinatorOperator', coordinatorOperator); assert.isString('coordinatorOperator', coordinatorOperator);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -167,10 +181,9 @@ export class CoordinatorRegistryContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator.toLowerCase()
coordinatorOperator.toLowerCase(), ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -179,33 +192,33 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)'); const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(coordinatorOperator: string): string { getABIEncodedTransactionData(
coordinatorOperator: string,
): string {
assert.isString('coordinatorOperator', coordinatorOperator); assert.isString('coordinatorOperator', coordinatorOperator);
const self = (this as any) as CoordinatorRegistryContract; const self = this as any as CoordinatorRegistryContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator.toLowerCase()
coordinatorOperator.toLowerCase(), ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>; private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>;
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<CoordinatorRegistryContract> { ): Promise<CoordinatorRegistryContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -218,17 +231,8 @@ export class CoordinatorRegistryContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return CoordinatorRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return CoordinatorRegistryContract.deployAsync(
bytecode,
abi,
provider,
txDefaults,
logDecodeDependenciesAbiOnly,
);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -245,13 +249,17 @@ export class CoordinatorRegistryContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -259,22 +267,18 @@ export class CoordinatorRegistryContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new CoordinatorRegistryContract( const contractInstance = new CoordinatorRegistryContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -283,12 +287,13 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
], ],
name: 'setCoordinatorEndpoint', name: 'setCoordinatorEndpoint',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -307,14 +312,16 @@ export class CoordinatorRegistryContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
inputs: [], inputs: [
outputs: [], ],
outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
}, },
{ {
anonymous: false, anonymous: false,
inputs: [ inputs: [
{ {
@ -329,7 +336,8 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
], ],
name: 'CoordinatorEndpointSet', name: 'CoordinatorEndpointSet',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -403,27 +411,15 @@ export class CoordinatorRegistryContract extends BaseContract {
); );
return logs; return logs;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string, super('CoordinatorRegistry', CoordinatorRegistryContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super(
'CoordinatorRegistry',
CoordinatorRegistryContract.ABI(),
address,
supportedProvider,
txDefaults,
logDecodeDependencies,
);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>( this._subscriptionManager = new SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>(
CoordinatorRegistryContract.ABI(), CoordinatorRegistryContract.ABI(),
this._web3Wrapper, this._web3Wrapper,
); );
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -23,144 +23,91 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
export class DutchAuctionContract extends BaseContract { export class DutchAuctionContract extends BaseContract {
public getAuctionDetails = { public getAuctionDetails = {
async sendTransactionAsync( async sendTransactionAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; txData?: Partial<TxData> | undefined,
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
const self = (this as any) as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const self = this as any as DutchAuctionContract;
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
[order], ]);
); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), self.getAuctionDetails.estimateGasAsync.bind(
self.getAuctionDetails.estimateGasAsync.bind(self, order), self,
); order
if (txDataWithDefaults.from !== undefined) { ),
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); );
} if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); }
return txHash;
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
txData?: Partial<TxData>, txData?: Partial<TxData>,
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
const self = (this as any) as DutchAuctionContract;
const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order, txData); const self = this as any as DutchAuctionContract;
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order
txHashPromise, , txData);
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
// When the transaction hash resolves, wait for it to be mined. txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
await txHashPromise, // When the transaction hash resolves, wait for it to be mined.
pollingIntervalMs, return self._web3Wrapper.awaitTransactionSuccessAsync(
timeoutMs, await txHashPromise,
); pollingIntervalMs,
})(), timeoutMs,
); );
})(),
);
}, },
async estimateGasAsync( async estimateGasAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
const self = (this as any) as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const self = this as any as DutchAuctionContract;
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
[order], ]);
); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), );
); if (txDataWithDefaults.from !== undefined) {
if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); }
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas;
return gas;
}, },
async callAsync( async callAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{ ): Promise<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber}
beginTimeSeconds: BigNumber; > {
endTimeSeconds: BigNumber;
beginAmount: BigNumber;
endAmount: BigNumber;
currentAmount: BigNumber;
currentTimeSeconds: BigNumber;
}> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -169,11 +116,9 @@ export class DutchAuctionContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as DutchAuctionContract; const self = this as any as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', ]);
[order],
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -182,266 +127,141 @@ export class DutchAuctionContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))');
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<{ const result = abiEncoder.strictDecodeReturnValue<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber}
beginTimeSeconds: BigNumber; >(rawCallResult);
endTimeSeconds: BigNumber;
beginAmount: BigNumber;
endAmount: BigNumber;
currentAmount: BigNumber;
currentTimeSeconds: BigNumber;
}>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(order: { getABIEncodedTransactionData(
makerAddress: string; order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string; const self = this as any as DutchAuctionContract;
makerAssetAmount: BigNumber; const abiEncodedTransactionData = self._strictEncodeArguments('getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))', [order
takerAssetAmount: BigNumber; ]);
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}): string {
const self = (this as any) as DutchAuctionContract;
const abiEncodedTransactionData = self._strictEncodeArguments(
'getAuctionDetails((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes))',
[order],
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public matchOrders = { public matchOrders = {
async sendTransactionAsync( async sendTransactionAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; assert.isString('buySignature', buySignature);
const encodedData = self._strictEncodeArguments( assert.isString('sellSignature', sellSignature);
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', const self = this as any as DutchAuctionContract;
[buyOrder, sellOrder, buySignature, sellSignature], const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
); sellOrder,
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( buySignature,
{ sellSignature
to: self.address, ]);
...txData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
data: encodedData, {
}, to: self.address,
self._web3Wrapper.getContractDefaults(), ...txData,
self.matchOrders.estimateGasAsync.bind(self, buyOrder, sellOrder, buySignature, sellSignature), data: encodedData,
); },
if (txDataWithDefaults.from !== undefined) { self._web3Wrapper.getContractDefaults(),
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self.matchOrders.estimateGasAsync.bind(
} self,
buyOrder,
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); sellOrder,
return txHash; buySignature,
sellSignature
),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
txData?: Partial<TxData>, txData?: Partial<TxData>,
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; assert.isString('buySignature', buySignature);
const txHashPromise = self.matchOrders.sendTransactionAsync( assert.isString('sellSignature', sellSignature);
buyOrder, const self = this as any as DutchAuctionContract;
sellOrder, const txHashPromise = self.matchOrders.sendTransactionAsync(buyOrder,
buySignature, sellOrder,
sellSignature, buySignature,
txData, sellSignature
); , txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
// When the transaction hash resolves, wait for it to be mined. // When the transaction hash resolves, wait for it to be mined.
return self._web3Wrapper.awaitTransactionSuccessAsync( return self._web3Wrapper.awaitTransactionSuccessAsync(
await txHashPromise, await txHashPromise,
pollingIntervalMs, pollingIntervalMs,
timeoutMs, timeoutMs,
); );
})(), })(),
); );
}, },
async estimateGasAsync( async estimateGasAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; assert.isString('buySignature', buySignature);
const encodedData = self._strictEncodeArguments( assert.isString('sellSignature', sellSignature);
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', const self = this as any as DutchAuctionContract;
[buyOrder, sellOrder, buySignature, sellSignature], const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
); sellOrder,
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( buySignature,
{ sellSignature
to: self.address, ]);
...txData, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
data: encodedData, {
}, to: self.address,
self._web3Wrapper.getContractDefaults(), ...txData,
); data: encodedData,
if (txDataWithDefaults.from !== undefined) { },
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self._web3Wrapper.getContractDefaults(),
} );
if (txDataWithDefaults.from !== undefined) {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
return gas; }
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
}, },
async callAsync( async callAsync(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string, buySignature: string,
sellSignature: string, sellSignature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{ ): Promise<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber}
left: { > {
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
right: {
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
leftMakerAssetSpreadAmount: BigNumber;
}> {
assert.isString('buySignature', buySignature); assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature); assert.isString('sellSignature', sellSignature);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -452,11 +272,12 @@ export class DutchAuctionContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as DutchAuctionContract; const self = this as any as DutchAuctionContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', sellOrder,
[buyOrder, sellOrder, buySignature, sellSignature], buySignature,
); sellSignature
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -465,82 +286,42 @@ export class DutchAuctionContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)');
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<{ const result = abiEncoder.strictDecodeReturnValue<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber}
left: { >(rawCallResult);
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
right: {
makerAssetFilledAmount: BigNumber;
takerAssetFilledAmount: BigNumber;
makerFeePaid: BigNumber;
takerFeePaid: BigNumber;
};
leftMakerAssetSpreadAmount: BigNumber;
}>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
buyOrder: { buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
takerAddress: string; buySignature: string,
feeRecipientAddress: string; sellSignature: string,
senderAddress: string; ): string {
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
sellOrder: {
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
buySignature: string,
sellSignature: string,
): string {
assert.isString('buySignature', buySignature); assert.isString('buySignature', buySignature);
assert.isString('sellSignature', sellSignature); assert.isString('sellSignature', sellSignature);
const self = (this as any) as DutchAuctionContract; const self = this as any as DutchAuctionContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', [buyOrder,
'matchOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),(address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),bytes,bytes)', sellOrder,
[buyOrder, sellOrder, buySignature, sellSignature], buySignature,
); sellSignature
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
_exchange: string, _exchange: string,
): Promise<DutchAuctionContract> { ): Promise<DutchAuctionContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -553,18 +334,9 @@ export class DutchAuctionContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return DutchAuctionContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, _exchange
{}, );
);
return DutchAuctionContract.deployAsync(
bytecode,
abi,
provider,
txDefaults,
logDecodeDependenciesAbiOnly,
_exchange,
);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -572,7 +344,7 @@ export class DutchAuctionContract extends BaseContract {
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi }, logDecodeDependencies: { [contractName: string]: ContractAbi },
_exchange: string, _exchange: string,
): Promise<DutchAuctionContract> { ): Promise<DutchAuctionContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -582,17 +354,20 @@ export class DutchAuctionContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[_exchange] = BaseContract._formatABIDataItemList( [_exchange
] = BaseContract._formatABIDataItemList(
constructorAbi.inputs, constructorAbi.inputs,
[_exchange], [_exchange
],
BaseContract._bigNumberToString, BaseContract._bigNumberToString,
); );
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, [_exchange]); const txData = deployInfo.encode(bytecode, [_exchange
]);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -600,22 +375,19 @@ export class DutchAuctionContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new DutchAuctionContract( const contractInstance = new DutchAuctionContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string, contractInstance.constructorArgs = [_exchange
provider, ];
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = [_exchange];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -670,7 +442,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
], ],
name: 'getAuctionDetails', name: 'getAuctionDetails',
@ -703,14 +475,14 @@ export class DutchAuctionContract extends BaseContract {
name: 'currentTimeSeconds', name: 'currentTimeSeconds',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -765,7 +537,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'sellOrder', name: 'sellOrder',
@ -819,7 +591,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'buySignature', name: 'buySignature',
@ -856,7 +628,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerFeePaid', name: 'takerFeePaid',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'right', name: 'right',
@ -878,27 +650,28 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerFeePaid', name: 'takerFeePaid',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'leftMakerAssetSpreadAmount', name: 'leftMakerAssetSpreadAmount',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
inputs: [ inputs: [
{ {
name: '_exchange', name: '_exchange',
type: 'address', type: 'address',
}, },
], ],
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -906,23 +679,11 @@ export class DutchAuctionContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string, super('DutchAuction', DutchAuctionContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super(
'DutchAuction',
DutchAuctionContract.ABI(),
address,
supportedProvider,
txDefaults,
logDecodeDependencies,
);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,11 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { import { BaseContract,
BaseContract,
BlockRange, BlockRange,
EventCallback, EventCallback,
IndexedFilterValues, IndexedFilterValues,
SubscriptionManager, SubscriptionManager,PromiseWithTransactionHash } from '@0x/base-contract';
PromiseWithTransactionHash,
} from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -31,7 +28,9 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
export type ERC20TokenEventArgs = ERC20TokenTransferEventArgs | ERC20TokenApprovalEventArgs; export type ERC20TokenEventArgs =
| ERC20TokenTransferEventArgs
| ERC20TokenApprovalEventArgs;
export enum ERC20TokenEvents { export enum ERC20TokenEvents {
Transfer = 'Transfer', Transfer = 'Transfer',
@ -50,6 +49,7 @@ export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs {
_value: BigNumber; _value: BigNumber;
} }
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -58,30 +58,33 @@ export class ERC20TokenContract extends BaseContract {
async sendTransactionAsync( async sendTransactionAsync(
_spender: string, _spender: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
...txData,
data: encodedData,
},
self._web3Wrapper.getContractDefaults(),
self.approve.estimateGasAsync.bind(
self,
_spender.toLowerCase(), _spender.toLowerCase(),
_value, _value
]); ),
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( );
{ if (txDataWithDefaults.from !== undefined) {
to: self.address, txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
...txData, }
data: encodedData,
}, const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
self._web3Wrapper.getContractDefaults(), return txHash;
self.approve.estimateGasAsync.bind(self, _spender.toLowerCase(), _value),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
_spender: string, _spender: string,
@ -90,55 +93,57 @@ export class ERC20TokenContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData); const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(),
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( _value
txHashPromise, , txData);
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
// When the transaction hash resolves, wait for it to be mined. txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
await txHashPromise, // When the transaction hash resolves, wait for it to be mined.
pollingIntervalMs, return self._web3Wrapper.awaitTransactionSuccessAsync(
timeoutMs, await txHashPromise,
); pollingIntervalMs,
})(), timeoutMs,
); );
})(),
);
}, },
async estimateGasAsync( async estimateGasAsync(
_spender: string, _spender: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_spender.toLowerCase(), _value
_value, ]);
]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), );
); if (txDataWithDefaults.from !== undefined) {
if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); }
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas;
return gas;
}, },
async callAsync( async callAsync(
_spender: string, _spender: string,
_value: BigNumber, _value: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -149,11 +154,10 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_spender.toLowerCase(), _value
_value, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -162,31 +166,36 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_spender: string, _value: BigNumber): string { getABIEncodedTransactionData(
_spender: string,
_value: BigNumber,
): string {
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_spender.toLowerCase(),
_spender.toLowerCase(), _value
_value, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public totalSupply = { public totalSupply = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<BigNumber
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -195,7 +204,7 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('totalSupply()', []); const encodedData = self._strictEncodeArguments('totalSupply()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -205,20 +214,20 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('totalSupply()'); const abiEncoder = self._lookupAbiEncoder('totalSupply()');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC20TokenContract; ): string {
const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -228,32 +237,36 @@ export class ERC20TokenContract extends BaseContract {
_from: string, _from: string,
_to: string, _to: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_to.toLowerCase(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
...txData,
data: encodedData,
},
self._web3Wrapper.getContractDefaults(),
self.transferFrom.estimateGasAsync.bind(
self,
_from.toLowerCase(), _from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_value, _value
]); ),
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( );
{ if (txDataWithDefaults.from !== undefined) {
to: self.address, txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
...txData, }
data: encodedData,
}, const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
self._web3Wrapper.getContractDefaults(), return txHash;
self.transferFrom.estimateGasAsync.bind(self, _from.toLowerCase(), _to.toLowerCase(), _value),
);
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
_from: string, _from: string,
@ -263,27 +276,25 @@ export class ERC20TokenContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const txHashPromise = self.transferFrom.sendTransactionAsync( const txHashPromise = self.transferFrom.sendTransactionAsync(_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, , txData);
txData, return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
); txHashPromise,
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
txHashPromise, // When the transaction hash resolves, wait for it to be mined.
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return self._web3Wrapper.awaitTransactionSuccessAsync(
// When the transaction hash resolves, wait for it to be mined. await txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( pollingIntervalMs,
await txHashPromise, timeoutMs,
pollingIntervalMs, );
timeoutMs, })(),
); );
})(),
);
}, },
async estimateGasAsync( async estimateGasAsync(
_from: string, _from: string,
@ -291,29 +302,28 @@ export class ERC20TokenContract extends BaseContract {
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( {
{ to: self.address,
to: self.address, ...txData,
...txData, data: encodedData,
data: encodedData, },
}, self._web3Wrapper.getContractDefaults(),
self._web3Wrapper.getContractDefaults(), );
); if (txDataWithDefaults.from !== undefined) {
if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); }
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas;
return gas;
}, },
async callAsync( async callAsync(
_from: string, _from: string,
@ -321,7 +331,8 @@ export class ERC20TokenContract extends BaseContract {
_value: BigNumber, _value: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
@ -333,12 +344,11 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -347,28 +357,30 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)'); const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string { getABIEncodedTransactionData(
_from: string,
_to: string,
_value: BigNumber,
): string {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(), _to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -377,7 +389,8 @@ export class ERC20TokenContract extends BaseContract {
_owner: string, _owner: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<BigNumber> { ): Promise<BigNumber
> {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -387,8 +400,9 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -397,22 +411,24 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)'); const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_owner: string): string { getABIEncodedTransactionData(
_owner: string,
): string {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -420,27 +436,33 @@ export class ERC20TokenContract extends BaseContract {
async sendTransactionAsync( async sendTransactionAsync(
_to: string, _to: string,
_value: BigNumber, _value: BigNumber,
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( _value
{ ]);
to: self.address, const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
...txData, {
data: encodedData, to: self.address,
}, ...txData,
self._web3Wrapper.getContractDefaults(), data: encodedData,
self.transfer.estimateGasAsync.bind(self, _to.toLowerCase(), _value), },
); self._web3Wrapper.getContractDefaults(),
if (txDataWithDefaults.from !== undefined) { self.transfer.estimateGasAsync.bind(
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); self,
} _to.toLowerCase(),
_value
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); ),
return txHash; );
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
_to: string, _to: string,
@ -449,48 +471,57 @@ export class ERC20TokenContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData); const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(),
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( _value
txHashPromise, , txData);
(async (): Promise<TransactionReceiptWithDecodedLogs> => { return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
// When the transaction hash resolves, wait for it to be mined. txHashPromise,
return self._web3Wrapper.awaitTransactionSuccessAsync( (async (): Promise<TransactionReceiptWithDecodedLogs> => {
await txHashPromise, // When the transaction hash resolves, wait for it to be mined.
pollingIntervalMs, return self._web3Wrapper.awaitTransactionSuccessAsync(
timeoutMs, await txHashPromise,
); pollingIntervalMs,
})(), timeoutMs,
); );
})(),
);
}, },
async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
assert.isString('_to', _to); _to: string,
assert.isBigNumber('_value', _value); _value: BigNumber,
const self = (this as any) as ERC20TokenContract; txData?: Partial<TxData> | undefined,
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); ): Promise<number> {
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( assert.isString('_to', _to);
{ assert.isBigNumber('_value', _value);
to: self.address, const self = this as any as ERC20TokenContract;
...txData, const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
data: encodedData, _value
}, ]);
self._web3Wrapper.getContractDefaults(), const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
); {
if (txDataWithDefaults.from !== undefined) { to: self.address,
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); ...txData,
} data: encodedData,
},
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); self._web3Wrapper.getContractDefaults(),
return gas; );
if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
}
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
}, },
async callAsync( async callAsync(
_to: string, _to: string,
_value: BigNumber, _value: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -501,8 +532,10 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_value
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -511,26 +544,27 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_to: string, _value: BigNumber): string { getABIEncodedTransactionData(
_to: string,
_value: BigNumber,
): string {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_to.toLowerCase(), _value
_value, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -540,7 +574,8 @@ export class ERC20TokenContract extends BaseContract {
_spender: string, _spender: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<BigNumber> { ): Promise<BigNumber
> {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -551,11 +586,10 @@ export class ERC20TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const encodedData = self._strictEncodeArguments('allowance(address,address)', [ const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner.toLowerCase(),
_owner.toLowerCase(), _spender.toLowerCase()
_spender.toLowerCase(), ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -564,35 +598,36 @@ export class ERC20TokenContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)'); const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_owner: string, _spender: string): string { getABIEncodedTransactionData(
_owner: string,
_spender: string,
): string {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.isString('_spender', _spender); assert.isString('_spender', _spender);
const self = (this as any) as ERC20TokenContract; const self = this as any as ERC20TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [_owner.toLowerCase(),
_owner.toLowerCase(), _spender.toLowerCase()
_spender.toLowerCase(), ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>; private readonly _subscriptionManager: SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>;
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<ERC20TokenContract> { ): Promise<ERC20TokenContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -605,11 +640,8 @@ export class ERC20TokenContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -626,13 +658,17 @@ export class ERC20TokenContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -640,22 +676,18 @@ export class ERC20TokenContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ERC20TokenContract( const contractInstance = new ERC20TokenContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -678,9 +710,10 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'totalSupply', name: 'totalSupply',
outputs: [ outputs: [
{ {
@ -692,7 +725,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -719,7 +752,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -738,7 +771,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: false, constant: false,
inputs: [ inputs: [
{ {
@ -761,7 +794,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -784,7 +817,7 @@ export class ERC20TokenContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
anonymous: false, anonymous: false,
inputs: [ inputs: [
{ {
@ -804,10 +837,11 @@ export class ERC20TokenContract extends BaseContract {
}, },
], ],
name: 'Transfer', name: 'Transfer',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
anonymous: false, anonymous: false,
inputs: [ inputs: [
{ {
@ -827,7 +861,8 @@ export class ERC20TokenContract extends BaseContract {
}, },
], ],
name: 'Approval', name: 'Approval',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -901,12 +936,7 @@ export class ERC20TokenContract extends BaseContract {
); );
return logs; return logs;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super('ERC20Token', ERC20TokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('ERC20Token', ERC20TokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>( this._subscriptionManager = new SubscriptionManager<ERC20TokenEventArgs, ERC20TokenEvents>(
@ -914,7 +944,7 @@ export class ERC20TokenContract extends BaseContract {
this._web3Wrapper, this._web3Wrapper,
); );
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -23,6 +23,7 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -32,7 +33,8 @@ export class EthBalanceCheckerContract extends BaseContract {
addresses: string[], addresses: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<BigNumber[]> { ): Promise<BigNumber[]
> {
assert.isArray('addresses', addresses); assert.isArray('addresses', addresses);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -42,8 +44,9 @@ export class EthBalanceCheckerContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as EthBalanceCheckerContract; const self = this as any as EthBalanceCheckerContract;
const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -52,30 +55,32 @@ export class EthBalanceCheckerContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])'); const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<BigNumber[]>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<BigNumber[]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(addresses: string[]): string { getABIEncodedTransactionData(
addresses: string[],
): string {
assert.isArray('addresses', addresses); assert.isArray('addresses', addresses);
const self = (this as any) as EthBalanceCheckerContract; const self = this as any as EthBalanceCheckerContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]); const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<EthBalanceCheckerContract> { ): Promise<EthBalanceCheckerContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -88,11 +93,8 @@ export class EthBalanceCheckerContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -109,13 +111,17 @@ export class EthBalanceCheckerContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -123,22 +129,18 @@ export class EthBalanceCheckerContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new EthBalanceCheckerContract( const contractInstance = new EthBalanceCheckerContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -160,23 +162,11 @@ export class EthBalanceCheckerContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string, super('EthBalanceChecker', EthBalanceCheckerContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super(
'EthBalanceChecker',
EthBalanceCheckerContract.ABI(),
address,
supportedProvider,
txDefaults,
logDecodeDependencies,
);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -23,6 +23,7 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -34,7 +35,8 @@ export class IValidatorContract extends BaseContract {
signature: string, signature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signerAddress', signerAddress); assert.isString('signerAddress', signerAddress);
assert.isString('signature', signature); assert.isString('signature', signature);
@ -46,12 +48,11 @@ export class IValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IValidatorContract; const self = this as any as IValidatorContract;
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [ const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash,
hash, signerAddress.toLowerCase(),
signerAddress.toLowerCase(), signature
signature, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -60,36 +61,38 @@ export class IValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)'); const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(hash: string, signerAddress: string, signature: string): string { getABIEncodedTransactionData(
hash: string,
signerAddress: string,
signature: string,
): string {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signerAddress', signerAddress); assert.isString('signerAddress', signerAddress);
assert.isString('signature', signature); assert.isString('signature', signature);
const self = (this as any) as IValidatorContract; const self = this as any as IValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash,
hash, signerAddress.toLowerCase(),
signerAddress.toLowerCase(), signature
signature, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<IValidatorContract> { ): Promise<IValidatorContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -102,11 +105,8 @@ export class IValidatorContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -123,13 +123,17 @@ export class IValidatorContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -137,22 +141,18 @@ export class IValidatorContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IValidatorContract( const contractInstance = new IValidatorContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -182,16 +182,11 @@ export class IValidatorContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super('IValidator', IValidatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('IValidator', IValidatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -23,6 +23,7 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
@ -33,7 +34,8 @@ export class IWalletContract extends BaseContract {
signature: string, signature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signature', signature); assert.isString('signature', signature);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -44,8 +46,10 @@ export class IWalletContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IWalletContract; const self = this as any as IWalletContract;
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash, signature]); const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash,
signature
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -54,34 +58,35 @@ export class IWalletContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)'); const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<boolean
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(hash: string, signature: string): string { getABIEncodedTransactionData(
hash: string,
signature: string,
): string {
assert.isString('hash', hash); assert.isString('hash', hash);
assert.isString('signature', signature); assert.isString('signature', signature);
const self = (this as any) as IWalletContract; const self = this as any as IWalletContract;
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash,
hash, signature
signature, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
): Promise<IWalletContract> { ): Promise<IWalletContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -94,11 +99,8 @@ export class IWalletContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -115,13 +117,17 @@ export class IWalletContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString); [] = BaseContract._formatABIDataItemList(
constructorAbi.inputs,
[],
BaseContract._bigNumberToString,
);
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, []); const txData = deployInfo.encode(bytecode, []);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -129,22 +135,18 @@ export class IWalletContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IWalletContract( const contractInstance = new IWalletContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string,
provider,
txDefaults,
logDecodeDependencies,
);
contractInstance.constructorArgs = []; contractInstance.constructorArgs = [];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -170,16 +172,11 @@ export class IWalletContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string,
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super('IWallet', IWalletContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('IWallet', IWalletContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma // tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace // tslint:disable:whitespace no-unbound-method no-trailing-whitespace
// tslint:disable:no-unused-variable // tslint:disable:no-unused-variable
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract'; import { BaseContract,PromiseWithTransactionHash } from '@0x/base-contract';
import { schemas } from '@0x/json-schemas'; import { schemas } from '@0x/json-schemas';
import { import {
BlockParam, BlockParam,
@ -23,44 +23,20 @@ import { assert } from '@0x/assert';
import * as ethers from 'ethers'; import * as ethers from 'ethers';
// tslint:enable:no-unused-variable // tslint:enable:no-unused-variable
/* istanbul ignore next */ /* istanbul ignore next */
// tslint:disable:no-parameter-reassignment // tslint:disable:no-parameter-reassignment
// tslint:disable-next-line:class-name // tslint:disable-next-line:class-name
export class OrderValidatorContract extends BaseContract { export class OrderValidatorContract extends BaseContract {
public getOrderAndTraderInfo = { public getOrderAndTraderInfo = {
async callAsync( async callAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string, takerAddress: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}]
[
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}
]
> { > {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -70,11 +46,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -83,57 +58,27 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)');
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<[{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}, {makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}]
[ >(rawCallResult);
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}
]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; takerAddress: string,
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string,
): string {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getOrderAndTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -143,7 +88,8 @@ export class OrderValidatorContract extends BaseContract {
assetData: string, assetData: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<[BigNumber, BigNumber]> { ): Promise<[BigNumber, BigNumber]
> {
assert.isString('target', target); assert.isString('target', target);
assert.isString('assetData', assetData); assert.isString('assetData', assetData);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -154,11 +100,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ const encodedData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -167,62 +112,37 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)'); const abiEncoder = self._lookupAbiEncoder('getBalanceAndAllowance(address,bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<[BigNumber, BigNumber]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(target: string, assetData: string): string { getABIEncodedTransactionData(
target: string,
assetData: string,
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isString('assetData', assetData); assert.isString('assetData', assetData);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getBalanceAndAllowance(address,bytes)', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getOrdersAndTradersInfo = { public getOrdersAndTradersInfo = {
async callAsync( async callAsync(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[], takerAddresses: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>]
[
Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>,
Array<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
]
> { > {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
@ -234,11 +154,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -247,91 +166,37 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])');
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<[Array<{orderStatus: number;orderHash: string;orderTakerAssetFilledAmount: BigNumber}>, Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>]
[ >(rawCallResult);
Array<{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber }>,
Array<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string; takerAddresses: string[],
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[],
): string {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getOrdersAndTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getTradersInfo = { public getTradersInfo = {
async callAsync( async callAsync(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[], takerAddresses: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>
Array<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
> { > {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
@ -343,11 +208,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -356,55 +220,27 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])');
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<Array<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}>
Array<{ >(rawCallResult);
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
orders: Array<{ orders: Array<{makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string}>,
makerAddress: string; takerAddresses: string[],
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
}>,
takerAddresses: string[],
): string {
assert.isArray('orders', orders); assert.isArray('orders', orders);
assert.isArray('takerAddresses', takerAddresses); assert.isArray('takerAddresses', takerAddresses);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', [orders,
'getTradersInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],address[])', takerAddresses
[orders, takerAddresses], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -414,7 +250,8 @@ export class OrderValidatorContract extends BaseContract {
tokenId: BigNumber, tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isString('token', token); assert.isString('token', token);
assert.isBigNumber('tokenId', tokenId); assert.isBigNumber('tokenId', tokenId);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -425,11 +262,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ const encodedData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [token.toLowerCase(),
token.toLowerCase(), tokenId
tokenId, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -438,26 +274,27 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('getERC721TokenOwner(address,uint256)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<string
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(token: string, tokenId: BigNumber): string { getABIEncodedTransactionData(
token: string,
tokenId: BigNumber,
): string {
assert.isString('token', token); assert.isString('token', token);
assert.isBigNumber('tokenId', tokenId); assert.isBigNumber('tokenId', tokenId);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getERC721TokenOwner(address,uint256)', [token.toLowerCase(),
token.toLowerCase(), tokenId
tokenId, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -467,7 +304,8 @@ export class OrderValidatorContract extends BaseContract {
assetData: string[], assetData: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<[BigNumber[], BigNumber[]]> { ): Promise<[BigNumber[], BigNumber[]]
> {
assert.isString('target', target); assert.isString('target', target);
assert.isArray('assetData', assetData); assert.isArray('assetData', assetData);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -478,11 +316,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [ const encodedData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -491,58 +328,39 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])'); const abiEncoder = self._lookupAbiEncoder('getBalancesAndAllowances(address,bytes[])');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<[BigNumber[], BigNumber[]]
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(target: string, assetData: string[]): string { getABIEncodedTransactionData(
target: string,
assetData: string[],
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isArray('assetData', assetData); assert.isArray('assetData', assetData);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [ const abiEncodedTransactionData = self._strictEncodeArguments('getBalancesAndAllowances(address,bytes[])', [target.toLowerCase(),
target.toLowerCase(), assetData
assetData, ]);
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getTraderInfo = { public getTraderInfo = {
async callAsync( async callAsync(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string;
takerAddress: string;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string, takerAddress: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{ ): Promise<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}
makerBalance: BigNumber; > {
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}> {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -552,11 +370,10 @@ export class OrderValidatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -565,62 +382,37 @@ export class OrderValidatorContract extends BaseContract {
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
); );
callDataWithDefaults.from = callDataWithDefaults.from callDataWithDefaults.from = callDataWithDefaults.from ? callDataWithDefaults.from.toLowerCase() : callDataWithDefaults.from;
? callDataWithDefaults.from.toLowerCase()
: callDataWithDefaults.from;
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
const abiEncoder = self._lookupAbiEncoder( const abiEncoder = self._lookupAbiEncoder('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)');
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)',
);
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<{ const result = abiEncoder.strictDecodeReturnValue<{makerBalance: BigNumber;makerAllowance: BigNumber;takerBalance: BigNumber;takerAllowance: BigNumber;makerZrxBalance: BigNumber;makerZrxAllowance: BigNumber;takerZrxBalance: BigNumber;takerZrxAllowance: BigNumber}
makerBalance: BigNumber; >(rawCallResult);
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
order: { order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
makerAddress: string; takerAddress: string,
takerAddress: string; ): string {
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string,
): string {
assert.isString('takerAddress', takerAddress); assert.isString('takerAddress', takerAddress);
const self = (this as any) as OrderValidatorContract; const self = this as any as OrderValidatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', [order,
'getTraderInfo((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),address)', takerAddress.toLowerCase()
[order, takerAddress.toLowerCase()], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public static async deployFrom0xArtifactAsync( public static async deployFrom0xArtifactAsync(
artifact: ContractArtifact | SimpleContractArtifact, artifact: ContractArtifact | SimpleContractArtifact,
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact }, logDecodeDependencies: { [contractName: string]: (ContractArtifact | SimpleContractArtifact) },
_exchange: string, _exchange: string,
_zrxAssetData: string, _zrxAssetData: string,
): Promise<OrderValidatorContract> { ): Promise<OrderValidatorContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -633,19 +425,10 @@ export class OrderValidatorContract 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;
const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce( const logDecodeDependenciesAbiOnly = Object.entries(logDecodeDependencies).reduce((accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), {});
(accumulator, [key, value]) => Object.assign(accumulator, { [key]: value.compilerOutput.abi }), return OrderValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, _exchange,
{}, _zrxAssetData
); );
return OrderValidatorContract.deployAsync(
bytecode,
abi,
provider,
txDefaults,
logDecodeDependenciesAbiOnly,
_exchange,
_zrxAssetData,
);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -653,8 +436,8 @@ export class OrderValidatorContract extends BaseContract {
supportedProvider: SupportedProvider, supportedProvider: SupportedProvider,
txDefaults: Partial<TxData>, txDefaults: Partial<TxData>,
logDecodeDependencies: { [contractName: string]: ContractAbi }, logDecodeDependencies: { [contractName: string]: ContractAbi },
_exchange: string, _exchange: string,
_zrxAssetData: string, _zrxAssetData: string,
): Promise<OrderValidatorContract> { ): Promise<OrderValidatorContract> {
assert.isHexString('bytecode', bytecode); assert.isHexString('bytecode', bytecode);
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -664,17 +447,23 @@ export class OrderValidatorContract extends BaseContract {
]); ]);
const provider = providerUtils.standardizeOrThrow(supportedProvider); const provider = providerUtils.standardizeOrThrow(supportedProvider);
const constructorAbi = BaseContract._lookupConstructorAbi(abi); const constructorAbi = BaseContract._lookupConstructorAbi(abi);
[_exchange, _zrxAssetData] = BaseContract._formatABIDataItemList( [_exchange,
_zrxAssetData
] = BaseContract._formatABIDataItemList(
constructorAbi.inputs, constructorAbi.inputs,
[_exchange, _zrxAssetData], [_exchange,
_zrxAssetData
],
BaseContract._bigNumberToString, BaseContract._bigNumberToString,
); );
const iface = new ethers.utils.Interface(abi); const iface = new ethers.utils.Interface(abi);
const deployInfo = iface.deployFunction; const deployInfo = iface.deployFunction;
const txData = deployInfo.encode(bytecode, [_exchange, _zrxAssetData]); const txData = deployInfo.encode(bytecode, [_exchange,
_zrxAssetData
]);
const web3Wrapper = new Web3Wrapper(provider); const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ data: txData }, {data: txData},
txDefaults, txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper), web3Wrapper.estimateGasAsync.bind(web3Wrapper),
); );
@ -682,22 +471,20 @@ export class OrderValidatorContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`OrderValidator successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`OrderValidator successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new OrderValidatorContract( const contractInstance = new OrderValidatorContract(txReceipt.contractAddress as string, provider, txDefaults, logDecodeDependencies);
txReceipt.contractAddress as string, contractInstance.constructorArgs = [_exchange,
provider, _zrxAssetData
txDefaults, ];
logDecodeDependencies,
);
contractInstance.constructorArgs = [_exchange, _zrxAssetData];
return contractInstance; return contractInstance;
} }
/** /**
* @returns The contract ABI * @returns The contract ABI
*/ */
public static ABI(): ContractAbi { public static ABI(): ContractAbi {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -752,7 +539,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddress', name: 'takerAddress',
@ -777,7 +564,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'orderTakerAssetFilledAmount', name: 'orderTakerAssetFilledAmount',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'traderInfo', name: 'traderInfo',
@ -815,14 +602,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -849,7 +636,7 @@ export class OrderValidatorContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -904,7 +691,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddresses', name: 'takerAddresses',
@ -929,7 +716,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'orderTakerAssetFilledAmount', name: 'orderTakerAssetFilledAmount',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
{ {
name: 'tradersInfo', name: 'tradersInfo',
@ -967,14 +754,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1029,7 +816,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddresses', name: 'takerAddresses',
@ -1074,14 +861,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1104,7 +891,7 @@ export class OrderValidatorContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1131,7 +918,7 @@ export class OrderValidatorContract extends BaseContract {
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [ inputs: [
{ {
@ -1186,7 +973,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddress', name: 'takerAddress',
@ -1231,14 +1018,14 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
}, },
{ {
inputs: [ inputs: [
{ {
name: '_exchange', name: '_exchange',
@ -1249,7 +1036,8 @@ export class OrderValidatorContract extends BaseContract {
type: 'bytes', type: 'bytes',
}, },
], ],
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -1257,23 +1045,11 @@ export class OrderValidatorContract extends BaseContract {
] as ContractAbi; ] as ContractAbi;
return abi; return abi;
} }
constructor( constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>, logDecodeDependencies?: { [contractName: string]: ContractAbi }) {
address: string, super('OrderValidator', OrderValidatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
supportedProvider: SupportedProvider,
txDefaults?: Partial<TxData>,
logDecodeDependencies?: { [contractName: string]: ContractAbi },
) {
super(
'OrderValidator',
OrderValidatorContract.ABI(),
address,
supportedProvider,
txDefaults,
logDecodeDependencies,
);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }
} }
// tslint:disable:max-file-line-count // tslint:disable:max-file-line-count
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align // tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff