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

fix the decoding of balanceId in org.stellar.sdk.ClaimClaimableBalanceOperation. #310

Merged

Conversation

overcat
Copy link
Member

@overcat overcat commented Dec 1, 2020

fix #309

@overcat overcat marked this pull request as ready for review December 1, 2020 03:24
@@ -22,14 +25,16 @@ public String getBalanceId() {
org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
ClaimClaimableBalanceOp op = new ClaimClaimableBalanceOp();

ClaimableBalanceID id = new ClaimableBalanceID();
id.setDiscriminant(ClaimableBalanceIDType.CLAIMABLE_BALANCE_ID_TYPE_V0);
Copy link
Member Author

Choose a reason for hiding this comment

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

The CLAIMABLE_BALANCE_ID_TYPE is already included in the banlanceId.

@tamirms
Copy link
Contributor

tamirms commented Dec 1, 2020

@overcat can you add a test?

Copy link
Contributor

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

No tests change as part of this that indicates we have no tests that cover this code and therefore this issue. Can you add a test that fails without this change and passes with the change?

@overcat
Copy link
Member Author

overcat commented Dec 2, 2020

Hi @leighmcculloch @tamirms, just added some tests.

ClaimClaimableBalanceOperation parsedOperation = (ClaimClaimableBalanceOperation) Operation.fromXdr(xdr);
assertEquals(accountId, parsedOperation.getSourceAccount());
assertEquals(balanceId, parsedOperation.getBalanceId());
// Generated by js-stellar-base.
Copy link
Member Author

Choose a reason for hiding this comment

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

const stellarBase = require("stellar-base")
const op = stellarBase.Operation.claimClaimableBalance({
    balanceId: "000000006d6a0c142516a9cc7885a85c5aba3a1f4af5181cf9e7a809ac7ae5e4a58c825f", 
    source: "GABTTS6N4CT7AUN4LD7IFIUMRD5PSMCW6QTLIQNEFZDEI6ZQVUCQMCLN"
})

console.log(op.toXDR().toString("base64"))

> AAAAAQAAAAADOcvN4KfwUbxY/oKijIj6+TBW9Ca0QaQuRkR7MK0FBgAAAA8AAAAAbWoMFCUWqcx4hahcWro6H0r1GBz556gJrHrl5KWMgl8=

@tamirms tamirms merged commit 7b3d60e into lightsail-network:master Dec 5, 2020
@tamirms tamirms mentioned this pull request Dec 5, 2020
@overcat overcat deleted the dev-fix-balanceId branch August 11, 2023 08:38
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.

Build Transaction with ClaimClaimableBalanceOperation,XDR cannot be decoded
3 participants