From e68b9c7e81dd89867fadef3d1d87a988f968f450 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Fri, 9 Feb 2018 12:20:25 -0800 Subject: Convert to baseUnits in signed order --- packages/testnet-faucets/src/ts/handler.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts index ac2718f84..bf713d709 100644 --- a/packages/testnet-faucets/src/ts/handler.ts +++ b/packages/testnet-faucets/src/ts/handler.ts @@ -129,18 +129,18 @@ export class Handler { } const zeroEx = networkConfig.zeroEx; res.setHeader('Content-Type', 'application/json'); - const makerTokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(requestedAssetType); - if (_.isUndefined(makerTokenAddress)) { + const makerToken = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(requestedAssetType); + if (_.isUndefined(makerToken) || _.isUndefined(makerToken.address)) { throw new Error(`Unsupported asset type: ${requestedAssetType}`); } const takerTokenSymbol = requestedAssetType === RequestedAssetType.WETH ? RequestedAssetType.ZRX : RequestedAssetType.WETH; - const takerTokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(takerTokenSymbol); - if (_.isUndefined(takerTokenAddress)) { + const takerToken = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(takerTokenSymbol); + if (_.isUndefined(takerToken) || _.isUndefined(takerToken.address)) { throw new Error(`Unsupported asset type: ${requestedAssetType}`); } - const makerTokenAmount = new BigNumber(0.1); - const takerTokenAmount = new BigNumber(0.1); + const makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(0.1), makerToken.decimals); + const takerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(0.1), takerToken.decimals); const order: Order = { maker: configs.DISPENSER_ADDRESS, taker: req.params.recipient, @@ -148,8 +148,8 @@ export class Handler { takerFee: new BigNumber(0), makerTokenAmount, takerTokenAmount, - makerTokenAddress, - takerTokenAddress, + makerTokenAddress: makerToken.address, + takerTokenAddress: takerToken.address, salt: ZeroEx.generatePseudoRandomSalt(), exchangeContractAddress: zeroEx.exchange.getContractAddress(), feeRecipient: ZeroEx.NULL_ADDRESS, -- cgit From 0a2947b86039030707d0d1bf20c27857bffad2aa Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Fri, 9 Feb 2018 12:27:28 -0800 Subject: address is not optional in this context --- packages/testnet-faucets/src/ts/handler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts index bf713d709..5f6ada186 100644 --- a/packages/testnet-faucets/src/ts/handler.ts +++ b/packages/testnet-faucets/src/ts/handler.ts @@ -130,13 +130,13 @@ export class Handler { const zeroEx = networkConfig.zeroEx; res.setHeader('Content-Type', 'application/json'); const makerToken = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(requestedAssetType); - if (_.isUndefined(makerToken) || _.isUndefined(makerToken.address)) { + if (_.isUndefined(makerToken)) { throw new Error(`Unsupported asset type: ${requestedAssetType}`); } const takerTokenSymbol = requestedAssetType === RequestedAssetType.WETH ? RequestedAssetType.ZRX : RequestedAssetType.WETH; const takerToken = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(takerTokenSymbol); - if (_.isUndefined(takerToken) || _.isUndefined(takerToken.address)) { + if (_.isUndefined(takerToken)) { throw new Error(`Unsupported asset type: ${requestedAssetType}`); } const makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(0.1), makerToken.decimals); -- cgit