aboutsummaryrefslogtreecommitdiffstats
path: root/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/testnet-faucets/src/ts/dispense_asset_tasks.ts')
-rw-r--r--packages/testnet-faucets/src/ts/dispense_asset_tasks.ts26
1 files changed, 16 insertions, 10 deletions
diff --git a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
index 3af5ca747..5c2002600 100644
--- a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
+++ b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
@@ -1,13 +1,14 @@
-import { ZeroEx } from '0x.js';
+import { ERC20TokenWrapper } from '0x.js';
import { BigNumber, logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { configs } from './configs';
+import { TOKENS_BY_NETWORK } from './tokens';
const DISPENSE_AMOUNT_ETHER = 0.1;
-const DISPENSE_AMOUNT_TOKEN = 0.1;
-const DISPENSE_MAX_AMOUNT_TOKEN = 2;
+const DISPENSE_AMOUNT_TOKEN = 1;
+const DISPENSE_MAX_AMOUNT_TOKEN = 100;
const DISPENSE_MAX_AMOUNT_ETHER = 2;
type AsyncTask = () => Promise<void>;
@@ -32,17 +33,22 @@ export const dispenseAssetTasks = {
logUtils.log(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
};
},
- dispenseTokenTask(recipientAddress: string, tokenSymbol: string, zeroEx: ZeroEx): AsyncTask {
+ dispenseTokenTask(
+ recipientAddress: string,
+ tokenSymbol: string,
+ networkId: number,
+ erc20TokenWrapper: ERC20TokenWrapper,
+ ): AsyncTask {
return async () => {
logUtils.log(`Processing ${tokenSymbol} ${recipientAddress}`);
const amountToDispense = new BigNumber(DISPENSE_AMOUNT_TOKEN);
- const token = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(tokenSymbol);
+ const token = TOKENS_BY_NETWORK[networkId][tokenSymbol];
if (_.isUndefined(token)) {
throw new Error(`Unsupported asset type: ${tokenSymbol}`);
}
- const baseUnitAmount = ZeroEx.toBaseUnitAmount(amountToDispense, token.decimals);
- const userBalanceBaseUnits = await zeroEx.token.getBalanceAsync(token.address, recipientAddress);
- const maxAmountBaseUnits = ZeroEx.toBaseUnitAmount(
+ const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amountToDispense, token.decimals);
+ const userBalanceBaseUnits = await erc20TokenWrapper.getBalanceAsync(token.address, recipientAddress);
+ const maxAmountBaseUnits = Web3Wrapper.toBaseUnitAmount(
new BigNumber(DISPENSE_MAX_AMOUNT_TOKEN),
token.decimals,
);
@@ -52,13 +58,13 @@ export const dispenseAssetTasks = {
);
return;
}
- const txHash = await zeroEx.token.transferAsync(
+ const txHash = await erc20TokenWrapper.transferAsync(
token.address,
configs.DISPENSER_ADDRESS,
recipientAddress,
baseUnitAmount,
);
- logUtils.log(`Sent ${amountToDispense} ZRX to ${recipientAddress} tx: ${txHash}`);
+ logUtils.log(`Sent ${amountToDispense} ${tokenSymbol} to ${recipientAddress} tx: ${txHash}`);
};
},
};