Closed RayXpub closed 1 year ago
Hey, there's no way to convert struct to ethereum.Value, and i think graph-cli generally converts structs into tuples. You can try returning a tuple. Here's how you can create a tuple https://github.com/LimeChain/demo-subgraph/blob/main/tests/gravity/gravity.test.ts#L32-L34
@dimitrovmaksim Thanks for the answer. I indeed managed to do so by using tuples as follow :
let callResult = new ethereum.Tuple();
callResult.push(ethereum.Value.fromAddress(a));
callResult.push(ethereum.Value.fromUnsignedBigInt(b));
callResult.push(ethereum.Value.fromUnsignedBigInt(c));
callResult.push(ethereum.Value.fromUnsignedBigInt(d));
createMockedFunction(
contractAddress,
"getStruct",
"getStruct(uint256):((address,uint96,uint256,uint256))"
)
.withArgs([ethereum.Value.fromUnsignedBigInt(id)])
.returns([ethereum.Value.fromTuple(callResult)]);
Hi,
I am trying to mock a function call returning a struct type in solidity but I can't seem to be able to find the correct return
ethereum.Value
syntax.Is there a way to achieve this or are struct return types no supported ?