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

Call getAsset from TrustlineCreatedEffectResponse class #396

Closed
przemyslawcelinski opened this issue Jan 4, 2022 · 1 comment · Fixed by #398
Closed

Call getAsset from TrustlineCreatedEffectResponse class #396

przemyslawcelinski opened this issue Jan 4, 2022 · 1 comment · Fixed by #398
Assignees
Labels

Comments

@przemyslawcelinski
Copy link

What version are you using?
Version 0.30.0

What did you do?
Call method

  public Asset getAsset() {
    if (assetType.equals("native")) {
      return new AssetTypeNative();
    } else {
      return Asset.createNonNativeAsset(assetCode, assetIssuer);
    }
  }

from TrustlineCreatedEffectResponse class

Operation "change_trust" in block 38115883 with effect trustline_created
https://horizon.stellar.org/transactions/a0a65ac4d71e44fc2be2bb071645a16a577efe6258e610214ab5dc60309c9798/effects which has
"asset_type": "liquidity_pool_shares" but assetCode and assetIssuer are null. So in Asset.createNonNativeAsset(assetCode, assetIssuer); is thrown NullPointerException

  public static Asset createNonNativeAsset(String code, String issuer) {
    if (code.length() >= 1 && code.length() <= 4) {
      return new AssetTypeCreditAlphaNum4(code, issuer);
    } else if (code.length() >= 5 && code.length() <= 12) {
      return new AssetTypeCreditAlphaNum12(code, issuer);
    } else {
      throw new AssetCodeLengthInvalidException();
    }
  }

I added comment to closed issue: #374 (comment)

@sreuland sreuland self-assigned this Jan 4, 2022
@sreuland
Copy link
Contributor

sreuland commented Jan 4, 2022

@przemyslawcelinski , thanks for report, yes, it looks like similar issue of mapping liquidity pools as asset from json into an sdk class, in this case TrustLineCUDResponse didn't map liquidity pool id and pass it to asset creation, I'm going through the effects and operations classes overall to get them all consistent.

sreuland added a commit to sreuland/java-stellar-sdk that referenced this issue Jan 6, 2022
…r all asset types(native, alpha4, alpha12, pool share). Fixed TrustlineCreatedEffectReponse marshaling to work when asset is of pool share type.
sreuland added a commit to sreuland/java-stellar-sdk that referenced this issue Jan 6, 2022
sreuland added a commit to sreuland/java-stellar-sdk that referenced this issue Jan 6, 2022
sreuland added a commit that referenced this issue Jan 10, 2022
…#398)

Fixes TrustlineCreatedEffectResponse.getAsset() to work when asset is of pool share type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants