aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/website/ts/blockchain.ts20
-rw-r--r--packages/website/ts/components/fill_order.tsx32
2 files changed, 22 insertions, 30 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index ae79651d5..db3872a32 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -36,6 +36,7 @@ import {
BlockchainErrs,
ContractInstance,
EtherscanLinkSuffixes,
+ Order as PortalOrder,
ProviderType,
Side,
SideToAssetToken,
@@ -288,6 +289,25 @@ export class Blockchain {
}),
);
}
+ public portalOrderToZeroExOrder(portalOrder: PortalOrder): SignedOrder {
+ const exchangeContractAddress = this.getExchangeContractAddressIfExists();
+ const zeroExSignedOrder = {
+ exchangeContractAddress,
+ maker: portalOrder.signedOrder.maker,
+ taker: portalOrder.signedOrder.taker,
+ makerTokenAddress: portalOrder.signedOrder.makerTokenAddress,
+ takerTokenAddress: portalOrder.signedOrder.takerTokenAddress,
+ makerTokenAmount: new BigNumber(portalOrder.signedOrder.makerTokenAmount),
+ takerTokenAmount: new BigNumber(portalOrder.signedOrder.takerTokenAmount),
+ makerFee: new BigNumber(portalOrder.signedOrder.makerFee),
+ takerFee: new BigNumber(portalOrder.signedOrder.takerFee),
+ expirationUnixTimestampSec: new BigNumber(portalOrder.signedOrder.expirationUnixTimestampSec),
+ feeRecipient: portalOrder.signedOrder.feeRecipient,
+ ecSignature: portalOrder.signedOrder.ecSignature,
+ salt: new BigNumber(portalOrder.signedOrder.salt),
+ };
+ return zeroExSignedOrder;
+ }
public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber): Promise<BigNumber> {
utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index 063c57688..51e44134c 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -518,21 +518,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
globalErrMsg = 'You must specify a fill amount';
}
- const signedOrder = {
- exchangeContractAddress: this.props.blockchain.getExchangeContractAddressIfExists(),
- maker: parsedOrder.signedOrder.maker,
- taker: _.isEmpty(parsedOrder.signedOrder.taker) ? constants.NULL_ADDRESS : parsedOrder.signedOrder.taker,
- makerTokenAddress: parsedOrder.signedOrder.makerTokenAddress,
- takerTokenAddress: parsedOrder.signedOrder.takerTokenAddress,
- makerTokenAmount: new BigNumber(parsedOrder.signedOrder.makerTokenAmount),
- takerTokenAmount: new BigNumber(parsedOrder.signedOrder.takerTokenAmount),
- makerFee: new BigNumber(parsedOrder.signedOrder.makerFee),
- takerFee: new BigNumber(parsedOrder.signedOrder.takerFee),
- expirationUnixTimestampSec: new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec),
- feeRecipient: parsedOrder.signedOrder.feeRecipient,
- ecSignature: parsedOrder.signedOrder.ecSignature,
- salt: new BigNumber(parsedOrder.signedOrder.salt),
- };
+ const signedOrder = this.props.blockchain.portalOrderToZeroExOrder(parsedOrder);
if (_.isEmpty(globalErrMsg)) {
try {
await this.props.blockchain.validateFillOrderThrowIfInvalidAsync(
@@ -621,21 +607,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
const takerTokenAmount = new BigNumber(parsedOrder.signedOrder.takerTokenAmount);
- const signedOrder = {
- exchangeContractAddress: this.props.blockchain.getExchangeContractAddressIfExists(),
- maker: parsedOrder.signedOrder.maker,
- taker: parsedOrder.signedOrder.taker,
- makerTokenAddress: parsedOrder.signedOrder.makerTokenAddress,
- takerTokenAddress: parsedOrder.signedOrder.takerTokenAddress,
- makerTokenAmount: new BigNumber(parsedOrder.signedOrder.makerTokenAmount),
- takerTokenAmount: new BigNumber(parsedOrder.signedOrder.takerTokenAmount),
- makerFee: new BigNumber(parsedOrder.signedOrder.makerFee),
- takerFee: new BigNumber(parsedOrder.signedOrder.takerFee),
- expirationUnixTimestampSec: new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec),
- feeRecipient: parsedOrder.signedOrder.feeRecipient,
- ecSignature: parsedOrder.signedOrder.ecSignature,
- salt: new BigNumber(parsedOrder.signedOrder.salt),
- };
+ const signedOrder = this.props.blockchain.portalOrderToZeroExOrder(parsedOrder);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
const unavailableTakerAmount = await this.props.blockchain.getUnavailableTakerAmountAsync(orderHash);
const availableTakerTokenAmount = takerTokenAmount.minus(unavailableTakerAmount);