Skip to content

Commit

Permalink
highwallet works
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 committed Nov 24, 2022
1 parent 518cc57 commit b3b2a7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public Cell createSigningMessage(long seqno) {

public Cell createSigningMessageInternal() {
CellBuilder message = CellBuilder.beginCell();
message.storeUint(BigInteger.valueOf(getOptions().walletId), 32); // todo review
message.storeUint(BigInteger.valueOf(getOptions().walletId), 32);

BigInteger i = BigInteger.valueOf((long) Math.pow(Instant.now().getEpochSecond() + 5 * 60L, 32))
.add(new BigInteger(String.valueOf(Instant.now().getEpochSecond())));
System.out.println("queryId --------------------------------- " + i);
message.storeUint(i, 64);

message.storeBit(true);

return message.endCell();
Expand All @@ -107,10 +108,12 @@ public String getPublicKey(Tonlib tonlib) {

public void sendTonCoins(Tonlib tonlib, byte[] secretKey) {

long seqno = 1; // dummy

Cell signingMessageAll = createSigningMessageInternal();
signingMessageAll.refs.add(createDict());

ExternalMessage msg = createExternalMessage(signingMessageAll, secretKey, 1, false);
ExternalMessage msg = createExternalMessage(signingMessageAll, secretKey, seqno, false);

tonlib.sendRawMessage(msg.message.toBocBase64(false));
}
Expand All @@ -126,15 +129,18 @@ private Cell createDict() {
Cell order = Contract.createCommonMsgInfo(orderHeader, null, null);

CellBuilder p = CellBuilder.beginCell();
p.storeUint(destination.getMode() == 0 ? 3 : destination.getMode(), 8); // mode
p.storeRef(order); // internal-msg
p.storeUint(destination.getMode(), 8); // mode
p.storeRef(order);

dictDestinations.elements.put(i++, p.endCell());
}

return dictDestinations.serialize(
Cell cellDict = dictDestinations.serialize(
k -> CellBuilder.beginCell().storeUint((Long) k, dictKeySize).bits,
v -> (Cell) v);
v -> (Cell) v
);

return cellDict;
}

public void deploy(Tonlib tonlib, byte[] secretKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public void testWalletV2Highload() throws InterruptedException {
Destination.builder()
.address(Address.of("EQAyjRKDnEpTBNfRHqYdnzGEQjdY4KG3gxgqiG3DpDY46u8G"))
.amount(Utils.toNano(1))
.mode((byte) 3)
.build(),
Destination.builder()
.address(Address.of("EQBrpstctZ5gF-VaaPswcWHe3JQijjNbtJVn5USXlZ-bAgO3"))
.amount(Utils.toNano(1))
.mode((byte) 3)
.build()
// Destination.builder()
// .address(Address.of("EQAaGHUHfkpWFGs428ETmym4vbvRNxCA1o4sTkwqigKjgf-_"))
Expand Down Expand Up @@ -76,6 +78,15 @@ public void testWalletV2Highload() throws InterruptedException {
// .build()

//EQCkS2OnOOjeLV-LEEUmIPh-_in4pdFr1cScZG1Inft3qUea
//EQCZlgy61mcgYNXK0yiFHC9CxjoxxAFkwiUtzTONrk6_Qk6W
//EQAt_kmFWgz5BJbPExcmUVdfz_go05xGSGbyfPGNjtsNacHu
//EQDO8yw0Dbs1loUBMtoBtT-V-YMSlZdQ_FwZWmyeoN9KpanF
//EQAsEVrV7tQtgoqzpxqYDdX-KLmPxQkfqRbj8RYtAcWdSWJh
//EQBFSkhPfFmwwherHCWnrqryc9zTu0HkV23Ya5EzD-FZjEz-
//EQC1ZVhIHkxQ-IKGK3htrFV90CRBbEfayJC4bzmPoeernBau
//EQALy9XBBfJZ4rZzSkZM65LYglzJ5ORbGbvN16NjbcigXliy
//EQAGashg_KuPjp1CbmU1ic-YTTKTMsbzpDc9PoqoeSRr-Fdz
//EQDJxUadaFJoa_0K_twQHawyJkkyv9vlui_ZsUQRA1mw0HVO
))
.build())
.build();
Expand All @@ -96,15 +107,15 @@ public void testWalletV2Highload() throws InterruptedException {

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

Utils.sleep(15, "deploying");
Utils.sleep(25, "deploying");

// transfer coins to multiple destination as specified in options
contract.sendTonCoins(tonlib, keyPair.getSecretKey());

Utils.sleep(60, "sending to multiple destinations");
Utils.sleep(30, "sending to multiple destinations");

balance = new BigInteger(tonlib.getAccountState(Address.of(bounceableAddress)).getBalance());
log.info("new wallet {} balance: {}", contract.getName(), Utils.formatNanoValue(balance));
assertThat(balance.longValue()).isLessThan(Utils.toNano(0.3).longValue());
assertThat(balance.longValue()).isLessThan(Utils.toNano(3).longValue());
}
}

0 comments on commit b3b2a7e

Please sign in to comment.