-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Type arguments in JSON ABI and the function selector #2218
Changes from 9 commits
84e0960
8d83510
9c1a512
9513ec0
f0c263b
899ddf6
2a437c0
4a806ca
d75d7ef
936583a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,8 @@ mod function_parameter; | |
pub use function_parameter::*; | ||
|
||
use crate::{error::*, parse_tree::*, semantic_analysis::*, style::*, type_engine::*, types::*}; | ||
use fuels_types::{Function, Property}; | ||
use sha2::{Digest, Sha256}; | ||
use sway_types::{Ident, Span, Spanned}; | ||
use sway_types::{Function, Ident, Property, Span, Spanned}; | ||
|
||
#[derive(Clone, Debug, Eq)] | ||
pub struct TypedFunctionDeclaration { | ||
|
@@ -95,12 +94,20 @@ impl ToJsonAbi for TypedFunctionDeclaration { | |
name: x.name.as_str().to_string(), | ||
type_field: x.type_id.json_abi_str(), | ||
components: x.type_id.generate_json_abi(), | ||
type_arguments: x | ||
.type_id | ||
.get_type_parameters() | ||
.map(|v| v.iter().map(|param| param.generate_json_abi()).collect()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar golf can be played here |
||
}) | ||
.collect(), | ||
outputs: vec![Property { | ||
name: "".to_string(), | ||
type_field: self.return_type.json_abi_str(), | ||
components: self.return_type.generate_json_abi(), | ||
type_arguments: self | ||
.return_type | ||
.get_type_parameters() | ||
.map(|v| v.iter().map(|param| param.generate_json_abi()).collect()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why go for par when you can go for a birdie? |
||
}], | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
use crate::{type_engine::*, types::*}; | ||
use fuels_types::Property; | ||
use std::{ | ||
fmt, | ||
hash::{Hash, Hasher}, | ||
}; | ||
use sway_types::Span; | ||
use sway_types::{Property, Span}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct TypeArgument { | ||
|
@@ -59,6 +58,10 @@ impl ToJsonAbi for TypeArgument { | |
name: "__tuple_element".to_string(), | ||
type_field: self.type_id.json_abi_str(), | ||
components: self.type_id.generate_json_abi(), | ||
type_arguments: self | ||
.type_id | ||
.get_type_parameters() | ||
.map(|v| v.iter().map(|param| param.generate_json_abi()).collect()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm running out of creativity but the same code golf could apply here |
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code golf:
.map(TypeParameter::generate_json_abi)