Skip to content

Commit

Permalink
Added to Tonlib:
Browse files Browse the repository at this point in the history
 getRawAccountStatus()
 tryLocateTxByOutcomingMessage()
 tryLocateTxByIncomingMessage();
 V4R2 wallet has now sendTonCoins method;
  • Loading branch information
neodix42 committed Mar 12, 2023
1 parent 8b9cec3 commit efa1511
Show file tree
Hide file tree
Showing 23 changed files with 353 additions and 64 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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</dependency>
```

Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>address</artifactId>
<version>0.1.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</dependency>
```

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>bitstring</artifactId>
<version>0.1.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</dependency>
```

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>cell</artifactId>
<version>0.1.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</dependency>
```

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>mnemonic</artifactId>
<version>0.1.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</dependency>
```

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>io.github.neodix42.ton4j</groupId>
<artifactId>smartcontract</artifactId>
<version>0.1.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ public enum WalletVersion {
/**
* reserved for internal usage
*/
config("Config");
config("Config"),
/**
* reserved for internal usage
*/
unidentified("Unidentified");

private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public <T extends Contract> T create() {
case multisig -> new MultisigWallet(options);
case master -> throw new Error("not implemented");
case config -> throw new Error("not implemented");
case unidentified -> throw new Error("not implemented");
};

return (T) result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,109 @@ private SubscriptionInfo parseSubscriptionData(List subscriptionData) {
.subscriptionId(subscriptionId.getNumber().longValue())
.build();
}


/**
* Sends amount of toncoins to destination address using auto-fetched seqno without the body and default send-mode 3
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount) {
long seqno = getSeqno(tonlib);
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno);
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}

/**
* Sends amount of toncoins to destination address using specified seqno with the body and default send-mode 3
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
* @param body byte[]
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount, long seqno, byte[] body) {
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno, body);
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}

/**
* Sends amount of toncoins to destination address using specified seqno with the body and specified send-mode
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
* @param body byte[]
* @param sendMode byte
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount, long seqno, byte[] body, byte sendMode) {
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno, body, sendMode);
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}

/**
* Sends amount of toncoins to destination address using auto-fetched seqno with the body and default send-mode 3
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
* @param body byte[]
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount, byte[] body) {
long seqno = getSeqno(tonlib);
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno, body);
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}

/**
* Sends amount of toncoins to destination address using specified seqno with the comment and default send-mode 3
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
* @param seqno long
* @param comment String
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount, long seqno, String comment) {
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno, CellBuilder.beginCell().storeUint(0, 32).storeString(comment).endCell());
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}

/**
* Sends amount of toncoins to destination address using auto-fetched seqno without the body and default send-mode 3
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
* @param comment String
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount, String comment) {
long seqno = getSeqno(tonlib);
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno, CellBuilder.beginCell().storeUint(0, 32).storeString(comment).endCell());
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}

/**
* Sends amount of toncoins to destination address using auto-fetched seqno with the body and specified send-mode
*
* @param tonlib Tonlib
* @param secretKey byte[]
* @param destinationAddress Address
* @param amount BigInteger
* @param body byte[]
* @param sendMode byte
*/
public void sendTonCoins(Tonlib tonlib, byte[] secretKey, Address destinationAddress, BigInteger amount, byte[] body, byte sendMode) {
long seqno = getSeqno(tonlib);
ExternalMessage msg = createTransferMessage(secretKey, destinationAddress, amount, seqno, body, sendMode);
tonlib.sendRawMessage(msg.message.toBocBase64(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.ton.java.smartcontract.TestFaucet.FAUCET_ADDRESS_RAW;

@Slf4j
@RunWith(JUnit4.class)
Expand All @@ -49,8 +50,7 @@ public void testPlugins() throws InterruptedException {
.build())
.build();

Wallet wallet = new Wallet(WalletVersion.V4R2, options);
WalletV4ContractR2 contract = wallet.create();
WalletV4ContractR2 contract = new Wallet(WalletVersion.V4R2, options).create();

InitExternalMessage msg = contract.createInitExternalMessage(keyPair.getSecretKey());
Address walletAddress = msg.address;
Expand Down Expand Up @@ -233,5 +233,7 @@ public void testPlugins() throws InterruptedException {
List<String> list = contract.getPluginsList(tonlib);
log.info("pluginsList: {}", list);
assertThat(list.isEmpty()).isTrue();

contract.sendTonCoins(tonlib, keyPair.getSecretKey(), Address.of(FAUCET_ADDRESS_RAW), Utils.toNano(0.33));
}
}
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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</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.2</version>
<version>0.1.3</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Loading

0 comments on commit efa1511

Please sign in to comment.