aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-08-07 07:58:46 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-08-09 05:27:30 +0800
commit52e094addcecc6136c9582a51dd52b8f44f769f7 (patch)
treeb7fafb49d1dccb99c9d16991454fc5229b5128a9 /packages/utils
parent6a6739ebbec291b61226c047fde7b3d0bb4a7250 (diff)
downloaddexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.tar
dexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.tar.gz
dexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.tar.bz2
dexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.tar.lz
dexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.tar.xz
dexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.tar.zst
dexon-sol-tools-52e094addcecc6136c9582a51dd52b8f44f769f7.zip
Move some ethers-related types to typescript-typings/ethers
Diffstat (limited to 'packages/utils')
-rw-r--r--packages/utils/src/abi_utils.ts18
1 files changed, 6 insertions, 12 deletions
diff --git a/packages/utils/src/abi_utils.ts b/packages/utils/src/abi_utils.ts
index 874e0b2da..fc64a2a89 100644
--- a/packages/utils/src/abi_utils.ts
+++ b/packages/utils/src/abi_utils.ts
@@ -1,20 +1,14 @@
import { AbiDefinition, AbiType, ContractAbi, DataItem, MethodAbi } from 'ethereum-types';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
import { BigNumber } from './configured_bignumber';
-export type EthersParamName = null | string | EthersNestedParamName;
-
-export interface EthersNestedParamName {
- name: string | null;
- names: EthersParamName[];
-}
-
// Note(albrow): This function is unexported in ethers.js. Copying it here for
// now.
// Source: https://github.com/ethers-io/ethers.js/blob/884593ab76004a808bf8097e9753fb5f8dcc3067/contracts/interface.js#L30
-function parseEthersParams(params: DataItem[]): { names: EthersParamName[]; types: string[] } {
- const names: EthersParamName[] = [];
+function parseEthersParams(params: DataItem[]): { names: ethers.ParamName[]; types: string[] } {
+ const names: ethers.ParamName[] = [];
const types: string[] = [];
params.forEach((param: DataItem) => {
@@ -43,7 +37,7 @@ function parseEthersParams(params: DataItem[]): { names: EthersParamName[]; type
// returns true if x is equal to y and false otherwise. Performs some minimal
// type conversion and data massaging for x and y, depending on type. name and
// type should typically be derived from parseEthersParams.
-function isAbiDataEqual(name: EthersParamName, type: string, x: any, y: any): boolean {
+function isAbiDataEqual(name: ethers.ParamName, type: string, x: any, y: any): boolean {
if (_.isUndefined(x) && _.isUndefined(y)) {
return true;
} else if (_.isUndefined(x) && !_.isUndefined(y)) {
@@ -70,7 +64,7 @@ function isAbiDataEqual(name: EthersParamName, type: string, x: any, y: any): bo
if (_.isString(name)) {
throw new Error('Internal error: type was tuple but names was a string');
} else if (_.isNull(name)) {
- throw new Error('Internal error: type was tuple but names was a null');
+ throw new Error('Internal error: type was tuple but names was null');
}
// For tuples, we iterate through the underlying values and check each
// one individually.
@@ -95,7 +89,7 @@ function isAbiDataEqual(name: EthersParamName, type: string, x: any, y: any): bo
//
const nestedName = _.isString(name.names[i])
? (name.names[i] as string)
- : ((name.names[i] as EthersNestedParamName).name as string);
+ : ((name.names[i] as ethers.NestedParamName).name as string);
if (!isAbiDataEqual(name.names[i], types[i], x[nestedName], y[nestedName])) {
return false;
}