-
Notifications
You must be signed in to change notification settings - Fork 512
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
Add LedgerHistory to Connection #1119
Conversation
9de66ef
to
fc52489
Compare
} | ||
}) | ||
} | ||
|
||
getLedgerVersion(): Promise<number> { | ||
return this._whenReady(Promise.resolve(this._ledgerVersion!)) | ||
async getLedgerVersion(): Promise<number> { |
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.
possible nit: missing an access modifier here. Is this on purpose?
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.
Which access modifier were you expecting? Since it's already a public method, we don't want to mark it private
now and force a breaking change unnecessarily.
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.
I feel like my eslint
config always yells at me to make access modifies explicit. I prefer to make things explicit, though if this library doesn't then I defer to the existing style.
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.
Oh like adding "public"? I've actually never used that before. Not against it, but yea lets hold off to a future PR if you're interested in making that change. This library has only used them in 1-2 places and I see our eslint passing clean.
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.
good questions from Keefer
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.
LGTM
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.
LGTM! Thanks for changes and documentation!
Implements a change suggested in #1110.
Ledger
class._whenReady(promise)
->_waitForReady()
. The old method appeared to not be working as expected: it was meant to run a promise after the connection was ready, but a promise would always start immediately at creation time. Instead we just remove the promise argument, and resolve once the connection is ready. Then, the caller can wait for this to resolve before moving on to start the thing that needed to wait.waitForReady
will set some ledger data, so that methods likegetBaseFee()
will always return a number and never return null. It would be considered a bug if this promise was ever broken, but we could go one step further to throw an error OR add "null" as a possible return value so that the user had to handle this error case just in case. LMK your thoughts if you have any.