Skip to content

Commit

Permalink
chore: update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Aug 3, 2024
1 parent ecd2fd6 commit a8bea1e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 43 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/stellar/sdk/Auth.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<SCVal, SCVal>() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/stellar/sdk/LiquidityPoolID.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.stellar.sdk.KeyPair;

// TODO: remove the exception class?
/**
* Indicates that there was a problem decoding strkey encoded string.
*
Expand Down
80 changes: 41 additions & 39 deletions src/test/java/org/stellar/sdk/AssetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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};

Expand Down
4 changes: 1 addition & 3 deletions src/test/java/org/stellar/sdk/FeeBumpTransactionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<SignerKey>(), null),
new TransactionPreconditions(null, null, BigInteger.ZERO, 0, new ArrayList<>(), null),
sorobanData,
Network.TESTNET);

Expand Down

0 comments on commit a8bea1e

Please sign in to comment.