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

Add DepositPreauth #958

Merged
merged 12 commits into from
Oct 31, 2018
Merged

Add DepositPreauth #958

merged 12 commits into from
Oct 31, 2018

Conversation

intelliot
Copy link
Collaborator

  • Add documentation of prepareTransaction, the preferred method for preparing DepositPreauth transactions.
    • ripple-lib was already capable of signing DepositPreauth transactions thanks to ripple-binary-codec v0.1.15. However, this release was not tagged on GitHub, so I incremented the library's version to v0.2.0 and published it to npm and GitHub.
    • I'm pinning ripple-lib to use ripple-binary-codec v0.2.0 so that we can be explicit about using updates of this dependency in the future.
  • Add support for parsing DepositPreauth transactions.
  • Allow ripple-lib to parse unrecognized transaction types, so that ripple-lib is still usable when new transaction types are added in the future.
    • For unrecognized transaction types, no specification will be provided, but rawTransaction will be included.

return checkResult(expected, 'prepare', response)
})
})

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be worthwhile to include a test for Unauthorize?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call. Added in cd1be9d

@intelliot intelliot requested a review from mDuo13 October 24, 2018 22:29
@intelliot
Copy link
Collaborator Author

@mDuo13 I exposed a method called parseAccountFlags() which takes a Flags number and returns an object naming the flags and indicating whether they are true or false.

Copy link
Collaborator

@mDuo13 mDuo13 left a comment

Choose a reason for hiding this comment

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

I wasn't able to test out the changes, but I left some suggestions on the documentation. (I commented on the index.md file, but of course, the changes should go in the upstream ejs files first.)

docs/index.md Outdated

### Return Value

This method returns an object with containing a key for each parsed flag. Each flag has a boolean value of `true` or `false`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The example implies that flags that are false are omitted from the return value, or at least that flags whose value is their default value are omitted. That should be explicit. Alternatively, it would be OK (maybe more useful?) if all known flags were included (even if most of them are false).

docs/index.md Outdated

### Parameters

This method takes one parameter, the `Flags` number to parse.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth a note that this only works for AccountRoot Flags since the flags have different mappings on other types of objects or in transactions like AccountSet.

docs/index.md Outdated

Name | Type | Description
---- | ---- | -----------
transaction | [transaction](https://developers.ripple.com/transaction-formats.html) | The specification (JSON) of the transaction to prepare. Set `Account` to the address of the account that is creating the transaction. Common fields like `Fee`, `Flags`, and `Sequence` may be omitted; `prepareTransaction` will set them automatically.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the rippled API documentation, we use the term "Auto-fillable fields" for fields whose values can be automatically provided, and "Common fields" for fields that apply to all transactions (but whose values cannot be automatically provided, such as Account). Let's try to match that usage here.

docs/index.md Outdated
@@ -4955,6 +5060,10 @@ sign(txJSON: string, keypair: object, options: object): {signedTransaction: stri

Sign a prepared transaction. The signed transaction must subsequently be [submitted](#submit).

This method can sign any of [the transaction types supported by ripple-binary-codec](https://github.com/ripple/ripple-binary-codec/blob/cfcde79c19c359e9a0466d7bc3dc9a3aef47bb99/src/enums/definitions.json#L1637). When a new transaction type is added, it will be unrecognized until ripple-binary-codec is updated. An error will be thrown:
Copy link
Collaborator

Choose a reason for hiding this comment

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

For style reasons, avoid future tense and passive voice except when talking about future events. (In this paragraph, there are two instances of future tense, one of which is appropriate and one of which isn't.) Here's a suggested rephrase:

When a new transaction type is added to the XRP Ledger, it will be unrecognized until ripple-binary-codec is updated. If you try to sign an unrecognized transaction type, this method throws an error similar to the following:

@intelliot
Copy link
Collaborator Author

This is ready for re-review

Copy link
Collaborator

@mDuo13 mDuo13 left a comment

Choose a reason for hiding this comment

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

🥇 I was able to run the code and it works nicely. The revised wording looks good, too. (Left one nitpick you can optionally fix.)

docs/index.md Outdated
@@ -4164,8 +4155,8 @@ Notably, this is the preferred method for preparing a `DepositPreauth` transacti

Name | Type | Description
---- | ---- | -----------
transaction | [transaction](https://developers.ripple.com/transaction-formats.html) | The specification (JSON) of the transaction to prepare. Set `Account` to the address of the account that is creating the transaction. Common fields like `Fee`, `Flags`, and `Sequence` may be omitted; `prepareTransaction` will set them automatically.
instructions | [instructions](#transaction-instructions) | *Optional* Instructions for executing the transaction
transaction | [transaction](https://developers.ripple.com/transaction-formats.html) | The specification (JSON) of the transaction to prepare. Set `Account` to the address of the account that is creating the transaction. Auto-fillable fields like `Fee`, `Flags`, and `Sequence` may be omitted; `prepareTransaction` will set them automatically.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I suggest changing the last sentence just a little more for conciseness, active voice, etc.:

You may omit auto-fillable fields like Fee, Flags, and Sequence to have them set automatically.

@intelliot intelliot requested a review from FredKSchott October 31, 2018 00:35
@intelliot intelliot merged commit 4189874 into develop Oct 31, 2018
@intelliot intelliot deleted the DepositPreauth branch October 31, 2018 23:27
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.

3 participants