-
Notifications
You must be signed in to change notification settings - Fork 568
Mark AssetsAvailable, AssetsTotal and LossUnrealized of Vault object as Optional #3153
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,17 +49,17 @@ export default interface Vault extends BaseLedgerEntry, HasPreviousTxnID { | |
| /** | ||
| * The total value of the vault. | ||
| */ | ||
| AssetsTotal: string | ||
| AssetsTotal?: string | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: These fields have been marked as "Default", not "Optional". Hence, we need to introduce a Default value for these fields. I'm not sure if there is a precedent in the xrpl.js library, we'll need to look into it.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those fields of the Vault ledger entry were updated from soeREQUIRED to soeDEFAULT, and, by definition, soeDEFAULT is optional, if present, must not have default value. The correct TypeScript representation is simply making the field optional with ?, which is what we've done in this library, e.g., |
||
|
|
||
| /** | ||
| * The asset amount that is available in the vault. | ||
| */ | ||
| AssetsAvailable: string | ||
| AssetsAvailable?: string | ||
|
|
||
| /** | ||
| * The potential loss amount that is not yet realized expressed as the vaults asset. | ||
| */ | ||
| LossUnrealized: string | ||
| LossUnrealized?: string | ||
|
|
||
| /** | ||
| * The identifier of the share MPTokenIssuance object. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,12 +48,12 @@ export interface VaultInfoResponse extends BaseResponse { | |
| /** | ||
| * Amount of assets currently available for withdrawal. | ||
| */ | ||
| AssetsAvailable: string | ||
| AssetsAvailable?: string | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like a breaking change is introduced in rippled that makes these properties optional that were once required. If someone if accessing them directly as we did in integration tests, it would break their code. Not to block this, but should we confirm this in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for bringing this up. I asked in #cpp-informal. The conclusion is this is fine since SAV is not even up for voting yet and breaking changes are allowed.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Saw the note from Mayukha, since we are releasing library even before the amendment goes live on Mainnet, we should allow such breaking changes as bug fixes OR keep releasing, the features as release candidates and only release a stable version once the amendment is live on mainnet (to follow Semver). Some thoughts...
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you said makes sense. Feel free to champion this, and we should adopt it if it brings benefits to the team and the community.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Where can people use the client library features for Single-Asset-Vault? Apart from standalone nodes on their local nodes, is it available for use on public networks? (The XRPLF developers have the right to introduce breaking changes into the |
||
|
|
||
| /** | ||
| * Total amount of assets in the vault. | ||
| */ | ||
| AssetsTotal: string | ||
| AssetsTotal?: string | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these fields marked as Optional in the In your experiments, did you observe that
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct. The existing integration tests are failing because vaultInfo RPC doesn't include those fields in the response when they have default values. This match the definition of an |
||
|
|
||
| /** | ||
| * Ledger entry type, always "Vault". | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -80,12 +80,12 @@ describe('Single Asset Vault', function () { | |||||
| VaultWithdrawalPolicy.vaultStrategyFirstComeFirstServe, | ||||||
| ) | ||||||
| assert.equal( | ||||||
| vault.AssetsTotal, | ||||||
| vault.AssetsTotal ?? '0', | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the test file supplying a default value for these fields? The default value of It is preferable to remove the
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is no longer true, and why those tests are failing. Without the change, we are performing |
||||||
| '0', | ||||||
| 'New Vault should have zero total assets', | ||||||
| ) | ||||||
| assert.equal( | ||||||
| vault.AssetsAvailable, | ||||||
| vault.AssetsAvailable ?? '0', | ||||||
| '0', | ||||||
| 'New Vault should have zero available assets', | ||||||
| ) | ||||||
|
|
||||||
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.
Uh oh!
There was an error while loading. Please reload this page.
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 don't think we need to make this change. In rippled,
soeDEFAULTis an internal serialization style. In xrpl.js/Typescript, fields are either required or optional (marked with ?). There is no concept of "Default" fields in TypeScript.