fix(abigen): resolve output struct types correctly (#1546)
* fix(abigen): resolve output struct types correctly * chore(clippy): make clippy happy
This commit is contained in:
parent
140b90d9b4
commit
6bb25e5228
|
@ -281,13 +281,9 @@ impl Context {
|
||||||
util::ident(&format!("{}Calls", self.contract_ident))
|
util::ident(&format!("{}Calls", self.contract_ident))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Expands to the `name : type` pairs of the function's parameters
|
/// Expands to the `name : type` pairs of the function's inputs
|
||||||
fn expand_params(
|
fn expand_input_params(&self, fun: &Function) -> Result<Vec<(TokenStream, TokenStream)>> {
|
||||||
&self,
|
fun.inputs
|
||||||
fun: &Function,
|
|
||||||
params: &[Param],
|
|
||||||
) -> Result<Vec<(TokenStream, TokenStream)>> {
|
|
||||||
params
|
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, param)| {
|
.map(|(idx, param)| {
|
||||||
|
@ -298,14 +294,17 @@ impl Context {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Expands to the `name : type` pairs of the function's inputs
|
|
||||||
fn expand_input_params(&self, fun: &Function) -> Result<Vec<(TokenStream, TokenStream)>> {
|
|
||||||
self.expand_params(fun, &fun.inputs)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Expands to the `name : type` pairs of the function's outputs
|
/// Expands to the `name : type` pairs of the function's outputs
|
||||||
fn expand_output_params(&self, fun: &Function) -> Result<Vec<(TokenStream, TokenStream)>> {
|
fn expand_output_params(&self, fun: &Function) -> Result<Vec<(TokenStream, TokenStream)>> {
|
||||||
self.expand_params(fun, &fun.outputs)
|
fun.outputs
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(idx, param)| {
|
||||||
|
let name = util::expand_input_name(idx, ¶m.name);
|
||||||
|
let ty = self.expand_output_param_type(fun, param, ¶m.kind)?;
|
||||||
|
Ok((name, ty))
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Expands to the return type of a function
|
/// Expands to the return type of a function
|
||||||
|
|
|
@ -659,3 +659,10 @@ fn can_generate_to_string_overload() {
|
||||||
fn can_generate_large_event() {
|
fn can_generate_large_event() {
|
||||||
abigen!(NewSale, "ethers-contract/tests/solidity-contracts/sale.json");
|
abigen!(NewSale, "ethers-contract/tests/solidity-contracts/sale.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_generate_large_output_struct() {
|
||||||
|
abigen!(LargeOutputStruct, "ethers-contract/tests/solidity-contracts/LargeStruct.json");
|
||||||
|
|
||||||
|
let r = GetByIdReturn(Info::default());
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "id",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "getById",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"internalType": "uint128",
|
||||||
|
"name": "x",
|
||||||
|
"type": "uint128"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int24",
|
||||||
|
"name": "y",
|
||||||
|
"type": "int24"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int24",
|
||||||
|
"name": "z",
|
||||||
|
"type": "int24"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "a",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int256",
|
||||||
|
"name": "b",
|
||||||
|
"type": "int256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int256",
|
||||||
|
"name": "c",
|
||||||
|
"type": "int256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int256",
|
||||||
|
"name": "d",
|
||||||
|
"type": "int256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "e",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "f",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"internalType": "struct Many.Info",
|
||||||
|
"name": "",
|
||||||
|
"type": "tuple"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue