renaming to -> toAddress
This commit is contained in:
@@ -45,7 +45,7 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase<Exchange
|
||||
): Promise<CalldataInfo> {
|
||||
assert.isValidSwapQuote('quote', quote);
|
||||
|
||||
const { to, methodAbi, ethAmount, params } = await this.getSmartContractParamsOrThrowAsync(quote, opts);
|
||||
const { toAddress, methodAbi, ethAmount, params } = await this.getSmartContractParamsOrThrowAsync(quote, opts);
|
||||
|
||||
const abiEncoder = new AbiEncoder.Method(methodAbi);
|
||||
|
||||
@@ -62,7 +62,7 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase<Exchange
|
||||
return {
|
||||
calldataHexString,
|
||||
methodAbi,
|
||||
to,
|
||||
toAddress,
|
||||
ethAmount,
|
||||
};
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export class ExchangeSwapQuoteConsumer implements SwapQuoteConsumerBase<Exchange
|
||||
|
||||
return {
|
||||
params,
|
||||
to: this._contractWrappers.exchange.address,
|
||||
toAddress: this._contractWrappers.exchange.address,
|
||||
methodAbi,
|
||||
};
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<Forward
|
||||
): Promise<CalldataInfo> {
|
||||
assert.isValidForwarderSwapQuote('quote', quote, this._getEtherTokenAssetDataOrThrow());
|
||||
|
||||
const { to, methodAbi, ethAmount, params } = await this.getSmartContractParamsOrThrowAsync(quote, opts);
|
||||
const { toAddress, methodAbi, ethAmount, params } = await this.getSmartContractParamsOrThrowAsync(quote, opts);
|
||||
|
||||
const abiEncoder = new AbiEncoder.Method(methodAbi);
|
||||
const { orders, signatures, feeOrders, feeSignatures, feePercentage, feeRecipient } = params;
|
||||
@@ -69,7 +69,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<Forward
|
||||
return {
|
||||
calldataHexString,
|
||||
methodAbi,
|
||||
to,
|
||||
toAddress,
|
||||
ethAmount,
|
||||
};
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class ForwarderSwapQuoteConsumer implements SwapQuoteConsumerBase<Forward
|
||||
|
||||
return {
|
||||
params,
|
||||
to: this._contractWrappers.forwarder.address,
|
||||
toAddress: this._contractWrappers.forwarder.address,
|
||||
ethAmount: ethAmount || worstCaseQuoteInfo.totalTakerTokenAmount,
|
||||
methodAbi,
|
||||
};
|
||||
|
@@ -43,26 +43,26 @@ export interface OrderProvider {
|
||||
* Represents the metadata to call a smart contract with calldata.
|
||||
* calldataHexString: The hexstring of the calldata.
|
||||
* methodAbi: The ABI of the smart contract method to call.
|
||||
* to: The contract address to call.
|
||||
* toAddress: The contract address to call.
|
||||
* ethAmount: If provided, the eth amount in wei to send with the smart contract call.
|
||||
*/
|
||||
export interface CalldataInfo {
|
||||
calldataHexString: string;
|
||||
methodAbi: MethodAbi;
|
||||
to: string;
|
||||
toAddress: string;
|
||||
ethAmount?: BigNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the metadata to call a smart contract with parameters.
|
||||
* params: The metadata object containing all the input parameters of a smart contract call.
|
||||
* to: The contract address to call.
|
||||
* toAddress: The contract address to call.
|
||||
* ethAmount: If provided, the eth amount in wei to send with the smart contract call.
|
||||
* methodAbi: The ABI of the smart contract method to call with params.
|
||||
*/
|
||||
export interface SmartContractParamsInfo<T> {
|
||||
params: T;
|
||||
to: string;
|
||||
toAddress: string;
|
||||
ethAmount?: BigNumber;
|
||||
methodAbi: MethodAbi;
|
||||
}
|
||||
|
@@ -151,11 +151,11 @@ describe('ExchangeSwapQuoteConsumer', () => {
|
||||
describe('valid swap quote', async () => {
|
||||
// TODO(david) Check for valid MethodAbi
|
||||
it('provide correct and optimized smart contract params for a marketSell SwapQuote', async () => {
|
||||
const { to, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
const { toAddress, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
marketSellSwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.exchange.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.exchange.address);
|
||||
const { takerAssetFillAmount, signatures, type } = params as ExchangeMarketSellSmartContractParams;
|
||||
expect(type).to.deep.equal(MarketOperation.Sell);
|
||||
expect(takerAssetFillAmount).to.bignumber.equal(
|
||||
@@ -165,11 +165,11 @@ describe('ExchangeSwapQuoteConsumer', () => {
|
||||
expect(signatures).to.deep.equal(orderSignatures);
|
||||
});
|
||||
it('provide correct and optimized smart contract params for a marketBuy SwapQuote', async () => {
|
||||
const { to, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
const { toAddress, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
marketBuySwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.exchange.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.exchange.address);
|
||||
const { makerAssetFillAmount, signatures, type } = params as ExchangeMarketBuySmartContractParams;
|
||||
expect(type).to.deep.equal(MarketOperation.Buy);
|
||||
expect(makerAssetFillAmount).to.bignumber.equal(
|
||||
@@ -188,14 +188,14 @@ describe('ExchangeSwapQuoteConsumer', () => {
|
||||
let takerBalance = await contractWrappers.erc20Token.getBalanceAsync(makerTokenAddress, takerAddress);
|
||||
expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI));
|
||||
expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT);
|
||||
const { calldataHexString, to } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
marketSellSwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.exchange.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.exchange.address);
|
||||
await web3Wrapper.sendTransactionAsync({
|
||||
from: takerAddress,
|
||||
to,
|
||||
to: toAddress,
|
||||
data: calldataHexString,
|
||||
gas: 4000000,
|
||||
});
|
||||
@@ -209,14 +209,14 @@ describe('ExchangeSwapQuoteConsumer', () => {
|
||||
let takerBalance = await contractWrappers.erc20Token.getBalanceAsync(makerTokenAddress, takerAddress);
|
||||
expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI));
|
||||
expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT);
|
||||
const { calldataHexString, to } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
marketBuySwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.exchange.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.exchange.address);
|
||||
await web3Wrapper.sendTransactionAsync({
|
||||
from: takerAddress,
|
||||
to,
|
||||
to: toAddress,
|
||||
data: calldataHexString,
|
||||
gas: 4000000,
|
||||
});
|
||||
|
@@ -248,11 +248,11 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
|
||||
describe('valid swap quote', async () => {
|
||||
it('provide correct and optimized smart contract params with default options for a marketSell SwapQuote (no affiliate fees)', async () => {
|
||||
const { to, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
const { toAddress, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
marketSellSwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.forwarder.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.forwarder.address);
|
||||
const {
|
||||
feeSignatures,
|
||||
feePercentage,
|
||||
@@ -268,11 +268,11 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
expect(feeSignatures).to.deep.equal([]);
|
||||
});
|
||||
it('provide correct and optimized smart contract params with default options for a marketBuy SwapQuote (no affiliate fees)', async () => {
|
||||
const { to, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
const { toAddress, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
marketBuySwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.forwarder.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.forwarder.address);
|
||||
const {
|
||||
makerAssetFillAmount,
|
||||
feeSignatures,
|
||||
@@ -292,11 +292,14 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
expect(feeSignatures).to.deep.equal([]);
|
||||
});
|
||||
it('provide correct and optimized smart contract params with affiliate fees for a marketSell SwapQuote', async () => {
|
||||
const { to, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(marketSellSwapQuote, {
|
||||
feePercentage: 0.05,
|
||||
feeRecipient,
|
||||
});
|
||||
expect(to).to.deep.equal(contractWrappers.forwarder.address);
|
||||
const { toAddress, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
marketSellSwapQuote,
|
||||
{
|
||||
feePercentage: 0.05,
|
||||
feeRecipient,
|
||||
},
|
||||
);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.forwarder.address);
|
||||
const {
|
||||
feeSignatures,
|
||||
feePercentage,
|
||||
@@ -312,11 +315,14 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
expect(feeSignatures).to.deep.equal([]);
|
||||
});
|
||||
it('provide correct and optimized smart contract params with affiliate fees for a marketBuy SwapQuote', async () => {
|
||||
const { to, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(marketBuySwapQuote, {
|
||||
feePercentage: 0.05,
|
||||
feeRecipient,
|
||||
});
|
||||
expect(to).to.deep.equal(contractWrappers.forwarder.address);
|
||||
const { toAddress, params } = await swapQuoteConsumer.getSmartContractParamsOrThrowAsync(
|
||||
marketBuySwapQuote,
|
||||
{
|
||||
feePercentage: 0.05,
|
||||
feeRecipient,
|
||||
},
|
||||
);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.forwarder.address);
|
||||
const {
|
||||
makerAssetFillAmount,
|
||||
feeSignatures,
|
||||
@@ -367,14 +373,14 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
let takerBalance = await contractWrappers.erc20Token.getBalanceAsync(makerTokenAddress, takerAddress);
|
||||
expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI));
|
||||
expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT);
|
||||
const { calldataHexString, to } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
marketSellSwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractWrappers.forwarder.address);
|
||||
expect(toAddress).to.deep.equal(contractWrappers.forwarder.address);
|
||||
await web3Wrapper.sendTransactionAsync({
|
||||
from: takerAddress,
|
||||
to,
|
||||
to: toAddress,
|
||||
data: calldataHexString,
|
||||
value: marketSellSwapQuote.worstCaseQuoteInfo.totalTakerTokenAmount,
|
||||
gas: 4000000,
|
||||
@@ -389,14 +395,14 @@ describe('ForwarderSwapQuoteConsumer', () => {
|
||||
let takerBalance = await contractWrappers.erc20Token.getBalanceAsync(makerTokenAddress, takerAddress);
|
||||
expect(makerBalance).to.bignumber.equal(new BigNumber(10).multipliedBy(ONE_ETH_IN_WEI));
|
||||
expect(takerBalance).to.bignumber.equal(constants.ZERO_AMOUNT);
|
||||
const { calldataHexString, to } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
const { calldataHexString, toAddress } = await swapQuoteConsumer.getCalldataOrThrowAsync(
|
||||
marketBuySwapQuote,
|
||||
{},
|
||||
);
|
||||
expect(to).to.deep.equal(contractAddresses.forwarder);
|
||||
expect(toAddress).to.deep.equal(contractAddresses.forwarder);
|
||||
await web3Wrapper.sendTransactionAsync({
|
||||
from: takerAddress,
|
||||
to,
|
||||
to: toAddress,
|
||||
data: calldataHexString,
|
||||
value: marketBuySwapQuote.worstCaseQuoteInfo.totalTakerTokenAmount,
|
||||
gas: 4000000,
|
||||
|
Reference in New Issue
Block a user