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

txnbuild: Use strings to represent accounts in txnbuild operations #3393

Merged
merged 3 commits into from
Feb 9, 2021

Conversation

tamirms
Copy link
Contributor

@tamirms tamirms commented Feb 5, 2021

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've updated the relevant CHANGELOG (here for Horizon) if
    needed with deprecations, added features, breaking changes, and DB schema changes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

Close #2813

Use strings to represent accounts in txnbuild operations.

This PR also fixes a bug ClaimableBalanceID(). The function builds an xdr.OperationId using the operation source account and the sequence number of the operation source account. It seems like we should be using the transaction source account and the sequence number found in the transaction. That is my understanding based on https://github.com/stellar/stellar-core/blob/b0cc4a9b8c3423358d1881b991834cf658bc38f5/src/transactions/CreateClaimableBalanceOpFrame.cpp#L278[…]L288

Why

We have an Account interface to represent Stellar accounts. The interface includes functions to get the account address and the account sequence number. This interface is useful for describing the source account of a Stellar transaction since we need to obtain the sequence number in order to define the transaction.

Many transaction operations also include Account fields. However, we never need the sequence number of an account to build an operation XDR. Instead of using the Account interface in operation structs, it would be more ergonomic to use strings since we only care about he account address when constructing operations.

Known limitations

[N/A]

@tamirms tamirms marked this pull request as ready for review February 5, 2021 18:34
@tamirms tamirms requested review from a team and leighmcculloch February 5, 2021 18:38
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

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

You should probably wait on another ✔️ but this LGTM. Thanks again for catching the balance ID mistake.

txnbuild/transaction.go Show resolved Hide resolved
Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

Thanks! 🚀 It was always a pain to use...

@tamirms tamirms merged commit 4090df1 into stellar:release-txnbuild-v6.0.0 Feb 9, 2021
@tamirms tamirms deleted the account-string branch February 9, 2021 06:24
@leighmcculloch
Copy link
Member

This PR also fixes a bug ClaimableBalanceID()

The bug being fixed could be a minor release for the current major release of txnbuild. What's the motivation for bundling this into the next major release?

@marcelosalloum
Copy link
Contributor

I agree, that fix could be shipped in a minor release IMO.

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.

5 participants