Rearrange assertions t match parameter order
This commit is contained in:
parent
b68d16820f
commit
ab8544b0ff
@ -54,20 +54,18 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
public async getBalanceAsync(
|
public async getBalanceAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
let balance = await tokenContract.balanceOf.callAsync(normalizedOwnerAddress, txData, defaultBlock);
|
let balance = await tokenContract.balanceOf.callAsync(normalizedOwnerAddress, txData, methodOpts.defaultBlock);
|
||||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
||||||
balance = new BigNumber(balance);
|
balance = new BigNumber(balance);
|
||||||
return balance;
|
return balance;
|
||||||
@ -90,16 +88,14 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
amountInBaseUnits: BigNumber,
|
amountInBaseUnits: BigNumber,
|
||||||
txOpts: TransactionOpts = {},
|
txOpts: TransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isETHAddressHex('spenderAddress', spenderAddress);
|
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);
|
||||||
if (!_.isUndefined(txOpts)) {
|
assert.isETHAddressHex('spenderAddress', spenderAddress);
|
||||||
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
||||||
const normalizedSpenderAddress = spenderAddress.toLowerCase();
|
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
|
||||||
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
|
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
|
||||||
|
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
||||||
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
|
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
||||||
|
const normalizedSpenderAddress = spenderAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const txHash = await tokenContract.approve.sendTransactionAsync(
|
const txHash = await tokenContract.approve.sendTransactionAsync(
|
||||||
@ -152,26 +148,24 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
spenderAddress: string,
|
spenderAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
|
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
||||||
assert.isETHAddressHex('spenderAddress', spenderAddress);
|
assert.isETHAddressHex('spenderAddress', spenderAddress);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
||||||
const normalizedSpenderAddress = spenderAddress.toLowerCase();
|
const normalizedSpenderAddress = spenderAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
let allowanceInBaseUnits = await tokenContract.allowance.callAsync(
|
let allowanceInBaseUnits = await tokenContract.allowance.callAsync(
|
||||||
normalizedOwnerAddress,
|
normalizedOwnerAddress,
|
||||||
normalizedSpenderAddress,
|
normalizedSpenderAddress,
|
||||||
txData,
|
txData,
|
||||||
defaultBlock,
|
methodOpts.defaultBlock,
|
||||||
);
|
);
|
||||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
||||||
allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits);
|
allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits);
|
||||||
@ -186,7 +180,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
public async getProxyAllowanceAsync(
|
public async getProxyAllowanceAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc20ProxyWrapper.getContractAddress();
|
||||||
const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, methodOpts);
|
const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, methodOpts);
|
||||||
@ -259,15 +253,13 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
txOpts: TransactionOpts = {},
|
txOpts: TransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
assert.isETHAddressHex('toAddress', toAddress);
|
|
||||||
await assert.isSenderAddressAsync('fromAddress', fromAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('fromAddress', fromAddress, this._web3Wrapper);
|
||||||
if (!_.isUndefined(txOpts)) {
|
assert.isETHAddressHex('toAddress', toAddress);
|
||||||
|
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
|
||||||
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedFromAddress = fromAddress.toLowerCase();
|
const normalizedFromAddress = fromAddress.toLowerCase();
|
||||||
const normalizedToAddress = toAddress.toLowerCase();
|
const normalizedToAddress = toAddress.toLowerCase();
|
||||||
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
|
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
|
|
||||||
@ -309,18 +301,16 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
amountInBaseUnits: BigNumber,
|
amountInBaseUnits: BigNumber,
|
||||||
txOpts: TransactionOpts = {},
|
txOpts: TransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.isETHAddressHex('toAddress', toAddress);
|
|
||||||
assert.isETHAddressHex('fromAddress', fromAddress);
|
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
|
assert.isETHAddressHex('fromAddress', fromAddress);
|
||||||
|
assert.isETHAddressHex('toAddress', toAddress);
|
||||||
await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper);
|
||||||
if (!_.isUndefined(txOpts)) {
|
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
|
||||||
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
||||||
}
|
|
||||||
const normalizedToAddress = toAddress.toLowerCase();
|
const normalizedToAddress = toAddress.toLowerCase();
|
||||||
const normalizedFromAddress = fromAddress.toLowerCase();
|
const normalizedFromAddress = fromAddress.toLowerCase();
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedSenderAddress = senderAddress.toLowerCase();
|
const normalizedSenderAddress = senderAddress.toLowerCase();
|
||||||
assert.isValidBaseUnitAmount('amountInBaseUnits', amountInBaseUnits);
|
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
|
|
||||||
@ -366,10 +356,10 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
callback: EventCallback<ArgsType>,
|
callback: EventCallback<ArgsType>,
|
||||||
): string {
|
): string {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
||||||
assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
|
assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
|
||||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||||
assert.isFunction('callback', callback);
|
assert.isFunction('callback', callback);
|
||||||
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const subscriptionToken = this._subscribe<ArgsType>(
|
const subscriptionToken = this._subscribe<ArgsType>(
|
||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
@ -409,10 +399,10 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
|||||||
indexFilterValues: IndexedFilterValues,
|
indexFilterValues: IndexedFilterValues,
|
||||||
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
|
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
||||||
assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
|
assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
|
||||||
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
||||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||||
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const logs = await this._getLogsAsync<ArgsType>(
|
const logs = await this._getLogsAsync<ArgsType>(
|
||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
|
@ -54,20 +54,18 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
public async getTokenCountAsync(
|
public async getTokenCountAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
let balance = await tokenContract.balanceOf.callAsync(normalizedOwnerAddress, txData, defaultBlock);
|
let balance = await tokenContract.balanceOf.callAsync(normalizedOwnerAddress, txData, methodOpts.defaultBlock);
|
||||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
||||||
balance = new BigNumber(balance);
|
balance = new BigNumber(balance);
|
||||||
return balance;
|
return balance;
|
||||||
@ -80,19 +78,21 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return The address of the owner of the NFT
|
* @return The address of the owner of the NFT
|
||||||
*/
|
*/
|
||||||
public async getOwnerOfAsync(tokenAddress: string, tokenId: BigNumber, methodOpts?: MethodOpts): Promise<string> {
|
public async getOwnerOfAsync(
|
||||||
|
tokenAddress: string,
|
||||||
|
tokenId: BigNumber,
|
||||||
|
methodOpts: MethodOpts = {},
|
||||||
|
): Promise<string> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
assert.isBigNumber('tokenId', tokenId);
|
assert.isBigNumber('tokenId', tokenId);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
try {
|
try {
|
||||||
const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId, txData, defaultBlock);
|
const tokenOwner = await tokenContract.ownerOf.callAsync(tokenId, txData, methodOpts.defaultBlock);
|
||||||
return tokenOwner;
|
return tokenOwner;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(ContractWrappersError.ERC721OwnerNotFound);
|
throw new Error(ContractWrappersError.ERC721OwnerNotFound);
|
||||||
@ -110,26 +110,24 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
operatorAddress: string,
|
operatorAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
||||||
assert.isETHAddressHex('operatorAddress', operatorAddress);
|
assert.isETHAddressHex('operatorAddress', operatorAddress);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
||||||
const normalizedOperatorAddress = operatorAddress.toLowerCase();
|
const normalizedOperatorAddress = operatorAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const isApprovedForAll = await tokenContract.isApprovedForAll.callAsync(
|
const isApprovedForAll = await tokenContract.isApprovedForAll.callAsync(
|
||||||
normalizedOwnerAddress,
|
normalizedOwnerAddress,
|
||||||
normalizedOperatorAddress,
|
normalizedOperatorAddress,
|
||||||
txData,
|
txData,
|
||||||
defaultBlock,
|
methodOpts.defaultBlock,
|
||||||
);
|
);
|
||||||
return isApprovedForAll;
|
return isApprovedForAll;
|
||||||
}
|
}
|
||||||
@ -143,19 +141,12 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
public async isProxyApprovedForAllAsync(
|
public async isProxyApprovedForAllAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
ownerAddress: string,
|
ownerAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
|
||||||
assert.isETHAddressHex('ownerAddress', ownerAddress);
|
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
|
||||||
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
||||||
const isProxyApprovedForAll = await this.isApprovedForAllAsync(
|
const isProxyApprovedForAll = await this.isApprovedForAllAsync(
|
||||||
normalizedTokenAddress,
|
tokenAddress,
|
||||||
normalizedOwnerAddress,
|
ownerAddress,
|
||||||
proxyAddress,
|
proxyAddress,
|
||||||
methodOpts,
|
methodOpts,
|
||||||
);
|
);
|
||||||
@ -172,19 +163,17 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
public async getApprovedIfExistsAsync(
|
public async getApprovedIfExistsAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
tokenId: BigNumber,
|
tokenId: BigNumber,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
assert.isBigNumber('tokenId', tokenId);
|
assert.isBigNumber('tokenId', tokenId);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
|
|
||||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const approvedAddress = await tokenContract.getApproved.callAsync(tokenId, txData, defaultBlock);
|
const approvedAddress = await tokenContract.getApproved.callAsync(tokenId, txData, methodOpts.defaultBlock);
|
||||||
if (approvedAddress === constants.NULL_ADDRESS) {
|
if (approvedAddress === constants.NULL_ADDRESS) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -201,7 +190,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
public async isProxyApprovedAsync(
|
public async isProxyApprovedAsync(
|
||||||
tokenAddress: string,
|
tokenAddress: string,
|
||||||
tokenId: BigNumber,
|
tokenId: BigNumber,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
|
||||||
const approvedAddress = await this.getApprovedIfExistsAsync(tokenAddress, tokenId, methodOpts);
|
const approvedAddress = await this.getApprovedIfExistsAsync(tokenAddress, tokenId, methodOpts);
|
||||||
@ -230,9 +219,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('ownerAddress', ownerAddress, this._web3Wrapper);
|
||||||
assert.isETHAddressHex('operatorAddress', operatorAddress);
|
assert.isETHAddressHex('operatorAddress', operatorAddress);
|
||||||
assert.isBoolean('isApproved', isApproved);
|
assert.isBoolean('isApproved', isApproved);
|
||||||
if (!_.isUndefined(txOpts)) {
|
|
||||||
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
const normalizedOwnerAddress = ownerAddress.toLowerCase();
|
||||||
const normalizedOperatorAddress = operatorAddress.toLowerCase();
|
const normalizedOperatorAddress = operatorAddress.toLowerCase();
|
||||||
@ -291,9 +278,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
assert.isETHAddressHex('approvedAddress', approvedAddress);
|
assert.isETHAddressHex('approvedAddress', approvedAddress);
|
||||||
assert.isBigNumber('tokenId', tokenId);
|
assert.isBigNumber('tokenId', tokenId);
|
||||||
if (!_.isUndefined(txOpts)) {
|
|
||||||
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedApprovedAddress = approvedAddress.toLowerCase();
|
const normalizedApprovedAddress = approvedAddress.toLowerCase();
|
||||||
|
|
||||||
@ -351,9 +336,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
assert.isETHAddressHex('receiverAddress', receiverAddress);
|
assert.isETHAddressHex('receiverAddress', receiverAddress);
|
||||||
await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper);
|
||||||
if (!_.isUndefined(txOpts)) {
|
|
||||||
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
assert.doesConformToSchema('txOpts', txOpts, txOptsSchema);
|
||||||
}
|
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const normalizedReceiverAddress = receiverAddress.toLowerCase();
|
const normalizedReceiverAddress = receiverAddress.toLowerCase();
|
||||||
const normalizedSenderAddress = senderAddress.toLowerCase();
|
const normalizedSenderAddress = senderAddress.toLowerCase();
|
||||||
@ -398,10 +381,10 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
callback: EventCallback<ArgsType>,
|
callback: EventCallback<ArgsType>,
|
||||||
): string {
|
): string {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
||||||
assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
|
assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
|
||||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||||
assert.isFunction('callback', callback);
|
assert.isFunction('callback', callback);
|
||||||
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const subscriptionToken = this._subscribe<ArgsType>(
|
const subscriptionToken = this._subscribe<ArgsType>(
|
||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
@ -441,10 +424,10 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
|||||||
indexFilterValues: IndexedFilterValues,
|
indexFilterValues: IndexedFilterValues,
|
||||||
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
|
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
|
||||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
||||||
assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
|
assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
|
||||||
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
||||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||||
|
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||||
const logs = await this._getLogsAsync<ArgsType>(
|
const logs = await this._getLogsAsync<ArgsType>(
|
||||||
normalizedTokenAddress,
|
normalizedTokenAddress,
|
||||||
eventName,
|
eventName,
|
||||||
|
@ -17,8 +17,8 @@ import { ContractWrapper } from './contract_wrapper';
|
|||||||
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated/exchange';
|
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents } from './generated/exchange';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all the functionality related to calling methods and subscribing to
|
* This class includes all the functionality related to calling methods, sending transactions and subscribing to
|
||||||
* events of the 0x Exchange smart contract.
|
* events of the 0x V2 Exchange smart contract.
|
||||||
*/
|
*/
|
||||||
export class ExchangeWrapper extends ContractWrapper {
|
export class ExchangeWrapper extends ContractWrapper {
|
||||||
public abi: ContractAbi = artifacts.Exchange.compilerOutput.abi;
|
public abi: ContractAbi = artifacts.Exchange.compilerOutput.abi;
|
||||||
@ -42,15 +42,17 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return The address of an asset proxy for a given signature
|
* @return The address of an asset proxy for a given signature
|
||||||
*/
|
*/
|
||||||
public async getAssetProxieBySignatureAsync(proxySignature: string, methodOpts?: MethodOpts): Promise<string> {
|
public async getAssetProxieBySignatureAsync(proxySignature: string, methodOpts: MethodOpts = {}): Promise<string> {
|
||||||
assert.isHexString('proxySignature', proxySignature);
|
assert.isHexString('proxySignature', proxySignature);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const exchangeContract = await this._getExchangeContractAsync();
|
const exchangeContract = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const assetProxy = await exchangeContract.getAssetProxy.callAsync(proxySignature, txData, defaultBlock);
|
const assetProxy = await exchangeContract.getAssetProxy.callAsync(
|
||||||
|
proxySignature,
|
||||||
|
txData,
|
||||||
|
methodOpts.defaultBlock,
|
||||||
|
);
|
||||||
return assetProxy;
|
return assetProxy;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -59,17 +61,17 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return The amount of the order (in taker tokens) that has already been filled.
|
* @return The amount of the order (in taker tokens) that has already been filled.
|
||||||
*/
|
*/
|
||||||
public async getFilledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
|
public async getFilledTakerAmountAsync(orderHash: string, methodOpts: MethodOpts = {}): Promise<BigNumber> {
|
||||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const exchangeContract = await this._getExchangeContractAsync();
|
const exchangeContract = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash, txData, defaultBlock);
|
const fillAmountInBaseUnits = await exchangeContract.filled.callAsync(
|
||||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
orderHash,
|
||||||
fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
|
txData,
|
||||||
|
methodOpts.defaultBlock,
|
||||||
|
);
|
||||||
return fillAmountInBaseUnits;
|
return fillAmountInBaseUnits;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -77,14 +79,15 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return Current context address
|
* @return Current context address
|
||||||
*/
|
*/
|
||||||
public async getCurrentContextAddressAsync(methodOpts?: MethodOpts): Promise<string> {
|
public async getCurrentContextAddressAsync(methodOpts: MethodOpts = {}): Promise<string> {
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const exchangeContract = await this._getExchangeContractAsync();
|
const exchangeContract = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const currentContextAddress = await exchangeContract.currentContextAddress.callAsync(txData, defaultBlock);
|
const currentContextAddress = await exchangeContract.currentContextAddress.callAsync(
|
||||||
|
txData,
|
||||||
|
methodOpts.defaultBlock,
|
||||||
|
);
|
||||||
return currentContextAddress;
|
return currentContextAddress;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -92,14 +95,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return Version
|
* @return Version
|
||||||
*/
|
*/
|
||||||
public async getVersionAsync(methodOpts?: MethodOpts): Promise<string> {
|
public async getVersionAsync(methodOpts: MethodOpts = {}): Promise<string> {
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const exchangeContract = await this._getExchangeContractAsync();
|
const exchangeContract = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const version = await exchangeContract.VERSION.callAsync(txData, defaultBlock);
|
const version = await exchangeContract.VERSION.callAsync(txData, methodOpts.defaultBlock);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -107,26 +108,24 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param makerAddress Maker address
|
* @param makerAddress Maker address
|
||||||
* @param senderAddress Sender address
|
* @param senderAddress Sender address
|
||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return Version
|
* @return Order epoch
|
||||||
*/
|
*/
|
||||||
public async getOrderEpochAsync(
|
public async getOrderEpochAsync(
|
||||||
makerAddress: string,
|
makerAddress: string,
|
||||||
senderAddress: string,
|
senderAddress: string,
|
||||||
methodOpts?: MethodOpts,
|
methodOpts: MethodOpts = {},
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
assert.isETHAddressHex('makerAddress', makerAddress);
|
assert.isETHAddressHex('makerAddress', makerAddress);
|
||||||
assert.isETHAddressHex('senderAddress', senderAddress);
|
assert.isETHAddressHex('senderAddress', senderAddress);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const exchangeContract = await this._getExchangeContractAsync();
|
const exchangeContract = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const orderEpoch = await exchangeContract.orderEpoch.callAsync(
|
const orderEpoch = await exchangeContract.orderEpoch.callAsync(
|
||||||
makerAddress,
|
makerAddress,
|
||||||
senderAddress,
|
senderAddress,
|
||||||
txData,
|
txData,
|
||||||
defaultBlock,
|
methodOpts.defaultBlock,
|
||||||
);
|
);
|
||||||
return orderEpoch;
|
return orderEpoch;
|
||||||
}
|
}
|
||||||
@ -137,24 +136,20 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @param methodOpts Optional arguments this method accepts.
|
* @param methodOpts Optional arguments this method accepts.
|
||||||
* @return If the order has been cancelled.
|
* @return If the order has been cancelled.
|
||||||
*/
|
*/
|
||||||
public async isCancelledAsync(orderHash: string, methodOpts?: MethodOpts): Promise<boolean> {
|
public async isCancelledAsync(orderHash: string, methodOpts: MethodOpts = {}): Promise<boolean> {
|
||||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||||
if (!_.isUndefined(methodOpts)) {
|
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
|
||||||
const exchangeContract = await this._getExchangeContractAsync();
|
const exchangeContract = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const isCancelled = await exchangeContract.cancelled.callAsync(orderHash, txData, defaultBlock);
|
const isCancelled = await exchangeContract.cancelled.callAsync(orderHash, txData, methodOpts.defaultBlock);
|
||||||
return isCancelled;
|
return isCancelled;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fills a signed order with an amount denominated in baseUnits of the taker asset.
|
* Fills a signed order with an amount denominated in baseUnits of the taker asset.
|
||||||
* @param signedOrder An object that conforms to the SignedOrder interface.
|
* @param signedOrder An object that conforms to the SignedOrder interface.
|
||||||
* @param fillTakerTokenAmount The amount of the order (in taker tokens baseUnits) that
|
* @param takerAssetFillAmount The amount of the order (in taker asset baseUnits) that
|
||||||
* you wish to fill.
|
* you wish to fill.
|
||||||
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw
|
|
||||||
* if upon execution the tokens cannot be transferred.
|
|
||||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||||
* Must be available via the supplied Provider
|
* Must be available via the supplied Provider
|
||||||
* passed to 0x.js.
|
* passed to 0x.js.
|
||||||
@ -164,12 +159,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
@decorators.asyncZeroExErrorHandler
|
@decorators.asyncZeroExErrorHandler
|
||||||
public async fillOrderAsync(
|
public async fillOrderAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
fillTakerTokenAmount: BigNumber,
|
takerAssetFillAmount: BigNumber,
|
||||||
takerAddress: string,
|
takerAddress: string,
|
||||||
orderTransactionOpts: OrderTransactionOpts = {},
|
orderTransactionOpts: OrderTransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
|
||||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||||
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
||||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||||
@ -178,7 +173,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
|
|
||||||
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
|
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
|
||||||
signedOrder,
|
signedOrder,
|
||||||
fillTakerTokenAmount,
|
takerAssetFillAmount,
|
||||||
signedOrder.signature,
|
signedOrder.signature,
|
||||||
{
|
{
|
||||||
from: normalizedTakerAddress,
|
from: normalizedTakerAddress,
|
||||||
@ -191,10 +186,8 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
/**
|
/**
|
||||||
* No-throw version of fillOrderAsync
|
* No-throw version of fillOrderAsync
|
||||||
* @param signedOrder An object that conforms to the SignedOrder interface.
|
* @param signedOrder An object that conforms to the SignedOrder interface.
|
||||||
* @param fillTakerTokenAmount The amount of the order (in taker tokens baseUnits) that
|
* @param takerAssetFillAmount The amount of the order (in taker asset baseUnits) that
|
||||||
* you wish to fill.
|
* you wish to fill.
|
||||||
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw
|
|
||||||
* if upon execution the tokens cannot be transferred.
|
|
||||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||||
* Must be available via the supplied Provider
|
* Must be available via the supplied Provider
|
||||||
* passed to 0x.js.
|
* passed to 0x.js.
|
||||||
@ -204,12 +197,12 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
@decorators.asyncZeroExErrorHandler
|
@decorators.asyncZeroExErrorHandler
|
||||||
public async fillOrderNoThrowAsync(
|
public async fillOrderNoThrowAsync(
|
||||||
signedOrder: SignedOrder,
|
signedOrder: SignedOrder,
|
||||||
fillTakerTokenAmount: BigNumber,
|
takerAssetFillAmount: BigNumber,
|
||||||
takerAddress: string,
|
takerAddress: string,
|
||||||
orderTransactionOpts: OrderTransactionOpts = {},
|
orderTransactionOpts: OrderTransactionOpts = {},
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
|
||||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||||
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
||||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||||
@ -218,7 +211,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
|
|
||||||
const txHash = await exchangeInstance.fillOrderNoThrow.sendTransactionAsync(
|
const txHash = await exchangeInstance.fillOrderNoThrow.sendTransactionAsync(
|
||||||
signedOrder,
|
signedOrder,
|
||||||
fillTakerTokenAmount,
|
takerAssetFillAmount,
|
||||||
signedOrder.signature,
|
signedOrder.signature,
|
||||||
{
|
{
|
||||||
from: normalizedTakerAddress,
|
from: normalizedTakerAddress,
|
||||||
@ -750,9 +743,14 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
}
|
||||||
const exchangeInstance = await this._getExchangeContractAsync();
|
const exchangeInstance = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const isPreSigned = await exchangeInstance.preSigned.callAsync(hash, signerAddress, txData, defaultBlock);
|
const isPreSigned = await exchangeInstance.preSigned.callAsync(
|
||||||
|
hash,
|
||||||
|
signerAddress,
|
||||||
|
txData,
|
||||||
|
methodOpts.defaultBlock,
|
||||||
|
);
|
||||||
return isPreSigned;
|
return isPreSigned;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -784,14 +782,14 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
* @returns Order info
|
* @returns Order info
|
||||||
*/
|
*/
|
||||||
@decorators.asyncZeroExErrorHandler
|
@decorators.asyncZeroExErrorHandler
|
||||||
public async getOrderInfoAsync(order: Order, methodOpts?: MethodOpts): Promise<OrderInfo> {
|
public async getOrderInfoAsync(order: Order, methodOpts: MethodOpts = {}): Promise<OrderInfo> {
|
||||||
if (!_.isUndefined(methodOpts)) {
|
if (!_.isUndefined(methodOpts)) {
|
||||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||||
}
|
}
|
||||||
const exchangeInstance = await this._getExchangeContractAsync();
|
const exchangeInstance = await this._getExchangeContractAsync();
|
||||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
|
||||||
const txData = {};
|
const txData = {};
|
||||||
const orderInfo = await exchangeInstance.getOrderInfo.callAsync(order, txData, defaultBlock);
|
const orderInfo = await exchangeInstance.getOrderInfo.callAsync(order, txData, methodOpts.defaultBlock);
|
||||||
return orderInfo;
|
return orderInfo;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,7 @@ describe('ExchangeWrapper', () => {
|
|||||||
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||||
makerAssetData,
|
makerAssetData,
|
||||||
takerAssetData,
|
takerAssetData,
|
||||||
anotherMakerAddress,
|
makerAddress,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
fillableAmount,
|
fillableAmount,
|
||||||
);
|
);
|
||||||
@ -244,7 +244,7 @@ describe('ExchangeWrapper', () => {
|
|||||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe.skip('#batchCancelOrdersAsync', () => {
|
describe('#batchCancelOrdersAsync', () => {
|
||||||
it('should cancel a batch of valid orders', async () => {
|
it('should cancel a batch of valid orders', async () => {
|
||||||
const orders = [signedOrder, anotherSignedOrder];
|
const orders = [signedOrder, anotherSignedOrder];
|
||||||
txHash = await contractWrappers.exchange.batchCancelOrdersAsync(orders);
|
txHash = await contractWrappers.exchange.batchCancelOrdersAsync(orders);
|
||||||
@ -252,13 +252,15 @@ describe('ExchangeWrapper', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('#cancelOrdersUpTo/getOrderEpochAsync', () => {
|
describe('#cancelOrdersUpTo/getOrderEpochAsync', () => {
|
||||||
it.skip('should cancel orders up to target order epoch', async () => {
|
it('should cancel orders up to target order epoch', async () => {
|
||||||
const targetOrderEpoch = new BigNumber(42);
|
const targetOrderEpoch = new BigNumber(42);
|
||||||
txHash = await contractWrappers.exchange.cancelOrdersUpToAsync(targetOrderEpoch, takerAddress);
|
txHash = await contractWrappers.exchange.cancelOrdersUpToAsync(targetOrderEpoch, makerAddress);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||||
const senderAddress = constants.NULL_ADDRESS;
|
const orderEpoch = await contractWrappers.exchange.getOrderEpochAsync(
|
||||||
const orderEpoch = await contractWrappers.exchange.getOrderEpochAsync(makerAddress, senderAddress);
|
makerAddress,
|
||||||
expect(orderEpoch).to.be.bignumber.equal(targetOrderEpoch);
|
constants.NULL_ADDRESS,
|
||||||
|
);
|
||||||
|
expect(orderEpoch).to.be.bignumber.equal(targetOrderEpoch.plus(1));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user