Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Remove ConvertBytes/Interface methods and add XDR type string constants.
Why
This is a follow up to:
The current exported interface with ConvertBytes and ConvertInterface encourages using the types defined outside the package, i.e. from the Go monorepo, as a name enum of sorts. Those types happen to be named the same, which is lucky given that if the Go types were named according to Go naming conventions they wouldn't match the Rust names encoded in the stellar-xdr Rust crate. The coupling is sort of convenient when using the stellar/go/xdr package, but otherwise the interface is very unintuitive.
Instead of the approach taken today, where another packages types are used as an enum, this package could provide a list of constants for all the types, and that would provide the same amount of certainty if folks were wanting to avoid having hardcoded strings.
Close #4
Notes
Generation of Type Constants
The constants are generated using the stellar-xdr Rust crate, so that the list of constants will always be up to date and match the underlying crate.
Rename of Convert* function to Decode
The function is renamed to align with the naming of the same operation in the
stellar-cli xdr
command, and thejs-stellar-xdr-json
package's exported interface. Some common nomenclature is helpful when maintaining a series of libraries and tools that export the same functionality.Todo
Merging
This PR should be merged after the PR below so that CI is in place: