Skip to content

Commit 534c9d4

Browse files
committed
review HighloadWalletV3 added by krigga; bulk send tests to come.
1 parent 4e22736 commit 534c9d4

File tree

7 files changed

+326
-44
lines changed

7 files changed

+326
-44
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
[![Based on TON][ton-svg]][ton]
55
![GitHub last commit](https://img.shields.io/github/last-commit/neodiX42/ton4j)
66

7-
Java libraries for interacting with TON blockchain.
8-
Do not forget to place tonlibjson library to your project. Latest Tonlib libraries can be found [here](https://github.com/ton-blockchain/ton/actions).
7+
Java libraries for interacting with TON blockchain.
8+
Do not forget to place tonlibjson library to your project. Latest Tonlib libraries can be
9+
found [here](https://github.com/ton-blockchain/ton/actions).
910

1011
## Maven [![Maven Central][maven-central-svg]][maven-central]
1112

1213
```xml
14+
1315
<dependency>
1416
<groupId>io.github.neodix42</groupId>
1517
<artifactId>smartcontract</artifactId>
@@ -20,6 +22,7 @@ Do not forget to place tonlibjson library to your project. Latest Tonlib librari
2022
## Jitpack [![JitPack][jitpack-svg]][jitpack]
2123

2224
```xml
25+
2326
<repositories>
2427
<repository>
2528
<id>jitpack.io</id>
@@ -29,6 +32,7 @@ Do not forget to place tonlibjson library to your project. Latest Tonlib librari
2932
```
3033

3134
```xml
35+
3236
<dependency>
3337
<groupId>io.github.neodix42</groupId>
3438
<artifactId>ton4j</artifactId>
@@ -45,7 +49,7 @@ You can use each submodule individually. Click the module below to get more deta
4549
* [Address](address/README.md) - create and parse TON wallet addresses.
4650
* [Mnemonic](mnemonic/README.md) - helpful methods for generating deterministic keys for TON blockchain.
4751
* [Emulator](emulator/README.md) - wrapper for using with external precompiled emulator shared library.
48-
* [Liteclient](liteclient/README.md) - wrapper for using with external precompiled lite-client binary.
52+
* [Liteclient](liteclient/README.md) - wrapper for using with external precompiled lite-client binary.
4953
* [Utils](utils/README.md) - create private and public keys, convert data, etc.
5054

5155
### Features
@@ -54,18 +58,20 @@ You can use each submodule individually. Click the module below to get more deta
5458
* ✅ Cells serialization / deserialization
5559
* ✅ TL-B serialization / deserialization
5660
* ✅ Cell builder and cell slicer (reader)
57-
* ✅ Tonlib wrapper
61+
* ✅ Tonlib wrapper
5862
* ✅ Support num, cell and slice as arguments for runMethod
5963
* ✅ Render List, Tuple, Slice, Cell and Number results from runMethod
6064
* ✅ Generate or import private key, sign, encrypt and decrypt using Tonlib
6165
* ✅ Encrypt/decrypt with mnemonic
6266
* ✅ Send external message
6367
* ✅ Get block transactions
6468
* ✅ Deploy contracts and send external messages using Tonlib
65-
* ✅ Wallets - Simple (V1), V2, V3, V4 (plugins), Lockup, Highload, DNS, Jetton, NFT, Payment-channels, Multisig
69+
* ✅ Wallets - Simple (V1), V2, V3, V4 (plugins), Lockup, Highload/Highload-V3, DNS, Jetton, NFT, Payment-channels,
70+
Multisig
6671
* ✅ HashMap, HashMapE, PfxHashMap, PfxHashMapE, HashMapAug, HashMapAugE serialization / deserialization
6772

6873
### Todo
74+
6975
* Support tuple and list as arguments for runMethod
7076
* Improve code coverage and add more integration tests
7177
* Add methods to store jettons metadata onchain

smartcontract/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,29 @@ Currently, following wallet versions and revisions are supported:
3030

3131
* V1R1
3232
* V1R2 [(see usage example)](v1r2-example.md)
33-
* V1R3 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV1R3DeployTransfer.java)
34-
* v2R1 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV2R1DeployTransferShort.java)
35-
* v2R2 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV2R2DeployTransferShort.java)
33+
*
34+
V1R3 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV1R3DeployTransfer.java)
35+
*
36+
v2R1 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV2R1DeployTransferShort.java)
37+
*
38+
v2R2 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV2R2DeployTransferShort.java)
3639
* v3R1
37-
* v3R2 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R2DeployTransferShort.java)
40+
*
41+
v3R2 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R2DeployTransferShort.java)
3842
* v4R1
3943
* v4R2 - subscription, plugins [(see usage example)](plugin-example.md)
40-
* Lockup - restricted [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestLockupWalletDeployTransfer.java)
41-
* Highload [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV2Highload.java)
44+
* Lockup -
45+
restricted [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestLockupWalletDeployTransfer.java)
46+
* Highload [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV2Highload.java)
47+
*
48+
Highload-V3 [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestHighloadWalletV3.java)
4249
* Dns [(see usage example)](dns-example.md)
4350
* Jetton [(see usage example)](jetton-example.md)
4451
* NFT [(see usage example)](nft-example.md)
45-
* Payment channels [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestPayments.java)
52+
* Payment channels [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestPayments.java)
4653
* Multisig [(see usage example)](./src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletMultisig.java)
4754
* Custom contract [(see usage example)](custom-smc-example.md)
4855

