Skip to content

Commit

Permalink
v10.16.3: fix estimate for overloaded contract methods
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Jun 30, 2023
1 parent b372555 commit 99470f7
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var estimateEVM = ({ provider, from, to, value, method, api, params }) => {
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.Contract(to, api, provider);
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
});
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`;
}
let contractMethod = contract.estimateGas[method];
let contractArguments = getContractArguments({ contract, method, params });
if(contractArguments) {
Expand Down
6 changes: 6 additions & 0 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ var estimateEVM = ({ provider, from, to, value, method, api, params }) => {
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.Contract(to, api, provider);
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
});
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`;
}
let contractMethod = contract.estimateGas[method];
let contractArguments = getContractArguments({ contract, method, params });
if(contractArguments) {
Expand Down
6 changes: 6 additions & 0 deletions dist/esm/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,12 @@ var estimateEVM = ({ provider, from, to, value, method, api, params }) => {
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.Contract(to, api, provider);
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
});
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`;
}
let contractMethod = contract.estimateGas[method];
let contractArguments = getContractArguments({ contract, method, params });
if(contractArguments) {
Expand Down
6 changes: 6 additions & 0 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.ethers.Contract(to, api, provider);
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
});
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`;
}
let contractMethod = contract.estimateGas[method];
let contractArguments = getContractArguments({ contract, method, params });
if(contractArguments) {
Expand Down
6 changes: 6 additions & 0 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.ethers.Contract(to, api, provider);
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
});
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`;
}
let contractMethod = contract.estimateGas[method];
let contractArguments = getContractArguments({ contract, method, params });
if(contractArguments) {
Expand Down
6 changes: 6 additions & 0 deletions dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.ethers.Contract(to, api, provider);
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
});
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`;
}
let contractMethod = contract.estimateGas[method];
let contractArguments = getContractArguments({ contract, method, params });
if(contractArguments) {
Expand Down
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-evm",
"moduleName": "Web3Client",
"version": "10.16.2",
"version": "10.16.3",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.evm.js",
"module": "dist/esm/index.evm.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client",
"moduleName": "Web3Client",
"version": "10.16.2",
"version": "10.16.3",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-solana",
"moduleName": "Web3Client",
"version": "10.16.2",
"version": "10.16.3",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.solana.js",
"module": "dist/esm/index.solana.js",
Expand Down
6 changes: 6 additions & 0 deletions src/platforms/evm/estimate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export default ({ provider, from, to, value, method, api, params }) => {
return provider.estimateGas({ from, to, value })
} else {
let contract = new ethers.Contract(to, api, provider)
let fragment = contract.interface.fragments.find((fragment) => {
return fragment.name == method
})
if(contract[method] === undefined) {
method = `${method}(${fragment.inputs.map((input)=>input.type).join(',')})`
}
let contractMethod = contract.estimateGas[method]
let contractArguments = getContractArguments({ contract, method, params })
if(contractArguments) {
Expand Down

0 comments on commit 99470f7

Please sign in to comment.