mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-11 10:14:07 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user