Implement eth_call for methods returning struct type (#59)

* Handle tuple return type in ethereum host API

* Update graph-cli version to fix eth_call error

* Handle all types in struct based on abi

Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
This commit is contained in:
2021-12-28 16:08:05 +05:30
committed by nabarun
co-authored by prathamesh
parent f52467f724
commit 31b302c9b5
11 changed files with 341 additions and 247 deletions
@@ -62,6 +62,22 @@ export function handleTest (event: Test): void {
// Entities can be written to the store with `.save()`
entity.save();
const contractAddress = dataSource.address();
const contract = Example1.bind(contractAddress);
// Access functions by calling them.
const res1 = contract.try_addMethod(BigInt.fromString('10'), BigInt.fromString('20'));
if (res1.reverted) {
log.debug('Contract eth call reverted', []);
} else {
log.debug('Contract eth call result: {}', [res1.value.toString()]);
}
// Access functions by calling them.
const res = contract.structMethod(BigInt.fromString('1000'), BigInt.fromString('500'));
log.debug('Contract eth call result: {}', [res.bidAmount1.toString()]);
// Note: If a handler doesn't require existing field values, it is faster
// _not_ to load the entity from the store. Instead, create it fresh with
// `new Entity(...)`, set the fields that should be updated and save the