-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change contract.options.jsonInterface - ts issue #5474
Comments
Investigate to fix this if its not time consuming. |
I ran the next example and it seems to be working acc = await createTempAccount();
// just to deploy the contracts, so we can use them later
const sendOptions = { from: acc.address, gas: '10000000' };
const tempcontract: Contract<typeof BasicAbi> = new Contract(BasicAbi, undefined, {
provider: 'ws://localhost:8545',
});
const tempcontract2: Contract<typeof GreeterAbi> = new Contract(GreeterAbi, undefined, {
provider: 'ws://localhost:8545',
});
const deployedBasicContract: any = await tempcontract
.deploy({
data: BasicBytecode,
arguments: [10, 'string init value'],
})
.send(sendOptions);
const deployedGreeterContract = await tempcontract2
.deploy({ data: GreeterBytecode, arguments: ['Greeting'] })
.send(sendOptions);
//end deploying
// test basic contract is working
const boolValue = await deployedBasicContract.methods.getBoolValue().call();
console.log('boolValue', boolValue);
// change interface and address
deployedBasicContract.options.jsonInterface = GreeterAbi;
deployedBasicContract['_address'] = deployedGreeterContract['_address'];
// test we use the other abi
const tx = await deployedBasicContract.methods
.setGreeting('New Greeting')
.send({ from: acc.address });
const res = await deployedBasicContract.methods.greet().call();
console.log('greeting', res); I believe, what makes this example work is the declaration of |
It turned out that the declared type of So the following old definition: jsonInterface: ContractAbiWithSignature; Needs to be replaced with: get jsonInterface(): ContractAbiWithSignature;
set jsonInterface(value: ContractAbi); And so this MR: #5645 should resolve this issue. |
Is there an existing issue for this?
Current Behavior
Changing contract abi via:
contract.options.jsonInterface = another_abi_json;
doesn't allow in ts with following error:
Expected Behavior
On contract instance
contract.options.jsonInterface = another_abi_json;
should reset and should regenerate the methods and events of the contract instance without ts error.Steps to Reproduce
Web3.js Version
4.0.1-alpha.0
Environment
Anything Else?
No response
The text was updated successfully, but these errors were encountered: