Skip to content

Commit

Permalink
added getRawTransactions with limit;
Browse files Browse the repository at this point in the history
fixed getAllRawTransactions historyLimit;
AccountState now includes wallet_id and seqno fo generic purposes;
Tonlib types are made serializable;
Refactoring, synthetic sugar, documentation;
  • Loading branch information
neodix42 committed Mar 8, 2023
1 parent 89bad30 commit 8b9cec3
Show file tree
Hide file tree
Showing 74 changed files with 427 additions and 105 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Do not forget to place tonlibjson library to your project. Latest Tonlib librari
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>smartcontract</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -32,7 +32,7 @@ Do not forget to place tonlibjson library to your project. Latest Tonlib librari
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>ton4j</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions address/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>address</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>address</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion address/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.neodix42</groupId>
<artifactId>top</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions bitstring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>bitstring</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>bitstring</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion bitstring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.neodix42</groupId>
<artifactId>top</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions cell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>cell</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>cell</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion cell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.neodix42</groupId>
<artifactId>top</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
4 changes: 2 additions & 2 deletions mnemonic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>mnemonic</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>mnemonic</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion mnemonic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>top</artifactId>
<groupId>io.github.neodix42</groupId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
12 changes: 12 additions & 0 deletions mnemonic/src/test/java/org/ton/java/mnemonic/TestMnemonic.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public void testMnemonicWithPassword() throws NoSuchAlgorithmException, InvalidK

@Test
public void testMnemonicValidation() throws NoSuchAlgorithmException, InvalidKeyException {

assertThat(Mnemonic.isValid(List.of("audit", "magic", "blossom", "digital", "dad", "buffalo", "river", "junior", "minimum", "congress", "banner", "garage", "flag", "tuna", "onion", "pair", "balance", "spice", "reason", "gossip", "cotton", "stock", "skate", "faith"), "")).isTrue();
assertThat(Mnemonic.isValid(List.of("kangaroo", "hen", "toddler", "resist"), "")).isTrue();
assertThat(Mnemonic.isValid(List.of("disease", "adult", "device", "grit"), "")).isTrue();

Expand Down Expand Up @@ -75,4 +77,14 @@ public void testMnemonicSeed2() throws NoSuchAlgorithmException, InvalidKeyExcep
byte[] res = Mnemonic.hmacSha512(key, data);
System.out.println(bytesToHex(res));
}

@Test
public void testMnemonicToKeyPair() throws NoSuchAlgorithmException, InvalidKeyException {

Pair key = Mnemonic.toKeyPair(List.of("audit", "magic", "blossom", "digital", "dad", "buffalo", "river",
"junior", "minimum", "congress", "banner", "garage", "flag", "tuna", "onion", "pair", "balance", "spice",
"reason", "gossip", "cotton", "stock", "skate", "faith"));
System.out.println(bytesToHex(key.getPublicKey()));
System.out.println(bytesToHex(key.getSecretKey()));
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.github.neodix42</groupId>
<artifactId>top</artifactId>
<packaging>pom</packaging>
<version>0.1.1</version>
<version>0.1.2</version>

<modules>
<module>bitstring</module>
Expand Down
4 changes: 2 additions & 2 deletions smartcontract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>smartcontract</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>smartcontract</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion smartcontract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.neodix42</groupId>
<artifactId>top</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import org.ton.java.smartcontract.wallet.Wallet;
import org.ton.java.smartcontract.wallet.v1.WalletV1ContractR3;
import org.ton.java.tonlib.Tonlib;
import org.ton.java.tonlib.types.VerbosityLevel;
import org.ton.java.utils.Utils;

import java.math.BigInteger;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.ton.java.utils.Utils.formatNanoValue;

@Slf4j
@RunWith(JUnit4.class)
Expand All @@ -25,7 +27,10 @@ public class TestWalletV1R3DeployTransferShort {
@Test
public void testNewWalletV1R3() throws InterruptedException {

Tonlib tonlib = Tonlib.builder().testnet(true).build();
Tonlib tonlib = Tonlib.builder()
.testnet(true)
.verbosityLevel(VerbosityLevel.DEBUG)
.build();

TweetNaclFast.Signature.KeyPair keyPair = Utils.generateSignatureKeyPair();

Expand All @@ -39,10 +44,12 @@ public void testNewWalletV1R3() throws InterruptedException {

log.info("non-bounceable address {}", nonBounceableAddress);
log.info(" bounceable address {}", bounceableAddress);
String status = tonlib.getAccountStatus(Address.of(bounceableAddress));
log.info("account status {}", status);

// top up new wallet using test-faucet-wallet
BigInteger balance = TestFaucet.topUpContract(tonlib, Address.of(nonBounceableAddress), Utils.toNano(1));
log.info("new wallet {} balance: {}", contract.getName(), Utils.formatNanoValue(balance));
log.info("new wallet {} balance: {}", contract.getName(), formatNanoValue(balance));

contract.deploy(tonlib, keyPair.getSecretKey());

Expand All @@ -54,7 +61,9 @@ public void testNewWalletV1R3() throws InterruptedException {
Utils.sleep(30);

balance = new BigInteger(tonlib.getAccountState(Address.of(bounceableAddress)).getBalance());
log.info("new wallet {} balance: {}", contract.getName(), Utils.formatNanoValue(balance));
status = tonlib.getAccountStatus(Address.of(bounceableAddress));
log.info("new wallet {} with status {} and balance: {}", contract.getName(), status, formatNanoValue(balance));

assertThat(balance.longValue()).isLessThan(Utils.toNano(0.2).longValue());

log.info("seqno {}", contract.getSeqno(tonlib));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.ton.java.smartcontract.wallet.Wallet;
import org.ton.java.smartcontract.wallet.v3.WalletV3ContractR2;
import org.ton.java.tonlib.Tonlib;
import org.ton.java.tonlib.types.VerbosityLevel;
import org.ton.java.utils.Utils;

import java.math.BigInteger;
Expand All @@ -25,7 +26,10 @@ public class TestWalletV3R2DeployTransferShort {
@Test
public void testWalletV3R2() throws InterruptedException {

Tonlib tonlib = Tonlib.builder().testnet(true).build();
Tonlib tonlib = Tonlib.builder()
.testnet(true)
.verbosityLevel(VerbosityLevel.DEBUG)
.build();

TweetNaclFast.Signature.KeyPair keyPair = Utils.generateSignatureKeyPair();

Expand All @@ -42,7 +46,8 @@ public void testWalletV3R2() throws InterruptedException {

log.info("non-bounceable address 1: {}", nonBounceableAddress1);
log.info(" bounceable address 1: {}", bounceableAddress1);

String status = tonlib.getAccountStatus(Address.of(bounceableAddress1));
log.info("account status {}", status);

Options options2 = Options.builder()
.publicKey(keyPair.getPublicKey())
Expand Down
4 changes: 2 additions & 2 deletions tlb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>top</artifactId>
<groupId>io.github.neodix42</groupId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>cell</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions tonlib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Java Tonlib library uses JNA to access methods in native Tonlib shared library.
<dependency>
<groupId>io.github.neodix42</groupId>
<artifactId>tonlib</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand All @@ -18,7 +18,7 @@ Java Tonlib library uses JNA to access methods in native Tonlib shared library.
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>tonlib</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion tonlib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.neodix42</groupId>
<artifactId>top</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Loading

0 comments on commit 8b9cec3

Please sign in to comment.