Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

[FIX] Correctly determine when to set SendMax (RLJS-272) #345

Merged
merged 1 commit into from
Apr 13, 2015

Conversation

alandotcom
Copy link
Contributor

  • SendMax should not be set when the source and destination currencies
    are the same and the issuers are "any that the source is able to use
    and the destination is able to receive"

    e.g.,

   source_amount: {
      value: '0.0003272934271954',
      currency: 'GWD',
      issuer: ''
   },
   destination_amount: {
      value: '0.0003272934271954',
      currency: 'GWD',
      issuer: 'r4p4gZaWSq8Cs1d8mn1jaGqVU1HUns1ek3'
   }

@alandotcom
Copy link
Contributor Author

Can this PR get some code review ❤️ ?


// SendMax
if (sendMaxRequired()) {
var max_value = bignum(payment.source_amount.value).plus(payment.source_slippage).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use new BigNumber, this will fail on newer versions of bignumber.js

@alandotcom
Copy link
Contributor Author

Updated to fix lint errors

function sendMaxRequired() {
var src = payment.source_account;

var srcamt = payment.source_amount;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why'd you remove the camel-casing? Also, I generally prefer fewer abbreviations, though sometimes it's reasonable to abbreviate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just noticed this. Something was lost when I copy/pasted this function. Will update

- SendMax should not be set when the source and destination currencies
  are the same and the issuers are "any that the source is able to use
  and the destination is able to receive"

  e.g.,

   source_amount: {
      value: '0.0003272934271954',
      currency: 'GWD',
      issuer: ''
   },
   destination_amount: {
      value: '0.0003272934271954',
      currency: 'GWD',
      issuer: 'r4p4gZaWSq8Cs1d8mn1jaGqVU1HUns1ek3'
   }

- SendMax documentation:
  https://ripple.com/build/transactions/#special-issuer-values-for-sendmax-and-amount
@clark800
Copy link
Contributor

LGTM

1 similar comment
@geertweening
Copy link
Contributor

LGTM

geertweening added a commit that referenced this pull request Apr 13, 2015
[FIX] Correctly determine when to set SendMax (RLJS-272)
@geertweening geertweening merged commit 9a8332c into ripple:release Apr 13, 2015
@alandotcom alandotcom deleted the hotfix/sendmax branch April 15, 2015 21:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants