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

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 CoordinatorContract extends BaseContract {
signature: string, signature: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
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 CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash, signature]); const encodedData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash,
signature
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -54,35 +58,38 @@ export class CoordinatorContract 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('getSignerAddress(bytes32,bytes)'); const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)');
// 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(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 CoordinatorContract; const self = this as any as CoordinatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [ const abiEncodedTransactionData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash,
hash, signature
signature,
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getTransactionHash = { public getTransactionHash = {
async callAsync( async callAsync(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -91,9 +98,8 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments('getTransactionHash((uint256,address,bytes))', [ const encodedData = self._strictEncodeArguments('getTransactionHash((uint256,address,bytes))', [transaction
transaction,
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -103,38 +109,35 @@ export class CoordinatorContract 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('getTransactionHash((uint256,address,bytes))'); const abiEncoder = self._lookupAbiEncoder('getTransactionHash((uint256,address,bytes))');
// 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(transaction: { salt: BigNumber; signerAddress: string; data: string }): string { getABIEncodedTransactionData(
const self = (this as any) as CoordinatorContract; transaction: {salt: BigNumber;signerAddress: string;data: string},
const abiEncodedTransactionData = self._strictEncodeArguments( ): string {
'getTransactionHash((uint256,address,bytes))',
[transaction], const self = this as any as CoordinatorContract;
); const abiEncodedTransactionData = self._strictEncodeArguments('getTransactionHash((uint256,address,bytes))', [transaction
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getCoordinatorApprovalHash = { public getCoordinatorApprovalHash = {
async callAsync( async callAsync(
approval: { approval: {txOrigin: string;transactionHash: string;transactionSignature: string;approvalExpirationTimeSeconds: BigNumber},
txOrigin: string;
transactionHash: string;
transactionSignature: string;
approvalExpirationTimeSeconds: BigNumber;
},
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -143,11 +146,9 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', [approval
'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', ]);
[approval],
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -156,56 +157,48 @@ export class CoordinatorContract 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('getCoordinatorApprovalHash((address,bytes32,bytes,uint256))'); const abiEncoder = self._lookupAbiEncoder('getCoordinatorApprovalHash((address,bytes32,bytes,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(approval: { getABIEncodedTransactionData(
txOrigin: string; approval: {txOrigin: string;transactionHash: string;transactionSignature: string;approvalExpirationTimeSeconds: BigNumber},
transactionHash: string; ): string {
transactionSignature: string;
approvalExpirationTimeSeconds: BigNumber; const self = this as any as CoordinatorContract;
}): string { const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorApprovalHash((address,bytes32,bytes,uint256))', [approval
const self = (this as any) as CoordinatorContract; ]);
const abiEncodedTransactionData = self._strictEncodeArguments(
'getCoordinatorApprovalHash((address,bytes32,bytes,uint256))',
[approval],
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public executeTransaction = { public executeTransaction = {
async sendTransactionAsync( async sendTransactionAsync(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[], approvalSignatures: string[],
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<string> { ): Promise<string> {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
assert.isArray('approvalSignatures', approvalSignatures); assert.isArray('approvalSignatures', approvalSignatures);
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
[
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
], ]);
);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -219,7 +212,7 @@ export class CoordinatorContract extends BaseContract {
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
), ),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
@ -230,7 +223,7 @@ export class CoordinatorContract extends BaseContract {
return txHash; return txHash;
}, },
awaitTransactionSuccessAsync( awaitTransactionSuccessAsync(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
@ -239,19 +232,18 @@ export class CoordinatorContract extends BaseContract {
pollingIntervalMs?: number, pollingIntervalMs?: number,
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
assert.isArray('approvalSignatures', approvalSignatures); assert.isArray('approvalSignatures', approvalSignatures);
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const txHashPromise = self.executeTransaction.sendTransactionAsync( const txHashPromise = self.executeTransaction.sendTransactionAsync(transaction,
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
txData, , txData);
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -265,28 +257,25 @@ export class CoordinatorContract extends BaseContract {
); );
}, },
async estimateGasAsync( async estimateGasAsync(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[], approvalSignatures: string[],
txData?: Partial<TxData> | undefined, txData?: Partial<TxData> | undefined,
): Promise<number> { ): Promise<number> {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
assert.isArray('approvalSignatures', approvalSignatures); assert.isArray('approvalSignatures', approvalSignatures);
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
[
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
], ]);
);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -303,14 +292,16 @@ export class CoordinatorContract extends BaseContract {
return gas; return gas;
}, },
async callAsync( async callAsync(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[], approvalSignatures: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
@ -323,17 +314,13 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
[
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -342,47 +329,45 @@ export class CoordinatorContract 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('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])');
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
);
// 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( getABIEncodedTransactionData(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[], approvalSignatures: string[],
): string { ): string {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
assert.isArray('approvalSignatures', approvalSignatures); assert.isArray('approvalSignatures', approvalSignatures);
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
'executeTransaction((uint256,address,bytes),address,bytes,uint256[],bytes[])',
[
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public EIP712_EXCHANGE_DOMAIN_HASH = { public EIP712_EXCHANGE_DOMAIN_HASH = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -391,7 +376,7 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); const encodedData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -401,34 +386,36 @@ export class CoordinatorContract 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('EIP712_EXCHANGE_DOMAIN_HASH()'); const abiEncoder = self._lookupAbiEncoder('EIP712_EXCHANGE_DOMAIN_HASH()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as CoordinatorContract; ): string {
const self = this as any as CoordinatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []); const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_EXCHANGE_DOMAIN_HASH()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public assertValidCoordinatorApprovals = { public assertValidCoordinatorApprovals = {
async callAsync( async callAsync(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[], approvalSignatures: string[],
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
@ -441,17 +428,13 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments( const encodedData = self._strictEncodeArguments('assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])',
[
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
], ]);
);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -460,42 +443,36 @@ export class CoordinatorContract 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('assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])');
'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])',
);
// 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( getABIEncodedTransactionData(
transaction: { salt: BigNumber; signerAddress: string; data: string }, transaction: {salt: BigNumber;signerAddress: string;data: string},
txOrigin: string, txOrigin: string,
transactionSignature: string, transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[], approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[], approvalSignatures: string[],
): string { ): string {
assert.isString('txOrigin', txOrigin); assert.isString('txOrigin', txOrigin);
assert.isString('transactionSignature', transactionSignature); assert.isString('transactionSignature', transactionSignature);
assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds); assert.isArray('approvalExpirationTimeSeconds', approvalExpirationTimeSeconds);
assert.isArray('approvalSignatures', approvalSignatures); assert.isArray('approvalSignatures', approvalSignatures);
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])', [transaction,
'assertValidCoordinatorApprovals((uint256,address,bytes),address,bytes,uint256[],bytes[])',
[
transaction,
txOrigin.toLowerCase(), txOrigin.toLowerCase(),
transactionSignature, transactionSignature,
approvalExpirationTimeSeconds, approvalExpirationTimeSeconds,
approvalSignatures, approvalSignatures
], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -504,21 +481,7 @@ export class CoordinatorContract extends BaseContract {
data: string, data: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise< ): Promise<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}>
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;
}>
> { > {
assert.isString('data', data); assert.isString('data', data);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -529,8 +492,9 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data]); const encodedData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -539,42 +503,33 @@ export class CoordinatorContract 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('decodeOrdersFromFillData(bytes)'); const abiEncoder = self._lookupAbiEncoder('decodeOrdersFromFillData(bytes)');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue< const result = abiEncoder.strictDecodeReturnValue<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}>
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;
}>
>(rawCallResult); >(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(data: string): string { getABIEncodedTransactionData(
data: string,
): string {
assert.isString('data', data); assert.isString('data', data);
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data]); const abiEncodedTransactionData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public EIP712_COORDINATOR_DOMAIN_HASH = { public EIP712_COORDINATOR_DOMAIN_HASH = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -583,7 +538,7 @@ export class CoordinatorContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as CoordinatorContract; const self = this as any as CoordinatorContract;
const encodedData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []); const encodedData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -593,29 +548,29 @@ export class CoordinatorContract 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('EIP712_COORDINATOR_DOMAIN_HASH()'); const abiEncoder = self._lookupAbiEncoder('EIP712_COORDINATOR_DOMAIN_HASH()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as CoordinatorContract; ): string {
const self = this as any as CoordinatorContract;
const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []); const abiEncodedTransactionData = self._strictEncodeArguments('EIP712_COORDINATOR_DOMAIN_HASH()', []);
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<CoordinatorContract> { ): Promise<CoordinatorContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
@ -629,18 +584,9 @@ export class CoordinatorContract 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 CoordinatorContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, _exchange
{}, );
);
return CoordinatorContract.deployAsync(
bytecode,
abi,
provider,
txDefaults,
logDecodeDependenciesAbiOnly,
_exchange,
);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -658,17 +604,20 @@ export class CoordinatorContract 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),
); );
@ -676,16 +625,13 @@ export class CoordinatorContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`Coordinator successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`Coordinator successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new CoordinatorContract( const contractInstance = new CoordinatorContract(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
*/ */
@ -733,7 +679,7 @@ export class CoordinatorContract extends BaseContract {
name: 'data', name: 'data',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
], ],
name: 'getTransactionHash', name: 'getTransactionHash',
@ -770,7 +716,7 @@ export class CoordinatorContract extends BaseContract {
name: 'approvalExpirationTimeSeconds', name: 'approvalExpirationTimeSeconds',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
name: 'getCoordinatorApprovalHash', name: 'getCoordinatorApprovalHash',
@ -803,7 +749,7 @@ export class CoordinatorContract extends BaseContract {
name: 'data', name: 'data',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'txOrigin', name: 'txOrigin',
@ -823,14 +769,16 @@ export class CoordinatorContract extends BaseContract {
}, },
], ],
name: 'executeTransaction', name: 'executeTransaction',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'EIP712_EXCHANGE_DOMAIN_HASH', name: 'EIP712_EXCHANGE_DOMAIN_HASH',
outputs: [ outputs: [
{ {
@ -861,7 +809,7 @@ export class CoordinatorContract extends BaseContract {
name: 'data', name: 'data',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'txOrigin', name: 'txOrigin',
@ -881,7 +829,8 @@ export class CoordinatorContract extends BaseContract {
}, },
], ],
name: 'assertValidCoordinatorApprovals', name: 'assertValidCoordinatorApprovals',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'view', stateMutability: 'view',
type: 'function', type: 'function',
@ -948,7 +897,7 @@ export class CoordinatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
], ],
payable: false, payable: false,
@ -957,7 +906,8 @@ export class CoordinatorContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'EIP712_COORDINATOR_DOMAIN_HASH', name: 'EIP712_COORDINATOR_DOMAIN_HASH',
outputs: [ outputs: [
{ {
@ -976,7 +926,8 @@ export class CoordinatorContract extends BaseContract {
type: 'address', type: 'address',
}, },
], ],
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -984,12 +935,7 @@ export class CoordinatorContract 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('Coordinator', CoordinatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('Coordinator', CoordinatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }

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,15 +40,20 @@ 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(
coordinatorEndpoint: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -58,7 +61,10 @@ export class CoordinatorRegistryContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.setCoordinatorEndpoint.estimateGasAsync.bind(self, coordinatorEndpoint), self.setCoordinatorEndpoint.estimateGasAsync.bind(
self,
coordinatorEndpoint
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -74,8 +80,9 @@ export class CoordinatorRegistryContract extends BaseContract {
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
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -88,10 +95,14 @@ export class CoordinatorRegistryContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
coordinatorEndpoint: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('coordinatorEndpoint', coordinatorEndpoint); assert.isString('coordinatorEndpoint', coordinatorEndpoint);
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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -111,7 +122,8 @@ export class CoordinatorRegistryContract extends BaseContract {
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,23 +144,23 @@ 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,9 +181,8 @@ 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(
{ {
@ -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,16 +267,12 @@ 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
*/ */
@ -283,7 +287,8 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
], ],
name: 'setCoordinatorEndpoint', name: 'setCoordinatorEndpoint',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -308,8 +313,10 @@ export class CoordinatorRegistryContract extends BaseContract {
type: 'function', type: 'function',
}, },
{ {
inputs: [], inputs: [
outputs: [], ],
outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -329,7 +336,8 @@ export class CoordinatorRegistryContract extends BaseContract {
}, },
], ],
name: 'CoordinatorEndpointSet', name: 'CoordinatorEndpointSet',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -403,20 +411,8 @@ 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(),

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,33 +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 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;
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<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,
@ -57,7 +44,10 @@ export class DutchAuctionContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.getAuctionDetails.estimateGasAsync.bind(self, order), self.getAuctionDetails.estimateGasAsync.bind(
self,
order
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -67,26 +57,15 @@ export class DutchAuctionContract extends BaseContract {
return txHash; 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;
const txHashPromise = self.getAuctionDetails.sendTransactionAsync(order
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -100,27 +79,13 @@ export class DutchAuctionContract extends BaseContract {
); );
}, },
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,
@ -137,30 +102,12 @@ export class DutchAuctionContract extends BaseContract {
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,90 +127,45 @@ 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('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 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -273,7 +173,13 @@ export class DutchAuctionContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.matchOrders.estimateGasAsync.bind(self, buyOrder, sellOrder, buySignature, sellSignature), self.matchOrders.estimateGasAsync.bind(
self,
buyOrder,
sellOrder,
buySignature,
sellSignature
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -283,50 +189,24 @@ export class DutchAuctionContract extends BaseContract {
return txHash; 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('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 txHashPromise = self.matchOrders.sendTransactionAsync( const txHashPromise = self.matchOrders.sendTransactionAsync(buyOrder,
buyOrder,
sellOrder, sellOrder,
buySignature, buySignature,
sellSignature, sellSignature
txData, , txData);
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -340,45 +220,22 @@ export class DutchAuctionContract extends BaseContract {
); );
}, },
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('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 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 txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -395,53 +252,16 @@ export class DutchAuctionContract extends BaseContract {
return gas; 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,81 +286,41 @@ 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;
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,
): 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, [
@ -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,
@ -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,16 +375,13 @@ 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
*/ */
@ -670,7 +442,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
], ],
name: 'getAuctionDetails', name: 'getAuctionDetails',
@ -703,7 +475,7 @@ export class DutchAuctionContract extends BaseContract {
name: 'currentTimeSeconds', name: 'currentTimeSeconds',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
@ -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,13 +650,13 @@ 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,
@ -898,7 +670,8 @@ export class DutchAuctionContract extends BaseContract {
type: 'address', type: 'address',
}, },
], ],
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'constructor', type: 'constructor',
@ -906,20 +679,8 @@ 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']);
} }
} }

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,
@ -50,15 +47,20 @@ export interface ERC20ProxyAuthorizedAddressRemovedEventArgs extends DecodedLogA
caller: string; caller: 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 ERC20ProxyContract extends BaseContract { export class ERC20ProxyContract extends BaseContract {
public addAuthorizedAddress = { public addAuthorizedAddress = {
async sendTransactionAsync(target: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -66,7 +68,10 @@ export class ERC20ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.addAuthorizedAddress.estimateGasAsync.bind(self, target.toLowerCase()), self.addAuthorizedAddress.estimateGasAsync.bind(
self,
target.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -82,8 +87,9 @@ export class ERC20ProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData); const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -96,10 +102,14 @@ export class ERC20ProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(target: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -115,7 +125,12 @@ export class ERC20ProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(target: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
target: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -125,8 +140,9 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -135,23 +151,23 @@ export class ERC20ProxyContract 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('addAuthorizedAddress(address)'); const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)');
// 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(target: string): string { getABIEncodedTransactionData(
target: string,
): string {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
target.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -161,7 +177,8 @@ export class ERC20ProxyContract extends BaseContract {
index_0: BigNumber, index_0: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isBigNumber('index_0', index_0); assert.isBigNumber('index_0', index_0);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -171,8 +188,9 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -181,30 +199,36 @@ export class ERC20ProxyContract 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('authorities(uint256)'); const abiEncoder = self._lookupAbiEncoder('authorities(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(index_0: BigNumber): string { getABIEncodedTransactionData(
index_0: BigNumber,
): string {
assert.isBigNumber('index_0', index_0); assert.isBigNumber('index_0', index_0);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public removeAuthorizedAddress = { public removeAuthorizedAddress = {
async sendTransactionAsync(target: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -212,7 +236,10 @@ export class ERC20ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.removeAuthorizedAddress.estimateGasAsync.bind(self, target.toLowerCase()), self.removeAuthorizedAddress.estimateGasAsync.bind(
self,
target.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -228,8 +255,9 @@ export class ERC20ProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData); const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -242,10 +270,14 @@ export class ERC20ProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(target: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -261,7 +293,12 @@ export class ERC20ProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(target: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
target: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -271,8 +308,9 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -281,29 +319,33 @@ export class ERC20ProxyContract 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('removeAuthorizedAddress(address)'); const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)');
// 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(target: string): string { getABIEncodedTransactionData(
target: string,
): string {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
target.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public owner = { public owner = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -312,7 +354,7 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('owner()', []); const encodedData = self._strictEncodeArguments('owner()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -322,20 +364,20 @@ export class ERC20ProxyContract 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('owner()'); const abiEncoder = self._lookupAbiEncoder('owner()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC20ProxyContract; ): string {
const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -348,10 +390,9 @@ export class ERC20ProxyContract extends BaseContract {
): Promise<string> { ): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -360,7 +401,11 @@ export class ERC20ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(self, target.toLowerCase(), index), self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(
self,
target.toLowerCase(),
index
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -378,12 +423,10 @@ export class ERC20ProxyContract extends BaseContract {
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync(target.toLowerCase(),
target.toLowerCase(), index
index, , txData);
txData,
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -403,10 +446,9 @@ export class ERC20ProxyContract extends BaseContract {
): Promise<number> { ): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -428,7 +470,8 @@ export class ERC20ProxyContract extends BaseContract {
index: BigNumber, index: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -439,10 +482,9 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -452,31 +494,36 @@ export class ERC20ProxyContract 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('removeAuthorizedAddressAtIndex(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)');
// 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(target: string, index: BigNumber): string { getABIEncodedTransactionData(
target: string,
index: BigNumber,
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
'removeAuthorizedAddressAtIndex(address,uint256)', index
[target.toLowerCase(), index], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getProxyId = { public getProxyId = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -485,7 +532,7 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('getProxyId()', []); const encodedData = self._strictEncodeArguments('getProxyId()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -495,20 +542,20 @@ export class ERC20ProxyContract 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('getProxyId()'); const abiEncoder = self._lookupAbiEncoder('getProxyId()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC20ProxyContract; ): string {
const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -518,7 +565,8 @@ export class ERC20ProxyContract extends BaseContract {
index_0: string, index_0: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('index_0', index_0); assert.isString('index_0', index_0);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -528,8 +576,9 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -538,29 +587,33 @@ export class ERC20ProxyContract 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('authorized(address)'); const abiEncoder = self._lookupAbiEncoder('authorized(address)');
// 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(index_0: string): string { getABIEncodedTransactionData(
index_0: string,
): string {
assert.isString('index_0', index_0); assert.isString('index_0', index_0);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()
index_0.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getAuthorizedAddresses = { public getAuthorizedAddresses = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string[]> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string[]
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -569,7 +622,7 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -579,29 +632,33 @@ export class ERC20ProxyContract 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('getAuthorizedAddresses()'); const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC20ProxyContract; ): string {
const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public transferOwnership = { public transferOwnership = {
async sendTransactionAsync(newOwner: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
newOwner: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -609,7 +666,10 @@ export class ERC20ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferOwnership.estimateGasAsync.bind(self, newOwner.toLowerCase()), self.transferOwnership.estimateGasAsync.bind(
self,
newOwner.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -625,8 +685,9 @@ export class ERC20ProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData); const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -639,10 +700,14 @@ export class ERC20ProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(newOwner: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
newOwner: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -658,7 +723,12 @@ export class ERC20ProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(newOwner: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
newOwner: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -668,8 +738,9 @@ export class ERC20ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -678,33 +749,33 @@ export class ERC20ProxyContract 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('transferOwnership(address)'); const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)');
// 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(newOwner: string): string { getABIEncodedTransactionData(
newOwner: string,
): string {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC20ProxyContract; const self = this as any as ERC20ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
newOwner.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<ERC20ProxyEventArgs, ERC20ProxyEvents>; private readonly _subscriptionManager: SubscriptionManager<ERC20ProxyEventArgs, ERC20ProxyEvents>;
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<ERC20ProxyContract> { ): Promise<ERC20ProxyContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -717,11 +788,8 @@ export class ERC20ProxyContract 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 ERC20ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return ERC20ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -738,13 +806,17 @@ export class ERC20ProxyContract 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),
); );
@ -752,16 +824,12 @@ export class ERC20ProxyContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ERC20Proxy successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`ERC20Proxy successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ERC20ProxyContract( const contractInstance = new ERC20ProxyContract(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
*/ */
@ -776,7 +844,8 @@ export class ERC20ProxyContract extends BaseContract {
}, },
], ],
name: 'addAuthorizedAddress', name: 'addAuthorizedAddress',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -809,14 +878,16 @@ export class ERC20ProxyContract extends BaseContract {
}, },
], ],
name: 'removeAuthorizedAddress', name: 'removeAuthorizedAddress',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'owner', name: 'owner',
outputs: [ outputs: [
{ {
@ -841,14 +912,16 @@ export class ERC20ProxyContract extends BaseContract {
}, },
], ],
name: 'removeAuthorizedAddressAtIndex', name: 'removeAuthorizedAddressAtIndex',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'getProxyId', name: 'getProxyId',
outputs: [ outputs: [
{ {
@ -881,7 +954,8 @@ export class ERC20ProxyContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'getAuthorizedAddresses', name: 'getAuthorizedAddresses',
outputs: [ outputs: [
{ {
@ -902,14 +976,17 @@ export class ERC20ProxyContract extends BaseContract {
}, },
], ],
name: 'transferOwnership', name: 'transferOwnership',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
inputs: [], inputs: [
outputs: [], ],
outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'fallback', type: 'fallback',
@ -929,7 +1006,8 @@ export class ERC20ProxyContract extends BaseContract {
}, },
], ],
name: 'AuthorizedAddressAdded', name: 'AuthorizedAddressAdded',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
@ -947,7 +1025,8 @@ export class ERC20ProxyContract extends BaseContract {
}, },
], ],
name: 'AuthorizedAddressRemoved', name: 'AuthorizedAddressRemoved',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -1021,12 +1100,7 @@ export class ERC20ProxyContract 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('ERC20Proxy', ERC20ProxyContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('ERC20Proxy', ERC20ProxyContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<ERC20ProxyEventArgs, ERC20ProxyEvents>( this._subscriptionManager = new SubscriptionManager<ERC20ProxyEventArgs, ERC20ProxyEvents>(

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
@ -62,10 +62,9 @@ export class ERC20TokenContract extends BaseContract {
): 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(),
_spender.toLowerCase(), _value
_value,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -74,7 +73,11 @@ export class ERC20TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.approve.estimateGasAsync.bind(self, _spender.toLowerCase(), _value), self.approve.estimateGasAsync.bind(
self,
_spender.toLowerCase(),
_value
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -92,8 +95,10 @@ export class ERC20TokenContract extends BaseContract {
): 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(),
_value
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -113,10 +118,9 @@ export class ERC20TokenContract extends BaseContract {
): 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(
{ {
@ -138,7 +142,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('_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,10 +154,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('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(
{ {
@ -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;
}, },
@ -233,11 +242,10 @@ export class ERC20TokenContract extends BaseContract {
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(
{ {
@ -246,7 +254,12 @@ export class ERC20TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferFrom.estimateGasAsync.bind(self, _from.toLowerCase(), _to.toLowerCase(), _value), self.transferFrom.estimateGasAsync.bind(
self,
_from.toLowerCase(),
_to.toLowerCase(),
_value
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -266,13 +279,11 @@ export class ERC20TokenContract extends BaseContract {
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>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -294,11 +305,10 @@ export class ERC20TokenContract extends BaseContract {
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(
{ {
@ -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,11 +344,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('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(
{ {
@ -347,27 +357,29 @@ 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;
}, },
}; };
@ -424,8 +440,10 @@ export class ERC20TokenContract extends BaseContract {
): 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(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -433,7 +451,11 @@ export class ERC20TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transfer.estimateGasAsync.bind(self, _to.toLowerCase(), _value), self.transfer.estimateGasAsync.bind(
self,
_to.toLowerCase(),
_value
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -451,8 +473,10 @@ export class ERC20TokenContract extends BaseContract {
): 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(),
_value
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -465,11 +489,17 @@ export class ERC20TokenContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
_to: string,
_value: BigNumber,
txData?: Partial<TxData> | undefined,
): Promise<number> {
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(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -490,7 +520,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('_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,25 +544,26 @@ 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,10 +586,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('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(
{ {
@ -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,16 +676,12 @@ 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
*/ */
@ -680,7 +712,8 @@ export class ERC20TokenContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'totalSupply', name: 'totalSupply',
outputs: [ outputs: [
{ {
@ -804,7 +837,8 @@ export class ERC20TokenContract extends BaseContract {
}, },
], ],
name: 'Transfer', name: 'Transfer',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
@ -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>(

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,
@ -50,15 +47,20 @@ export interface ERC721ProxyAuthorizedAddressRemovedEventArgs extends DecodedLog
caller: string; caller: 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 ERC721ProxyContract extends BaseContract { export class ERC721ProxyContract extends BaseContract {
public addAuthorizedAddress = { public addAuthorizedAddress = {
async sendTransactionAsync(target: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -66,7 +68,10 @@ export class ERC721ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.addAuthorizedAddress.estimateGasAsync.bind(self, target.toLowerCase()), self.addAuthorizedAddress.estimateGasAsync.bind(
self,
target.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -82,8 +87,9 @@ export class ERC721ProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData); const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -96,10 +102,14 @@ export class ERC721ProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(target: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -115,7 +125,12 @@ export class ERC721ProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(target: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
target: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -125,8 +140,9 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -135,23 +151,23 @@ export class ERC721ProxyContract 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('addAuthorizedAddress(address)'); const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)');
// 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(target: string): string { getABIEncodedTransactionData(
target: string,
): string {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
target.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -161,7 +177,8 @@ export class ERC721ProxyContract extends BaseContract {
index_0: BigNumber, index_0: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isBigNumber('index_0', index_0); assert.isBigNumber('index_0', index_0);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -171,8 +188,9 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0]); const encodedData = self._strictEncodeArguments('authorities(uint256)', [index_0
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -181,30 +199,36 @@ export class ERC721ProxyContract 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('authorities(uint256)'); const abiEncoder = self._lookupAbiEncoder('authorities(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(index_0: BigNumber): string { getABIEncodedTransactionData(
index_0: BigNumber,
): string {
assert.isBigNumber('index_0', index_0); assert.isBigNumber('index_0', index_0);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0]); const abiEncodedTransactionData = self._strictEncodeArguments('authorities(uint256)', [index_0
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public removeAuthorizedAddress = { public removeAuthorizedAddress = {
async sendTransactionAsync(target: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -212,7 +236,10 @@ export class ERC721ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.removeAuthorizedAddress.estimateGasAsync.bind(self, target.toLowerCase()), self.removeAuthorizedAddress.estimateGasAsync.bind(
self,
target.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -228,8 +255,9 @@ export class ERC721ProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData); const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -242,10 +270,14 @@ export class ERC721ProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(target: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -261,7 +293,12 @@ export class ERC721ProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(target: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
target: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -271,8 +308,9 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -281,29 +319,33 @@ export class ERC721ProxyContract 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('removeAuthorizedAddress(address)'); const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)');
// 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(target: string): string { getABIEncodedTransactionData(
target: string,
): string {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
target.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public owner = { public owner = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -312,7 +354,7 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('owner()', []); const encodedData = self._strictEncodeArguments('owner()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -322,20 +364,20 @@ export class ERC721ProxyContract 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('owner()'); const abiEncoder = self._lookupAbiEncoder('owner()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC721ProxyContract; ): string {
const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []); const abiEncodedTransactionData = self._strictEncodeArguments('owner()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -348,10 +390,9 @@ export class ERC721ProxyContract extends BaseContract {
): Promise<string> { ): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -360,7 +401,11 @@ export class ERC721ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(self, target.toLowerCase(), index), self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(
self,
target.toLowerCase(),
index
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -378,12 +423,10 @@ export class ERC721ProxyContract extends BaseContract {
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync(target.toLowerCase(),
target.toLowerCase(), index
index, , txData);
txData,
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -403,10 +446,9 @@ export class ERC721ProxyContract extends BaseContract {
): Promise<number> { ): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -428,7 +470,8 @@ export class ERC721ProxyContract extends BaseContract {
index: BigNumber, index: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -439,10 +482,9 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -452,31 +494,36 @@ export class ERC721ProxyContract 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('removeAuthorizedAddressAtIndex(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)');
// 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(target: string, index: BigNumber): string { getABIEncodedTransactionData(
target: string,
index: BigNumber,
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
'removeAuthorizedAddressAtIndex(address,uint256)', index
[target.toLowerCase(), index], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getProxyId = { public getProxyId = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -485,7 +532,7 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('getProxyId()', []); const encodedData = self._strictEncodeArguments('getProxyId()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -495,20 +542,20 @@ export class ERC721ProxyContract 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('getProxyId()'); const abiEncoder = self._lookupAbiEncoder('getProxyId()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC721ProxyContract; ): string {
const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -518,7 +565,8 @@ export class ERC721ProxyContract extends BaseContract {
index_0: string, index_0: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('index_0', index_0); assert.isString('index_0', index_0);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -528,8 +576,9 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()]); const encodedData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -538,29 +587,33 @@ export class ERC721ProxyContract 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('authorized(address)'); const abiEncoder = self._lookupAbiEncoder('authorized(address)');
// 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(index_0: string): string { getABIEncodedTransactionData(
index_0: string,
): string {
assert.isString('index_0', index_0); assert.isString('index_0', index_0);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('authorized(address)', [index_0.toLowerCase()
index_0.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getAuthorizedAddresses = { public getAuthorizedAddresses = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string[]> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string[]
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -569,7 +622,7 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -579,29 +632,33 @@ export class ERC721ProxyContract 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('getAuthorizedAddresses()'); const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ERC721ProxyContract; ): string {
const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public transferOwnership = { public transferOwnership = {
async sendTransactionAsync(newOwner: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
newOwner: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -609,7 +666,10 @@ export class ERC721ProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferOwnership.estimateGasAsync.bind(self, newOwner.toLowerCase()), self.transferOwnership.estimateGasAsync.bind(
self,
newOwner.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -625,8 +685,9 @@ export class ERC721ProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData); const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -639,10 +700,14 @@ export class ERC721ProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(newOwner: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
newOwner: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -658,7 +723,12 @@ export class ERC721ProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(newOwner: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
newOwner: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -668,8 +738,9 @@ export class ERC721ProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -678,33 +749,33 @@ export class ERC721ProxyContract 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('transferOwnership(address)'); const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)');
// 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(newOwner: string): string { getABIEncodedTransactionData(
newOwner: string,
): string {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as ERC721ProxyContract; const self = this as any as ERC721ProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
newOwner.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<ERC721ProxyEventArgs, ERC721ProxyEvents>; private readonly _subscriptionManager: SubscriptionManager<ERC721ProxyEventArgs, ERC721ProxyEvents>;
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<ERC721ProxyContract> { ): Promise<ERC721ProxyContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -717,11 +788,8 @@ export class ERC721ProxyContract 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 ERC721ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return ERC721ProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -738,13 +806,17 @@ export class ERC721ProxyContract 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),
); );
@ -752,16 +824,12 @@ export class ERC721ProxyContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ERC721Proxy successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`ERC721Proxy successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ERC721ProxyContract( const contractInstance = new ERC721ProxyContract(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
*/ */
@ -776,7 +844,8 @@ export class ERC721ProxyContract extends BaseContract {
}, },
], ],
name: 'addAuthorizedAddress', name: 'addAuthorizedAddress',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -809,14 +878,16 @@ export class ERC721ProxyContract extends BaseContract {
}, },
], ],
name: 'removeAuthorizedAddress', name: 'removeAuthorizedAddress',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'owner', name: 'owner',
outputs: [ outputs: [
{ {
@ -841,14 +912,16 @@ export class ERC721ProxyContract extends BaseContract {
}, },
], ],
name: 'removeAuthorizedAddressAtIndex', name: 'removeAuthorizedAddressAtIndex',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'getProxyId', name: 'getProxyId',
outputs: [ outputs: [
{ {
@ -881,7 +954,8 @@ export class ERC721ProxyContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'getAuthorizedAddresses', name: 'getAuthorizedAddresses',
outputs: [ outputs: [
{ {
@ -902,14 +976,17 @@ export class ERC721ProxyContract extends BaseContract {
}, },
], ],
name: 'transferOwnership', name: 'transferOwnership',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
inputs: [], inputs: [
outputs: [], ],
outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'fallback', type: 'fallback',
@ -929,7 +1006,8 @@ export class ERC721ProxyContract extends BaseContract {
}, },
], ],
name: 'AuthorizedAddressAdded', name: 'AuthorizedAddressAdded',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
@ -947,7 +1025,8 @@ export class ERC721ProxyContract extends BaseContract {
}, },
], ],
name: 'AuthorizedAddressRemoved', name: 'AuthorizedAddressRemoved',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -1021,12 +1100,7 @@ export class ERC721ProxyContract 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('ERC721Proxy', ERC721ProxyContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('ERC721Proxy', ERC721ProxyContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<ERC721ProxyEventArgs, ERC721ProxyEvents>( this._subscriptionManager = new SubscriptionManager<ERC721ProxyEventArgs, ERC721ProxyEvents>(

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,
@ -60,6 +57,7 @@ export interface ERC721TokenApprovalForAllEventArgs extends DecodedLogArgs {
_approved: boolean; _approved: boolean;
} }
/* 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
@ -69,7 +67,8 @@ export class ERC721TokenContract extends BaseContract {
_tokenId: BigNumber, _tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -79,8 +78,9 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); const encodedData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -89,22 +89,24 @@ export class ERC721TokenContract 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('getApproved(uint256)'); const abiEncoder = self._lookupAbiEncoder('getApproved(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(_tokenId: BigNumber): string { getABIEncodedTransactionData(
_tokenId: BigNumber,
): string {
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId]); const abiEncodedTransactionData = self._strictEncodeArguments('getApproved(uint256)', [_tokenId
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -116,10 +118,9 @@ export class ERC721TokenContract extends BaseContract {
): Promise<string> { ): Promise<string> {
assert.isString('_approved', _approved); assert.isString('_approved', _approved);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved.toLowerCase(),
_approved.toLowerCase(), _tokenId
_tokenId,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -128,7 +129,11 @@ export class ERC721TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.approve.estimateGasAsync.bind(self, _approved.toLowerCase(), _tokenId), self.approve.estimateGasAsync.bind(
self,
_approved.toLowerCase(),
_tokenId
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -146,8 +151,10 @@ export class ERC721TokenContract extends BaseContract {
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_approved', _approved); assert.isString('_approved', _approved);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const txHashPromise = self.approve.sendTransactionAsync(_approved.toLowerCase(), _tokenId, txData); const txHashPromise = self.approve.sendTransactionAsync(_approved.toLowerCase(),
_tokenId
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -167,10 +174,9 @@ export class ERC721TokenContract extends BaseContract {
): Promise<number> { ): Promise<number> {
assert.isString('_approved', _approved); assert.isString('_approved', _approved);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved.toLowerCase(),
_approved.toLowerCase(), _tokenId
_tokenId,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -192,7 +198,8 @@ export class ERC721TokenContract extends BaseContract {
_tokenId: BigNumber, _tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('_approved', _approved); assert.isString('_approved', _approved);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -203,10 +210,9 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [ const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_approved.toLowerCase(),
_approved.toLowerCase(), _tokenId
_tokenId,
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -216,25 +222,26 @@ export class ERC721TokenContract 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<void>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<void
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_approved: string, _tokenId: BigNumber): string { getABIEncodedTransactionData(
_approved: string,
_tokenId: BigNumber,
): string {
assert.isString('_approved', _approved); assert.isString('_approved', _approved);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_approved.toLowerCase(),
_approved.toLowerCase(), _tokenId
_tokenId,
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -249,11 +256,10 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -262,7 +268,12 @@ export class ERC721TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferFrom.estimateGasAsync.bind(self, _from.toLowerCase(), _to.toLowerCase(), _tokenId), self.transferFrom.estimateGasAsync.bind(
self,
_from.toLowerCase(),
_to.toLowerCase(),
_tokenId
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -282,13 +293,11 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const txHashPromise = self.transferFrom.sendTransactionAsync( const txHashPromise = self.transferFrom.sendTransactionAsync(_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
txData, , txData);
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -310,11 +319,10 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -337,7 +345,8 @@ export class ERC721TokenContract extends BaseContract {
_tokenId: BigNumber, _tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
@ -349,11 +358,10 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -363,27 +371,29 @@ export class ERC721TokenContract 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<void>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<void
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(_from: string, _to: string, _tokenId: BigNumber): string { getABIEncodedTransactionData(
_from: string,
_to: string,
_tokenId: BigNumber,
): string {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -398,11 +408,10 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -411,7 +420,12 @@ export class ERC721TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.safeTransferFrom1.estimateGasAsync.bind(self, _from.toLowerCase(), _to.toLowerCase(), _tokenId), self.safeTransferFrom1.estimateGasAsync.bind(
self,
_from.toLowerCase(),
_to.toLowerCase(),
_tokenId
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -431,13 +445,11 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const txHashPromise = self.safeTransferFrom1.sendTransactionAsync( const txHashPromise = self.safeTransferFrom1.sendTransactionAsync(_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
txData, , txData);
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -459,11 +471,10 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -486,7 +497,8 @@ export class ERC721TokenContract extends BaseContract {
_tokenId: BigNumber, _tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
@ -498,11 +510,10 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -512,27 +523,29 @@ export class ERC721TokenContract 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('safeTransferFrom(address,address,uint256)'); const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256)');
// 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(_from: string, _to: string, _tokenId: BigNumber): string { getABIEncodedTransactionData(
_from: string,
_to: string,
_tokenId: BigNumber,
): string {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -542,7 +555,8 @@ export class ERC721TokenContract extends BaseContract {
_tokenId: BigNumber, _tokenId: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<string> { ): Promise<string
> {
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -552,8 +566,9 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); const encodedData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -562,22 +577,24 @@ export class ERC721TokenContract 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('ownerOf(uint256)'); const abiEncoder = self._lookupAbiEncoder('ownerOf(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(_tokenId: BigNumber): string { getABIEncodedTransactionData(
_tokenId: BigNumber,
): string {
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId]); const abiEncodedTransactionData = self._strictEncodeArguments('ownerOf(uint256)', [_tokenId
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -586,7 +603,8 @@ export class ERC721TokenContract 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,
@ -596,8 +614,9 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
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,
@ -606,22 +625,24 @@ export class ERC721TokenContract 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 ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -633,10 +654,9 @@ export class ERC721TokenContract extends BaseContract {
): Promise<string> { ): Promise<string> {
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
assert.isBoolean('_approved', _approved); assert.isBoolean('_approved', _approved);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator.toLowerCase(),
_operator.toLowerCase(), _approved
_approved,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -645,7 +665,11 @@ export class ERC721TokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.setApprovalForAll.estimateGasAsync.bind(self, _operator.toLowerCase(), _approved), self.setApprovalForAll.estimateGasAsync.bind(
self,
_operator.toLowerCase(),
_approved
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -663,12 +687,10 @@ export class ERC721TokenContract extends BaseContract {
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
assert.isBoolean('_approved', _approved); assert.isBoolean('_approved', _approved);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const txHashPromise = self.setApprovalForAll.sendTransactionAsync( const txHashPromise = self.setApprovalForAll.sendTransactionAsync(_operator.toLowerCase(),
_operator.toLowerCase(), _approved
_approved, , txData);
txData,
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -688,10 +710,9 @@ export class ERC721TokenContract extends BaseContract {
): Promise<number> { ): Promise<number> {
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
assert.isBoolean('_approved', _approved); assert.isBoolean('_approved', _approved);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator.toLowerCase(),
_operator.toLowerCase(), _approved
_approved,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -713,7 +734,8 @@ export class ERC721TokenContract extends BaseContract {
_approved: boolean, _approved: boolean,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
assert.isBoolean('_approved', _approved); assert.isBoolean('_approved', _approved);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -724,10 +746,9 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ const encodedData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator.toLowerCase(),
_operator.toLowerCase(), _approved
_approved,
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -737,25 +758,26 @@ export class ERC721TokenContract 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('setApprovalForAll(address,bool)'); const abiEncoder = self._lookupAbiEncoder('setApprovalForAll(address,bool)');
// 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(_operator: string, _approved: boolean): string { getABIEncodedTransactionData(
_operator: string,
_approved: boolean,
): string {
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
assert.isBoolean('_approved', _approved); assert.isBoolean('_approved', _approved);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [ const abiEncodedTransactionData = self._strictEncodeArguments('setApprovalForAll(address,bool)', [_operator.toLowerCase(),
_operator.toLowerCase(), _approved
_approved,
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -772,12 +794,11 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.isString('_data', _data); assert.isString('_data', _data);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId,
_data, _data
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -791,7 +812,7 @@ export class ERC721TokenContract extends BaseContract {
_from.toLowerCase(), _from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId,
_data, _data
), ),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
@ -814,14 +835,12 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.isString('_data', _data); assert.isString('_data', _data);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const txHashPromise = self.safeTransferFrom2.sendTransactionAsync( const txHashPromise = self.safeTransferFrom2.sendTransactionAsync(_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId,
_data, _data
txData, , txData);
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -845,12 +864,11 @@ export class ERC721TokenContract extends BaseContract {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.isString('_data', _data); assert.isString('_data', _data);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId,
_data, _data
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -874,7 +892,8 @@ export class ERC721TokenContract extends BaseContract {
_data: string, _data: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
@ -887,12 +906,11 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [ const encodedData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from.toLowerCase(),
_from.toLowerCase(),
_to.toLowerCase(), _to.toLowerCase(),
_tokenId, _tokenId,
_data, _data
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -902,28 +920,33 @@ export class ERC721TokenContract 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('safeTransferFrom(address,address,uint256,bytes)'); const abiEncoder = self._lookupAbiEncoder('safeTransferFrom(address,address,uint256,bytes)');
// 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(_from: string, _to: string, _tokenId: BigNumber, _data: string): string { getABIEncodedTransactionData(
_from: string,
_to: string,
_tokenId: BigNumber,
_data: string,
): string {
assert.isString('_from', _from); assert.isString('_from', _from);
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_tokenId', _tokenId); assert.isBigNumber('_tokenId', _tokenId);
assert.isString('_data', _data); assert.isString('_data', _data);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('safeTransferFrom(address,address,uint256,bytes)', [_from.toLowerCase(),
'safeTransferFrom(address,address,uint256,bytes)', _to.toLowerCase(),
[_from.toLowerCase(), _to.toLowerCase(), _tokenId, _data], _tokenId,
); _data
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -933,7 +956,8 @@ export class ERC721TokenContract extends BaseContract {
_operator: string, _operator: string,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<boolean> { ): Promise<boolean
> {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -944,10 +968,9 @@ export class ERC721TokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ const encodedData = self._strictEncodeArguments('isApprovedForAll(address,address)', [_owner.toLowerCase(),
_owner.toLowerCase(), _operator.toLowerCase()
_operator.toLowerCase(),
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -957,35 +980,36 @@ export class ERC721TokenContract 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('isApprovedForAll(address,address)'); const abiEncoder = self._lookupAbiEncoder('isApprovedForAll(address,address)');
// 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(_owner: string, _operator: string): string { getABIEncodedTransactionData(
_owner: string,
_operator: string,
): string {
assert.isString('_owner', _owner); assert.isString('_owner', _owner);
assert.isString('_operator', _operator); assert.isString('_operator', _operator);
const self = (this as any) as ERC721TokenContract; const self = this as any as ERC721TokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('isApprovedForAll(address,address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('isApprovedForAll(address,address)', [_owner.toLowerCase(),
_owner.toLowerCase(), _operator.toLowerCase()
_operator.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
private readonly _subscriptionManager: SubscriptionManager<ERC721TokenEventArgs, ERC721TokenEvents>; private readonly _subscriptionManager: SubscriptionManager<ERC721TokenEventArgs, ERC721TokenEvents>;
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<ERC721TokenContract> { ): Promise<ERC721TokenContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -998,11 +1022,8 @@ export class ERC721TokenContract 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 ERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return ERC721TokenContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -1019,13 +1040,17 @@ export class ERC721TokenContract 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),
); );
@ -1033,16 +1058,12 @@ export class ERC721TokenContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ERC721Token successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`ERC721Token successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ERC721TokenContract( const contractInstance = new ERC721TokenContract(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
*/ */
@ -1080,7 +1101,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'approve', name: 'approve',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -1102,7 +1124,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'transferFrom', name: 'transferFrom',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -1124,7 +1147,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'safeTransferFrom', name: 'safeTransferFrom',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -1180,7 +1204,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'setApprovalForAll', name: 'setApprovalForAll',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -1206,7 +1231,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'safeTransferFrom', name: 'safeTransferFrom',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -1254,7 +1280,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'Transfer', name: 'Transfer',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
@ -1277,7 +1304,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'Approval', name: 'Approval',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
@ -1300,7 +1328,8 @@ export class ERC721TokenContract extends BaseContract {
}, },
], ],
name: 'ApprovalForAll', name: 'ApprovalForAll',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -1374,12 +1403,7 @@ export class ERC721TokenContract 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('ERC721Token', ERC721TokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('ERC721Token', ERC721TokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<ERC721TokenEventArgs, ERC721TokenEvents>( this._subscriptionManager = new SubscriptionManager<ERC721TokenEventArgs, ERC721TokenEvents>(

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,16 +129,12 @@ 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
*/ */
@ -160,20 +162,8 @@ 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']);
} }
} }

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,15 +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 IAssetProxyContract extends BaseContract { export class IAssetProxyContract extends BaseContract {
public addAuthorizedAddress = { public addAuthorizedAddress = {
async sendTransactionAsync(target: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -39,7 +44,10 @@ export class IAssetProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.addAuthorizedAddress.estimateGasAsync.bind(self, target.toLowerCase()), self.addAuthorizedAddress.estimateGasAsync.bind(
self,
target.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -55,8 +63,9 @@ export class IAssetProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData); const txHashPromise = self.addAuthorizedAddress.sendTransactionAsync(target.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -69,10 +78,14 @@ export class IAssetProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(target: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -88,7 +101,12 @@ export class IAssetProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(target: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
target: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -98,8 +116,9 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -108,32 +127,36 @@ export class IAssetProxyContract 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('addAuthorizedAddress(address)'); const abiEncoder = self._lookupAbiEncoder('addAuthorizedAddress(address)');
// 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(target: string): string { getABIEncodedTransactionData(
target: string,
): string {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('addAuthorizedAddress(address)', [target.toLowerCase()
target.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public removeAuthorizedAddress = { public removeAuthorizedAddress = {
async sendTransactionAsync(target: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -141,7 +164,10 @@ export class IAssetProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.removeAuthorizedAddress.estimateGasAsync.bind(self, target.toLowerCase()), self.removeAuthorizedAddress.estimateGasAsync.bind(
self,
target.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -157,8 +183,9 @@ export class IAssetProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase(), txData); const txHashPromise = self.removeAuthorizedAddress.sendTransactionAsync(target.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -171,10 +198,14 @@ export class IAssetProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(target: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
target: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -190,7 +221,12 @@ export class IAssetProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(target: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
target: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -200,8 +236,9 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()]); const encodedData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -210,23 +247,23 @@ export class IAssetProxyContract 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('removeAuthorizedAddress(address)'); const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddress(address)');
// 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(target: string): string { getABIEncodedTransactionData(
target: string,
): string {
assert.isString('target', target); assert.isString('target', target);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddress(address)', [target.toLowerCase()
target.toLowerCase(),
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -239,10 +276,9 @@ export class IAssetProxyContract extends BaseContract {
): Promise<string> { ): Promise<string> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -251,7 +287,11 @@ export class IAssetProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(self, target.toLowerCase(), index), self.removeAuthorizedAddressAtIndex.estimateGasAsync.bind(
self,
target.toLowerCase(),
index
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -269,12 +309,10 @@ export class IAssetProxyContract extends BaseContract {
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync( const txHashPromise = self.removeAuthorizedAddressAtIndex.sendTransactionAsync(target.toLowerCase(),
target.toLowerCase(), index
index, , txData);
txData,
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -294,10 +332,9 @@ export class IAssetProxyContract extends BaseContract {
): Promise<number> { ): Promise<number> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -319,7 +356,8 @@ export class IAssetProxyContract extends BaseContract {
index: BigNumber, index: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
@ -330,10 +368,9 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [ const encodedData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
target.toLowerCase(), index
index,
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -343,26 +380,27 @@ export class IAssetProxyContract 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('removeAuthorizedAddressAtIndex(address,uint256)'); const abiEncoder = self._lookupAbiEncoder('removeAuthorizedAddressAtIndex(address,uint256)');
// 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(target: string, index: BigNumber): string { getABIEncodedTransactionData(
target: string,
index: BigNumber,
): string {
assert.isString('target', target); assert.isString('target', target);
assert.isBigNumber('index', index); assert.isBigNumber('index', index);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('removeAuthorizedAddressAtIndex(address,uint256)', [target.toLowerCase(),
'removeAuthorizedAddressAtIndex(address,uint256)', index
[target.toLowerCase(), index], ]);
);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
@ -378,12 +416,11 @@ export class IAssetProxyContract extends BaseContract {
assert.isString('from', from); assert.isString('from', from);
assert.isString('to', to); assert.isString('to', to);
assert.isBigNumber('amount', amount); assert.isBigNumber('amount', amount);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [assetData,
assetData,
from.toLowerCase(), from.toLowerCase(),
to.toLowerCase(), to.toLowerCase(),
amount, amount
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -392,7 +429,13 @@ export class IAssetProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferFrom.estimateGasAsync.bind(self, assetData, from.toLowerCase(), to.toLowerCase(), amount), self.transferFrom.estimateGasAsync.bind(
self,
assetData,
from.toLowerCase(),
to.toLowerCase(),
amount
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -414,14 +457,12 @@ export class IAssetProxyContract extends BaseContract {
assert.isString('from', from); assert.isString('from', from);
assert.isString('to', to); assert.isString('to', to);
assert.isBigNumber('amount', amount); assert.isBigNumber('amount', amount);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const txHashPromise = self.transferFrom.sendTransactionAsync( const txHashPromise = self.transferFrom.sendTransactionAsync(assetData,
assetData,
from.toLowerCase(), from.toLowerCase(),
to.toLowerCase(), to.toLowerCase(),
amount, amount
txData, , txData);
);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -445,12 +486,11 @@ export class IAssetProxyContract extends BaseContract {
assert.isString('from', from); assert.isString('from', from);
assert.isString('to', to); assert.isString('to', to);
assert.isBigNumber('amount', amount); assert.isBigNumber('amount', amount);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [assetData,
assetData,
from.toLowerCase(), from.toLowerCase(),
to.toLowerCase(), to.toLowerCase(),
amount, amount
]); ]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -474,7 +514,8 @@ export class IAssetProxyContract extends BaseContract {
amount: BigNumber, amount: BigNumber,
callData: Partial<CallData> = {}, callData: Partial<CallData> = {},
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<void> { ): Promise<void
> {
assert.isString('assetData', assetData); assert.isString('assetData', assetData);
assert.isString('from', from); assert.isString('from', from);
assert.isString('to', to); assert.isString('to', to);
@ -487,12 +528,11 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [ const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [assetData,
assetData,
from.toLowerCase(), from.toLowerCase(),
to.toLowerCase(), to.toLowerCase(),
amount, amount
]); ]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -502,33 +542,42 @@ export class IAssetProxyContract 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(bytes,address,address,uint256)'); const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
// 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(assetData: string, from: string, to: string, amount: BigNumber): string { getABIEncodedTransactionData(
assetData: string,
from: string,
to: string,
amount: BigNumber,
): string {
assert.isString('assetData', assetData); assert.isString('assetData', assetData);
assert.isString('from', from); assert.isString('from', from);
assert.isString('to', to); assert.isString('to', to);
assert.isBigNumber('amount', amount); assert.isBigNumber('amount', amount);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments( const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [assetData,
'transferFrom(bytes,address,address,uint256)', from.toLowerCase(),
[assetData, from.toLowerCase(), to.toLowerCase(), amount], to.toLowerCase(),
); amount
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getProxyId = { public getProxyId = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -537,7 +586,7 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('getProxyId()', []); const encodedData = self._strictEncodeArguments('getProxyId()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -547,26 +596,30 @@ export class IAssetProxyContract 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('getProxyId()'); const abiEncoder = self._lookupAbiEncoder('getProxyId()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as IAssetProxyContract; ): string {
const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []); const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public getAuthorizedAddresses = { public getAuthorizedAddresses = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string[]> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string[]
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -575,7 +628,7 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const encodedData = self._strictEncodeArguments('getAuthorizedAddresses()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -585,29 +638,33 @@ export class IAssetProxyContract 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('getAuthorizedAddresses()'); const abiEncoder = self._lookupAbiEncoder('getAuthorizedAddresses()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as IAssetProxyContract; ): string {
const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []); const abiEncodedTransactionData = self._strictEncodeArguments('getAuthorizedAddresses()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public transferOwnership = { public transferOwnership = {
async sendTransactionAsync(newOwner: string, txData?: Partial<TxData> | undefined): Promise<string> { async sendTransactionAsync(
newOwner: string,
txData?: Partial<TxData> | undefined,
): Promise<string> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -615,7 +672,10 @@ export class IAssetProxyContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferOwnership.estimateGasAsync.bind(self, newOwner.toLowerCase()), self.transferOwnership.estimateGasAsync.bind(
self,
newOwner.toLowerCase()
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -631,8 +691,9 @@ export class IAssetProxyContract extends BaseContract {
timeoutMs?: number, timeoutMs?: number,
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> { ): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase(), txData); const txHashPromise = self.transferOwnership.sendTransactionAsync(newOwner.toLowerCase()
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -645,10 +706,14 @@ export class IAssetProxyContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(newOwner: string, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
newOwner: string,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -664,7 +729,12 @@ export class IAssetProxyContract extends BaseContract {
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
async callAsync(newOwner: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<void> { async callAsync(
newOwner: string,
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<void
> {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -674,8 +744,9 @@ export class IAssetProxyContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()]); const encodedData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -684,32 +755,32 @@ export class IAssetProxyContract 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('transferOwnership(address)'); const abiEncoder = self._lookupAbiEncoder('transferOwnership(address)');
// 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(newOwner: string): string { getABIEncodedTransactionData(
newOwner: string,
): string {
assert.isString('newOwner', newOwner); assert.isString('newOwner', newOwner);
const self = (this as any) as IAssetProxyContract; const self = this as any as IAssetProxyContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transferOwnership(address)', [newOwner.toLowerCase()
newOwner.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) },
): Promise<IAssetProxyContract> { ): Promise<IAssetProxyContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -722,11 +793,8 @@ export class IAssetProxyContract 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 IAssetProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return IAssetProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -743,13 +811,17 @@ export class IAssetProxyContract 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),
); );
@ -757,16 +829,12 @@ export class IAssetProxyContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`IAssetProxy successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`IAssetProxy successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new IAssetProxyContract( const contractInstance = new IAssetProxyContract(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
*/ */
@ -781,7 +849,8 @@ export class IAssetProxyContract extends BaseContract {
}, },
], ],
name: 'addAuthorizedAddress', name: 'addAuthorizedAddress',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -795,7 +864,8 @@ export class IAssetProxyContract extends BaseContract {
}, },
], ],
name: 'removeAuthorizedAddress', name: 'removeAuthorizedAddress',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -813,7 +883,8 @@ export class IAssetProxyContract extends BaseContract {
}, },
], ],
name: 'removeAuthorizedAddressAtIndex', name: 'removeAuthorizedAddressAtIndex',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -839,14 +910,16 @@ export class IAssetProxyContract extends BaseContract {
}, },
], ],
name: 'transferFrom', name: 'transferFrom',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'getProxyId', name: 'getProxyId',
outputs: [ outputs: [
{ {
@ -860,7 +933,8 @@ export class IAssetProxyContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'getAuthorizedAddresses', name: 'getAuthorizedAddresses',
outputs: [ outputs: [
{ {
@ -881,7 +955,8 @@ export class IAssetProxyContract extends BaseContract {
}, },
], ],
name: 'transferOwnership', name: 'transferOwnership',
outputs: [], outputs: [
],
payable: false, payable: false,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',
type: 'function', type: 'function',
@ -889,12 +964,7 @@ export class IAssetProxyContract 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('IAssetProxy', IAssetProxyContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('IAssetProxy', IAssetProxyContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
} }

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,11 +48,10 @@ 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(
{ {
@ -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,16 +141,12 @@ 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
*/ */
@ -182,12 +182,7 @@ 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']);
} }

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,16 +135,12 @@ 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
*/ */
@ -170,12 +172,7 @@ 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']);
} }

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}]
[
{ orderStatus: number; orderHash: string; orderTakerAssetFilledAmount: BigNumber },
{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}
]
>(rawCallResult); >(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;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string, takerAddress: string,
): 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,10 +100,9 @@ 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(
{ {
@ -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}>]
[
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); >(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;
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[],
): 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<{
makerBalance: BigNumber;
makerAllowance: BigNumber;
takerBalance: BigNumber;
takerAllowance: BigNumber;
makerZrxBalance: BigNumber;
makerZrxAllowance: BigNumber;
takerZrxBalance: BigNumber;
takerZrxAllowance: BigNumber;
}>
>(rawCallResult); >(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;
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[],
): 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,10 +262,9 @@ 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(
{ {
@ -438,25 +274,26 @@ 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,10 +316,9 @@ 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(
{ {
@ -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,60 +382,35 @@ 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;
feeRecipientAddress: string;
senderAddress: string;
makerAssetAmount: BigNumber;
takerAssetAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
salt: BigNumber;
makerAssetData: string;
takerAssetData: string;
},
takerAddress: string, takerAddress: string,
): 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> {
@ -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,
@ -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,16 +471,14 @@ 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
*/ */
@ -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,7 +602,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
@ -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,7 +754,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
@ -1029,7 +816,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddresses', name: 'takerAddresses',
@ -1074,7 +861,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
@ -1186,7 +973,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerAssetData', name: 'takerAssetData',
type: 'bytes', type: 'bytes',
}, },
], ]
}, },
{ {
name: 'takerAddress', name: 'takerAddress',
@ -1231,7 +1018,7 @@ export class OrderValidatorContract extends BaseContract {
name: 'takerZrxAllowance', name: 'takerZrxAllowance',
type: 'uint256', type: 'uint256',
}, },
], ]
}, },
], ],
payable: false, payable: false,
@ -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,20 +1045,8 @@ 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']);
} }
} }

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 ZRXTokenEventArgs = ZRXTokenTransferEventArgs | ZRXTokenApprovalEventArgs; export type ZRXTokenEventArgs =
| ZRXTokenTransferEventArgs
| ZRXTokenApprovalEventArgs;
export enum ZRXTokenEvents { export enum ZRXTokenEvents {
Transfer = 'Transfer', Transfer = 'Transfer',
@ -50,12 +49,17 @@ export interface ZRXTokenApprovalEventArgs 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
export class ZRXTokenContract extends BaseContract { export class ZRXTokenContract extends BaseContract {
public name = { public name = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -64,7 +68,7 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
const encodedData = self._strictEncodeArguments('name()', []); const encodedData = self._strictEncodeArguments('name()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -74,20 +78,20 @@ export class ZRXTokenContract 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('name()'); const abiEncoder = self._lookupAbiEncoder('name()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ZRXTokenContract; ): string {
const self = this as any as ZRXTokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('name()', []); const abiEncodedTransactionData = self._strictEncodeArguments('name()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -100,10 +104,9 @@ export class ZRXTokenContract extends BaseContract {
): 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -112,7 +115,11 @@ export class ZRXTokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.approve.estimateGasAsync.bind(self, _spender.toLowerCase(), _value), self.approve.estimateGasAsync.bind(
self,
_spender.toLowerCase(),
_value
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -130,8 +137,10 @@ export class ZRXTokenContract extends BaseContract {
): 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(), _value, txData); const txHashPromise = self.approve.sendTransactionAsync(_spender.toLowerCase(),
_value
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -151,10 +160,9 @@ export class ZRXTokenContract extends BaseContract {
): 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -176,7 +184,8 @@ export class ZRXTokenContract extends BaseContract {
_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, [
@ -187,10 +196,9 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -200,31 +208,36 @@ export class ZRXTokenContract 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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,
@ -233,7 +246,7 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
const encodedData = self._strictEncodeArguments('totalSupply()', []); const encodedData = self._strictEncodeArguments('totalSupply()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -243,20 +256,20 @@ export class ZRXTokenContract 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 ZRXTokenContract; ): string {
const self = this as any as ZRXTokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []); const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -271,11 +284,10 @@ export class ZRXTokenContract extends BaseContract {
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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -284,7 +296,12 @@ export class ZRXTokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transferFrom.estimateGasAsync.bind(self, _from.toLowerCase(), _to.toLowerCase(), _value), self.transferFrom.estimateGasAsync.bind(
self,
_from.toLowerCase(),
_to.toLowerCase(),
_value
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -304,13 +321,11 @@ export class ZRXTokenContract extends BaseContract {
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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -332,11 +347,10 @@ export class ZRXTokenContract extends BaseContract {
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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -359,7 +373,8 @@ export class ZRXTokenContract 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);
@ -371,11 +386,10 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -385,33 +399,39 @@ export class ZRXTokenContract 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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;
}, },
}; };
public decimals = { public decimals = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<number> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<number
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -420,7 +440,7 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
const encodedData = self._strictEncodeArguments('decimals()', []); const encodedData = self._strictEncodeArguments('decimals()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -430,20 +450,20 @@ export class ZRXTokenContract 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('decimals()'); const abiEncoder = self._lookupAbiEncoder('decimals()');
// tslint:disable boolean-naming // tslint:disable boolean-naming
const result = abiEncoder.strictDecodeReturnValue<number>(rawCallResult); const result = abiEncoder.strictDecodeReturnValue<number
>(rawCallResult);
// tslint:enable boolean-naming // tslint:enable boolean-naming
return result; return result;
}, },
getABIEncodedTransactionData(): string { getABIEncodedTransactionData(
const self = (this as any) as ZRXTokenContract; ): string {
const self = this as any as ZRXTokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []); const abiEncodedTransactionData = self._strictEncodeArguments('decimals()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -453,7 +473,8 @@ export class ZRXTokenContract 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,
@ -463,8 +484,9 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
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,
@ -473,27 +495,33 @@ export class ZRXTokenContract 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()]); const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner.toLowerCase()
]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
}; };
public symbol = { public symbol = {
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> { async callAsync(
callData: Partial<CallData> = {},
defaultBlock?: BlockParam,
): Promise<string
> {
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
schemas.addressSchema, schemas.addressSchema,
schemas.numberSchema, schemas.numberSchema,
@ -502,7 +530,7 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
const encodedData = self._strictEncodeArguments('symbol()', []); const encodedData = self._strictEncodeArguments('symbol()', []);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
@ -512,20 +540,20 @@ export class ZRXTokenContract 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('symbol()'); const abiEncoder = self._lookupAbiEncoder('symbol()');
// 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(): string { getABIEncodedTransactionData(
const self = (this as any) as ZRXTokenContract; ): string {
const self = this as any as ZRXTokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []); const abiEncodedTransactionData = self._strictEncodeArguments('symbol()', []);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -538,8 +566,10 @@ export class ZRXTokenContract extends BaseContract {
): 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -547,7 +577,11 @@ export class ZRXTokenContract extends BaseContract {
data: encodedData, data: encodedData,
}, },
self._web3Wrapper.getContractDefaults(), self._web3Wrapper.getContractDefaults(),
self.transfer.estimateGasAsync.bind(self, _to.toLowerCase(), _value), self.transfer.estimateGasAsync.bind(
self,
_to.toLowerCase(),
_value
),
); );
if (txDataWithDefaults.from !== undefined) { if (txDataWithDefaults.from !== undefined) {
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
@ -565,8 +599,10 @@ export class ZRXTokenContract extends BaseContract {
): 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(), _value, txData); const txHashPromise = self.transfer.sendTransactionAsync(_to.toLowerCase(),
_value
, txData);
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>( return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
txHashPromise, txHashPromise,
(async (): Promise<TransactionReceiptWithDecodedLogs> => { (async (): Promise<TransactionReceiptWithDecodedLogs> => {
@ -579,11 +615,17 @@ export class ZRXTokenContract extends BaseContract {
})(), })(),
); );
}, },
async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial<TxData> | undefined): Promise<number> { async estimateGasAsync(
_to: string,
_value: BigNumber,
txData?: Partial<TxData> | undefined,
): Promise<number> {
assert.isString('_to', _to); assert.isString('_to', _to);
assert.isBigNumber('_value', _value); assert.isBigNumber('_value', _value);
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(), _value]); const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_value
]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{ {
to: self.address, to: self.address,
@ -604,7 +646,8 @@ export class ZRXTokenContract extends BaseContract {
_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, [
@ -615,8 +658,10 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
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,
@ -625,25 +670,26 @@ export class ZRXTokenContract 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [ const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to.toLowerCase(),
_to.toLowerCase(), _value
_value,
]); ]);
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
@ -654,7 +700,8 @@ export class ZRXTokenContract 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, [
@ -665,10 +712,9 @@ export class ZRXTokenContract extends BaseContract {
if (defaultBlock !== undefined) { if (defaultBlock !== undefined) {
assert.isBlockParam('defaultBlock', defaultBlock); assert.isBlockParam('defaultBlock', defaultBlock);
} }
const self = (this as any) as ZRXTokenContract; const self = this as any as ZRXTokenContract;
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(
{ {
@ -678,35 +724,36 @@ export class ZRXTokenContract 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 ZRXTokenContract; const self = this as any as ZRXTokenContract;
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<ZRXTokenEventArgs, ZRXTokenEvents>; private readonly _subscriptionManager: SubscriptionManager<ZRXTokenEventArgs, ZRXTokenEvents>;
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<ZRXTokenContract> { ): Promise<ZRXTokenContract> {
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [ assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
schemas.addressSchema, schemas.addressSchema,
@ -719,11 +766,8 @@ export class ZRXTokenContract 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 ZRXTokenContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly, );
{},
);
return ZRXTokenContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
} }
public static async deployAsync( public static async deployAsync(
bytecode: string, bytecode: string,
@ -740,13 +784,17 @@ export class ZRXTokenContract 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),
); );
@ -754,16 +802,12 @@ export class ZRXTokenContract extends BaseContract {
logUtils.log(`transactionHash: ${txHash}`); logUtils.log(`transactionHash: ${txHash}`);
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash); const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
logUtils.log(`ZRXToken successfully deployed at ${txReceipt.contractAddress}`); logUtils.log(`ZRXToken successfully deployed at ${txReceipt.contractAddress}`);
const contractInstance = new ZRXTokenContract( const contractInstance = new ZRXTokenContract(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
*/ */
@ -771,7 +815,8 @@ export class ZRXTokenContract extends BaseContract {
const abi = [ const abi = [
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'name', name: 'name',
outputs: [ outputs: [
{ {
@ -806,7 +851,8 @@ export class ZRXTokenContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'totalSupply', name: 'totalSupply',
outputs: [ outputs: [
{ {
@ -845,7 +891,8 @@ export class ZRXTokenContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'decimals', name: 'decimals',
outputs: [ outputs: [
{ {
@ -876,7 +923,8 @@ export class ZRXTokenContract extends BaseContract {
}, },
{ {
constant: true, constant: true,
inputs: [], inputs: [
],
name: 'symbol', name: 'symbol',
outputs: [ outputs: [
{ {
@ -932,8 +980,10 @@ export class ZRXTokenContract extends BaseContract {
type: 'function', type: 'function',
}, },
{ {
inputs: [], inputs: [
outputs: [], ],
outputs: [
],
payable: false, payable: false,
type: 'constructor', type: 'constructor',
}, },
@ -957,7 +1007,8 @@ export class ZRXTokenContract extends BaseContract {
}, },
], ],
name: 'Transfer', name: 'Transfer',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
{ {
@ -980,7 +1031,8 @@ export class ZRXTokenContract extends BaseContract {
}, },
], ],
name: 'Approval', name: 'Approval',
outputs: [], outputs: [
],
type: 'event', type: 'event',
}, },
] as ContractAbi; ] as ContractAbi;
@ -1054,12 +1106,7 @@ export class ZRXTokenContract 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('ZRXToken', ZRXTokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies); super('ZRXToken', ZRXTokenContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']); classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
this._subscriptionManager = new SubscriptionManager<ZRXTokenEventArgs, ZRXTokenEvents>( this._subscriptionManager = new SubscriptionManager<ZRXTokenEventArgs, ZRXTokenEvents>(