fixed testing for swap quoter + setup for consumer testing added framework for testing consumers added testing and updated some types
28 lines
960 B
TypeScript
28 lines
960 B
TypeScript
import { BigNumber } from '@0x/utils';
|
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
|
import { AbiDefinition, ContractAbi, MethodAbi } from 'ethereum-types';
|
|
import * as _ from 'lodash';
|
|
|
|
import { constants } from '../constants';
|
|
|
|
export const utils = {
|
|
numberPercentageToEtherTokenAmountPercentage(percentage: number): BigNumber {
|
|
return Web3Wrapper.toBaseUnitAmount(constants.ONE_AMOUNT, constants.ETHER_TOKEN_DECIMALS).multipliedBy(
|
|
percentage,
|
|
);
|
|
},
|
|
getMethodAbiFromContractAbi(abi: ContractAbi, name: string): MethodAbi | undefined {
|
|
return _.find(
|
|
abi,
|
|
(def: AbiDefinition): boolean => {
|
|
if (def.type === 'function') {
|
|
const methodDef = def as MethodAbi;
|
|
return methodDef.name === name;
|
|
} else {
|
|
return false;
|
|
}
|
|
},
|
|
) as MethodAbi | undefined;
|
|
},
|
|
};
|