aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-09-13 19:45:27 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-09-19 23:56:23 +0800
commit6701ec68bdbda91e63ab199510469e3e6a421b57 (patch)
tree21d51c159d8f32f10af0f37e13c5b8723c5da2a2
parent7b259c3f4c09ea2d8bfe688238f046fa8c62ec03 (diff)
downloaddexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.tar
dexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.tar.gz
dexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.tar.bz2
dexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.tar.lz
dexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.tar.xz
dexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.tar.zst
dexon-sol-tools-6701ec68bdbda91e63ab199510469e3e6a421b57.zip
Upgrade contract_templates to work with ethers 4.0
-rw-r--r--packages/contract_templates/contract.handlebars6
-rw-r--r--packages/contract_templates/partials/callAsync.handlebars8
-rw-r--r--packages/contract_templates/partials/tx.handlebars12
3 files changed, 10 insertions, 16 deletions
diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars
index 466893aa7..5c5f8c808 100644
--- a/packages/contract_templates/contract.handlebars
+++ b/packages/contract_templates/contract.handlebars
@@ -65,10 +65,12 @@ export class {{contractName}}Contract extends BaseContract {
[{{> params inputs=ctor.inputs}}],
BaseContract._bigNumberToString,
);
- const txData = ethers.Contract.getDeployTransaction(bytecode, abi, {{> params inputs=ctor.inputs}});
+ const iface = new ethers.Interface(abi);
+ let deployInfo = iface.deployFunction;
+ const txData = deployInfo.encode(bytecode, [{{> params inputs=ctor.inputs}}]);
const web3Wrapper = new Web3Wrapper(provider);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
- txData,
+ {data: txData},
txDefaults,
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
);
diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars
index 94752691d..dd1b90212 100644
--- a/packages/contract_templates/partials/callAsync.handlebars
+++ b/packages/contract_templates/partials/callAsync.handlebars
@@ -8,10 +8,8 @@ async callAsync(
const inputAbi = self._lookupAbi(functionSignature).inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]);
- const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}(
- {{> params inputs=inputs}}
- ) as ethers.CallDescription;
- const encodedData = ethersFunction.data;
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}};
+ const encodedData = ethersFunction.encode([{{> params inputs=inputs}}]);
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
@@ -21,7 +19,7 @@ async callAsync(
self._web3Wrapper.getContractDefaults(),
);
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
- let resultArray = ethersFunction.parse(rawCallResult);
+ let resultArray = ethersFunction.decode(rawCallResult);
const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
diff --git a/packages/contract_templates/partials/tx.handlebars b/packages/contract_templates/partials/tx.handlebars
index 4340d662e..b39156583 100644
--- a/packages/contract_templates/partials/tx.handlebars
+++ b/packages/contract_templates/partials/tx.handlebars
@@ -12,9 +12,7 @@ public {{this.tsName}} = {
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]);
- const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
- {{> params inputs=inputs}}
- ).data;
+ const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
@@ -37,9 +35,7 @@ public {{this.tsName}} = {
const self = this as any as {{contractName}}Contract;
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString);
- const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
- {{> params inputs=inputs}}
- ).data;
+ const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
{
to: self.address,
@@ -57,9 +53,7 @@ public {{this.tsName}} = {
const self = this as any as {{contractName}}Contract;
const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString);
- const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
- {{> params inputs=inputs}}
- ).data;
+ const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]);
return abiEncodedTransactionData;
},
{{> callAsync}}