From acd4aaf2565fcf861fd987d19589c376f367d7fb Mon Sep 17 00:00:00 2001 From: Bartek Nowotarski Date: Tue, 4 Sep 2018 17:50:57 +0200 Subject: [PATCH 1/2] Remove KeyPair dependency from requests and responses --- src/main/java/org/stellar/sdk/Account.java | 21 ++-- .../stellar/sdk/AccountMergeOperation.java | 23 ++-- .../org/stellar/sdk/AllowTrustOperation.java | 20 ++-- src/main/java/org/stellar/sdk/Asset.java | 18 +-- .../stellar/sdk/AssetTypeCreditAlphaNum.java | 12 +- .../sdk/AssetTypeCreditAlphaNum12.java | 10 +- .../stellar/sdk/AssetTypeCreditAlphaNum4.java | 10 +- .../stellar/sdk/BumpSequenceOperation.java | 4 +- .../org/stellar/sdk/ChangeTrustOperation.java | 4 +- .../stellar/sdk/CreateAccountOperation.java | 21 ++-- .../sdk/CreatePassiveSellOfferOperation.java | 4 +- src/main/java/org/stellar/sdk/KeyPair.java | 7 +- .../stellar/sdk/ManageBuyOfferOperation.java | 4 +- .../org/stellar/sdk/ManageDataOperation.java | 4 +- .../stellar/sdk/ManageSellOfferOperation.java | 4 +- src/main/java/org/stellar/sdk/Operation.java | 21 ++-- .../org/stellar/sdk/PathPaymentOperation.java | 21 ++-- .../org/stellar/sdk/PaymentOperation.java | 22 ++-- .../org/stellar/sdk/SetOptionsOperation.java | 21 ++-- src/main/java/org/stellar/sdk/StrKey.java | 15 +++ .../java/org/stellar/sdk/Transaction.java | 16 +-- .../sdk/TransactionBuilderAccount.java | 7 +- .../sdk/requests/AccountsRequestBuilder.java | 5 +- .../sdk/requests/EffectsRequestBuilder.java | 5 +- .../sdk/requests/OffersRequestBuilder.java | 5 +- .../requests/OperationsRequestBuilder.java | 5 +- .../sdk/requests/OrderBookRequestBuilder.java | 4 +- .../sdk/requests/PathsRequestBuilder.java | 11 +- .../sdk/requests/PaymentsRequestBuilder.java | 5 +- .../TradeAggregationsRequestBuilder.java | 4 +- .../sdk/requests/TradesRequestBuilder.java | 9 +- .../requests/TransactionsRequestBuilder.java | 5 +- .../sdk/responses/AccountResponse.java | 25 ++-- .../sdk/responses/AssetDeserializer.java | 3 +- .../sdk/responses/EffectDeserializer.java | 2 - .../stellar/sdk/responses/GsonSingleton.java | 2 - .../sdk/responses/KeyPairTypeAdapter.java | 21 ---- .../stellar/sdk/responses/OfferResponse.java | 7 +- .../sdk/responses/OperationDeserializer.java | 2 - .../sdk/responses/PageDeserializer.java | 2 - .../stellar/sdk/responses/PathResponse.java | 7 +- .../stellar/sdk/responses/TradeResponse.java | 11 +- .../responses/TransactionDeserializer.java | 2 - .../sdk/responses/TransactionResponse.java | 7 +- .../AccountCreditedEffectResponse.java | 4 +- .../effects/AccountDebitedEffectResponse.java | 4 +- .../sdk/responses/effects/EffectResponse.java | 5 +- .../effects/TradeEffectResponse.java | 13 +-- .../TrustlineAuthorizationResponse.java | 8 +- .../TrustlineAuthorizedEffectResponse.java | 4 +- .../effects/TrustlineCUDResponse.java | 4 +- .../TrustlineDeauthorizedEffectResponse.java | 4 +- .../AccountMergeOperationResponse.java | 12 +- .../AllowTrustOperationResponse.java | 14 +-- .../ChangeTrustOperationResponse.java | 14 +-- .../CreateAccountOperationResponse.java | 12 +- ...eatePassiveSellOfferOperationResponse.java | 7 +- .../ManageBuyOfferOperationResponse.java | 7 +- .../ManageSellOfferOperationResponse.java | 7 +- .../operations/OperationResponse.java | 5 +- .../PathPaymentOperationResponse.java | 17 ++- .../operations/PaymentOperationResponse.java | 14 +-- .../SetOptionsOperationResponse.java | 7 +- .../java/org/stellar/sdk/AccountTest.java | 14 ++- src/test/java/org/stellar/sdk/AssetTest.java | 16 +-- .../java/org/stellar/sdk/KeyPairTest.java | 10 ++ .../java/org/stellar/sdk/OperationTest.java | 109 +++++++++--------- src/test/java/org/stellar/sdk/ServerTest.java | 4 +- .../java/org/stellar/sdk/TransactionTest.java | 84 +++++++------- .../requests/EffectsRequestBuilderTest.java | 2 +- .../requests/OffersRequestBuilderTest.java | 2 +- .../OperationsRequestBuilderTest.java | 2 +- .../requests/OrderBookRequestBuilderTest.java | 4 +- .../sdk/requests/PathsRequestBuilderTest.java | 6 +- .../requests/PaymentsRequestBuilderTest.java | 2 +- .../TradeAggregationsRequestBuilderTest.java | 2 +- .../requests/TradesRequestBuilderTest.java | 6 +- .../TransactionsRequestBuilderTest.java | 2 +- .../responses/AccountDeserializerTest.java | 6 +- .../AccountsPageDeserializerTest.java | 4 +- .../sdk/responses/AssetDeserializerTest.java | 2 +- .../sdk/responses/EffectDeserializerTest.java | 58 +++++----- .../EffectsPageDeserializerTest.java | 2 +- .../responses/OfferPageDeserializerTest.java | 6 +- .../responses/OperationDeserializerTest.java | 50 ++++---- .../OperationsPageDeserializerTest.java | 8 +- .../responses/OrderBookDeserializerTest.java | 2 +- .../responses/PathsPageDeserializerTest.java | 18 +-- .../responses/TradesPageDeserializerTest.java | 4 +- .../TransactionDeserializerTest.java | 2 +- .../TransactionPageDeserializerTest.java | 4 +- 91 files changed, 483 insertions(+), 548 deletions(-) delete mode 100644 src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java diff --git a/src/main/java/org/stellar/sdk/Account.java b/src/main/java/org/stellar/sdk/Account.java index 8b973422c..dabcb69d2 100644 --- a/src/main/java/org/stellar/sdk/Account.java +++ b/src/main/java/org/stellar/sdk/Account.java @@ -10,22 +10,27 @@ * @see org.stellar.sdk.Transaction.Builder */ public class Account implements TransactionBuilderAccount { - private final KeyPair mKeyPair; + private final String mAccountId; private Long mSequenceNumber; /** * Class constructor. - * @param keypair KeyPair associated with this Account + * @param accountId ID associated with this Account * @param sequenceNumber Current sequence number of the account (can be obtained using java-stellar-sdk or horizon server) */ - public Account(KeyPair keypair, Long sequenceNumber) { - mKeyPair = checkNotNull(keypair, "keypair cannot be null"); + public Account(String accountId, Long sequenceNumber) { + mAccountId = checkNotNull(accountId, "accountId cannot be null"); mSequenceNumber = checkNotNull(sequenceNumber, "sequenceNumber cannot be null"); } @Override - public KeyPair getKeypair() { - return mKeyPair; + public String getAccountId() { + return mAccountId; + } + + @Override + public KeyPair getKeyPair() { + return KeyPair.fromAccountId(mAccountId); } @Override @@ -46,7 +51,7 @@ public void incrementSequenceNumber() { } public int hashCode() { - return Objects.hashCode(this.mKeyPair, this.mSequenceNumber); + return Objects.hashCode(this.mAccountId, this.mSequenceNumber); } @Override @@ -56,7 +61,7 @@ public boolean equals(Object object) { } Account other = (Account) object; - return Objects.equal(this.mKeyPair, other.mKeyPair) && + return Objects.equal(this.mAccountId, other.mAccountId) && Objects.equal(this.mSequenceNumber, other.mSequenceNumber); } diff --git a/src/main/java/org/stellar/sdk/AccountMergeOperation.java b/src/main/java/org/stellar/sdk/AccountMergeOperation.java index 355330b34..4c0a0baa5 100644 --- a/src/main/java/org/stellar/sdk/AccountMergeOperation.java +++ b/src/main/java/org/stellar/sdk/AccountMergeOperation.java @@ -1,7 +1,6 @@ package org.stellar.sdk; import com.google.common.base.Objects; -import org.stellar.sdk.xdr.AccountID; import org.stellar.sdk.xdr.Operation.OperationBody; import org.stellar.sdk.xdr.OperationType; @@ -13,25 +12,23 @@ */ public class AccountMergeOperation extends Operation { - private final KeyPair destination; + private final String destination; - private AccountMergeOperation(KeyPair destination) { + private AccountMergeOperation(String destination) { this.destination = checkNotNull(destination, "destination cannot be null"); } /** * The account that receives the remaining XLM balance of the source account. */ - public KeyPair getDestination() { + public String getDestination() { return destination; } @Override OperationBody toOperationBody() { OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody(); - AccountID destination = new AccountID(); - destination.setAccountID(this.destination.getXdrPublicKey()); - body.setDestination(destination); + body.setDestination(StrKey.encodeToXDRAccountId(this.destination)); body.setDiscriminant(OperationType.ACCOUNT_MERGE); return body; } @@ -41,19 +38,21 @@ OperationBody toOperationBody() { * @see AccountMergeOperation */ public static class Builder { - private final KeyPair destination; + private final String destination; - private KeyPair mSourceAccount; + private String mSourceAccount; Builder(OperationBody op) { - destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID()); + destination = StrKey.encodeStellarAccountId( + op.getDestination().getAccountID().getEd25519().getUint256() + ); } /** * Creates a new AccountMerge builder. * @param destination The account that receives the remaining XLM balance of the source account. */ - public Builder(KeyPair destination) { + public Builder(String destination) { this.destination = destination; } @@ -62,7 +61,7 @@ public Builder(KeyPair destination) { * @param sourceAccount Source account * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = sourceAccount; return this; } diff --git a/src/main/java/org/stellar/sdk/AllowTrustOperation.java b/src/main/java/org/stellar/sdk/AllowTrustOperation.java index 7a44bcd6e..21ec896a2 100644 --- a/src/main/java/org/stellar/sdk/AllowTrustOperation.java +++ b/src/main/java/org/stellar/sdk/AllowTrustOperation.java @@ -11,11 +11,11 @@ */ public class AllowTrustOperation extends Operation { - private final KeyPair trustor; + private final String trustor; private final String assetCode; private final boolean authorize; - private AllowTrustOperation(KeyPair trustor, String assetCode, boolean authorize) { + private AllowTrustOperation(String trustor, String assetCode, boolean authorize) { this.trustor = checkNotNull(trustor, "trustor cannot be null"); this.assetCode = checkNotNull(assetCode, "assetCode cannot be null"); this.authorize = authorize; @@ -24,7 +24,7 @@ private AllowTrustOperation(KeyPair trustor, String assetCode, boolean authorize /** * The account of the recipient of the trustline. */ - public KeyPair getTrustor() { + public String getTrustor() { return trustor; } @@ -47,9 +47,7 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { AllowTrustOp op = new AllowTrustOp(); // trustor - AccountID trustor = new AccountID(); - trustor.setAccountID(this.trustor.getXdrPublicKey()); - op.setTrustor(trustor); + op.setTrustor(StrKey.encodeToXDRAccountId(this.trustor)); // asset AllowTrustOp.AllowTrustOpAsset asset = new AllowTrustOp.AllowTrustOpAsset(); if (assetCode.length() <= 4) { @@ -78,14 +76,14 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { * @see AllowTrustOperation */ public static class Builder { - private final KeyPair trustor; + private final String trustor; private final String assetCode; private final boolean authorize; - private KeyPair mSourceAccount; + private String mSourceAccount; Builder(AllowTrustOp op) { - trustor = KeyPair.fromXdrPublicKey(op.getTrustor().getAccountID()); + trustor = StrKey.encodeStellarAccountId(op.getTrustor().getAccountID().getEd25519().getUint256()); switch (op.getAsset().getDiscriminant()) { case ASSET_TYPE_CREDIT_ALPHANUM4: assetCode = new String(op.getAsset().getAssetCode4().getAssetCode4()).trim(); @@ -105,7 +103,7 @@ public static class Builder { * @param assetCode The asset of the trustline the source account is authorizing. For example, if a gateway wants to allow another account to hold its USD credit, the type is USD. * @param authorize Flag indicating whether the trustline is authorized. */ - public Builder(KeyPair trustor, String assetCode, boolean authorize) { + public Builder(String trustor, String assetCode, boolean authorize) { this.trustor = trustor; this.assetCode = assetCode; this.authorize = authorize; @@ -116,7 +114,7 @@ public Builder(KeyPair trustor, String assetCode, boolean authorize) { * @param sourceAccount Source account * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = sourceAccount; return this; } diff --git a/src/main/java/org/stellar/sdk/Asset.java b/src/main/java/org/stellar/sdk/Asset.java index 9e7507439..24629645d 100644 --- a/src/main/java/org/stellar/sdk/Asset.java +++ b/src/main/java/org/stellar/sdk/Asset.java @@ -11,7 +11,7 @@ public static Asset create(String type, String code, String issuer) { if (type.equals("native")) { return new AssetTypeNative(); } else { - return Asset.createNonNativeAsset(code, KeyPair.fromAccountId(issuer)); + return Asset.createNonNativeAsset(code, issuer); } } @@ -20,7 +20,7 @@ public static Asset create(String type, String code, String issuer) { * @param code Asset code * @param issuer Asset issuer */ - public static Asset createNonNativeAsset(String code, KeyPair issuer) { + 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) { @@ -35,18 +35,22 @@ public static Asset createNonNativeAsset(String code, KeyPair issuer) { * @param xdr XDR object */ public static Asset fromXdr(org.stellar.sdk.xdr.Asset xdr) { + String accountId; switch (xdr.getDiscriminant()) { case ASSET_TYPE_NATIVE: return new AssetTypeNative(); case ASSET_TYPE_CREDIT_ALPHANUM4: String assetCode4 = Util.paddedByteArrayToString(xdr.getAlphaNum4().getAssetCode().getAssetCode4()); - KeyPair issuer4 = KeyPair.fromXdrPublicKey( - xdr.getAlphaNum4().getIssuer().getAccountID()); - return new AssetTypeCreditAlphaNum4(assetCode4, issuer4); + accountId = StrKey.encodeStellarAccountId( + xdr.getAlphaNum4().getIssuer().getAccountID().getEd25519().getUint256() + ); + return new AssetTypeCreditAlphaNum4(assetCode4, accountId); case ASSET_TYPE_CREDIT_ALPHANUM12: String assetCode12 = Util.paddedByteArrayToString(xdr.getAlphaNum12().getAssetCode().getAssetCode12()); - KeyPair issuer12 = KeyPair.fromXdrPublicKey(xdr.getAlphaNum12().getIssuer().getAccountID()); - return new AssetTypeCreditAlphaNum12(assetCode12, issuer12); + accountId = StrKey.encodeStellarAccountId( + xdr.getAlphaNum12().getIssuer().getAccountID().getEd25519().getUint256() + ); + return new AssetTypeCreditAlphaNum12(assetCode12, accountId); default: throw new IllegalArgumentException("Unknown asset type " + xdr.getDiscriminant()); } diff --git a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java index 2e08a33d4..d6d930efa 100644 --- a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java +++ b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java @@ -11,13 +11,13 @@ */ public abstract class AssetTypeCreditAlphaNum extends Asset { protected final String mCode; - protected final KeyPair mIssuer; + protected final String mIssuer; - public AssetTypeCreditAlphaNum(String code, KeyPair issuer) { + public AssetTypeCreditAlphaNum(String code, String issuer) { checkNotNull(code, "code cannot be null"); checkNotNull(issuer, "issuer cannot be null"); mCode = new String(code); - mIssuer = KeyPair.fromAccountId(issuer.getAccountId()); + mIssuer = new String(issuer); } /** @@ -30,8 +30,8 @@ public String getCode() { /** * Returns asset issuer */ - public KeyPair getIssuer() { - return KeyPair.fromAccountId(mIssuer.getAccountId()); + public String getIssuer() { + return new String(mIssuer); } @Override @@ -48,6 +48,6 @@ public boolean equals(Object object) { AssetTypeCreditAlphaNum o = (AssetTypeCreditAlphaNum) object; return this.getCode().equals(o.getCode()) && - this.getIssuer().getAccountId().equals(o.getIssuer().getAccountId()); + this.getIssuer().equals(o.getIssuer()); } } diff --git a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java index 3afc90f1f..68722e55d 100644 --- a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java +++ b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java @@ -1,8 +1,6 @@ package org.stellar.sdk; -import org.stellar.sdk.xdr.AccountID; -import org.stellar.sdk.xdr.AssetCode12; -import org.stellar.sdk.xdr.AssetType; +import org.stellar.sdk.xdr.*; /** * Represents all assets with codes 5-12 characters long. @@ -15,7 +13,7 @@ public final class AssetTypeCreditAlphaNum12 extends AssetTypeCreditAlphaNum { * @param code Asset code * @param issuer Asset issuer */ - public AssetTypeCreditAlphaNum12(String code, KeyPair issuer) { + public AssetTypeCreditAlphaNum12(String code, String issuer) { super(code, issuer); if (code.length() < 5 || code.length() > 12) { throw new AssetCodeLengthInvalidException(); @@ -35,9 +33,7 @@ public org.stellar.sdk.xdr.Asset toXdr() { AssetCode12 assetCode12 = new AssetCode12(); assetCode12.setAssetCode12(Util.paddedByteArray(mCode, 12)); credit.setAssetCode(assetCode12); - AccountID accountID = new AccountID(); - accountID.setAccountID(mIssuer.getXdrPublicKey()); - credit.setIssuer(accountID); + credit.setIssuer(StrKey.encodeToXDRAccountId(mIssuer)); xdr.setAlphaNum12(credit); return xdr; } diff --git a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java index ed3c7f9d2..b737dbf07 100644 --- a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java +++ b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java @@ -1,8 +1,6 @@ package org.stellar.sdk; -import org.stellar.sdk.xdr.AccountID; -import org.stellar.sdk.xdr.AssetCode4; -import org.stellar.sdk.xdr.AssetType; +import org.stellar.sdk.xdr.*; /** * Represents all assets with codes 1-4 characters long. @@ -15,7 +13,7 @@ public final class AssetTypeCreditAlphaNum4 extends AssetTypeCreditAlphaNum { * @param code Asset code * @param issuer Asset issuer */ - public AssetTypeCreditAlphaNum4(String code, KeyPair issuer) { + public AssetTypeCreditAlphaNum4(String code, String issuer) { super(code, issuer); if (code.length() < 1 || code.length() > 4) { throw new AssetCodeLengthInvalidException(); @@ -35,9 +33,7 @@ public org.stellar.sdk.xdr.Asset toXdr() { AssetCode4 assetCode4 = new AssetCode4(); assetCode4.setAssetCode4(Util.paddedByteArray(mCode, 4)); credit.setAssetCode(assetCode4); - AccountID accountID = new AccountID(); - accountID.setAccountID(mIssuer.getXdrPublicKey()); - credit.setIssuer(accountID); + credit.setIssuer(StrKey.encodeToXDRAccountId(mIssuer)); xdr.setAlphaNum4(credit); return xdr; } diff --git a/src/main/java/org/stellar/sdk/BumpSequenceOperation.java b/src/main/java/org/stellar/sdk/BumpSequenceOperation.java index 6f5263fd1..6d6dd8825 100644 --- a/src/main/java/org/stellar/sdk/BumpSequenceOperation.java +++ b/src/main/java/org/stellar/sdk/BumpSequenceOperation.java @@ -38,7 +38,7 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { public static class Builder { private final long bumpTo; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new BumpSequence builder from a BumpSequence XDR. @@ -61,7 +61,7 @@ public Builder(long bumpTo) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public BumpSequenceOperation.Builder setSourceAccount(KeyPair sourceAccount) { + public BumpSequenceOperation.Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/ChangeTrustOperation.java b/src/main/java/org/stellar/sdk/ChangeTrustOperation.java index 9af0b3bb5..e533261d3 100644 --- a/src/main/java/org/stellar/sdk/ChangeTrustOperation.java +++ b/src/main/java/org/stellar/sdk/ChangeTrustOperation.java @@ -58,7 +58,7 @@ public static class Builder { private final Asset asset; private final String limit; - private KeyPair mSourceAccount; + private String mSourceAccount; Builder(ChangeTrustOp op) { asset = Asset.fromXdr(op.getLine()); @@ -81,7 +81,7 @@ public Builder(Asset asset, String limit) { * @param sourceAccount Source account * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/CreateAccountOperation.java b/src/main/java/org/stellar/sdk/CreateAccountOperation.java index 9aba9fe4f..938ed2e04 100644 --- a/src/main/java/org/stellar/sdk/CreateAccountOperation.java +++ b/src/main/java/org/stellar/sdk/CreateAccountOperation.java @@ -1,7 +1,6 @@ package org.stellar.sdk; import com.google.common.base.Objects; -import org.stellar.sdk.xdr.AccountID; import org.stellar.sdk.xdr.CreateAccountOp; import org.stellar.sdk.xdr.Int64; import org.stellar.sdk.xdr.OperationType; @@ -14,10 +13,10 @@ */ public class CreateAccountOperation extends Operation { - private final KeyPair destination; + private final String destination; private final String startingBalance; - private CreateAccountOperation(KeyPair destination, String startingBalance) { + private CreateAccountOperation(String destination, String startingBalance) { this.destination = checkNotNull(destination, "destination cannot be null"); this.startingBalance = checkNotNull(startingBalance, "startingBalance cannot be null"); } @@ -32,16 +31,14 @@ public String getStartingBalance() { /** * Account that is created and funded */ - public KeyPair getDestination() { + public String getDestination() { return destination; } @Override org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { CreateAccountOp op = new CreateAccountOp(); - AccountID destination = new AccountID(); - destination.setAccountID(this.destination.getXdrPublicKey()); - op.setDestination(destination); + op.setDestination(StrKey.encodeToXDRAccountId(this.destination)); Int64 startingBalance = new Int64(); startingBalance.setInt64(Operation.toXdrAmount(this.startingBalance)); op.setStartingBalance(startingBalance); @@ -57,17 +54,17 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { * @see CreateAccountOperation */ public static class Builder { - private final KeyPair destination; + private final String destination; private final String startingBalance; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new CreateAccount builder from a CreateAccountOp XDR. * @param op {@link CreateAccountOp} */ Builder(CreateAccountOp op) { - destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID()); + destination = StrKey.encodeStellarAccountId(op.getDestination().getAccountID().getEd25519().getUint256()); startingBalance = Operation.fromXdrAmount(op.getStartingBalance().getInt64().longValue()); } @@ -77,7 +74,7 @@ public static class Builder { * @param startingBalance The initial balance to start with in lumens. * @throws ArithmeticException when startingBalance has more than 7 decimal places. */ - public Builder(KeyPair destination, String startingBalance) { + public Builder(String destination, String startingBalance) { this.destination = destination; this.startingBalance = startingBalance; } @@ -87,7 +84,7 @@ public Builder(KeyPair destination, String startingBalance) { * @param account The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair account) { + public Builder setSourceAccount(String account) { mSourceAccount = account; return this; } diff --git a/src/main/java/org/stellar/sdk/CreatePassiveSellOfferOperation.java b/src/main/java/org/stellar/sdk/CreatePassiveSellOfferOperation.java index fdcea948e..a47e6f778 100644 --- a/src/main/java/org/stellar/sdk/CreatePassiveSellOfferOperation.java +++ b/src/main/java/org/stellar/sdk/CreatePassiveSellOfferOperation.java @@ -83,7 +83,7 @@ public static class Builder { private final String amount; private final String price; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new CreatePassiveOffer builder from a CreatePassiveOfferOp XDR. @@ -119,7 +119,7 @@ public Builder(Asset selling, Asset buying, String amount, String price) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public CreatePassiveSellOfferOperation.Builder setSourceAccount(KeyPair sourceAccount) { + public CreatePassiveSellOfferOperation.Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/KeyPair.java b/src/main/java/org/stellar/sdk/KeyPair.java index 8e7d68a90..1f60b78af 100644 --- a/src/main/java/org/stellar/sdk/KeyPair.java +++ b/src/main/java/org/stellar/sdk/KeyPair.java @@ -112,7 +112,12 @@ public static KeyPair fromAccountId(String accountId) { * @return {@link KeyPair} */ public static KeyPair fromPublicKey(byte[] publicKey) { - EdDSAPublicKeySpec publicKeySpec = new EdDSAPublicKeySpec(publicKey, ed25519); + EdDSAPublicKeySpec publicKeySpec; + try { + publicKeySpec = new EdDSAPublicKeySpec(publicKey, ed25519); + } catch (IllegalArgumentException e) { + throw new RuntimeException("Public key is invalid"); + } return new KeyPair(new EdDSAPublicKey(publicKeySpec)); } diff --git a/src/main/java/org/stellar/sdk/ManageBuyOfferOperation.java b/src/main/java/org/stellar/sdk/ManageBuyOfferOperation.java index d0398c43f..747609b8c 100644 --- a/src/main/java/org/stellar/sdk/ManageBuyOfferOperation.java +++ b/src/main/java/org/stellar/sdk/ManageBuyOfferOperation.java @@ -98,7 +98,7 @@ public static class Builder { private final String price; private long offerId = 0; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new ManageBuyOffer builder from a ManageBuyOfferOp XDR. @@ -146,7 +146,7 @@ public Builder setOfferId(long offerId) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/ManageDataOperation.java b/src/main/java/org/stellar/sdk/ManageDataOperation.java index 6f0a726de..38e5fb5be 100644 --- a/src/main/java/org/stellar/sdk/ManageDataOperation.java +++ b/src/main/java/org/stellar/sdk/ManageDataOperation.java @@ -61,7 +61,7 @@ public static class Builder { private final String name; private final byte[] value; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new ManageOffer builder from a ManageDataOp XDR. @@ -91,7 +91,7 @@ public Builder(String name, byte[] value) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/ManageSellOfferOperation.java b/src/main/java/org/stellar/sdk/ManageSellOfferOperation.java index ffe9a3ae8..497ff0bff 100644 --- a/src/main/java/org/stellar/sdk/ManageSellOfferOperation.java +++ b/src/main/java/org/stellar/sdk/ManageSellOfferOperation.java @@ -96,7 +96,7 @@ public static class Builder { private final String price; private long offerId = 0; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new ManageSellOffer builder from a ManageSellOfferOp XDR. @@ -140,7 +140,7 @@ public Builder setOfferId(long offerId) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/Operation.java b/src/main/java/org/stellar/sdk/Operation.java index 6ec04d5b0..dee922726 100644 --- a/src/main/java/org/stellar/sdk/Operation.java +++ b/src/main/java/org/stellar/sdk/Operation.java @@ -1,8 +1,7 @@ package org.stellar.sdk; import com.google.common.io.BaseEncoding; -import org.stellar.sdk.xdr.AccountID; -import org.stellar.sdk.xdr.XdrDataOutputStream; +import org.stellar.sdk.xdr.*; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -16,7 +15,7 @@ public abstract class Operation { Operation() {} - private KeyPair mSourceAccount; + private String mSourceAccount; private static final BigDecimal ONE = new BigDecimal(10).pow(7); @@ -37,9 +36,7 @@ protected static String fromXdrAmount(long value) { public org.stellar.sdk.xdr.Operation toXdr() { org.stellar.sdk.xdr.Operation xdr = new org.stellar.sdk.xdr.Operation(); if (getSourceAccount() != null) { - AccountID sourceAccount = new AccountID(); - sourceAccount.setAccountID(getSourceAccount().getXdrPublicKey()); - xdr.setSourceAccount(sourceAccount); + xdr.setSourceAccount(StrKey.encodeToXDRAccountId(mSourceAccount)); } xdr.setBody(toOperationBody()); return xdr; @@ -112,7 +109,9 @@ public static Operation fromXdr(org.stellar.sdk.xdr.Operation xdr) { throw new RuntimeException("Unknown operation body " + body.getDiscriminant()); } if (xdr.getSourceAccount() != null) { - operation.setSourceAccount(KeyPair.fromXdrPublicKey(xdr.getSourceAccount().getAccountID())); + operation.setSourceAccount( + StrKey.encodeStellarAccountId(xdr.getSourceAccount().getAccountID().getEd25519().getUint256()) + ); } return operation; } @@ -120,16 +119,16 @@ public static Operation fromXdr(org.stellar.sdk.xdr.Operation xdr) { /** * Returns operation source account. */ - public KeyPair getSourceAccount() { + public String getSourceAccount() { return mSourceAccount; } /** * Sets operation source account. - * @param keypair + * @param sourceAccount */ - void setSourceAccount(KeyPair keypair) { - mSourceAccount = checkNotNull(keypair, "keypair cannot be null"); + void setSourceAccount(String sourceAccount) { + mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); } /** diff --git a/src/main/java/org/stellar/sdk/PathPaymentOperation.java b/src/main/java/org/stellar/sdk/PathPaymentOperation.java index b93b6e971..398133bbc 100644 --- a/src/main/java/org/stellar/sdk/PathPaymentOperation.java +++ b/src/main/java/org/stellar/sdk/PathPaymentOperation.java @@ -1,7 +1,6 @@ package org.stellar.sdk; import com.google.common.base.Objects; -import org.stellar.sdk.xdr.AccountID; import org.stellar.sdk.xdr.Int64; import org.stellar.sdk.xdr.OperationType; import org.stellar.sdk.xdr.PathPaymentOp; @@ -20,12 +19,12 @@ public class PathPaymentOperation extends Operation { private final Asset sendAsset; private final String sendMax; - private final KeyPair destination; + private final String destination; private final Asset destAsset; private final String destAmount; private final Asset[] path; - private PathPaymentOperation(Asset sendAsset, String sendMax, KeyPair destination, + private PathPaymentOperation(Asset sendAsset, String sendMax, String destination, Asset destAsset, String destAmount, Asset[] path) { this.sendAsset = checkNotNull(sendAsset, "sendAsset cannot be null"); this.sendMax = checkNotNull(sendMax, "sendMax cannot be null"); @@ -57,7 +56,7 @@ public String getSendMax() { /** * Account that receives the payment. */ - public KeyPair getDestination() { + public String getDestination() { return destination; } @@ -93,9 +92,7 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { sendMax.setInt64(Operation.toXdrAmount(this.sendMax)); op.setSendMax(sendMax); // destination - AccountID destination = new AccountID(); - destination.setAccountID(this.destination.getXdrPublicKey()); - op.setDestination(destination); + op.setDestination(StrKey.encodeToXDRAccountId(this.destination)); // destAsset op.setDestAsset(destAsset.toXdr()); // destAmount @@ -122,17 +119,17 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { public static class Builder { private final Asset sendAsset; private final String sendMax; - private final KeyPair destination; + private final String destination; private final Asset destAsset; private final String destAmount; private Asset[] path; - private KeyPair mSourceAccount; + private String mSourceAccount; Builder(PathPaymentOp op) { sendAsset = Asset.fromXdr(op.getSendAsset()); sendMax = Operation.fromXdrAmount(op.getSendMax().getInt64().longValue()); - destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID()); + destination = StrKey.encodeStellarAccountId(op.getDestination().getAccountID().getEd25519().getUint256()); destAsset = Asset.fromXdr(op.getDestAsset()); destAmount = Operation.fromXdrAmount(op.getDestAmount().getInt64().longValue()); path = new Asset[op.getPath().length]; @@ -150,7 +147,7 @@ public static class Builder { * @param destAmount The amount of destination asset the destination account receives. * @throws ArithmeticException when sendMax or destAmount has more than 7 decimal places. */ - public Builder(Asset sendAsset, String sendMax, KeyPair destination, + public Builder(Asset sendAsset, String sendMax, String destination, Asset destAsset, String destAmount) { this.sendAsset = checkNotNull(sendAsset, "sendAsset cannot be null"); this.sendMax = checkNotNull(sendMax, "sendMax cannot be null"); @@ -176,7 +173,7 @@ public Builder setPath(Asset[] path) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null"); return this; } diff --git a/src/main/java/org/stellar/sdk/PaymentOperation.java b/src/main/java/org/stellar/sdk/PaymentOperation.java index d35061ffd..d8256b300 100644 --- a/src/main/java/org/stellar/sdk/PaymentOperation.java +++ b/src/main/java/org/stellar/sdk/PaymentOperation.java @@ -15,11 +15,11 @@ */ public class PaymentOperation extends Operation { - private final KeyPair destination; + private final String destination; private final Asset asset; private final String amount; - private PaymentOperation(KeyPair destination, Asset asset, String amount) { + private PaymentOperation(String destination, Asset asset, String amount) { this.destination = checkNotNull(destination, "destination cannot be null"); this.asset = checkNotNull(asset, "asset cannot be null"); this.amount = checkNotNull(amount, "amount cannot be null"); @@ -28,7 +28,7 @@ private PaymentOperation(KeyPair destination, Asset asset, String amount) { /** * Account that receives the payment. */ - public KeyPair getDestination() { + public String getDestination() { return destination; } @@ -51,9 +51,7 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { PaymentOp op = new PaymentOp(); // destination - AccountID destination = new AccountID(); - destination.setAccountID(this.destination.getXdrPublicKey()); - op.setDestination(destination); + op.setDestination(StrKey.encodeToXDRAccountId(this.destination)); // asset op.setAsset(asset.toXdr()); // amount @@ -72,30 +70,30 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { * @see PathPaymentOperation */ public static class Builder { - private final KeyPair destination; + private final String destination; private final Asset asset; private final String amount; - private KeyPair mSourceAccount; + private String mSourceAccount; /** * Construct a new PaymentOperation builder from a PaymentOp XDR. * @param op {@link PaymentOp} */ Builder(PaymentOp op) { - destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID()); + destination = StrKey.encodeStellarAccountId(op.getDestination().getAccountID().getEd25519().getUint256()); asset = Asset.fromXdr(op.getAsset()); amount = Operation.fromXdrAmount(op.getAmount().getInt64().longValue()); } /** * Creates a new PaymentOperation builder. - * @param destination The destination keypair (uses only the public key). + * @param destination The destination account id * @param asset The asset to send. * @param amount The amount to send in lumens. * @throws ArithmeticException when amount has more than 7 decimal places. */ - public Builder(KeyPair destination, Asset asset, String amount) { + public Builder(String destination, Asset asset, String amount) { this.destination = destination; this.asset = asset; this.amount = amount; @@ -106,7 +104,7 @@ public Builder(KeyPair destination, Asset asset, String amount) { * @param account The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair account) { + public Builder setSourceAccount(String account) { mSourceAccount = account; return this; } diff --git a/src/main/java/org/stellar/sdk/SetOptionsOperation.java b/src/main/java/org/stellar/sdk/SetOptionsOperation.java index b0346473c..ba2574305 100644 --- a/src/main/java/org/stellar/sdk/SetOptionsOperation.java +++ b/src/main/java/org/stellar/sdk/SetOptionsOperation.java @@ -12,7 +12,7 @@ */ public class SetOptionsOperation extends Operation { - private final KeyPair inflationDestination; + private final String inflationDestination; private final Integer clearFlags; private final Integer setFlags; private final Integer masterKeyWeight; @@ -23,7 +23,7 @@ public class SetOptionsOperation extends Operation { private final SignerKey signer; private final Integer signerWeight; - private SetOptionsOperation(KeyPair inflationDestination, Integer clearFlags, Integer setFlags, + private SetOptionsOperation(String inflationDestination, Integer clearFlags, Integer setFlags, Integer masterKeyWeight, Integer lowThreshold, Integer mediumThreshold, Integer highThreshold, String homeDomain, SignerKey signer, Integer signerWeight) { this.inflationDestination = inflationDestination; @@ -41,7 +41,7 @@ private SetOptionsOperation(KeyPair inflationDestination, Integer clearFlags, In /** * Account of the inflation destination. */ - public KeyPair getInflationDestination() { + public String getInflationDestination() { return inflationDestination; } @@ -114,9 +114,7 @@ public Integer getSignerWeight() { org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { SetOptionsOp op = new SetOptionsOp(); if (inflationDestination != null) { - AccountID inflationDestination = new AccountID(); - inflationDestination.setAccountID(this.inflationDestination.getXdrPublicKey()); - op.setInflationDest(inflationDestination); + op.setInflationDest(StrKey.encodeToXDRAccountId(this.inflationDestination)); } if (clearFlags != null) { Uint32 clearFlags = new Uint32(); @@ -173,7 +171,7 @@ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() { * @see SetOptionsOperation */ public static class Builder { - private KeyPair inflationDestination; + private String inflationDestination; private Integer clearFlags; private Integer setFlags; private Integer masterKeyWeight; @@ -183,12 +181,11 @@ public static class Builder { private String homeDomain; private SignerKey signer; private Integer signerWeight; - private KeyPair sourceAccount; + private String sourceAccount; Builder(SetOptionsOp op) { if (op.getInflationDest() != null) { - inflationDestination = KeyPair.fromXdrPublicKey( - op.getInflationDest().getAccountID()); + inflationDestination = StrKey.encodeStellarAccountId(op.getInflationDest().getAccountID().getEd25519().getUint256()); } if (op.getClearFlags() != null) { clearFlags = op.getClearFlags().getUint32(); @@ -227,7 +224,7 @@ public Builder() {} * @param inflationDestination The inflation destination account. * @return Builder object so you can chain methods. */ - public Builder setInflationDestination(KeyPair inflationDestination) { + public Builder setInflationDestination(String inflationDestination) { this.inflationDestination = inflationDestination; return this; } @@ -324,7 +321,7 @@ public Builder setSigner(SignerKey signer, Integer weight) { * @param sourceAccount The operation's source account. * @return Builder object so you can chain methods. */ - public Builder setSourceAccount(KeyPair sourceAccount) { + public Builder setSourceAccount(String sourceAccount) { this.sourceAccount = sourceAccount; return this; } diff --git a/src/main/java/org/stellar/sdk/StrKey.java b/src/main/java/org/stellar/sdk/StrKey.java index 7b2f258f1..a4728e3ee 100644 --- a/src/main/java/org/stellar/sdk/StrKey.java +++ b/src/main/java/org/stellar/sdk/StrKey.java @@ -1,6 +1,10 @@ package org.stellar.sdk; import com.google.common.io.BaseEncoding; +import org.stellar.sdk.xdr.AccountID; +import org.stellar.sdk.xdr.PublicKey; +import org.stellar.sdk.xdr.PublicKeyType; +import org.stellar.sdk.xdr.Uint256; import java.io.*; import java.util.Arrays; @@ -27,6 +31,17 @@ public static String encodeStellarAccountId(byte[] data) { return String.valueOf(encoded); } + public static AccountID encodeToXDRAccountId(String data) { + AccountID accountID = new AccountID(); + PublicKey publicKey = new PublicKey(); + publicKey.setDiscriminant(PublicKeyType.PUBLIC_KEY_TYPE_ED25519); + Uint256 uint256 = new Uint256(); + uint256.setUint256(decodeStellarAccountId(data)); + publicKey.setEd25519(uint256); + accountID.setAccountID(publicKey); + return accountID; + } + public static byte[] decodeStellarAccountId(String data) { return decodeCheck(VersionByte.ACCOUNT_ID, data.toCharArray()); } diff --git a/src/main/java/org/stellar/sdk/Transaction.java b/src/main/java/org/stellar/sdk/Transaction.java index d70a2a39f..c653879ff 100644 --- a/src/main/java/org/stellar/sdk/Transaction.java +++ b/src/main/java/org/stellar/sdk/Transaction.java @@ -21,7 +21,7 @@ */ public class Transaction { private final int mFee; - private final KeyPair mSourceAccount; + private final String mSourceAccount; private final long mSequenceNumber; private final Operation[] mOperations; private final Memo mMemo; @@ -30,7 +30,7 @@ public class Transaction { private List mSignatures; Transaction( - KeyPair sourceAccount, + String sourceAccount, int fee, long sequenceNumber, Operation[] operations, @@ -114,7 +114,7 @@ public Network getNetwork() { return mNetwork; } - public KeyPair getSourceAccount() { + public String getSourceAccount() { return mSourceAccount; } @@ -163,9 +163,6 @@ public org.stellar.sdk.xdr.Transaction toXdr() { sequenceNumberUint.setInt64(mSequenceNumber); org.stellar.sdk.xdr.SequenceNumber sequenceNumber = new org.stellar.sdk.xdr.SequenceNumber(); sequenceNumber.setSequenceNumber(sequenceNumberUint); - // sourceAccount - org.stellar.sdk.xdr.AccountID sourceAccount = new org.stellar.sdk.xdr.AccountID(); - sourceAccount.setAccountID(mSourceAccount.getXdrPublicKey()); // operations org.stellar.sdk.xdr.Operation[] operations = new org.stellar.sdk.xdr.Operation[mOperations.length]; for (int i = 0; i < mOperations.length; i++) { @@ -178,7 +175,7 @@ public org.stellar.sdk.xdr.Transaction toXdr() { org.stellar.sdk.xdr.Transaction transaction = new org.stellar.sdk.xdr.Transaction(); transaction.setFee(fee); transaction.setSeqNum(sequenceNumber); - transaction.setSourceAccount(sourceAccount); + transaction.setSourceAccount(StrKey.encodeToXDRAccountId(this.mSourceAccount)); transaction.setOperations(operations); transaction.setMemo(mMemo.toXdr()); transaction.setTimeBounds(mTimeBounds == null ? null : mTimeBounds.toXdr()); @@ -208,7 +205,6 @@ public static Transaction fromEnvelopeXdr(String envelope, Network network) thro public static Transaction fromEnvelopeXdr(TransactionEnvelope envelope, Network network) { org.stellar.sdk.xdr.Transaction tx = envelope.getTx(); int mFee = tx.getFee().getUint32(); - KeyPair mSourceAccount = KeyPair.fromXdrPublicKey(tx.getSourceAccount().getAccountID()); Long mSequenceNumber = tx.getSeqNum().getSequenceNumber().getInt64(); Memo mMemo = Memo.fromXdr(tx.getMemo()); TimeBounds mTimeBounds = TimeBounds.fromXdr(tx.getTimeBounds()); @@ -219,7 +215,7 @@ public static Transaction fromEnvelopeXdr(TransactionEnvelope envelope, Network } Transaction transaction = new Transaction( - mSourceAccount, + StrKey.encodeStellarAccountId(tx.getSourceAccount().getAccountID().getEd25519().getUint256()), mFee, mSequenceNumber, mOperations, @@ -418,7 +414,7 @@ public Transaction build() { Operation[] operations = new Operation[mOperations.size()]; operations = mOperations.toArray(operations); Transaction transaction = new Transaction( - mSourceAccount.getKeypair(), + mSourceAccount.getAccountId(), operations.length * operationFee, mSourceAccount.getIncrementedSequenceNumber(), operations, diff --git a/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java b/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java index e514b9aa3..86a2308ea 100644 --- a/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java +++ b/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java @@ -4,10 +4,15 @@ * Specifies interface for Account object used in {@link org.stellar.sdk.Transaction.Builder} */ public interface TransactionBuilderAccount { + /** + * Returns ID associated with this Account + */ + String getAccountId(); + /** * Returns keypair associated with this Account */ - KeyPair getKeypair(); + KeyPair getKeyPair(); /** * Returns current sequence number ot this Account. diff --git a/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java index 9718f9ea8..bca3e9507 100644 --- a/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java @@ -5,7 +5,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.AccountResponse; import org.stellar.sdk.responses.Page; @@ -40,8 +39,8 @@ public AccountResponse account(HttpUrl uri) throws IOException { * @param account Account to fetch * @throws IOException */ - public AccountResponse account(KeyPair account) throws IOException { - this.setSegments("accounts", account.getAccountId()); + public AccountResponse account(String account) throws IOException { + this.setSegments("accounts", account); return this.account(this.buildUri()); } diff --git a/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java index 4d617f3c6..5d9450a72 100644 --- a/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java @@ -5,7 +5,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Page; import org.stellar.sdk.responses.effects.EffectResponse; @@ -26,9 +25,9 @@ public EffectsRequestBuilder(OkHttpClient httpClient, HttpUrl serverURI) { * @see Effects for Account * @param account Account for which to get effects */ - public EffectsRequestBuilder forAccount(KeyPair account) { + public EffectsRequestBuilder forAccount(String account) { account = checkNotNull(account, "account cannot be null"); - this.setSegments("accounts", account.getAccountId(), "effects"); + this.setSegments("accounts", account, "effects"); return this; } diff --git a/src/main/java/org/stellar/sdk/requests/OffersRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/OffersRequestBuilder.java index 0110989a1..d7dcd6af6 100644 --- a/src/main/java/org/stellar/sdk/requests/OffersRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/OffersRequestBuilder.java @@ -5,7 +5,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.OfferResponse; import org.stellar.sdk.responses.Page; @@ -26,9 +25,9 @@ public OffersRequestBuilder(OkHttpClient httpClient, HttpUrl serverURI) { * @see Offers for Account * @param account Account for which to get offers */ - public OffersRequestBuilder forAccount(KeyPair account) { + public OffersRequestBuilder forAccount(String account) { account = checkNotNull(account, "account cannot be null"); - this.setSegments("accounts", account.getAccountId(), "offers"); + this.setSegments("accounts", account, "offers"); return this; } diff --git a/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java index bf7f1993e..9fe9534cf 100644 --- a/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java @@ -5,7 +5,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Page; import org.stellar.sdk.responses.operations.OperationResponse; @@ -52,9 +51,9 @@ public OperationResponse operation(long operationId) throws IOException { * @see Operations for Account * @param account Account for which to get operations */ - public OperationsRequestBuilder forAccount(KeyPair account) { + public OperationsRequestBuilder forAccount(String account) { account = checkNotNull(account, "account cannot be null"); - this.setSegments("accounts", account.getAccountId(), "operations"); + this.setSegments("accounts", account, "operations"); return this; } diff --git a/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java index 52d49c5c7..fc940350a 100644 --- a/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java @@ -24,7 +24,7 @@ public OrderBookRequestBuilder buyingAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("buying_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("buying_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("buying_asset_issuer", creditAlphaNumAsset.getIssuer()); } return this; } @@ -34,7 +34,7 @@ public OrderBookRequestBuilder sellingAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("selling_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("selling_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("selling_asset_issuer", creditAlphaNumAsset.getIssuer()); } return this; } diff --git a/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java index c5927b36d..1cd5001d5 100644 --- a/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java @@ -8,7 +8,6 @@ import okhttp3.Response; import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeCreditAlphaNum; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Page; import org.stellar.sdk.responses.PathResponse; @@ -22,13 +21,13 @@ public PathsRequestBuilder(OkHttpClient httpClient, HttpUrl serverURI) { super(httpClient, serverURI, "paths"); } - public PathsRequestBuilder destinationAccount(KeyPair account) { - uriBuilder.setQueryParameter("destination_account", account.getAccountId()); + public PathsRequestBuilder destinationAccount(String account) { + uriBuilder.setQueryParameter("destination_account", account); return this; } - public PathsRequestBuilder sourceAccount(KeyPair account) { - uriBuilder.setQueryParameter("source_account", account.getAccountId()); + public PathsRequestBuilder sourceAccount(String account) { + uriBuilder.setQueryParameter("source_account", account); return this; } @@ -42,7 +41,7 @@ public PathsRequestBuilder destinationAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("destination_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("destination_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("destination_asset_issuer", creditAlphaNumAsset.getIssuer()); } return this; } diff --git a/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java index efe7ca7a9..396faeb56 100644 --- a/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java @@ -5,7 +5,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Page; import org.stellar.sdk.responses.operations.OperationResponse; @@ -26,9 +25,9 @@ public PaymentsRequestBuilder(OkHttpClient httpClient, HttpUrl serverURI) { * @see Payments for Account * @param account Account for which to get payments */ - public PaymentsRequestBuilder forAccount(KeyPair account) { + public PaymentsRequestBuilder forAccount(String account) { account = checkNotNull(account, "account cannot be null"); - this.setSegments("accounts", account.getAccountId(), "payments"); + this.setSegments("accounts", account, "payments"); return this; } diff --git a/src/main/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilder.java index 58d5258fb..ebe075074 100644 --- a/src/main/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilder.java @@ -32,7 +32,7 @@ private void baseAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("base_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("base_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("base_asset_issuer", creditAlphaNumAsset.getIssuer()); } } @@ -41,7 +41,7 @@ private void counterAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("counter_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("counter_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("counter_asset_issuer", creditAlphaNumAsset.getIssuer()); } } diff --git a/src/main/java/org/stellar/sdk/requests/TradesRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/TradesRequestBuilder.java index 53fbea5ad..f220b439c 100644 --- a/src/main/java/org/stellar/sdk/requests/TradesRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/TradesRequestBuilder.java @@ -8,7 +8,6 @@ import okhttp3.Response; import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeCreditAlphaNum; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Page; import org.stellar.sdk.responses.TradeResponse; @@ -27,7 +26,7 @@ public TradesRequestBuilder baseAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("base_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("base_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("base_asset_issuer", creditAlphaNumAsset.getIssuer()); } return this; } @@ -37,7 +36,7 @@ public TradesRequestBuilder counterAsset(Asset asset) { if (asset instanceof AssetTypeCreditAlphaNum) { AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset; uriBuilder.setQueryParameter("counter_asset_code", creditAlphaNumAsset.getCode()); - uriBuilder.setQueryParameter("counter_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId()); + uriBuilder.setQueryParameter("counter_asset_issuer", creditAlphaNumAsset.getIssuer()); } return this; } @@ -47,9 +46,9 @@ public TradesRequestBuilder counterAsset(Asset asset) { * @see Trades for Account * @param account Account for which to get trades */ - public TradesRequestBuilder forAccount(KeyPair account) { + public TradesRequestBuilder forAccount(String account) { account = checkNotNull(account, "account cannot be null"); - this.setSegments("accounts", account.getAccountId(), "trades"); + this.setSegments("accounts", account, "trades"); return this; } diff --git a/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java index 704a6f039..10d9613c3 100644 --- a/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java +++ b/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java @@ -5,7 +5,6 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Page; import org.stellar.sdk.responses.TransactionResponse; @@ -52,9 +51,9 @@ public TransactionResponse transaction(String transactionId) throws IOException * @see Transactions for Account * @param account Account for which to get transactions */ - public TransactionsRequestBuilder forAccount(KeyPair account) { + public TransactionsRequestBuilder forAccount(String account) { account = checkNotNull(account, "account cannot be null"); - this.setSegments("accounts", account.getAccountId(), "transactions"); + this.setSegments("accounts", account, "transactions"); return this; } diff --git a/src/main/java/org/stellar/sdk/responses/AccountResponse.java b/src/main/java/org/stellar/sdk/responses/AccountResponse.java index dafe27f6e..6535ad869 100644 --- a/src/main/java/org/stellar/sdk/responses/AccountResponse.java +++ b/src/main/java/org/stellar/sdk/responses/AccountResponse.java @@ -18,8 +18,8 @@ * @see org.stellar.sdk.Server#accounts() */ public class AccountResponse extends Response implements org.stellar.sdk.TransactionBuilderAccount { - @SerializedName("account_id") /* KeyPairTypeAdapter used */ - private KeyPair keypair; + @SerializedName("account_id") + private String accountId; @SerializedName("sequence") private Long sequenceNumber; @SerializedName("subentry_count") @@ -43,18 +43,23 @@ public class AccountResponse extends Response implements org.stellar.sdk.Transac @SerializedName("_links") private Links links; - AccountResponse(KeyPair keypair) { - this.keypair = keypair; + AccountResponse(String accountId) { + this.accountId = accountId; } - public AccountResponse(KeyPair keypair, Long sequenceNumber) { - this.keypair = keypair; + public AccountResponse(String accountId, Long sequenceNumber) { + this.accountId = accountId; this.sequenceNumber = sequenceNumber; } @Override - public KeyPair getKeypair() { - return keypair; + public String getAccountId() { + return accountId; + } + + @Override + public KeyPair getKeyPair() { + return KeyPair.fromAccountId(accountId); } @Override @@ -219,8 +224,8 @@ public String getAssetCode() { return assetCode; } - public KeyPair getAssetIssuer() { - return KeyPair.fromAccountId(assetIssuer); + public String getAssetIssuer() { + return assetIssuer; } public String getBalance() { diff --git a/src/main/java/org/stellar/sdk/responses/AssetDeserializer.java b/src/main/java/org/stellar/sdk/responses/AssetDeserializer.java index a811a72fb..6cfc79cc7 100644 --- a/src/main/java/org/stellar/sdk/responses/AssetDeserializer.java +++ b/src/main/java/org/stellar/sdk/responses/AssetDeserializer.java @@ -7,7 +7,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; import java.lang.reflect.Type; @@ -20,7 +19,7 @@ public Asset deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont } else { String code = json.getAsJsonObject().get("asset_code").getAsString(); String issuer = json.getAsJsonObject().get("asset_issuer").getAsString(); - return Asset.createNonNativeAsset(code, KeyPair.fromAccountId(issuer)); + return Asset.createNonNativeAsset(code, issuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java b/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java index 0826d866f..6d67550db 100644 --- a/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java +++ b/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java @@ -7,7 +7,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.effects.*; import java.lang.reflect.Type; @@ -17,7 +16,6 @@ class EffectDeserializer implements JsonDeserializer { public EffectResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { // Create new Gson object with adapters needed in Operation Gson gson = new GsonBuilder() - .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe()) .create(); int type = json.getAsJsonObject().get("type_i").getAsInt(); diff --git a/src/main/java/org/stellar/sdk/responses/GsonSingleton.java b/src/main/java/org/stellar/sdk/responses/GsonSingleton.java index 49c9ab646..f4fb835f2 100644 --- a/src/main/java/org/stellar/sdk/responses/GsonSingleton.java +++ b/src/main/java/org/stellar/sdk/responses/GsonSingleton.java @@ -5,7 +5,6 @@ import com.google.gson.reflect.TypeToken; import org.stellar.sdk.Asset; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.effects.EffectResponse; import org.stellar.sdk.responses.operations.OperationResponse; @@ -29,7 +28,6 @@ public static Gson getInstance() { instance = new GsonBuilder() .registerTypeAdapter(Asset.class, new AssetDeserializer()) - .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe()) .registerTypeAdapter(OperationResponse.class, new OperationDeserializer()) .registerTypeAdapter(EffectResponse.class, new EffectDeserializer()) .registerTypeAdapter(TransactionResponse.class, new TransactionDeserializer()) diff --git a/src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java b/src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java deleted file mode 100644 index 4d25162a9..000000000 --- a/src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.stellar.sdk.responses; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import org.stellar.sdk.KeyPair; - -import java.io.IOException; - -class KeyPairTypeAdapter extends TypeAdapter { - @Override - public void write(JsonWriter out, KeyPair value) throws IOException { - // Don't need this. - } - - @Override - public KeyPair read(JsonReader in) throws IOException { - return KeyPair.fromAccountId(in.nextString()); - } -} diff --git a/src/main/java/org/stellar/sdk/responses/OfferResponse.java b/src/main/java/org/stellar/sdk/responses/OfferResponse.java index 08931e2a5..2a6ad200e 100644 --- a/src/main/java/org/stellar/sdk/responses/OfferResponse.java +++ b/src/main/java/org/stellar/sdk/responses/OfferResponse.java @@ -3,7 +3,6 @@ import com.google.gson.annotations.SerializedName; import org.stellar.sdk.Asset; -import org.stellar.sdk.KeyPair; /** * Represents offer response. @@ -17,7 +16,7 @@ public class OfferResponse extends Response implements Pageable { @SerializedName("paging_token") private final String pagingToken; @SerializedName("seller") - private final KeyPair seller; + private final String seller; @SerializedName("selling") private final Asset selling; @SerializedName("buying") @@ -33,7 +32,7 @@ public class OfferResponse extends Response implements Pageable { @SerializedName("_links") private final Links links; - public OfferResponse(Long id, String pagingToken, KeyPair seller, Asset selling, Asset buying, String amount, String price, Integer lastModifiedLedger, String lastModifiedTime, Links links) { + public OfferResponse(Long id, String pagingToken, String seller, Asset selling, Asset buying, String amount, String price, Integer lastModifiedLedger, String lastModifiedTime, Links links) { this.id = id; this.pagingToken = pagingToken; this.seller = seller; @@ -54,7 +53,7 @@ public String getPagingToken() { return pagingToken; } - public KeyPair getSeller() { + public String getSeller() { return seller; } diff --git a/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java b/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java index 7172014c0..e7b9c3bc4 100644 --- a/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java +++ b/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java @@ -7,7 +7,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.operations.*; import java.lang.reflect.Type; @@ -17,7 +16,6 @@ class OperationDeserializer implements JsonDeserializer { public OperationResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { // Create new Gson object with adapters needed in Operation Gson gson = new GsonBuilder() - .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe()) .create(); int type = json.getAsJsonObject().get("type_i").getAsInt(); diff --git a/src/main/java/org/stellar/sdk/responses/PageDeserializer.java b/src/main/java/org/stellar/sdk/responses/PageDeserializer.java index d51fbd19d..a2f1a4125 100644 --- a/src/main/java/org/stellar/sdk/responses/PageDeserializer.java +++ b/src/main/java/org/stellar/sdk/responses/PageDeserializer.java @@ -10,7 +10,6 @@ import com.google.gson.reflect.TypeToken; import org.stellar.sdk.Asset; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.effects.EffectResponse; import org.stellar.sdk.responses.operations.OperationResponse; @@ -40,7 +39,6 @@ public Page deserialize(JsonElement json, Type typeOfT, JsonDeserializationCo // Create new Gson object with adapters needed in Page Gson gson = new GsonBuilder() .registerTypeAdapter(Asset.class, new AssetDeserializer()) - .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe()) .registerTypeAdapter(OperationResponse.class, new OperationDeserializer()) .registerTypeAdapter(EffectResponse.class, new EffectDeserializer()) .registerTypeAdapter(TransactionResponse.class, new TransactionDeserializer()) diff --git a/src/main/java/org/stellar/sdk/responses/PathResponse.java b/src/main/java/org/stellar/sdk/responses/PathResponse.java index 7b6acede3..b78f3a137 100644 --- a/src/main/java/org/stellar/sdk/responses/PathResponse.java +++ b/src/main/java/org/stellar/sdk/responses/PathResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; import java.util.ArrayList; @@ -68,8 +67,7 @@ public Asset getDestinationAsset() { if (destinationAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(destinationAssetIssuer); - return Asset.createNonNativeAsset(destinationAssetCode, issuer); + return Asset.createNonNativeAsset(destinationAssetCode, destinationAssetIssuer); } } @@ -77,8 +75,7 @@ public Asset getSourceAsset() { if (sourceAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(sourceAssetIssuer); - return Asset.createNonNativeAsset(sourceAssetCode, issuer); + return Asset.createNonNativeAsset(sourceAssetCode, sourceAssetIssuer); } } diff --git a/src/main/java/org/stellar/sdk/responses/TradeResponse.java b/src/main/java/org/stellar/sdk/responses/TradeResponse.java index 42f819652..6f8ded1cd 100644 --- a/src/main/java/org/stellar/sdk/responses/TradeResponse.java +++ b/src/main/java/org/stellar/sdk/responses/TradeResponse.java @@ -2,7 +2,6 @@ import com.google.gson.annotations.SerializedName; import org.stellar.sdk.Asset; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.Price; ; @@ -27,7 +26,7 @@ public class TradeResponse extends Response implements Pageable { protected final boolean baseIsSeller; @SerializedName("base_account") - protected final KeyPair baseAccount; + protected final String baseAccount; @SerializedName("base_offer_id") private final String baseOfferId; @SerializedName("base_amount") @@ -40,7 +39,7 @@ public class TradeResponse extends Response implements Pageable { protected final String baseAssetIssuer; @SerializedName("counter_account") - protected final KeyPair counterAccount; + protected final String counterAccount; @SerializedName("counter_offer_id") private final String counterOfferId; @SerializedName("counter_amount") @@ -58,7 +57,7 @@ public class TradeResponse extends Response implements Pageable { @SerializedName("_links") private TradeResponse.Links links; - public TradeResponse(String id, String pagingToken, String ledgerCloseTime, String offerId, boolean baseIsSeller, KeyPair baseAccount, String baseOfferId, String baseAmount, String baseAssetType, String baseAssetCode, String baseAssetIssuer, KeyPair counterAccount, String counterOfferId, String counterAmount, String counterAssetType, String counterAssetCode, String counterAssetIssuer, Price price) { + public TradeResponse(String id, String pagingToken, String ledgerCloseTime, String offerId, boolean baseIsSeller, String baseAccount, String baseOfferId, String baseAmount, String baseAssetType, String baseAssetCode, String baseAssetIssuer, String counterAccount, String counterOfferId, String counterAmount, String counterAssetType, String counterAssetCode, String counterAssetIssuer, Price price) { this.id = id; this.pagingToken = pagingToken; this.ledgerCloseTime = ledgerCloseTime; @@ -103,7 +102,7 @@ public String getBaseOfferId() { return baseOfferId; } - public KeyPair getBaseAccount() { + public String getBaseAccount() { return baseAccount; } @@ -127,7 +126,7 @@ public String getBaseAssetIssuer() { return baseAssetIssuer; } - public KeyPair getCounterAccount() { + public String getCounterAccount() { return counterAccount; } diff --git a/src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java b/src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java index 9e1e6b325..098f07e65 100644 --- a/src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java +++ b/src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java @@ -8,7 +8,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.Memo; import java.lang.reflect.Type; @@ -18,7 +17,6 @@ public class TransactionDeserializer implements JsonDeserializerEffect documentation @@ -9,7 +7,7 @@ * @see org.stellar.sdk.Server#effects() */ public class TrustlineAuthorizedEffectResponse extends TrustlineAuthorizationResponse { - TrustlineAuthorizedEffectResponse(KeyPair trustor, String assetType, String assetCode) { + TrustlineAuthorizedEffectResponse(String trustor, String assetType, String assetCode) { super(trustor, assetType, assetCode); } } diff --git a/src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java index 65d2ff618..9a8e40039 100644 --- a/src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java +++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; abstract class TrustlineCUDResponse extends EffectResponse { @SerializedName("limit") @@ -31,8 +30,7 @@ public Asset getAsset() { if (assetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(assetIssuer); - return Asset.createNonNativeAsset(assetCode, issuer); + return Asset.createNonNativeAsset(assetCode, assetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java index 84cf1712c..ce78c94e3 100644 --- a/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java +++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java @@ -1,7 +1,5 @@ package org.stellar.sdk.responses.effects; -import org.stellar.sdk.KeyPair; - /** * Represents trustline_deauthorized effect response. * @see Effect documentation @@ -9,7 +7,7 @@ * @see org.stellar.sdk.Server#effects() */ public class TrustlineDeauthorizedEffectResponse extends TrustlineAuthorizationResponse { - TrustlineDeauthorizedEffectResponse(KeyPair trustor, String assetType, String assetCode) { + TrustlineDeauthorizedEffectResponse(String trustor, String assetType, String assetCode) { super(trustor, assetType, assetCode); } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java index 6856a7a98..a1f91a84d 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java @@ -2,8 +2,6 @@ import com.google.gson.annotations.SerializedName; -import org.stellar.sdk.KeyPair; - /** * Represents AccountMerge operation response. * @see Operation documentation @@ -12,20 +10,20 @@ */ public class AccountMergeOperationResponse extends OperationResponse { @SerializedName("account") - protected final KeyPair account; + protected final String account; @SerializedName("into") - protected final KeyPair into; + protected final String into; - AccountMergeOperationResponse(KeyPair account, KeyPair into) { + AccountMergeOperationResponse(String account, String into) { this.account = account; this.into = into; } - public KeyPair getAccount() { + public String getAccount() { return account; } - public KeyPair getInto() { + public String getInto() { return into; } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java index b394a6b3b..991283960 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents AllowTrust operation response. @@ -14,9 +13,9 @@ */ public class AllowTrustOperationResponse extends OperationResponse { @SerializedName("trustor") - protected final KeyPair trustor; + protected final String trustor; @SerializedName("trustee") - protected final KeyPair trustee; + protected final String trustee; @SerializedName("asset_type") protected final String assetType; @SerializedName("asset_code") @@ -26,7 +25,7 @@ public class AllowTrustOperationResponse extends OperationResponse { @SerializedName("authorize") protected final boolean authorize; - AllowTrustOperationResponse(boolean authorize, String assetIssuer, String assetCode, String assetType, KeyPair trustee, KeyPair trustor) { + AllowTrustOperationResponse(boolean authorize, String assetIssuer, String assetCode, String assetType, String trustee, String trustor) { this.authorize = authorize; this.assetIssuer = assetIssuer; this.assetCode = assetCode; @@ -35,11 +34,11 @@ public class AllowTrustOperationResponse extends OperationResponse { this.trustor = trustor; } - public KeyPair getTrustor() { + public String getTrustor() { return trustor; } - public KeyPair getTrustee() { + public String getTrustee() { return trustee; } @@ -51,8 +50,7 @@ public Asset getAsset() { if (assetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(assetIssuer); - return Asset.createNonNativeAsset(assetCode, issuer); + return Asset.createNonNativeAsset(assetCode, assetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java index 33e167eb3..c9b27ceb8 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents ChangeTrust operation response. @@ -14,9 +13,9 @@ */ public class ChangeTrustOperationResponse extends OperationResponse { @SerializedName("trustor") - protected final KeyPair trustor; + protected final String trustor; @SerializedName("trustee") - protected final KeyPair trustee; + protected final String trustee; @SerializedName("asset_type") protected final String assetType; @SerializedName("asset_code") @@ -26,7 +25,7 @@ public class ChangeTrustOperationResponse extends OperationResponse { @SerializedName("limit") protected final String limit; - ChangeTrustOperationResponse(KeyPair trustor, KeyPair trustee, String assetType, String assetCode, String assetIssuer, String limit) { + ChangeTrustOperationResponse(String trustor, String trustee, String assetType, String assetCode, String assetIssuer, String limit) { this.trustor = trustor; this.trustee = trustee; this.assetType = assetType; @@ -35,11 +34,11 @@ public class ChangeTrustOperationResponse extends OperationResponse { this.limit = limit; } - public KeyPair getTrustor() { + public String getTrustor() { return trustor; } - public KeyPair getTrustee() { + public String getTrustee() { return trustee; } @@ -51,8 +50,7 @@ public Asset getAsset() { if (assetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(assetIssuer); - return Asset.createNonNativeAsset(assetCode, issuer); + return Asset.createNonNativeAsset(assetCode, assetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java index c7764b04a..67194e638 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java @@ -2,8 +2,6 @@ import com.google.gson.annotations.SerializedName; -import org.stellar.sdk.KeyPair; - /** * Represents CreateAccount operation response. * @see Operation documentation @@ -12,19 +10,19 @@ */ public class CreateAccountOperationResponse extends OperationResponse { @SerializedName("account") - protected final KeyPair account; + protected final String account; @SerializedName("funder") - protected final KeyPair funder; + protected final String funder; @SerializedName("starting_balance") protected final String startingBalance; - CreateAccountOperationResponse(KeyPair funder, String startingBalance, KeyPair account) { + CreateAccountOperationResponse(String funder, String startingBalance, String account) { this.funder = funder; this.startingBalance = startingBalance; this.account = account; } - public KeyPair getAccount() { + public String getAccount() { return account; } @@ -32,7 +30,7 @@ public String getStartingBalance() { return startingBalance; } - public KeyPair getFunder() { + public String getFunder() { return funder; } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/CreatePassiveSellOfferOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/CreatePassiveSellOfferOperationResponse.java index c0369efa7..673a6eaf1 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/CreatePassiveSellOfferOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/CreatePassiveSellOfferOperationResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents CreatePassiveSellOffer operation response. @@ -64,8 +63,7 @@ public Asset getBuyingAsset() { if (buyingAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(buyingAssetIssuer); - return Asset.createNonNativeAsset(buyingAssetCode, issuer); + return Asset.createNonNativeAsset(buyingAssetCode, buyingAssetIssuer); } } @@ -73,8 +71,7 @@ public Asset getSellingAsset() { if (sellingAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(sellingAssetIssuer); - return Asset.createNonNativeAsset(sellingAssetCode, issuer); + return Asset.createNonNativeAsset(sellingAssetCode, sellingAssetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/ManageBuyOfferOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/ManageBuyOfferOperationResponse.java index 490f0270a..186cf3f0a 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/ManageBuyOfferOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/ManageBuyOfferOperationResponse.java @@ -3,7 +3,6 @@ import com.google.gson.annotations.SerializedName; import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents ManageBuyOffer operation response. @@ -63,8 +62,7 @@ public Asset getBuyingAsset() { if (buyingAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(buyingAssetIssuer); - return Asset.createNonNativeAsset(buyingAssetCode, issuer); + return Asset.createNonNativeAsset(buyingAssetCode, buyingAssetIssuer); } } @@ -72,8 +70,7 @@ public Asset getSellingAsset() { if (sellingAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(sellingAssetIssuer); - return Asset.createNonNativeAsset(sellingAssetCode, issuer); + return Asset.createNonNativeAsset(sellingAssetCode, sellingAssetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/ManageSellOfferOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/ManageSellOfferOperationResponse.java index ce34ace06..0d5d7b90c 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/ManageSellOfferOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/ManageSellOfferOperationResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents ManageSellOffer operation response. @@ -64,8 +63,7 @@ public Asset getBuyingAsset() { if (buyingAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(buyingAssetIssuer); - return Asset.createNonNativeAsset(buyingAssetCode, issuer); + return Asset.createNonNativeAsset(buyingAssetCode, buyingAssetIssuer); } } @@ -73,8 +71,7 @@ public Asset getSellingAsset() { if (sellingAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(sellingAssetIssuer); - return Asset.createNonNativeAsset(sellingAssetCode, issuer); + return Asset.createNonNativeAsset(sellingAssetCode, sellingAssetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java index c1d34124e..9e51fac33 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java @@ -2,7 +2,6 @@ import com.google.gson.annotations.SerializedName; -import org.stellar.sdk.KeyPair; import org.stellar.sdk.responses.Link; import org.stellar.sdk.responses.Pageable; import org.stellar.sdk.responses.Response; @@ -17,7 +16,7 @@ public abstract class OperationResponse extends Response implements Pageable { @SerializedName("id") protected Long id; @SerializedName("source_account") - protected KeyPair sourceAccount; + protected String sourceAccount; @SerializedName("paging_token") protected String pagingToken; @SerializedName("created_at") @@ -35,7 +34,7 @@ public Long getId() { return id; } - public KeyPair getSourceAccount() { + public String getSourceAccount() { return sourceAccount; } diff --git a/src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java index a425471ab..1509cd126 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents PathPayment operation response. @@ -20,9 +19,9 @@ public class PathPaymentOperationResponse extends OperationResponse { @SerializedName("source_max") protected final String sourceMax; @SerializedName("from") - protected final KeyPair from; + protected final String from; @SerializedName("to") - protected final KeyPair to; + protected final String to; @SerializedName("asset_type") protected final String assetType; @@ -38,7 +37,7 @@ public class PathPaymentOperationResponse extends OperationResponse { @SerializedName("source_asset_issuer") protected final String sourceAssetIssuer; - public PathPaymentOperationResponse(String amount, String sourceAmount, String sourceMax, KeyPair from, KeyPair to, String assetType, String assetCode, String assetIssuer, String sourceAssetType, String sourceAssetCode, String sourceAssetIssuer) { + public PathPaymentOperationResponse(String amount, String sourceAmount, String sourceMax, String from, String to, String assetType, String assetCode, String assetIssuer, String sourceAssetType, String sourceAssetCode, String sourceAssetIssuer) { this.amount = amount; this.sourceAmount = sourceAmount; this.sourceMax = sourceMax; @@ -64,11 +63,11 @@ public String getSourceMax() { return sourceMax; } - public KeyPair getFrom() { + public String getFrom() { return from; } - public KeyPair getTo() { + public String getTo() { return to; } @@ -76,8 +75,7 @@ public Asset getAsset() { if (assetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(assetIssuer); - return Asset.createNonNativeAsset(assetCode, issuer); + return Asset.createNonNativeAsset(assetCode, assetIssuer); } } @@ -85,8 +83,7 @@ public Asset getSourceAsset() { if (sourceAssetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(sourceAssetIssuer); - return Asset.createNonNativeAsset(sourceAssetCode, issuer); + return Asset.createNonNativeAsset(sourceAssetCode, sourceAssetIssuer); } } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java index 623d5257e..925409aed 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java @@ -4,7 +4,6 @@ import org.stellar.sdk.Asset; import org.stellar.sdk.AssetTypeNative; -import org.stellar.sdk.KeyPair; /** * Represents Payment operation response. @@ -22,11 +21,11 @@ public class PaymentOperationResponse extends OperationResponse { @SerializedName("asset_issuer") protected final String assetIssuer; @SerializedName("from") - protected final KeyPair from; + protected final String from; @SerializedName("to") - protected final KeyPair to; + protected final String to; - PaymentOperationResponse(String amount, String assetType, String assetCode, String assetIssuer, KeyPair from, KeyPair to) { + PaymentOperationResponse(String amount, String assetType, String assetCode, String assetIssuer, String from, String to) { this.amount = amount; this.assetType = assetType; this.assetCode = assetCode; @@ -43,16 +42,15 @@ public Asset getAsset() { if (assetType.equals("native")) { return new AssetTypeNative(); } else { - KeyPair issuer = KeyPair.fromAccountId(assetIssuer); - return Asset.createNonNativeAsset(assetCode, issuer); + return Asset.createNonNativeAsset(assetCode, assetIssuer); } } - public KeyPair getFrom() { + public String getFrom() { return from; } - public KeyPair getTo() { + public String getTo() { return to; } } diff --git a/src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java index b995739e9..61ce14f30 100644 --- a/src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java +++ b/src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java @@ -1,7 +1,6 @@ package org.stellar.sdk.responses.operations; import com.google.gson.annotations.SerializedName; - import org.stellar.sdk.KeyPair; /** @@ -18,7 +17,7 @@ public class SetOptionsOperationResponse extends OperationResponse { @SerializedName("high_threshold") protected final Integer highThreshold; @SerializedName("inflation_dest") - protected final KeyPair inflationDestination; + protected final String inflationDestination; @SerializedName("home_domain") protected final String homeDomain; @SerializedName("signer_key") @@ -32,7 +31,7 @@ public class SetOptionsOperationResponse extends OperationResponse { @SerializedName("set_flags_s") protected final String[] setFlags; - SetOptionsOperationResponse(Integer lowThreshold, Integer medThreshold, Integer highThreshold, KeyPair inflationDestination, String homeDomain, String signerKey, Integer signerWeight, Integer masterKeyWeight, String[] clearFlags, String[] setFlags) { + SetOptionsOperationResponse(Integer lowThreshold, Integer medThreshold, Integer highThreshold, String inflationDestination, String homeDomain, String signerKey, Integer signerWeight, Integer masterKeyWeight, String[] clearFlags, String[] setFlags) { this.lowThreshold = lowThreshold; this.medThreshold = medThreshold; this.highThreshold = highThreshold; @@ -57,7 +56,7 @@ public Integer getHighThreshold() { return highThreshold; } - public KeyPair getInflationDestination() { + public String getInflationDestination() { return inflationDestination; } diff --git a/src/test/java/org/stellar/sdk/AccountTest.java b/src/test/java/org/stellar/sdk/AccountTest.java index 6c10d6377..2e58d3af9 100644 --- a/src/test/java/org/stellar/sdk/AccountTest.java +++ b/src/test/java/org/stellar/sdk/AccountTest.java @@ -14,14 +14,16 @@ public void testNullArguments() { } catch (NullPointerException e) {} try { - new Account(KeyPair.random(), null); + KeyPair random = KeyPair.random(); + new Account(random.getAccountId(), null); fail(); } catch (NullPointerException e) {} } @Test public void testGetIncrementedSequenceNumber() { - Account account = new Account(KeyPair.random(), 100L); + KeyPair random = KeyPair.random(); + Account account = new Account(random.getAccountId(), 100L); Long incremented; incremented = account.getIncrementedSequenceNumber(); assertEquals(new Long(100L), account.getSequenceNumber()); @@ -33,7 +35,8 @@ public void testGetIncrementedSequenceNumber() { @Test public void testIncrementSequenceNumber() { - Account account = new Account(KeyPair.random(), 100L); + KeyPair random = KeyPair.random(); + Account account = new Account(random.getAccountId(), 100L); account.incrementSequenceNumber(); assertEquals(account.getSequenceNumber(), new Long(101L)); } @@ -41,8 +44,9 @@ public void testIncrementSequenceNumber() { @Test public void testGetters() { KeyPair keypair = KeyPair.random(); - Account account = new Account(keypair, 100L); - assertEquals(account.getKeypair().getAccountId(), keypair.getAccountId()); + Account account = new Account(keypair.getAccountId(), 100L); + assertEquals(account.getKeyPair().getAccountId(), keypair.getAccountId()); + assertEquals(account.getAccountId(), keypair.getAccountId()); assertEquals(account.getSequenceNumber(), new Long(100L)); } } \ No newline at end of file diff --git a/src/test/java/org/stellar/sdk/AssetTest.java b/src/test/java/org/stellar/sdk/AssetTest.java index 7e01c3258..ceddf3e22 100644 --- a/src/test/java/org/stellar/sdk/AssetTest.java +++ b/src/test/java/org/stellar/sdk/AssetTest.java @@ -24,28 +24,28 @@ public void testAssetTypeNative() { public void testAssetTypeCreditAlphaNum4() { String code = "USDA"; KeyPair issuer = KeyPair.random(); - AssetTypeCreditAlphaNum4 asset = new AssetTypeCreditAlphaNum4(code, issuer); + AssetTypeCreditAlphaNum4 asset = new AssetTypeCreditAlphaNum4(code, issuer.getAccountId()); org.stellar.sdk.xdr.Asset xdr = asset.toXdr(); AssetTypeCreditAlphaNum4 parsedAsset = (AssetTypeCreditAlphaNum4) Asset.fromXdr(xdr); assertEquals(code, asset.getCode()); - assertEquals(issuer.getAccountId(), parsedAsset.getIssuer().getAccountId()); + assertEquals(issuer.getAccountId(), parsedAsset.getIssuer()); } @Test public void testAssetTypeCreditAlphaNum12() { String code = "TESTTEST"; KeyPair issuer = KeyPair.random(); - AssetTypeCreditAlphaNum12 asset = new AssetTypeCreditAlphaNum12(code, issuer); + AssetTypeCreditAlphaNum12 asset = new AssetTypeCreditAlphaNum12(code, issuer.getAccountId()); org.stellar.sdk.xdr.Asset xdr = asset.toXdr(); AssetTypeCreditAlphaNum12 parsedAsset = (AssetTypeCreditAlphaNum12) Asset.fromXdr(xdr); assertEquals(code, asset.getCode()); - assertEquals(issuer.getAccountId(), parsedAsset.getIssuer().getAccountId()); + assertEquals(issuer.getAccountId(), parsedAsset.getIssuer()); } @Test public void testHashCode() { - KeyPair issuer1 = KeyPair.random(); - KeyPair issuer2 = KeyPair.random(); + String issuer1 = KeyPair.random().getAccountId(); + String issuer2 = KeyPair.random().getAccountId(); // Equal assertEquals(new AssetTypeNative().hashCode(), new AssetTypeNative().hashCode()); @@ -65,8 +65,8 @@ public void testHashCode() { @Test public void testAssetEquals() { - KeyPair issuer1 = KeyPair.random(); - KeyPair issuer2 = KeyPair.random(); + String issuer1 = KeyPair.random().getAccountId(); + String issuer2 = KeyPair.random().getAccountId(); assertTrue(new AssetTypeNative().equals(new AssetTypeNative())); assertTrue(new AssetTypeCreditAlphaNum4("USD", issuer1).equals(new AssetTypeCreditAlphaNum4("USD", issuer1))); diff --git a/src/test/java/org/stellar/sdk/KeyPairTest.java b/src/test/java/org/stellar/sdk/KeyPairTest.java index 28ad8461c..54d087477 100644 --- a/src/test/java/org/stellar/sdk/KeyPairTest.java +++ b/src/test/java/org/stellar/sdk/KeyPairTest.java @@ -12,6 +12,16 @@ public class KeyPairTest { private static final String SEED = "1123740522f11bfef6b3671f51e159ccf589ccf8965262dd5f97d1721d383dd4"; + @Test + public void testInvalidPublicKey() { + try { + KeyPair.fromAccountId("GAH6H2XPCZS27WMKPTZJPTDN7JMBCDHTLU5WQP7TUI2ORA2M5FY5DHNU"); + fail(); + } catch (RuntimeException e) { + assertEquals("Public key is invalid", e.getMessage()); + } + } + @Test public void testSign() { String expectedSig = "587d4b472eeef7d07aafcd0b049640b0bb3f39784118c2e2b73a04fa2f64c9c538b4b2d0f5335e968a480021fdc23e98c0ddf424cb15d8131df8cb6c4bb58309"; diff --git a/src/test/java/org/stellar/sdk/OperationTest.java b/src/test/java/org/stellar/sdk/OperationTest.java index 33771076c..b3ac96880 100644 --- a/src/test/java/org/stellar/sdk/OperationTest.java +++ b/src/test/java/org/stellar/sdk/OperationTest.java @@ -24,16 +24,16 @@ public void testCreateAccountOperation() throws FormatException, IOException, As KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII"); String startingAmount = "1000"; - CreateAccountOperation operation = new CreateAccountOperation.Builder(destination, startingAmount) - .setSourceAccount(source) + CreateAccountOperation operation = new CreateAccountOperation.Builder(destination.getAccountId(), startingAmount) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); CreateAccountOperation parsedOperation = (CreateAccountOperation) Operation.fromXdr(xdr); assertEquals(10000000000L, xdr.getBody().getCreateAccountOp().getStartingBalance().getInt64().longValue()); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); - assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); + assertEquals(destination.getAccountId(), parsedOperation.getDestination()); assertEquals(startingAmount, parsedOperation.getStartingBalance()); assertEquals( @@ -51,16 +51,16 @@ public void testPaymentOperation() throws FormatException, IOException, AssetCod Asset asset = new AssetTypeNative(); String amount = "1000"; - PaymentOperation operation = new PaymentOperation.Builder(destination, asset, amount) - .setSourceAccount(source) + PaymentOperation operation = new PaymentOperation.Builder(destination.getAccountId(), asset, amount) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); PaymentOperation parsedOperation = (PaymentOperation) Operation.fromXdr(xdr); assertEquals(10000000000L, xdr.getBody().getPaymentOp().getAmount().getInt64().longValue()); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); - assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); + assertEquals(destination.getAccountId(), parsedOperation.getDestination()); assertTrue(parsedOperation.getAsset() instanceof AssetTypeNative); assertEquals(amount, parsedOperation.getAmount()); @@ -85,14 +85,14 @@ public void testPathPaymentOperation() throws FormatException, IOException, Asse Asset sendAsset = new AssetTypeNative(); String sendMax = "0.0001"; - Asset destAsset = new AssetTypeCreditAlphaNum4("USD", issuer); + Asset destAsset = new AssetTypeCreditAlphaNum4("USD", issuer.getAccountId()); String destAmount = "0.0001"; - Asset[] path = {new AssetTypeCreditAlphaNum4("USD", pathIssuer1), new AssetTypeCreditAlphaNum12("TESTTEST", pathIssuer2)}; + Asset[] path = {new AssetTypeCreditAlphaNum4("USD", pathIssuer1.getAccountId()), new AssetTypeCreditAlphaNum12("TESTTEST", pathIssuer2.getAccountId())}; PathPaymentOperation operation = new PathPaymentOperation.Builder( - sendAsset, sendMax, destination, destAsset, destAmount) + sendAsset, sendMax, destination.getAccountId(), destAsset, destAmount) .setPath(path) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -101,8 +101,8 @@ public void testPathPaymentOperation() throws FormatException, IOException, Asse assertEquals(1000L, xdr.getBody().getPathPaymentOp().getSendMax().getInt64().longValue()); assertEquals(1000L, xdr.getBody().getPathPaymentOp().getDestAmount().getInt64().longValue()); assertTrue(parsedOperation.getSendAsset() instanceof AssetTypeNative); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); - assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); + assertEquals(destination.getAccountId(), parsedOperation.getDestination()); assertEquals(sendMax, parsedOperation.getSendMax()); assertTrue(parsedOperation.getDestAsset() instanceof AssetTypeCreditAlphaNum4); assertEquals(destAmount, parsedOperation.getDestAmount()); @@ -122,19 +122,14 @@ public void testPathPaymentEmptyPathOperation() throws FormatException, IOExcept // GCGZLB3X2B3UFOFSHHQ6ZGEPEX7XYPEH6SBFMIV74EUDOFZJA3VNL6X4 KeyPair issuer = KeyPair.fromSecretSeed("SBOBVZUN6WKVMI6KIL2GHBBEETEV6XKQGILITNH6LO6ZA22DBMSDCPAG"); - // GAVAQKT2M7B4V3NN7RNNXPU5CWNDKC27MYHKLF5UNYXH4FNLFVDXKRSV - KeyPair pathIssuer1 = KeyPair.fromSecretSeed("SALDLG5XU5AEJWUOHAJPSC4HJ2IK3Z6BXXP4GWRHFT7P7ILSCFFQ7TC5"); - // GBCP5W2VS7AEWV2HFRN7YYC623LTSV7VSTGIHFXDEJU7S5BAGVCSETRR - KeyPair pathIssuer2 = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ"); - Asset sendAsset = new AssetTypeNative(); String sendMax = "0.0001"; - Asset destAsset = new AssetTypeCreditAlphaNum4("USD", issuer); + Asset destAsset = new AssetTypeCreditAlphaNum4("USD", issuer.getAccountId()); String destAmount = "0.0001"; PathPaymentOperation operation = new PathPaymentOperation.Builder( - sendAsset, sendMax, destination, destAsset, destAmount) - .setSourceAccount(source) + sendAsset, sendMax, destination.getAccountId(), destAsset, destAmount) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -143,8 +138,8 @@ public void testPathPaymentEmptyPathOperation() throws FormatException, IOExcept assertEquals(1000L, xdr.getBody().getPathPaymentOp().getSendMax().getInt64().longValue()); assertEquals(1000L, xdr.getBody().getPathPaymentOp().getDestAmount().getInt64().longValue()); assertTrue(parsedOperation.getSendAsset() instanceof AssetTypeNative); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); - assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); + assertEquals(destination.getAccountId(), parsedOperation.getDestination()); assertEquals(sendMax, parsedOperation.getSendMax()); assertTrue(parsedOperation.getDestAsset() instanceof AssetTypeCreditAlphaNum4); assertEquals(destAmount, parsedOperation.getDestAmount()); @@ -164,14 +159,14 @@ public void testChangeTrustOperation() throws FormatException, IOException { String limit = "922337203685.4775807"; ChangeTrustOperation operation = new ChangeTrustOperation.Builder(asset, limit) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); ChangeTrustOperation parsedOperation = (ChangeTrustOperation) Operation.fromXdr(xdr); assertEquals(9223372036854775807L, xdr.getBody().getChangeTrustOp().getLimit().getInt64().longValue()); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); assertTrue(parsedOperation.getAsset() instanceof AssetTypeNative); assertEquals(limit, parsedOperation.getLimit()); @@ -190,15 +185,15 @@ public void testAllowTrustOperation() throws IOException, FormatException { String assetCode = "USDA"; boolean authorize = true; - AllowTrustOperation operation = new AllowTrustOperation.Builder(trustor, assetCode, authorize) - .setSourceAccount(source) + AllowTrustOperation operation = new AllowTrustOperation.Builder(trustor.getAccountId(), assetCode, authorize) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); AllowTrustOperation parsedOperation = (AllowTrustOperation) Operation.fromXdr(xdr); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); - assertEquals(trustor.getAccountId(), parsedOperation.getTrustor().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); + assertEquals(trustor.getAccountId(), parsedOperation.getTrustor()); assertEquals(assetCode, parsedOperation.getAssetCode()); assertEquals(authorize, parsedOperation.getAuthorize()); @@ -217,8 +212,8 @@ public void testAllowTrustOperationAssetCodeBuffer() throws IOException, FormatE String assetCode = "USDABC"; boolean authorize = true; - AllowTrustOperation operation = new AllowTrustOperation.Builder(trustor, assetCode, authorize) - .setSourceAccount(source) + AllowTrustOperation operation = new AllowTrustOperation.Builder(trustor.getAccountId(), assetCode, authorize) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -246,7 +241,7 @@ public void testSetOptionsOperation() throws FormatException { Integer signerWeight = 1; SetOptionsOperation operation = new SetOptionsOperation.Builder() - .setInflationDestination(inflationDestination) + .setInflationDestination(inflationDestination.getAccountId()) .setClearFlags(clearFlags) .setSetFlags(setFlags) .setMasterKeyWeight(masterKeyWeight) @@ -255,13 +250,13 @@ public void testSetOptionsOperation() throws FormatException { .setHighThreshold(highThreshold) .setHomeDomain(homeDomain) .setSigner(signer, signerWeight) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); SetOptionsOperation parsedOperation = (SetOptionsOperation) SetOptionsOperation.fromXdr(xdr); - assertEquals(inflationDestination.getAccountId(), parsedOperation.getInflationDestination().getAccountId()); + assertEquals(inflationDestination.getAccountId(), parsedOperation.getInflationDestination()); assertEquals(clearFlags, parsedOperation.getClearFlags()); assertEquals(setFlags, parsedOperation.getSetFlags()); assertEquals(masterKeyWeight, parsedOperation.getMasterKeyWeight()); @@ -272,7 +267,7 @@ public void testSetOptionsOperation() throws FormatException { assertEquals(signer.getDiscriminant().getValue(), parsedOperation.getSigner().getDiscriminant().getValue()); assertEquals(signer.getEd25519().getUint256(), parsedOperation.getSigner().getEd25519().getUint256()); assertEquals(signerWeight, parsedOperation.getSignerWeight()); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); assertEquals( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAABAAAAAO3gUmG83C+VCqO6FztuMtXJF/l7grZA7MjRzqdZ9W8QAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAIAAAABAAAAAwAAAAEAAAAEAAAAAQAAAAtzdGVsbGFyLm9yZwAAAAABAAAAAET+21WXwEtXRyxb/GBe1tc5V/WUzIOW4yJp+XQgNUUiAAAAAQ==", @@ -288,7 +283,7 @@ public void testSetOptionsOperationSingleField() { SetOptionsOperation operation = new SetOptionsOperation.Builder() .setHomeDomain(homeDomain) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -304,7 +299,7 @@ public void testSetOptionsOperationSingleField() { assertEquals(homeDomain, parsedOperation.getHomeDomain()); assertEquals(null, parsedOperation.getSigner()); assertEquals(null, parsedOperation.getSignerWeight()); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); assertEquals( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAtzdGVsbGFyLm9yZwAAAAAA", @@ -321,7 +316,7 @@ public void testSetOptionsOperationSignerSha256() { SetOptionsOperation operation = new SetOptionsOperation.Builder() .setSigner(Signer.sha256Hash(hash), 10) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -337,7 +332,7 @@ public void testSetOptionsOperationSignerSha256() { assertEquals(null, parsedOperation.getHomeDomain()); assertTrue(Arrays.equals(hash, parsedOperation.getSigner().getHashX().getUint256())); assertEquals(new Integer(10), parsedOperation.getSignerWeight()); - assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); + assertEquals(source.getAccountId(), parsedOperation.getSourceAccount()); assertEquals( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAACbpRqMkaQAfCYSk/n3xIl4fCoHfKqxF34ht2iuvSYEJQAAAAK", @@ -351,9 +346,9 @@ public void testSetOptionsOperationPreAuthTxSigner() { KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); long sequenceNumber = 2908908335136768L; - Account account = new Account(source, sequenceNumber); + Account account = new Account(source.getAccountId(), sequenceNumber); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -362,7 +357,7 @@ public void testSetOptionsOperationPreAuthTxSigner() { SetOptionsOperation operation = new SetOptionsOperation.Builder() .setSigner(Signer.preAuthTx(transaction), 10) - .setSourceAccount(opSource) + .setSourceAccount(opSource.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -378,7 +373,7 @@ public void testSetOptionsOperationPreAuthTxSigner() { assertEquals(null, parsedOperation.getHomeDomain()); assertTrue(Arrays.equals(transaction.hash(), parsedOperation.getSigner().getPreAuthTx().getUint256())); assertEquals(new Integer(10), parsedOperation.getSignerWeight()); - assertEquals(opSource.getAccountId(), parsedOperation.getSourceAccount().getAccountId()); + assertEquals(opSource.getAccountId(), parsedOperation.getSourceAccount()); assertEquals( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAB1vRBIRC3w7ZH5rQa17hIBKUwZTvBP4kNmSP7jVyw1fQAAAAK", @@ -393,7 +388,7 @@ public void testManageSellOfferOperation() throws IOException, FormatException { KeyPair issuer = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ"); Asset selling = new AssetTypeNative(); - Asset buying = Asset.createNonNativeAsset("USD", issuer); + Asset buying = Asset.createNonNativeAsset("USD", issuer.getAccountId()); String amount = "0.00001"; String price = "0.85334384"; // n=5333399 d=6250000 Price priceObj = Price.fromString(price); @@ -401,7 +396,7 @@ public void testManageSellOfferOperation() throws IOException, FormatException { ManageSellOfferOperation operation = new ManageSellOfferOperation.Builder(selling, buying, amount, price) .setOfferId(offerId) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -430,7 +425,7 @@ public void testManageBuyOfferOperation() throws IOException, FormatException { KeyPair issuer = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ"); Asset selling = new AssetTypeNative(); - Asset buying = Asset.createNonNativeAsset("USD", issuer); + Asset buying = Asset.createNonNativeAsset("USD", issuer.getAccountId()); String amount = "0.00001"; String price = "0.85334384"; // n=5333399 d=6250000 Price priceObj = Price.fromString(price); @@ -438,7 +433,7 @@ public void testManageBuyOfferOperation() throws IOException, FormatException { ManageBuyOfferOperation operation = new ManageBuyOfferOperation.Builder(selling, buying, amount, price) .setOfferId(offerId) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -499,13 +494,13 @@ public void testCreatePassiveSellOfferOperation() throws IOException, FormatExce KeyPair issuer = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ"); Asset selling = new AssetTypeNative(); - Asset buying = Asset.createNonNativeAsset("USD", issuer); + Asset buying = Asset.createNonNativeAsset("USD", issuer.getAccountId()); String amount = "0.00001"; String price = "2.93850088"; // n=36731261 d=12500000 Price priceObj = Price.fromString(price); CreatePassiveSellOfferOperation operation = new CreatePassiveSellOfferOperation.Builder(selling, buying, amount, price) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -532,15 +527,15 @@ public void testAccountMergeOperation() throws IOException, FormatException { // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII"); - AccountMergeOperation operation = new AccountMergeOperation.Builder(destination) - .setSourceAccount(source) + AccountMergeOperation operation = new AccountMergeOperation.Builder(destination.getAccountId()) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); AccountMergeOperation parsedOperation = (AccountMergeOperation) Operation.fromXdr(xdr); - assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId()); + assertEquals(destination.getAccountId(), parsedOperation.getDestination()); assertEquals( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAgAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxA=", @@ -553,7 +548,7 @@ public void testManageDataOperation() throws IOException, FormatException { KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); ManageDataOperation operation = new ManageDataOperation.Builder("test", new byte[]{0, 1, 2, 3, 4}) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -574,7 +569,7 @@ public void testManageDataOperationEmptyValue() throws IOException, FormatExcept KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); ManageDataOperation operation = new ManageDataOperation.Builder("test", null) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -595,7 +590,7 @@ public void testBumpSequence() throws IOException, FormatException { KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); BumpSequenceOperation operation = new BumpSequenceOperation.Builder(156L) - .setSourceAccount(source) + .setSourceAccount(source.getAccountId()) .build(); org.stellar.sdk.xdr.Operation xdr = operation.toXdr(); @@ -660,7 +655,7 @@ public void testInflationOperation() { "AAAAAAAAAAk=", operation.toXdrBase64()); - operation.setSourceAccount(source); + operation.setSourceAccount(source.getAccountId()); assertEquals( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAk=", diff --git a/src/test/java/org/stellar/sdk/ServerTest.java b/src/test/java/org/stellar/sdk/ServerTest.java index bb22e7d30..c8a5d737d 100644 --- a/src/test/java/org/stellar/sdk/ServerTest.java +++ b/src/test/java/org/stellar/sdk/ServerTest.java @@ -166,9 +166,9 @@ Transaction buildTransaction(Network network) throws IOException { KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction.Builder builder = new Transaction.Builder(account, network) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .addMemo(Memo.text("Hello world!")) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE); diff --git a/src/test/java/org/stellar/sdk/TransactionTest.java b/src/test/java/org/stellar/sdk/TransactionTest.java index aae2005b5..335a957ad 100644 --- a/src/test/java/org/stellar/sdk/TransactionTest.java +++ b/src/test/java/org/stellar/sdk/TransactionTest.java @@ -20,9 +20,9 @@ public void testDefaultBaseFee() throws FormatException { Transaction.Builder.setDefaultOperationFee(2345); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -37,7 +37,7 @@ public void testDefaultBaseFee() throws FormatException { Network.TESTNET ); - assertEquals(transaction.getSourceAccount().getAccountId(), transaction2.getSourceAccount().getAccountId()); + assertEquals(transaction.getSourceAccount(), transaction2.getSourceAccount()); assertEquals(transaction.getSequenceNumber(), transaction2.getSequenceNumber()); assertEquals(transaction.getFee(), transaction2.getFee()); assertEquals( @@ -66,9 +66,9 @@ public void testBuilderSuccessTestnet() throws FormatException { KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); long sequenceNumber = 2908908335136768L; - Account account = new Account(source, sequenceNumber); + Account account = new Account(source.getAccountId(), sequenceNumber); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -78,13 +78,13 @@ public void testBuilderSuccessTestnet() throws FormatException { "AAAAAF7FIiDToW1fOYUFBC0dmyufJbFTOa2GQESGz+S2h5ViAAAAZAAKVaMAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAAEqBfIAAAAAAAAAAABtoeVYgAAAEDLki9Oi700N60Lo8gUmEFHbKvYG4QSqXiLIt9T0ru2O5BphVl/jR9tYtHAD+UeDYhgXNgwUxqTEu1WukvEyYcD", transaction.toEnvelopeXdrBase64()); - assertEquals(transaction.getSourceAccount(), source); + assertEquals(transaction.getSourceAccount(), source.getAccountId()); assertEquals(transaction.getSequenceNumber(), sequenceNumber + 1); assertEquals(transaction.getFee(), 100); Transaction transaction2 = Transaction.fromEnvelopeXdr(transaction.toEnvelopeXdr(), Network.TESTNET); - assertEquals(transaction.getSourceAccount().getAccountId(), transaction2.getSourceAccount().getAccountId()); + assertEquals(transaction.getSourceAccount(), transaction2.getSourceAccount()); assertEquals(transaction.getSequenceNumber(), transaction2.getSequenceNumber()); assertEquals(transaction.getFee(), transaction2.getFee()); assertEquals( @@ -101,9 +101,9 @@ public void testBuilderMemoText() throws FormatException { KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .addMemo(Memo.text("Hello world!")) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -116,7 +116,7 @@ public void testBuilderMemoText() throws FormatException { Transaction transaction2 = Transaction.fromEnvelopeXdr(transaction.toEnvelopeXdr(), Network.TESTNET); - assertEquals(transaction.getSourceAccount().getAccountId(), transaction2.getSourceAccount().getAccountId()); + assertEquals(transaction.getSourceAccount(), transaction2.getSourceAccount()); assertEquals(transaction.getSequenceNumber(), transaction2.getSequenceNumber()); assertEquals(transaction.getMemo(), transaction2.getMemo()); assertEquals(transaction.getFee(), transaction2.getFee()); @@ -132,9 +132,9 @@ public void testBuilderTimeBounds() throws FormatException, IOException { KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .addTimeBounds(new TimeBounds(42, 1337)) .addMemo(Memo.hash("abcdef")) .build(); @@ -154,7 +154,7 @@ public void testBuilderTimeBounds() throws FormatException, IOException { Transaction transaction2 = Transaction.fromEnvelopeXdr(transaction.toEnvelopeXdr(), Network.TESTNET); - assertEquals(transaction.getSourceAccount().getAccountId(), transaction2.getSourceAccount().getAccountId()); + assertEquals(transaction.getSourceAccount(), transaction2.getSourceAccount()); assertEquals(transaction.getSequenceNumber(), transaction2.getSequenceNumber()); assertEquals(transaction.getMemo(), transaction2.getMemo()); assertEquals(transaction.getTimeBounds(), transaction2.getTimeBounds()); @@ -171,9 +171,9 @@ public void testBuilderBaseFee() throws FormatException { KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .setOperationFee(200) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -186,7 +186,7 @@ public void testBuilderBaseFee() throws FormatException { Transaction transaction2 = Transaction.fromEnvelopeXdr(transaction.toEnvelopeXdr(), Network.TESTNET); - assertEquals(transaction.getSourceAccount().getAccountId(), transaction2.getSourceAccount().getAccountId()); + assertEquals(transaction.getSourceAccount(), transaction2.getSourceAccount()); assertEquals(transaction.getSequenceNumber(), transaction2.getSequenceNumber()); assertEquals(transaction.getFee(), transaction2.getFee()); assertEquals( @@ -200,7 +200,7 @@ public void testBuilderBaseFeeThrows() throws FormatException { // GBPMKIRA2OQW2XZZQUCQILI5TMVZ6JNRKM423BSAISDM7ZFWQ6KWEBC4 KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction.Builder builder = new Transaction.Builder(account, Network.TESTNET); try { builder.setOperationFee(99); @@ -212,9 +212,9 @@ public void testBuilderBaseFeeThrows() throws FormatException { @Test public void testBuilderWithTimeBoundsButNoTimeout() throws IOException { - Account account = new Account(KeyPair.random(), 2908908335136768L); + Account account = new Account(KeyPair.random().getAccountId(), 2908908335136768L); new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(KeyPair.random(), "2000").build()) + .addOperation(new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build()) .addTimeBounds(new TimeBounds(42, 1337)) .addMemo(Memo.hash("abcdef")) .build(); @@ -222,10 +222,10 @@ public void testBuilderWithTimeBoundsButNoTimeout() throws IOException { @Test public void testBuilderRequiresTimeoutOrTimeBounds() throws IOException { - Account account = new Account(KeyPair.random(), 2908908335136768L); + Account account = new Account(KeyPair.random().getAccountId(), 2908908335136768L); try { new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(KeyPair.random(), "2000").build()) + .addOperation(new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build()) .addMemo(Memo.hash("abcdef")) .build(); } catch (RuntimeException exception) { @@ -239,10 +239,10 @@ public void testBuilderRequiresTimeoutOrTimeBounds() throws IOException { @Test public void testBuilderTimeoutNegative() throws IOException { - Account account = new Account(KeyPair.random(), 2908908335136768L); + Account account = new Account(KeyPair.random().getAccountId(), 2908908335136768L); try { new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(KeyPair.random(), "2000").build()) + .addOperation(new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build()) .addMemo(Memo.hash("abcdef")) .setTimeout(-1) .build(); @@ -255,9 +255,9 @@ public void testBuilderTimeoutNegative() throws IOException { @Test public void testBuilderTimeoutSetsTimeBounds() throws IOException { - Account account = new Account(KeyPair.random(), 2908908335136768L); + Account account = new Account(KeyPair.random().getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(KeyPair.random(), "2000").build()) + .addOperation(new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build()) .setTimeout(10) .build(); @@ -268,10 +268,10 @@ public void testBuilderTimeoutSetsTimeBounds() throws IOException { @Test public void testBuilderFailsWhenSettingTimeoutAndMaxTimeAlreadySet() throws IOException { - Account account = new Account(KeyPair.random(), 2908908335136768L); + Account account = new Account(KeyPair.random().getAccountId(), 2908908335136768L); try { new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(KeyPair.random(), "2000").build()) + .addOperation(new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build()) .addTimeBounds(new TimeBounds(42, 1337)) .setTimeout(10) .build(); @@ -284,9 +284,9 @@ public void testBuilderFailsWhenSettingTimeoutAndMaxTimeAlreadySet() throws IOEx @Test public void testBuilderFailsWhenSettingTimeoutAndMaxTimeNotSet() throws IOException { - Account account = new Account(KeyPair.random(), 2908908335136768L); + Account account = new Account(KeyPair.random().getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(KeyPair.random(), "2000").build()) + .addOperation(new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build()) .addTimeBounds(new TimeBounds(42, 0)) .setTimeout(10) .build(); @@ -303,9 +303,9 @@ public void testBuilderTimeBoundsNoMaxTime() throws FormatException, IOException KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .addTimeBounds(new TimeBounds(42, 0)) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .addMemo(Memo.hash("abcdef")) @@ -333,9 +333,9 @@ public void testBuilderSuccessPublic() throws FormatException { KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.PUBLIC) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -351,9 +351,9 @@ public void testSha256HashSigning() throws FormatException { KeyPair source = KeyPair.fromAccountId("GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB"); KeyPair destination = KeyPair.fromAccountId("GDJJRRMBK4IWLEPJGIE6SXD2LP7REGZODU7WDC3I2D6MR37F4XSHBKX2"); - Account account = new Account(source, 0L); + Account account = new Account(source.getAccountId(), 0L); Transaction transaction = new Transaction.Builder(account, Network.PUBLIC) - .addOperation(new PaymentOperation.Builder(destination, new AssetTypeNative(), "2000").build()) + .addOperation(new PaymentOperation.Builder(destination.getAccountId(), new AssetTypeNative(), "2000").build()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -376,9 +376,9 @@ public void testToBase64EnvelopeXdrBuilderNoSignatures() throws FormatException, KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); Transaction transaction = new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); @@ -393,7 +393,7 @@ public void testNoOperations() throws FormatException, IOException { // GBPMKIRA2OQW2XZZQUCQILI5TMVZ6JNRKM423BSAISDM7ZFWQ6KWEBC4 KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); try { Transaction transaction = new Transaction.Builder(account, Network.TESTNET).setTimeout( Transaction.Builder.TIMEOUT_INFINITE @@ -412,9 +412,9 @@ public void testTryingToAddMemoTwice() throws FormatException, IOException { KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); try { - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); new Transaction.Builder(account, Network.TESTNET) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .addMemo(Memo.none()) .addMemo(Memo.none()); fail(); @@ -429,10 +429,10 @@ public void testNoNetworkSet() throws FormatException { KeyPair source = KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); KeyPair destination = KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); - Account account = new Account(source, 2908908335136768L); + Account account = new Account(source.getAccountId(), 2908908335136768L); try { new Transaction.Builder(account, null) - .addOperation(new CreateAccountOperation.Builder(destination, "2000").build()) + .addOperation(new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()) .addMemo(Memo.none()) .setTimeout(Transaction.Builder.TIMEOUT_INFINITE) .build(); diff --git a/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java index 273388150..8fff5a0f7 100644 --- a/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java @@ -23,7 +23,7 @@ public void testEffects() { public void testForAccount() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.effects() - .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")) + .forAccount("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H") .limit(200) .order(RequestBuilder.Order.DESC) .buildUri(); diff --git a/src/test/java/org/stellar/sdk/requests/OffersRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OffersRequestBuilderTest.java index bbcccb6f8..0d4b10931 100644 --- a/src/test/java/org/stellar/sdk/requests/OffersRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/OffersRequestBuilderTest.java @@ -13,7 +13,7 @@ public class OffersRequestBuilderTest { public void testForAccount() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.offers() - .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")) + .forAccount("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H") .limit(200) .order(RequestBuilder.Order.DESC) .buildUri(); diff --git a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java index fe9641d9d..a34637865 100644 --- a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java @@ -23,7 +23,7 @@ public void testOperations() { public void testForAccount() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.operations() - .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")) + .forAccount("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H") .limit(200) .order(RequestBuilder.Order.DESC) .buildUri(); diff --git a/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java index 09cc06802..2c012ec63 100644 --- a/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java @@ -14,8 +14,8 @@ public class OrderBookRequestBuilderTest { public void testOrderBook() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.orderBook() - .buyingAsset(Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W"))) - .sellingAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ"))) + .buyingAsset(Asset.createNonNativeAsset("EUR", "GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W")) + .sellingAsset(Asset.createNonNativeAsset("USD", "GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")) .buildUri(); assertEquals( diff --git a/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java index 3d9916b7d..7e02fa773 100644 --- a/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java @@ -14,10 +14,10 @@ public class PathsRequestBuilderTest { public void testAccounts() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.paths() - .destinationAccount(KeyPair.fromAccountId("GB24QI3BJNKBY4YNJZ2I37HFIYK56BL2OURFML76X46RQQKDLVT7WKJF")) - .sourceAccount(KeyPair.fromAccountId("GD4KO3IOYYWIYVI236Y35K2DU6VNYRH3BPNFJSH57J5BLLCQHBIOK3IN")) + .destinationAccount("GB24QI3BJNKBY4YNJZ2I37HFIYK56BL2OURFML76X46RQQKDLVT7WKJF") + .sourceAccount("GD4KO3IOYYWIYVI236Y35K2DU6VNYRH3BPNFJSH57J5BLLCQHBIOK3IN") .destinationAmount("20.50") - .destinationAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH"))) + .destinationAsset(Asset.createNonNativeAsset("USD", "GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH")) .cursor("13537736921089") .limit(200) .order(RequestBuilder.Order.ASC) diff --git a/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java index 7bee1e0e9..b4477b9dc 100644 --- a/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java @@ -23,7 +23,7 @@ public void testPayments() { public void testForAccount() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.payments() - .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")) + .forAccount("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H") .limit(200) .order(RequestBuilder.Order.DESC) .buildUri(); diff --git a/src/test/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilderTest.java index acbc6c490..41dea768f 100644 --- a/src/test/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/TradeAggregationsRequestBuilderTest.java @@ -12,7 +12,7 @@ public void testTradeAggregations() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.tradeAggregations( new AssetTypeNative(), - Asset.createNonNativeAsset("BTC", KeyPair.fromAccountId("GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH")), + Asset.createNonNativeAsset("BTC", "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH"), 1512689100000L, 1512775500000L, 300000L, diff --git a/src/test/java/org/stellar/sdk/requests/TradesRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/TradesRequestBuilderTest.java index 9e8c2eb6d..941c07410 100644 --- a/src/test/java/org/stellar/sdk/requests/TradesRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/TradesRequestBuilderTest.java @@ -14,8 +14,8 @@ public class TradesRequestBuilderTest { public void testTrades() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.trades() - .baseAsset(Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W"))) - .counterAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ"))) + .baseAsset(Asset.createNonNativeAsset("EUR", "GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W")) + .counterAsset(Asset.createNonNativeAsset("USD", "GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")) .cursor("13537736921089") .limit(200) .order(RequestBuilder.Order.ASC) @@ -37,7 +37,7 @@ public void testTrades() { public void testTradesForAccount() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.trades() - .forAccount(KeyPair.fromAccountId("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")) + .forAccount("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ") .cursor("13537736921089") .limit(200) .order(RequestBuilder.Order.ASC) diff --git a/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java index d277271ee..a1e1762c5 100644 --- a/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java @@ -23,7 +23,7 @@ public void testTransactions() { public void testForAccount() { Server server = new Server("https://horizon-testnet.stellar.org"); HttpUrl uri = server.transactions() - .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H")) + .forAccount("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H") .limit(200) .order(RequestBuilder.Order.DESC) .buildUri(); diff --git a/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java index 94b326a93..42f1b83b6 100644 --- a/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java @@ -10,7 +10,7 @@ public class AccountDeserializerTest extends TestCase { @Test public void testDeserialize() { AccountResponse account = GsonSingleton.getInstance().fromJson(json, AccountResponse.class); - assertEquals(account.getKeypair().getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); + assertEquals(account.getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); assertEquals(account.getSequenceNumber(), new Long(2319149195853854L)); assertEquals(account.getSubentryCount(), new Integer(0)); assertEquals(account.getInflationDestination(), "GAGRSA6QNQJN2OQYCBNQGMFLO4QLZFNEHIFXOMTQVSUTWVTWT66TOFSC"); @@ -26,7 +26,7 @@ public void testDeserialize() { assertEquals(account.getBalances()[0].getAssetType(), "credit_alphanum4"); assertEquals(account.getBalances()[0].getAssetCode(), "ABC"); - assertEquals(account.getBalances()[0].getAssetIssuer().getAccountId(), "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU"); + assertEquals(account.getBalances()[0].getAssetIssuer(), "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU"); assertEquals(account.getBalances()[0].getBalance(), "1001.0000000"); assertEquals(account.getBalances()[0].getLimit(), "12000.4775807"); assertEquals(account.getBalances()[0].getBuyingLiabilities(), "100.1234567"); @@ -64,7 +64,7 @@ public void testDeserializeV9() { assertEquals(account.getBalances()[0].getAssetType(), "credit_alphanum4"); assertEquals(account.getBalances()[0].getAssetCode(), "ABC"); - assertEquals(account.getBalances()[0].getAssetIssuer().getAccountId(), "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU"); + assertEquals(account.getBalances()[0].getAssetIssuer(), "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU"); assertEquals(account.getBalances()[0].getBalance(), "1001.0000000"); assertEquals(account.getBalances()[0].getLimit(), "12000.4775807"); assertEquals(account.getBalances()[0].getBuyingLiabilities(), null); diff --git a/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java index 1f47a7c0f..b66cb2283 100644 --- a/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java @@ -11,8 +11,8 @@ public class AccountsPageDeserializerTest extends TestCase { public void testDeserialize() { Page accountsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType()); - assertEquals(accountsPage.getRecords().get(0).getKeypair().getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); - assertEquals(accountsPage.getRecords().get(9).getKeypair().getAccountId(), "GACFGMEV7A5H44O3K4EN6GRQ4SA543YJBZTKGNKPEMEQEAJFO4Q7ENG6"); + assertEquals(accountsPage.getRecords().get(0).getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); + assertEquals(accountsPage.getRecords().get(9).getAccountId(), "GACFGMEV7A5H44O3K4EN6GRQ4SA543YJBZTKGNKPEMEQEAJFO4Q7ENG6"); assertEquals(accountsPage.getLinks().getNext().getHref(), "/accounts?order=asc&limit=10&cursor=86861418598401"); assertEquals(accountsPage.getLinks().getPrev().getHref(), "/accounts?order=desc&limit=10&cursor=1"); assertEquals(accountsPage.getLinks().getSelf().getHref(), "/accounts?order=asc&limit=10&cursor="); diff --git a/src/test/java/org/stellar/sdk/responses/AssetDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AssetDeserializerTest.java index 61b482661..fd41cf84d 100644 --- a/src/test/java/org/stellar/sdk/responses/AssetDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/AssetDeserializerTest.java @@ -24,6 +24,6 @@ public void testDeserializeCredit() { assertEquals(asset.getType(), "credit_alphanum4"); AssetTypeCreditAlphaNum creditAsset = (AssetTypeCreditAlphaNum) asset; assertEquals(creditAsset.getCode(), "CNY"); - assertEquals(creditAsset.getIssuer().getAccountId(), "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX"); + assertEquals(creditAsset.getIssuer(), "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX"); } } diff --git a/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java index e8d5702f9..5346b2155 100644 --- a/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java @@ -33,7 +33,7 @@ public void testDeserializeAccountCreatedEffect() { AccountCreatedEffectResponse effect = (AccountCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ"); + assertEquals(effect.getAccount(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ"); assertEquals(effect.getStartingBalance(), "30.0"); assertEquals(effect.getPagingToken(), "65571265847297-1"); @@ -65,7 +65,7 @@ public void testDeserializeAccountRemovedEffect() { AccountRemovedEffectResponse effect = (AccountRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ"); + assertEquals(effect.getAccount(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/65571265847297"); assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=65571265847297-1"); @@ -97,7 +97,7 @@ public void testDeserializeAccountCreditedEffect() { AccountCreditedEffectResponse effect = (AccountCreditedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GDLGTRIBFH24364GPWPUS45GUFC2GU4ARPGWTXVCPLGTUHX3IOS3ON47"); + assertEquals(effect.getAccount(), "GDLGTRIBFH24364GPWPUS45GUFC2GU4ARPGWTXVCPLGTUHX3IOS3ON47"); TestCase.assertEquals(effect.getAsset(), new AssetTypeNative()); assertEquals(effect.getAmount(), "1000.0"); @@ -131,7 +131,7 @@ public void testDeserializeAccountDebitedEffect() { AccountDebitedEffectResponse effect = (AccountDebitedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"); + assertEquals(effect.getAccount(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"); assertEquals(effect.getAsset(), new AssetTypeNative()); assertEquals(effect.getAmount(), "30.0"); @@ -166,7 +166,7 @@ public void testDeserializeAccountThresholdsUpdatedEffect() { AccountThresholdsUpdatedEffectResponse effect = (AccountThresholdsUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); assertEquals(effect.getLowThreshold(), new Integer(2)); assertEquals(effect.getMedThreshold(), new Integer(3)); assertEquals(effect.getHighThreshold(), new Integer(4)); @@ -200,7 +200,7 @@ public void testDeserializeAccountHomeDomainUpdatedEffect() { AccountHomeDomainUpdatedEffectResponse effect = (AccountHomeDomainUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); assertEquals(effect.getHomeDomain(), "stellar.org"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/18970870550529"); @@ -233,7 +233,7 @@ public void testDeserializeAccountFlagsUpdatedEffect() { AccountFlagsUpdatedEffectResponse effect = (AccountFlagsUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); assertEquals(effect.getAuthRequiredFlag(), new Boolean(false)); assertEquals(effect.getAuthRevokableFlag(), new Boolean(true)); @@ -266,7 +266,7 @@ public void testDeserializeAccountInflationDestinationUpdatedEffect() { AccountInflationDestinationUpdatedEffectResponse effect = (AccountInflationDestinationUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); + assertEquals(effect.getAccount(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); assertEquals(effect.getCreatedAt(), "2018-06-06T10:20:50Z"); } @@ -295,7 +295,7 @@ public void testDeserializeSignerCreatedEffect() { SignerCreatedEffectResponse effect = (SignerCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU"); + assertEquals(effect.getAccount(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU"); assertEquals(effect.getWeight(), new Integer(1)); assertEquals(effect.getPublicKey(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU"); @@ -329,7 +329,7 @@ public void testDeserializeSignerRemovedEffect() { SignerRemovedEffectResponse effect = (SignerRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6"); + assertEquals(effect.getAccount(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6"); assertEquals(effect.getWeight(), new Integer(0)); assertEquals(effect.getPublicKey(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6"); @@ -363,7 +363,7 @@ public void testDeserializeSignerUpdatedEffect() { SignerUpdatedEffectResponse effect = (SignerUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); assertEquals(effect.getWeight(), new Integer(2)); assertEquals(effect.getPublicKey(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); @@ -399,8 +399,8 @@ public void testDeserializeTrustlineCreatedEffect() { TrustlineCreatedEffectResponse effect = (TrustlineCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); - TestCase.assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA"))); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + TestCase.assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")); assertEquals(effect.getLimit(), "1000.0"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730"); @@ -435,8 +435,8 @@ public void testDeserializeTrustlineRemovedEffect() { TrustlineRemovedEffectResponse effect = (TrustlineRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); - assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA"))); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")); assertEquals(effect.getLimit(), "0.0"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730"); @@ -471,8 +471,8 @@ public void testDeserializeTrustlineUpdatedEffect() { TrustlineUpdatedEffectResponse effect = (TrustlineUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); - assertEquals(effect.getAsset(), Asset.createNonNativeAsset("TESTTEST", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA"))); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAsset(), Asset.createNonNativeAsset("TESTTEST", "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")); assertEquals(effect.getLimit(), "100.0"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730"); @@ -506,10 +506,10 @@ public void testDeserializeTrustlineAuthorizedEffect() { TrustlineAuthorizedEffectResponse effect = (TrustlineAuthorizedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); assertEquals(effect.getAssetType(), "credit_alphanum12"); assertEquals(effect.getAssetCode(), "TESTTEST"); - assertEquals(effect.getTrustor().getAccountId(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR"); + assertEquals(effect.getTrustor(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730"); assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2"); @@ -542,10 +542,10 @@ public void testDeserializeTrustlineDeauthorizedEffect() { TrustlineDeauthorizedEffectResponse effect = (TrustlineDeauthorizedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); assertEquals(effect.getAssetType(), "credit_alphanum4"); assertEquals(effect.getAssetCode(), "EUR"); - assertEquals(effect.getTrustor().getAccountId(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR"); + assertEquals(effect.getTrustor(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR"); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730"); assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2"); @@ -585,13 +585,13 @@ public void testDeserializeTradeEffect() { TradeEffectResponse effect = (TradeEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); - assertEquals(effect.getSeller().getAccountId(), "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB"); + assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO"); + assertEquals(effect.getSeller(), "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB"); assertEquals(effect.getOfferId(), new Long(1)); assertEquals(effect.getSoldAmount(), "1000.0"); - assertEquals(effect.getSoldAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GCWVFBJ24754I5GXG4JOEB72GJCL3MKWC7VAEYWKGQHPVH3ENPNBSKWS"))); + assertEquals(effect.getSoldAsset(), Asset.createNonNativeAsset("EUR", "GCWVFBJ24754I5GXG4JOEB72GJCL3MKWC7VAEYWKGQHPVH3ENPNBSKWS")); assertEquals(effect.getBoughtAmount(), "60.0"); - assertEquals(effect.getBoughtAsset(), Asset.createNonNativeAsset("TESTTEST", KeyPair.fromAccountId("GAHXPUDP3AK6F2QQM4FIRBGPNGKLRDDSTQCVKEXXKKRHJZUUQ23D5BU7"))); + assertEquals(effect.getBoughtAsset(), Asset.createNonNativeAsset("TESTTEST", "GAHXPUDP3AK6F2QQM4FIRBGPNGKLRDDSTQCVKEXXKKRHJZUUQ23D5BU7")); assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730"); assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2"); @@ -622,7 +622,7 @@ public void testDeserializeDataCreatedEffect() { DataCreatedEffectResponse effect = (DataCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); + assertEquals(effect.getAccount(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); assertEquals(effect.getCreatedAt(), "2018-06-06T10:23:57Z"); } @@ -650,7 +650,7 @@ public void testDeserializeDataRemovedEffect() { DataRemovedEffectResponse effect = (DataRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); + assertEquals(effect.getAccount(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); assertEquals(effect.getCreatedAt(), "2018-06-06T10:23:57Z"); } @@ -678,7 +678,7 @@ public void testDeserializeDataUpdatedEffect() { DataUpdatedEffectResponse effect = (DataUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); + assertEquals(effect.getAccount(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); assertEquals(effect.getCreatedAt(), "2018-06-06T10:23:57Z"); } @@ -707,7 +707,7 @@ public void testDeserializeSequenceBumpedEffect() { SequenceBumpedEffectResponse effect = (SequenceBumpedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class); - assertEquals(effect.getAccount().getAccountId(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); + assertEquals(effect.getAccount(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF"); assertEquals(effect.getCreatedAt(), "2018-06-06T10:23:57Z"); assertEquals(effect.getNewSequence(), new Long(79473726952833048L)); } diff --git a/src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java index da650407b..a5b722b5a 100644 --- a/src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java @@ -20,7 +20,7 @@ public void testDeserialize() { AccountCreatedEffectResponse accountCreatedEffect = (AccountCreatedEffectResponse) effectsPage.getRecords().get(8); assertEquals(accountCreatedEffect.getStartingBalance(), "10000.0"); - assertEquals(accountCreatedEffect.getAccount().getAccountId(), "GDIQJ6G5AWSBRMHIZYWVWCFN64Q4BZ4TYEAQRO5GVR4EWR23RKBJ2A4R"); + assertEquals(accountCreatedEffect.getAccount(), "GDIQJ6G5AWSBRMHIZYWVWCFN64Q4BZ4TYEAQRO5GVR4EWR23RKBJ2A4R"); assertEquals(effectsPage.getLinks().getNext().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&limit=10&cursor=3962163165138945-3"); } diff --git a/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java index 0c9be231e..f357c5c65 100644 --- a/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java @@ -14,10 +14,10 @@ public void testDeserialize() { Page transactionsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType()); assertEquals(transactionsPage.getRecords().get(0).getId(), new Long(241)); - assertEquals(transactionsPage.getRecords().get(0).getSeller().getAccountId(), "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD"); + assertEquals(transactionsPage.getRecords().get(0).getSeller(), "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD"); assertEquals(transactionsPage.getRecords().get(0).getPagingToken(), "241"); - assertEquals(transactionsPage.getRecords().get(0).getSelling(), Asset.createNonNativeAsset("INR", KeyPair.fromAccountId("GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD"))); - assertEquals(transactionsPage.getRecords().get(0).getBuying(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD"))); + assertEquals(transactionsPage.getRecords().get(0).getSelling(), Asset.createNonNativeAsset("INR", "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD")); + assertEquals(transactionsPage.getRecords().get(0).getBuying(), Asset.createNonNativeAsset("USD", "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD")); assertEquals(transactionsPage.getRecords().get(0).getAmount(), "10.0000000"); assertEquals(transactionsPage.getRecords().get(0).getPrice(), "11.0000000"); assertEquals(transactionsPage.getRecords().get(0).getLastModifiedLedger(), new Integer(22200794)); diff --git a/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java index 82b6ae558..e78633f3d 100644 --- a/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java @@ -40,14 +40,14 @@ public void testDeserializeCreateAccountOperation() { "}"; CreateAccountOperationResponse operation = (CreateAccountOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getSourceAccount().getAccountId(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD"); + assertEquals(operation.getSourceAccount(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD"); assertEquals(operation.getPagingToken(), "3936840037961729"); assertEquals(operation.getId(), new Long(3936840037961729L)); assertNull(operation.isTransactionSuccessful()); - assertEquals(operation.getAccount().getAccountId(), "GAR4DDXYNSN2CORG3XQFLAPWYKTUMLZYHYWV4Y2YJJ4JO6ZJFXMJD7PT"); + assertEquals(operation.getAccount(), "GAR4DDXYNSN2CORG3XQFLAPWYKTUMLZYHYWV4Y2YJJ4JO6ZJFXMJD7PT"); assertEquals(operation.getStartingBalance(), "299454.904954"); - assertEquals(operation.getFunder().getAccountId(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD"); + assertEquals(operation.getFunder(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD"); assertEquals(operation.getLinks().getEffects().getHref(), "/operations/3936840037961729/effects{?cursor,limit,order}"); assertEquals(operation.getLinks().getPrecedes().getHref(), "/operations?cursor=3936840037961729&order=asc"); @@ -90,12 +90,12 @@ public void testDeserializePaymentOperation() { " }"; PaymentOperationResponse operation = (PaymentOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getSourceAccount().getAccountId(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ"); + assertEquals(operation.getSourceAccount(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ"); assertEquals(operation.getId(), new Long(3940808587743233L)); assertEquals(operation.isTransactionSuccessful(), new Boolean(false)); - assertEquals(operation.getFrom().getAccountId(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ"); - assertEquals(operation.getTo().getAccountId(), "GDWNY2POLGK65VVKIH5KQSH7VWLKRTQ5M6ADLJAYC2UEHEBEARCZJWWI"); + assertEquals(operation.getFrom(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ"); + assertEquals(operation.getTo(), "GDWNY2POLGK65VVKIH5KQSH7VWLKRTQ5M6ADLJAYC2UEHEBEARCZJWWI"); assertEquals(operation.getAmount(), "100.0"); assertEquals(operation.getAsset(), new AssetTypeNative()); } @@ -138,10 +138,10 @@ public void testDeserializeNonNativePaymentOperation() { assertEquals(operation.isTransactionSuccessful(), new Boolean(true)); - assertEquals(operation.getFrom().getAccountId(), "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA"); - assertEquals(operation.getTo().getAccountId(), "GBHUSIZZ7FS2OMLZVZ4HLWJMXQ336NFSXHYERD7GG54NRITDTEWWBBI6"); + assertEquals(operation.getFrom(), "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA"); + assertEquals(operation.getTo(), "GBHUSIZZ7FS2OMLZVZ4HLWJMXQ336NFSXHYERD7GG54NRITDTEWWBBI6"); assertEquals(operation.getAmount(), "1000000000.0"); - assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA"))); + assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")); } @Test @@ -179,10 +179,10 @@ public void testDeserializeAllowTrustOperation() { AllowTrustOperationResponse operation = (AllowTrustOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getTrustee().getAccountId(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM"); - assertEquals(operation.getTrustor().getAccountId(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F"); + assertEquals(operation.getTrustee(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM"); + assertEquals(operation.getTrustor(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F"); assertEquals(operation.isAuthorize(), true); - assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM"))); + assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM")); } @Test @@ -220,10 +220,10 @@ public void testDeserializeChangeTrustOperation() { ChangeTrustOperationResponse operation = (ChangeTrustOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getTrustee().getAccountId(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM"); - assertEquals(operation.getTrustor().getAccountId(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F"); + assertEquals(operation.getTrustee(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM"); + assertEquals(operation.getTrustor(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F"); assertEquals(operation.getLimit(), "922337203685.4775807"); - assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM"))); + assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM")); } @Test @@ -273,7 +273,7 @@ public void testDeserializeSetOptionsOperation() { assertEquals(operation.getSignerKey(), "GD3ZYXVC7C3ECD5I4E5NGPBFJJSULJ6HJI2FBHGKYFV34DSIWB4YEKJZ"); assertEquals(operation.getSignerWeight(), new Integer(1)); assertEquals(operation.getHomeDomain(), "stellar.org"); - assertEquals(operation.getInflationDestination().getAccountId(), "GBYWSY4NPLLPTP22QYANGTT7PEHND64P4D4B6LFEUHGUZRVYJK2H4TBE"); + assertEquals(operation.getInflationDestination(), "GBYWSY4NPLLPTP22QYANGTT7PEHND64P4D4B6LFEUHGUZRVYJK2H4TBE"); assertEquals(operation.getLowThreshold(), new Integer(1)); assertEquals(operation.getMedThreshold(), new Integer(2)); assertEquals(operation.getHighThreshold(), new Integer(3)); @@ -355,8 +355,8 @@ public void testDeserializeAccountMergeOperation() { AccountMergeOperationResponse operation = (AccountMergeOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getAccount().getAccountId(), "GD6GKRABNDVYDETEZJQEPS7IBQMERCN44R5RCI4LJNX6BMYQM2KPGGZ2"); - assertEquals(operation.getInto().getAccountId(), "GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN"); + assertEquals(operation.getAccount(), "GD6GKRABNDVYDETEZJQEPS7IBQMERCN44R5RCI4LJNX6BMYQM2KPGGZ2"); + assertEquals(operation.getInto(), "GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN"); } @Test @@ -396,7 +396,7 @@ public void testDeserializeManageBuyOfferOperation() { assertEquals(operation.getOfferId(), new Integer(0)); assertEquals(operation.getAmount(), "100.0"); - assertEquals(operation.getBuyingAsset(), Asset.createNonNativeAsset("CNY", KeyPair.fromAccountId("GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN"))); + assertEquals(operation.getBuyingAsset(), Asset.createNonNativeAsset("CNY", "GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN")); assertEquals(operation.getSellingAsset(), new AssetTypeNative()); } @@ -441,13 +441,13 @@ public void testDeserializePathPaymentOperation() { PathPaymentOperationResponse operation = (PathPaymentOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getFrom().getAccountId(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); - assertEquals(operation.getTo().getAccountId(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); + assertEquals(operation.getFrom(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); + assertEquals(operation.getTo(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); assertEquals(operation.getAmount(), "2.5000000"); assertEquals(operation.getSourceAmount(), "1.1777000"); assertEquals(operation.getSourceMax(), "1.1779523"); assertEquals(operation.getAsset(), new AssetTypeNative()); - assertEquals(operation.getSourceAsset(), Asset.createNonNativeAsset("XRP", KeyPair.fromAccountId("GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5"))); + assertEquals(operation.getSourceAsset(), Asset.createNonNativeAsset("XRP", "GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5")); } @Test @@ -490,12 +490,12 @@ public void testDeserializePathPaymentOperationSourceAssetNative() { PathPaymentOperationResponse operation = (PathPaymentOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class); - assertEquals(operation.getFrom().getAccountId(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); - assertEquals(operation.getTo().getAccountId(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); + assertEquals(operation.getFrom(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); + assertEquals(operation.getTo(), "GC45JH537XZD4DY4WTV5PCUJL4KPOIE4WMGX5OP5KSPS2OLGRUOVVIGD"); assertEquals(operation.getAmount(), "2.5000000"); assertEquals(operation.getSourceMax(), "1.1779523"); assertEquals(operation.getSourceAsset(), new AssetTypeNative()); - assertEquals(operation.getAsset(), Asset.createNonNativeAsset("XRP", KeyPair.fromAccountId("GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5"))); + assertEquals(operation.getAsset(), Asset.createNonNativeAsset("XRP", "GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5")); } @Test diff --git a/src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java index dfd8e02df..e06464410 100644 --- a/src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java @@ -18,16 +18,16 @@ public void testDeserialize() { CreateAccountOperationResponse createAccountOperation = (CreateAccountOperationResponse) operationsPage.getRecords().get(0); assertEquals(createAccountOperation.getStartingBalance(), "10000.0"); assertEquals(createAccountOperation.getPagingToken(), "3717508943056897"); - assertEquals(createAccountOperation.getAccount().getAccountId(), "GDFH4NIYMIIAKRVEJJZOIGWKXGQUF3XHJG6ZM6CEA64AMTVDN44LHOQE"); - assertEquals(createAccountOperation.getFunder().getAccountId(), "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K"); + assertEquals(createAccountOperation.getAccount(), "GDFH4NIYMIIAKRVEJJZOIGWKXGQUF3XHJG6ZM6CEA64AMTVDN44LHOQE"); + assertEquals(createAccountOperation.getFunder(), "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K"); assertEquals(createAccountOperation.getCreatedAt(), "2018-01-22T21:30:53Z"); assertEquals(createAccountOperation.getTransactionHash(), "dd9d10c80a344f4464df3ecaa63705a5ef4a0533ff2f2099d5ef371ab5e1c046"); PaymentOperationResponse paymentOperation = (PaymentOperationResponse) operationsPage.getRecords().get(4); assertEquals(paymentOperation.getAmount(), "10.123"); TestCase.assertEquals(paymentOperation.getAsset(), new AssetTypeNative()); - assertEquals(paymentOperation.getFrom().getAccountId(), "GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R"); - assertEquals(paymentOperation.getTo().getAccountId(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"); + assertEquals(paymentOperation.getFrom(), "GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R"); + assertEquals(paymentOperation.getTo(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"); } String json = "{\n" + diff --git a/src/test/java/org/stellar/sdk/responses/OrderBookDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OrderBookDeserializerTest.java index aaae7582b..25f69f038 100644 --- a/src/test/java/org/stellar/sdk/responses/OrderBookDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/OrderBookDeserializerTest.java @@ -12,7 +12,7 @@ public void testDeserialize() { OrderBookResponse orderBook = GsonSingleton.getInstance().fromJson(json, OrderBookResponse.class); assertEquals(orderBook.getBase(), new AssetTypeNative()); - assertEquals(orderBook.getCounter(), Asset.createNonNativeAsset("DEMO", KeyPair.fromAccountId("GBAMBOOZDWZPVV52RCLJQYMQNXOBLOXWNQAY2IF2FREV2WL46DBCH3BE"))); + assertEquals(orderBook.getCounter(), Asset.createNonNativeAsset("DEMO", "GBAMBOOZDWZPVV52RCLJQYMQNXOBLOXWNQAY2IF2FREV2WL46DBCH3BE")); assertEquals(orderBook.getBids()[0].getAmount(), "31.4007644"); assertEquals(orderBook.getBids()[0].getPrice(), "0.0024224"); diff --git a/src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java index 6e632b5af..fd522b564 100644 --- a/src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java @@ -24,25 +24,25 @@ public void testDeserialize() throws IOException, URISyntaxException { assertNull(pathsPage.getNextPage(new OkHttpClient())); assertEquals(pathsPage.getRecords().get(0).getDestinationAmount(), "20.0000000"); - Assert.assertEquals(pathsPage.getRecords().get(0).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN"))); + Assert.assertEquals(pathsPage.getRecords().get(0).getDestinationAsset(), Asset.createNonNativeAsset("EUR", "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")); assertEquals(pathsPage.getRecords().get(0).getPath().size(), 0); assertEquals(pathsPage.getRecords().get(0).getSourceAmount(), "30.0000000"); - assertEquals(pathsPage.getRecords().get(0).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN"))); + assertEquals(pathsPage.getRecords().get(0).getSourceAsset(), Asset.createNonNativeAsset("USD", "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")); assertEquals(pathsPage.getRecords().get(1).getDestinationAmount(), "50.0000000"); - assertEquals(pathsPage.getRecords().get(1).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GBFMFKDUFYYITWRQXL4775CVUV3A3WGGXNJUAP4KTXNEQ2HG7JRBITGH"))); + assertEquals(pathsPage.getRecords().get(1).getDestinationAsset(), Asset.createNonNativeAsset("EUR", "GBFMFKDUFYYITWRQXL4775CVUV3A3WGGXNJUAP4KTXNEQ2HG7JRBITGH")); assertEquals(pathsPage.getRecords().get(1).getPath().size(), 1); - assertEquals(pathsPage.getRecords().get(1).getPath().get(0), Asset.createNonNativeAsset("GBP", KeyPair.fromAccountId("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN"))); + assertEquals(pathsPage.getRecords().get(1).getPath().get(0), Asset.createNonNativeAsset("GBP", "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")); assertEquals(pathsPage.getRecords().get(1).getSourceAmount(), "60.0000000"); - assertEquals(pathsPage.getRecords().get(1).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GBRAOXQDNQZRDIOK64HZI4YRDTBFWNUYH3OIHQLY4VEK5AIGMQHCLGXI"))); + assertEquals(pathsPage.getRecords().get(1).getSourceAsset(), Asset.createNonNativeAsset("USD", "GBRAOXQDNQZRDIOK64HZI4YRDTBFWNUYH3OIHQLY4VEK5AIGMQHCLGXI")); assertEquals(pathsPage.getRecords().get(2).getDestinationAmount(), "200.0000000"); - assertEquals(pathsPage.getRecords().get(2).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GBRCOBK7C7UE72PB5JCPQU3ZI45ZCEM7HKQ3KYV3YD3XB7EBOPBEDN2G"))); + assertEquals(pathsPage.getRecords().get(2).getDestinationAsset(), Asset.createNonNativeAsset("EUR", "GBRCOBK7C7UE72PB5JCPQU3ZI45ZCEM7HKQ3KYV3YD3XB7EBOPBEDN2G")); assertEquals(pathsPage.getRecords().get(2).getPath().size(), 2); - assertEquals(pathsPage.getRecords().get(2).getPath().get(0), Asset.createNonNativeAsset("GBP", KeyPair.fromAccountId("GAX7B3ZT3EOZW5POAMV4NGPPKCYUOYW2QQDIAF23JAXF72NMGRYPYOPM"))); - assertEquals(pathsPage.getRecords().get(2).getPath().get(1), Asset.createNonNativeAsset("PLN", KeyPair.fromAccountId("GACWIA2XGDFWWN3WKPX63JTK4S2J5NDPNOIVYMZY6RVTS7LWF2VHZLV3"))); + assertEquals(pathsPage.getRecords().get(2).getPath().get(0), Asset.createNonNativeAsset("GBP", "GAX7B3ZT3EOZW5POAMV4NGPPKCYUOYW2QQDIAF23JAXF72NMGRYPYOPM")); + assertEquals(pathsPage.getRecords().get(2).getPath().get(1), Asset.createNonNativeAsset("PLN", "GACWIA2XGDFWWN3WKPX63JTK4S2J5NDPNOIVYMZY6RVTS7LWF2VHZLV3")); assertEquals(pathsPage.getRecords().get(2).getSourceAmount(), "300.0000000"); - assertEquals(pathsPage.getRecords().get(2).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GC7J5IHS3GABSX7AZLRINXWLHFTL3WWXLU4QX2UGSDEAIAQW2Q72U3KH"))); + assertEquals(pathsPage.getRecords().get(2).getSourceAsset(), Asset.createNonNativeAsset("USD", "GC7J5IHS3GABSX7AZLRINXWLHFTL3WWXLU4QX2UGSDEAIAQW2Q72U3KH")); } String json = "{\n" + diff --git a/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java index b7c5e0475..3dae35d2f 100644 --- a/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java @@ -23,11 +23,11 @@ public void testDeserialize() { assertEquals(tradesPage.getRecords().get(0).getBaseOfferId(), "10"); assertEquals(tradesPage.getRecords().get(0).getCounterOfferId(), "11"); assertEquals(tradesPage.getRecords().get(0).getBaseAsset(), new AssetTypeNative()); - assertEquals(tradesPage.getRecords().get(0).getCounterAsset(), Asset.createNonNativeAsset("JPY", KeyPair.fromAccountId("GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM"))); + assertEquals(tradesPage.getRecords().get(0).getCounterAsset(), Asset.createNonNativeAsset("JPY", "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM")); assertEquals(tradesPage.getRecords().get(0).getPrice().getNumerator(), 267); assertEquals(tradesPage.getRecords().get(0).getPrice().getDenominator(), 1000); - assertEquals(tradesPage.getRecords().get(1).getBaseAccount().getAccountId(), "GAVH5JM5OKXGMQDS7YPRJ4MQCPXJUGH26LYQPQJ4SOMOJ4SXY472ZM7G"); + assertEquals(tradesPage.getRecords().get(1).getBaseAccount(), "GAVH5JM5OKXGMQDS7YPRJ4MQCPXJUGH26LYQPQJ4SOMOJ4SXY472ZM7G"); } String json = "{\n" + diff --git a/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java index 4d4b246e4..00eb0371a 100644 --- a/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java @@ -15,7 +15,7 @@ public void testDeserialize() { assertEquals(transaction.getCreatedAt(), "2015-11-20T17:01:28Z"); assertEquals(transaction.getPagingToken(), "3933090531512320"); assertEquals(transaction.isSuccessful(), new Boolean(true)); - assertEquals(transaction.getSourceAccount().getAccountId(), "GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK"); + assertEquals(transaction.getSourceAccount(), "GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK"); assertEquals(transaction.getSourceAccountSequence(), new Long(2373051035426646L)); assertEquals(transaction.getFeePaid(), new Long(100)); assertEquals(transaction.getOperationCount(), new Integer(1)); diff --git a/src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java index a0322fdd1..1d8db01a1 100644 --- a/src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java @@ -12,13 +12,13 @@ public class TransactionPageDeserializerTest extends TestCase { public void testDeserialize() { Page transactionsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType()); - assertEquals(transactionsPage.getRecords().get(0).getSourceAccount().getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); + assertEquals(transactionsPage.getRecords().get(0).getSourceAccount(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); assertEquals(transactionsPage.getRecords().get(0).getPagingToken(), "12884905984"); assertTrue(transactionsPage.getRecords().get(0).getMemo() instanceof MemoText); MemoText memoText = (MemoText) transactionsPage.getRecords().get(0).getMemo(); assertEquals(memoText.getText(), "hello world"); assertEquals(transactionsPage.getRecords().get(0).getLinks().getAccount().getHref(), "/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); - assertEquals(transactionsPage.getRecords().get(9).getSourceAccount().getAccountId(), "GAENIE5LBJIXLMJIAJ7225IUPA6CX7EGHUXRX5FLCZFFAQSG2ZUYSWFK"); + assertEquals(transactionsPage.getRecords().get(9).getSourceAccount(), "GAENIE5LBJIXLMJIAJ7225IUPA6CX7EGHUXRX5FLCZFFAQSG2ZUYSWFK"); // Empty memo_text assertTrue(transactionsPage.getRecords().get(2).getMemo() instanceof MemoText); From 0cb3c7eee4ec8e227453981505beb0c47bf3c2cb Mon Sep 17 00:00:00 2001 From: Tamir Sen Date: Tue, 16 Jul 2019 08:41:19 +0300 Subject: [PATCH 2/2] Bump version --- CHANGELOG.md | 5 +++++ build.gradle | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6304303b..6acf56f77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ As this project is pre 1.0, breaking changes may happen for minor version bumps. A breaking change will get clearly notified in this log. +## 0.9.0 +* Use strings to represent account ids instead of KeyPair instances because account ids will not necessarily be valid + public keys. If you try to parse an invalid public key into a KeyPair you will encounter an exception. To prevent + exceptions when parsing horizon responses it is better to represent account ids as strings + ## 0.8.0 * Removed deprecated methods and classes listed in the 0.7.0 changelog entry diff --git a/build.gradle b/build.gradle index 8f834c237..62348dd21 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'com.github.ben-manes.versions' // gradle dependencyUpdates -Drevi apply plugin: 'project-report' // gradle htmlDependencyReport sourceCompatibility = 1.6 -version = '0.7.0' +version = '0.9.0' group = 'stellar' jar {