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

Make AccountResponse conform to the StellarBase.Account interface. #655

Merged
merged 3 commits into from
Jun 1, 2021

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Jun 1, 2021

This resolves an unintentional breaking change introduced in 8.2.0 in which StellarSdk.AccountResponse was no longer interchangeable with StellarBase.Account in things like TransactionBuilder. This also closes #653.

Limitations: Since the test suite is written in JavaScript rather than TypeScript, this is impossible to catch there. More work needs to be done to avoid this happening in the future.

@Shaptic Shaptic requested a review from a team June 1, 2021 20:35
This just changes Account -> AccountResponse, the rest is just
wrapping the docstrings @ 80 chars for aesthetics.
Copy link
Contributor

@JakeUrban JakeUrban left a comment

Choose a reason for hiding this comment

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

One note about the type signature of createSubaccount() but the substance of the change looks good 👍

Comment on lines +87 to +89
public createSubaccount(id: string): MuxedAccount {
return this._baseAccount.createSubaccount(id);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The Account.createSubaccount() method doesn't have a type annotation:

https://stellar.github.io/js-stellar-sdk/js-stellar-base_src_account.js.html

My guess is that TypeScript will assume id is of type Any, in which case Account would still be incompatible with AccountResponse because createSubaccount()'s function signature doesn't match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stellar-base is written in pure JavaScript, so its source will never have true type annotations (aside from in the jsdoc). They're provided after-the-fact in index.d.ts, where id is in fact specified to be a string. I've also made sure of this in a test script (based on #653).

Aside: The true long-term fix here is to make Account an interface just like in the Go SDK, with AccountResponse (at the SDK level) and another Account plus MuxedAccount (at the base level) being three implementations of it, but that's a bigger investment (and a major version bump) for Later:tm:.

@Shaptic Shaptic requested a review from JakeUrban June 1, 2021 22: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.

Type AccountResponse not assignable to type Account anymore
2 participants