49-
5056
More examples on how to work with [smart-contracts](../smartcontract/src/main/java/org/ton/java/smartcontract) can be
5157
found in [here](../smartcontract/src/test/java/org/ton/java/smartcontract).
5258

smartcontract/src/main/java/org/ton/java/smartcontract/highload/HighloadWalletV3.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import org.ton.java.address.Address;
44
import org.ton.java.cell.Cell;
55
import org.ton.java.cell.CellBuilder;
6-
import org.ton.java.cell.TonHashMap;
7-
import org.ton.java.smartcontract.types.Destination;
86
import org.ton.java.smartcontract.types.ExternalMessage;
9-
import org.ton.java.smartcontract.types.HighloadConfig;
107
import org.ton.java.smartcontract.types.HighloadV3BatchItem;
118
import org.ton.java.smartcontract.types.HighloadV3Config;
129
import org.ton.java.smartcontract.types.WalletCodes;
@@ -25,12 +22,11 @@
2522

2623
public class HighloadWalletV3 implements WalletContract {
2724

28-
//https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/highload-wallet-v2-code.fc
2925
Options options;
3026
Address address;
3127

3228
/**
33-
* interface to <a href="https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/highload-wallet-v2-code.fc">highload smart-contract</a>
29+
* interface to <a href="https://github.com/ton-blockchain/highload-wallet-contract-v3/blob/main/contracts/highload-wallet-v3.func">highload-v3 smart-contract</a>
3430
*
3531
* @param options Options - mandatory - highloadQueryId, walletId, publicKey
3632
*/
@@ -95,6 +91,15 @@ public Cell createSigningMessage(long seqno) {
9591
return message.endCell();
9692
}
9793

94+
/**
95+
* Construct MsgInner according to TL-B:
96+
* <pre>
97+
* _ {n:#} subwallet_id:uint32 message_to_send:^Cell send_mode:uint8 query_id:QueryId created_at:uint64 timeout:uint22 = MsgInner;`
98+
* </pre>
99+
*
100+
* @param highloadConfig HighloadV3Config
101+
* @return Cell
102+
*/
98103
public Cell createSigningMessageInternal(HighloadV3Config highloadConfig) {
99104
CellBuilder message = CellBuilder.beginCell();
100105
message.storeUint(BigInteger.valueOf(getOptions().walletId), 32);

smartcontract/src/main/java/org/ton/java/smartcontract/types/HighloadQueryId.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@ public class HighloadQueryId {
77
static final int BITNUMBER_SIZE = 10;
88

99
int shift;
10-
int bitnumber;
10+
int bitNumber;
1111

1212
public HighloadQueryId() {
1313
shift = 0;
14-
bitnumber = 0;
14+
bitNumber = 0;
1515
}
1616

17-
public static HighloadQueryId fromShiftAndBitNumber(int shift, int bitnumber) throws IllegalArgumentException {
17+
public static HighloadQueryId fromShiftAndBitNumber(int shift, int bitNumber) throws IllegalArgumentException {
1818
if (shift < 0) {
1919
throw new IllegalArgumentException("Shift cannot be less than 0");
2020
}
2121
if (shift > MAX_SHIFT) {
2222
throw new IllegalArgumentException("Shift cannot be greater than " + MAX_SHIFT);
2323
}
24-
if (bitnumber < 0) {
25-
throw new IllegalArgumentException("Bitnumber cannot be less than 0");
24+
if (bitNumber < 0) {
25+
throw new IllegalArgumentException("BitNumber cannot be less than 0");
2626
}
27-
if (bitnumber > MAX_BITNUMBER) {
28-
throw new IllegalArgumentException("Bitnumber cannot be greater than " + MAX_BITNUMBER);
27+
if (bitNumber > MAX_BITNUMBER) {
28+
throw new IllegalArgumentException("BitNumber cannot be greater than " + MAX_BITNUMBER);
2929
}
3030
HighloadQueryId qid = new HighloadQueryId();
3131
qid.shift = shift;
32-
qid.bitnumber = bitnumber;
32+
qid.bitNumber = bitNumber;
3333
return qid;
3434
}
3535

@@ -42,16 +42,16 @@ public static HighloadQueryId fromQueryId(int queryId) {
4242
}
4343

4444
public int getQueryId() {
45-
return (shift << BITNUMBER_SIZE) + bitnumber;
45+
return (shift << BITNUMBER_SIZE) + bitNumber;
4646
}
4747

4848
public boolean hasNext() {
49-
boolean isEnd = bitnumber >= (MAX_BITNUMBER - 1) && shift >= MAX_SHIFT; // last usable queryId is left for emergency withdrawal
49+
boolean isEnd = bitNumber >= (MAX_BITNUMBER - 1) && shift >= MAX_SHIFT; // last usable queryId is left for emergency withdrawal
5050
return !isEnd;
5151
}
5252

5353
public HighloadQueryId getNext() throws IllegalStateException {
54-
int newBitnumber = bitnumber + 1;
54+
int newBitnumber = bitNumber + 1;
5555
int newShift = shift;
5656

5757
if (newShift >= MAX_SHIFT && newBitnumber > (MAX_BITNUMBER - 1)) {
@@ -73,11 +73,11 @@ public int getShift() {
7373
return shift;
7474
}
7575

76-
public int getBitnumber() {
77-
return bitnumber;
76+
public int getBitNumber() {
77+
return bitNumber;
7878
}
7979

8080
public int toSeqno() {
81-
return shift * 1023 + bitnumber;
81+
return shift * 1023 + bitNumber;
8282
}
8383
}

0 commit comments

Comments
 (0)