diff --git a/src/main/java/org/stellar/sdk/Auth.java b/src/main/java/org/stellar/sdk/Auth.java index 4804af774..c82d8ced5 100644 --- a/src/main/java/org/stellar/sdk/Auth.java +++ b/src/main/java/org/stellar/sdk/Auth.java @@ -199,7 +199,8 @@ public static SorobanAuthorizationEntry authorizeEntry( } // This structure is defined here: - // https://soroban.stellar.org/docs/fundamentals-and-concepts/invoking-contracts-with-transactions#stellar-account-signatures + // https://developers.stellar.org/docs/learn/encyclopedia/contract-development/contract-interactions/stellar-transaction#stellar-account-signatures + // https://github.com/stellar/rs-soroban-env/blob/99d8c92cdc7e5cd0f5311df8f88d04658ecde7d2/soroban-env-host/src/native_contract/account_contract.rs#L51 SCVal sigScVal = Scv.toMap( new LinkedHashMap() { diff --git a/src/main/java/org/stellar/sdk/LiquidityPoolID.java b/src/main/java/org/stellar/sdk/LiquidityPoolID.java index 20372f5ab..978a4ffb0 100644 --- a/src/main/java/org/stellar/sdk/LiquidityPoolID.java +++ b/src/main/java/org/stellar/sdk/LiquidityPoolID.java @@ -3,6 +3,7 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; +// TODO: make this one protected? expose it as String? /** * Represents a Liquidity Pool ID on the Stellar network. * diff --git a/src/main/java/org/stellar/sdk/exception/FormatException.java b/src/main/java/org/stellar/sdk/exception/FormatException.java index 187f12cca..d3de4be8c 100644 --- a/src/main/java/org/stellar/sdk/exception/FormatException.java +++ b/src/main/java/org/stellar/sdk/exception/FormatException.java @@ -2,6 +2,7 @@ import org.stellar.sdk.KeyPair; +// TODO: remove the exception class? /** * Indicates that there was a problem decoding strkey encoded string. * diff --git a/src/test/java/org/stellar/sdk/AssetTest.java b/src/test/java/org/stellar/sdk/AssetTest.java index 25efa3e6e..22c31649e 100644 --- a/src/test/java/org/stellar/sdk/AssetTest.java +++ b/src/test/java/org/stellar/sdk/AssetTest.java @@ -2,10 +2,11 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.stellar.sdk.Asset.create; +import static org.stellar.sdk.Asset.createNativeAsset; +import static org.stellar.sdk.Asset.createNonNativeAsset; import java.io.IOException; import java.util.Arrays; @@ -15,7 +16,7 @@ /** Created by andrewrogers on 7/1/15. */ public class AssetTest { - Asset xlm = create("native"); + Asset xlm = createNativeAsset(); @Test public void testAssetTypeNative() { @@ -92,35 +93,33 @@ public void testAssetEquals() { 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))); - assertTrue( - new AssetTypeCreditAlphaNum12("ABCDE", issuer1) - .equals(new AssetTypeCreditAlphaNum12("ABCDE", issuer1))); - - assertFalse(new AssetTypeNative().equals(new AssetTypeCreditAlphaNum4("USD", issuer1))); - assertFalse(new AssetTypeNative().equals(new AssetTypeCreditAlphaNum12("ABCDE", issuer1))); - assertFalse( - new AssetTypeCreditAlphaNum4("EUR", issuer1) - .equals(new AssetTypeCreditAlphaNum4("USD", issuer1))); - assertFalse( - new AssetTypeCreditAlphaNum4("EUR", issuer1) - .equals(new AssetTypeCreditAlphaNum4("EUR", issuer2))); - assertFalse( - new AssetTypeCreditAlphaNum12("ABCDE", issuer1) - .equals(new AssetTypeCreditAlphaNum12("EDCBA", issuer1))); - assertFalse( - new AssetTypeCreditAlphaNum12("ABCDE", issuer1) - .equals(new AssetTypeCreditAlphaNum12("ABCDE", issuer2))); + assertEquals(new AssetTypeNative(), new AssetTypeNative()); + assertEquals( + new AssetTypeCreditAlphaNum4("USD", issuer1), new AssetTypeCreditAlphaNum4("USD", issuer1)); + assertEquals( + new AssetTypeCreditAlphaNum12("ABCDE", issuer1), + new AssetTypeCreditAlphaNum12("ABCDE", issuer1)); + + assertNotEquals(new AssetTypeNative(), new AssetTypeCreditAlphaNum4("USD", issuer1)); + assertNotEquals(new AssetTypeNative(), new AssetTypeCreditAlphaNum12("ABCDE", issuer1)); + assertNotEquals( + new AssetTypeCreditAlphaNum4("EUR", issuer1), new AssetTypeCreditAlphaNum4("USD", issuer1)); + assertNotEquals( + new AssetTypeCreditAlphaNum4("EUR", issuer1), new AssetTypeCreditAlphaNum4("EUR", issuer2)); + assertNotEquals( + new AssetTypeCreditAlphaNum12("ABCDE", issuer1), + new AssetTypeCreditAlphaNum12("EDCBA", issuer1)); + assertNotEquals( + new AssetTypeCreditAlphaNum12("ABCDE", issuer1), + new AssetTypeCreditAlphaNum12("ABCDE", issuer2)); } @Test public void testAssetCompareTo0IfAssetsEqual() { - Asset assetA = create(null, "ARST", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); - - Asset assetB = create(null, "USD", "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"); + Asset assetA = + createNonNativeAsset("ARST", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + Asset assetB = + createNonNativeAsset("USD", "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"); assertEquals(0, xlm.compareTo(xlm)); assertEquals(0, assetA.compareTo(assetA)); @@ -129,9 +128,11 @@ public void testAssetCompareTo0IfAssetsEqual() { @Test public void testAssetCompareToOrderingByType() { - Asset anum4 = create(null, "ARSZ", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + Asset anum4 = + createNonNativeAsset("ARSZ", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); Asset anum12 = - create(null, "ARSTANUM12", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + createNonNativeAsset( + "ARSTANUM12", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); assertEquals(0, xlm.compareTo(xlm)); assertEquals(-1, xlm.compareTo(anum4)); @@ -149,9 +150,9 @@ public void testAssetCompareToOrderingByType() { @Test public void testAssetCompareToOrderingByCode() { Asset assetARST = - create(null, "ARST", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + createNonNativeAsset("ARST", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); Asset assetUSDX = - create(null, "USDX", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + createNonNativeAsset("USDX", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); assertEquals(0, assetARST.compareTo(assetARST)); assertTrue(assetARST.compareTo(assetUSDX) < 0); @@ -163,10 +164,9 @@ public void testAssetCompareToOrderingByCode() { @Test public void testAssetCompareToOrderingByIssuer() { Asset assetIssuerA = - create( - null, new String("ARST"), "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + createNonNativeAsset("ARST", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); Asset assetIssuerB = - create(null, "ARST", "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"); + createNonNativeAsset("ARST", "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"); assertTrue(assetIssuerA.compareTo(assetIssuerB) < 0); assertEquals(0, assetIssuerA.compareTo(assetIssuerA)); @@ -180,18 +180,20 @@ public void testAssetsAreSortable() { // Native is always first Asset a = create("native"); // Type is Alphanum4 - Asset b = create(null, "BCDE", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + Asset b = + createNonNativeAsset("BCDE", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); // Type is Alphanum12 - Asset c = create(null, "ABCD1", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + Asset c = + createNonNativeAsset("ABCD1", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); // Code is > Asset d = - create( - null, new String("ABCD2"), "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); + createNonNativeAsset("ABCD2", "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO"); // Issuer is > - Asset e = create(null, "ABCD2", "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"); + Asset e = + createNonNativeAsset("ABCD2", "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"); Asset[] expected = {a, b, c, d, e}; diff --git a/src/test/java/org/stellar/sdk/FeeBumpTransactionTest.java b/src/test/java/org/stellar/sdk/FeeBumpTransactionTest.java index df12cd13b..807e5bc27 100644 --- a/src/test/java/org/stellar/sdk/FeeBumpTransactionTest.java +++ b/src/test/java/org/stellar/sdk/FeeBumpTransactionTest.java @@ -22,7 +22,6 @@ import org.stellar.sdk.xdr.LedgerEntryType; import org.stellar.sdk.xdr.LedgerFootprint; import org.stellar.sdk.xdr.LedgerKey; -import org.stellar.sdk.xdr.SignerKey; import org.stellar.sdk.xdr.SorobanResources; import org.stellar.sdk.xdr.SorobanTransactionData; import org.stellar.sdk.xdr.Uint256; @@ -331,8 +330,7 @@ public void testCreateWithBaseFeeWithSorobanOp() { account.getIncrementedSequenceNumber(), new org.stellar.sdk.operations.Operation[] {invokeHostFunctionOperation}, null, - new TransactionPreconditions( - null, null, BigInteger.ZERO, 0, new ArrayList(), null), + new TransactionPreconditions(null, null, BigInteger.ZERO, 0, new ArrayList<>(), null), sorobanData, Network.TESTNET);