-
Notifications
You must be signed in to change notification settings - Fork 207
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
Can't handle two dimensional array rightly in codegen from solidity #1576
Labels
bug
Something isn't working
Comments
can you share the ABI or the contract address? |
Thx for reply. Here's the function abi gened by solc 0.8.20:
It gens ts code:
static error in
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which packages are impacted by your issue?
@graphprotocol/graph-cli
Describe the issue
codegen from solidity func like :
function getPositionsByTokenIds(uint256[] memory) public view returns (Position.PositionInfo[][] memory)
The Solidity function return type:Position.PositionInfo[][] is a two-dimensional array. PositionInfo[][] is a two-dimensional array. Each element itself is also a Position.PositionInfo[] array.
TypeScript mapping type: Reader__getPositionsByTokenIdsResultValue0Struct[] is a one-dimensional array. This means that the return type expected by TypeScript is an array of Reader__getPositionsByTokenIdsResultValue0Struct objects, not an array of arrays (a two-dimensional array).
Reproduction
graph codegen
Steps to Reproduce the Bug or Issue
gen code:
getPositionsByTokenIds( tokenIds: Array<BigInt> ): Array<Array<Reader__getPositionsByTokenIdsResultValue0Struct>> { let result = super.call( "getPositionsByTokenIds", "getPositionsByTokenIds(uint256[]):((((uint256,address,address,bool,uint256),uint256,uint256,uint256,uint256,uint256,uint256,uint256,int256,uint256,bool,(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256)),(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256))),address)[][])", [ethereum.Value.fromUnsignedBigIntArray(tokenIds)] ); return result[0].toTupleMatrix<>(); }
try_getPositionsByTokenIds(tokenIds: Array<BigInt>): ethereum.CallResult<Array<Reader__getPositionsByTokenIdsResultValue0Struct>> { let result = super.tryCall( "getPositionsByTokenIds", "getPositionsByTokenIds(uint256[]):((((uint256,address,address,bool,uint256),uint256,uint256,uint256,uint256,uint256,uint256,uint256,int256,uint256,bool,(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256)),(uint256,(uint256,uint256,uint256,uint256),(uint256,uint256,uint256,uint256))),address)[][])", [ethereum.Value.fromUnsignedBigIntArray(tokenIds)] ); if (result.reverted) { return new ethereum.CallResult(); } let value = result.value; return ethereum.CallResult.fromValue(value[0].toTupleMatrix<>()); }
Expected behavior
Screenshots or Videos
No response
Platform
@graphprotocol/*
version(s): [e.g. 2.6.2]Subgraph Manifest
No response
Subgraph GraphQL Schema
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: