diff --git a/smartcontract/custom-smc-example.md b/smartcontract/custom-smc-example.md index 30eacddc..421fd98a 100644 --- a/smartcontract/custom-smc-example.md +++ b/smartcontract/custom-smc-example.md @@ -316,15 +316,15 @@ Check if contract was deployed successfully Tonlib tonlib = Tonlib.builder().build(); RunResult result = tonlib.runMethod(address,"seqno"); -TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry(); +TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack(); log.info("seqno: {}", seqno.getNumber()); result=tonlib.runMethod(address, "get_x_data"); -TvmStackEntryNumber x_data=(TvmStackEntryNumber)result.getStackEntry(); +TvmStackEntryNumber x_data=(TvmStackEntryNumber)result.getStack(); log.info("x_data: {}", seqno.getNumber()); result=tonlib.runMethod(address,"get_extra_field"); -TvmStackEntryNumber extra_field = (TvmStackEntryNumber)result.getStackEntry(); +TvmStackEntryNumber extra_field = (TvmStackEntryNumber)result.getStack(); log.info("extra_field: {}", seqno.getNumber()); // result diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsCollection.java b/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsCollection.java index ebd12c40..38adb0b4 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsCollection.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsCollection.java @@ -94,10 +94,10 @@ public CollectionData getCollectionData(Tonlib tonlib) { throw new Error("method get_collection_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber nextItemIndexResult = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber nextItemIndexResult = (TvmStackEntryNumber) result.getStack().get(0); long nextItemIndex = nextItemIndexResult.getNumber().longValue(); - TvmStackEntryCell collectionContentResult = (TvmStackEntryCell) result.getStackEntry().get(1); // cell or slice + TvmStackEntryCell collectionContentResult = (TvmStackEntryCell) result.getStack().get(1); // cell or slice Cell collectionContent = Cell.fromBoc(Utils.base64ToBytes(collectionContentResult.getCell().getBytes())); String collectionContentUri = NftUtils.parseOffchainUriCell(collectionContent); @@ -132,7 +132,7 @@ public Address getNftItemAddressByIndex(Tonlib tonlib, BigInteger index) { throw new Error("method get_nft_address_by_index, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell addr = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell addr = (TvmStackEntryCell) result.getStack().get(0); return NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(addr.getCell().getBytes()))); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsItem.java b/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsItem.java index f41921c7..bfd0d74f 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsItem.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsItem.java @@ -83,18 +83,18 @@ public ItemData getData(Tonlib tonlib) { throw new Error("method get_nft_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber isInitializedNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber isInitializedNumber = (TvmStackEntryNumber) result.getStack().get(0); boolean isInitialized = isInitializedNumber.getNumber().longValue() == -1; - BigInteger index = ((TvmStackEntryNumber) result.getStackEntry().get(1)).getNumber(); + BigInteger index = ((TvmStackEntryNumber) result.getStack().get(1)).getNumber(); - TvmStackEntryCell collectionAddr = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell collectionAddr = (TvmStackEntryCell) result.getStack().get(2); Address collectionAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(collectionAddr.getCell().getBytes()))); - TvmStackEntryCell ownerAddr = (TvmStackEntryCell) result.getStackEntry().get(3); + TvmStackEntryCell ownerAddr = (TvmStackEntryCell) result.getStack().get(3); Address ownerAddress = isInitialized ? NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(ownerAddr.getCell().getBytes()))) : null; - TvmStackEntryCell contentC = (TvmStackEntryCell) result.getStackEntry().get(4); + TvmStackEntryCell contentC = (TvmStackEntryCell) result.getStack().get(4); Cell contentCell = CellBuilder.fromBoc(Utils.base64ToBytes(contentC.getCell().getBytes())); return ItemData.builder() @@ -152,7 +152,7 @@ public String getDomain(Tonlib tonlib) { throw new Error("method get_domain, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell domainCell = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell domainCell = (TvmStackEntryCell) result.getStack().get(0); return new String(CellBuilder.fromBoc(Utils.base64ToBytes(domainCell.getCell().getBytes())).bits.toByteArray()); } @@ -164,7 +164,7 @@ public Address getEditor(Tonlib tonlib) { throw new Error("method get_editor, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell editorCell = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell editorCell = (TvmStackEntryCell) result.getStack().get(0); return NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(editorCell.getCell().getBytes()))); } @@ -179,13 +179,13 @@ public AuctionInfo getAuctionInfo(Tonlib tonlib) { throw new Error("method get_auction_info, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell maxBidAddressCell = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell maxBidAddressCell = (TvmStackEntryCell) result.getStack().get(0); Address maxBidAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(maxBidAddressCell.getCell().getBytes()))); - TvmStackEntryNumber maxBidAmountNumber = (TvmStackEntryNumber) result.getStackEntry().get(1); + TvmStackEntryNumber maxBidAmountNumber = (TvmStackEntryNumber) result.getStack().get(1); BigInteger maxBidAmount = maxBidAmountNumber.getNumber(); - TvmStackEntryNumber auctionEndTimeNumber = (TvmStackEntryNumber) result.getStackEntry().get(2); + TvmStackEntryNumber auctionEndTimeNumber = (TvmStackEntryNumber) result.getStack().get(2); long auctionEndTime = auctionEndTimeNumber.getNumber().longValue(); return AuctionInfo.builder() @@ -203,7 +203,7 @@ public long getLastFillUpTime(Tonlib tonlib) { throw new Error("method get_last_fill_up_time, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber time = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber time = (TvmStackEntryNumber) result.getStack().get(0); return time.getNumber().longValue(); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsUtils.java b/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsUtils.java index 54fc2624..458222f6 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsUtils.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/dns/DnsUtils.java @@ -137,16 +137,16 @@ private static Object dnsResolveImpl(Tonlib tonlib, Address dnsAddress, byte[] r stack.offer("[num, " + categoryInteger + "]"); RunResult result = tonlib.runMethod(dnsAddress, "dnsresolve", stack); - if (result.getStackEntry().size() != 2) { + if (result.getStack().size() != 2) { throw new Error("Invalid dnsresolve response"); } Cell cell = null; - int resultLen = ((TvmStackEntryNumber) result.getStackEntry().get(0)).getNumber().intValue(); - Object r = result.getStackEntry().get(1); + int resultLen = ((TvmStackEntryNumber) result.getStack().get(0)).getNumber().intValue(); + Object r = result.getStack().get(1); if (r instanceof TvmStackEntryCell) { - TvmStackEntryCell cellResult = (TvmStackEntryCell) result.getStackEntry().get(1); + TvmStackEntryCell cellResult = (TvmStackEntryCell) result.getStack().get(1); cell = CellBuilder.fromBoc(Utils.base64ToBytes(cellResult.getCell().getBytes())); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/lockup/LockupWalletV1.java b/smartcontract/src/main/java/org/ton/java/smartcontract/lockup/LockupWalletV1.java index 7bcbdc7f..e4c9ef2e 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/lockup/LockupWalletV1.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/lockup/LockupWalletV1.java @@ -140,7 +140,7 @@ public long getWalletId(Tonlib tonlib) { Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "wallet_id"); - TvmStackEntryNumber subWalletId = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber subWalletId = (TvmStackEntryNumber) result.getStack().get(0); return subWalletId.getNumber().longValue(); } @@ -149,7 +149,7 @@ public String getPublicKey(Tonlib tonlib) { Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "get_public_key"); - TvmStackEntryNumber pubkey = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber pubkey = (TvmStackEntryNumber) result.getStack().get(0); return pubkey.getNumber().toString(16); } @@ -165,7 +165,7 @@ public boolean check_destination(Tonlib tonlib, String destination) { stack.offer("[slice, " + c.endCell().toHex(true) + "]"); RunResult result = tonlib.runMethod(myAddress, "check_destination", stack); - TvmStackEntryNumber found = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber found = (TvmStackEntryNumber) result.getStack().get(0); return (found.getNumber().intValue() == -1); } @@ -201,9 +201,9 @@ public BigInteger getNominalLockedBalance(Tonlib tonlib) { public List getBalances(Tonlib tonlib) { Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "get_balances"); - TvmStackEntryNumber balance = (TvmStackEntryNumber) result.getStackEntry().get(0); // ton balance - TvmStackEntryNumber restrictedValue = (TvmStackEntryNumber) result.getStackEntry().get(1); // total_restricted_value - TvmStackEntryNumber lockedValue = (TvmStackEntryNumber) result.getStackEntry().get(2); // total_locked_value + TvmStackEntryNumber balance = (TvmStackEntryNumber) result.getStack().get(0); // ton balance + TvmStackEntryNumber restrictedValue = (TvmStackEntryNumber) result.getStack().get(1); // total_restricted_value + TvmStackEntryNumber lockedValue = (TvmStackEntryNumber) result.getStack().get(2); // total_locked_value return List.of( balance.getNumber(), @@ -216,7 +216,7 @@ public long getSeqno(Tonlib tonlib) { Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "seqno"); - TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack().get(0); return seqno.getNumber().longValue(); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/payments/PaymentChannel.java b/smartcontract/src/main/java/org/ton/java/smartcontract/payments/PaymentChannel.java index b27e01f1..bfcfbcd5 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/payments/PaymentChannel.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/payments/PaymentChannel.java @@ -251,7 +251,7 @@ public BigInteger getChannelState(Tonlib tonlib) { throw new Error("method get_channel_state, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber addr = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber addr = (TvmStackEntryNumber) result.getStack().get(0); return addr.getNumber(); } @@ -264,35 +264,35 @@ public ChannelData getData(Tonlib tonlib) { throw new Error("method get_channel_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber stateNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber stateNumber = (TvmStackEntryNumber) result.getStack().get(0); - TvmStackEntryTuple balanceTuple = (TvmStackEntryTuple) result.getStackEntry().get(1); + TvmStackEntryTuple balanceTuple = (TvmStackEntryTuple) result.getStack().get(1); TvmStackEntryNumber balanceA = (TvmStackEntryNumber) balanceTuple.getTuple().getElements().get(0); TvmStackEntryNumber balanceB = (TvmStackEntryNumber) balanceTuple.getTuple().getElements().get(1); - TvmStackEntryTuple keyTuple = (TvmStackEntryTuple) result.getStackEntry().get(2); + TvmStackEntryTuple keyTuple = (TvmStackEntryTuple) result.getStack().get(2); TvmStackEntryNumber publicKeyA = (TvmStackEntryNumber) keyTuple.getTuple().getElements().get(0); TvmStackEntryNumber publicKeyB = (TvmStackEntryNumber) keyTuple.getTuple().getElements().get(1); - TvmStackEntryNumber channelIdNumber = (TvmStackEntryNumber) result.getStackEntry().get(3); + TvmStackEntryNumber channelIdNumber = (TvmStackEntryNumber) result.getStack().get(3); - TvmStackEntryTuple closureConfigTuple = (TvmStackEntryTuple) result.getStackEntry().get(4); + TvmStackEntryTuple closureConfigTuple = (TvmStackEntryTuple) result.getStack().get(4); TvmStackEntryNumber quarantineDuration = (TvmStackEntryNumber) closureConfigTuple.getTuple().getElements().get(0); TvmStackEntryNumber misbehaviourFine = (TvmStackEntryNumber) closureConfigTuple.getTuple().getElements().get(1); TvmStackEntryNumber conditionalCloseDuration = (TvmStackEntryNumber) closureConfigTuple.getTuple().getElements().get(2); - TvmStackEntryTuple commitedSeqnoTuple = (TvmStackEntryTuple) result.getStackEntry().get(5); + TvmStackEntryTuple commitedSeqnoTuple = (TvmStackEntryTuple) result.getStack().get(5); TvmStackEntryNumber seqnoA = (TvmStackEntryNumber) commitedSeqnoTuple.getTuple().getElements().get(0); TvmStackEntryNumber seqnoB = (TvmStackEntryNumber) commitedSeqnoTuple.getTuple().getElements().get(1); Cell quarantine = null; - TvmStackEntryList quarantineList = (TvmStackEntryList) result.getStackEntry().get(6); + TvmStackEntryList quarantineList = (TvmStackEntryList) result.getStack().get(6); for (Object o : quarantineList.getList().getElements()) { TvmStackEntryCell t = (TvmStackEntryCell) o; quarantine = CellBuilder.fromBoc(Utils.base64ToBytes(t.getCell().getBytes())); } - TvmStackEntryTuple trippleTuple = (TvmStackEntryTuple) result.getStackEntry().get(7); + TvmStackEntryTuple trippleTuple = (TvmStackEntryTuple) result.getStack().get(7); TvmStackEntryNumber excessFee = (TvmStackEntryNumber) trippleTuple.getTuple().getElements().get(0); TvmStackEntryCell addressACell = (TvmStackEntryCell) trippleTuple.getTuple().getElements().get(1); diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonMinter.java b/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonMinter.java index 91f8e382..81bbbf05 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonMinter.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonMinter.java @@ -159,17 +159,17 @@ public JettonMinterData getJettonData(Tonlib tonlib) { throw new Error("method get_nft_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber totalSupplyNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber totalSupplyNumber = (TvmStackEntryNumber) result.getStack().get(0); BigInteger totalSupply = totalSupplyNumber.getNumber(); System.out.println("minter totalSupply: " + Utils.formatNanoValue(totalSupply)); - boolean isMutable = ((TvmStackEntryNumber) result.getStackEntry().get(1)).getNumber().longValue() == -1; + boolean isMutable = ((TvmStackEntryNumber) result.getStack().get(1)).getNumber().longValue() == -1; - TvmStackEntryCell adminAddr = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell adminAddr = (TvmStackEntryCell) result.getStack().get(2); Address adminAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(adminAddr.getCell().getBytes()))); - TvmStackEntryCell jettonContent = (TvmStackEntryCell) result.getStackEntry().get(3); + TvmStackEntryCell jettonContent = (TvmStackEntryCell) result.getStack().get(3); Cell jettonContentCell = CellBuilder.fromBoc(Utils.base64ToBytes(jettonContent.getCell().getBytes())); String jettonContentUri = null; try { @@ -178,7 +178,7 @@ public JettonMinterData getJettonData(Tonlib tonlib) { //todo } - TvmStackEntryCell contentC = (TvmStackEntryCell) result.getStackEntry().get(4); + TvmStackEntryCell contentC = (TvmStackEntryCell) result.getStack().get(4); Cell jettonWalletCode = CellBuilder.fromBoc(Utils.base64ToBytes(contentC.getCell().getBytes())); return JettonMinterData.builder() @@ -199,7 +199,7 @@ public BigInteger getTotalSupply(Tonlib tonlib) { throw new Error("method get_jetton_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber totalSupplyNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber totalSupplyNumber = (TvmStackEntryNumber) result.getStack().get(0); return totalSupplyNumber.getNumber(); } @@ -223,7 +223,7 @@ public Address getJettonWalletAddress(Tonlib tonlib, Address ownerAddress) { throw new Error("method get_wallet_address, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell addr = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell addr = (TvmStackEntryCell) result.getStack().get(0); return NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(addr.getCell().getBytes()))); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonWallet.java b/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonWallet.java index 0e6f23ee..a339aad3 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonWallet.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/token/ft/JettonWallet.java @@ -104,16 +104,16 @@ public JettonWalletData getData(Tonlib tonlib) { throw new Error("method get_wallet_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber balanceNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber balanceNumber = (TvmStackEntryNumber) result.getStack().get(0); BigInteger balance = balanceNumber.getNumber(); - TvmStackEntryCell ownerAddr = (TvmStackEntryCell) result.getStackEntry().get(1); + TvmStackEntryCell ownerAddr = (TvmStackEntryCell) result.getStack().get(1); Address ownerAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(ownerAddr.getCell().getBytes()))); - TvmStackEntryCell jettonMinterAddr = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell jettonMinterAddr = (TvmStackEntryCell) result.getStack().get(2); Address jettonMinterAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(jettonMinterAddr.getCell().getBytes()))); - TvmStackEntryCell jettonWallet = (TvmStackEntryCell) result.getStackEntry().get(3); + TvmStackEntryCell jettonWallet = (TvmStackEntryCell) result.getStack().get(3); Cell jettonWalletCode = CellBuilder.fromBoc(Utils.base64ToBytes(jettonWallet.getCell().getBytes())); return JettonWalletData.builder() .balance(balance) @@ -131,7 +131,7 @@ public BigInteger getBalance(Tonlib tonlib) { throw new Error("method get_wallet_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber balanceNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber balanceNumber = (TvmStackEntryNumber) result.getStack().get(0); return balanceNumber.getNumber(); } } \ No newline at end of file diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftCollection.java b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftCollection.java index ff852ce7..a8bdfb61 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftCollection.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftCollection.java @@ -201,11 +201,11 @@ public CollectionData getCollectionData(Tonlib tonlib) { throw new Error("method get_collection_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber itemsCountNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber itemsCountNumber = (TvmStackEntryNumber) result.getStack().get(0); long nextItemIndex = itemsCountNumber.getNumber().longValue(); - TvmStackEntryCell collectionContent = (TvmStackEntryCell) result.getStackEntry().get(1); + TvmStackEntryCell collectionContent = (TvmStackEntryCell) result.getStack().get(1); Cell collectionContentCell = CellBuilder.fromBoc(Utils.base64ToBytes(collectionContent.getCell().getBytes())); String collectionContentUri = null; @@ -215,7 +215,7 @@ public CollectionData getCollectionData(Tonlib tonlib) { //todo } - TvmStackEntryCell ownerAddressCell = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell ownerAddressCell = (TvmStackEntryCell) result.getStack().get(2); Address ownerAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(ownerAddressCell.getCell().getBytes()))); return CollectionData.builder() @@ -244,7 +244,7 @@ public ItemData getNftItemContent(Tonlib tonlib, NftItem nftItem) { throw new Error("method get_nft_content, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell contentCell = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell contentCell = (TvmStackEntryCell) result.getStack().get(2); Cell content = CellBuilder.fromBoc(Utils.base64ToBytes(contentCell.getCell().getBytes())); try { @@ -271,7 +271,7 @@ public Address getNftItemAddressByIndex(Tonlib tonlib, BigInteger index) { throw new Error("method get_nft_address_by_index, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell addrCell = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell addrCell = (TvmStackEntryCell) result.getStack().get(0); return NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(addrCell.getCell().getBytes()))); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftItem.java b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftItem.java index 014e49ff..9ab056b6 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftItem.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftItem.java @@ -83,18 +83,18 @@ public ItemData getData(Tonlib tonlib) { throw new Error("method get_nft_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber isInitializedNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber isInitializedNumber = (TvmStackEntryNumber) result.getStack().get(0); boolean isInitialized = isInitializedNumber.getNumber().longValue() == -1; - BigInteger index = ((TvmStackEntryNumber) result.getStackEntry().get(1)).getNumber(); + BigInteger index = ((TvmStackEntryNumber) result.getStack().get(1)).getNumber(); - TvmStackEntryCell collectionAddr = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell collectionAddr = (TvmStackEntryCell) result.getStack().get(2); Address collectionAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(collectionAddr.getCell().getBytes()))); - TvmStackEntryCell ownerAddr = (TvmStackEntryCell) result.getStackEntry().get(3); + TvmStackEntryCell ownerAddr = (TvmStackEntryCell) result.getStack().get(3); Address ownerAddress = isInitialized ? NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(ownerAddr.getCell().getBytes()))) : null; - TvmStackEntryCell contentCell = (TvmStackEntryCell) result.getStackEntry().get(4); + TvmStackEntryCell contentCell = (TvmStackEntryCell) result.getStack().get(4); Cell cell = CellBuilder.fromBoc(Utils.base64ToBytes(contentCell.getCell().getBytes())); String contentUri = null; diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftSale.java b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftSale.java index 9c2ae0e4..0dffafb5 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftSale.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftSale.java @@ -98,13 +98,13 @@ public NftSaleData getData(Tonlib tonlib) { throw new Error("method get_sale_data, returned an exit code " + result.getExit_code()); } - TvmStackEntryCell marketplaceAddressCell = (TvmStackEntryCell) result.getStackEntry().get(0); + TvmStackEntryCell marketplaceAddressCell = (TvmStackEntryCell) result.getStack().get(0); Address marketplaceAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(marketplaceAddressCell.getCell().getBytes()))); - TvmStackEntryCell nftAddressCell = (TvmStackEntryCell) result.getStackEntry().get(1); + TvmStackEntryCell nftAddressCell = (TvmStackEntryCell) result.getStack().get(1); Address nftAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(nftAddressCell.getCell().getBytes()))); - TvmStackEntryCell nftOwnerAddressCell = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell nftOwnerAddressCell = (TvmStackEntryCell) result.getStack().get(2); Address nftOwnerAddress = null; try { nftOwnerAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(nftOwnerAddressCell.getCell().getBytes()))); @@ -112,16 +112,16 @@ public NftSaleData getData(Tonlib tonlib) { //todo } - TvmStackEntryNumber fullPriceNumber = (TvmStackEntryNumber) result.getStackEntry().get(3); + TvmStackEntryNumber fullPriceNumber = (TvmStackEntryNumber) result.getStack().get(3); BigInteger fullPrice = fullPriceNumber.getNumber(); - TvmStackEntryNumber marketplaceFeeNumber = (TvmStackEntryNumber) result.getStackEntry().get(4); + TvmStackEntryNumber marketplaceFeeNumber = (TvmStackEntryNumber) result.getStack().get(4); BigInteger marketplaceFee = marketplaceFeeNumber.getNumber(); - TvmStackEntryCell royaltyAddressCell = (TvmStackEntryCell) result.getStackEntry().get(5); + TvmStackEntryCell royaltyAddressCell = (TvmStackEntryCell) result.getStack().get(5); Address royaltyAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(royaltyAddressCell.getCell().getBytes()))); - TvmStackEntryNumber royaltyAmountNumber = (TvmStackEntryNumber) result.getStackEntry().get(6); + TvmStackEntryNumber royaltyAmountNumber = (TvmStackEntryNumber) result.getStack().get(6); BigInteger royaltyAmount = royaltyAmountNumber.getNumber(); diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftUtils.java b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftUtils.java index a11a6a09..610bc681 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftUtils.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/token/nft/NftUtils.java @@ -162,14 +162,14 @@ public static Address parseAddress(Cell cell) { public static Royalty getRoyaltyParams(Tonlib tonlib, Address address) { RunResult result = tonlib.runMethod(address, "royalty_params"); - TvmStackEntryNumber royaltyFactorNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber royaltyFactorNumber = (TvmStackEntryNumber) result.getStack().get(0); BigInteger royaltyFactor = royaltyFactorNumber.getNumber(); - TvmStackEntryNumber royaltyBaseNumber = (TvmStackEntryNumber) result.getStackEntry().get(1); + TvmStackEntryNumber royaltyBaseNumber = (TvmStackEntryNumber) result.getStack().get(1); BigInteger royaltyBase = royaltyBaseNumber.getNumber(); double royalty = royaltyFactor.divide(royaltyBase).doubleValue(); - TvmStackEntryCell royaltyAddressCell = (TvmStackEntryCell) result.getStackEntry().get(2); + TvmStackEntryCell royaltyAddressCell = (TvmStackEntryCell) result.getStack().get(2); Address royaltyAddress = NftUtils.parseAddress(CellBuilder.fromBoc(Utils.base64ToBytes(royaltyAddressCell.getCell().getBytes()))); return Royalty.builder() diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/WalletContract.java b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/WalletContract.java index 31666f4f..bfaaf897 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/WalletContract.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/WalletContract.java @@ -364,7 +364,7 @@ default long getSeqno(Tonlib tonlib) { throw new Error("method seqno returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack().get(0); return seqno.getNumber().longValue(); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v1/SimpleWalletContractR3.java b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v1/SimpleWalletContractR3.java index c5c8d076..7c10d8cd 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v1/SimpleWalletContractR3.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v1/SimpleWalletContractR3.java @@ -52,7 +52,7 @@ public String getPublicKey(Tonlib tonlib) { throw new Error("method get_public_key, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber publicKeyNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber publicKeyNumber = (TvmStackEntryNumber) result.getStack().get(0); return publicKeyNumber.getNumber().toString(16); } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v2/WalletV2ContractR2.java b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v2/WalletV2ContractR2.java index 8e28eedf..ac30b980 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v2/WalletV2ContractR2.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v2/WalletV2ContractR2.java @@ -33,7 +33,7 @@ public String getPublicKey(Tonlib tonlib) { throw new Error("method get_public_key, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber publicKeyNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber publicKeyNumber = (TvmStackEntryNumber) result.getStack().get(0); return publicKeyNumber.getNumber().toString(16); } } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v3/WalletV3ContractR2.java b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v3/WalletV3ContractR2.java index ec7f26e7..9b68ed97 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v3/WalletV3ContractR2.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v3/WalletV3ContractR2.java @@ -36,7 +36,7 @@ public String getPublicKey(Tonlib tonlib) { throw new Error("method get_public_key, returned an exit code " + result.getExit_code()); } - TvmStackEntryNumber publicKeyNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber publicKeyNumber = (TvmStackEntryNumber) result.getStack().get(0); return publicKeyNumber.getNumber().toString(16); } } diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v4/WalletV4ContractR2.java b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v4/WalletV4ContractR2.java index 43a15fdf..e5a8bc5d 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v4/WalletV4ContractR2.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/wallet/v4/WalletV4ContractR2.java @@ -186,7 +186,7 @@ public long getWalletId(Tonlib tonlib) { Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "get_subwallet_id"); - TvmStackEntryNumber subWalletId = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber subWalletId = (TvmStackEntryNumber) result.getStack().get(0); return subWalletId.getNumber().longValue(); } @@ -194,7 +194,7 @@ public long getWalletId(Tonlib tonlib) { public byte[] getPublicKey(Tonlib tonlib) { Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "get_public_key"); - TvmStackEntryNumber pubKey = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber pubKey = (TvmStackEntryNumber) result.getStack().get(0); return pubKey.getNumber().toByteArray(); } @@ -213,7 +213,7 @@ public boolean isPluginInstalled(Tonlib tonlib, Address pluginAddress) { stack.offer("[num, " + hashPart + "]"); RunResult result = tonlib.runMethod(myAddress, "is_plugin_installed", stack); - TvmStackEntryNumber resultNumber = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber resultNumber = (TvmStackEntryNumber) result.getStack().get(0); return resultNumber.getNumber().longValue() != 0; } @@ -225,7 +225,7 @@ public List getPluginsList(Tonlib tonlib) { List r = new ArrayList<>(); Address myAddress = getAddress(); RunResult result = tonlib.runMethod(myAddress, "get_plugin_list"); - TvmStackEntryList list = (TvmStackEntryList) result.getStackEntry().get(0); + TvmStackEntryList list = (TvmStackEntryList) result.getStack().get(0); for (Object o : list.getList().getElements()) { TvmStackEntryTuple t = (TvmStackEntryTuple) o; TvmTuple tuple = t.getTuple(); @@ -245,7 +245,7 @@ public SubscriptionInfo getSubscriptionData(Tonlib tonlib, Address pluginAddress RunResult result = tonlib.runMethod(pluginAddress, "get_subscription_data"); if (result.getExit_code() == 0) { - return parseSubscriptionData(result.getStackEntry()); + return parseSubscriptionData(result.getStack()); } else { throw new Error("Error executing get_subscription_data. Exit code " + result.getExit_code()); @@ -277,7 +277,7 @@ public Cell createPluginDataCell(Address wallet, return cell.endCell(); } - private SubscriptionInfo parseSubscriptionData(List subscriptionData) { + private SubscriptionInfo parseSubscriptionData(List subscriptionData) { TvmStackEntryTuple walletAddr = (TvmStackEntryTuple) subscriptionData.get(0); TvmStackEntryNumber wc = (TvmStackEntryNumber) walletAddr.getTuple().getElements().get(0); TvmStackEntryNumber hash = (TvmStackEntryNumber) walletAddr.getTuple().getElements().get(1); diff --git a/smartcontract/src/test/java/org/ton/java/smartcontract/unittests/TestCustomContract.java b/smartcontract/src/test/java/org/ton/java/smartcontract/unittests/TestCustomContract.java index f9c1d822..4ebaa6e0 100644 --- a/smartcontract/src/test/java/org/ton/java/smartcontract/unittests/TestCustomContract.java +++ b/smartcontract/src/test/java/org/ton/java/smartcontract/unittests/TestCustomContract.java @@ -49,17 +49,17 @@ public void testCustomContract() { RunResult result = tonlib.runMethod(address, "seqno"); log.info("gas_used {}, exit_code {} ", result.getGas_used(), result.getExit_code()); - TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack().get(0); log.info("seqno: {}", seqno.getNumber()); result = tonlib.runMethod(address, "get_x_data"); log.info("gas_used {}, exit_code {} ", result.getGas_used(), result.getExit_code()); - TvmStackEntryNumber x_data = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber x_data = (TvmStackEntryNumber) result.getStack().get(0); log.info("x_data: {}", x_data.getNumber()); result = tonlib.runMethod(address, "get_extra_field"); log.info("gas_used {}, exit_code {} ", result.getGas_used(), result.getExit_code()); - TvmStackEntryNumber extra_field = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber extra_field = (TvmStackEntryNumber) result.getStack().get(0); log.info("extra_field: {}", extra_field.getNumber()); Address destinationAddress = Address.of("kf_sPxv06KagKaRmOOKxeDQwApCx3i8IQOwv507XD51JOLka"); diff --git a/tonlib/README.md b/tonlib/README.md index a730bd08..6db2b1dc 100644 --- a/tonlib/README.md +++ b/tonlib/README.md @@ -180,7 +180,7 @@ RunResult result = tonlib.runMethod(address, "seqno"); log.info("gas_used {}, exit_code {} ", result.getGas_used(), result.getExit_code()); -TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry().get(0); +TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack().get(0); log.info("seqno: {}", eqno.getNumber()); // result @@ -193,7 +193,7 @@ Retrieve past_election_ids ```java Address address = Address.of("-1:3333333333333333333333333333333333333333333333333333333333333333"); RunResult result = tonlib.runMethod(address,"past_election_ids"); -TvmStackEntryList listResult = (TvmStackEntryList)result.getStackEntry().get(0); +TvmStackEntryList listResult = (TvmStackEntryList)result.getStack().get(0); for(Object o: listResult.getList().getElements()){ TvmStackEntryNumber electionId = (TvmStackEntryNumber); diff --git a/tonlib/src/main/java/org/ton/java/tonlib/RunResultParser.java b/tonlib/src/main/java/org/ton/java/tonlib/RunResultParser.java new file mode 100644 index 00000000..fb7454d8 --- /dev/null +++ b/tonlib/src/main/java/org/ton/java/tonlib/RunResultParser.java @@ -0,0 +1,193 @@ +package org.ton.java.tonlib; + +import com.google.gson.*; +import org.ton.java.tonlib.types.*; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import static java.util.Objects.nonNull; + +public class RunResultParser { + + Gson customGson; + + RunResultParser() { + GsonBuilder gsonBuilder = new GsonBuilder(); + + JsonDeserializer deserializerStackEntryNumber = (json, typeOfT, context) -> { + JsonElement i2 = json.getAsJsonObject().get("number").getAsJsonObject(); + String i3 = i2.getAsJsonObject().get("number").getAsString(); + TvmNumber n = TvmNumber.builder().number(i3).build(); + return TvmStackEntryNumber.builder().number(n).build(); + }; + + JsonDeserializer deserializerStackEntryCell = (json, typeOfT, context) -> { + JsonElement i2 = json.getAsJsonObject().get("cell").getAsJsonObject(); + String i3 = i2.getAsJsonObject().get("bytes").getAsString(); + TvmCell n = TvmCell.builder().bytes(i3).build(); + return TvmStackEntryCell.builder().cell(n).build(); + }; + + JsonDeserializer deserializerStackEntrySlice = (json, typeOfT, context) -> { + JsonElement i2 = json.getAsJsonObject().get("slice").getAsJsonObject(); + String i3 = i2.getAsJsonObject().get("bytes").getAsString(); + TvmSlice n = TvmSlice.builder().bytes(i3).build(); + return TvmStackEntrySlice.builder().slice(n).build(); + }; + + JsonDeserializer deserializerStackEntryList = (json, typeOfT, context) -> { + TvmList list = TvmList.builder().build(); + TvmStackEntryList entryList = TvmStackEntryList.builder().build(); + List elements = new ArrayList<>(); + JsonElement l = json.getAsJsonObject().get("list"); + JsonArray elementsArray = l.getAsJsonObject().getAsJsonArray("elements"); + if (nonNull(elementsArray)) { + for (int j = 0; j < elementsArray.size(); j++) { + JsonElement element = elementsArray.get(j); + String elementType = element.getAsJsonObject().get("@type").getAsString(); + elements.add(deserializeByType(elementType, element, context)); +// switch (elType2) { +// case "tvm.stackEntryNumber" -> { +// TvmStackEntryNumber n2 = context.deserialize(elInner2, TvmStackEntryNumber.class); +// elements.add(n2); +// } +// case "tvm.stackEntryCell" -> { +// TvmStackEntryCell c2 = context.deserialize(elInner2, TvmStackEntryCell.class); +// elements.add(c2); +// } +// case "tvm.stackEntrySlice" -> { +// TvmStackEntrySlice s2 = context.deserialize(elInner2, TvmStackEntrySlice.class); +// elements.add(s2); +// } +// case "tvm.stackEntryList" -> { +// TvmStackEntryList l2 = context.deserialize(elInner2, TvmStackEntryList.class); +// elements.add(l2); +// } +// case "tvm.stackEntryTuple" -> { +// TvmStackEntryTuple t2 = context.deserialize(elInner2, TvmStackEntryTuple.class); +// elements.add(t2); +// } +// } + } + } + list.setElements(elements); + entryList.setList(list); + return entryList; + }; + + JsonDeserializer deserializerStackEntryTuple = (json, typeOfT, context) -> { + TvmTuple tuple = TvmTuple.builder().build(); + TvmStackEntryTuple entryList = TvmStackEntryTuple.builder().build(); + List elements = new ArrayList<>(); + JsonElement l = json.getAsJsonObject().get("tuple"); + JsonArray elementsArray = l.getAsJsonObject().getAsJsonArray("elements"); + if (nonNull(elementsArray)) { + for (int j = 0; j < elementsArray.size(); j++) { + JsonElement element = elementsArray.get(j); + String elementType = element.getAsJsonObject().get("@type").getAsString(); + elements.add(deserializeByType(elementType, element, context)); +// switch (elType2) { +// case "tvm.stackEntryNumber": +// TvmStackEntryNumber n2 = context.deserialize(elInner2, TvmStackEntryNumber.class); +// elements.add(n2); +// break; +// case "tvm.stackEntryCell": +// TvmStackEntryCell c2 = context.deserialize(elInner2, TvmStackEntryCell.class); +// elements.add(c2); +// break; +// case "tvm.stackEntrySlice": +// TvmStackEntrySlice s2 = context.deserialize(elInner2, TvmStackEntrySlice.class); +// elements.add(s2); +// break; +// case "tvm.stackEntryList": +// TvmStackEntryList l2 = context.deserialize(elInner2, TvmStackEntryList.class); +// elements.add(l2); +// break; +// case "tvm.stackEntryTuple": +// TvmStackEntryTuple t2 = context.deserialize(elInner2, TvmStackEntryTuple.class); +// elements.add(t2); +// break; +// } + } + } + tuple.setElements(elements); + entryList.setTuple(tuple); + return entryList; + }; + + + JsonDeserializer deserializer = (json, typeOfT, context) -> { + + List stack = new ArrayList<>(); + + JsonObject jsonObject = json.getAsJsonObject(); + String el = jsonObject.get("@type").toString(); + if (!el.contains("smc.runResult")) { + throw new Error("json string does not come from runmethod result"); + } + JsonElement stackList = jsonObject.get("stack"); + + BigInteger gasUsed = jsonObject.get("gas_used").getAsBigInteger(); + long exitCode = jsonObject.get("exit_code").getAsLong(); + + for (int i = 0; i < stackList.getAsJsonArray().size(); i++) { + JsonElement element = stackList.getAsJsonArray().get(i); + String elementType = element.getAsJsonObject().get("@type").getAsString(); + stack.add(deserializeByType(elementType, element, context)); +// switch (elType) { +// case "tvm.stackEntryNumber": +// TvmStackEntryNumber n1 = context.deserialize(elInner, TvmStackEntryNumber.class); +// stack.add(n1); +// break; +// case "tvm.stackEntryCell": +// TvmStackEntryCell c1 = context.deserialize(elInner, TvmStackEntryCell.class); +// stack.add(c1); +// break; +// case "tvm.stackEntrySlice": +// TvmStackEntrySlice s1 = context.deserialize(elInner, TvmStackEntrySlice.class); +// stack.add(s1); +// break; +// case "tvm.stackEntryList": +// TvmStackEntryList l1 = context.deserialize(elInner, TvmStackEntryList.class); +// stack.add(l1); +// break; +// case "tvm.stackEntryTuple": +// TvmStackEntryTuple t1 = context.deserialize(elInner, TvmStackEntryTuple.class); +// stack.add(t1); +// break; +// } + } + return RunResult.builder() + .stack(stack) + .exit_code(exitCode) + .gas_used(gasUsed) + .build(); + }; + + gsonBuilder.registerTypeAdapter(RunResult.class, deserializer); + gsonBuilder.registerTypeAdapter(TvmStackEntryNumber.class, deserializerStackEntryNumber); + gsonBuilder.registerTypeAdapter(TvmStackEntryCell.class, deserializerStackEntryCell); + gsonBuilder.registerTypeAdapter(TvmStackEntrySlice.class, deserializerStackEntrySlice); + gsonBuilder.registerTypeAdapter(TvmStackEntryList.class, deserializerStackEntryList); + gsonBuilder.registerTypeAdapter(TvmStackEntryTuple.class, deserializerStackEntryTuple); + + customGson = gsonBuilder.setObjectToNumberStrategy(ToNumberPolicy.BIG_DECIMAL).create(); + } + + public RunResult parse(String runMethodResult) { + return customGson.fromJson(runMethodResult, RunResult.class); + } + + private Object deserializeByType(String type, JsonElement jsonElement, JsonDeserializationContext context) { + return switch (type) { + case "tvm.stackEntryNumber" -> context.deserialize(jsonElement, TvmStackEntryNumber.class); + case "tvm.stackEntryCell" -> context.deserialize(jsonElement, TvmStackEntryCell.class); + case "tvm.stackEntrySlice" -> context.deserialize(jsonElement, TvmStackEntrySlice.class); + case "tvm.stackEntryList" -> context.deserialize(jsonElement, TvmStackEntryList.class); + case "tvm.stackEntryTuple" -> context.deserialize(jsonElement, TvmStackEntryTuple.class); + default -> null; + }; + } +} diff --git a/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java b/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java index d35a99c2..5e711a6d 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java @@ -96,6 +96,8 @@ public class Tonlib { private boolean synced; + RunResultParser runResultParser; + public static TonlibBuilder builder() { return new CustomTonlibBuilder(); } @@ -105,29 +107,15 @@ private static class CustomTonlibBuilder extends TonlibBuilder { public Tonlib build() { try { - String tonlibName = null; - switch (Utils.getOS()) { - case LINUX: - tonlibName = "tonlibjson.so"; - break; - case LINUX_ARM: - tonlibName = "tonlibjson-arm.so"; - break; - case WINDOWS: - tonlibName = "tonlibjson.dll"; - break; - case WINDOWS_ARM: - tonlibName = "tonlibjson-arm.dll"; - break; - case MAC: - tonlibName = "tonlibjson.dylib"; - break; - case MAC_ARM64: - tonlibName = "tonlibjson-arm.dylib"; - break; - case UNKNOWN: - throw new Error("Operating system is not supported!"); - } + String tonlibName = switch (Utils.getOS()) { + case LINUX -> "tonlibjson.so"; + case LINUX_ARM -> "tonlibjson-arm.so"; + case WINDOWS -> "tonlibjson.dll"; + case WINDOWS_ARM -> "tonlibjson-arm.dll"; + case MAC -> "tonlibjson.dylib"; + case MAC_ARM64 -> "tonlibjson-arm.dylib"; + case UNKNOWN -> throw new Error("Operating system is not supported!"); + }; if (isNull(super.pathToTonlibSharedLib)) { super.pathToTonlibSharedLib = tonlibName; @@ -150,6 +138,7 @@ public Tonlib build() { } super.synced = false; + super.runResultParser = new RunResultParser(); String configData; if (isNull(super.pathToGlobalConfig)) { @@ -658,11 +647,7 @@ public RunResult runMethod(long contractId, String methodName, Deque sta String result = syncAndRead(); -// System.out.println("result 1: " + result); - RunResultGeneric g = gson.fromJson(result, RunResultGeneric.class); -// System.out.println("result 2: " + g); - - return ParseRunResult.getTypedRunResult(g.getStack(), g.getExit_code(), g.getGas_used()); + return runResultParser.parse(result); } /** diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/ParseRunResult.java b/tonlib/src/main/java/org/ton/java/tonlib/types/ParseRunResult.java index b2541f64..2bed93aa 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/ParseRunResult.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/ParseRunResult.java @@ -3,12 +3,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.ToNumberPolicy; -import com.google.gson.internal.LinkedTreeMap; -import org.apache.commons.lang3.StringUtils; import org.ton.java.cell.Cell; import org.ton.java.utils.Utils; -import java.util.*; +import java.util.ArrayDeque; +import java.util.Arrays; +import java.util.Base64; +import java.util.Deque; import static java.util.Objects.isNull; @@ -19,7 +20,7 @@ public class ParseRunResult { .create(); // key - marker(UUID), value - original string - public static Map markers = new HashMap<>(); +// public static Map markers = new HashMap<>(); /** * @param elementType - "num", "number", "int", "cell", "slice" @@ -95,96 +96,6 @@ public static String serializeTvmElement(TvmStackEntry entry) { } } - public static TvmStackEntry parseJsonElement(Object element) { - LinkedTreeMap t = (LinkedTreeMap) element; - - String key1 = (String) t.keySet().toArray()[0]; - Object val1 = t.get(key1); - String key2 = (String) t.keySet().toArray()[1]; - Object val2 = t.get(key2); - - if (key2.equals("tuple")) { - return (TvmStackEntryTuple) parseJsonElement(val2); - } else if (key2.equals("list")) { - return (TvmStackEntryList) parseJsonElement(val2); - } else if (key2.equals("elements")) { - List elements = gson.fromJson(String.valueOf(val2), List.class); - List resultElements = new ArrayList<>(); //TvmStackEntry - - for (Object o : elements) { - LinkedTreeMap tt = (LinkedTreeMap) o; - String k1 = (String) tt.keySet().toArray()[0]; - Object v1 = tt.get(k1); - String k2 = (String) tt.keySet().toArray()[1]; - Object v2 = tt.get(k2); - - if (v1.equals("tvm.stackEntryNumber")) { - TvmNumber number = gson.fromJson(String.valueOf(v2), TvmNumber.class); - TvmStackEntryNumber stackNumber = TvmStackEntryNumber.builder() - .number(number) - .build(); - resultElements.add(stackNumber); - } else if (v1.equals("tvm.stackEntryCell")) { - TvmCell cell = gson.fromJson(String.valueOf(v2), TvmCell.class); - String key = cell.getBytes(); - cell.setBytes(markers.get(key)); - markers.remove(key); - TvmStackEntryCell stackCell = TvmStackEntryCell.builder() - .cell(cell) - .build(); - resultElements.add(stackCell); - } else if (v1.equals("tvm.stackEntrySlice")) { - TvmSlice slice = gson.fromJson(String.valueOf(v2), TvmSlice.class); - String key = slice.getBytes(); - slice.setBytes(markers.get(key)); - markers.remove(key); - - TvmStackEntrySlice stackSlice = TvmStackEntrySlice.builder() - .slice(slice) - .build(); - resultElements.add(stackSlice); - } else if (v1.equals("tuple")) { - resultElements.add(parseJsonElement(val2)); - } else if (v1.equals("tvm.stackEntryTuple")) { - resultElements.add(parseJsonElement(v2)); - } else if (v1.equals("list")) { - resultElements.add(parseJsonElement(val2)); - } else if (v1.equals("tvm.stackEntryList")) { - resultElements.add(parseJsonElement(v2)); - } - } - - if (val1.equals("tvm.tuple")) { - return TvmStackEntryTuple.builder() - .tuple(TvmTuple.builder() - .elements(resultElements) - .build()) - .build(); - } else if (val1.equals("tvm.list")) { - - return TvmStackEntryList.builder() - .list(TvmList.builder() - .elements(resultElements) - .build()) - .build(); - } - } else if (key2.equals("number")) { - return gson.fromJson(String.valueOf(element), TvmStackEntryNumber.class); - } else if (key2.equals("cell")) { - TvmStackEntryCell cell = gson.fromJson(String.valueOf(element), TvmStackEntryCell.class); - String key = cell.getCell().getBytes(); - cell.getCell().setBytes(markers.get(key)); - markers.remove(key); - return cell; - } else if (key2.equals("slice")) { - TvmStackEntrySlice slice = gson.fromJson(String.valueOf(element), TvmStackEntrySlice.class); - String key = slice.getSlice().getBytes(); - slice.getSlice().setBytes(markers.get(key)); - markers.remove(key); - return slice; - } - throw new Error("Error parsing json element"); - } public static Deque serializeTvmStack(Deque tvmStack) { @@ -195,81 +106,6 @@ public static Deque serializeTvmStack(Deque tvmStack) { return stack; } - public static TvmStackEntryList parseTvmEntryListStack(TvmStackEntryList list) { - List els = new ArrayList<>(); - - for (Object o : list.getList().getElements()) { - LinkedTreeMap t = (LinkedTreeMap) o; - els.add(parseJsonElement(t)); - } - - TvmStackEntryList listResult = TvmStackEntryList.builder().build(); - TvmList tvmList = TvmList.builder().build(); - tvmList.setElements(els); - listResult.setList(tvmList); - return listResult; - } - - public static TvmStackEntryTuple parseTvmEntryTupleStack(TvmStackEntryTuple list) { - List els = new ArrayList<>(); - - for (Object o : list.getTuple().getElements()) { - LinkedTreeMap t = (LinkedTreeMap) o; - els.add(parseJsonElement(t)); - } - - TvmStackEntryTuple listResult = TvmStackEntryTuple.builder().build(); - TvmTuple tvmTuple = TvmTuple.builder().build(); - tvmTuple.setElements(els); - listResult.setTuple(tvmTuple); - return listResult; - } - - public static RunResult getTypedRunResult(List stack, long exitCode, long gasUsed) { - - List resultStack = new ArrayList<>(); - for (int i = 0; i < stack.size(); i++) { - String stackElement = String.valueOf(stack.get(i)); - - stackElement = temporaryReplaceBase64(stackElement, stackElement, "@type=tvm.cell"); - stackElement = temporaryReplaceBase64(stackElement, stackElement, "@type=tvm.slice"); - - String resultEscaped = stackElement; - - if (resultEscaped.substring(0, resultEscaped.indexOf(",")).contains("stackEntryList")) { - TvmStackEntryList list = gson.fromJson(resultEscaped, TvmStackEntryList.class); - list = parseTvmEntryListStack(list); - resultStack.add(list); - } else if (resultEscaped.substring(0, resultEscaped.indexOf(",")).contains("stackEntryTuple")) { - TvmStackEntryTuple tuple = gson.fromJson(resultEscaped, TvmStackEntryTuple.class); - tuple = parseTvmEntryTupleStack(tuple); - resultStack.add(tuple); - } else if (resultEscaped.substring(0, resultEscaped.indexOf(",")).contains("stackEntryNumber")) { - TvmStackEntryNumber number = gson.fromJson(resultEscaped, TvmStackEntryNumber.class); - resultStack.add(number); - } else if (resultEscaped.substring(0, resultEscaped.indexOf(",")).contains("stackEntryCell")) { - TvmStackEntryCell cell = gson.fromJson(resultEscaped, TvmStackEntryCell.class); - String key = cell.getCell().getBytes(); - cell.getCell().setBytes(markers.get(key)); - markers.remove(key); - resultStack.add(cell); - } else if (resultEscaped.substring(0, resultEscaped.indexOf(",")).contains("stackEntrySlice")) { - TvmStackEntrySlice slice = gson.fromJson(resultEscaped, TvmStackEntrySlice.class); - String key = slice.getSlice().getBytes(); - slice.getSlice().setBytes(markers.get(key)); - markers.remove(key); - resultStack.add(slice); - } else { - throw new Error("Unknown type in TVM stack"); - } - } // end for stack - return RunResult.builder() - .stackEntry(resultStack) - .exit_code(exitCode) - .gas_used(gasUsed) - .build(); - } - private static String bytesToBase64(byte[] bytes) { return Base64.getEncoder().encodeToString(bytes); } @@ -319,21 +155,4 @@ private static int findPosOfClosingBracket(String str, String pattern) { } return -1; } - - /** - * workaround since Gson cannot deserialize deep nested long base64 strings; - * replace cell values in a "bytes" field with the UUID, after deserialization to gson, replace UUID with original values - */ - private static String temporaryReplaceBase64(String originalResult, String processResult, String template) { - while (processResult.contains(template)) { - String oldCell = sbb(processResult, "{" + template); - String oldCellBytes = oldCell.substring(oldCell.indexOf("bytes=") + 6, oldCell.length() - 1); - String uuid = UUID.randomUUID().toString(); - String newCell = StringUtils.replaceOnce(oldCell, oldCellBytes, uuid); - markers.put(uuid, oldCellBytes); - originalResult = StringUtils.replaceOnce(originalResult, oldCell, newCell); - processResult = StringUtils.replaceOnce(processResult, oldCell, ""); - } - return originalResult; - } } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RunResult.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RunResult.java index c7189fb5..721f0f61 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RunResult.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RunResult.java @@ -5,6 +5,7 @@ import lombok.Setter; import lombok.ToString; +import java.math.BigInteger; import java.util.List; @Builder @@ -12,8 +13,8 @@ @Getter @ToString public class RunResult { - List stackEntry; - long gas_used; + List stack; + BigInteger gas_used; long exit_code; } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RunResultGeneric.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RunResultGeneric.java deleted file mode 100644 index 4f94530e..00000000 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RunResultGeneric.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.ton.java.tonlib.types; - -import com.google.gson.annotations.SerializedName; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -import java.util.List; - -@Builder -@Setter -@Getter -@ToString -public class RunResultGeneric { - @SerializedName("@type") - final String type = "smc.runResult"; - long gas_used; - List stack; - long exit_code; -} - diff --git a/tonlib/src/test/java/org/ton/java/tonlib/TestConcurrentTonlib.java b/tonlib/src/test/java/org/ton/java/tonlib/TestConcurrentTonlib.java index ca2eafef..a076e4f9 100644 --- a/tonlib/src/test/java/org/ton/java/tonlib/TestConcurrentTonlib.java +++ b/tonlib/src/test/java/org/ton/java/tonlib/TestConcurrentTonlib.java @@ -41,7 +41,8 @@ public void testTonlibRunMethod() { RunResult result = tonlib.runMethod(elector, "compute_returned_stake", stack); - BigInteger returnStake = ((TvmStackEntryNumber) result.getStackEntry().get(0)).getNumber(); + BigInteger returnStake = ((TvmStackEntryNumber) result.getStack().get(0)).getNumber(); + log.info("return stake: {} ", Utils.formatNanoValue(returnStake.longValue())); assertThat(result.getExit_code()).isEqualTo(0L); } diff --git a/tonlib/src/test/java/org/ton/java/tonlib/TestParseRunMethodResults.java b/tonlib/src/test/java/org/ton/java/tonlib/TestParseRunMethodResults.java index 6114ff8d..c36bf37b 100644 --- a/tonlib/src/test/java/org/ton/java/tonlib/TestParseRunMethodResults.java +++ b/tonlib/src/test/java/org/ton/java/tonlib/TestParseRunMethodResults.java @@ -4,18 +4,22 @@ import com.google.gson.GsonBuilder; import com.google.gson.ToNumberPolicy; import lombok.extern.slf4j.Slf4j; +import org.assertj.core.api.Assertions; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.ton.java.address.Address; import org.ton.java.cell.CellBuilder; import org.ton.java.tonlib.types.*; import org.ton.java.utils.Utils; +import java.math.BigInteger; import java.util.ArrayDeque; import java.util.Deque; import java.util.Objects; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.ton.java.tonlib.TestTonlibJson.ELECTOR_ADDRESSS; @Slf4j @RunWith(JUnit4.class) @@ -48,52 +52,37 @@ public void tesTvmRenderStack() { assertThat(r0.size()).isZero(); } - @Test - public void tesTvmRenderParticipantsList() { - - String tonlib_result_participants_list = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("participants_list.json"))); - - TvmStackEntryList list = gson.fromJson(tonlib_result_participants_list, TvmStackEntryList.class); - - log.info(list.toString()); - - TvmStackEntryList listResult = ParseRunResult.parseTvmEntryListStack(list); - - for (Object l : listResult.getList().getElements()) { - TvmStackEntryTuple tuple = (TvmStackEntryTuple) l; - log.info(tuple.toString()); - } - - assertThat(listResult.getList().getElements()).isNotEqualTo(0); - } - @Test public void testGetTypeRunResultStackTuple() { String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodResultStackEntryTuple.json"))); - RunResultGeneric g = gson.fromJson(stackTuple, RunResultGeneric.class); - log.info("generic: {}", g); - RunResult result = ParseRunResult.getTypedRunResult(g.getStack(), 0, 0); - log.info(result.toString()); + RunResult result = new RunResultParser().parse(stackTuple); + log.info("result {}", result.toString()); } @Test public void testGetTypeRunResultStackList() { String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodResultStackEntryList.json"))); - RunResultGeneric g = gson.fromJson(stackTuple, RunResultGeneric.class); - log.info("generic: {}", g); - RunResult result = ParseRunResult.getTypedRunResult(g.getStack(), 0, 0); - log.info(result.toString()); + RunResult result = new RunResultParser().parse(stackTuple); + log.info("result {}", result.toString()); + } + + @Test + public void testGetTypeRunResultStackListDeserializer() { + String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodNumbers.json"))); + + + RunResult result = new RunResultParser().parse(stackTuple); + log.info("RunResult: {}", result); + } @Test public void testGetTypeRunResultStackTupleWithList() { String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodResultStackEntryTupleWithList.json"))); - RunResultGeneric g = gson.fromJson(stackTuple, RunResultGeneric.class); - log.info("g: {}", g); - RunResult result = ParseRunResult.getTypedRunResult(g.getStack(), 0, 0); + RunResult result = new RunResultParser().parse(stackTuple); log.info(result.toString()); } @@ -101,9 +90,7 @@ public void testGetTypeRunResultStackTupleWithList() { public void testGetTypeRunResultStackEntryListWithTuple() { String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodResultStackEntryListWithTuple.json"))); - RunResultGeneric g = gson.fromJson(stackTuple, RunResultGeneric.class); - log.info("g: {}", g); - RunResult result = ParseRunResult.getTypedRunResult(g.getStack(), 0, 0); + RunResult result = new RunResultParser().parse(stackTuple); log.info(result.toString()); } @@ -111,55 +98,70 @@ public void testGetTypeRunResultStackEntryListWithTuple() { public void testGetTypeRunResultStackEntryListPastElections() { String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodResultPastElections.json"))); - RunResultGeneric g = gson.fromJson(stackTuple, RunResultGeneric.class); - log.info("g: {}", g); - RunResult result = ParseRunResult.getTypedRunResult(g.getStack(), 0, 0); + RunResult result = new RunResultParser().parse(stackTuple); log.info("result {}", result.toString()); - log.info("{}", ParseRunResult.markers.size()); } @Test public void testGetTypeRunResultGetSubscriptionData() { String stackTuple = Utils.streamToString(Objects.requireNonNull(TestTonlibJson.class.getClassLoader().getResourceAsStream("RunMethodGetSubscriptionData.json"))); - RunResultGeneric g = gson.fromJson(stackTuple, RunResultGeneric.class); - log.info("g: {}", g); - - RunResult result = ParseRunResult.getTypedRunResult(g.getStack(), 0, 0); - log.info(result.toString()); + RunResult result = new RunResultParser().parse(stackTuple); + log.info("result {}", result.toString()); - TvmStackEntryTuple walletAddr = (TvmStackEntryTuple) result.getStackEntry().get(0); + TvmStackEntryTuple walletAddr = (TvmStackEntryTuple) result.getStack().get(0); TvmStackEntryNumber wc = (TvmStackEntryNumber) walletAddr.getTuple().getElements().get(0); TvmStackEntryNumber hash = (TvmStackEntryNumber) walletAddr.getTuple().getElements().get(1); log.info("walletAddr: {}:{}", wc.getNumber(), hash.getNumber().toString(16)); - TvmStackEntryTuple beneficiaryAddr = (TvmStackEntryTuple) result.getStackEntry().get(1); + TvmStackEntryTuple beneficiaryAddr = (TvmStackEntryTuple) result.getStack().get(1); TvmStackEntryNumber beneficiaryAddrWc = (TvmStackEntryNumber) beneficiaryAddr.getTuple().getElements().get(0); TvmStackEntryNumber beneficiaryAddrHash = (TvmStackEntryNumber) beneficiaryAddr.getTuple().getElements().get(1); log.info("walletAddr: {}:{}", beneficiaryAddrWc.getNumber(), beneficiaryAddrHash.getNumber().toString(16)); - TvmStackEntryNumber amount = (TvmStackEntryNumber) result.getStackEntry().get(2); + TvmStackEntryNumber amount = (TvmStackEntryNumber) result.getStack().get(2); log.info("amount: {}", amount.getNumber()); - TvmStackEntryNumber period = (TvmStackEntryNumber) result.getStackEntry().get(3); + TvmStackEntryNumber period = (TvmStackEntryNumber) result.getStack().get(3); log.info("period: {}", period.getNumber()); - TvmStackEntryNumber startTime = (TvmStackEntryNumber) result.getStackEntry().get(4); + TvmStackEntryNumber startTime = (TvmStackEntryNumber) result.getStack().get(4); log.info("startTime: {}", startTime.getNumber()); - TvmStackEntryNumber timeOut = (TvmStackEntryNumber) result.getStackEntry().get(5); + TvmStackEntryNumber timeOut = (TvmStackEntryNumber) result.getStack().get(5); log.info("timeOut: {}", timeOut.getNumber()); - TvmStackEntryNumber lastPaymentTime = (TvmStackEntryNumber) result.getStackEntry().get(6); + TvmStackEntryNumber lastPaymentTime = (TvmStackEntryNumber) result.getStack().get(6); log.info("lastPaymentTime: {}", lastPaymentTime.getNumber()); - TvmStackEntryNumber lastRequestTime = (TvmStackEntryNumber) result.getStackEntry().get(7); + TvmStackEntryNumber lastRequestTime = (TvmStackEntryNumber) result.getStack().get(7); log.info("lastRequestTime: {}", lastRequestTime.getNumber()); - TvmStackEntryNumber failedAttempts = (TvmStackEntryNumber) result.getStackEntry().get(8); + TvmStackEntryNumber failedAttempts = (TvmStackEntryNumber) result.getStack().get(8); log.info("failedAttempts: {}", failedAttempts.getNumber()); - TvmStackEntryNumber subscriptionId = (TvmStackEntryNumber) result.getStackEntry().get(9); + TvmStackEntryNumber subscriptionId = (TvmStackEntryNumber) result.getStack().get(9); log.info("subscriptionId: {}", subscriptionId.getNumber()); } + + @Test + public void testTonlibComputeReturnedStake() { + Tonlib tonlib = Tonlib.builder() + .build(); + + MasterChainInfo last = tonlib.getLast(); + log.info("last: {}", last); + + Address elector = Address.of(ELECTOR_ADDRESSS); + Deque stack = new ArrayDeque<>(); + Address address = Address.of("Ef_sR2c8U-tNfCU5klvd60I5VMXUd_U9-22uERrxrrt3uzYi"); + stack.offer("[num, " + address.toDecimal() + "]"); + + RunResult result = tonlib.runMethod(elector, "compute_returned_stake", stack); + + BigInteger returnStake = ((TvmStackEntryNumber) result.getStack().get(0)).getNumber(); + + log.info("return stake: {} ", Utils.formatNanoValue(returnStake.longValue())); + Assertions.assertThat(result.getExit_code()).isEqualTo(0L); + } } diff --git a/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java b/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java index 4c394e9c..7e27324b 100644 --- a/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java +++ b/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java @@ -327,7 +327,7 @@ public void testTonlibKeystorePath() { Address address = Address.of("Ef8-sf_0CQDgwW6kNuNY8mUvRW-MGQ34Evffj8O0Z9Ly1tZ4"); RunResult result = tonlib.runMethod(address, "seqno"); log.info("gas_used {}, exit_code {} ", result.getGas_used(), result.getExit_code()); - TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack().get(0); log.info("seqno: {}", seqno.getNumber()); assertThat(result.getExit_code()).isZero(); } @@ -340,7 +340,7 @@ public void testTonlibRunMethodSeqno() { Address address = Address.of(TON_FOUNDATION); RunResult result = tonlib.runMethod(address, "seqno"); log.info("gas_used {}, exit_code {} ", result.getGas_used(), result.getExit_code()); - TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber seqno = (TvmStackEntryNumber) result.getStack().get(0); log.info("seqno: {}", seqno.getNumber()); assertThat(result.getExit_code()).isZero(); } @@ -363,7 +363,7 @@ public void testTonlibRunMethodParticipantsList() { RunResult result = tonlib.runMethod(address, "participant_list"); log.info(result.toString()); - TvmStackEntryList listResult = (TvmStackEntryList) result.getStackEntry().get(0); + TvmStackEntryList listResult = (TvmStackEntryList) result.getStack().get(0); for (Object o : listResult.getList().getElements()) { TvmStackEntryTuple t = (TvmStackEntryTuple) o; TvmTuple tuple = t.getTuple(); @@ -379,7 +379,7 @@ public void testTonlibRunMethodActiveElectionId() { Tonlib tonlib = Tonlib.builder().build(); Address address = Address.of("-1:3333333333333333333333333333333333333333333333333333333333333333"); RunResult result = tonlib.runMethod(address, "active_election_id"); - TvmStackEntryNumber electionId = (TvmStackEntryNumber) result.getStackEntry().get(0); + TvmStackEntryNumber electionId = (TvmStackEntryNumber) result.getStack().get(0); log.info("electionId: {}", electionId.getNumber()); assertThat(result.getExit_code()).isZero(); } @@ -389,7 +389,7 @@ public void testTonlibRunMethodPastElectionsId() { Tonlib tonlib = Tonlib.builder().build(); Address address = Address.of("-1:3333333333333333333333333333333333333333333333333333333333333333"); RunResult result = tonlib.runMethod(address, "past_election_ids"); - TvmStackEntryList listResult = (TvmStackEntryList) result.getStackEntry().get(0); + TvmStackEntryList listResult = (TvmStackEntryList) result.getStack().get(0); for (Object o : listResult.getList().getElements()) { TvmStackEntryNumber electionId = (TvmStackEntryNumber) o; log.info(electionId.getNumber().toString()); @@ -402,7 +402,7 @@ public void testTonlibRunMethodPastElections() { Tonlib tonlib = Tonlib.builder().build(); Address address = Address.of("-1:3333333333333333333333333333333333333333333333333333333333333333"); RunResult result = tonlib.runMethod(address, "past_elections"); - TvmStackEntryList listResult = (TvmStackEntryList) result.getStackEntry().get(0); + TvmStackEntryList listResult = (TvmStackEntryList) result.getStack().get(0); log.info("pastElections: {}", listResult); assertThat(result.getExit_code()).isZero(); @@ -433,7 +433,7 @@ public void testTonlibRunMethodComputeReturnedStake() { stack.offer("[num," + validatorAddress.toDecimal() + "]"); result = tonlib.runMethod(elector, "compute_returned_stake", stack); - BigInteger returnStake = ((TvmStackEntryNumber) result.getStackEntry().get(0)).getNumber(); + BigInteger returnStake = ((TvmStackEntryNumber) result.getStack().get(0)).getNumber(); log.info("return stake: {} ", Utils.formatNanoValue(returnStake.longValue())); } } \ No newline at end of file diff --git a/tonlib/src/test/resources/RunMethodGetSubscriptionData.json b/tonlib/src/test/resources/RunMethodGetSubscriptionData.json index e3c3b350..37aa0d63 100644 --- a/tonlib/src/test/resources/RunMethodGetSubscriptionData.json +++ b/tonlib/src/test/resources/RunMethodGetSubscriptionData.json @@ -103,6 +103,5 @@ } } ], - "exit_code": 0, - "@extra": "146f5e93-6751-43d8-844b-20e858fa5d55" + "exit_code": 42 } \ No newline at end of file diff --git a/tonlib/src/test/resources/RunMethodNumbers.json b/tonlib/src/test/resources/RunMethodNumbers.json new file mode 100644 index 00000000..a587b786 --- /dev/null +++ b/tonlib/src/test/resources/RunMethodNumbers.json @@ -0,0 +1,208 @@ +{ + "@type": "smc.runResult", + "gas_used": 6276, + "stack": [ + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "0" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "124" + } + }, + { + "@type": "tvm.stackEntryCell", + "cell": { + "@type": "tvm.cell", + "bytes": "te6cckECIQEABc" + } + }, + { + "@type": "tvm.stackEntryList", + "list": { + "@type": "tvm.list", + "elements": [ + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "111" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "222" + } + }, + { + "@type": "tvm.stackEntryCell", + "cell": { + "@type": "tvm.cell", + "bytes": "te6cckECIQEABcAAAgE" + } + }, + { + "@type": "tvm.stackEntryList", + "list": { + "@type": "tvm.list", + "elements": [ + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "777" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "888" + } + }, + { + "@type": "tvm.stackEntryCell", + "cell": { + "@type": "tvm.cell", + "bytes": "te6cc" + } + } + ] + } + } + ] + } + }, + { + "@type": "tvm.stackEntryTuple", + "tuple": { + "@type": "tvm.tuple", + "elements": [ + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "1655397962" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "1655406062" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "900" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "20224315222834892040910520959613509512879128406473594936956787164646029239082" + } + }, + { + "@type": "tvm.stackEntryCell", + "cell": { + "@type": "tvm.cell", + "bytes": "te6cckECIQEABcAAAgEgAQICASADBAIBIBMUAgEgBQYCASALDAIBSAcIAgEgCQoAn77xFPYdHud9/XxD27SE7dRVs+VB2Dszjptk+r0hCda77sIl4gcHPfvbi4Xk+BEwFesBwPKU1moLbnV7g+SWPQTQB4eHPTioaOsteWpvuwAgAJ++6UDuDPaZ11DNvWyM4pD9eo1jO0f8NBVbMae8ZiuoKyJP9t7QDSd19GebDmn3GAuqo+zFMSZx/JXhzz9eKy2p4AeHhz04qGjrLXlqb7sAIACfvz9A1RquY4ise4uFFNrl3Yi7rgJNBOPN+lUUcW11zh+WW01uSNP6AXyYNnTh46HeMb85YRiXgKU0rbyTwiSSllQDw8OenFQ0dZa8tTfdgBAAn78h6bEtkGxCXjOy6yeiyNNjgjcqmfjl6AY7DGRKdnwV/2A6+F3xMUqpDypX6mikQP+JYQ89a5Cp5P4PctU7ZpToA8PDnpxUNHWWvLU33YAQAgEgDQ4CASAREgCfvwPw+A7wo00AfYzNhCethcribk6CoI7lSamH73vShI69Spcur8lhgeQIdp8Ixa6HYhfY6foAwRH9kD6MyJiuoGgDw8OenFQ0dZa8tTfdgBACAVgPEACfvpreMNECQEOCN9mrzBfMTORWR2PVF212T4UoF/Z+jNCM4zbpVbdOc4uBGouBhdC8v7YmCu8wUDHR8DR0voWNRKAPDxhY6vLiplrzEHpAAEAAn764ZUZkjiqvbf25Ew/WHZGG3K5pCYsg22ptZS6K/JGy/sPxv06KagKaRmOOKxeDQwApCx3i8IQOwv507XD51JOADw8OenFQ0dZa8tTfdgBAAJ+/GkuGo2B6KHr9ZMbFuIximKXqiSDAf3RKl/5/ndjnQ2r3NoiFwqC68r05AsyPBm9FePRMIhDImBT4DIaVxXsoEAPDw56cVDR1lry1N92AEACfvy1cK0tYN8lpg+ktVcV/sXP0e+GS+dzU0v55537zJmGqP7TkmgbMHqI8tWvp23qrt2PTgwqc6ueV9PV5F6xLUswDw8OenFQ0dZa8tTfdgBACASAVFgIBIBkaAgFIFxgAn79oXEYExforx4u9yid7XZvr5fl36425ebUjXRcHfpD55aPEsXsMywdKstmbXuGqCaxfebamaJ4UpBOshkHDuPyQAeHhz04qGjrLXlqb7sAIAJ++yb1zERD4FoZU9ah/uQR1icCiXDc4Nptz7ej5uxtrDW6ZGIIoPkg4SlNM7S1Lmv4XLmlpYbXNreuZfuVgMC2cEAeHhz04qGjrLXlqb7sAIACfvsG51s3lxH52I90zUPWawzqjVQnrB4+bY+eM0AXK3AKOXPKKQLqWjq27vDMh7nffetKOmTIinF00yPWYTy17OigHh4c9OKho6y15am+7ACAAn79st32CBdCacq9xDxq8fYUZ/71Y2CEu9as6f3aOUSdlUjCRe9rXnpGuSWqibavlUS9oppb46aKqh9TeHeiwLFV2AeHhz04qGjrLXlqb7sAIAgEgGxwCAUgdHgCfvwIzWf0m1cLymZp9GzQahy1OWDY8kXNIY61oW9i0nQ6cYha0a0hIHdFEHdfDpK0o5ElArz5FJHUzx2qIXOOkf0QDw8OenFQ0dZa8tTfdgBAAn76iQY+Vde/Lufxyl0jGCn8g8xm2WCFJ/0rJAGZAglc29drFfgaIqxNxEBpONohiNBEaxaWZzRQkk5kUj8eaI7dwDw8OenFQ0dZa8tTfdgBAAgFYHyAAnb4GWkvIMQKze4YjE50tEaW6C8h1nZcX5f3r0jS+DOHAOLxDXaLpW997JoE4EV4LLl1TtRibpM5+OCHIMK2YBx+APDw56cVDR1lry1N92AEAnb4C9Cd1v2qe/93ujjz5jsHIokKxEdmZZQpN4OcYfLVbxog/D9rLTh9cm2sLRr+iBAfPOrOjTPzoSCxe/rWZKhJAPDw56cVDR1lry1N92AG4qNxt" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "1699984000000000" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "2289789918651" + } + }, + { + "@type": "tvm.stackEntryList", + "list": { + "@type": "tvm.list", + "elements": [ + { + "@type": "tvm.stackEntryTuple", + "tuple": { + "@type": "tvm.tuple", + "elements": [ + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "1655369162" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "1655377262" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "900" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "42351514466890978821103931745645426908480833706817633891839160753551019660519" + } + }, + { + "@type": "tvm.stackEntryCell", + "cell": { + "@type": "tvm.cell", + "bytes": "te6cckECJQEABm4AAgEgAQICASADBAIBIBESAgEgBQYCASALDAIBIAcIAgFICQoAn78ILXHthAeypmM2X4cYHkx1tYLxKpWFGLr1AVEiYwakPfYM+fEhMQ3sRVSbXjkmXDw8RXro0XCuDsvagYXyQuS8A15QudXKvGGWvLU33YAQAJ+/Lsvwy12Jfn3VshRTutbzxCuc4zrj10AAumOWEeeuOkUn+29oBpO6+jPNhzT7jAXVUfZimJM4/krw55+vFZbU8ANeULnVyrxhlry1N92AEACfvs42p2Hj7J7A3ma+5ZwU9pANOP0msA9dR0qW98z6KUi4wkXva156Rrklqom2r5VEvaKaW+OmiqofU3h3osCxVdgGvKFzq5V4wy15am+7ACAAn77adhzAke9OGWnWpNQRY4GtF8aQYklpjIipRh0EYrgLdxeIa7RdK3vvZNAnAivBZcuqdqMTdJnPxwQ5BhWzAOPwBryhc6uVeMMteWpvuwAgAJ+/TcAPpe5q08fTeo64Su8irjnU5PVBPZyvtxKUeYoeebQxC1o1pCQO6KIO6+HSVpRyJKBXnyKSOpnjtUQucdI/ogGvKFzq5V4wy15am+7ACAIBIA0OAgEgDxAAn78z76R5tipILXCz3s3awq26txEYd16l9nUns8bhZnpWgy55RSBdS0dW3d4ZkPc7771pR0yZEU4ummR6zCeWvZ0UA15QudXKvGGWvLU33YAQAJ++/u8wT7qcPORBiMIeG/FiT4tJ9fgWOIScxg5fRS3kbTLtYr8DRFWJuIgNJxtEMRoIjWLSzOaKEknMikfjzRHbuAa8oXOrlXjDLXlqb7sAIACfvsF84acJjVV79uAcmQmt90uuGwlKDSmaq2Q8F15sguTg0Qfh+1lpw+uTbWFo1/RAgPnnVnRpn50JBYvf1rMlQkgGvKFzq5V4wy15am+7ACACASATFAIBYiEiAgEgFRYCASAbHACfvyGYc+ZW6EAmb3I1gbu+dXVJVRG1QhsBgSOBiRZqoIITsPxv06KagKaRmOOKxeDQwApCx3i8IQOwv507XD51JOADXlC51cq8YZa8tTfdgBACASAXGACfvtVJnVFFrYA1dcQYDH+U2N+hH46d/oifPcwd3H6of21mwiXiBwc9+9uLheT4ETAV6wHA8pTWagtudXuD5JY9BNAGvKFzq5V4wy15am+7ACACASAZGgCfvqA8fn0HO+bAJymmp7erSc52gFXFl9/IQwIcUnYr2Cg4/tOSaBsweojy1a+nbequ3Y9ODCpzq55X09XkXrEtSzANeULnVyrxhlry1N92AEAAn76k5QOwotIq/Xut25X8hVOkTNb3bAC2coT/pTWGk2pXDTIxBFB8kHCUppnaWpc1/C5c0tLDa5tb1zL9ysBgWzggDXlC51cq8YZa8tTfdgBAAgEgHR4An78aDve6lX6g8I0q8Bjp+nKSRspxHA1FjQ4yKXgSY5xGFltNbkjT+gF8mDZ04eOh3jG/OWEYl4ClNK28k8IkkpZUA15QudXKvGGWvLU33YAQAJ++3DAWlTFjKwWezpTUrRu3Hk/mdaf/gjWhu4vuwhPxeH3ubRELhUF15XpyBZkeDN6K8eiYRCGRMCnwGQ0rivZQIAa8oXOrlXjDLXlqb7sAIAIBIB8gAJ++iWkZqi9RdH2Fib19a4ZRJ/LaX5zsO1dhpzqSLnCIzO0eJYvYZlg6VZbM2vcNUE1i+821M0TwpSCdZDIOHcfkgA15QudXKvGGWvLU33YAQACfvpOMwU57+njMRI7D9Mgg60KBnCugpXeLLwnWPQTv3iIwLnQbUu0853AHqYz0Ul6oMZioPQMY45godjM9SjCSMqANeULnVyrxhlry1N92AEACAUgjJACfvtfXr0ebMmKH1uRCT2OVKUfemEFRxgouk1d1TSh1Np/WwHXwu+JilVIeVK/U0UiB/xLCHnrXIVPJ/B7lqnbNKdAGvKFzq5V4wy15am+7ACAAnr5jFBB6vxUJCAupEtig6rD96a4x8nm7757PkjqEY6lu6lS5dX5LDA8gQ7T4Ri10OxC+x0/QBgiP7IH0ZkTFdQNAGvKFzq5V4wy15am+7AAAnr5oQusL5HZVYY9J5KKfPHcQ60Su6kMJ94UqbP0RYzJN2cZt0qtunOcXAjUXAwuheX9sTBXeYKBjo+Bo6X0LGolAGvKXd732CQy15iD0gABIIpYN" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "1899982000000000" + } + }, + { + "@type": "tvm.stackEntryNumber", + "number": { + "@type": "tvm.numberDecimal", + "number": "3920620712333" + } + } + ] + } + } + ] + } + } + ] + } + } + ], + "exit_code": 0 +} \ No newline at end of file diff --git a/tonlib/src/test/resources/participants_list.json b/tonlib/src/test/resources/participants_list.json deleted file mode 100644 index 1fcdff1f..00000000 --- a/tonlib/src/test/resources/participants_list.json +++ /dev/null @@ -1,448 +0,0 @@ -{ - "@type": "tvm.stackEntryList", - "list": { - "@type": "tvm.list", - "elements": [ - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "9611398166486797600451574266292909340199297993694468911038591952166189386388" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "31436176142115892197513022243260411592023543599459442512748828287497100211056" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "36399517673521513301304048357617273399818007423833620914049712973023408929990" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "41776696286610546147845800594401727235285702048184873286240674270861134126027" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "42635870121307536200694680820519725907335984382355056176092113846236908153773" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "53169698514234303138802511694109092296193355002957272028317890828109715601488" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "55747079431428739706187209984598606362108579721425255575455103805008916092036" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "62830225640607569694232876276570923738866359593600142497336096677837669440430" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "67168906290058119498024620131792839954241827161723238193131950416091970529130" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "67402650486929471740668086098569391295952692987241551185277763744389879246299" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "88709155793729751756530473235669507021521812661942079833838482729069622523666" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "89023121548703369962320676315051089328668298429821558533767391483495250528280" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "91238136352662258327177912646346870727844560040376435379275773682662045334142" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "92620367321634552868691178238560620622234279286100239606179637559887068557058" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "93735440183759504453936480802930339781783773438557677507297261785961666866277" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "52477175932963" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "93774841752951001914828042401058185123422517732399814199386419514096877036723" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "95962629547772877679981526018119968988398679180521399130795796187040380764718" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "98814727095735563659433043601352482193214184032021136817282674974234496146852" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "108984047237210940778598484533950987763465494649257476615358405389202435383016" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - }, - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "113916530324219467986346495549705625848455193867682650297155896664777872827574" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "99999000000000" - } - } - ] - } - } - ] - } -} \ No newline at end of file diff --git a/tonlib/src/test/resources/past_elections.json b/tonlib/src/test/resources/past_elections.json deleted file mode 100644 index 7bffea6d..00000000 --- a/tonlib/src/test/resources/past_elections.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "@type": "tvm.stackEntryList", - "list": { - "@type": "tvm.list", - "elements": [ - { - "@type": "tvm.stackEntryTuple", - "tuple": { - "@type": "tvm.tuple", - "elements": [ - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "1655369162" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "1655377262" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "900" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "42351514466890978821103931745645426908480833706817633891839160753551019660519" - } - }, - { - "@type": "tvm.stackEntryCell", - "cell": { - "@type": "tvm.cell", - "bytes": "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" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "1899982000000000" - } - }, - { - "@type": "tvm.stackEntryNumber", - "number": { - "@type": "tvm.numberDecimal", - "number": "3920620712333" - } - } - ] - } - } - ] - } -} \ No newline at end of file