You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
I have a simple Solidity contract. The functions which do not exist with different parameter signatures (no function overloading) work fine in a Hardhat , Waffle , Chai , TypeScript test setup, but fail if the function exists with different function signatures ...
pragma solidity^0.7.0;
contractStakingContract {
function getStakedAmount(addressuser) publicpurereturns (uint) {
// return uint(user) & 0x7; // return 0..7return (user ==address(0x0)) ?0 : 1; // one ticket for every account, no matter how much staked
}
function getStakedAmount() publicviewreturns (uint) {
returngetStakedAmount(msg.sender);
}
}
import{Signer}from"@ethersproject/abstract-signer";import{ethers,waffle}from"hardhat";import{expect}from"chai";import{Accounts,Signers}from"../types";importStakingContractArtifactfrom"../artifacts/contracts/StakingContract.sol/StakingContract.json";importProbTokenSaleArtifactfrom"../artifacts/contracts/ProbTokenSale.sol/ProbTokenSale.json";import{StakingContract}from"../typechain/StakingContract";import{ProbTokenSale}from"../typechain/ProbTokenSale";const{ deployContract }=waffle;constmax_tickets=1000;consttickets_per_stake=1;describe("ProbTokenSale",function(){before(asyncfunction(){this.accounts={}asAccounts;this.signers={}asSigners;constsigners: Signer[]=awaitethers.getSigners();this.signers.admin=signers[0];this.accounts.admin=awaitsigners[0].getAddress();console.log("account:",this.accounts.admin);this.stake=(awaitdeployContract(this.signers.admin,StakingContractArtifact,[]))asStakingContract;this.pts=(awaitdeployContract(this.signers.admin,ProbTokenSaleArtifact,[max_tickets,tickets_per_stake]))asProbTokenSale;});it("user account can call StakingContract.getStakedAmount",asyncfunction(){expect(awaitthis.stake.connect(this.signers.admin).getStakedAmount()).to.equal(1);});});
TypeError: this.stake.connect(...).getStakedAmount is not a function
at Context.<anonymous> (test/ProbTokenSale.ts:33:57)
at step (test/ProbTokenSale.ts:33:23)
at Object.next (test/ProbTokenSale.ts:14:53)
at /home/sum/DEV/ETH/ZeroSwap/zeroswap-dto-lottery-nft/test/ProbTokenSale.ts:8:71
at new Promise (<anonymous>)
at __awaiter (test/ProbTokenSale.ts:4:12)
at Context.<anonymous> (test/ProbTokenSale.ts:81:16)
Any idea what is wrong ?
The text was updated successfully, but these errors were encountered:
Any chance that a TypeScript approach may provide a better solution ?
SvenMeyer
changed the title
problems with function overloading in Solidity contracts ?
ethers.js - problem with function overloading in Solidity contracts
Dec 23, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have a simple Solidity contract. The functions which do not exist with different parameter signatures (no function overloading) work fine in a Hardhat , Waffle , Chai , TypeScript test setup, but fail if the function exists with different function signatures ...
Any idea what is wrong ?
The text was updated successfully, but these errors were encountered: