Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/blockchain' into blockchain
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 committed Nov 12, 2024
2 parents 0440267 + d8d0437 commit c74d766
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
10 changes: 9 additions & 1 deletion blockchain/src/main/java/org/ton/java/Blockchain.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ public SendExternalResult sendExternal(Message message) {
}
return SendExternalResult.builder().tonlibResult(tonlibResult).build();
} else { // emulator

String initialBalance = Utils.formatNanoValue(customEmulatorShardAccount.getBalance());

log.info(
"Sending external message to bounceable address {} on {}...",
stateInit.getAddress().toBounceable(),
Expand All @@ -367,7 +370,12 @@ public SendExternalResult sendExternal(Message message) {
.printEmulatorInfo(false)
.build();

emulateTransactionResult.getTransaction().printTransactionFees(true, true);
emulateTransactionResult
.getTransaction()
.printTransactionFees(true, true, initialBalance);
log.info(
"final balance {}",
Utils.formatNanoValue(emulateTransactionResult.getNewShardAccount().getBalance()));
emulateTransactionResult.getTransaction().printAllMessages(true);
} else {
log.error(
Expand Down
4 changes: 1 addition & 3 deletions blockchain/src/test/java/org/ton/java/BlockchainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testDeployCustomContractContractOnEmulator() {
Blockchain blockchain =
Blockchain.builder()
.network(Network.EMULATOR)
.customContractAsResource("simple.fc")
.customContractAsResource("simple.tolk")
.customContractDataCell(
CellBuilder.beginCell()
.storeUint(0, 32) // seqno
Expand Down Expand Up @@ -359,7 +359,6 @@ public void testSendMessagesChainCustomContractOnEmulatorTolk() {
.endCell();

Message extMsg = MsgUtils.createExternalMessage(dummyAddress, null, bodyCell);

blockchain.sendExternal(extMsg);

currentSeqno = blockchain.runGetSeqNo();
Expand All @@ -371,7 +370,6 @@ public void testSendMessagesChainCustomContractOnEmulatorTolk() {
.endCell();

extMsg = MsgUtils.createExternalMessage(dummyAddress, null, bodyCell);

blockchain.sendExternal(extMsg);
currentSeqno = blockchain.runGetSeqNo();
System.out.printf("current seqno %s\n", currentSeqno);
Expand Down
2 changes: 1 addition & 1 deletion cell/src/main/java/org/ton/java/tlb/types/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void printAllTransactions() {
log.info("No transactions");
return;
}
Transaction.printTxHeader();
Transaction.printTxHeader("");
for (Transaction tx : txs) {
tx.printTransactionFees();
}
Expand Down
58 changes: 38 additions & 20 deletions cell/src/main/java/org/ton/java/tlb/types/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,29 +370,27 @@ public void printTransactionFees() {
printTransactionFees(false, false);
}

public void printTransactionFees(boolean withHeader, boolean withFooter, String balance) {
TransactionFees txFees = getTransactionFees();

if (withHeader) {
printTxHeader(" (initial balance " + balance + ")");
}
printTxData(txFees);

if (withFooter) {
printTxFooter();
}
}

public void printTransactionFees(boolean withHeader, boolean withFooter) {
TransactionFees txFees = getTransactionFees();

if (withHeader) {
printTxHeader();
printTxHeader("");
}
String str =
String.format(
"| %-9s| %-13s| %-15s| %-15s| %-13s| %-13s| %-14s| %-11s| %-8s| %-14s| %-9s| %-11s| %-13s |",
txFees.getOp(),
txFees.getType(),
Utils.formatNanoValueZero(txFees.getValueIn()),
Utils.formatNanoValueZero(txFees.getValueOut()),
Utils.formatNanoValueZero(txFees.getTotalFees()),
Utils.formatNanoValueZero(txFees.getInForwardFee()),
Utils.formatNanoValueZero(txFees.getOutForwardFee()),
txFees.getTotalActions(),
txFees.getOutMsgs(),
Utils.formatNanoValueZero(txFees.getComputeFee()),
txFees.getExitCode(),
txFees.getActionCode(),
txFees.getAccount());
log.info(str);
printTxData(txFees);

if (withFooter) {
printTxFooter();
}
Expand Down Expand Up @@ -571,9 +569,9 @@ public void printAllMessages(boolean withHeader) {
MessageFees.printMessageFeesFooter();
}

public static void printTxHeader() {
public static void printTxHeader(String balance) {
log.info("");
log.info("Transactions");
log.info("Transactions" + balance);
log.info(
"------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
log.info(
Expand All @@ -587,6 +585,26 @@ public static void printTxFooter() {
"------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
}

public static void printTxData(TransactionFees txFees) {
String str =
String.format(
"| %-9s| %-13s| %-15s| %-15s| %-13s| %-13s| %-14s| %-11s| %-8s| %-14s| %-9s| %-11s| %-13s |",
txFees.getOp(),
txFees.getType(),
Utils.formatNanoValueZero(txFees.getValueIn()),
Utils.formatNanoValueZero(txFees.getValueOut()),
Utils.formatNanoValueZero(txFees.getTotalFees()),
Utils.formatNanoValueZero(txFees.getInForwardFee()),
Utils.formatNanoValueZero(txFees.getOutForwardFee()),
txFees.getTotalActions(),
txFees.getOutMsgs(),
Utils.formatNanoValueZero(txFees.getComputeFee()),
txFees.getExitCode(),
txFees.getActionCode(),
txFees.getAccount());
log.info(str);
}

private String formatMsgType(String fullMsgType) {
if (fullMsgType.equals("InternalMessageInfo")) {
return "internal-in";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public class TransactionFees {
long now;
BigInteger lt;
String account;
BigInteger balance;
}

0 comments on commit c74d766

Please sign in to comment.