Skip to content
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

Move structs from "valuesMulti" and "valuesSingle". Merge input & output #13

Merged
merged 2 commits into from
May 30, 2024

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented May 30, 2024

This is a PR from a series of many.

  • InputMultiValue, OutputMultiValue -> MultiValue
  • InputVariadicValue, OutputVariadicValue -> VariadicValue
  • InputOptionalValue, OutputOptionalValue -> OptionalValue

No logic change, only refactoring.

See: #5.

@andreibancioiu andreibancioiu self-assigned this May 30, 2024
if i != len(outputValues)-1 {
return errors.New("variadic values must be last among output values")
}

err = s.deserializeVariadicValues(partsHolder, value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was dropped by mistake within this series of PRs.

https://github.com/multiversx/mx-sdk-abi-go/blob/main/abi/serializer.go#L147

package abi

// Field is a field in a struct, enum etc.
type Field struct {
Copy link
Contributor Author

@andreibancioiu andreibancioiu May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was moved from valuesSingle to its own file.

Most other structs from valuesSingle were moved to their own files (addressValue, boolValue etc.) in previous PRs. Small integers follow in the next PR.

@andreibancioiu andreibancioiu marked this pull request as ready for review May 30, 2024 07:14
sstanculeanu
sstanculeanu previously approved these changes May 30, 2024
if value.Value == nil {
return nil
}

return s.doSerialize(partsHolder, []any{value.Value})
}

func (s *serializer) serializeInputMultiValue(partsHolder *partsHolder, value InputMultiValue) error {
func (s *serializer) serializeMultiValue(partsHolder *partsHolder, value *MultiValue) error {
for _, item := range value.Items {
err := s.doSerialize(partsHolder, []any{item})
Copy link

@axenteoctavian axenteoctavian May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you do return s.doSerialize(partsHolder, value.Items) maybe? Same comment for the other funcs

Copy link
Contributor Author

@andreibancioiu andreibancioiu May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point! Refactored.

Tests are passing in the "staging" branch: #8.

@andreibancioiu andreibancioiu merged commit 32ae587 into feat/composite May 30, 2024
@andreibancioiu andreibancioiu deleted the composite-part-4 branch May 30, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants