aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJacob Evans <dekz@dekz.net>2018-04-20 06:49:23 +0800
committerGitHub <noreply@github.com>2018-04-20 06:49:23 +0800
commit62a55c013516c82eb4aa26c90db7533cd72f8d1b (patch)
treea96728392d7f9890e8a8f5a8c18627acc2ea8f28 /packages
parentf6fd4281a4772c28521fa606bd37f16a21dbe23c (diff)
parent72336eb393d775817619a354d784b7dea4e243bf (diff)
downloaddexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.tar
dexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.tar.gz
dexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.tar.bz2
dexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.tar.lz
dexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.tar.xz
dexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.tar.zst
dexon-sol-tools-62a55c013516c82eb4aa26c90db7533cd72f8d1b.zip
Merge pull request #540 from 0xProject/feature/abi-gen/tuple-return-types
Support Tuples returned from functions
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/package.json2
-rw-r--r--packages/base-contract/CHANGELOG.json9
-rw-r--r--packages/base-contract/package.json2
-rw-r--r--packages/base-contract/src/index.ts8
-rw-r--r--packages/contract_templates/contract.handlebars2
-rw-r--r--packages/contract_templates/partials/callAsync.handlebars11
-rw-r--r--packages/contract_templates/partials/return_type.handlebars2
-rw-r--r--packages/metacoin/package.json2
-rw-r--r--packages/typescript-typings/CHANGELOG.json9
-rw-r--r--packages/typescript-typings/types/ethers/index.d.ts (renamed from packages/typescript-typings/types/ethers-contracts/index.d.ts)9
-rw-r--r--packages/utils/CHANGELOG.json9
-rw-r--r--packages/utils/package.json2
-rw-r--r--packages/utils/src/abi_decoder.ts8
-rw-r--r--packages/web3-wrapper/package.json2
14 files changed, 54 insertions, 23 deletions
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index dd4bd3f5c..e7cdff09e 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -109,7 +109,7 @@
"ethereumjs-abi": "^0.6.4",
"ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"js-sha3": "^0.7.0",
"lodash": "^4.17.4",
"uuid": "^3.1.0",
diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json
index ed3c86465..c5d467b7f 100644
--- a/packages/base-contract/CHANGELOG.json
+++ b/packages/base-contract/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.3.0",
+ "changes": [
+ {
+ "note": "Update ethers-contracts to ethers.js",
+ "pr": 540
+ }
+ ]
+ },
+ {
"timestamp": 1524044013,
"version": "0.2.1",
"changes": [
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index 22ae43cdc..78dcbfe7f 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -42,7 +42,7 @@
"@0xproject/typescript-typings": "^0.2.0",
"@0xproject/utils": "^0.5.2",
"@0xproject/web3-wrapper": "^0.6.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4"
},
"publishConfig": {
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index bfa99fac1..e95b18db6 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -10,13 +10,13 @@ import {
} from '@0xproject/types';
import { abiUtils, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import * as ethersContracts from 'ethers-contracts';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
import { formatABIDataItem } from './utils';
export interface EthersInterfaceByFunctionSignature {
- [key: string]: ethersContracts.Interface;
+ [key: string]: ethers.Interface;
}
export class BaseContract {
@@ -62,7 +62,7 @@ export class BaseContract {
}
return txDataWithDefaults;
}
- protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface {
+ protected _lookupEthersInterface(functionSignature: string): ethers.Interface {
const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
if (_.isUndefined(ethersInterface)) {
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
@@ -92,7 +92,7 @@ export class BaseContract {
this._ethersInterfacesByFunctionSignature = {};
_.each(methodAbis, methodAbi => {
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
- this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]);
+ this._ethersInterfacesByFunctionSignature[functionSignature] = new ethers.Interface([methodAbi]);
});
}
}
diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars
index 472452d74..cf51dad90 100644
--- a/packages/contract_templates/contract.handlebars
+++ b/packages/contract_templates/contract.handlebars
@@ -8,7 +8,7 @@ import { BaseContract } from '@0xproject/base-contract';
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, Provider, TxData, TxDataPayable } from '@0xproject/types';
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import * as ethersContracts from 'ethers-contracts';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
{{#if events}}
diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars
index a6f4abdf2..58fb2f09c 100644
--- a/packages/contract_templates/partials/callAsync.handlebars
+++ b/packages/contract_templates/partials/callAsync.handlebars
@@ -5,20 +5,21 @@ async callAsync(
defaultBlock?: BlockParam,
): Promise<{{> return_type outputs=outputs}}> {
const self = this as any as {{contractName}}Contract;
- const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
+ const functionSignature = '{{this.functionSignature}}';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
- const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}(
{{> params inputs=inputs}}
- ).data;
+ ) as ethers.CallDescription;
+ const encodedData = ethersFunction.data;
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{
data: encodedData,
}
)
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ let resultArray = ethersFunction.parse(rawCallResult);
const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
- const outputParamsTypes = _.map(outputAbi, 'type');
- let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any;
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}};
diff --git a/packages/contract_templates/partials/return_type.handlebars b/packages/contract_templates/partials/return_type.handlebars
index 9dd509953..77d96e8c4 100644
--- a/packages/contract_templates/partials/return_type.handlebars
+++ b/packages/contract_templates/partials/return_type.handlebars
@@ -1,6 +1,6 @@
{{#if outputs.length}}
{{#singleReturnValue}}
-{{#returnType outputs.0.type components}}{{/returnType}}
+{{#returnType outputs.0.type outputs.0.components}}{{/returnType}}
{{/singleReturnValue}}
{{^singleReturnValue}}
[{{#each outputs}}{{#returnType type components}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}]
diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json
index 80bd22791..e944d725b 100644
--- a/packages/metacoin/package.json
+++ b/packages/metacoin/package.json
@@ -32,7 +32,7 @@
"@0xproject/types": "^0.6.1",
"@0xproject/utils": "^0.5.2",
"@0xproject/web3-wrapper": "^0.6.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4",
"web3-provider-engine": "^13.0.1"
},
diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json
index a2f1e7615..f3f68d509 100644
--- a/packages/typescript-typings/CHANGELOG.json
+++ b/packages/typescript-typings/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.3.0",
+ "changes": [
+ {
+ "note": "Add types for `ethers.js`, removing `ethers-contracts`",
+ "pr": 540
+ }
+ ]
+ },
+ {
"version": "0.2.0",
"changes": [
{
diff --git a/packages/typescript-typings/types/ethers-contracts/index.d.ts b/packages/typescript-typings/types/ethers/index.d.ts
index e5d38819e..7e04c7dd1 100644
--- a/packages/typescript-typings/types/ethers-contracts/index.d.ts
+++ b/packages/typescript-typings/types/ethers/index.d.ts
@@ -1,4 +1,4 @@
-declare module 'ethers-contracts' {
+declare module 'ethers' {
export interface TransactionDescription {
name: string;
signature: string;
@@ -12,17 +12,20 @@ declare module 'ethers-contracts' {
(...params: any[]): TransactionDescription | CallDescription;
inputs: { names: string[]; types: string[] };
outputs: { names: string[]; types: string[] };
+ type: string;
}
export interface EventDescription {
parse: (...args: any[]) => any;
inputs: { names: string[]; types: string[] };
signature: string;
- topic: string;
+ topics: string[];
}
export class Interface {
public functions: { [functionName: string]: FunctionDescription };
public events: { [eventName: string]: EventDescription };
- public static decodeParams(types: string[], data: string): any[];
constructor(abi: any);
}
+ export class Contract {
+ constructor(address: string, abi: any, provider: any);
+ }
}
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index 1aeb3b457..e7f3c052c 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.6.0",
+ "changes": [
+ {
+ "note": "Update ethers-contracts to ethers.js",
+ "pr": 540
+ }
+ ]
+ },
+ {
"version": "0.5.2",
"changes": [
{
diff --git a/packages/utils/package.json b/packages/utils/package.json
index bbc87c53f..f309c2126 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -35,7 +35,7 @@
"@0xproject/typescript-typings": "^0.2.0",
"@types/node": "^8.0.53",
"bignumber.js": "~4.1.0",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"js-sha3": "^0.7.0",
"lodash": "^4.17.4",
"web3": "^0.20.0"
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index 36c7839cf..150f74a15 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -9,7 +9,7 @@ import {
RawLog,
SolidityTypes,
} from '@0xproject/types';
-import * as ethersContracts from 'ethers-contracts';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
import { BigNumber } from './configured_bignumber';
@@ -36,7 +36,7 @@ export class AbiDecoder {
if (_.isUndefined(event)) {
return log;
}
- const ethersInterface = new ethersContracts.Interface([event]);
+ const ethersInterface = new ethers.Interface([event]);
const logData = log.data;
const decodedParams: DecodedLogArgs = {};
let topicsIndex = 1;
@@ -77,10 +77,10 @@ export class AbiDecoder {
if (_.isUndefined(abiArray)) {
return;
}
- const ethersInterface = new ethersContracts.Interface(abiArray);
+ const ethersInterface = new ethers.Interface(abiArray);
_.map(abiArray, (abi: AbiDefinition) => {
if (abi.type === AbiType.Event) {
- const topic = ethersInterface.events[abi.name].topic;
+ const topic = ethersInterface.events[abi.name].topics[0];
this._methodIds[topic] = abi;
}
});
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 61a886e46..118330707 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -61,7 +61,7 @@
"@0xproject/types": "^0.6.1",
"@0xproject/typescript-typings": "^0.2.0",
"@0xproject/utils": "^0.5.2",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4",
"web3": "^0.20.0"
},