-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix multi-argument contract calls #169
Conversation
cc @AlicanC @luizstacio this probably should also be implemented on |
I had implemented it on this PR: FuelLabs/fuels-ts#170 |
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.
One question, otherwise LGTM!
fuels-contract/src/contract.rs
Outdated
external_contracts: None, | ||
wallet: wallet.clone(), | ||
}) | ||
} | ||
|
||
// Returns true if the method call takes custom inputs or has more than one argument. This is used to determine whether we need to compute the `call_data_offset`. | ||
fn should_compute_call_data_offset(args: &[Token]) -> bool { | ||
match args.iter().any(|t| matches!(t, Token::Struct(_))) { |
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.
Shouldn't we also check for Enum
and in the future Tuples
?
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.
Yes for enums. Tuples might or might not be a thing, we'll see once the time comes.
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.
yes!
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.
nice!
Calls with multiple arguments, for instance
Were broken due to how we compute the call data offset. Before, we added this extra offset only if the argument was a custom type. Turns out, if you have more than one argument, you also need that. The only moment you don't need this extra offset is when the method takes only one arg and it's not a custom type.
This PR makes some simple, non-breaking changes to check whether we should or not compute this offset.