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

Support stellar-core protocol 12 #274

Merged
merged 14 commits into from
Oct 9, 2019
Merged

Support stellar-core protocol 12 #274

merged 14 commits into from
Oct 9, 2019

Conversation

abuiles
Copy link
Contributor

@abuiles abuiles commented Oct 2, 2019

Add support for stellar-core protocol 12 release and CAP 24 ("Make PathPayment Symmetrical").

Add ➕

  • Operation.pathPaymentStrictSend: Sends a path payment, debiting from the source account exactly a specified amount of one asset, crediting at least a given amount of another asset.

    The following operation will debit exactly 10 USD from the source account, crediting at least 9.2 EUR in the destination account 💸:

    var sendAsset = new StellarBase.Asset(
      'USD',
      'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
    );
    var sendAmount = '10';
    var destination =
      'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ';
    var destAsset = new StellarBase.Asset(
      'USD',
      'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
    );
    var destMin = '9.2';
    var path = [
      new StellarBase.Asset(
        'USD',
        'GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB'
      ),
      new StellarBase.Asset(
        'EUR',
        'GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL'
      )
    ];
    let op = StellarBase.Operation.pathPaymentStrictSend({
      sendAsset,
      sendAmount,
      destination,
      destAsset,
      destMin,
      path
    });
  • Operation.pathPaymentStrictReceive: This behaves the same as the former pathPayments operation.

    The following operation will debit maximum 10 USD from the source account, crediting exactly 9.2 EUR in the destination account 💸:

    var sendAsset = new StellarBase.Asset(
      'USD',
      'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
    );
    var sendMax = '10';
    var destination =
      'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ';
    var destAsset = new StellarBase.Asset(
      'USD',
      'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
    );
    var destAmount = '9.2';
    var path = [
      new StellarBase.Asset(
        'USD',
        'GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB'
      ),
      new StellarBase.Asset(
        'EUR',
        'GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL'
      )
    ];
    let op = StellarBase.Operation.pathPaymentStrictReceive({
      sendAsset,
      sendMax,
      destination,
      destAsset,
      destAmount,
      path
    });

Deprecated ❗️

  • Operation.pathPayment is being deprecated in favor of Operation.pathPaymentStrictReceive. Both functions take the same arguments and behave the same.

@abuiles abuiles marked this pull request as ready for review October 3, 2019 01:09
@marcinx
Copy link

marcinx commented Oct 3, 2019

Beautiful! I was just about to ask :)

@abuiles abuiles force-pushed the protocol-12 branch 2 times, most recently from 37d555e to ee1d1bd Compare October 3, 2019 02:02
Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

LGTM, just one question.

CHANGELOG.md Outdated

- `Operation.pathPaymentStrictSend`: Sends a path payments, debiting from the source account exactly an specified amount of one asset, crediting at least a given amount of another asset. ([#274](https://github.com/stellar/js-stellar-base/pull/274)).

The following operation will debit exactly $10 USD from the source acount, crediting at least $9.2 EUR in the destination account 💸:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The following operation will debit exactly $10 USD from the source acount, crediting at least $9.2 EUR in the destination account 💸:
The following operation will debit exactly 10 USD from the source acount, crediting at least 9.2 EUR in the destination account 💸:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bartekn oh, good catch! I won't apply the suggestion but do it as a commit on my machine since I used $ somewhere else

src/operations/index.js Show resolved Hide resolved
@abuiles abuiles merged commit 5f907f2 into master Oct 9, 2019
@abuiles abuiles deleted the protocol-12 branch October 9, 2019 00:29
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