Skip to content

Commit

Permalink
add example of retrieving comment of tx
Browse files Browse the repository at this point in the history
  • Loading branch information
neodiX committed Jun 17, 2024
1 parent c40cf5d commit 0a94acb
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.ton.java.address.Address;
import org.ton.java.cell.Cell;
import org.ton.java.cell.CellSlice;
import org.ton.java.smartcontract.TestFaucet;
import org.ton.java.smartcontract.types.WalletV3Config;
import org.ton.java.smartcontract.wallet.v3.WalletV3R2;
import org.ton.java.tonlib.types.ExtMessageInfo;
import org.ton.java.tonlib.types.RawMessage;
import org.ton.java.tonlib.types.RawTransaction;
import org.ton.java.tonlib.types.RawTransactions;
import org.ton.java.utils.Utils;

import java.math.BigInteger;

import static java.util.Objects.nonNull;
import static org.assertj.core.api.Assertions.assertThat;

@Slf4j
@RunWith(JUnit4.class)
public class TestWalletV3R2Short extends CommonTest {

@Test
public void testWalletV3R12() throws InterruptedException {
String hex = Utils.base64ToHexString("dGVzdFdhbGxldFYzUjItOTg=");
String str = CellSlice.beginParse(Cell.fromHex(hex)).loadSnakeString();
log.info("cell {}", str);
}

@Test
public void testWalletV3R2() throws InterruptedException {

Expand Down Expand Up @@ -97,7 +110,7 @@ public void testWalletV3R2() throws InterruptedException {
.walletId(98)
.seqno(contract2.getSeqno())
.destination(Address.of(TestFaucet.BOUNCEABLE))
.amount(Utils.toNano(0.8))
.amount(Utils.toNano(0.7))
.comment("testWalletV3R2-98")
.build();

Expand All @@ -119,6 +132,40 @@ public void testWalletV3R2() throws InterruptedException {
log.info("2 pubkey {}", contract2.getPublicKey());

assertThat(contract1.getPublicKey()).isEqualTo(contract2.getPublicKey());

log.info("txs of wallet1");
RawTransactions txs = tonlib.getRawTransactions(bounceableAddress1, null, null);
for (RawTransaction tx : txs.getTransactions()) {
if (nonNull(tx.getIn_msg()) && (!tx.getIn_msg().getSource().getAccount_address().equals(""))) {
log.info("{}, {} <<<<< {} : {}, comment: {} ", Utils.toUTC(tx.getUtime()),
tx.getIn_msg().getSource().getAccount_address(), tx.getIn_msg().getDestination().getAccount_address(),
Utils.formatNanoValue(tx.getIn_msg().getValue()), CellSlice.beginParse(Cell.fromHex(Utils.base64ToHexString(tx.getIn_msg().getMsg_data().getText()))).loadSnakeString());
}
if (nonNull(tx.getOut_msgs())) {
for (RawMessage msg : tx.getOut_msgs()) {
log.info("{}, {} >>>>> {} : {}, comment: {}", Utils.toUTC(tx.getUtime()),
msg.getSource().getAccount_address(), msg.getDestination().getAccount_address(),
Utils.formatNanoValue(msg.getValue()), CellSlice.beginParse(Cell.fromHex(Utils.base64ToHexString(msg.getMsg_data().getText()))).loadSnakeString());
}
}
}
// CellSlice.beginParse(Cell.fromHex(Utils.base64ToHexString()).loadSnakeString()
log.info("txs of wallet2");
txs = tonlib.getRawTransactions(bounceableAddress2, null, null);
for (RawTransaction tx : txs.getTransactions()) {
if (nonNull(tx.getIn_msg()) && (!tx.getIn_msg().getSource().getAccount_address().equals(""))) {
log.info("{}, {} <<<<< {} : {}, comment: {} ", Utils.toUTC(tx.getUtime()),
tx.getIn_msg().getSource().getAccount_address(), tx.getIn_msg().getDestination().getAccount_address(),
Utils.formatNanoValue(tx.getIn_msg().getValue()), CellSlice.beginParse(Cell.fromHex(Utils.base64ToHexString(tx.getIn_msg().getMsg_data().getText()))).loadSnakeString());
}
if (nonNull(tx.getOut_msgs())) {
for (RawMessage msg : tx.getOut_msgs()) {
log.info("{}, {} >>>>> {} : {}, comment: {}", Utils.toUTC(tx.getUtime()),
msg.getSource().getAccount_address(), msg.getDestination().getAccount_address(),
Utils.formatNanoValue(msg.getValue()), CellSlice.beginParse(Cell.fromHex(Utils.base64ToHexString(msg.getMsg_data().getText()))).loadSnakeString());
}
}
}
}

/*
Expand Down

0 comments on commit 0a94acb

Please sign in to comment.