From 8b9cec38d59c901e76ffc59f38a60b8888161e56 Mon Sep 17 00:00:00 2001 From: neodiX Date: Wed, 8 Mar 2023 20:21:51 +0100 Subject: [PATCH] added getRawTransactions with limit; fixed getAllRawTransactions historyLimit; AccountState now includes wallet_id and seqno fo generic purposes; Tonlib types are made serializable; Refactoring, synthetic sugar, documentation; --- README.md | 4 +- address/README.md | 4 +- address/pom.xml | 2 +- bitstring/README.md | 4 +- bitstring/pom.xml | 2 +- cell/README.md | 4 +- cell/pom.xml | 2 +- mnemonic/README.md | 4 +- mnemonic/pom.xml | 2 +- .../org/ton/java/mnemonic/TestMnemonic.java | 12 ++ pom.xml | 2 +- smartcontract/README.md | 4 +- smartcontract/pom.xml | 2 +- .../java/smartcontract/types/WalletCodes.java | 12 ++ .../TestWalletV1R3DeployTransferShort.java | 15 ++- .../TestWalletV3R2DeployTransferShort.java | 9 +- tlb/pom.xml | 4 +- tonlib/README.md | 4 +- tonlib/pom.xml | 2 +- .../main/java/org/ton/java/tonlib/Tonlib.java | 93 ++++++++++++++- .../ton/java/tonlib/types/AccountAddress.java | 4 +- .../java/tonlib/types/AccountAddressOnly.java | 4 +- .../ton/java/tonlib/types/AccountState.java | 6 +- .../tonlib/types/AccountTransactionId.java | 4 +- .../ton/java/tonlib/types/BlockHeader.java | 3 +- .../org/ton/java/tonlib/types/BlockId.java | 4 +- .../org/ton/java/tonlib/types/BlockIdExt.java | 4 +- .../java/tonlib/types/BlockTransactions.java | 3 +- .../org/ton/java/tonlib/types/Bounceable.java | 4 +- .../org/ton/java/tonlib/types/ConfigInfo.java | 4 +- .../java/org/ton/java/tonlib/types/Data.java | 4 +- .../ton/java/tonlib/types/Destination.java | 4 +- .../ton/java/tonlib/types/ExtMessageInfo.java | 4 +- .../java/org/ton/java/tonlib/types/Fees.java | 4 +- .../java/tonlib/types/FullAccountState.java | 4 +- .../java/org/ton/java/tonlib/types/Key.java | 4 +- .../java/tonlib/types/LastTransactionId.java | 3 +- .../ton/java/tonlib/types/LoadContract.java | 4 +- .../java/tonlib/types/MasterChainInfo.java | 4 +- .../org/ton/java/tonlib/types/MsgData.java | 4 +- .../ton/java/tonlib/types/NonBounceable.java | 4 +- .../java/org/ton/java/tonlib/types/Ok.java | 4 +- .../ton/java/tonlib/types/ParseRunResult.java | 8 +- .../org/ton/java/tonlib/types/QueryFees.java | 3 +- .../org/ton/java/tonlib/types/QueryInfo.java | 4 +- .../ton/java/tonlib/types/RawAccountForm.java | 4 +- .../java/tonlib/types/RawAccountState.java | 8 +- .../org/ton/java/tonlib/types/RawMessage.java | 4 +- .../ton/java/tonlib/types/RawTransaction.java | 3 +- .../java/tonlib/types/RawTransactions.java | 3 +- .../org/ton/java/tonlib/types/RunResult.java | 3 +- .../org/ton/java/tonlib/types/Shards.java | 3 +- .../org/ton/java/tonlib/types/ShortTxId.java | 4 +- .../tonlib/types/SyncStateInProgress.java | 4 +- .../ton/java/tonlib/types/TonlibError.java | 4 +- .../org/ton/java/tonlib/types/TvmCell.java | 4 +- .../org/ton/java/tonlib/types/TvmEntry.java | 4 +- .../org/ton/java/tonlib/types/TvmList.java | 3 +- .../org/ton/java/tonlib/types/TvmNumber.java | 4 +- .../org/ton/java/tonlib/types/TvmSlice.java | 4 +- .../ton/java/tonlib/types/TvmStackEntry.java | 4 +- .../java/tonlib/types/TvmStackEntryCell.java | 4 +- .../java/tonlib/types/TvmStackEntryList.java | 4 +- .../tonlib/types/TvmStackEntryNumber.java | 3 +- .../java/tonlib/types/TvmStackEntrySlice.java | 4 +- .../java/tonlib/types/TvmStackEntryTuple.java | 4 +- .../org/ton/java/tonlib/types/TvmTuple.java | 3 +- .../java/tonlib/types/UpdateSyncState.java | 4 +- .../ton/java/tonlib/types/VerbosityLevel.java | 4 +- .../ton/java/tonlib/TestConcurrentTonlib.java | 28 ++++- .../org/ton/java/tonlib/TestTonlibJson.java | 106 +++++++++++++++--- utils/README.md | 4 +- utils/pom.xml | 2 +- .../main/java/org/ton/java/utils/Utils.java | 10 ++ 74 files changed, 427 insertions(+), 105 deletions(-) diff --git a/README.md b/README.md index e3b3d987..0501fab1 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Do not forget to place tonlibjson library to your project. Latest Tonlib librari io.github.neodix42 smartcontract - 0.1.1 + 0.1.2 ``` @@ -32,7 +32,7 @@ Do not forget to place tonlibjson library to your project. Latest Tonlib librari io.github.neodix42 ton4j - 0.1.1 + 0.1.2 ``` diff --git a/address/README.md b/address/README.md index aef2999d..3b5fca3b 100644 --- a/address/README.md +++ b/address/README.md @@ -6,7 +6,7 @@ io.github.neodix42 address - 0.1.1 + 0.1.2 ``` @@ -17,7 +17,7 @@ io.github.neodix42.ton4j address - 0.1.1 + 0.1.2 ``` diff --git a/address/pom.xml b/address/pom.xml index 97a222af..77e9c837 100644 --- a/address/pom.xml +++ b/address/pom.xml @@ -6,7 +6,7 @@ io.github.neodix42 top - 0.1.1 + 0.1.2 4.0.0 diff --git a/bitstring/README.md b/bitstring/README.md index 52475c56..527b7466 100644 --- a/bitstring/README.md +++ b/bitstring/README.md @@ -6,7 +6,7 @@ io.github.neodix42 bitstring - 0.1.1 + 0.1.2 ``` @@ -16,7 +16,7 @@ io.github.neodix42.ton4j bitstring - 0.1.1 + 0.1.2 ``` diff --git a/bitstring/pom.xml b/bitstring/pom.xml index 5decfaa8..c60b4484 100644 --- a/bitstring/pom.xml +++ b/bitstring/pom.xml @@ -6,7 +6,7 @@ io.github.neodix42 top - 0.1.1 + 0.1.2 4.0.0 diff --git a/cell/README.md b/cell/README.md index 43b49399..4a0130cf 100644 --- a/cell/README.md +++ b/cell/README.md @@ -6,7 +6,7 @@ io.github.neodix42 cell - 0.1.1 + 0.1.2 ``` @@ -16,7 +16,7 @@ io.github.neodix42.ton4j cell - 0.1.1 + 0.1.2 ``` diff --git a/cell/pom.xml b/cell/pom.xml index 9bf63824..21da23af 100644 --- a/cell/pom.xml +++ b/cell/pom.xml @@ -6,7 +6,7 @@ io.github.neodix42 top - 0.1.1 + 0.1.2 4.0.0 diff --git a/mnemonic/README.md b/mnemonic/README.md index 88f72a02..2182759e 100644 --- a/mnemonic/README.md +++ b/mnemonic/README.md @@ -6,7 +6,7 @@ io.github.neodix42 mnemonic - 0.1.1 + 0.1.2 ``` @@ -16,7 +16,7 @@ io.github.neodix42.ton4j mnemonic - 0.1.1 + 0.1.2 ``` diff --git a/mnemonic/pom.xml b/mnemonic/pom.xml index b36d38a7..4cc5fc44 100644 --- a/mnemonic/pom.xml +++ b/mnemonic/pom.xml @@ -5,7 +5,7 @@ top io.github.neodix42 - 0.1.1 + 0.1.2 4.0.0 diff --git a/mnemonic/src/test/java/org/ton/java/mnemonic/TestMnemonic.java b/mnemonic/src/test/java/org/ton/java/mnemonic/TestMnemonic.java index 073135c4..fbd4f74f 100644 --- a/mnemonic/src/test/java/org/ton/java/mnemonic/TestMnemonic.java +++ b/mnemonic/src/test/java/org/ton/java/mnemonic/TestMnemonic.java @@ -36,6 +36,8 @@ public void testMnemonicWithPassword() throws NoSuchAlgorithmException, InvalidK @Test public void testMnemonicValidation() throws NoSuchAlgorithmException, InvalidKeyException { + + assertThat(Mnemonic.isValid(List.of("audit", "magic", "blossom", "digital", "dad", "buffalo", "river", "junior", "minimum", "congress", "banner", "garage", "flag", "tuna", "onion", "pair", "balance", "spice", "reason", "gossip", "cotton", "stock", "skate", "faith"), "")).isTrue(); assertThat(Mnemonic.isValid(List.of("kangaroo", "hen", "toddler", "resist"), "")).isTrue(); assertThat(Mnemonic.isValid(List.of("disease", "adult", "device", "grit"), "")).isTrue(); @@ -75,4 +77,14 @@ public void testMnemonicSeed2() throws NoSuchAlgorithmException, InvalidKeyExcep byte[] res = Mnemonic.hmacSha512(key, data); System.out.println(bytesToHex(res)); } + + @Test + public void testMnemonicToKeyPair() throws NoSuchAlgorithmException, InvalidKeyException { + + Pair key = Mnemonic.toKeyPair(List.of("audit", "magic", "blossom", "digital", "dad", "buffalo", "river", + "junior", "minimum", "congress", "banner", "garage", "flag", "tuna", "onion", "pair", "balance", "spice", + "reason", "gossip", "cotton", "stock", "skate", "faith")); + System.out.println(bytesToHex(key.getPublicKey())); + System.out.println(bytesToHex(key.getSecretKey())); + } } diff --git a/pom.xml b/pom.xml index 8b02c1e3..90b0ee36 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.github.neodix42 top pom - 0.1.1 + 0.1.2 bitstring diff --git a/smartcontract/README.md b/smartcontract/README.md index 77699ae1..d4e26c15 100644 --- a/smartcontract/README.md +++ b/smartcontract/README.md @@ -7,7 +7,7 @@ io.github.neodix42 smartcontract - 0.1.1 + 0.1.2 ``` @@ -18,7 +18,7 @@ io.github.neodix42.ton4j smartcontract - 0.1.1 + 0.1.2 ``` diff --git a/smartcontract/pom.xml b/smartcontract/pom.xml index ec47a8c9..b4023bae 100644 --- a/smartcontract/pom.xml +++ b/smartcontract/pom.xml @@ -6,7 +6,7 @@ io.github.neodix42 top - 0.1.1 + 0.1.2 4.0.0 diff --git a/smartcontract/src/main/java/org/ton/java/smartcontract/types/WalletCodes.java b/smartcontract/src/main/java/org/ton/java/smartcontract/types/WalletCodes.java index a2c2786a..a3eff2f7 100644 --- a/smartcontract/src/main/java/org/ton/java/smartcontract/types/WalletCodes.java +++ b/smartcontract/src/main/java/org/ton/java/smartcontract/types/WalletCodes.java @@ -9,17 +9,29 @@ public enum WalletCodes { V3R1("B5EE9C724101010100620000C0FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED543FBE6EE0"), V3R2("B5EE9C724101010100710000DEFF0020DD2082014C97BA218201339CBAB19F71B0ED44D0D31FD31F31D70BFFE304E0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED5410BD6DAD"), V4R2("B5EE9C72410214010002D4000114FF00F4A413F4BCF2C80B010201200203020148040504F8F28308D71820D31FD31FD31F02F823BBF264ED44D0D31FD31FD3FFF404D15143BAF2A15151BAF2A205F901541064F910F2A3F80024A4C8CB1F5240CB1F5230CBFF5210F400C9ED54F80F01D30721C0009F6C519320D74A96D307D402FB00E830E021C001E30021C002E30001C0039130E30D03A4C8CB1F12CB1FCBFF1011121302E6D001D0D3032171B0925F04E022D749C120925F04E002D31F218210706C7567BD22821064737472BDB0925F05E003FA403020FA4401C8CA07CBFFC9D0ED44D0810140D721F404305C810108F40A6FA131B3925F07E005D33FC8258210706C7567BA923830E30D03821064737472BA925F06E30D06070201200809007801FA00F40430F8276F2230500AA121BEF2E0508210706C7567831EB17080185004CB0526CF1658FA0219F400CB6917CB1F5260CB3F20C98040FB0006008A5004810108F45930ED44D0810140D720C801CF16F400C9ED540172B08E23821064737472831EB17080185005CB055003CF1623FA0213CB6ACB1FCB3FC98040FB00925F03E20201200A0B0059BD242B6F6A2684080A06B90FA0218470D4080847A4937D29910CE6903E9FF9837812801B7810148987159F31840201580C0D0011B8C97ED44D0D70B1F8003DB29DFB513420405035C87D010C00B23281F2FFF274006040423D029BE84C600201200E0F0019ADCE76A26840206B90EB85FFC00019AF1DF6A26840106B90EB858FC0006ED207FA00D4D422F90005C8CA0715CBFFC9D077748018C8CB05CB0222CF165005FA0214CB6B12CCCCC973FB00C84014810108F451F2A7020070810108D718FA00D33FC8542047810108F451F2A782106E6F746570748018C8CB05CB025006CF165004FA0214CB6A12CB1FCB3FC973FB0002006C810108D718FA00D33F305224810108F459F2A782106473747270748018C8CB05CB025005CF165003FA0213CB6ACB1F12CB3FC973FB00000AF400C9ED54696225E5"), + lockup("B5EE9C7241021E01000261000114FF00F4A413F4BCF2C80B010201200203020148040501F2F28308D71820D31FD31FD31F802403F823BB13F2F2F003802251A9BA1AF2F4802351B7BA1BF2F4801F0BF9015410C5F9101AF2F4F8005057F823F0065098F823F0062071289320D74A8E8BD30731D4511BDB3C12B001E8309229A0DF72FB02069320D74A96D307D402FB00E8D103A4476814154330F004ED541D0202CD0607020120131402012008090201200F100201200A0B002D5ED44D0D31FD31FD3FFD3FFF404FA00F404FA00F404D1803F7007434C0C05C6C2497C0F83E900C0871C02497C0F80074C7C87040A497C1383C00D46D3C00608420BABE7114AC2F6C2497C338200A208420BABE7106EE86BCBD20084AE0840EE6B2802FBCBD01E0C235C62008087E4055040DBE4404BCBD34C7E00A60840DCEAA7D04EE84BCBD34C034C7CC0078C3C412040DD78CA00C0D0E00130875D27D2A1BE95B0C60000C1039480AF00500161037410AF0050810575056001010244300F004ED540201201112004548E1E228020F4966FA520933023BB9131E2209835FA00D113A14013926C21E2B3E6308003502323287C5F287C572FFC4F2FFFD00007E80BD00007E80BD00326000431448A814C4E0083D039BE865BE803444E800A44C38B21400FE809004E0083D10C06002012015160015BDE9F780188242F847800C02012017180201481B1C002DB5187E006D88868A82609E00C6207E00C63F04EDE20B30020158191A0017ADCE76A268699F98EB85FFC00017AC78F6A268698F98EB858FC00011B325FB513435C2C7E00017B1D1BE08E0804230FB50F620002801D0D3030178B0925B7FE0FA4031FA403001F001A80EDAA4"), + dnsCollection("B5EE9C7241021D010002C7000114FF00F4A413F4BCF2C80B0102016202030202CC040502012017180201200607020120131402012008090201200D0E016D420C70094840FF2F0DE01D0D3030171B0925F03E0FA403001D31FED44D0D4D4303122C000E30210245F048210370FEC51BADC840FF2F080A0201200B0C00D032F82320821062E44069BCF2E0C701F00420D74920C218F2E0C8208103F0BBF2E0C92078A908C000F2E0CA21F005F2E0CB58F00714BEF2E0CC22F9018050F833206EB38E10D0F4043052108307F40E6FA131F2D0CD9130E2C85004CF16C9C85003CF1612CCC9F00C000D1C3232C072742000331C27C074C1C07000082CE500A98200B784B98C4830003CB432600201200F100201201112004F3223880875D244B5C61673C58875D2883000082CE6C070007CB83280B50C3400A44C78B98C727420007F1C0875D2638D572E882CE38B8C00B4C1C8700B48F0802C0929BE14902E6C08B08BC8F04EAC2C48B09800F05EC4EC04AC6CC82CE500A98200B784F7B99B04AEA00093083001258C2040FA201938083001658C20407D200CB8083001A58C204064200A38083001E58C20404B2007B8083002258C204032200538083002650C20191EB83002A4E00C9D781E9C600069006AC0BC018060840EE6B2802A0060840EE6B2802A00A08418B9101A68608209E3402A410830856456F81B04A5A9D6A0192A41392002015815160039D2CF8053810F805BBC00C646582AC678B387D0165B5E66664C0207D804002D007232FFFE0A33C5B25C083232C044FD003D0032C03260001B3E401D3232C084B281F2FFF27420020120191A0201201B1C0007B8B5D318001FBA7A3ED44D0D4D43031F00A7001F00B8001BB905BED44D0D4D430307FF002128009DBA30C3020D74978A908C000F2E04620D70A07C00021D749C0085210B0935B786DE0209501D3073101DE21F0035122D71830F9018200BA93C8CB0F01820167A3ED43D8CF16C90191789170E212A0018F83DF327"), + dnsItem("B5EE9C7241022801000698000114FF00F4A413F4BCF2C80B0102016202030202CC04050201201E1F02012006070201481819020120080902015816170201200A0B000D470C8CB01C9D0801F73E09DBC400B434C0C05C6C2497C1383E903E900C7E800C5C75C87E800C7E800C3C0289ECE39397C15B088D148CB1C17CB865407E90350C1B5C3232C1FD00327E08E08418B9101A68608209E3402A4108308324CC200337A0404B20403C162A20032A41287E08C0683C00911DFC02440D7E08FC02F814D671C1462C200C00113E910C1C2EBCB8536003F88E34109B5F0BFA40307020F8256D8040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00E029C70091709509D31F50AAE221F008F82321BC24C0008E9E343A3A3B8E1636363737375135C705F2E196102510241023F823F00BE30EE0310DD33F256EB31FB0926C21E30D0D0E0F00FE302680698064A98452B0BEF2E19782103B9ACA0052A0A15270BC993682103B9ACA0019A193390805E220C2008E328210557CEA20F82510396D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00923036E2803C23F823A1A120C2009313A0029130E24474F0091024F823F00B00D2343653CDA182103B9ACA005210A15270BC993682103B9ACA0016A1923005E220C2008E378210370FEC516D72295134544743708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB001CA10B9130E26D5477655477632EF00B0204C882105FCC3D145220BA8E9531373B5372C705F2E191109A104910384706401504E082101A0B9D515220BA8E195B32353537375135C705F2E19A03D4304015045033F823F00BE02182104EB1F0F9BAE3023B20821044BEAE41BAE302382782104ED14B65BA1310111200885B363638385147C705F2E19B04D3FF20D74AC20007D0D30701C000F2E19CF404300798D43040168307F417983050058307F45B30E270C8CB07F400C910354014F823F00B01FE30363A246EF2E19D8050F833D0F4043052408307F40E6FA1F2E19FD30721C00022C001B1F2E1A021C0008E9124109B1068517A10571046105C43144CDD9630103A395F07E201C0018E32708210370FEC51586D8100A0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00915BE21301FE8E7A37F8235006A1810258BC066E16B0F2E19E23D0D749F823F0075290BEF2E1975178A182103B9ACA00A120C2008E32102782104ED14B6558076D72708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093303535E2F82381012CA0F0024477F0091045103412F823F00BE05F041501F03502FA4021F001FA40D20031FA0082103B9ACA001DA121945314A0A1DE22D70B01C300209205A19135E220C2FFF2E192218E3E821005138D91C8500BCF16500DCF1671244B145448C0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00106994102C395BE20114008A8E3528F0018210D53276DB103946096D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093383430E21045103412F823F00B009A32353582102FCB26A2BA8E3A7082108B77173504C8CBFF5005CF161443308040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00E05F04840FF2F00093083001258C2040FA201938083001658C20407D200CB8083001A58C204064200A38083001E58C20404B2007B8083002258C204032200538083002650C20191EB83002A4E00C9D781E9C600069006AC0BC018060840EE6B2802A0060840EE6B2802A00A08418B9101A68608209E3402A410830856456F81B04A5A9D6A0192A4139200201201A1B0201201C1D0021081BA50C1B5C0838343E903E8034CFCC200017321400F3C5807E80B2CFF26000513B513434FFFE900835D2708027DFC07E9035353D0134CFCC0415C415B80C1C1B5B5B5B490415C415A0002B01B232FFD40173C59400F3C5B3333D0032CFF27B5520020120202102012024250013BBB39F00A175F07F008802027422230010A874F00A10475F07000CA959F00A6C71000DB8FCFF00A5F03802012026270013B64A5E014204EBE0FA1000C7B461843AE9240F152118001E5C08DE014206EBE0FA1A60E038001E5C339E8086007AE140F8001E5C33B84111C466105E033E04883DCB11FB64DDC4964AD1BA06B879240DC23572F37CC5CAAAB143A2FFFBC4180012660F003C003060FE81EDF4260F00306EB1583C"), + jettonMinter("B5EE9C7241020B010001ED000114FF00F4A413F4BCF2C80B0102016202030202CC040502037A60090A03EFD9910E38048ADF068698180B8D848ADF07D201800E98FE99FF6A2687D007D206A6A18400AA9385D47181A9AA8AAE382F9702480FD207D006A18106840306B90FD001812881A28217804502A906428027D012C678B666664F6AA7041083DEECBEF29385D71811A92E001F1811802600271812F82C207F97840607080093DFC142201B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064907C80383A6465816503E5FFE4E83BC00C646582AC678B28027D0109E5B589666664B8FD80400FE3603FA00FA40F82854120870542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D05008C705F2E04A12A1035024C85004FA0258CF16CCCCC9ED5401FA403020D70B01C3008E1F8210D53276DB708010C8CB055003CF1622FA0212CB6ACB1FCB3FC98042FB00915BE200303515C705F2E049FA403059C85004FA0258CF16CCCCC9ED54002E5143C705F2E049D43001C85004FA0258CF16CCCCC9ED54007DADBCF6A2687D007D206A6A183618FC1400B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064FC80383A6465816503E5FFE4E840001FAF16F6A2687D007D206A6A183FAA904051007F09"), + jettonWallet("B5EE9C7241021201000328000114FF00F4A413F4BCF2C80B0102016202030202CC0405001BA0F605DA89A1F401F481F481A8610201D40607020148080900BB0831C02497C138007434C0C05C6C2544D7C0FC02F83E903E900C7E800C5C75C87E800C7E800C00B4C7E08403E29FA954882EA54C4D167C0238208405E3514654882EA58C511100FC02780D60841657C1EF2EA4D67C02B817C12103FCBC2000113E910C1C2EBCB853600201200A0B020120101101F500F4CFFE803E90087C007B51343E803E903E90350C144DA8548AB1C17CB8B04A30BFFCB8B0950D109C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C032483E401C1D3232C0B281F2FFF274013E903D010C7E801DE0063232C1540233C59C3E8085F2DAC4F3208405E351467232C7C6600C03F73B51343E803E903E90350C0234CFFE80145468017E903E9014D6F1C1551CDB5C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C0327E401C1D3232C0B281F2FFF274140371C1472C7CB8B0C2BE80146A2860822625A020822625A004AD822860822625A028062849F8C3C975C2C070C008E00D0E0F009ACB3F5007FA0222CF165006CF1625FA025003CF16C95005CC2391729171E25008A813A08208989680AA008208989680A0A014BCF2E2C504C98040FB001023C85004FA0258CF1601CF16CCC9ED5400705279A018A182107362D09CC8CB1F5230CB3F58FA025007CF165007CF16C9718018C8CB0524CF165006FA0215CB6A14CCC971FB0010241023000E10491038375F040076C200B08E218210D53276DB708010C8CB055008CF165004FA0216CB6A12CB1F12CB3FC972FB0093356C21E203C85004FA0258CF1601CF16CCC9ED5400DB3B51343E803E903E90350C01F4CFFE803E900C145468549271C17CB8B049F0BFFCB8B0A0822625A02A8005A805AF3CB8B0E0841EF765F7B232C7C572CFD400FE8088B3C58073C5B25C60063232C14933C59C3E80B2DAB33260103EC01004F214013E809633C58073C5B3327B55200083200835C87B51343E803E903E90350C0134C7E08405E3514654882EA0841EF765F784EE84AC7CB8B174CFCC7E800C04E81408F214013E809633C58073C5B3327B55205ECCF23D"), + nftItem("B5EE9C7241020D010001D0000114FF00F4A413F4BCF2C80B0102016202030202CE04050009A11F9FE00502012006070201200B0C02D70C8871C02497C0F83434C0C05C6C2497C0F83E903E900C7E800C5C75C87E800C7E800C3C00812CE3850C1B088D148CB1C17CB865407E90350C0408FC00F801B4C7F4CFE08417F30F45148C2EA3A1CC840DD78C9004F80C0D0D0D4D60840BF2C9A884AEB8C097C12103FCBC20080900113E910C1C2EBCB8536001F65135C705F2E191FA4021F001FA40D20031FA00820AFAF0801BA121945315A0A1DE22D70B01C300209206A19136E220C2FFF2E192218E3E821005138D91C85009CF16500BCF16712449145446A0708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB00104794102A375BE20A00727082108B77173505C8CBFF5004CF1610248040708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB000082028E3526F0018210D53276DB103744006D71708010C8CB055007CF165005FA0215CB6A12CB1FCB3F226EB39458CF17019132E201C901FB0093303234E25502F003003B3B513434CFFE900835D27080269FC07E90350C04090408F80C1C165B5B60001D00F232CFD633C58073C5B3327B5520BF75041B"), + nftCollection("B5EE9C724102140100021F000114FF00F4A413F4BCF2C80B0102016202030202CD04050201200E0F04E7D10638048ADF000E8698180B8D848ADF07D201800E98FE99FF6A2687D20699FEA6A6A184108349E9CA829405D47141BAF8280E8410854658056B84008646582A802E78B127D010A65B509E58FE59F80E78B64C0207D80701B28B9E382F970C892E000F18112E001718112E001F181181981E0024060708090201200A0B00603502D33F5313BBF2E1925313BA01FA00D43028103459F0068E1201A44343C85005CF1613CB3FCCCCCCC9ED54925F05E200A6357003D4308E378040F4966FA5208E2906A4208100FABE93F2C18FDE81019321A05325BBF2F402FA00D43022544B30F00623BA9302A402DE04926C21E2B3E6303250444313C85005CF1613CB3FCCCCCCC9ED54002C323401FA40304144C85005CF1613CB3FCCCCCCC9ED54003C8E15D4D43010344130C85005CF1613CB3FCCCCCCC9ED54E05F04840FF2F00201200C0D003D45AF0047021F005778018C8CB0558CF165004FA0213CB6B12CCCCC971FB008002D007232CFFE0A33C5B25C083232C044FD003D0032C03260001B3E401D3232C084B281F2FFF2742002012010110025BC82DF6A2687D20699FEA6A6A182DE86A182C40043B8B5D31ED44D0FA40D33FD4D4D43010245F04D0D431D430D071C8CB0701CF16CCC980201201213002FB5DAFDA89A1F481A67FA9A9A860D883A1A61FA61FF480610002DB4F47DA89A1F481A67FA9A9A86028BE09E008E003E00B01A500C6E"), + payments("B5EE9C72410230010007FB000114FF00F4A413F4BCF2C80B0102012002030201480405000AF26C21F0190202CB06070201202E2F020120080902012016170201200A0B0201200C0D0009D3610F80CC001D6B5007434C7FE8034C7CC1BC0FE19E0201580E0F0201201011002D3E11DBC4BE11DBC43232C7FE11DBC47E80B2C7F2407320008B083E1B7B51343480007E187E80007E18BE80007E18F4FFC07E1934FFC07E1974DFC07E19BC01887080A7F4C7C07E1A34C7C07E1A7D01007E1AB7807080E535007E1AF7BE1B2002012012130201201415008D3E13723E11BE117E113E10540132803E10BE80BE10FE8084F2FFC4B2FFF2DFFC02887080A7FE12BE127E121400F2C7C4B2C7FD0037807080E53E12C073253E1333C5B8B27B5520004D1C3C02FE106CFCB8193E803E800C3E1096283E18BE10C0683E18FE10BE10E8006EFCB819BC032000CF1D3C02FE106CFCB819348020C235C6083E4040E4BE1124BE117890CC3E443CB81974C7C060841A5B9A5D2EBCB81A3E118074DFD66EBCB81CBE803E800C3E1094882FBE10D4882FAC3CB819807E18BE18FE12F43E800C3E10BE10E80068006E7CB8199FFE187C0320004120843777222E9C20043232C15401B3C594013E808532DA84B2C7F2DFF2407EC02002012018190201D42B2C0201201A1B0201201E1F0201201C1D00E5473F00BD401D001D401D021F90102D31F01821043436D74BAF2E068F84601D37F59BAF2E072F844544355F910F8454330F910B0F2E065D33FD33F30F84822B9F84922B9B0F2E06C21F86820F869F84A6E915B8E19F84AD0D33FFA003171D721D33F305033BC02BCB1936DF86ADEE2F800F00C8006F3E12F43E800C7E903E900C3E09DBC41CBE10D62F24CC20C1B7BE10FE11963C03FE10BE11A04020BC03DC3E185C3E189C3E18DB7E1ABC032000B51D3C02F5007400750074087E4040B4C7C0608410DB1BDCEEBCB81A3E118074DFD66EBCB81CBE111510D57E443E1150CC3E442C3CB8197E80007E18BE80007E18F4CFF4CFCC3E1208AE7E1248AE6C3CB81B007E1A3E1A7E003C042001C1573F00BF84A6EF2E06AD2008308D71820F9012392F84492F845E24130F910F2E065D31F018210556E436CBAF2E068F84601D37F59BAF2E072D401D08308D71820F901F8444130F910F2E06501D430D08308D71820F901F8454130F910F2E06501820020120222301FED31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE2303205D31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE23032F8485280BEF8495250BEB0524BBE1AB0527ABE19210064B05215BE14B05248BE17B0F2E06970F82305C8CB3F5004FA0215F40015CB3F5004FA0212F400CB1F12CA00CA00C9F86AF00C01C31CFC02FE129BACFCB81AF48020C235C6083E4048E4BE1124BE1178904C3E443CB81974C7C0608410DA19D46EBCB81A3E118074DFD66EBCB81CB5007420C235C6083E407E11104C3E443CB81940750C3420C235C6083E407E11504C3E443CB81940602403F71CFC02FE129BACFCB81AF48020C235C6083E4048E4BE1124BE1178904C3E443CB81974C7C0608410DB10DBAEBCB81A3E118074DFD66EBCB81CBD010C3E12B434CFFE803D0134CFFE803D0134C7FE11DBC4148828083E08EE7CB81BBE11DBC4A83E08EF3CB81C34800C151D5A64D6D4C8F7A2B98E82A49B08B8C3816028292A01FCD31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE2303205D31F01821043685374BAF2E068F84601D37F59BAF2E072D33FFA00F404552003D200019AD401D0D33FFA00F40430937F206DE230325339BE5381BEB0F8495250BEB0F8485290BEB02502FE5237BE16B05262BEB0F2E06927C20097F84918BEF2E0699137E222C20097F84813BEF2E0699132E2F84AD0D33FFA00F404D33FFA00F404D31FF8476F105220A0F823BCF2E06FD200D20030B3F2E073209C3537373A5274BC5263BC12B18E11323939395250BC5299BC18B14650134440E25319BAB3F2E06D9130E30D7F05C82627002496F8476F1114A098F8476F1117A00603E203003ECB3F5004FA0215F40012CB3F5004FA0213F400CB1F12CA00CA00C9F86AF00C00620A8020F4966FA5208E213050038020F4666FA1208E1001FA00ED1E15DA119450C3A00B9133E2923430E202926C21E2B31B000C3535075063140038C8CB3F5004FA0212F400CB3F5003FA0213F400CB1FCA00C9F86AF00C00D51D3C02FE129BACFCB81AFE12B434CFFE803D010C74CFFE803D010C74C7CC3E11DBC4283E11DBC4A83E08EE7CB81C7E003E10886808E87E18BE10D400E816287E18FE10F04026BE10BE10E83E189C3E18F7BE10B04026BE10FE10A83E18DC3E18F780693E1A293E1A7C042001F53B7EF4C7C8608419F1F4A06EA4CC7C037808608403818830AEA54C7C03B6CC780C882084155DD61FAEA54C3C0476CC780820841E6849BBEEA54C3C04B6CC7808208407C546B3EEA54C3C0576CC780820840223AA8CAEA54C3C05B6CC7808208419BDBC1A6EA54C3C05F6CC780C60840950CAA46EA53C0636CC78202D0008840FF2F00075BC7FE3A7805FC25E87D007D207D20184100D0CAF6A1EC7C217C21B7817C227C22B7817C237C23FC247C24B7817C2524C3B7818823881B22A021984008DBD0CABA7805FC20C8B870FC253748B8F07C256840206B90FD0018C020EB90FD0018B8EB90E98F987C23B7882908507C11DE491839707C23B788507C23B789507C11DE48B9F03A4331C4966"), + highload("B5EE9C724101090100E5000114FF00F4A413F4BCF2C80B010201200203020148040501EAF28308D71820D31FD33FF823AA1F5320B9F263ED44D0D31FD33FD3FFF404D153608040F40E6FA131F2605173BAF2A207F901541087F910F2A302F404D1F8007F8E16218010F4786FA5209802D307D43001FB009132E201B3E65B8325A1C840348040F4438AE63101C8CB1F13CB3FCBFFF400C9ED54080004D03002012006070017BD9CE76A26869AF98EB85FFC0041BE5F976A268698F98E99FE9FF98FA0268A91040207A0737D098C92DBFC95DD1F140034208040F4966FA56C122094305303B9DE2093333601926C21E2B39F9E545A"), + multisig("B5EE9C7241022B01000418000114FF00F4A413F4BCF2C80B010201200203020148040504DAF220C7008E8330DB3CE08308D71820F90101D307DB3C22C00013A1537178F40E6FA1F29FDB3C541ABAF910F2A006F40420F90101D31F5118BAF2AAD33F705301F00A01C20801830ABCB1F26853158040F40E6FA120980EA420C20AF2670EDFF823AA1F5340B9F2615423A3534E202321220202CC06070201200C0D02012008090201660A0B0003D1840223F2980BC7A0737D0986D9E52ED9E013C7A21C2125002D00A908B5D244A824C8B5D2A5C0B5007404FC02BA1B04A0004F085BA44C78081BA44C3800740835D2B0C026B500BC02F21633C5B332781C75C8F20073C5BD0032600201200E0F02012014150115BBED96D5034705520DB3C82A020148101102012012130173B11D7420C235C6083E404074C1E08075313B50F614C81E3D039BE87CA7F5C2FFD78C7E443CA82B807D01085BA4D6DC4CB83E405636CF0069006027003DAEDA80E800E800FA02017A0211FC8080FC80DD794FF805E47A0000E78B64C00017AE19573FC100D56676A1EC40020120161702012018190151B7255B678626466A4610081E81CDF431C24D845A4000331A61E62E005AE0261C0B6FEE1C0B77746E10230189B5599B6786ABE06FEDB1C6CA2270081E8F8DF4A411C4A05A400031C38410021AE424BAE064F6451613990039E2CA840090081E886052261C52261C52265C4036625CCD8A30230201201A1B0017B506B5CE104035599DA87B100201201C1D020399381E1F0111AC1A6D9E2F81B60940230015ADF94100CC9576A1EC1840010DA936CF0557C160230015ADDFDC20806AB33B50F6200220DB3C02F265F8005043714313DB3CED54232A000AD3FFD3073004A0DB3C2FAE5320B0F26212B102A425B3531CB9B0258100E1AA23A028BCB0F269820186A0F8010597021110023E3E308E8D11101FDB3C40D778F44310BD05E254165B5473E7561053DCDB3C54710A547ABC242528260020ED44D0D31FD307D307D33FF404F404D1005E018E1A30D20001F2A3D307D3075003D70120F90105F90115BAF2A45003E06C2121D74AAA0222D749BAF2AB70542013000C01C8CBFFCB0704D6DB3CED54F80F70256E5389BEB198106E102D50C75F078F1B30542403504DDB3C5055A046501049103A4B0953B9DB3C5054167FE2F800078325A18E2C268040F4966FA52094305303B9DE208E1638393908D2000197D3073016F007059130E27F080705926C31E2B3E630062A2728290060708E2903D08308D718D307F40430531678F40E6FA1F2A5D70BFF544544F910F2A6AE5220B15203BD14A1236EE66C2232007E5230BE8E205F03F8009322D74A9802D307D402FB0002E83270C8CA0040148040F44302F0078E1771C8CB0014CB0712CB0758CF0158CF1640138040F44301E201208E8A104510344300DB3CED54925F06E22A001CC8CB1FCB07CB07CB3FF400F400C9B99895F4"), + master("FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F31D307D4D101FB00A4C8CB1FCBFFC9ED54"), //partial code + config("FF00F4A413F4BCF2C80B"); //partial code private final String value; diff --git a/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV1R3DeployTransferShort.java b/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV1R3DeployTransferShort.java index 69decd8d..94652fd9 100644 --- a/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV1R3DeployTransferShort.java +++ b/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV1R3DeployTransferShort.java @@ -12,11 +12,13 @@ import org.ton.java.smartcontract.wallet.Wallet; import org.ton.java.smartcontract.wallet.v1.WalletV1ContractR3; import org.ton.java.tonlib.Tonlib; +import org.ton.java.tonlib.types.VerbosityLevel; import org.ton.java.utils.Utils; import java.math.BigInteger; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.ton.java.utils.Utils.formatNanoValue; @Slf4j @RunWith(JUnit4.class) @@ -25,7 +27,10 @@ public class TestWalletV1R3DeployTransferShort { @Test public void testNewWalletV1R3() throws InterruptedException { - Tonlib tonlib = Tonlib.builder().testnet(true).build(); + Tonlib tonlib = Tonlib.builder() + .testnet(true) + .verbosityLevel(VerbosityLevel.DEBUG) + .build(); TweetNaclFast.Signature.KeyPair keyPair = Utils.generateSignatureKeyPair(); @@ -39,10 +44,12 @@ public void testNewWalletV1R3() throws InterruptedException { log.info("non-bounceable address {}", nonBounceableAddress); log.info(" bounceable address {}", bounceableAddress); + String status = tonlib.getAccountStatus(Address.of(bounceableAddress)); + log.info("account status {}", status); // top up new wallet using test-faucet-wallet BigInteger balance = TestFaucet.topUpContract(tonlib, Address.of(nonBounceableAddress), Utils.toNano(1)); - log.info("new wallet {} balance: {}", contract.getName(), Utils.formatNanoValue(balance)); + log.info("new wallet {} balance: {}", contract.getName(), formatNanoValue(balance)); contract.deploy(tonlib, keyPair.getSecretKey()); @@ -54,7 +61,9 @@ public void testNewWalletV1R3() throws InterruptedException { Utils.sleep(30); balance = new BigInteger(tonlib.getAccountState(Address.of(bounceableAddress)).getBalance()); - log.info("new wallet {} balance: {}", contract.getName(), Utils.formatNanoValue(balance)); + status = tonlib.getAccountStatus(Address.of(bounceableAddress)); + log.info("new wallet {} with status {} and balance: {}", contract.getName(), status, formatNanoValue(balance)); + assertThat(balance.longValue()).isLessThan(Utils.toNano(0.2).longValue()); log.info("seqno {}", contract.getSeqno(tonlib)); diff --git a/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R2DeployTransferShort.java b/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R2DeployTransferShort.java index 09d4965a..20cc5e4d 100644 --- a/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R2DeployTransferShort.java +++ b/smartcontract/src/test/java/org/ton/java/smartcontract/integrationtests/TestWalletV3R2DeployTransferShort.java @@ -12,6 +12,7 @@ import org.ton.java.smartcontract.wallet.Wallet; import org.ton.java.smartcontract.wallet.v3.WalletV3ContractR2; import org.ton.java.tonlib.Tonlib; +import org.ton.java.tonlib.types.VerbosityLevel; import org.ton.java.utils.Utils; import java.math.BigInteger; @@ -25,7 +26,10 @@ public class TestWalletV3R2DeployTransferShort { @Test public void testWalletV3R2() throws InterruptedException { - Tonlib tonlib = Tonlib.builder().testnet(true).build(); + Tonlib tonlib = Tonlib.builder() + .testnet(true) + .verbosityLevel(VerbosityLevel.DEBUG) + .build(); TweetNaclFast.Signature.KeyPair keyPair = Utils.generateSignatureKeyPair(); @@ -42,7 +46,8 @@ public void testWalletV3R2() throws InterruptedException { log.info("non-bounceable address 1: {}", nonBounceableAddress1); log.info(" bounceable address 1: {}", bounceableAddress1); - + String status = tonlib.getAccountStatus(Address.of(bounceableAddress1)); + log.info("account status {}", status); Options options2 = Options.builder() .publicKey(keyPair.getPublicKey()) diff --git a/tlb/pom.xml b/tlb/pom.xml index 6d4c9743..857c96f7 100644 --- a/tlb/pom.xml +++ b/tlb/pom.xml @@ -5,7 +5,7 @@ top io.github.neodix42 - 0.1.1 + 0.1.2 4.0.0 @@ -47,7 +47,7 @@ io.github.neodix42 cell - 0.1.1 + 0.1.2 compile diff --git a/tonlib/README.md b/tonlib/README.md index f4285570..9808fca3 100644 --- a/tonlib/README.md +++ b/tonlib/README.md @@ -8,7 +8,7 @@ Java Tonlib library uses JNA to access methods in native Tonlib shared library. io.github.neodix42 tonlib - 0.1.1 + 0.1.2 ``` @@ -18,7 +18,7 @@ Java Tonlib library uses JNA to access methods in native Tonlib shared library. io.github.neodix42.ton4j tonlib - 0.1.1 + 0.1.2 ``` diff --git a/tonlib/pom.xml b/tonlib/pom.xml index 63cb3328..272f76a2 100644 --- a/tonlib/pom.xml +++ b/tonlib/pom.xml @@ -6,7 +6,7 @@ io.github.neodix42 top - 0.1.1 + 0.1.2 4.0.0 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 c679a713..0b59ad60 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/Tonlib.java @@ -7,6 +7,7 @@ import com.sun.jna.Native; import lombok.Builder; import lombok.extern.java.Log; +import org.apache.commons.lang3.StringUtils; import org.ton.java.address.Address; import org.ton.java.cell.Cell; import org.ton.java.cell.CellBuilder; @@ -451,7 +452,7 @@ public BlockHeader getBlockHeader(BlockIdExt fullblock) { public RawTransactions getRawTransactions(String address, BigInteger fromTxLt, String fromTxHash) { if (isNull(fromTxLt) || isNull(fromTxHash)) { - FullAccountState fullAccountState = getAccountState(AccountAddressOnly.builder().account_address(address).build()); + RawAccountState fullAccountState = getRawAccountState(AccountAddressOnly.builder().account_address(address).build()); fromTxLt = fullAccountState.getLast_transaction_id().getLt(); fromTxHash = fullAccountState.getLast_transaction_id().getHash(); } @@ -469,21 +470,68 @@ public RawTransactions getRawTransactions(String address, BigInteger fromTxLt, S return gson.fromJson(result, RawTransactions.class); } - public RawTransactions getAllRawTransactions(String address, BigInteger fromTxLt, String fromTxHash, long historyLimit) { + /** + * Simliar to getRawTransactions but limits the number of txs + * + * @param address String + * @param fromTxLt BigInteger + * @param fromTxHash String + * @param limit int + * @return RawTransactions + */ + public RawTransactions getRawTransactions(String address, BigInteger fromTxLt, String fromTxHash, int limit) { + + if (isNull(fromTxLt) || isNull(fromTxHash)) { + FullAccountState fullAccountState = getAccountState(AccountAddressOnly.builder().account_address(address).build()); + fromTxLt = fullAccountState.getLast_transaction_id().getLt(); + fromTxHash = fullAccountState.getLast_transaction_id().getHash(); + } + GetRawTransactionsQuery getRawTransactionsQuery = GetRawTransactionsQuery.builder() + .account_address(AccountAddressOnly.builder().account_address(address).build()) + .from_transaction_id(LastTransactionId.builder() + .lt(fromTxLt) + .hash(fromTxHash) + .build()) + .build(); + + send(gson.toJson(getRawTransactionsQuery)); + + String result = syncAndRead(); + + RawTransactions rawTransactions = gson.fromJson(result, RawTransactions.class); + + if (limit > rawTransactions.getTransactions().size()) { + limit = rawTransactions.getTransactions().size(); + } + + return RawTransactions.builder() + .previous_transaction_id(rawTransactions.getPrevious_transaction_id()) + .transactions(rawTransactions.getTransactions().subList(0, limit)) + .build(); + } + + public RawTransactions getAllRawTransactions(String address, BigInteger fromTxLt, String fromTxHash, int historyLimit) { List transactions = new ArrayList<>(); RawTransactions rawTransactions = getRawTransactions(address, fromTxLt, fromTxHash); + transactions.addAll(rawTransactions.getTransactions()); while (rawTransactions.getPrevious_transaction_id().getLt().compareTo(BigInteger.ZERO) != 0) { rawTransactions = getRawTransactions(address, rawTransactions.getPrevious_transaction_id().getLt(), rawTransactions.getPrevious_transaction_id().getHash()); transactions.addAll(rawTransactions.getTransactions()); if (transactions.size() > historyLimit) { - break; + rawTransactions.setTransactions(transactions.subList(0, historyLimit)); + return rawTransactions; } } - rawTransactions.setTransactions(transactions); + if (historyLimit > rawTransactions.getTransactions().size()) { + rawTransactions.setTransactions(transactions); + } else { + rawTransactions.setTransactions(transactions.subList(0, historyLimit)); + } + return rawTransactions; } @@ -546,6 +594,12 @@ public Map getAllBlockTransactions(BlockIdExt fullblock return totalTxs; } + /** + * Returns RawAccountState that always contains code and data + * + * @param address AccountAddressOnly + * @return RawAccountState + */ public RawAccountState getRawAccountState(AccountAddressOnly address) { GetRawAccountStateQueryOnly getAccountStateQuery = GetRawAccountStateQueryOnly.builder().account_address(address).build(); @@ -568,6 +622,12 @@ public RawAccountState getRawAccountState(Address address) { return gson.fromJson(result, RawAccountState.class); } + /** + * With comparison to getRawAccountState returns wallet_id and seqno and always returns code and data. + * + * @param address AccountAddressOnly + * @return FullAccountState + */ public FullAccountState getAccountState(AccountAddressOnly address) { GetAccountStateQueryOnly getAccountStateQuery = GetAccountStateQueryOnly.builder().account_address(address).build(); @@ -578,6 +638,12 @@ public FullAccountState getAccountState(AccountAddressOnly address) { return gson.fromJson(result, FullAccountState.class); } + /** + * With comparison to getRawAccountState returns wallet_id and seqno and always returns code and data. + * + * @param address Address + * @return FullAccountState + */ public FullAccountState getAccountState(Address address) { AccountAddressOnly accountAddressOnly = AccountAddressOnly.builder() .account_address(address.toString(false)) @@ -590,6 +656,25 @@ public FullAccountState getAccountState(Address address) { return gson.fromJson(result, FullAccountState.class); } + /** + * Returns account status by address. + * + * @param address Address + * @return String - uninitialized, frozen or active. + */ + public String getAccountStatus(Address address) { + RawAccountState state = getRawAccountState(address); + if (nonNull(state) && StringUtils.isEmpty(state.getCode())) { + if (StringUtils.isEmpty(state.getFrozen_hash())) { + return "uninitialized"; + } else { + return "frozen"; + } + } else { + return "active"; + } + } + public Cell getConfigParam(BlockIdExt id, long param) { diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddress.java b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddress.java index 16a4b710..ef354279 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddress.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddress.java @@ -5,10 +5,12 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class AccountAddress { +public class AccountAddress implements Serializable { RawAccountForm account_address; } \ No newline at end of file diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddressOnly.java b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddressOnly.java index 46a5394f..c39830f4 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddressOnly.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountAddressOnly.java @@ -5,10 +5,12 @@ import lombok.ToString; import lombok.experimental.SuperBuilder; +import java.io.Serializable; + @SuperBuilder @Setter @Getter @ToString -public class AccountAddressOnly { +public class AccountAddressOnly implements Serializable { String account_address; } \ No newline at end of file diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountState.java b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountState.java index b5bc0331..6dd9c1da 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountState.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountState.java @@ -5,12 +5,16 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class AccountState { +public class AccountState implements Serializable { String code; String data; String frozen_hash; + long wallet_id; + int seqno; } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountTransactionId.java b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountTransactionId.java index a24e39aa..60fa1e79 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/AccountTransactionId.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/AccountTransactionId.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class AccountTransactionId { +public class AccountTransactionId implements Serializable { @SerializedName("@type") final String type = "blocks.accountTransactionId"; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockHeader.java b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockHeader.java index 07d5d24f..8b4c70e6 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockHeader.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockHeader.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class BlockHeader { +public class BlockHeader implements Serializable { @SerializedName(value = "@type") final String type = "blocks.header"; BlockId id; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockId.java b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockId.java index f8794afd..092711a7 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockId.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockId.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class BlockId { +public class BlockId implements Serializable { @SerializedName(value = "@type") final String type = "ton.blockId"; long workchain; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockIdExt.java b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockIdExt.java index 95e1d4fc..f9e8612b 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockIdExt.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockIdExt.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class BlockIdExt { +public class BlockIdExt implements Serializable { @SerializedName("@type") final String type = "ton.blockIdExt"; long workchain; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockTransactions.java b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockTransactions.java index 9ef16c32..ea1fe464 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/BlockTransactions.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/BlockTransactions.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class BlockTransactions { +public class BlockTransactions implements Serializable { @SerializedName("@type") final String type = "blocks.transactions"; BlockIdExt id; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Bounceable.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Bounceable.java index 92790134..0e6db97c 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Bounceable.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Bounceable.java @@ -5,11 +5,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class Bounceable { +public class Bounceable implements Serializable { String b64; String b64url; } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/ConfigInfo.java b/tonlib/src/main/java/org/ton/java/tonlib/types/ConfigInfo.java index 99a0deee..bdfa4c9a 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/ConfigInfo.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/ConfigInfo.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class ConfigInfo { +public class ConfigInfo implements Serializable { @SerializedName("@type") final String type = "configInfo"; TvmCell config; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Data.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Data.java index 3eafd7df..233a688c 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Data.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Data.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class Data { +public class Data implements Serializable { @SerializedName("@type") final String type = "data"; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Destination.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Destination.java index f7a629d0..8181cedc 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Destination.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Destination.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class Destination { +public class Destination implements Serializable { @SerializedName("@type") final String type = "data"; // not necessary diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/ExtMessageInfo.java b/tonlib/src/main/java/org/ton/java/tonlib/types/ExtMessageInfo.java index 8ababc49..19a03289 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/ExtMessageInfo.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/ExtMessageInfo.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class ExtMessageInfo { +public class ExtMessageInfo implements Serializable { @SerializedName("@type") final String type = "raw.extMessageInfo"; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Fees.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Fees.java index 5f320846..5c30c106 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Fees.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Fees.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class Fees { +public class Fees implements Serializable { @SerializedName("@type") final String type = "fees"; long in_fwd_fee; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/FullAccountState.java b/tonlib/src/main/java/org/ton/java/tonlib/types/FullAccountState.java index c723cfdf..26f9d06a 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/FullAccountState.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/FullAccountState.java @@ -5,11 +5,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class FullAccountState { +public class FullAccountState implements Serializable { AccountAddressOnly address; String balance; LastTransactionId last_transaction_id; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Key.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Key.java index 1893e85e..ce46c3ca 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Key.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Key.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class Key { +public class Key implements Serializable { @SerializedName("@type") final String type = "key"; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/LastTransactionId.java b/tonlib/src/main/java/org/ton/java/tonlib/types/LastTransactionId.java index 42c0059c..979dc2e9 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/LastTransactionId.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/LastTransactionId.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.math.BigInteger; @Builder @Setter @Getter @ToString -public class LastTransactionId { +public class LastTransactionId implements Serializable { @SerializedName("@type") final String type = "internal.transactionId"; // not necessary BigInteger lt; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/LoadContract.java b/tonlib/src/main/java/org/ton/java/tonlib/types/LoadContract.java index 27b625cf..ddae6154 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/LoadContract.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/LoadContract.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class LoadContract { +public class LoadContract implements Serializable { @SerializedName(value = "@type") final String type = "smc.info"; long id; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/MasterChainInfo.java b/tonlib/src/main/java/org/ton/java/tonlib/types/MasterChainInfo.java index 28aa6e17..33469374 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/MasterChainInfo.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/MasterChainInfo.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class MasterChainInfo { +public class MasterChainInfo implements Serializable { @SerializedName("@type") final String type = "blocks.masterchainInfo"; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/MsgData.java b/tonlib/src/main/java/org/ton/java/tonlib/types/MsgData.java index 3910dee1..69a1ec4b 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/MsgData.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/MsgData.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class MsgData { +public class MsgData implements Serializable { @SerializedName("@type") final String type;// = "msg.dataRaw"; can be also msg.dataText diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/NonBounceable.java b/tonlib/src/main/java/org/ton/java/tonlib/types/NonBounceable.java index b2537ec5..67b89f12 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/NonBounceable.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/NonBounceable.java @@ -5,11 +5,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class NonBounceable { +public class NonBounceable implements Serializable { String b64; String b64url; } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Ok.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Ok.java index 83fca16e..f2d95ff8 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Ok.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Ok.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class Ok { +public class Ok implements Serializable { @SerializedName("@type") final String type = "ok"; } 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 2bed93aa..08d72646 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 @@ -6,6 +6,7 @@ import org.ton.java.cell.Cell; import org.ton.java.utils.Utils; +import java.io.Serializable; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Base64; @@ -13,7 +14,8 @@ import static java.util.Objects.isNull; -public class ParseRunResult { + +public class ParseRunResult implements Serializable { private static final Gson gson = new GsonBuilder() .setObjectToNumberStrategy(ToNumberPolicy.BIG_DECIMAL) .setLenient() @@ -29,7 +31,9 @@ public class ParseRunResult { */ public static TvmStackEntry renderTvmElement(String elementType, String element) { - String[] values = {"num", "number", "int", "cell", "slice", "tvm.cell", "tvm.slice"}; + String[] values = { + "num", "number", "int", "cell", "slice", "tvm.cell", "tvm.slice" + }; if (Arrays.asList(values).contains(elementType)) { diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/QueryFees.java b/tonlib/src/main/java/org/ton/java/tonlib/types/QueryFees.java index 370fb0f1..d58f0f67 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/QueryFees.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/QueryFees.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class QueryFees { +public class QueryFees implements Serializable { @SerializedName("@type") final String type = "query.fees"; Fees source_fees; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/QueryInfo.java b/tonlib/src/main/java/org/ton/java/tonlib/types/QueryInfo.java index 4943e0ac..90ccf16d 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/QueryInfo.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/QueryInfo.java @@ -5,11 +5,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class QueryInfo { +public class QueryInfo implements Serializable { long id; long valid_until; String body_hash; // byte[] diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountForm.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountForm.java index f1c4abe9..1cf82bf6 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountForm.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountForm.java @@ -5,11 +5,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class RawAccountForm { +public class RawAccountForm implements Serializable { final String given_type = "raw_form"; //final String given_type = "friendly_non_bounceable"; String raw_form; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountState.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountState.java index 6ecf3e49..1fcaefc6 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountState.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RawAccountState.java @@ -6,16 +6,20 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class RawAccountState { +public class RawAccountState implements Serializable { @SerializedName(value = "@type") - final String type = "raw.accountState"; + final String type = "raw.fullAccountState"; String balance; String code; String data; LastTransactionId last_transaction_id; + BlockIdExt block_id; + String frozen_hash; long sync_utime; } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java index be5b75ca..c3f6ec88 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RawMessage.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class RawMessage { +public class RawMessage implements Serializable { @SerializedName("@type") final String type = "raw.message"; AccountAddressOnly source; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransaction.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransaction.java index c508862e..4b0263bc 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransaction.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransaction.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class RawTransaction { +public class RawTransaction implements Serializable { @SerializedName("@type") final String type = "raw.transaction"; long utime; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransactions.java b/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransactions.java index 6a9dfb0d..441468df 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransactions.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/RawTransactions.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class RawTransactions { +public class RawTransactions implements Serializable { @SerializedName("@type") final String type = "raw.transactions"; List transactions; 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 721f0f61..a59c762a 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.io.Serializable; import java.math.BigInteger; import java.util.List; @@ -12,7 +13,7 @@ @Setter @Getter @ToString -public class RunResult { +public class RunResult implements Serializable { List stack; BigInteger gas_used; long exit_code; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/Shards.java b/tonlib/src/main/java/org/ton/java/tonlib/types/Shards.java index 182da8c0..ea2a58fc 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/Shards.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/Shards.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class Shards { +public class Shards implements Serializable { @SerializedName("@type") final String type = "blocks.shards"; List shards; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/ShortTxId.java b/tonlib/src/main/java/org/ton/java/tonlib/types/ShortTxId.java index 34ce84f2..3d4fb22d 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/ShortTxId.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/ShortTxId.java @@ -5,11 +5,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class ShortTxId { +public class ShortTxId implements Serializable { long mode; String account; //base64 long lt; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/SyncStateInProgress.java b/tonlib/src/main/java/org/ton/java/tonlib/types/SyncStateInProgress.java index 9405d83c..89292d4a 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/SyncStateInProgress.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/SyncStateInProgress.java @@ -4,9 +4,11 @@ import lombok.Getter; import lombok.ToString; +import java.io.Serializable; + @Getter @ToString -public class SyncStateInProgress { +public class SyncStateInProgress implements Serializable { @SerializedName(value = "@type") final String type = "syncStateInProgress"; long from_seqno; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TonlibError.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TonlibError.java index 51ee193e..d9015a92 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TonlibError.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TonlibError.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TonlibError { +public class TonlibError implements Serializable { @SerializedName("@type") final String type = "error"; long code; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmCell.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmCell.java index c5366387..5ec7d349 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmCell.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmCell.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmCell extends TvmEntry { +public class TvmCell extends TvmEntry implements Serializable { @SerializedName("@type") final String type = "tvm.cell"; String bytes; //base64 diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmEntry.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmEntry.java index 321d70da..5f97bcba 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmEntry.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmEntry.java @@ -1,6 +1,8 @@ package org.ton.java.tonlib.types; -public abstract class TvmEntry { +import java.io.Serializable; + +public abstract class TvmEntry implements Serializable { } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmList.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmList.java index 0509902a..12af1e48 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmList.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmList.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class TvmList extends TvmEntry { +public class TvmList extends TvmEntry implements Serializable { @SerializedName("@type") final String type = "tvm.list"; List elements; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmNumber.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmNumber.java index 6cfc2106..64622c8c 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmNumber.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmNumber.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmNumber extends TvmEntry { +public class TvmNumber extends TvmEntry implements Serializable { @SerializedName("@type") final String type = "tvm.numberDecimal"; String number; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmSlice.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmSlice.java index 81b90210..cdc3b109 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmSlice.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmSlice.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmSlice extends TvmEntry { +public class TvmSlice extends TvmEntry implements Serializable { @SerializedName("@type") final String type = "tvm.slice"; String bytes; //base64? diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntry.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntry.java index 590441f5..cee0674c 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntry.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntry.java @@ -3,9 +3,11 @@ import lombok.Getter; import lombok.Setter; +import java.io.Serializable; + @Setter @Getter -public abstract class TvmStackEntry { +public abstract class TvmStackEntry implements Serializable { } diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryCell.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryCell.java index f5e09095..f50448af 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryCell.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryCell.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmStackEntryCell extends TvmStackEntry { +public class TvmStackEntryCell extends TvmStackEntry implements Serializable { @SerializedName("@type") final String type = "tvm.stackEntryCell"; TvmCell cell; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryList.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryList.java index 8e82d8f7..5207084e 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryList.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryList.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmStackEntryList extends TvmStackEntry { +public class TvmStackEntryList extends TvmStackEntry implements Serializable { @SerializedName("@type") final String type = "tvm.stackEntryList"; TvmList list; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryNumber.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryNumber.java index 6ae635bd..4534b3df 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryNumber.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryNumber.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.math.BigInteger; @Builder @Setter @Getter @ToString -public class TvmStackEntryNumber extends TvmStackEntry { +public class TvmStackEntryNumber extends TvmStackEntry implements Serializable { @SerializedName("@type") final String type = "tvm.stackEntryNumber"; TvmNumber number; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntrySlice.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntrySlice.java index ce488900..8c6893bb 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntrySlice.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntrySlice.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmStackEntrySlice extends TvmStackEntry { +public class TvmStackEntrySlice extends TvmStackEntry implements Serializable { @SerializedName("@type") final String type = "tvm.stackEntrySlice"; TvmSlice slice; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryTuple.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryTuple.java index 6c6a3b87..266a135a 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryTuple.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmStackEntryTuple.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class TvmStackEntryTuple extends TvmStackEntry { +public class TvmStackEntryTuple extends TvmStackEntry implements Serializable { @SerializedName("@type") final String type = "tvm.stackEntryTuple"; TvmTuple tuple; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmTuple.java b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmTuple.java index f399e796..cf202934 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/TvmTuple.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/TvmTuple.java @@ -6,13 +6,14 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; import java.util.List; @Builder @Setter @Getter @ToString -public class TvmTuple { +public class TvmTuple implements Serializable { @SerializedName("@type") final String type = "tvm.tuple"; List elements; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/UpdateSyncState.java b/tonlib/src/main/java/org/ton/java/tonlib/types/UpdateSyncState.java index d080430e..914a84a2 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/UpdateSyncState.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/UpdateSyncState.java @@ -6,11 +6,13 @@ import lombok.Setter; import lombok.ToString; +import java.io.Serializable; + @Builder @Setter @Getter @ToString -public class UpdateSyncState { +public class UpdateSyncState implements Serializable { @SerializedName(value = "@type") final String type = "updateSyncState"; SyncStateInProgress sync_state; diff --git a/tonlib/src/main/java/org/ton/java/tonlib/types/VerbosityLevel.java b/tonlib/src/main/java/org/ton/java/tonlib/types/VerbosityLevel.java index 5a5b213f..468534c2 100644 --- a/tonlib/src/main/java/org/ton/java/tonlib/types/VerbosityLevel.java +++ b/tonlib/src/main/java/org/ton/java/tonlib/types/VerbosityLevel.java @@ -1,5 +1,7 @@ package org.ton.java.tonlib.types; -public enum VerbosityLevel { +import java.io.Serializable; + +public enum VerbosityLevel implements Serializable { FATAL, ERROR, WARNING, INFO, DEBUG } 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 a076e4f9..d979c03b 100644 --- a/tonlib/src/test/java/org/ton/java/tonlib/TestConcurrentTonlib.java +++ b/tonlib/src/test/java/org/ton/java/tonlib/TestConcurrentTonlib.java @@ -14,6 +14,8 @@ import java.math.BigInteger; import java.util.ArrayDeque; import java.util.Deque; +import java.util.List; +import java.util.random.RandomGenerator; import static org.assertj.core.api.Assertions.assertThat; import static org.ton.java.tonlib.TestTonlibJson.ELECTOR_ADDRESSS; @@ -25,9 +27,15 @@ public class TestConcurrentTonlib { /** * There is no need for @extra field, since each Tonlib instance handling only its requests */ + + private static final List addresses = List.of("EQCtPHFrtkIw3UC2rNfSgVWYT1MiMLDUtgMy2M7j1P_eNMDq", "EQBrA5RGdTvbITagqlTT4nTflJG_NTcVqS929TV0eTjRPe1Q", "EQCs04A1_QPPSoovBGoa17D1N24wWHVeKYzrbB2H9a9grW-n"); + private static final List pubKeys = List.of("de225cb04a68d05b9f5be64c42f30842d76600bd681d654470bb982ffa218d9c", "1990e4eb05d6f309970837c3659f2e4194c2d2aa3ce6fd973bf12dbf8213feb8", "0d9b934a00a0cd64ad95bb6cf5dc1268eea862fba0882bc58f52a57dbd6abb7b"); + +// private static Tonlib tonlib = Tonlib.builder().build(); // you can't use one tonlib instance for parallel queries + @Test @ThreadCount(6) - public void testTonlibRunMethod() { + public void testTonlibRunMethod1() { Tonlib tonlib = Tonlib.builder() .build(); @@ -46,4 +54,22 @@ public void testTonlibRunMethod() { log.info("return stake: {} ", Utils.formatNanoValue(returnStake.longValue())); assertThat(result.getExit_code()).isEqualTo(0L); } + + @Test + @ThreadCount(6) + public void testTonlibRunMethod2() { + + Tonlib tonlib = Tonlib.builder() + .ignoreCache(false) + .build(); // instead, spawn new instance each time + + int i = RandomGenerator.getDefault().nextInt(0, 3); + RunResult result = tonlib.runMethod(Address.of(addresses.get(i)), "get_public_key"); + TvmStackEntryNumber pubkey = (TvmStackEntryNumber) result.getStack().get(0); + + String resultPubKey = pubkey.getNumber().toString(16); + log.info("{} with resultPubKey[{}]: {}", addresses.get(i), i, resultPubKey); + + assertThat(resultPubKey).isEqualTo(pubKeys.get(i)); + } } 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 7d43c1c6..876f4316 100644 --- a/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java +++ b/tonlib/src/test/java/org/ton/java/tonlib/TestTonlibJson.java @@ -185,6 +185,31 @@ public void testTonlibGetTxsByAddress() { assertThat(rawTransactions.getTransactions().size()).isLessThan(20); } + @Test + public void testTonlibGetTxsWithLimitByAddress() { + Tonlib tonlib = Tonlib.builder().build(); + + Address address = Address.of(TON_FOUNDATION); + + log.info("address: " + address.toString(true)); + + RawTransactions rawTransactions = tonlib.getRawTransactions(address.toString(false), null, null, 3); + + for (RawTransaction tx : rawTransactions.getTransactions()) { + if ((tx.getIn_msg() != null) && (!tx.getIn_msg().getSource().getAccount_address().equals(""))) { + log.info("{}, {} <<<<< {} : {} ", Utils.toUTC(tx.getUtime()), tx.getIn_msg().getSource().getAccount_address(), tx.getIn_msg().getDestination().getAccount_address(), Utils.formatNanoValue(tx.getIn_msg().getValue())); + } + if (tx.getOut_msgs() != null) { + for (RawMessage msg : tx.getOut_msgs()) { + log.info("{}, {} >>>>> {} : {} ", Utils.toUTC(tx.getUtime()), msg.getSource().getAccount_address(), msg.getDestination().getAccount_address(), Utils.formatNanoValue(msg.getValue())); + } + } + } + + log.info("total txs: {}", rawTransactions.getTransactions().size()); + assertThat(rawTransactions.getTransactions().size()).isLessThan(4); + } + @Test public void testTonlibGetAllTxsByAddress() { Tonlib tonlib = Tonlib.builder().build(); @@ -208,9 +233,36 @@ public void testTonlibGetAllTxsByAddress() { } } - assertThat(rawTransactions.getTransactions().size()).isGreaterThan(20); + assertThat(rawTransactions.getTransactions().size()).isGreaterThan(50); + } + + @Test + public void testTonlibGetAllTxsByAddressSmallHistoryLimit() { + Tonlib tonlib = Tonlib.builder().build(); + + Address address = Address.of(TON_FOUNDATION); + + log.info("address: " + address.toString(true)); + + RawTransactions rawTransactions = tonlib.getAllRawTransactions(address.toString(false), null, null, 3); + + log.info("total txs: {}", rawTransactions.getTransactions().size()); + + for (RawTransaction tx : rawTransactions.getTransactions()) { + if ((tx.getIn_msg() != null) && (!tx.getIn_msg().getSource().getAccount_address().equals(""))) { + log.info("<<<<< {} - {} : {} ", tx.getIn_msg().getSource().getAccount_address(), tx.getIn_msg().getDestination().getAccount_address(), Utils.formatNanoValue(tx.getIn_msg().getValue())); + } + if (tx.getOut_msgs() != null) { + for (RawMessage msg : tx.getOut_msgs()) { + log.info(">>>>> {} - {} : {} ", msg.getSource().getAccount_address(), msg.getDestination().getAccount_address(), Utils.formatNanoValue(msg.getValue())); + } + } + } + + assertThat(rawTransactions.getTransactions().size()).isLessThan(4); } + /** * Create new key pair and sign data using Tonlib library */ @@ -303,23 +355,23 @@ public void testTonlibRawAccountState() { assertThat(accountState.getCode()).isNotBlank(); } - @Test - public void testTonlibAccountState() { - Tonlib tonlib = Tonlib.builder().build(); - - Address addr = Address.of("Ef8-sf_0CQDgwW6kNuNY8mUvRW-MGQ34Evffj8O0Z9Ly1tZ4"); - log.info("address: " + addr.toString(true)); - - AccountAddressOnly accountAddressOnly = AccountAddressOnly.builder() - .account_address(addr.toString(true)) - .build(); - - FullAccountState accountState = tonlib.getAccountState(accountAddressOnly); - log.info(accountState.toString()); - log.info("balance: {}", accountState.getBalance()); - assertThat(accountState.getLast_transaction_id().getHash()).isNotBlank(); - log.info("last {}", tonlib.getLast()); - } +// @Test +// public void testTonlibAccountState() { +// Tonlib tonlib = Tonlib.builder().build(); +// +// Address addr = Address.of("Ef8-sf_0CQDgwW6kNuNY8mUvRW-MGQ34Evffj8O0Z9Ly1tZ4"); +// log.info("address: " + addr.toString(true)); +// +// AccountAddressOnly accountAddressOnly = AccountAddressOnly.builder() +// .account_address(addr.toString(true)) +// .build(); +// +// FullAccountState accountState = tonlib.getAccountState(accountAddressOnly); +// log.info(accountState.toString()); +// log.info("balance: {}", accountState.getBalance()); +// assertThat(accountState.getLast_transaction_id().getHash()).isNotBlank(); +// log.info("last {}", tonlib.getLast()); +// } @Test public void testTonlibKeystorePath() { @@ -441,4 +493,22 @@ public void testTonlibRunMethodComputeReturnedStake() { BigInteger returnStake = ((TvmStackEntryNumber) result.getStack().get(0)).getNumber(); log.info("return stake: {} ", Utils.formatNanoValue(returnStake.longValue())); } + + @Test + public void testTonlib3() { + Tonlib tonlib = Tonlib.builder() + .verbosityLevel(VerbosityLevel.DEBUG) + .build(); + + int i = 0; + FullAccountState accountState1 = tonlib.getAccountState(Address.of("EQCtPHFrtkIw3UC2rNfSgVWYT1MiMLDUtgMy2M7j1P_eNMDq")); + log.info("=========================================="); + RawAccountState accountState2 = tonlib.getRawAccountState(Address.of("EQCtPHFrtkIw3UC2rNfSgVWYT1MiMLDUtgMy2M7j1P_eNMDq")); + log.info("{} with balance {} and code [{}]: {}", "EQCtPHFrtkIw3UC2rNfSgVWYT1MiMLDUtgMy2M7j1P_eNMDq", i, accountState1.getBalance(), accountState1); + log.info("{} with balance {} and code [{}]: {}", "EQCtPHFrtkIw3UC2rNfSgVWYT1MiMLDUtgMy2M7j1P_eNMDq", i, accountState2.getBalance(), accountState2); + log.info("wallet_id {}, seqno {}", accountState1.getAccount_state().getWallet_id(), accountState1.getAccount_state().getSeqno()); + log.info("frozen_hash {}", accountState1.getAccount_state().getFrozen_hash()); + log.info("frozen_hash {}", accountState2.getFrozen_hash()); + assertThat(accountState1.getBalance()).isEqualTo(accountState2.getBalance()); + } } \ No newline at end of file diff --git a/utils/README.md b/utils/README.md index a91dc337..9c9b9d07 100644 --- a/utils/README.md +++ b/utils/README.md @@ -7,7 +7,7 @@ io.github.neodix42 utils - 0.1.1 + 0.1.2 ``` @@ -18,7 +18,7 @@ io.github.neodix42.ton4j utils - 0.1.1 + 0.1.2 ``` diff --git a/utils/pom.xml b/utils/pom.xml index 25959499..84f18691 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -6,7 +6,7 @@ io.github.neodix42 top - 0.1.1 + 0.1.2 4.0.0 diff --git a/utils/src/main/java/org/ton/java/utils/Utils.java b/utils/src/main/java/org/ton/java/utils/Utils.java index 445eccf6..b3a89967 100644 --- a/utils/src/main/java/org/ton/java/utils/Utils.java +++ b/utils/src/main/java/org/ton/java/utils/Utils.java @@ -20,6 +20,7 @@ import java.util.Base64; import java.util.Locale; import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.zip.CRC32C; import java.util.zip.Checksum; @@ -508,4 +509,13 @@ public static void sleep(long seconds, String text) { System.out.println(e.getMessage()); } } + + public static int ip2int(String address) { + int result = 0; + for (String part : address.split(Pattern.quote("."))) { + result = result << 8; + result |= Integer.parseInt(part); + } + return result; + } }