├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── cli ├── Cargo.toml └── src │ ├── arg_parsers.rs │ └── main.rs ├── docs └── lite.tl ├── liteapi ├── Cargo.toml ├── examples │ ├── client.rs │ └── server.rs └── src │ ├── client.rs │ ├── layers │ └── mod.rs │ ├── lib.rs │ ├── peer.rs │ ├── server.rs │ ├── tl │ ├── adnl.rs │ ├── common.rs │ ├── mod.rs │ ├── request.rs │ ├── response.rs │ ├── tests.rs │ └── utils.rs │ └── types.rs └── network-config ├── Cargo.toml └── src └── lib.rs /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | name: Continuous integration 4 | 5 | jobs: 6 | build: 7 | name: Build liteapi 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions-rs/toolchain@v1 12 | with: 13 | profile: minimal 14 | toolchain: stable 15 | override: true 16 | - uses: actions-rs/cargo@v1 17 | with: 18 | command: build 19 | args: --manifest-path=liteapi/Cargo.toml 20 | 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .idea 3 | .vscode 4 | /log 5 | *.dat -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.21.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "adnl" 22 | version = "2.0.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "8b3cb50ffb09675285804083fc6283ad84a0857db567280959903b84c9ea3aac" 25 | dependencies = [ 26 | "aes", 27 | "ctr", 28 | "everscale-crypto", 29 | "futures", 30 | "hex", 31 | "log", 32 | "pin-project", 33 | "rand", 34 | "rand_core", 35 | "sha2", 36 | "thiserror", 37 | "tokio", 38 | "tokio-util", 39 | ] 40 | 41 | [[package]] 42 | name = "aes" 43 | version = "0.8.4" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" 46 | dependencies = [ 47 | "cfg-if", 48 | "cipher", 49 | "cpufeatures", 50 | ] 51 | 52 | [[package]] 53 | name = "aho-corasick" 54 | version = "1.1.3" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 57 | dependencies = [ 58 | "memchr", 59 | ] 60 | 61 | [[package]] 62 | name = "android-tzdata" 63 | version = "0.1.1" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" 66 | 67 | [[package]] 68 | name = "android_system_properties" 69 | version = "0.1.5" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 72 | dependencies = [ 73 | "libc", 74 | ] 75 | 76 | [[package]] 77 | name = "anstream" 78 | version = "0.6.13" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" 81 | dependencies = [ 82 | "anstyle", 83 | "anstyle-parse", 84 | "anstyle-query", 85 | "anstyle-wincon", 86 | "colorchoice", 87 | "utf8parse", 88 | ] 89 | 90 | [[package]] 91 | name = "anstyle" 92 | version = "1.0.6" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" 95 | 96 | [[package]] 97 | name = "anstyle-parse" 98 | version = "0.2.3" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" 101 | dependencies = [ 102 | "utf8parse", 103 | ] 104 | 105 | [[package]] 106 | name = "anstyle-query" 107 | version = "1.0.2" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" 110 | dependencies = [ 111 | "windows-sys 0.52.0", 112 | ] 113 | 114 | [[package]] 115 | name = "anstyle-wincon" 116 | version = "3.0.2" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" 119 | dependencies = [ 120 | "anstyle", 121 | "windows-sys 0.52.0", 122 | ] 123 | 124 | [[package]] 125 | name = "atty" 126 | version = "0.2.14" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 129 | dependencies = [ 130 | "hermit-abi 0.1.19", 131 | "libc", 132 | "winapi", 133 | ] 134 | 135 | [[package]] 136 | name = "autocfg" 137 | version = "1.2.0" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" 140 | 141 | [[package]] 142 | name = "backtrace" 143 | version = "0.3.71" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" 146 | dependencies = [ 147 | "addr2line", 148 | "cc", 149 | "cfg-if", 150 | "libc", 151 | "miniz_oxide", 152 | "object", 153 | "rustc-demangle", 154 | ] 155 | 156 | [[package]] 157 | name = "base64" 158 | version = "0.13.1" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" 161 | 162 | [[package]] 163 | name = "base64" 164 | version = "0.21.7" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" 167 | 168 | [[package]] 169 | name = "bitflags" 170 | version = "1.3.2" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 173 | 174 | [[package]] 175 | name = "block-buffer" 176 | version = "0.10.4" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 179 | dependencies = [ 180 | "generic-array", 181 | ] 182 | 183 | [[package]] 184 | name = "bumpalo" 185 | version = "3.15.4" 186 | source = "registry+https://github.com/rust-lang/crates.io-index" 187 | checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" 188 | 189 | [[package]] 190 | name = "bytes" 191 | version = "1.6.0" 192 | source = "registry+https://github.com/rust-lang/crates.io-index" 193 | checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" 194 | 195 | [[package]] 196 | name = "cc" 197 | version = "1.0.90" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" 200 | 201 | [[package]] 202 | name = "cfg-if" 203 | version = "1.0.0" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 206 | 207 | [[package]] 208 | name = "chrono" 209 | version = "0.4.35" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" 212 | dependencies = [ 213 | "android-tzdata", 214 | "iana-time-zone", 215 | "js-sys", 216 | "num-traits", 217 | "wasm-bindgen", 218 | "windows-targets 0.52.4", 219 | ] 220 | 221 | [[package]] 222 | name = "cipher" 223 | version = "0.4.4" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" 226 | dependencies = [ 227 | "crypto-common", 228 | "inout", 229 | ] 230 | 231 | [[package]] 232 | name = "clap" 233 | version = "3.2.25" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" 236 | dependencies = [ 237 | "atty", 238 | "bitflags", 239 | "clap_derive", 240 | "clap_lex", 241 | "indexmap", 242 | "once_cell", 243 | "strsim", 244 | "termcolor", 245 | "textwrap", 246 | ] 247 | 248 | [[package]] 249 | name = "clap_derive" 250 | version = "3.2.25" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" 253 | dependencies = [ 254 | "heck", 255 | "proc-macro-error", 256 | "proc-macro2", 257 | "quote", 258 | "syn 1.0.109", 259 | ] 260 | 261 | [[package]] 262 | name = "clap_lex" 263 | version = "0.2.4" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" 266 | dependencies = [ 267 | "os_str_bytes", 268 | ] 269 | 270 | [[package]] 271 | name = "colorchoice" 272 | version = "1.0.0" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 275 | 276 | [[package]] 277 | name = "core-foundation-sys" 278 | version = "0.8.6" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" 281 | 282 | [[package]] 283 | name = "cpufeatures" 284 | version = "0.2.12" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" 287 | dependencies = [ 288 | "libc", 289 | ] 290 | 291 | [[package]] 292 | name = "crc" 293 | version = "3.0.1" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" 296 | dependencies = [ 297 | "crc-catalog", 298 | ] 299 | 300 | [[package]] 301 | name = "crc-catalog" 302 | version = "2.4.0" 303 | source = "registry+https://github.com/rust-lang/crates.io-index" 304 | checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" 305 | 306 | [[package]] 307 | name = "crc32fast" 308 | version = "1.4.0" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" 311 | dependencies = [ 312 | "cfg-if", 313 | ] 314 | 315 | [[package]] 316 | name = "crossbeam" 317 | version = "0.8.4" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" 320 | dependencies = [ 321 | "crossbeam-channel", 322 | "crossbeam-deque", 323 | "crossbeam-epoch", 324 | "crossbeam-queue", 325 | "crossbeam-utils", 326 | ] 327 | 328 | [[package]] 329 | name = "crossbeam-channel" 330 | version = "0.5.12" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" 333 | dependencies = [ 334 | "crossbeam-utils", 335 | ] 336 | 337 | [[package]] 338 | name = "crossbeam-deque" 339 | version = "0.8.5" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" 342 | dependencies = [ 343 | "crossbeam-epoch", 344 | "crossbeam-utils", 345 | ] 346 | 347 | [[package]] 348 | name = "crossbeam-epoch" 349 | version = "0.9.18" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 352 | dependencies = [ 353 | "crossbeam-utils", 354 | ] 355 | 356 | [[package]] 357 | name = "crossbeam-queue" 358 | version = "0.3.11" 359 | source = "registry+https://github.com/rust-lang/crates.io-index" 360 | checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" 361 | dependencies = [ 362 | "crossbeam-utils", 363 | ] 364 | 365 | [[package]] 366 | name = "crossbeam-utils" 367 | version = "0.8.19" 368 | source = "registry+https://github.com/rust-lang/crates.io-index" 369 | checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" 370 | 371 | [[package]] 372 | name = "crypto-common" 373 | version = "0.1.6" 374 | source = "registry+https://github.com/rust-lang/crates.io-index" 375 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 376 | dependencies = [ 377 | "generic-array", 378 | "typenum", 379 | ] 380 | 381 | [[package]] 382 | name = "ctr" 383 | version = "0.9.2" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" 386 | dependencies = [ 387 | "cipher", 388 | ] 389 | 390 | [[package]] 391 | name = "curve25519-dalek" 392 | version = "4.1.2" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" 395 | dependencies = [ 396 | "cfg-if", 397 | "cpufeatures", 398 | "curve25519-dalek-derive", 399 | "fiat-crypto", 400 | "platforms", 401 | "rustc_version", 402 | "subtle", 403 | "zeroize", 404 | ] 405 | 406 | [[package]] 407 | name = "curve25519-dalek-derive" 408 | version = "0.1.1" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" 411 | dependencies = [ 412 | "proc-macro2", 413 | "quote", 414 | "syn 2.0.55", 415 | ] 416 | 417 | [[package]] 418 | name = "darling" 419 | version = "0.13.4" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" 422 | dependencies = [ 423 | "darling_core", 424 | "darling_macro", 425 | ] 426 | 427 | [[package]] 428 | name = "darling_core" 429 | version = "0.13.4" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" 432 | dependencies = [ 433 | "fnv", 434 | "ident_case", 435 | "proc-macro2", 436 | "quote", 437 | "strsim", 438 | "syn 1.0.109", 439 | ] 440 | 441 | [[package]] 442 | name = "darling_macro" 443 | version = "0.13.4" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" 446 | dependencies = [ 447 | "darling_core", 448 | "quote", 449 | "syn 1.0.109", 450 | ] 451 | 452 | [[package]] 453 | name = "derivative" 454 | version = "2.2.0" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 457 | dependencies = [ 458 | "proc-macro2", 459 | "quote", 460 | "syn 1.0.109", 461 | ] 462 | 463 | [[package]] 464 | name = "digest" 465 | version = "0.10.7" 466 | source = "registry+https://github.com/rust-lang/crates.io-index" 467 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 468 | dependencies = [ 469 | "block-buffer", 470 | "crypto-common", 471 | ] 472 | 473 | [[package]] 474 | name = "env_filter" 475 | version = "0.1.0" 476 | source = "registry+https://github.com/rust-lang/crates.io-index" 477 | checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" 478 | dependencies = [ 479 | "log", 480 | "regex", 481 | ] 482 | 483 | [[package]] 484 | name = "env_logger" 485 | version = "0.9.3" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" 488 | dependencies = [ 489 | "atty", 490 | "humantime", 491 | "log", 492 | "regex", 493 | "termcolor", 494 | ] 495 | 496 | [[package]] 497 | name = "env_logger" 498 | version = "0.11.3" 499 | source = "registry+https://github.com/rust-lang/crates.io-index" 500 | checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" 501 | dependencies = [ 502 | "anstream", 503 | "anstyle", 504 | "env_filter", 505 | "humantime", 506 | "log", 507 | ] 508 | 509 | [[package]] 510 | name = "everscale-crypto" 511 | version = "0.2.1" 512 | source = "registry+https://github.com/rust-lang/crates.io-index" 513 | checksum = "0b0304a55e328ca4f354e59e6816bccb43b03f681b85b31c6bd10ea7233d62b5" 514 | dependencies = [ 515 | "curve25519-dalek", 516 | "generic-array", 517 | "hex", 518 | "rand", 519 | "sha2", 520 | "tl-proto", 521 | ] 522 | 523 | [[package]] 524 | name = "fiat-crypto" 525 | version = "0.2.7" 526 | source = "registry+https://github.com/rust-lang/crates.io-index" 527 | checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" 528 | 529 | [[package]] 530 | name = "flate2" 531 | version = "1.0.28" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" 534 | dependencies = [ 535 | "crc32fast", 536 | "miniz_oxide", 537 | ] 538 | 539 | [[package]] 540 | name = "fnv" 541 | version = "1.0.7" 542 | source = "registry+https://github.com/rust-lang/crates.io-index" 543 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 544 | 545 | [[package]] 546 | name = "form_urlencoded" 547 | version = "1.2.1" 548 | source = "registry+https://github.com/rust-lang/crates.io-index" 549 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 550 | dependencies = [ 551 | "percent-encoding", 552 | ] 553 | 554 | [[package]] 555 | name = "futures" 556 | version = "0.3.30" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" 559 | dependencies = [ 560 | "futures-channel", 561 | "futures-core", 562 | "futures-executor", 563 | "futures-io", 564 | "futures-sink", 565 | "futures-task", 566 | "futures-util", 567 | ] 568 | 569 | [[package]] 570 | name = "futures-channel" 571 | version = "0.3.30" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 574 | dependencies = [ 575 | "futures-core", 576 | "futures-sink", 577 | ] 578 | 579 | [[package]] 580 | name = "futures-core" 581 | version = "0.3.30" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 584 | 585 | [[package]] 586 | name = "futures-executor" 587 | version = "0.3.30" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" 590 | dependencies = [ 591 | "futures-core", 592 | "futures-task", 593 | "futures-util", 594 | ] 595 | 596 | [[package]] 597 | name = "futures-io" 598 | version = "0.3.30" 599 | source = "registry+https://github.com/rust-lang/crates.io-index" 600 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 601 | 602 | [[package]] 603 | name = "futures-macro" 604 | version = "0.3.30" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" 607 | dependencies = [ 608 | "proc-macro2", 609 | "quote", 610 | "syn 2.0.55", 611 | ] 612 | 613 | [[package]] 614 | name = "futures-sink" 615 | version = "0.3.30" 616 | source = "registry+https://github.com/rust-lang/crates.io-index" 617 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" 618 | 619 | [[package]] 620 | name = "futures-task" 621 | version = "0.3.30" 622 | source = "registry+https://github.com/rust-lang/crates.io-index" 623 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 624 | 625 | [[package]] 626 | name = "futures-util" 627 | version = "0.3.30" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 630 | dependencies = [ 631 | "futures-channel", 632 | "futures-core", 633 | "futures-io", 634 | "futures-macro", 635 | "futures-sink", 636 | "futures-task", 637 | "memchr", 638 | "pin-project-lite", 639 | "pin-utils", 640 | "slab", 641 | ] 642 | 643 | [[package]] 644 | name = "generic-array" 645 | version = "0.14.7" 646 | source = "registry+https://github.com/rust-lang/crates.io-index" 647 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 648 | dependencies = [ 649 | "typenum", 650 | "version_check", 651 | ] 652 | 653 | [[package]] 654 | name = "getrandom" 655 | version = "0.2.12" 656 | source = "registry+https://github.com/rust-lang/crates.io-index" 657 | checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" 658 | dependencies = [ 659 | "cfg-if", 660 | "libc", 661 | "wasi", 662 | ] 663 | 664 | [[package]] 665 | name = "gimli" 666 | version = "0.28.1" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" 669 | 670 | [[package]] 671 | name = "hashbrown" 672 | version = "0.12.3" 673 | source = "registry+https://github.com/rust-lang/crates.io-index" 674 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 675 | 676 | [[package]] 677 | name = "heck" 678 | version = "0.4.1" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 681 | 682 | [[package]] 683 | name = "hermit-abi" 684 | version = "0.1.19" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 687 | dependencies = [ 688 | "libc", 689 | ] 690 | 691 | [[package]] 692 | name = "hermit-abi" 693 | version = "0.3.9" 694 | source = "registry+https://github.com/rust-lang/crates.io-index" 695 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 696 | 697 | [[package]] 698 | name = "hex" 699 | version = "0.4.3" 700 | source = "registry+https://github.com/rust-lang/crates.io-index" 701 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 702 | 703 | [[package]] 704 | name = "humantime" 705 | version = "2.1.0" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 708 | 709 | [[package]] 710 | name = "iana-time-zone" 711 | version = "0.1.60" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" 714 | dependencies = [ 715 | "android_system_properties", 716 | "core-foundation-sys", 717 | "iana-time-zone-haiku", 718 | "js-sys", 719 | "wasm-bindgen", 720 | "windows-core", 721 | ] 722 | 723 | [[package]] 724 | name = "iana-time-zone-haiku" 725 | version = "0.1.2" 726 | source = "registry+https://github.com/rust-lang/crates.io-index" 727 | checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" 728 | dependencies = [ 729 | "cc", 730 | ] 731 | 732 | [[package]] 733 | name = "ident_case" 734 | version = "1.0.1" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 737 | 738 | [[package]] 739 | name = "idna" 740 | version = "0.5.0" 741 | source = "registry+https://github.com/rust-lang/crates.io-index" 742 | checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" 743 | dependencies = [ 744 | "unicode-bidi", 745 | "unicode-normalization", 746 | ] 747 | 748 | [[package]] 749 | name = "indexmap" 750 | version = "1.9.3" 751 | source = "registry+https://github.com/rust-lang/crates.io-index" 752 | checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" 753 | dependencies = [ 754 | "autocfg", 755 | "hashbrown", 756 | ] 757 | 758 | [[package]] 759 | name = "inout" 760 | version = "0.1.3" 761 | source = "registry+https://github.com/rust-lang/crates.io-index" 762 | checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" 763 | dependencies = [ 764 | "generic-array", 765 | ] 766 | 767 | [[package]] 768 | name = "itoa" 769 | version = "1.0.11" 770 | source = "registry+https://github.com/rust-lang/crates.io-index" 771 | checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" 772 | 773 | [[package]] 774 | name = "js-sys" 775 | version = "0.3.69" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" 778 | dependencies = [ 779 | "wasm-bindgen", 780 | ] 781 | 782 | [[package]] 783 | name = "libc" 784 | version = "0.2.153" 785 | source = "registry+https://github.com/rust-lang/crates.io-index" 786 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 787 | 788 | [[package]] 789 | name = "lock_api" 790 | version = "0.4.11" 791 | source = "registry+https://github.com/rust-lang/crates.io-index" 792 | checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" 793 | dependencies = [ 794 | "autocfg", 795 | "scopeguard", 796 | ] 797 | 798 | [[package]] 799 | name = "log" 800 | version = "0.4.21" 801 | source = "registry+https://github.com/rust-lang/crates.io-index" 802 | checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" 803 | 804 | [[package]] 805 | name = "memchr" 806 | version = "2.7.1" 807 | source = "registry+https://github.com/rust-lang/crates.io-index" 808 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" 809 | 810 | [[package]] 811 | name = "miniz_oxide" 812 | version = "0.7.2" 813 | source = "registry+https://github.com/rust-lang/crates.io-index" 814 | checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" 815 | dependencies = [ 816 | "adler", 817 | ] 818 | 819 | [[package]] 820 | name = "mio" 821 | version = "0.8.11" 822 | source = "registry+https://github.com/rust-lang/crates.io-index" 823 | checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" 824 | dependencies = [ 825 | "libc", 826 | "wasi", 827 | "windows-sys 0.48.0", 828 | ] 829 | 830 | [[package]] 831 | name = "num-traits" 832 | version = "0.2.18" 833 | source = "registry+https://github.com/rust-lang/crates.io-index" 834 | checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" 835 | dependencies = [ 836 | "autocfg", 837 | ] 838 | 839 | [[package]] 840 | name = "num_cpus" 841 | version = "1.16.0" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" 844 | dependencies = [ 845 | "hermit-abi 0.3.9", 846 | "libc", 847 | ] 848 | 849 | [[package]] 850 | name = "object" 851 | version = "0.32.2" 852 | source = "registry+https://github.com/rust-lang/crates.io-index" 853 | checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" 854 | dependencies = [ 855 | "memchr", 856 | ] 857 | 858 | [[package]] 859 | name = "once_cell" 860 | version = "1.19.0" 861 | source = "registry+https://github.com/rust-lang/crates.io-index" 862 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 863 | 864 | [[package]] 865 | name = "os_str_bytes" 866 | version = "6.6.1" 867 | source = "registry+https://github.com/rust-lang/crates.io-index" 868 | checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" 869 | 870 | [[package]] 871 | name = "parking_lot" 872 | version = "0.12.1" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 875 | dependencies = [ 876 | "lock_api", 877 | "parking_lot_core", 878 | ] 879 | 880 | [[package]] 881 | name = "parking_lot_core" 882 | version = "0.9.9" 883 | source = "registry+https://github.com/rust-lang/crates.io-index" 884 | checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" 885 | dependencies = [ 886 | "cfg-if", 887 | "libc", 888 | "redox_syscall", 889 | "smallvec", 890 | "windows-targets 0.48.5", 891 | ] 892 | 893 | [[package]] 894 | name = "percent-encoding" 895 | version = "2.3.1" 896 | source = "registry+https://github.com/rust-lang/crates.io-index" 897 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 898 | 899 | [[package]] 900 | name = "pest" 901 | version = "2.7.8" 902 | source = "registry+https://github.com/rust-lang/crates.io-index" 903 | checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" 904 | dependencies = [ 905 | "memchr", 906 | "thiserror", 907 | "ucd-trie", 908 | ] 909 | 910 | [[package]] 911 | name = "pest_derive" 912 | version = "2.7.8" 913 | source = "registry+https://github.com/rust-lang/crates.io-index" 914 | checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" 915 | dependencies = [ 916 | "pest", 917 | "pest_generator", 918 | ] 919 | 920 | [[package]] 921 | name = "pest_generator" 922 | version = "2.7.8" 923 | source = "registry+https://github.com/rust-lang/crates.io-index" 924 | checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" 925 | dependencies = [ 926 | "pest", 927 | "pest_meta", 928 | "proc-macro2", 929 | "quote", 930 | "syn 2.0.55", 931 | ] 932 | 933 | [[package]] 934 | name = "pest_meta" 935 | version = "2.7.8" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" 938 | dependencies = [ 939 | "once_cell", 940 | "pest", 941 | "sha2", 942 | ] 943 | 944 | [[package]] 945 | name = "pin-project" 946 | version = "1.1.5" 947 | source = "registry+https://github.com/rust-lang/crates.io-index" 948 | checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" 949 | dependencies = [ 950 | "pin-project-internal", 951 | ] 952 | 953 | [[package]] 954 | name = "pin-project-internal" 955 | version = "1.1.5" 956 | source = "registry+https://github.com/rust-lang/crates.io-index" 957 | checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" 958 | dependencies = [ 959 | "proc-macro2", 960 | "quote", 961 | "syn 2.0.55", 962 | ] 963 | 964 | [[package]] 965 | name = "pin-project-lite" 966 | version = "0.2.13" 967 | source = "registry+https://github.com/rust-lang/crates.io-index" 968 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" 969 | 970 | [[package]] 971 | name = "pin-utils" 972 | version = "0.1.0" 973 | source = "registry+https://github.com/rust-lang/crates.io-index" 974 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 975 | 976 | [[package]] 977 | name = "platforms" 978 | version = "3.3.0" 979 | source = "registry+https://github.com/rust-lang/crates.io-index" 980 | checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" 981 | 982 | [[package]] 983 | name = "ppv-lite86" 984 | version = "0.2.17" 985 | source = "registry+https://github.com/rust-lang/crates.io-index" 986 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 987 | 988 | [[package]] 989 | name = "pretty-hex" 990 | version = "0.2.1" 991 | source = "registry+https://github.com/rust-lang/crates.io-index" 992 | checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" 993 | 994 | [[package]] 995 | name = "proc-macro-error" 996 | version = "1.0.4" 997 | source = "registry+https://github.com/rust-lang/crates.io-index" 998 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 999 | dependencies = [ 1000 | "proc-macro-error-attr", 1001 | "proc-macro2", 1002 | "quote", 1003 | "syn 1.0.109", 1004 | "version_check", 1005 | ] 1006 | 1007 | [[package]] 1008 | name = "proc-macro-error-attr" 1009 | version = "1.0.4" 1010 | source = "registry+https://github.com/rust-lang/crates.io-index" 1011 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 1012 | dependencies = [ 1013 | "proc-macro2", 1014 | "quote", 1015 | "version_check", 1016 | ] 1017 | 1018 | [[package]] 1019 | name = "proc-macro2" 1020 | version = "1.0.79" 1021 | source = "registry+https://github.com/rust-lang/crates.io-index" 1022 | checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" 1023 | dependencies = [ 1024 | "unicode-ident", 1025 | ] 1026 | 1027 | [[package]] 1028 | name = "quote" 1029 | version = "1.0.35" 1030 | source = "registry+https://github.com/rust-lang/crates.io-index" 1031 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 1032 | dependencies = [ 1033 | "proc-macro2", 1034 | ] 1035 | 1036 | [[package]] 1037 | name = "rand" 1038 | version = "0.8.5" 1039 | source = "registry+https://github.com/rust-lang/crates.io-index" 1040 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 1041 | dependencies = [ 1042 | "libc", 1043 | "rand_chacha", 1044 | "rand_core", 1045 | ] 1046 | 1047 | [[package]] 1048 | name = "rand_chacha" 1049 | version = "0.3.1" 1050 | source = "registry+https://github.com/rust-lang/crates.io-index" 1051 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1052 | dependencies = [ 1053 | "ppv-lite86", 1054 | "rand_core", 1055 | ] 1056 | 1057 | [[package]] 1058 | name = "rand_core" 1059 | version = "0.6.4" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 1062 | dependencies = [ 1063 | "getrandom", 1064 | ] 1065 | 1066 | [[package]] 1067 | name = "redox_syscall" 1068 | version = "0.4.1" 1069 | source = "registry+https://github.com/rust-lang/crates.io-index" 1070 | checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" 1071 | dependencies = [ 1072 | "bitflags", 1073 | ] 1074 | 1075 | [[package]] 1076 | name = "regex" 1077 | version = "1.10.4" 1078 | source = "registry+https://github.com/rust-lang/crates.io-index" 1079 | checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" 1080 | dependencies = [ 1081 | "aho-corasick", 1082 | "memchr", 1083 | "regex-automata", 1084 | "regex-syntax", 1085 | ] 1086 | 1087 | [[package]] 1088 | name = "regex-automata" 1089 | version = "0.4.6" 1090 | source = "registry+https://github.com/rust-lang/crates.io-index" 1091 | checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" 1092 | dependencies = [ 1093 | "aho-corasick", 1094 | "memchr", 1095 | "regex-syntax", 1096 | ] 1097 | 1098 | [[package]] 1099 | name = "regex-syntax" 1100 | version = "0.8.2" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" 1103 | 1104 | [[package]] 1105 | name = "ring" 1106 | version = "0.17.8" 1107 | source = "registry+https://github.com/rust-lang/crates.io-index" 1108 | checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" 1109 | dependencies = [ 1110 | "cc", 1111 | "cfg-if", 1112 | "getrandom", 1113 | "libc", 1114 | "spin", 1115 | "untrusted", 1116 | "windows-sys 0.52.0", 1117 | ] 1118 | 1119 | [[package]] 1120 | name = "rustc-demangle" 1121 | version = "0.1.23" 1122 | source = "registry+https://github.com/rust-lang/crates.io-index" 1123 | checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" 1124 | 1125 | [[package]] 1126 | name = "rustc-hash" 1127 | version = "1.1.0" 1128 | source = "registry+https://github.com/rust-lang/crates.io-index" 1129 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 1130 | 1131 | [[package]] 1132 | name = "rustc_version" 1133 | version = "0.4.0" 1134 | source = "registry+https://github.com/rust-lang/crates.io-index" 1135 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 1136 | dependencies = [ 1137 | "semver", 1138 | ] 1139 | 1140 | [[package]] 1141 | name = "rustls" 1142 | version = "0.22.3" 1143 | source = "registry+https://github.com/rust-lang/crates.io-index" 1144 | checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" 1145 | dependencies = [ 1146 | "log", 1147 | "ring", 1148 | "rustls-pki-types", 1149 | "rustls-webpki", 1150 | "subtle", 1151 | "zeroize", 1152 | ] 1153 | 1154 | [[package]] 1155 | name = "rustls-pki-types" 1156 | version = "1.4.0" 1157 | source = "registry+https://github.com/rust-lang/crates.io-index" 1158 | checksum = "868e20fada228fefaf6b652e00cc73623d54f8171e7352c18bb281571f2d92da" 1159 | 1160 | [[package]] 1161 | name = "rustls-webpki" 1162 | version = "0.102.2" 1163 | source = "registry+https://github.com/rust-lang/crates.io-index" 1164 | checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" 1165 | dependencies = [ 1166 | "ring", 1167 | "rustls-pki-types", 1168 | "untrusted", 1169 | ] 1170 | 1171 | [[package]] 1172 | name = "ryu" 1173 | version = "1.0.17" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" 1176 | 1177 | [[package]] 1178 | name = "scopeguard" 1179 | version = "1.2.0" 1180 | source = "registry+https://github.com/rust-lang/crates.io-index" 1181 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" 1182 | 1183 | [[package]] 1184 | name = "semver" 1185 | version = "1.0.22" 1186 | source = "registry+https://github.com/rust-lang/crates.io-index" 1187 | checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" 1188 | 1189 | [[package]] 1190 | name = "serde" 1191 | version = "1.0.197" 1192 | source = "registry+https://github.com/rust-lang/crates.io-index" 1193 | checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" 1194 | dependencies = [ 1195 | "serde_derive", 1196 | ] 1197 | 1198 | [[package]] 1199 | name = "serde_derive" 1200 | version = "1.0.197" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" 1203 | dependencies = [ 1204 | "proc-macro2", 1205 | "quote", 1206 | "syn 2.0.55", 1207 | ] 1208 | 1209 | [[package]] 1210 | name = "serde_json" 1211 | version = "1.0.115" 1212 | source = "registry+https://github.com/rust-lang/crates.io-index" 1213 | checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" 1214 | dependencies = [ 1215 | "itoa", 1216 | "ryu", 1217 | "serde", 1218 | ] 1219 | 1220 | [[package]] 1221 | name = "serde_with" 1222 | version = "1.14.0" 1223 | source = "registry+https://github.com/rust-lang/crates.io-index" 1224 | checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" 1225 | dependencies = [ 1226 | "base64 0.13.1", 1227 | "serde", 1228 | "serde_with_macros", 1229 | ] 1230 | 1231 | [[package]] 1232 | name = "serde_with_macros" 1233 | version = "1.5.2" 1234 | source = "registry+https://github.com/rust-lang/crates.io-index" 1235 | checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" 1236 | dependencies = [ 1237 | "darling", 1238 | "proc-macro2", 1239 | "quote", 1240 | "syn 1.0.109", 1241 | ] 1242 | 1243 | [[package]] 1244 | name = "sha2" 1245 | version = "0.10.8" 1246 | source = "registry+https://github.com/rust-lang/crates.io-index" 1247 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" 1248 | dependencies = [ 1249 | "cfg-if", 1250 | "cpufeatures", 1251 | "digest", 1252 | ] 1253 | 1254 | [[package]] 1255 | name = "signal-hook-registry" 1256 | version = "1.4.1" 1257 | source = "registry+https://github.com/rust-lang/crates.io-index" 1258 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" 1259 | dependencies = [ 1260 | "libc", 1261 | ] 1262 | 1263 | [[package]] 1264 | name = "slab" 1265 | version = "0.4.9" 1266 | source = "registry+https://github.com/rust-lang/crates.io-index" 1267 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 1268 | dependencies = [ 1269 | "autocfg", 1270 | ] 1271 | 1272 | [[package]] 1273 | name = "smallvec" 1274 | version = "1.13.2" 1275 | source = "registry+https://github.com/rust-lang/crates.io-index" 1276 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 1277 | 1278 | [[package]] 1279 | name = "socket2" 1280 | version = "0.5.6" 1281 | source = "registry+https://github.com/rust-lang/crates.io-index" 1282 | checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" 1283 | dependencies = [ 1284 | "libc", 1285 | "windows-sys 0.52.0", 1286 | ] 1287 | 1288 | [[package]] 1289 | name = "spin" 1290 | version = "0.9.8" 1291 | source = "registry+https://github.com/rust-lang/crates.io-index" 1292 | checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" 1293 | 1294 | [[package]] 1295 | name = "strsim" 1296 | version = "0.10.0" 1297 | source = "registry+https://github.com/rust-lang/crates.io-index" 1298 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1299 | 1300 | [[package]] 1301 | name = "subtle" 1302 | version = "2.5.0" 1303 | source = "registry+https://github.com/rust-lang/crates.io-index" 1304 | checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" 1305 | 1306 | [[package]] 1307 | name = "syn" 1308 | version = "1.0.109" 1309 | source = "registry+https://github.com/rust-lang/crates.io-index" 1310 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1311 | dependencies = [ 1312 | "proc-macro2", 1313 | "quote", 1314 | "unicode-ident", 1315 | ] 1316 | 1317 | [[package]] 1318 | name = "syn" 1319 | version = "2.0.55" 1320 | source = "registry+https://github.com/rust-lang/crates.io-index" 1321 | checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" 1322 | dependencies = [ 1323 | "proc-macro2", 1324 | "quote", 1325 | "unicode-ident", 1326 | ] 1327 | 1328 | [[package]] 1329 | name = "termcolor" 1330 | version = "1.4.1" 1331 | source = "registry+https://github.com/rust-lang/crates.io-index" 1332 | checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" 1333 | dependencies = [ 1334 | "winapi-util", 1335 | ] 1336 | 1337 | [[package]] 1338 | name = "textwrap" 1339 | version = "0.16.1" 1340 | source = "registry+https://github.com/rust-lang/crates.io-index" 1341 | checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" 1342 | 1343 | [[package]] 1344 | name = "thiserror" 1345 | version = "1.0.58" 1346 | source = "registry+https://github.com/rust-lang/crates.io-index" 1347 | checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" 1348 | dependencies = [ 1349 | "thiserror-impl", 1350 | ] 1351 | 1352 | [[package]] 1353 | name = "thiserror-impl" 1354 | version = "1.0.58" 1355 | source = "registry+https://github.com/rust-lang/crates.io-index" 1356 | checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" 1357 | dependencies = [ 1358 | "proc-macro2", 1359 | "quote", 1360 | "syn 2.0.55", 1361 | ] 1362 | 1363 | [[package]] 1364 | name = "tinyvec" 1365 | version = "1.6.0" 1366 | source = "registry+https://github.com/rust-lang/crates.io-index" 1367 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 1368 | dependencies = [ 1369 | "tinyvec_macros", 1370 | ] 1371 | 1372 | [[package]] 1373 | name = "tinyvec_macros" 1374 | version = "0.1.1" 1375 | source = "registry+https://github.com/rust-lang/crates.io-index" 1376 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 1377 | 1378 | [[package]] 1379 | name = "tl-proto" 1380 | version = "0.4.6" 1381 | source = "registry+https://github.com/rust-lang/crates.io-index" 1382 | checksum = "d4da430e55186abb18b4d1457a23eb0765af0dee66a9f741d652d6eaa476a8d7" 1383 | dependencies = [ 1384 | "bytes", 1385 | "digest", 1386 | "sha2", 1387 | "smallvec", 1388 | "thiserror", 1389 | "tl-proto-proc", 1390 | ] 1391 | 1392 | [[package]] 1393 | name = "tl-proto-proc" 1394 | version = "0.4.6" 1395 | source = "registry+https://github.com/rust-lang/crates.io-index" 1396 | checksum = "5a3eaf6822a3ce34a40564dd3078a915d35c3c5fd1f6b3d81eab991e6d00a0fb" 1397 | dependencies = [ 1398 | "proc-macro2", 1399 | "quote", 1400 | "rustc-hash", 1401 | "syn 2.0.55", 1402 | "tl-scheme", 1403 | ] 1404 | 1405 | [[package]] 1406 | name = "tl-scheme" 1407 | version = "0.2.0" 1408 | source = "registry+https://github.com/rust-lang/crates.io-index" 1409 | checksum = "9fbfb36e00e1c6be44d5ed8b2be322667f8ad4955387375c0cf617c542e01a56" 1410 | dependencies = [ 1411 | "crc", 1412 | "pest", 1413 | "pest_derive", 1414 | "rustc-hash", 1415 | "thiserror", 1416 | ] 1417 | 1418 | [[package]] 1419 | name = "tokio" 1420 | version = "1.36.0" 1421 | source = "registry+https://github.com/rust-lang/crates.io-index" 1422 | checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" 1423 | dependencies = [ 1424 | "backtrace", 1425 | "bytes", 1426 | "libc", 1427 | "mio", 1428 | "num_cpus", 1429 | "parking_lot", 1430 | "pin-project-lite", 1431 | "signal-hook-registry", 1432 | "socket2", 1433 | "tokio-macros", 1434 | "windows-sys 0.48.0", 1435 | ] 1436 | 1437 | [[package]] 1438 | name = "tokio-macros" 1439 | version = "2.2.0" 1440 | source = "registry+https://github.com/rust-lang/crates.io-index" 1441 | checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" 1442 | dependencies = [ 1443 | "proc-macro2", 1444 | "quote", 1445 | "syn 2.0.55", 1446 | ] 1447 | 1448 | [[package]] 1449 | name = "tokio-tower" 1450 | version = "0.6.0" 1451 | source = "registry+https://github.com/rust-lang/crates.io-index" 1452 | checksum = "f4322b6e2ebfd3be4082c16df4341505ef333683158b55f22afaf3f61565d728" 1453 | dependencies = [ 1454 | "crossbeam", 1455 | "futures-core", 1456 | "futures-sink", 1457 | "futures-util", 1458 | "pin-project", 1459 | "tokio", 1460 | "tower", 1461 | "tower-service", 1462 | "tracing", 1463 | ] 1464 | 1465 | [[package]] 1466 | name = "tokio-util" 1467 | version = "0.7.10" 1468 | source = "registry+https://github.com/rust-lang/crates.io-index" 1469 | checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" 1470 | dependencies = [ 1471 | "bytes", 1472 | "futures-core", 1473 | "futures-sink", 1474 | "pin-project-lite", 1475 | "tokio", 1476 | "tracing", 1477 | ] 1478 | 1479 | [[package]] 1480 | name = "ton_lc" 1481 | version = "0.1.0" 1482 | dependencies = [ 1483 | "base64 0.13.1", 1484 | "chrono", 1485 | "clap", 1486 | "env_logger 0.9.3", 1487 | "hex", 1488 | "log", 1489 | "pretty-hex", 1490 | "rand", 1491 | "regex", 1492 | "tokio", 1493 | "ton_liteapi 0.1.0", 1494 | "ton_networkconfig 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1495 | "ureq", 1496 | ] 1497 | 1498 | [[package]] 1499 | name = "ton_liteapi" 1500 | version = "0.1.0" 1501 | source = "registry+https://github.com/rust-lang/crates.io-index" 1502 | checksum = "e2ccb9ece58a1ede8fc27ed076c8c1c8063f88e9ec7e825e488c436b49ab46ca" 1503 | dependencies = [ 1504 | "adnl", 1505 | "derivative", 1506 | "futures", 1507 | "hex", 1508 | "log", 1509 | "pin-project", 1510 | "rand", 1511 | "thiserror", 1512 | "tl-proto", 1513 | "tokio", 1514 | "tokio-tower", 1515 | "tokio-util", 1516 | "tower", 1517 | ] 1518 | 1519 | [[package]] 1520 | name = "ton_liteapi" 1521 | version = "0.2.0" 1522 | dependencies = [ 1523 | "adnl", 1524 | "base64 0.13.1", 1525 | "derivative", 1526 | "env_logger 0.11.3", 1527 | "futures", 1528 | "hex", 1529 | "log", 1530 | "pin-project", 1531 | "rand", 1532 | "thiserror", 1533 | "tl-proto", 1534 | "tokio", 1535 | "tokio-tower", 1536 | "tokio-util", 1537 | "tower", 1538 | "ureq", 1539 | "x25519-dalek", 1540 | ] 1541 | 1542 | [[package]] 1543 | name = "ton_networkconfig" 1544 | version = "0.1.0" 1545 | dependencies = [ 1546 | "serde", 1547 | "serde_json", 1548 | "serde_with", 1549 | ] 1550 | 1551 | [[package]] 1552 | name = "ton_networkconfig" 1553 | version = "0.1.0" 1554 | source = "registry+https://github.com/rust-lang/crates.io-index" 1555 | checksum = "9ab402c6f30bbe26914481ad184d5d9e8e54deaf4a4f6e52946f3547c998342f" 1556 | dependencies = [ 1557 | "serde", 1558 | "serde_json", 1559 | "serde_with", 1560 | ] 1561 | 1562 | [[package]] 1563 | name = "tower" 1564 | version = "0.4.13" 1565 | source = "registry+https://github.com/rust-lang/crates.io-index" 1566 | checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" 1567 | dependencies = [ 1568 | "futures-core", 1569 | "futures-util", 1570 | "pin-project", 1571 | "pin-project-lite", 1572 | "tokio", 1573 | "tokio-util", 1574 | "tower-layer", 1575 | "tower-service", 1576 | "tracing", 1577 | ] 1578 | 1579 | [[package]] 1580 | name = "tower-layer" 1581 | version = "0.3.2" 1582 | source = "registry+https://github.com/rust-lang/crates.io-index" 1583 | checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" 1584 | 1585 | [[package]] 1586 | name = "tower-service" 1587 | version = "0.3.2" 1588 | source = "registry+https://github.com/rust-lang/crates.io-index" 1589 | checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" 1590 | 1591 | [[package]] 1592 | name = "tracing" 1593 | version = "0.1.40" 1594 | source = "registry+https://github.com/rust-lang/crates.io-index" 1595 | checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" 1596 | dependencies = [ 1597 | "log", 1598 | "pin-project-lite", 1599 | "tracing-attributes", 1600 | "tracing-core", 1601 | ] 1602 | 1603 | [[package]] 1604 | name = "tracing-attributes" 1605 | version = "0.1.27" 1606 | source = "registry+https://github.com/rust-lang/crates.io-index" 1607 | checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" 1608 | dependencies = [ 1609 | "proc-macro2", 1610 | "quote", 1611 | "syn 2.0.55", 1612 | ] 1613 | 1614 | [[package]] 1615 | name = "tracing-core" 1616 | version = "0.1.32" 1617 | source = "registry+https://github.com/rust-lang/crates.io-index" 1618 | checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" 1619 | dependencies = [ 1620 | "once_cell", 1621 | ] 1622 | 1623 | [[package]] 1624 | name = "typenum" 1625 | version = "1.17.0" 1626 | source = "registry+https://github.com/rust-lang/crates.io-index" 1627 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" 1628 | 1629 | [[package]] 1630 | name = "ucd-trie" 1631 | version = "0.1.6" 1632 | source = "registry+https://github.com/rust-lang/crates.io-index" 1633 | checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" 1634 | 1635 | [[package]] 1636 | name = "unicode-bidi" 1637 | version = "0.3.15" 1638 | source = "registry+https://github.com/rust-lang/crates.io-index" 1639 | checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" 1640 | 1641 | [[package]] 1642 | name = "unicode-ident" 1643 | version = "1.0.12" 1644 | source = "registry+https://github.com/rust-lang/crates.io-index" 1645 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 1646 | 1647 | [[package]] 1648 | name = "unicode-normalization" 1649 | version = "0.1.23" 1650 | source = "registry+https://github.com/rust-lang/crates.io-index" 1651 | checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" 1652 | dependencies = [ 1653 | "tinyvec", 1654 | ] 1655 | 1656 | [[package]] 1657 | name = "untrusted" 1658 | version = "0.9.0" 1659 | source = "registry+https://github.com/rust-lang/crates.io-index" 1660 | checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" 1661 | 1662 | [[package]] 1663 | name = "ureq" 1664 | version = "2.9.6" 1665 | source = "registry+https://github.com/rust-lang/crates.io-index" 1666 | checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" 1667 | dependencies = [ 1668 | "base64 0.21.7", 1669 | "flate2", 1670 | "log", 1671 | "once_cell", 1672 | "rustls", 1673 | "rustls-pki-types", 1674 | "rustls-webpki", 1675 | "url", 1676 | "webpki-roots", 1677 | ] 1678 | 1679 | [[package]] 1680 | name = "url" 1681 | version = "2.5.0" 1682 | source = "registry+https://github.com/rust-lang/crates.io-index" 1683 | checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" 1684 | dependencies = [ 1685 | "form_urlencoded", 1686 | "idna", 1687 | "percent-encoding", 1688 | ] 1689 | 1690 | [[package]] 1691 | name = "utf8parse" 1692 | version = "0.2.1" 1693 | source = "registry+https://github.com/rust-lang/crates.io-index" 1694 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 1695 | 1696 | [[package]] 1697 | name = "version_check" 1698 | version = "0.9.4" 1699 | source = "registry+https://github.com/rust-lang/crates.io-index" 1700 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1701 | 1702 | [[package]] 1703 | name = "wasi" 1704 | version = "0.11.0+wasi-snapshot-preview1" 1705 | source = "registry+https://github.com/rust-lang/crates.io-index" 1706 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1707 | 1708 | [[package]] 1709 | name = "wasm-bindgen" 1710 | version = "0.2.92" 1711 | source = "registry+https://github.com/rust-lang/crates.io-index" 1712 | checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" 1713 | dependencies = [ 1714 | "cfg-if", 1715 | "wasm-bindgen-macro", 1716 | ] 1717 | 1718 | [[package]] 1719 | name = "wasm-bindgen-backend" 1720 | version = "0.2.92" 1721 | source = "registry+https://github.com/rust-lang/crates.io-index" 1722 | checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" 1723 | dependencies = [ 1724 | "bumpalo", 1725 | "log", 1726 | "once_cell", 1727 | "proc-macro2", 1728 | "quote", 1729 | "syn 2.0.55", 1730 | "wasm-bindgen-shared", 1731 | ] 1732 | 1733 | [[package]] 1734 | name = "wasm-bindgen-macro" 1735 | version = "0.2.92" 1736 | source = "registry+https://github.com/rust-lang/crates.io-index" 1737 | checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" 1738 | dependencies = [ 1739 | "quote", 1740 | "wasm-bindgen-macro-support", 1741 | ] 1742 | 1743 | [[package]] 1744 | name = "wasm-bindgen-macro-support" 1745 | version = "0.2.92" 1746 | source = "registry+https://github.com/rust-lang/crates.io-index" 1747 | checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" 1748 | dependencies = [ 1749 | "proc-macro2", 1750 | "quote", 1751 | "syn 2.0.55", 1752 | "wasm-bindgen-backend", 1753 | "wasm-bindgen-shared", 1754 | ] 1755 | 1756 | [[package]] 1757 | name = "wasm-bindgen-shared" 1758 | version = "0.2.92" 1759 | source = "registry+https://github.com/rust-lang/crates.io-index" 1760 | checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" 1761 | 1762 | [[package]] 1763 | name = "webpki-roots" 1764 | version = "0.26.1" 1765 | source = "registry+https://github.com/rust-lang/crates.io-index" 1766 | checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" 1767 | dependencies = [ 1768 | "rustls-pki-types", 1769 | ] 1770 | 1771 | [[package]] 1772 | name = "winapi" 1773 | version = "0.3.9" 1774 | source = "registry+https://github.com/rust-lang/crates.io-index" 1775 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1776 | dependencies = [ 1777 | "winapi-i686-pc-windows-gnu", 1778 | "winapi-x86_64-pc-windows-gnu", 1779 | ] 1780 | 1781 | [[package]] 1782 | name = "winapi-i686-pc-windows-gnu" 1783 | version = "0.4.0" 1784 | source = "registry+https://github.com/rust-lang/crates.io-index" 1785 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1786 | 1787 | [[package]] 1788 | name = "winapi-util" 1789 | version = "0.1.6" 1790 | source = "registry+https://github.com/rust-lang/crates.io-index" 1791 | checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" 1792 | dependencies = [ 1793 | "winapi", 1794 | ] 1795 | 1796 | [[package]] 1797 | name = "winapi-x86_64-pc-windows-gnu" 1798 | version = "0.4.0" 1799 | source = "registry+https://github.com/rust-lang/crates.io-index" 1800 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1801 | 1802 | [[package]] 1803 | name = "windows-core" 1804 | version = "0.52.0" 1805 | source = "registry+https://github.com/rust-lang/crates.io-index" 1806 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 1807 | dependencies = [ 1808 | "windows-targets 0.52.4", 1809 | ] 1810 | 1811 | [[package]] 1812 | name = "windows-sys" 1813 | version = "0.48.0" 1814 | source = "registry+https://github.com/rust-lang/crates.io-index" 1815 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1816 | dependencies = [ 1817 | "windows-targets 0.48.5", 1818 | ] 1819 | 1820 | [[package]] 1821 | name = "windows-sys" 1822 | version = "0.52.0" 1823 | source = "registry+https://github.com/rust-lang/crates.io-index" 1824 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1825 | dependencies = [ 1826 | "windows-targets 0.52.4", 1827 | ] 1828 | 1829 | [[package]] 1830 | name = "windows-targets" 1831 | version = "0.48.5" 1832 | source = "registry+https://github.com/rust-lang/crates.io-index" 1833 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1834 | dependencies = [ 1835 | "windows_aarch64_gnullvm 0.48.5", 1836 | "windows_aarch64_msvc 0.48.5", 1837 | "windows_i686_gnu 0.48.5", 1838 | "windows_i686_msvc 0.48.5", 1839 | "windows_x86_64_gnu 0.48.5", 1840 | "windows_x86_64_gnullvm 0.48.5", 1841 | "windows_x86_64_msvc 0.48.5", 1842 | ] 1843 | 1844 | [[package]] 1845 | name = "windows-targets" 1846 | version = "0.52.4" 1847 | source = "registry+https://github.com/rust-lang/crates.io-index" 1848 | checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" 1849 | dependencies = [ 1850 | "windows_aarch64_gnullvm 0.52.4", 1851 | "windows_aarch64_msvc 0.52.4", 1852 | "windows_i686_gnu 0.52.4", 1853 | "windows_i686_msvc 0.52.4", 1854 | "windows_x86_64_gnu 0.52.4", 1855 | "windows_x86_64_gnullvm 0.52.4", 1856 | "windows_x86_64_msvc 0.52.4", 1857 | ] 1858 | 1859 | [[package]] 1860 | name = "windows_aarch64_gnullvm" 1861 | version = "0.48.5" 1862 | source = "registry+https://github.com/rust-lang/crates.io-index" 1863 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1864 | 1865 | [[package]] 1866 | name = "windows_aarch64_gnullvm" 1867 | version = "0.52.4" 1868 | source = "registry+https://github.com/rust-lang/crates.io-index" 1869 | checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" 1870 | 1871 | [[package]] 1872 | name = "windows_aarch64_msvc" 1873 | version = "0.48.5" 1874 | source = "registry+https://github.com/rust-lang/crates.io-index" 1875 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1876 | 1877 | [[package]] 1878 | name = "windows_aarch64_msvc" 1879 | version = "0.52.4" 1880 | source = "registry+https://github.com/rust-lang/crates.io-index" 1881 | checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" 1882 | 1883 | [[package]] 1884 | name = "windows_i686_gnu" 1885 | version = "0.48.5" 1886 | source = "registry+https://github.com/rust-lang/crates.io-index" 1887 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1888 | 1889 | [[package]] 1890 | name = "windows_i686_gnu" 1891 | version = "0.52.4" 1892 | source = "registry+https://github.com/rust-lang/crates.io-index" 1893 | checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" 1894 | 1895 | [[package]] 1896 | name = "windows_i686_msvc" 1897 | version = "0.48.5" 1898 | source = "registry+https://github.com/rust-lang/crates.io-index" 1899 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1900 | 1901 | [[package]] 1902 | name = "windows_i686_msvc" 1903 | version = "0.52.4" 1904 | source = "registry+https://github.com/rust-lang/crates.io-index" 1905 | checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" 1906 | 1907 | [[package]] 1908 | name = "windows_x86_64_gnu" 1909 | version = "0.48.5" 1910 | source = "registry+https://github.com/rust-lang/crates.io-index" 1911 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1912 | 1913 | [[package]] 1914 | name = "windows_x86_64_gnu" 1915 | version = "0.52.4" 1916 | source = "registry+https://github.com/rust-lang/crates.io-index" 1917 | checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" 1918 | 1919 | [[package]] 1920 | name = "windows_x86_64_gnullvm" 1921 | version = "0.48.5" 1922 | source = "registry+https://github.com/rust-lang/crates.io-index" 1923 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1924 | 1925 | [[package]] 1926 | name = "windows_x86_64_gnullvm" 1927 | version = "0.52.4" 1928 | source = "registry+https://github.com/rust-lang/crates.io-index" 1929 | checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" 1930 | 1931 | [[package]] 1932 | name = "windows_x86_64_msvc" 1933 | version = "0.48.5" 1934 | source = "registry+https://github.com/rust-lang/crates.io-index" 1935 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1936 | 1937 | [[package]] 1938 | name = "windows_x86_64_msvc" 1939 | version = "0.52.4" 1940 | source = "registry+https://github.com/rust-lang/crates.io-index" 1941 | checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" 1942 | 1943 | [[package]] 1944 | name = "x25519-dalek" 1945 | version = "2.0.1" 1946 | source = "registry+https://github.com/rust-lang/crates.io-index" 1947 | checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" 1948 | dependencies = [ 1949 | "curve25519-dalek", 1950 | "rand_core", 1951 | "serde", 1952 | "zeroize", 1953 | ] 1954 | 1955 | [[package]] 1956 | name = "zeroize" 1957 | version = "1.7.0" 1958 | source = "registry+https://github.com/rust-lang/crates.io-index" 1959 | checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" 1960 | dependencies = [ 1961 | "zeroize_derive", 1962 | ] 1963 | 1964 | [[package]] 1965 | name = "zeroize_derive" 1966 | version = "1.4.2" 1967 | source = "registry+https://github.com/rust-lang/crates.io-index" 1968 | checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" 1969 | dependencies = [ 1970 | "proc-macro2", 1971 | "quote", 1972 | "syn 2.0.55", 1973 | ] 1974 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | members = [ 4 | "cli", 5 | "liteapi", 6 | "network-config", 7 | ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Vladimir Lebedev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TON lite_api 2 | 3 | Implementation of low-level [lite_api](https://github.com/ton-blockchain/ton/blob/master/tl/generate/scheme/lite_api.tl) and [lite-client](https://github.com/ton-blockchain/ton/tree/master/lite-client) in Rust using [adnl-rs](https://github.com/tonstack/adnl-rs). 4 | 5 | | Feature | Status | 6 | | --------------- | -------------- | 7 | | lite_api client | ✅ Implemented | 8 | | lite_api server | ✅ Implemented | 9 | | lite-client cli | ✅ Implemented | 10 | | async | ✅ Implemented | 11 | 12 | ## Installation 13 | 14 | ```bash 15 | cargo install ton_lc 16 | ``` 17 | 18 | ## Usage 19 | 20 | Without any options, [mainnet config](https://ton.org/global.config.json) will be used. 21 | For testnet, use `-t / --testnet` flag. 22 | To use your own config, pass `-c / --config ` option. 23 | Also you can use `--address` and `--public-key` to connect to specific liteserver. 24 | 25 | Send an external message to TON: 26 | 27 | ```bash 28 | echo 1234 | ton_lc send-message - # accept message bytes from stdin 29 | ton_lc send-message ./query.boc # read from file 30 | ``` 31 | 32 | It prints: 33 | 34 | ``` 35 | [ERROR] Server error [code=0]: cannot apply external message to current state : failed to parse external message cannot deserialize bag-of-cells: invalid header, error 0 36 | ``` 37 | 38 | ``` 39 | OPTIONS: 40 | --address
Liteserver address (IP:PORT) 41 | -c, --config Local network config from file 42 | -h, --help Print help information 43 | --public-key Liteserver public key (hex-encoded) 44 | -t, --testnet Use testnet config, if not provided use mainnet config 45 | -V, --version Print version information 46 | 47 | SUBCOMMANDS: 48 | get-account-state Download account state at specified block 49 | get-all-shards-info 50 | get-block Downloads and dumps specified block 51 | get-block-header Download block header with specified merkle proofs 52 | get-block-proof Download masterchain proof 53 | get-config-all Download all config params 54 | get-config-params Download specified config params 55 | get-libraries Download specified libraries 56 | get-masterchain-info Get masterchain info 57 | get-masterchain-info-ext Get masterchain info with additional data 58 | get-one-transaction 59 | get-shard-info 60 | get-state Download state for masterchain block seqnos < 1000 61 | get-time Get server time 62 | get-transactions Iterate through transactions for an account 63 | get-validator-stats 64 | get-version Shows server time, version and capabilities 65 | help Print this message or the help of the given subcommand(s) 66 | list-block-transactions List transactions for a specified block 67 | lookup-block Find block by seqno, lt or utime, block header will be 68 | downloaded with specified merkle proofs 69 | run-smc-method Run get-method for smart contract 70 | send-message Send external message 71 | ``` 72 | 73 | ## Debug logging 74 | 75 | ```bash 76 | echo 1234 | RUST_LOG=debug ton_lc send-message - 77 | ``` 78 | 79 | prints: 80 | 81 | ``` 82 | [2022-03-15T10:43:55Z DEBUG liteclient::private] Sending query: 83 | Length: 20 (0x14) bytes 84 | 0000: df 06 8c 79 0c 82 d4 0a 69 05 31 32 33 34 0a 00 ...y....i.1234.. 85 | 0010: 00 00 00 00 .... 86 | [2022-03-15T10:43:55Z DEBUG liteclient::private] Received: 87 | Length: 148 (0x94) bytes 88 | 0000: 48 e1 a9 bb 00 00 00 00 8a 63 61 6e 6e 6f 74 20 H........cannot 89 | 0010: 61 70 70 6c 79 20 65 78 74 65 72 6e 61 6c 20 6d apply external m 90 | 0020: 65 73 73 61 67 65 20 74 6f 20 63 75 72 72 65 6e essage to curren 91 | 0030: 74 20 73 74 61 74 65 20 3a 20 66 61 69 6c 65 64 t state : failed 92 | 0040: 20 74 6f 20 70 61 72 73 65 20 65 78 74 65 72 6e to parse extern 93 | 0050: 61 6c 20 6d 65 73 73 61 67 65 20 63 61 6e 6e 6f al message canno 94 | 0060: 74 20 64 65 73 65 72 69 61 6c 69 7a 65 20 62 61 t deserialize ba 95 | 0070: 67 2d 6f 66 2d 63 65 6c 6c 73 3a 20 69 6e 76 61 g-of-cells: inva 96 | 0080: 6c 69 64 20 68 65 61 64 65 72 2c 20 65 72 72 6f lid header, erro 97 | 0090: 72 20 30 00 r 0. 98 | [ERROR] Server error [code=0]: cannot apply external message to current state : failed to parse external message cannot deserialize bag-of-cells: invalid header, error 0 99 | ``` 100 | -------------------------------------------------------------------------------- /cli/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ton_lc" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Low-level implementation of TON lite client" 6 | repository = "https://github.com/tonstack/lite-client" 7 | keywords = ["ton"] 8 | categories = ["network-programming"] 9 | license = "MIT" 10 | authors = ["Vladimir Lebedev "] 11 | 12 | [dependencies] 13 | base64 = "0.13.0" 14 | pretty-hex = '0.2.1' 15 | env_logger = '0.9.0' 16 | log = '0.4.14' 17 | clap = { version = "3.2.25", features = ["derive"] } 18 | chrono = "0.4.19" 19 | hex = "0.4.3" 20 | ureq = "2.4.0" 21 | regex = "1" 22 | ton_liteapi = "0.1.0" 23 | ton_networkconfig = "0.1.0" 24 | rand = "0.8.5" 25 | tokio = { version = "1.36", features = ["full"] } -------------------------------------------------------------------------------- /cli/src/arg_parsers.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | use regex::Regex; 4 | use ton_liteapi::tl::common::{Int256, BlockIdExt, AccountId}; 5 | 6 | pub fn parse_block_id_ext(s: &str) -> std::result::Result { 7 | let re = Regex::new(r"\(([-]?\d+),([a-fA-F0-9]+),(\d+)\):([^:]+):(.+)").unwrap(); 8 | 9 | if let Some(capture) = re.captures(s) { 10 | let workchain = capture[1] 11 | .parse::() 12 | .map_err(|e| format!("Can't parse workchain '{}': {:?}", &capture[1], e))?; 13 | let shard = u64::from_str_radix(&capture[2], 16) 14 | .map_err(|e| format!("Can't parse shard '{}': {:?}", &capture[2], e))?; 15 | let seqno = capture[3] 16 | .parse::() 17 | .map_err(|e| format!("Can't parse seqno '{}': {:?}", &capture[3], e))?; 18 | let root_hash = capture[4].parse::() 19 | .map_err(|e| format!("Can't parse root_hash '{}': {:?}", &capture[4], e))?; 20 | let file_hash = capture[5].parse::() 21 | .map_err(|e| format!("Can't parse file_hash '{}': {:?}", &capture[5], e))?; 22 | Ok(BlockIdExt { 23 | workchain, 24 | shard, 25 | seqno, 26 | root_hash, 27 | file_hash, 28 | }) 29 | } else { 30 | Err("Wrong format, must be (workchain,shard_hex,seqno):root_hash:file_hash".into()) 31 | } 32 | } 33 | 34 | fn parse_account_base64(s: &str) -> std::result::Result> { 35 | let res = base64::decode_config(s, base64::URL_SAFE)?; 36 | if res.len() != 36 { 37 | return Err(format!("Wrong length for base64 address, expected 36, got {}", res.len()).into()) 38 | } 39 | let workchain = res[1] as i8; 40 | let id = Int256((&res[2..34]).try_into()?); 41 | Ok(AccountId { 42 | workchain: workchain.into(), 43 | id, 44 | }) 45 | } 46 | 47 | fn parse_account_raw(s: &str) -> std::result::Result> { 48 | let (workchain, account) = s.split_once(":").ok_or_else(|| format!("can't parse {}: wrong address format, must be :", s))?; 49 | let workchain = workchain.parse::().map_err(|_e| format!("wrong workchain {}", workchain))?; 50 | let id = account.parse::().map_err(|_e| format!("wrong account id {}", account))?; 51 | Ok(AccountId { workchain, id }) 52 | } 53 | 54 | pub fn parse_account_id(s: &str) -> std::result::Result { 55 | parse_account_base64(s).or_else(|e| parse_account_raw(s).map_err(|e2| format!("Can't parse account as base64 ({}) or as raw ({}))", e, e2))) 56 | } 57 | 58 | pub fn parse_key(s: &str) -> std::result::Result<[u8; 32], Box> { 59 | Ok(base64::decode(s).or_else(|_e| hex::decode(s)).map_err(|_e| "can't parse key")?.as_slice().try_into()?) 60 | } -------------------------------------------------------------------------------- /cli/src/main.rs: -------------------------------------------------------------------------------- 1 | mod arg_parsers; 2 | 3 | use chrono::{DateTime, Utc}; 4 | use clap::{Parser, Subcommand}; 5 | use rand::seq::SliceRandom as _; 6 | use ton_liteapi::tl::common::{AccountId, BlockId, BlockIdExt, Int256, TransactionId3}; 7 | use ton_liteapi::client::LiteClient; 8 | use pretty_hex::PrettyHex; 9 | use ton_networkconfig::ConfigGlobal; 10 | use std::error::Error; 11 | use std::fs::{read_to_string, File}; 12 | use std::io::{stdin, Read}; 13 | use std::net::SocketAddr; 14 | use std::path::PathBuf; 15 | use std::str::FromStr; 16 | use std::time::{Duration, UNIX_EPOCH}; 17 | 18 | use crate::arg_parsers::{parse_account_id, parse_block_id_ext, parse_key}; 19 | 20 | type Result = std::result::Result>; 21 | 22 | #[derive(Parser, Debug)] 23 | #[clap(author, version, about, long_about = None)] 24 | struct Args { 25 | /// Local network config from file 26 | #[clap(short, long, parse(from_os_str), value_name = "FILE", group = "config-group")] 27 | config: Option, 28 | /// Use testnet config, if not provided use mainnet config 29 | #[clap(short, long, parse(from_flag), group = "config-group")] 30 | testnet: bool, 31 | /// Liteserver address (IP:PORT) 32 | #[clap(long, group = "config-group")] 33 | address: Option, 34 | /// Liteserver public key (hex-encoded) 35 | #[clap(long, value_parser = parse_key, requires = "address")] 36 | public_key: Option<[u8; 32]>, 37 | #[clap(subcommand)] 38 | command: Commands, 39 | } 40 | 41 | #[derive(Subcommand, Debug)] 42 | enum Commands { 43 | /// Get masterchain info 44 | GetMasterchainInfo, 45 | /// Get masterchain info with additional data 46 | GetMasterchainInfoExt { 47 | mode: u32, 48 | }, 49 | /// Get server time 50 | GetTime, 51 | /// Shows server time, version and capabilities 52 | GetVersion, 53 | /// Downloads and dumps specified block 54 | #[clap(arg_required_else_help = true)] 55 | GetBlock { 56 | #[clap(value_parser = parse_block_id_ext)] 57 | block_id_ext: BlockIdExt, 58 | }, 59 | /// Download state for masterchain block seqnos < 1000 60 | GetState { 61 | #[clap(value_parser = parse_block_id_ext)] 62 | block_id_ext: BlockIdExt, 63 | }, 64 | /// Download block header with specified merkle proofs 65 | GetBlockHeader { 66 | #[clap(value_parser = parse_block_id_ext)] 67 | block_id_ext: BlockIdExt, 68 | #[clap(long)] 69 | with_state_update: bool, 70 | #[clap(long)] 71 | with_value_flow: bool, 72 | #[clap(long)] 73 | with_extra: bool, 74 | #[clap(long)] 75 | with_shard_hashes: bool, 76 | #[clap(long)] 77 | with_prev_blk_signatures: bool, 78 | }, 79 | /// Send external message 80 | #[clap(arg_required_else_help = true, parse(from_os_str))] 81 | SendMessage { 82 | /// File to send or "-" for reading from stdin 83 | file: PathBuf, 84 | }, 85 | /// Download account state at specified block 86 | GetAccountState { 87 | #[clap(value_parser = parse_block_id_ext)] 88 | block_id_ext: BlockIdExt, 89 | #[clap(value_parser = parse_account_id)] 90 | account_id: AccountId, 91 | }, 92 | /// Run get-method for smart contract 93 | RunSmcMethod { 94 | #[clap(value_parser = parse_block_id_ext)] 95 | block_id_ext: BlockIdExt, 96 | #[clap(value_parser = parse_account_id)] 97 | account_id: AccountId, 98 | method_id: u64, 99 | params: Vec, 100 | }, 101 | GetShardInfo { 102 | #[clap(value_parser = parse_block_id_ext)] 103 | block_id_ext: BlockIdExt, 104 | workchain: i32, 105 | shard: u64, 106 | exact: bool, 107 | }, 108 | GetAllShardsInfo { 109 | #[clap(value_parser = parse_block_id_ext)] 110 | block_id_ext: BlockIdExt, 111 | }, 112 | GetOneTransaction { 113 | #[clap(value_parser = parse_block_id_ext)] 114 | block_id_ext: BlockIdExt, 115 | #[clap(value_parser = parse_account_id)] 116 | account_id: AccountId, 117 | lt: u64, 118 | }, 119 | /// Iterate through transactions for an account 120 | GetTransactions { 121 | count: u32, 122 | #[clap(value_parser = parse_account_id)] 123 | account_id: AccountId, 124 | lt: u64, 125 | hash: Int256, 126 | }, 127 | /// Find block by seqno, lt or utime, block header will be downloaded with specified merkle proofs 128 | LookupBlock { 129 | workchain: i32, 130 | shard: u64, 131 | #[clap(short, long, group = "lookup-variant")] 132 | seqno: Option, 133 | #[clap(short, long, group = "lookup-variant")] 134 | lt: Option, 135 | #[clap(short, long, group = "lookup-variant")] 136 | utime: Option, 137 | #[clap(long)] 138 | with_state_update: bool, 139 | #[clap(long)] 140 | with_value_flow: bool, 141 | #[clap(long)] 142 | with_extra: bool, 143 | #[clap(long)] 144 | with_shard_hashes: bool, 145 | #[clap(long)] 146 | with_prev_blk_signatures: bool, 147 | }, 148 | /// List transactions for a specified block 149 | ListBlockTransactions { 150 | #[clap(value_parser = parse_block_id_ext)] 151 | block_id_ext: BlockIdExt, 152 | count: u32, 153 | #[clap(short, long)] 154 | reverse_order: bool, 155 | #[clap(short, long)] 156 | want_proof: bool, 157 | #[clap(requires = "after-lt", value_parser = parse_account_id, long)] 158 | after_account: Option, 159 | #[clap(requires = "after-account", long)] 160 | after_lt: Option, 161 | }, 162 | /// Download masterchain proof 163 | GetBlockProof { 164 | #[clap(value_parser = parse_block_id_ext)] 165 | known_block: BlockIdExt, 166 | #[clap(value_parser = parse_block_id_ext)] 167 | target_block: Option, 168 | #[clap(long)] 169 | allow_weak_target: bool, 170 | #[clap(long)] 171 | base_block_from_request: bool, 172 | }, 173 | /// Download all config params 174 | GetConfigAll { 175 | #[clap(value_parser = parse_block_id_ext)] 176 | block_id_ext: BlockIdExt, 177 | #[clap(long)] 178 | with_state_root: bool, 179 | #[clap(long)] 180 | with_libraries: bool, 181 | #[clap(long)] 182 | with_state_extra_root: bool, 183 | #[clap(long)] 184 | with_shard_hashes: bool, 185 | #[clap(long)] 186 | with_validator_set: bool, 187 | #[clap(long)] 188 | with_special_smc: bool, 189 | #[clap(long)] 190 | with_accounts_root: bool, 191 | #[clap(long)] 192 | with_prev_blocks: bool, 193 | #[clap(long)] 194 | with_workchain_info: bool, 195 | #[clap(long)] 196 | with_capabilities: bool, 197 | #[clap(long)] 198 | extract_from_key_block: bool, 199 | }, 200 | /// Download specified config params 201 | GetConfigParams { 202 | #[clap(value_parser = parse_block_id_ext)] 203 | block_id_ext: BlockIdExt, 204 | param_list: Vec, 205 | #[clap(long)] 206 | with_state_root: bool, 207 | #[clap(long)] 208 | with_libraries: bool, 209 | #[clap(long)] 210 | with_state_extra_root: bool, 211 | #[clap(long)] 212 | with_shard_hashes: bool, 213 | #[clap(long)] 214 | with_validator_set: bool, 215 | #[clap(long)] 216 | with_special_smc: bool, 217 | #[clap(long)] 218 | with_accounts_root: bool, 219 | #[clap(long)] 220 | with_prev_blocks: bool, 221 | #[clap(long)] 222 | with_workchain_info: bool, 223 | #[clap(long)] 224 | with_capabilities: bool, 225 | #[clap(long)] 226 | extract_from_key_block: bool, 227 | }, 228 | GetValidatorStats { 229 | #[clap(value_parser = parse_block_id_ext)] 230 | block_id_ext: BlockIdExt, 231 | limit: u32, 232 | start_after: Option, 233 | modified_after: Option, 234 | }, 235 | /// Download specified libraries 236 | GetLibraries { 237 | library_list: Vec, 238 | }, 239 | } 240 | 241 | #[tokio::main] 242 | async fn main() -> Result<()> { 243 | env_logger::init(); 244 | let args = Args::parse(); 245 | 246 | let client = if let (Some(address), Some(public_key)) = (&args.address, &args.public_key) { 247 | LiteClient::connect(address, public_key).await? 248 | } else { 249 | let config_json = if let Some(config) = args.config { 250 | read_to_string(config)? 251 | } else { 252 | download_config(args.testnet).await? 253 | }; 254 | let config: ConfigGlobal = ConfigGlobal::from_str(&config_json)?; 255 | let ls = config.liteservers.choose(&mut rand::thread_rng()).unwrap(); 256 | let public_key: [u8; 32] = ls.id.clone().into(); 257 | LiteClient::connect(ls.socket_addr(), public_key).await? 258 | }; 259 | 260 | let mut client = client; 261 | 262 | if let Err(e) = execute_command(&mut client, &args.command).await { 263 | println!("[ERROR] {:?}", e); 264 | } 265 | Ok(()) 266 | } 267 | 268 | async fn execute_command(client: &mut LiteClient, command: &Commands) -> Result<()> { 269 | match command { 270 | Commands::GetMasterchainInfo => { 271 | let result = client.get_masterchain_info().await?; 272 | println!("{:#?}\n", result); 273 | println!("Last masterchain BlockIdExt: {}", result.last); 274 | } 275 | Commands::GetMasterchainInfoExt { mode } => { 276 | let result = client.get_masterchain_info_ext(*mode).await?; 277 | println!("{:#?}\n", result); 278 | println!("Last masterchain BlockIdExt: {}", result.last); 279 | } 280 | Commands::GetTime => { 281 | let result = client.get_time().await?; 282 | let time = DateTime::::from(UNIX_EPOCH + Duration::from_secs(result as u64)); 283 | println!("Current time: {} => {:?}", result, time); 284 | } 285 | Commands::GetVersion => { 286 | let result = client.get_version().await?; 287 | println!("Current version: {:?}", result); 288 | } 289 | Commands::GetBlock { block_id_ext } => { 290 | let result = client.get_block(block_id_ext.clone()).await?; 291 | println!("BlockData: {:?}", result.hex_dump()); 292 | } 293 | Commands::GetState { block_id_ext } => { 294 | let result = client.get_state(block_id_ext.clone()).await?; 295 | println!("{:#?}", result); 296 | } 297 | Commands::GetBlockHeader { block_id_ext, with_state_update, with_value_flow, with_extra, with_shard_hashes, with_prev_blk_signatures } => { 298 | let result = client.get_block_header( 299 | block_id_ext.clone(), 300 | *with_state_update, 301 | *with_value_flow, 302 | *with_extra, 303 | *with_shard_hashes, 304 | *with_prev_blk_signatures, 305 | ).await?; 306 | println!("Block Header: {:?}", result.hex_dump()); 307 | } 308 | Commands::SendMessage { file } => { 309 | let mut data = Vec::::new(); 310 | if file.to_str().map(|f| f == "-").unwrap_or(false) { 311 | stdin().read_to_end(&mut data)?; 312 | } else { 313 | File::open(file)?.read_to_end(&mut data)?; 314 | } 315 | let result = client.send_message(data).await?; 316 | println!("result = {:?}", result); 317 | } 318 | Commands::GetAccountState { block_id_ext, account_id } => { 319 | let result = client.get_account_state(block_id_ext.clone(), account_id.clone()).await?; 320 | println!("{:#?}", result); 321 | } 322 | Commands::RunSmcMethod { block_id_ext, account_id, method_id, params } => { 323 | let result = client.run_smc_method(0, block_id_ext.clone(), account_id.clone(), *method_id, params.clone()).await?; 324 | println!("{:#?}", result); 325 | } 326 | Commands::GetShardInfo { block_id_ext, workchain, shard, exact } => { 327 | let result = client.get_shard_info(block_id_ext.clone(), *workchain, *shard, *exact).await?; 328 | println!("{:#?}", result); 329 | } 330 | Commands::GetAllShardsInfo { block_id_ext } => { 331 | let result = client.get_all_shards_info(block_id_ext.clone()).await?; 332 | println!("{:#?}", result); 333 | } 334 | Commands::GetOneTransaction { block_id_ext, account_id, lt } => { 335 | let result = client.get_one_transaction(block_id_ext.clone(), account_id.clone(), *lt).await?; 336 | println!("{:#?}", result); 337 | } 338 | Commands::GetTransactions { count, account_id, lt, hash } => { 339 | let result = client.get_transactions(*count, account_id.clone(), *lt, hash.clone()).await?; 340 | println!("{:#?}", result); 341 | } 342 | Commands::LookupBlock { workchain, shard, seqno, lt, utime, with_state_update, with_value_flow, with_extra, with_shard_hashes, with_prev_blk_signatures } => { 343 | let result = client.lookup_block( 344 | (), 345 | BlockId { workchain: *workchain, shard: *shard, seqno: seqno.unwrap_or(0) }, 346 | seqno.map(|_| ()), 347 | *lt, 348 | *utime, 349 | *with_state_update, 350 | *with_value_flow, 351 | *with_extra, 352 | *with_shard_hashes, 353 | *with_prev_blk_signatures, 354 | ).await?; 355 | println!("{:#?}", result); 356 | } 357 | Commands::ListBlockTransactions { block_id_ext, count, reverse_order, want_proof, after_account, after_lt } => { 358 | let after = after_account.as_ref().and_then(|account| after_lt.map(|lt| TransactionId3 { 359 | account: account.id.clone(), 360 | lt, 361 | })); 362 | let result = client.list_block_transactions( 363 | block_id_ext.clone(), 364 | *count, 365 | after, 366 | *reverse_order, 367 | *want_proof, 368 | ).await?; 369 | println!("{:#?}", result); 370 | } 371 | Commands::GetBlockProof { known_block, target_block, allow_weak_target, base_block_from_request } => { 372 | let result = client.get_block_proof( 373 | known_block.clone(), 374 | target_block.clone(), 375 | *allow_weak_target, 376 | *base_block_from_request, 377 | ).await?; 378 | println!("{:#?}", result); 379 | } 380 | Commands::GetConfigAll { block_id_ext, with_state_root, with_libraries, with_state_extra_root, with_shard_hashes, with_validator_set, with_special_smc, with_accounts_root, with_prev_blocks, with_workchain_info, with_capabilities, extract_from_key_block } => { 381 | let result = client.get_config_all( 382 | block_id_ext.clone(), 383 | *with_state_root, 384 | *with_libraries, 385 | *with_state_extra_root, 386 | *with_shard_hashes, 387 | *with_validator_set, 388 | *with_special_smc, 389 | *with_accounts_root, 390 | *with_prev_blocks, 391 | *with_workchain_info, 392 | *with_capabilities, 393 | *extract_from_key_block, 394 | ).await?; 395 | println!("{:#?}", result); 396 | } 397 | Commands::GetConfigParams { block_id_ext, param_list, with_state_root, with_libraries, with_state_extra_root, with_shard_hashes, with_validator_set, with_special_smc, with_accounts_root, with_prev_blocks, with_workchain_info, with_capabilities, extract_from_key_block } => { 398 | let result = client.get_config_params( 399 | block_id_ext.clone(), 400 | param_list.clone(), 401 | *with_state_root, 402 | *with_libraries, 403 | *with_state_extra_root, 404 | *with_shard_hashes, 405 | *with_validator_set, 406 | *with_special_smc, 407 | *with_accounts_root, 408 | *with_prev_blocks, 409 | *with_workchain_info, 410 | *with_capabilities, 411 | *extract_from_key_block, 412 | ).await?; 413 | println!("{:#?}", result); 414 | } 415 | Commands::GetValidatorStats { block_id_ext, limit, start_after, modified_after } => { 416 | let result = client.get_validator_stats( 417 | block_id_ext.clone(), 418 | *limit, 419 | start_after.clone(), 420 | *modified_after, 421 | ).await?; 422 | println!("{:#?}", result); 423 | } 424 | Commands::GetLibraries { library_list } => { 425 | let result = client.get_libraries(library_list.clone()).await?; 426 | println!("{:#?}", result); 427 | } 428 | }; 429 | Ok(()) 430 | } 431 | 432 | async fn download_config(testnet: bool) -> Result { 433 | let url = if testnet { 434 | "https://ton.org/testnet-global.config.json" 435 | } else { 436 | "https://ton.org/global.config.json" 437 | }; 438 | let response = ureq::get(url).call() 439 | .map_err(|e| format!("Error occurred while fetching config from {}: {:?}. Use --config if you have local config.", url, e))?; 440 | if response.status() != 200 { 441 | return Err(format!( 442 | "Url {} responded with error code {}. Use --config if you have local config.", 443 | url, 444 | response.status() 445 | ) 446 | .into()); 447 | } 448 | Ok(response.into_string()?) 449 | } 450 | -------------------------------------------------------------------------------- /docs/lite.tl: -------------------------------------------------------------------------------- 1 | int ? = Int; 2 | long ? = Long; 3 | double ? = Double; 4 | string ? = String; 5 | object ? = Object; 6 | function ? = Function; 7 | bytes data:string = Bytes; 8 | true = True; 9 | boolTrue = Bool; 10 | boolFalse = Bool; 11 | 12 | 13 | vector {t:Type} # [ t ] = Vector t; 14 | 15 | int128 4*[ int ] = Int128; 16 | int256 8*[ int ] = Int256; 17 | 18 | tonNode.blockId workchain:int shard:long seqno:int = tonNode.BlockId; 19 | tonNode.blockIdExt workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt; 20 | tonNode.zeroStateIdExt workchain:int root_hash:int256 file_hash:int256 = tonNode.ZeroStateIdExt; 21 | 22 | adnl.message.query query_id:int256 query:bytes = adnl.Message; 23 | adnl.message.answer query_id:int256 answer:bytes = adnl.Message; 24 | 25 | liteServer.error code:int message:string = liteServer.Error; 26 | 27 | liteServer.accountId workchain:int id:int256 = liteServer.AccountId; 28 | 29 | liteServer.masterchainInfo last:tonNode.blockIdExt state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfo; 30 | liteServer.masterchainInfoExt mode:# version:int capabilities:long last:tonNode.blockIdExt last_utime:int now:int state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfoExt; 31 | liteServer.currentTime now:int = liteServer.CurrentTime; 32 | liteServer.version mode:# version:int capabilities:long now:int = liteServer.Version; 33 | liteServer.blockData id:tonNode.blockIdExt data:bytes = liteServer.BlockData; 34 | liteServer.blockState id:tonNode.blockIdExt root_hash:int256 file_hash:int256 data:bytes = liteServer.BlockState; 35 | liteServer.blockHeader id:tonNode.blockIdExt mode:# header_proof:bytes = liteServer.BlockHeader; 36 | liteServer.sendMsgStatus status:int = liteServer.SendMsgStatus; 37 | liteServer.accountState id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes proof:bytes state:bytes = liteServer.AccountState; 38 | liteServer.runMethodResult mode:# id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:mode.0?bytes proof:mode.0?bytes state_proof:mode.1?bytes init_c7:mode.3?bytes lib_extras:mode.4?bytes exit_code:int result:mode.2?bytes = liteServer.RunMethodResult; 39 | liteServer.shardInfo id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes shard_descr:bytes = liteServer.ShardInfo; 40 | liteServer.allShardsInfo id:tonNode.blockIdExt proof:bytes data:bytes = liteServer.AllShardsInfo; 41 | liteServer.transactionInfo id:tonNode.blockIdExt proof:bytes transaction:bytes = liteServer.TransactionInfo; 42 | liteServer.transactionList ids:(vector tonNode.blockIdExt) transactions:bytes = liteServer.TransactionList; 43 | liteServer.transactionId mode:# account:mode.0?int256 lt:mode.1?long hash:mode.2?int256 = liteServer.TransactionId; 44 | liteServer.transactionId3 account:int256 lt:long = liteServer.TransactionId3; 45 | liteServer.blockTransactions id:tonNode.blockIdExt req_count:# incomplete:Bool ids:(vector liteServer.transactionId) proof:bytes = liteServer.BlockTransactions; 46 | liteServer.signature node_id_short:int256 signature:bytes = liteServer.Signature; 47 | liteServer.signatureSet validator_set_hash:int catchain_seqno:int signatures:(vector liteServer.signature) = liteServer.SignatureSet; 48 | liteServer.blockLinkBack to_key_block:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt dest_proof:bytes proof:bytes state_proof:bytes = liteServer.BlockLink; 49 | liteServer.blockLinkForward to_key_block:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt dest_proof:bytes config_proof:bytes signatures:liteServer.SignatureSet = liteServer.BlockLink; 50 | liteServer.partialBlockProof complete:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt steps:(vector liteServer.BlockLink) = liteServer.PartialBlockProof; 51 | liteServer.configInfo mode:# id:tonNode.blockIdExt state_proof:bytes config_proof:bytes = liteServer.ConfigInfo; 52 | liteServer.validatorStats mode:# id:tonNode.blockIdExt count:int complete:Bool state_proof:bytes data_proof:bytes = liteServer.ValidatorStats; 53 | 54 | liteServer.debug.verbosity value:int = liteServer.debug.Verbosity; 55 | 56 | ---functions--- 57 | 58 | liteServer.getMasterchainInfo = liteServer.MasterchainInfo; 59 | liteServer.getMasterchainInfoExt mode:# = liteServer.MasterchainInfoExt; 60 | liteServer.getTime = liteServer.CurrentTime; 61 | liteServer.getVersion = liteServer.Version; 62 | liteServer.getBlock id:tonNode.blockIdExt = liteServer.BlockData; 63 | liteServer.getState id:tonNode.blockIdExt = liteServer.BlockState; 64 | liteServer.getBlockHeader id:tonNode.blockIdExt mode:# = liteServer.BlockHeader; 65 | liteServer.sendMessage body:bytes = liteServer.SendMsgStatus; 66 | liteServer.getAccountState id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; 67 | liteServer.runSmcMethod mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; 68 | liteServer.getShardInfo id:tonNode.blockIdExt workchain:int shard:long exact:Bool = liteServer.ShardInfo; 69 | liteServer.getAllShardsInfo id:tonNode.blockIdExt = liteServer.AllShardsInfo; 70 | liteServer.getOneTransaction id:tonNode.blockIdExt account:liteServer.accountId lt:long = liteServer.TransactionInfo; 71 | liteServer.getTransactions count:# account:liteServer.accountId lt:long hash:int256 = liteServer.TransactionList; 72 | liteServer.lookupBlock mode:# id:tonNode.blockId lt:mode.1?long utime:mode.2?int = liteServer.BlockHeader; 73 | liteServer.listBlockTransactions id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactions; 74 | liteServer.getBlockProof mode:# known_block:tonNode.blockIdExt target_block:mode.0?tonNode.blockIdExt = liteServer.PartialBlockProof; 75 | liteServer.getConfigAll mode:# id:tonNode.blockIdExt = liteServer.ConfigInfo; 76 | liteServer.getConfigParams mode:# id:tonNode.blockIdExt param_list:(vector int) = liteServer.ConfigInfo; 77 | liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int start_after:mode.0?int256 modified_after:mode.2?int = liteServer.ValidatorStats; 78 | 79 | liteServer.queryPrefix = Object; 80 | liteServer.query data:bytes = Object; 81 | liteServer.waitMasterchainSeqno seqno:int timeout_ms:int = Object; // query prefix -------------------------------------------------------------------------------- /liteapi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ton_liteapi" 3 | version = "0.2.0" 4 | edition = "2021" 5 | description = "Implementation of TON lite_api.tl interface" 6 | repository = "https://github.com/tonstack/lite-client" 7 | keywords = ["ton"] 8 | categories = ["network-programming"] 9 | license = "MIT" 10 | authors = ["Vladimir Lebedev "] 11 | 12 | [dependencies] 13 | adnl = "2.0.0" 14 | tl-proto = { version = "0.4", features = ["bytes"] } 15 | derivative = "2.2.0" 16 | log = { version = "0.4.14", features = ["max_level_trace"] } 17 | hex = "0.4.3" 18 | thiserror = "1" 19 | tokio = { version = "1", features = ["net", "io-util"] } 20 | tower = { version = "0.4.13", features = ["make", "util", "buffer"] } 21 | tokio-util = { version = "0.7.10" } 22 | tokio-tower = "0.6.0" 23 | rand = "0.8.5" 24 | futures = "0.3" 25 | pin-project = "1" 26 | 27 | [dev-dependencies] 28 | ureq = "2.4.0" 29 | base64 = "0.13.0" 30 | x25519-dalek = { version = "2.0.1", features = ["static_secrets"] } 31 | tokio = { version = "1.36", features = ["full"] } 32 | env_logger = "0.11.3" 33 | -------------------------------------------------------------------------------- /liteapi/examples/client.rs: -------------------------------------------------------------------------------- 1 | use ton_liteapi::client::LiteClient; 2 | 3 | #[tokio::main] 4 | async fn main() -> Result<(), Box> { 5 | env_logger::init(); 6 | let server_public = hex::decode("9f69357376ad875d1543faea6f0bb9fbcd283521b743b1c0d2d432587fe9dbae")?; 7 | let server_address = ("127.0.0.1", 8080); 8 | let mut liteclient = LiteClient::connect(server_address, server_public).await?; 9 | let result = liteclient.get_time().await?; 10 | println!("{:?}", result); 11 | let result = liteclient.get_time().await?; 12 | println!("{:?}", result); 13 | let result = liteclient.get_time().await?; 14 | println!("{:?}", result); 15 | Ok(()) 16 | } -------------------------------------------------------------------------------- /liteapi/examples/server.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::error::Error; 3 | 4 | use adnl::crypto::{KeyPair, SecretKey}; 5 | use adnl::AdnlAddress; 6 | use ton_liteapi::layers::{UnwrapMessagesLayer, WrapErrorLayer}; 7 | use ton_liteapi::server::serve; 8 | use ton_liteapi::tl::request::{Request, WrappedRequest}; 9 | use ton_liteapi::types::LiteError; 10 | use ton_liteapi::tl::response::CurrentTime; 11 | use ton_liteapi::tl::response::Response; 12 | use tower::{make::Shared, ServiceBuilder}; 13 | 14 | async fn handler(req: WrappedRequest) -> Result { 15 | println!("Received frame: {:?}", &req); 16 | if let Request::GetTime = req.request { 17 | Ok(Response::CurrentTime(CurrentTime { now: 1234 })) 18 | } else { 19 | Err(LiteError::UnexpectedMessage) 20 | } 21 | } 22 | 23 | #[tokio::main] 24 | async fn main() -> Result<(), Box> { 25 | // ADNL: get private key from environment variable KEY or use default insecure one 26 | let private_key_hex = env::var("KEY").unwrap_or_else(|_| "f0971651aec4bb0d65ec3861c597687fda9c1e7d2ee8a93acb9a131aa9f3aee7".to_string()); 27 | let private_key_bytes: [u8; 32] = hex::decode(private_key_hex)?.try_into().unwrap(); 28 | let keypair = KeyPair::from(&SecretKey::from_bytes(private_key_bytes)); 29 | 30 | // ADNL: print public key and adnl address associated with given private key 31 | println!( 32 | "Public key is: {}", 33 | hex::encode(keypair.public_key.as_bytes()) 34 | ); 35 | println!( 36 | "Address is: {}", 37 | hex::encode(AdnlAddress::from(&keypair.public_key).as_bytes()) 38 | ); 39 | 40 | let service = ServiceBuilder::new() 41 | .buffer(100) 42 | .layer(UnwrapMessagesLayer) 43 | .layer(WrapErrorLayer) 44 | .service_fn(handler); 45 | 46 | serve(&("127.0.0.1", 8080), keypair, Shared::new(service)).await?; 47 | Ok(()) 48 | } -------------------------------------------------------------------------------- /liteapi/src/client.rs: -------------------------------------------------------------------------------- 1 | use adnl::AdnlPeer; 2 | use tokio::net::ToSocketAddrs; 3 | use tokio_tower::multiplex; 4 | use tower::{Service as _, ServiceBuilder, ServiceExt as _}; 5 | 6 | use crate::{layers::{UnwrapErrorLayer, WrapMessagesLayer}, peer::LitePeer, tl::{common::*, request::*, response::*, utils::FromResponse}, types::LiteError}; 7 | 8 | type Result = std::result::Result; 9 | 10 | pub struct LiteClient { 11 | inner: tower::util::BoxService< 12 | WrappedRequest, 13 | Response, 14 | LiteError, 15 | >, 16 | wait_seqno: Option, 17 | } 18 | 19 | impl LiteClient { 20 | pub async fn connect(address: A, public_key: impl AsRef<[u8]>) -> Result { 21 | let adnl = AdnlPeer::connect(public_key, address).await?; 22 | let lite = LitePeer::new(adnl); 23 | let service = ServiceBuilder::new() 24 | .layer(UnwrapErrorLayer) 25 | .layer(WrapMessagesLayer) 26 | .service(multiplex::Client::<_, Box, _>::new(lite)); 27 | Ok(Self { inner: service.boxed(), wait_seqno: None }) 28 | } 29 | 30 | pub fn wait_masterchain_seqno(mut self, seqno: u32) -> Self { 31 | self.wait_seqno = Some(seqno); 32 | self 33 | } 34 | 35 | async fn send_request(&mut self, request: Request) -> Result 36 | { 37 | let wrapped_request = WrappedRequest { 38 | wait_masterchain_seqno: self.wait_seqno.take().map(|seqno| WaitMasterchainSeqno { seqno, timeout_ms: 10000 }), 39 | request: request.into(), 40 | }; 41 | T::from_response(self.inner.ready().await?.call(wrapped_request).await?) 42 | } 43 | 44 | pub async fn get_masterchain_info(&mut self) -> Result { 45 | let response: MasterchainInfo = self.send_request(Request::GetMasterchainInfo).await?; 46 | Ok(response) 47 | } 48 | 49 | pub async fn get_masterchain_info_ext(&mut self, mode: u32) -> Result { 50 | let request = Request::GetMasterchainInfoExt(GetMasterchainInfoExt { mode }); 51 | let response: MasterchainInfoExt = self.send_request(request).await?; 52 | Ok(response) 53 | } 54 | 55 | pub async fn get_time(&mut self) -> Result { 56 | let response: CurrentTime = self.send_request(Request::GetTime).await?; 57 | Ok(response.now) 58 | } 59 | 60 | pub async fn get_version(&mut self) -> Result { 61 | let response: Version = self.send_request(Request::GetVersion).await?; 62 | Ok(response) 63 | } 64 | 65 | pub async fn get_block(&mut self, id: BlockIdExt) -> Result> { 66 | let request = Request::GetBlock(GetBlock { id }); 67 | let response: BlockData = self.send_request(request).await?; 68 | Ok(response.data) 69 | } 70 | 71 | pub async fn get_state(&mut self, id: BlockIdExt) -> Result { 72 | let request = Request::GetState(GetState { id }); 73 | let response: BlockState = self.send_request(request).await?; 74 | Ok(response) 75 | } 76 | 77 | pub async fn get_block_header( 78 | &mut self, 79 | id: BlockIdExt, 80 | with_state_update: bool, 81 | with_value_flow: bool, 82 | with_extra: bool, 83 | with_shard_hashes: bool, 84 | with_prev_blk_signatures: bool, 85 | ) -> Result> { 86 | let request = Request::GetBlockHeader(GetBlockHeader { 87 | id, 88 | mode: (), 89 | with_state_update: if with_state_update { Some(()) } else { None }, 90 | with_value_flow: if with_value_flow { Some(()) } else { None }, 91 | with_extra: if with_extra { Some(()) } else { None }, 92 | with_shard_hashes: if with_shard_hashes { Some(()) } else { None }, 93 | with_prev_blk_signatures: if with_prev_blk_signatures { Some(()) } else { None }, 94 | }); 95 | let response: BlockHeader = self.send_request(request).await?; 96 | Ok(response.header_proof) 97 | } 98 | 99 | pub async fn send_message(&mut self, body: Vec) -> Result { 100 | let request = Request::SendMessage(SendMessage { body }); 101 | let response: SendMsgStatus = self.send_request(request).await?; 102 | Ok(response.status) 103 | } 104 | 105 | pub async fn get_account_state(&mut self, id: BlockIdExt, account: AccountId) -> Result { 106 | let request = Request::GetAccountState(GetAccountState { id, account }); 107 | let response: AccountState = self.send_request(request).await?; 108 | Ok(response) 109 | } 110 | 111 | pub async fn run_smc_method(&mut self, mode: u32, id: BlockIdExt, account: AccountId, method_id: u64, params: Vec) -> Result { 112 | let request = Request::RunSmcMethod(RunSmcMethod { mode, id, account, method_id, params }); 113 | let response: RunMethodResult = self.send_request(request).await?; 114 | Ok(response) 115 | } 116 | 117 | pub async fn get_shard_info(&mut self, id: BlockIdExt, workchain: i32, shard: u64, exact: bool) -> Result { 118 | let request = Request::GetShardInfo(GetShardInfo { id, workchain, shard, exact }); 119 | let response: ShardInfo = self.send_request(request).await?; 120 | Ok(response) 121 | } 122 | 123 | pub async fn get_all_shards_info(&mut self, id: BlockIdExt) -> Result { 124 | let request = Request::GetAllShardsInfo(GetAllShardsInfo { id }); 125 | let response: AllShardsInfo = self.send_request(request).await?; 126 | Ok(response) 127 | } 128 | 129 | pub async fn get_one_transaction(&mut self, id: BlockIdExt, account: AccountId, lt: u64) -> Result { 130 | let request = Request::GetOneTransaction(GetOneTransaction { id, account, lt }); 131 | let response: TransactionInfo = self.send_request(request).await?; 132 | Ok(response) 133 | } 134 | 135 | pub async fn get_transactions(&mut self, count: u32, account: AccountId, lt: u64, hash: Int256) -> Result { 136 | let request = Request::GetTransactions(GetTransactions { count, account, lt, hash }); 137 | let response: TransactionList = self.send_request(request).await?; 138 | Ok(response) 139 | } 140 | 141 | pub async fn lookup_block( 142 | &mut self, 143 | mode: (), 144 | id: BlockId, 145 | seqno: Option<()>, 146 | lt: Option, 147 | utime: Option, 148 | with_state_update: bool, 149 | with_value_flow: bool, 150 | with_extra: bool, 151 | with_shard_hashes: bool, 152 | with_prev_blk_signatures: bool, 153 | ) -> Result { 154 | let request = Request::LookupBlock(LookupBlock { 155 | mode, 156 | id, 157 | seqno, 158 | lt, 159 | utime, 160 | with_state_update: if with_state_update { Some(()) } else { None }, 161 | with_value_flow: if with_value_flow { Some(()) } else { None }, 162 | with_extra: if with_extra { Some(()) } else { None }, 163 | with_shard_hashes: if with_shard_hashes { Some(()) } else { None }, 164 | with_prev_blk_signatures: if with_prev_blk_signatures { Some(()) } else { None }, 165 | }); 166 | let response: BlockHeader = self.send_request(request).await?; 167 | Ok(response) 168 | } 169 | 170 | pub async fn list_block_transactions( 171 | &mut self, 172 | id: BlockIdExt, 173 | count: u32, 174 | after: Option, 175 | reverse_order: bool, 176 | want_proof: bool 177 | ) -> Result { 178 | let request = Request::ListBlockTransactions(ListBlockTransactions { 179 | id, 180 | mode: (), 181 | count, 182 | after, 183 | reverse_order: if reverse_order { Some(()) } else { None }, 184 | want_proof: if want_proof { Some(()) } else { None }, 185 | }); 186 | let response: BlockTransactions = self.send_request(request).await?; 187 | Ok(response) 188 | } 189 | 190 | pub async fn get_block_proof( 191 | &mut self, 192 | known_block: BlockIdExt, 193 | target_block: Option, 194 | allow_weak_target: bool, 195 | base_block_from_request: bool 196 | ) -> Result { 197 | let request = Request::GetBlockProof(GetBlockProof { 198 | mode: (), 199 | known_block, 200 | target_block, 201 | allow_weak_target: if allow_weak_target { Some(()) } else { None }, 202 | base_block_from_request: if base_block_from_request { Some(()) } else { None }, 203 | }); 204 | let response: PartialBlockProof = self.send_request(request).await?; 205 | Ok(response) 206 | } 207 | 208 | pub async fn get_config_all( 209 | &mut self, 210 | id: BlockIdExt, 211 | with_state_root: bool, 212 | with_libraries: bool, 213 | with_state_extra_root: bool, 214 | with_shard_hashes: bool, 215 | with_validator_set: bool, 216 | with_special_smc: bool, 217 | with_accounts_root: bool, 218 | with_prev_blocks: bool, 219 | with_workchain_info: bool, 220 | with_capabilities: bool, 221 | extract_from_key_block: bool, 222 | ) -> Result { 223 | let request = Request::GetConfigAll(GetConfigAll { 224 | mode: (), 225 | id, 226 | with_state_root: if with_state_root { Some(()) } else { None }, 227 | with_libraries: if with_libraries { Some(()) } else { None }, 228 | with_state_extra_root: if with_state_extra_root { Some(()) } else { None }, 229 | with_shard_hashes: if with_shard_hashes { Some(()) } else { None }, 230 | with_validator_set: if with_validator_set { Some(()) } else { None }, 231 | with_special_smc: if with_special_smc { Some(()) } else { None }, 232 | with_accounts_root: if with_accounts_root { Some(()) } else { None }, 233 | with_prev_blocks: if with_prev_blocks { Some(()) } else { None }, 234 | with_workchain_info: if with_workchain_info { Some(()) } else { None }, 235 | with_capabilities: if with_capabilities { Some(()) } else { None }, 236 | extract_from_key_block: if extract_from_key_block { Some(()) } else { None }, 237 | }); 238 | let response: ConfigInfo = self.send_request(request).await?; 239 | Ok(response) 240 | } 241 | 242 | pub async fn get_config_params( 243 | &mut self, 244 | id: BlockIdExt, 245 | param_list: Vec, 246 | with_state_root: bool, 247 | with_libraries: bool, 248 | with_state_extra_root: bool, 249 | with_shard_hashes: bool, 250 | with_validator_set: bool, 251 | with_special_smc: bool, 252 | with_accounts_root: bool, 253 | with_prev_blocks: bool, 254 | with_workchain_info: bool, 255 | with_capabilities: bool, 256 | extract_from_key_block: bool, 257 | ) -> Result { 258 | let request = Request::GetConfigParams(GetConfigParams { 259 | mode: (), 260 | id, 261 | param_list, 262 | with_state_root: if with_state_root { Some(()) } else { None }, 263 | with_libraries: if with_libraries { Some(()) } else { None }, 264 | with_state_extra_root: if with_state_extra_root { Some(()) } else { None }, 265 | with_shard_hashes: if with_shard_hashes { Some(()) } else { None }, 266 | with_validator_set: if with_validator_set { Some(()) } else { None }, 267 | with_special_smc: if with_special_smc { Some(()) } else { None }, 268 | with_accounts_root: if with_accounts_root { Some(()) } else { None }, 269 | with_prev_blocks: if with_prev_blocks { Some(()) } else { None }, 270 | with_workchain_info: if with_workchain_info { Some(()) } else { None }, 271 | with_capabilities: if with_capabilities { Some(()) } else { None }, 272 | extract_from_key_block: if extract_from_key_block { Some(()) } else { None }, 273 | }); 274 | let response: ConfigInfo = self.send_request(request).await?; 275 | Ok(response) 276 | } 277 | 278 | pub async fn get_validator_stats(&mut self, id: BlockIdExt, limit: u32, start_after: Option, modified_after: Option) -> Result { 279 | let request = Request::GetValidatorStats(GetValidatorStats { mode: (), id, limit, start_after, modified_after }); 280 | let response: ValidatorStats = self.send_request(request).await?; 281 | Ok(response) 282 | } 283 | 284 | pub async fn get_libraries(&mut self, library_list: Vec) -> Result> { 285 | let request = Request::GetLibraries(GetLibraries { library_list }); 286 | let response: LibraryResult = self.send_request(request).await?; 287 | Ok(response.result) 288 | } 289 | } -------------------------------------------------------------------------------- /liteapi/src/layers/mod.rs: -------------------------------------------------------------------------------- 1 | use std::task::{Context, Poll}; 2 | 3 | use futures::future::{self, BoxFuture}; 4 | use tower::{Layer, Service}; 5 | 6 | use crate::tl::common::Int256; 7 | use crate::tl::request::LiteQuery; 8 | use crate::tl::response::Error; 9 | use crate::types::LiteService; 10 | use crate::{tl::{adnl::Message, request::WrappedRequest, response::Response}, types::LiteError}; 11 | 12 | pub struct WrapMessagesLayer; 13 | 14 | impl Layer for WrapMessagesLayer { 15 | type Service = WrapService; 16 | 17 | fn layer(&self, service: S) -> Self::Service { 18 | WrapService { 19 | service 20 | } 21 | } 22 | } 23 | 24 | pub struct WrapService { 25 | service: S, 26 | } 27 | 28 | impl Service for WrapService 29 | where 30 | S: Service, 31 | S::Error: Into, 32 | S::Response: Into, 33 | S::Future: Send + 'static, 34 | { 35 | type Response = Response; 36 | type Error = LiteError; 37 | type Future = BoxFuture<'static, Result>; 38 | 39 | fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { 40 | self.service.poll_ready(cx).map_err(Into::into) 41 | } 42 | 43 | fn call(&mut self, request: WrappedRequest) -> Self::Future { 44 | let fut = self.service.call(Message::Query { 45 | query_id: Int256::default(), 46 | query: LiteQuery { 47 | wrapped_request: request, 48 | } 49 | }); 50 | Box::pin(async move { 51 | let response = fut.await.map_err(Into::into)?.into(); 52 | 53 | match response { 54 | Message::Answer { answer, .. } => Ok(answer), 55 | _ => Err(LiteError::UnexpectedMessage) 56 | } 57 | }) 58 | } 59 | } 60 | 61 | pub struct UnwrapMessagesLayer; 62 | 63 | impl Layer for UnwrapMessagesLayer { 64 | type Service = UnwrapService; 65 | 66 | fn layer(&self, service: S) -> Self::Service { 67 | UnwrapService { 68 | service 69 | } 70 | } 71 | } 72 | 73 | pub struct UnwrapService { 74 | service: S, 75 | } 76 | 77 | impl Service for UnwrapService 78 | where 79 | S: LiteService, 80 | S::Future: Send + 'static, 81 | { 82 | type Response = Message; 83 | type Error = LiteError; 84 | type Future = BoxFuture<'static, Result>; 85 | 86 | fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { 87 | self.service.poll_ready(cx).map_err(Into::into) 88 | } 89 | 90 | fn call(&mut self, request: Message) -> Self::Future { 91 | let (query_id, request) = match request { 92 | Message::Query { query_id, query: LiteQuery { wrapped_request } } => (query_id, wrapped_request), 93 | Message::Ping { random_id } => return Box::pin(future::ok(Message::Pong { random_id })), 94 | _ => return Box::pin(future::err(LiteError::UnexpectedMessage)) 95 | }; 96 | let fut = self.service.call(request); 97 | Box::pin(async move { 98 | let answer = fut.await.map_err(Into::::into)?.into(); 99 | Ok(Message::Answer { query_id, answer }) 100 | }) 101 | } 102 | } 103 | 104 | pub struct WrapErrorLayer; 105 | 106 | impl Layer for WrapErrorLayer { 107 | type Service = WrapErrorService; 108 | 109 | fn layer(&self, service: S) -> Self::Service { 110 | WrapErrorService { 111 | service 112 | } 113 | } 114 | } 115 | 116 | pub struct WrapErrorService { 117 | service: S, 118 | } 119 | 120 | impl Service for WrapErrorService 121 | where 122 | S: Service, 123 | S::Error: Into, 124 | S::Response: Into, 125 | S::Future: Send + 'static, 126 | { 127 | type Response = Response; 128 | type Error = LiteError; 129 | type Future = BoxFuture<'static, Result>; 130 | 131 | fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { 132 | self.service.poll_ready(cx).map_err(Into::into) 133 | } 134 | 135 | fn call(&mut self, request: WrappedRequest) -> Self::Future { 136 | let fut = self.service.call(request); 137 | Box::pin(async move { 138 | let response = fut.await; 139 | match response { 140 | Ok(x) => Ok(x.into()), 141 | Err(e) => Ok(Response::Error(Error { 142 | code: 500, 143 | message: format!("{:?}", e.into()).as_str().into(), 144 | })) 145 | } 146 | }) 147 | } 148 | } 149 | 150 | pub struct UnwrapErrorService { 151 | service: S, 152 | } 153 | 154 | impl UnwrapErrorService { 155 | pub fn new(service: S) -> Self { 156 | Self { service } 157 | } 158 | } 159 | 160 | impl Service for UnwrapErrorService 161 | where 162 | S: Service, 163 | S::Future: Send + 'static, 164 | { 165 | type Response = Response; 166 | type Error = LiteError; 167 | type Future = BoxFuture<'static, Result>; 168 | 169 | fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { 170 | self.service.poll_ready(cx) 171 | } 172 | 173 | fn call(&mut self, request: WrappedRequest) -> Self::Future { 174 | let fut = self.service.call(request); 175 | Box::pin(async move { 176 | match fut.await { 177 | Ok(Response::Error(error)) => Err(LiteError::from(error)), 178 | Ok(response) => Ok(response), 179 | Err(e) => Err(e), 180 | } 181 | }) 182 | } 183 | } 184 | 185 | // Implement From for LiteError 186 | impl From for LiteError { 187 | fn from(error: Error) -> Self { 188 | LiteError::ServerError(error) 189 | } 190 | } 191 | 192 | pub struct UnwrapErrorLayer; 193 | 194 | impl Layer for UnwrapErrorLayer { 195 | type Service = UnwrapErrorService; 196 | 197 | fn layer(&self, service: S) -> Self::Service { 198 | UnwrapErrorService { 199 | service 200 | } 201 | } 202 | } -------------------------------------------------------------------------------- /liteapi/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod tl; 2 | pub mod types; 3 | pub mod peer; 4 | pub mod layers; 5 | pub mod client; 6 | pub mod server; -------------------------------------------------------------------------------- /liteapi/src/peer.rs: -------------------------------------------------------------------------------- 1 | use std::task::Poll; 2 | 3 | use adnl::AdnlError; 4 | use futures::{Sink, Stream}; 5 | use pin_project::pin_project; 6 | use rand::random; 7 | use tokio_tower::multiplex::TagStore; 8 | use tokio_util::bytes::Bytes; 9 | 10 | use crate::{tl::{adnl::Message, common::Int256}, types::LiteError}; 11 | 12 | #[pin_project] 13 | pub struct LitePeer { 14 | #[pin] 15 | inner: T, 16 | } 17 | 18 | impl LitePeer { 19 | pub fn new(inner: T) -> Self { 20 | Self { inner } 21 | } 22 | } 23 | 24 | impl Sink for LitePeer where T: Sink { 25 | type Error = LiteError; 26 | 27 | fn poll_ready(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll> { 28 | self.project().inner.poll_ready(cx).map_err(|e| LiteError::AdnlError(e.into())) 29 | } 30 | 31 | fn start_send(self: std::pin::Pin<&mut Self>, item: Message) -> Result<(), Self::Error> { 32 | log::debug!("Sending TL message: {:?}", item); 33 | let data = tl_proto::serialize(item).into(); 34 | self.project().inner.start_send(data).map_err(|e| LiteError::AdnlError(e.into())) 35 | } 36 | 37 | fn poll_flush(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll> { 38 | self.project().inner.poll_flush(cx).map_err(|e| LiteError::AdnlError(e.into())) 39 | } 40 | 41 | fn poll_close(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll> { 42 | self.project().inner.poll_close(cx).map_err(|e| LiteError::AdnlError(e.into())) 43 | } 44 | } 45 | 46 | impl Stream for LitePeer where T: Stream> { 47 | type Item = Result; 48 | 49 | fn poll_next(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll> { 50 | let inner = self.project().inner.poll_next(cx); 51 | match inner { 52 | Poll::Ready(Some(Ok(bytes))) => { 53 | let decoded = tl_proto::deserialize(&bytes); 54 | log::debug!("Decoded to TL message:\n{:?}\n{:?}", bytes, decoded); 55 | Poll::Ready(Some(decoded.map_err(|e| LiteError::TlError(e)))) 56 | }, 57 | Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(LiteError::AdnlError(e.into())))), 58 | Poll::Ready(None) => Poll::Ready(None), 59 | Poll::Pending => Poll::Pending, 60 | } 61 | } 62 | } 63 | 64 | #[derive(PartialEq, Eq)] 65 | pub enum LiteTag { 66 | Int256(Int256), 67 | Long(u64), 68 | } 69 | 70 | impl TagStore for LitePeer { 71 | type Tag = LiteTag; 72 | 73 | fn assign_tag(self: std::pin::Pin<&mut Self>, r: &mut Message) -> Self::Tag { 74 | match r { 75 | Message::Answer { query_id, .. } => { *query_id = Int256::random(); LiteTag::Int256(query_id.clone()) }, 76 | Message::Query { query_id, .. } => { *query_id = Int256::random(); LiteTag::Int256(query_id.clone()) }, 77 | Message::Ping { random_id } => { *random_id = random(); LiteTag::Long(random_id.clone()) }, 78 | Message::Pong { random_id } => { *random_id = random(); LiteTag::Long(random_id.clone()) }, 79 | } 80 | } 81 | 82 | fn finish_tag(self: std::pin::Pin<&mut Self>, r: &Message) -> Self::Tag { 83 | match r { 84 | Message::Answer { query_id, .. } => LiteTag::Int256(query_id.clone()), 85 | Message::Query { query_id, .. } => LiteTag::Int256(query_id.clone()), 86 | Message::Ping { random_id } => LiteTag::Long(random_id.clone()), 87 | Message::Pong { random_id } => LiteTag::Long(random_id.clone()), 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /liteapi/src/server.rs: -------------------------------------------------------------------------------- 1 | 2 | use std::future::poll_fn; 3 | use std::io::ErrorKind; 4 | use std::net::SocketAddr; 5 | use std::time::Duration; 6 | 7 | use adnl::crypto::KeyPair; 8 | use adnl::AdnlPeer; 9 | use tokio::net::TcpListener; 10 | use tokio::net::ToSocketAddrs; 11 | use tokio_tower::multiplex::Server; 12 | use tower::MakeService; 13 | use tower::Service; 14 | 15 | use crate::peer::LitePeer; 16 | use crate::tl::adnl::Message; 17 | 18 | pub async fn serve(addr: &A, private_key: KeyPair, mut service_maker: M) -> Result<(), Box> 19 | where A: ToSocketAddrs, 20 | M: MakeService + Send, 21 | M::Error: std::fmt::Debug, 22 | M::MakeError: std::error::Error, 23 | M::Service: Send + 'static, 24 | >::Future: Send { 25 | let listener = TcpListener::bind(addr).await?; 26 | 27 | loop { 28 | let (socket, addr) = match listener.accept().await { 29 | Ok((socket, addr)) => (socket, addr), 30 | Err(e) => { 31 | // [From `hyper::Server` in 0.14](https://github.com/hyperium/hyper/blob/v0.14.27/src/server/tcp.rs#L186) 32 | // 33 | // > A possible scenario is that the process has hit the max open files 34 | // > allowed, and so trying to accept a new connection will fail with 35 | // > `EMFILE`. In some cases, it's preferable to just wait for some time, if 36 | // > the application will likely close some files (or connections), and try 37 | // > to accept the connection again. If this option is `true`, the error 38 | // > will be logged at the `error` level, since it is still a big deal, 39 | // > and then the listener will sleep for 1 second. 40 | if !matches!(e.kind(), ErrorKind::ConnectionRefused | ErrorKind::ConnectionAborted | ErrorKind::ConnectionReset) { 41 | log::error!("accept error: {e}"); 42 | tokio::time::sleep(Duration::from_secs(1)).await; 43 | } 44 | continue; 45 | } 46 | }; 47 | log::debug!("[{addr:?}] Accepted socket"); 48 | if let Err(e) = poll_fn(|cx| service_maker.poll_ready(cx)).await { 49 | log::error!("[{addr:?}] Polling failed: {:?}", e); 50 | continue 51 | }; 52 | let service = match service_maker.make_service(addr).await { 53 | Ok(x) => x, 54 | Err(e) => { 55 | log::error!("[{addr:?}] Making service failed: {:?}", e); 56 | continue 57 | } 58 | }; 59 | let private_key = private_key.clone(); 60 | tokio::spawn(async move { 61 | let adnl = match AdnlPeer::handle_handshake(socket, |_| Some(private_key.clone())).await { 62 | Ok(x) => x, 63 | Err(e) => { 64 | log::error!("[{addr:?}] Handshake failed: {:?}", e); 65 | return 66 | } 67 | }; 68 | log::debug!("[{addr:?}] Handshake performed"); 69 | let lite = LitePeer::new(adnl); 70 | if let Err(e) = Server::new(lite, service).await { 71 | log::error!("[{addr:?}] Server failed: {:?}", e); 72 | } 73 | }); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /liteapi/src/tl/adnl.rs: -------------------------------------------------------------------------------- 1 | use derivative::Derivative; 2 | use tl_proto::{TlRead, TlWrite}; 3 | 4 | use super::request::LiteQuery; 5 | use super::response::Response; 6 | use super::common::*; 7 | use super::utils::*; 8 | 9 | #[derive(TlRead, TlWrite, Derivative)] 10 | #[derivative(Debug, Clone, PartialEq)] 11 | #[tl(boxed)] 12 | pub enum Message { 13 | /// adnl.message.query query_id:int256 query:bytes = adnl.Message; 14 | #[tl(id = 0xb48bf97a)] 15 | Query { query_id: Int256, #[tl(with = "struct_as_bytes")] query: LiteQuery }, 16 | 17 | /// adnl.message.answer query_id:int256 answer:bytes = adnl.Message; 18 | #[tl(id = 0x0fac8416)] 19 | Answer { query_id: Int256, #[tl(with = "struct_as_bytes")] answer: Response }, 20 | 21 | /// tcp.ping random_id:long = tcp.Pong; 22 | #[tl(id = 0x4d082b9a)] 23 | Ping { random_id: u64 }, 24 | 25 | /// tcp.pong random_id:long = tcp.Pong; 26 | #[tl(id = 0xdc69fb03)] 27 | Pong { random_id: u64 }, 28 | } -------------------------------------------------------------------------------- /liteapi/src/tl/common.rs: -------------------------------------------------------------------------------- 1 | use core::fmt; 2 | use std::{fmt::Display, str::FromStr}; 3 | 4 | use derivative::Derivative; 5 | use hex::FromHex; 6 | use tl_proto::{TlRead, TlWrite}; 7 | use super::utils::*; 8 | 9 | /// true = True; 10 | #[derive(TlRead, TlWrite, Derivative)] 11 | #[derivative(Debug, Clone, PartialEq)] 12 | pub struct True; 13 | 14 | /// string ? = String; 15 | #[derive(TlRead, TlWrite, Derivative)] 16 | #[derivative(Debug, Clone, PartialEq)] 17 | pub struct String(#[derivative(Debug(format_with = "fmt_string"))] Vec); 18 | 19 | impl fmt::Display for String { 20 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 21 | write!( 22 | f, 23 | "{}", 24 | std::string::String::from_utf8(self.0.clone()).unwrap() 25 | ) 26 | } 27 | } 28 | 29 | impl From<&str> for String { 30 | fn from(s: &str) -> Self { 31 | Self(s.as_bytes().to_vec()) 32 | } 33 | } 34 | 35 | impl String { 36 | pub fn new(str: std::string::String) -> Self { 37 | Self(str.into_bytes()) 38 | } 39 | } 40 | 41 | /// int256 8*[ int ] = Int256; 42 | #[derive(TlRead, TlWrite, Derivative)] 43 | #[derivative(Debug, Clone, PartialEq, Eq, Default, Hash)] 44 | pub struct Int256(#[derivative(Debug(format_with = "fmt_bytes"))] pub [u8; 32]); 45 | 46 | impl FromStr for Int256 { 47 | fn from_str(s: &str) -> Result { 48 | Self::from_hex(s) 49 | } 50 | type Err = hex::FromHexError; 51 | } 52 | 53 | impl Display for Int256 { 54 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 55 | f.write_str(&self.to_hex()) 56 | } 57 | } 58 | 59 | impl Int256 { 60 | pub fn to_hex(&self) -> std::string::String { 61 | hex::encode(self.0) 62 | } 63 | 64 | pub fn from_hex(s: &str) -> Result { 65 | Ok(Int256(<[u8; 32]>::from_hex(s)?)) 66 | } 67 | 68 | pub fn random() -> Self { 69 | Self(rand::random()) 70 | } 71 | } 72 | 73 | /// tonNode.blockId workchain:int shard:long seqno:int = tonNode.BlockId; 74 | #[derive(TlRead, TlWrite, Derivative)] 75 | #[derivative(Debug, Clone, PartialEq)] 76 | pub struct BlockId { 77 | pub workchain: i32, 78 | pub shard: u64, 79 | pub seqno: u32, 80 | } 81 | 82 | /// tonNode.blockIdExt workchain:int shard:long seqno:int root_hash:int256 file_hash:int256 = tonNode.BlockIdExt; 83 | #[derive(TlRead, TlWrite, Derivative)] 84 | #[derivative(Debug, Clone, PartialEq, Eq, Hash)] 85 | pub struct BlockIdExt { 86 | pub workchain: i32, 87 | pub shard: u64, 88 | pub seqno: u32, 89 | pub root_hash: Int256, 90 | pub file_hash: Int256, 91 | } 92 | 93 | impl fmt::Display for BlockIdExt { 94 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 95 | write!(f, "({},{:X},{}):{}:{}", self.workchain, self.shard, self.seqno, self.root_hash.to_string(), self.file_hash.to_string()) 96 | } 97 | } 98 | 99 | /// liteServer.accountId workchain:int id:int256 = liteServer.AccountId; 100 | #[derive(TlRead, TlWrite, Derivative)] 101 | #[derivative(Debug, Clone, PartialEq)] 102 | pub struct AccountId { 103 | pub workchain: i32, 104 | pub id: Int256, 105 | } 106 | 107 | /// liteServer.transactionId3 account:int256 lt:long = liteServer.TransactionId3; 108 | #[derive(TlRead, TlWrite, Derivative)] 109 | #[derivative(Debug, Clone, PartialEq)] 110 | // #[tl(boxed, id = "liteServer.transactionId3", scheme_inline = r##"liteServer.transactionId3 account:int256 lt:long = liteServer.TransactionId3;"##)] 111 | pub struct TransactionId3 { 112 | pub account: Int256, 113 | pub lt: u64, 114 | } 115 | 116 | /// liteServer.signature node_id_short:int256 signature:bytes = liteServer.Signature; 117 | #[derive(TlRead, TlWrite, Derivative)] 118 | #[derivative(Debug, Clone, PartialEq)] 119 | // #[tl(boxed, id = "liteServer.signature", scheme_inline = r##"liteServer.signature node_id_short:int256 signature:bytes = liteServer.Signature;"##)] 120 | pub struct Signature { 121 | pub node_id_short: Int256, 122 | #[derivative(Debug(format_with = "fmt_bytes"))] 123 | pub signature: Vec, 124 | } 125 | 126 | /// liteServer.signatureSet validator_set_hash:int catchain_seqno:int signatures:(vector liteServer.signature) = liteServer.SignatureSet; 127 | #[derive(TlRead, TlWrite, Derivative)] 128 | #[derivative(Debug, Clone, PartialEq)] 129 | #[tl( 130 | boxed, 131 | id = "liteServer.signatureSet", 132 | scheme_inline = r##"liteServer.signatureSet validator_set_hash:int catchain_seqno:int signatures:(vector liteServer.signature) = liteServer.SignatureSet;"## 133 | )] 134 | pub struct SignatureSet { 135 | pub validator_set_hash: u32, 136 | pub catchain_seqno: u32, 137 | pub signatures: Vec, 138 | } 139 | 140 | #[derive(TlRead, TlWrite, Derivative)] 141 | #[derivative(Debug, Clone, PartialEq)] 142 | #[tl( 143 | boxed, 144 | scheme_inline = r##"liteServer.blockLinkBack to_key_block:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt dest_proof:bytes proof:bytes state_proof:bytes = liteServer.BlockLink; 145 | liteServer.blockLinkForward to_key_block:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt dest_proof:bytes config_proof:bytes signatures:liteServer.SignatureSet = liteServer.BlockLink;"## 146 | )] 147 | pub enum BlockLink { 148 | /// liteServer.blockLinkBack to_key_block:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt dest_proof:bytes proof:bytes state_proof:bytes = liteServer.BlockLink; 149 | #[tl(id = "liteServer.blockLinkBack")] 150 | BlockLinkBack { 151 | to_key_block: bool, 152 | from: BlockIdExt, 153 | to: BlockIdExt, 154 | #[derivative(Debug(format_with = "fmt_bytes"))] 155 | dest_proof: Vec, 156 | #[derivative(Debug(format_with = "fmt_bytes"))] 157 | proof: Vec, 158 | #[derivative(Debug(format_with = "fmt_bytes"))] 159 | state_proof: Vec, 160 | }, 161 | /// liteServer.blockLinkForward to_key_block:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt dest_proof:bytes config_proof:bytes signatures:liteServer.SignatureSet = liteServer.BlockLink; 162 | #[tl(id = "liteServer.blockLinkForward")] 163 | BlockLinkForward { 164 | to_key_block: bool, 165 | from: BlockIdExt, 166 | to: BlockIdExt, 167 | #[derivative(Debug(format_with = "fmt_bytes"))] 168 | dest_proof: Vec, 169 | #[derivative(Debug(format_with = "fmt_bytes"))] 170 | config_proof: Vec, 171 | signatures: SignatureSet, 172 | }, 173 | } 174 | 175 | /// tonNode.zeroStateIdExt workchain:int root_hash:int256 file_hash:int256 = tonNode.ZeroStateIdExt; 176 | #[derive(TlRead, TlWrite, Derivative)] 177 | #[derivative(Debug, Clone, PartialEq)] 178 | pub struct ZeroStateIdExt { 179 | pub workchain: i32, 180 | #[tl(size_hint = 32)] 181 | pub root_hash: Int256, 182 | #[tl(size_hint = 32)] 183 | pub file_hash: Int256, 184 | } 185 | 186 | /// liteServer.transactionId mode:# account:mode.0?int256 lt:mode.1?long hash:mode.2?int256 = liteServer.TransactionId; 187 | #[derive(TlRead, TlWrite, Derivative)] 188 | #[derivative(Debug, Clone, PartialEq)] 189 | pub struct TransactionId { 190 | #[tl(flags)] 191 | pub mode: (), 192 | #[tl(flags_bit = "mode.0")] 193 | pub account: Option, 194 | #[tl(flags_bit = "mode.1")] 195 | pub lt: Option, 196 | #[tl(flags_bit = "mode.2")] 197 | pub hash: Option, 198 | } 199 | 200 | /// liteServer.libraryEntry hash:int256 data:bytes = liteServer.LibraryEntry; 201 | #[derive(TlRead, TlWrite, Derivative)] 202 | #[derivative(Debug, Clone, PartialEq)] 203 | pub struct LibraryEntry { 204 | pub hash: Int256, 205 | #[derivative(Debug(format_with = "fmt_bytes"))] 206 | pub data: Vec, 207 | } 208 | -------------------------------------------------------------------------------- /liteapi/src/tl/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod adnl; 2 | pub mod common; 3 | pub mod request; 4 | pub mod response; 5 | pub mod utils; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | -------------------------------------------------------------------------------- /liteapi/src/tl/request.rs: -------------------------------------------------------------------------------- 1 | use derivative::Derivative; 2 | use tl_proto::{TlRead, TlWrite}; 3 | 4 | use super::common::*; 5 | use super::utils::*; 6 | 7 | /// liteServer.query data:bytes = Object; 8 | #[derive(TlRead, TlWrite, Derivative)] 9 | #[derivative(Debug, Clone, PartialEq)] 10 | #[tl( 11 | boxed, 12 | id = "liteServer.query", 13 | scheme_inline = r##"liteServer.query data:bytes = Object;"## 14 | )] 15 | pub struct LiteQuery { 16 | #[tl(with = "struct_as_bytes")] 17 | pub wrapped_request: WrappedRequest, 18 | } 19 | 20 | #[derive(TlRead, TlWrite, Derivative)] 21 | #[derivative(Debug, Clone, PartialEq)] 22 | pub struct WrappedRequest { 23 | #[tl(read_with = "lossy_read")] 24 | pub wait_masterchain_seqno: Option, 25 | pub request: Request, 26 | } 27 | 28 | /// liteServer.query data:bytes = Object; 29 | #[derive(TlRead, TlWrite, Derivative)] 30 | #[derivative(Debug, Clone, PartialEq)] 31 | #[tl( 32 | boxed, 33 | id = "liteServer.waitMasterchainSeqno", 34 | scheme_inline = r##"liteServer.waitMasterchainSeqno seqno:int timeout_ms:int = Object;"## 35 | )] 36 | pub struct WaitMasterchainSeqno { 37 | pub seqno: u32, 38 | pub timeout_ms: u32, 39 | } 40 | 41 | #[derive(TlRead, TlWrite, Derivative)] 42 | #[derivative(Debug, Clone, PartialEq)] 43 | pub struct GetMasterchainInfoExt { 44 | pub mode: u32 45 | } 46 | 47 | #[derive(TlRead, TlWrite, Derivative)] 48 | #[derivative(Debug, Clone, PartialEq)] 49 | pub struct GetBlock { 50 | pub id: BlockIdExt, 51 | } 52 | 53 | #[derive(TlRead, TlWrite, Derivative)] 54 | #[derivative(Debug, Clone, PartialEq)] 55 | pub struct GetState { 56 | pub id: BlockIdExt, 57 | } 58 | 59 | #[derive(TlRead, TlWrite, Derivative)] 60 | #[derivative(Debug, Clone, PartialEq)] 61 | pub struct GetBlockHeader { 62 | pub id: BlockIdExt, 63 | #[tl(flags)] 64 | pub mode: (), 65 | #[tl(flags_bit = "mode.0")] 66 | pub with_state_update: Option<()>, 67 | #[tl(flags_bit = "mode.1")] 68 | pub with_value_flow: Option<()>, 69 | #[tl(flags_bit = "mode.4")] 70 | pub with_extra: Option<()>, 71 | #[tl(flags_bit = "mode.5")] 72 | pub with_shard_hashes: Option<()>, 73 | #[tl(flags_bit = "mode.6")] 74 | pub with_prev_blk_signatures: Option<()>, 75 | } 76 | 77 | #[derive(TlRead, TlWrite, Derivative)] 78 | #[derivative(Debug, Clone, PartialEq)] 79 | pub struct SendMessage { 80 | pub body: Vec, 81 | } 82 | 83 | #[derive(TlRead, TlWrite, Derivative)] 84 | #[derivative(Debug, Clone, PartialEq)] 85 | pub struct GetAccountState { 86 | pub id: BlockIdExt, 87 | pub account: AccountId, 88 | } 89 | 90 | #[derive(TlRead, TlWrite, Derivative)] 91 | #[derivative(Debug, Clone, PartialEq)] 92 | pub struct RunSmcMethod { 93 | pub mode: u32, 94 | pub id: BlockIdExt, 95 | pub account: AccountId, 96 | pub method_id: u64, 97 | pub params: Vec, 98 | } 99 | 100 | #[derive(TlRead, TlWrite, Derivative)] 101 | #[derivative(Debug, Clone, PartialEq)] 102 | pub struct GetShardInfo { 103 | pub id: BlockIdExt, 104 | pub workchain: i32, 105 | pub shard: u64, 106 | pub exact: bool, 107 | } 108 | 109 | #[derive(TlRead, TlWrite, Derivative)] 110 | #[derivative(Debug, Clone, PartialEq)] 111 | pub struct GetAllShardsInfo { 112 | pub id: BlockIdExt, 113 | } 114 | 115 | #[derive(TlRead, TlWrite, Derivative)] 116 | #[derivative(Debug, Clone, PartialEq)] 117 | pub struct GetOneTransaction { 118 | pub id: BlockIdExt, 119 | pub account: AccountId, 120 | pub lt: u64, 121 | } 122 | 123 | #[derive(TlRead, TlWrite, Derivative)] 124 | #[derivative(Debug, Clone, PartialEq)] 125 | pub struct GetTransactions { 126 | pub count: u32, 127 | pub account: AccountId, 128 | pub lt: u64, 129 | pub hash: Int256, 130 | } 131 | 132 | #[derive(TlRead, TlWrite, Derivative)] 133 | #[derivative(Debug, Clone, PartialEq)] 134 | pub struct LookupBlock { 135 | #[tl(flags)] 136 | pub mode: (), 137 | pub id: BlockId, 138 | #[tl(flags_bit = "mode.0")] 139 | pub seqno: Option<()>, 140 | #[tl(flags_bit = "mode.1")] 141 | pub lt: Option, 142 | #[tl(flags_bit = "mode.2")] 143 | pub utime: Option, 144 | #[tl(flags_bit = "mode.4")] 145 | pub with_state_update: Option<()>, 146 | #[tl(flags_bit = "mode.5")] 147 | pub with_value_flow: Option<()>, 148 | #[tl(flags_bit = "mode.8")] 149 | pub with_extra: Option<()>, 150 | #[tl(flags_bit = "mode.9")] 151 | pub with_shard_hashes: Option<()>, 152 | #[tl(flags_bit = "mode.10")] 153 | pub with_prev_blk_signatures: Option<()>, 154 | } 155 | 156 | #[derive(TlRead, TlWrite, Derivative)] 157 | #[derivative(Debug, Clone, PartialEq)] 158 | pub struct LookupBlockWithProof { 159 | #[tl(flags)] 160 | pub mode: (), 161 | pub id: BlockId, 162 | pub mc_block_id: BlockIdExt, 163 | #[tl(flags_bit = "mode.0")] 164 | pub seqno: Option<()>, 165 | #[tl(flags_bit = "mode.1")] 166 | pub lt: Option, 167 | #[tl(flags_bit = "mode.2")] 168 | pub utime: Option, 169 | #[tl(flags_bit = "mode.4")] 170 | pub with_state_update: Option<()>, 171 | #[tl(flags_bit = "mode.5")] 172 | pub with_value_flow: Option<()>, 173 | #[tl(flags_bit = "mode.8")] 174 | pub with_extra: Option<()>, 175 | #[tl(flags_bit = "mode.9")] 176 | pub with_shard_hashes: Option<()>, 177 | #[tl(flags_bit = "mode.10")] 178 | pub with_prev_blk_signatures: Option<()>, 179 | } 180 | 181 | #[derive(TlRead, TlWrite, Derivative)] 182 | #[derivative(Debug, Clone, PartialEq)] 183 | pub struct ListBlockTransactions { 184 | pub id: BlockIdExt, 185 | #[tl(flags)] 186 | pub mode: (), 187 | pub count: u32, 188 | #[tl(flags_bit = "mode.7")] 189 | pub after: Option, 190 | #[tl(flags_bit = "mode.6")] 191 | pub reverse_order: Option<()>, 192 | #[tl(flags_bit = "mode.5")] 193 | pub want_proof: Option<()>, 194 | } 195 | 196 | #[derive(TlRead, TlWrite, Derivative)] 197 | #[derivative(Debug, Clone, PartialEq)] 198 | pub struct GetBlockProof { 199 | #[tl(flags)] 200 | pub mode: (), 201 | pub known_block: BlockIdExt, 202 | #[tl(flags_bit = "mode.0")] 203 | pub target_block: Option, 204 | #[tl(flags_bit = "mode.1")] 205 | pub allow_weak_target: Option<()>, 206 | #[tl(flags_bit = "mode.12")] 207 | pub base_block_from_request: Option<()>, 208 | } 209 | 210 | #[derive(TlRead, TlWrite, Derivative)] 211 | #[derivative(Debug, Clone, PartialEq)] 212 | pub struct GetConfigAll { 213 | #[tl(flags)] 214 | pub mode: (), 215 | pub id: BlockIdExt, 216 | #[tl(flags_bit = "mode.0")] 217 | pub with_state_root: Option<()>, 218 | #[tl(flags_bit = "mode.1")] 219 | pub with_libraries: Option<()>, 220 | #[tl(flags_bit = "mode.2")] 221 | pub with_state_extra_root: Option<()>, 222 | #[tl(flags_bit = "mode.3")] 223 | pub with_shard_hashes: Option<()>, 224 | #[tl(flags_bit = "mode.4")] 225 | pub with_validator_set: Option<()>, 226 | #[tl(flags_bit = "mode.5")] 227 | pub with_special_smc: Option<()>, 228 | #[tl(flags_bit = "mode.6")] 229 | pub with_accounts_root: Option<()>, 230 | #[tl(flags_bit = "mode.7")] 231 | pub with_prev_blocks: Option<()>, 232 | #[tl(flags_bit = "mode.8")] 233 | pub with_workchain_info: Option<()>, 234 | #[tl(flags_bit = "mode.9")] 235 | pub with_capabilities: Option<()>, 236 | #[tl(flags_bit = "mode.15")] 237 | pub extract_from_key_block: Option<()>, 238 | } 239 | 240 | #[derive(TlRead, TlWrite, Derivative)] 241 | #[derivative(Debug, Clone, PartialEq)] 242 | pub struct GetConfigParams { 243 | #[tl(flags)] 244 | pub mode: (), 245 | pub id: BlockIdExt, 246 | pub param_list: Vec, 247 | #[tl(flags_bit = "mode.0")] 248 | pub with_state_root: Option<()>, 249 | #[tl(flags_bit = "mode.1")] 250 | pub with_libraries: Option<()>, 251 | #[tl(flags_bit = "mode.2")] 252 | pub with_state_extra_root: Option<()>, 253 | #[tl(flags_bit = "mode.3")] 254 | pub with_shard_hashes: Option<()>, 255 | #[tl(flags_bit = "mode.4")] 256 | pub with_validator_set: Option<()>, 257 | #[tl(flags_bit = "mode.5")] 258 | pub with_special_smc: Option<()>, 259 | #[tl(flags_bit = "mode.6")] 260 | pub with_accounts_root: Option<()>, 261 | #[tl(flags_bit = "mode.7")] 262 | pub with_prev_blocks: Option<()>, 263 | #[tl(flags_bit = "mode.8")] 264 | pub with_workchain_info: Option<()>, 265 | #[tl(flags_bit = "mode.9")] 266 | pub with_capabilities: Option<()>, 267 | #[tl(flags_bit = "mode.15")] 268 | pub extract_from_key_block: Option<()>, 269 | } 270 | 271 | #[derive(TlRead, TlWrite, Derivative)] 272 | #[derivative(Debug, Clone, PartialEq)] 273 | pub struct GetValidatorStats { 274 | #[tl(flags)] 275 | pub mode: (), 276 | pub id: BlockIdExt, 277 | pub limit: u32, 278 | #[tl(flags_bit = "mode.0")] 279 | pub start_after: Option, 280 | #[tl(flags_bit = "mode.2")] 281 | pub modified_after: Option, 282 | } 283 | 284 | #[derive(TlRead, TlWrite, Derivative)] 285 | #[derivative(Debug, Clone, PartialEq)] 286 | pub struct GetLibraries { 287 | pub library_list: Vec, 288 | } 289 | 290 | #[derive(TlRead, TlWrite, Derivative)] 291 | #[derivative(Debug, Clone, PartialEq)] 292 | pub struct GetLibrariesWithProof { 293 | pub id: BlockIdExt, 294 | #[tl(flags)] 295 | pub mode: (), 296 | pub library_list: Vec, 297 | } 298 | 299 | #[derive(TlRead, TlWrite, Derivative)] 300 | #[derivative(Debug, Clone, PartialEq)] 301 | pub struct GetShardBlockProof { 302 | pub id: BlockIdExt, 303 | } 304 | 305 | #[derive(TlRead, TlWrite, Derivative)] 306 | #[derivative(Debug, Clone, PartialEq)] 307 | pub struct GetOutMsgQueueSizes { 308 | #[tl(flags)] 309 | pub mode: (), 310 | #[tl(flags_bit = "mode.0")] 311 | pub shard_id: Option<(u32, u64)>, 312 | } 313 | 314 | #[derive(TlRead, TlWrite, Derivative)] 315 | #[derivative(Debug, Clone, PartialEq)] 316 | pub struct GetBlockOutMsgQueueSize { 317 | #[tl(flags)] 318 | pub mode: (), 319 | pub id: BlockIdExt, 320 | #[tl(flags_bit = "mode.0")] 321 | pub want_proof: Option<()>, 322 | } 323 | 324 | #[derive(TlRead, TlWrite, Derivative)] 325 | #[derivative(Debug, Clone, PartialEq)] 326 | pub struct GetDispatchQueueInfo { 327 | #[tl(flags)] 328 | pub mode: (), 329 | pub id: BlockIdExt, 330 | #[tl(flags_bit = "mode.0")] 331 | pub want_proof: Option<()>, 332 | #[tl(flags_bit = "mode.1")] 333 | pub after_addr: Option, 334 | pub max_accounts: u32, 335 | } 336 | 337 | #[derive(TlRead, TlWrite, Derivative)] 338 | #[derivative(Debug, Clone, PartialEq)] 339 | pub struct GetDispatchQueueMessages { 340 | #[tl(flags)] 341 | pub mode: (), 342 | pub id: BlockIdExt, 343 | pub addr: Int256, 344 | pub after_lt: u64, 345 | pub max_messages: u32, 346 | #[tl(flags_bit = "mode.0")] 347 | pub want_proof: Option<()>, 348 | #[tl(flags_bit = "mode.1")] 349 | pub one_account: Option<()>, 350 | #[tl(flags_bit = "mode.2")] 351 | pub message_boc: Option<()>, 352 | } 353 | 354 | #[derive(TlRead, TlWrite, Derivative)] 355 | #[derivative(Debug, Clone, PartialEq)] 356 | #[tl(boxed)] 357 | pub enum Request { 358 | /// liteServer.getMasterchainInfo = liteServer.MasterchainInfo; 359 | #[tl(id = 0x89b5e62e)] 360 | GetMasterchainInfo, 361 | 362 | /// liteServer.getMasterchainInfoExt mode:# = liteServer.MasterchainInfoExt; 363 | #[tl(id = 0x70a671df)] 364 | GetMasterchainInfoExt(GetMasterchainInfoExt), 365 | 366 | /// liteServer.getTime = liteServer.CurrentTime; 367 | #[tl(id = 0x16ad5a34)] 368 | GetTime, 369 | 370 | /// liteServer.getVersion = liteServer.Version; 371 | #[tl(id = 0x232b940b)] 372 | GetVersion, 373 | 374 | /// liteServer.getBlock id:tonNode.blockIdExt = liteServer.BlockData; 375 | #[tl(id = 0x6377cf0d)] 376 | GetBlock(GetBlock), 377 | 378 | /// liteServer.getState id:tonNode.blockIdExt = liteServer.BlockState; 379 | #[tl(id = 0xba6e2eb6)] 380 | GetState(GetState), 381 | 382 | /// liteServer.getBlockHeader id:tonNode.blockIdExt mode:# = liteServer.BlockHeader; 383 | #[tl(id = 0x21ec069e)] 384 | GetBlockHeader(GetBlockHeader), 385 | 386 | /// liteServer.sendMessage body:bytes = liteServer.SendMsgStatus; 387 | #[tl(id = 0x690ad482)] 388 | SendMessage(SendMessage), 389 | 390 | /// liteServer.getAccountState id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; 391 | #[tl(id = 0x6b890e25)] 392 | GetAccountState(GetAccountState), 393 | 394 | /// liteServer.getAccountStatePrunned id:tonNode.blockIdExt account:liteServer.accountId = liteServer.AccountState; 395 | #[tl(id = 0x5a698507)] 396 | GetAccountStatePrunned(GetAccountState), 397 | 398 | /// liteServer.runSmcMethod mode:# id:tonNode.blockIdExt account:liteServer.accountId method_id:long params:bytes = liteServer.RunMethodResult; 399 | #[tl(id = 0x5cc65dd2)] 400 | RunSmcMethod(RunSmcMethod), 401 | 402 | /// liteServer.getShardInfo id:tonNode.blockIdExt workchain:int shard:long exact:Bool = liteServer.ShardInfo; 403 | #[tl(id = 0x46a2f425)] 404 | GetShardInfo(GetShardInfo), 405 | 406 | /// liteServer.getAllShardsInfo id:tonNode.blockIdExt = liteServer.AllShardsInfo; 407 | #[tl(id = 0x74d3fd6b)] 408 | GetAllShardsInfo(GetAllShardsInfo), 409 | 410 | /// liteServer.getOneTransaction id:tonNode.blockIdExt account:liteServer.accountId lt:long = liteServer.TransactionInfo; 411 | #[tl(id = 0xd40f24ea)] 412 | GetOneTransaction(GetOneTransaction), 413 | 414 | /// liteServer.getTransactions count:# account:liteServer.accountId lt:long hash:int256 = liteServer.TransactionList; 415 | #[tl(id = 0x1c40e7a1)] 416 | GetTransactions(GetTransactions), 417 | 418 | /// liteServer.lookupBlock mode:# id:tonNode.blockId lt:mode.1?long utime:mode.2?int = liteServer.BlockHeader; 419 | #[tl(id = 0xfac8f71e)] 420 | LookupBlock(LookupBlock), 421 | 422 | /// liteServer.lookupBlockWithProof mode:# id:tonNode.blockId mc_block_id:tonNode.blockIdExt lt:mode.1?long utime:mode.2?int = liteServer.LookupBlockResult; 423 | #[tl(id = 0x9c045ff8)] 424 | LookupBlockWithProof(LookupBlockWithProof), 425 | 426 | /// liteServer.listBlockTransactions id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactions; 427 | #[tl(id = 0xadfcc7da)] 428 | ListBlockTransactions(ListBlockTransactions), 429 | 430 | /// liteServer.listBlockTransactionsExt id:tonNode.blockIdExt mode:# count:# after:mode.7?liteServer.transactionId3 reverse_order:mode.6?true want_proof:mode.5?true = liteServer.BlockTransactionsExt; 431 | #[tl(id = 0x0079dd5c)] 432 | ListBlockTransactionsExt(ListBlockTransactions), 433 | 434 | /// liteServer.getBlockProof mode:# known_block:tonNode.blockIdExt target_block:mode.0?tonNode.blockIdExt = liteServer.PartialBlockProof; 435 | #[tl(id = 0x8aea9c44)] 436 | GetBlockProof(GetBlockProof), 437 | 438 | /// liteServer.getConfigAll mode:# id:tonNode.blockIdExt = liteServer.ConfigInfo; 439 | #[tl(id = 0x911b26b7)] 440 | GetConfigAll(GetConfigAll), 441 | 442 | /// liteServer.getConfigParams mode:# id:tonNode.blockIdExt param_list:(vector int) = liteServer.ConfigInfo; 443 | #[tl(id = 0x2a111c19)] 444 | GetConfigParams(GetConfigParams), 445 | 446 | /// liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int start_after:mode.0?int256 modified_after:mode.2?int = liteServer.ValidatorStats; 447 | #[tl(id = 0x091a58bc)] 448 | GetValidatorStats(GetValidatorStats), 449 | 450 | /// liteServer.getLibraries library_list:(vector int256) = liteServer.LibraryResult; 451 | #[tl(id = 0xd122b662)] 452 | GetLibraries(GetLibraries), 453 | 454 | /// liteServer.getLibrariesWithProof id:tonNode.blockIdExt mode:# library_list:(vector int256) = liteServer.LibraryResultWithProof; 455 | #[tl(id = 0xd97693bd)] 456 | GetLibrariesWithProof(GetLibrariesWithProof), 457 | 458 | /// liteServer.getShardBlockProof id:tonNode.blockIdExt = liteServer.ShardBlockProof; 459 | #[tl(id = 0x4ca60350)] 460 | GetShardBlockProof(GetShardBlockProof), 461 | 462 | /// liteServer.getOutMsgQueueSizes mode:# wc:mode.0?int shard:mode.0?long = liteServer.OutMsgQueueSizes; 463 | #[tl(id = 0x7bc19c36)] 464 | GetOutMsgQueueSizes(GetOutMsgQueueSizes), 465 | 466 | /// liteServer.getBlockOutMsgQueueSize mode:# id:tonNode.blockIdExt want_proof:mode.0?true = liteServer.BlockOutMsgQueueSize; 467 | #[tl(id = 0x8f6c7779)] 468 | GetBlockOutMsgQueueSize(GetBlockOutMsgQueueSize), 469 | 470 | /// liteServer.getDispatchQueueInfo mode:# id:tonNode.blockIdExt after_addr:mode.1?int256 max_accounts:int want_proof:mode.0?true = liteServer.DispatchQueueInfo; 471 | #[tl(id = 0x01e66bf3)] 472 | GetDispatchQueueInfo(GetDispatchQueueInfo), 473 | 474 | /// liteServer.getDispatchQueueMessages mode:# id:tonNode.blockIdExt addr:int256 after_lt:long max_messages:int want_proof:mode.0?true one_account:mode.1?true messages_boc:mode.2?true = liteServer.DispatchQueueMessages; 475 | #[tl(id = 0xbbfd6439)] 476 | GetDispatchQueueMessages(GetDispatchQueueMessages), 477 | } 478 | -------------------------------------------------------------------------------- /liteapi/src/tl/response.rs: -------------------------------------------------------------------------------- 1 | use derivative::Derivative; 2 | use tl_proto::{TlRead, TlWrite}; 3 | 4 | use super::common::*; 5 | use super::utils::*; 6 | 7 | #[derive(TlRead, TlWrite, Derivative)] 8 | #[derivative(Debug, Clone, PartialEq)] 9 | pub struct MasterchainInfo { 10 | pub last: BlockIdExt, 11 | pub state_root_hash: Int256, 12 | pub init: ZeroStateIdExt, 13 | } 14 | 15 | #[derive(TlRead, TlWrite, Derivative)] 16 | #[derivative(Debug, Clone, PartialEq)] 17 | pub struct MasterchainInfoExt { 18 | #[tl(flags)] 19 | pub mode: (), 20 | pub version: u32, 21 | pub capabilities: u64, 22 | pub last: BlockIdExt, 23 | pub last_utime: u32, 24 | pub now: u32, 25 | pub state_root_hash: Int256, 26 | pub init: ZeroStateIdExt, 27 | } 28 | 29 | #[derive(TlRead, TlWrite, Derivative)] 30 | #[derivative(Debug, Clone, PartialEq)] 31 | pub struct CurrentTime { 32 | pub now: u32, 33 | } 34 | 35 | #[derive(TlRead, TlWrite, Derivative)] 36 | #[derivative(Debug, Clone, PartialEq)] 37 | pub struct Version { 38 | pub mode: u32, 39 | pub version: u32, 40 | pub capabilities: u64, 41 | pub now: u32, 42 | } 43 | 44 | #[derive(TlRead, TlWrite, Derivative)] 45 | #[derivative(Debug, Clone, PartialEq)] 46 | pub struct BlockData { 47 | pub id: BlockIdExt, 48 | #[derivative(Debug(format_with="fmt_bytes"))] 49 | pub data: Vec, 50 | } 51 | 52 | #[derive(TlRead, TlWrite, Derivative)] 53 | #[derivative(Debug, Clone, PartialEq)] 54 | pub struct BlockState { 55 | pub id: BlockIdExt, 56 | pub root_hash: Int256, 57 | pub file_hash: Int256, 58 | #[derivative(Debug(format_with="fmt_bytes"))] 59 | pub data: Vec, 60 | } 61 | 62 | #[derive(TlRead, TlWrite, Derivative)] 63 | #[derivative(Debug, Clone, PartialEq)] 64 | pub struct BlockHeader { 65 | pub id: BlockIdExt, 66 | #[tl(flags)] 67 | pub mode: (), 68 | #[tl(flags_bit = "mode.0")] 69 | pub with_state_update: Option<()>, 70 | #[tl(flags_bit = "mode.1")] 71 | pub with_value_flow: Option<()>, 72 | #[tl(flags_bit = "mode.4")] 73 | pub with_extra: Option<()>, 74 | #[tl(flags_bit = "mode.5")] 75 | pub with_shard_hashes: Option<()>, 76 | #[tl(flags_bit = "mode.6")] 77 | pub with_prev_blk_signatures: Option<()>, 78 | #[derivative(Debug(format_with="fmt_bytes"))] 79 | pub header_proof: Vec, 80 | } 81 | 82 | #[derive(TlRead, TlWrite, Derivative)] 83 | #[derivative(Debug, Clone, PartialEq)] 84 | pub struct SendMsgStatus { 85 | pub status: u32, 86 | } 87 | 88 | #[derive(TlRead, TlWrite, Derivative)] 89 | #[derivative(Debug, Clone, PartialEq)] 90 | pub struct AccountState { 91 | pub id: BlockIdExt, 92 | pub shardblk: BlockIdExt, 93 | #[derivative(Debug(format_with = "fmt_bytes"))] 94 | pub shard_proof: Vec, 95 | #[derivative(Debug(format_with = "fmt_bytes"))] 96 | pub proof: Vec, 97 | #[derivative(Debug(format_with = "fmt_bytes"))] 98 | pub state: Vec, 99 | } 100 | 101 | #[derive(TlRead, TlWrite, Derivative)] 102 | #[derivative(Debug, Clone, PartialEq)] 103 | pub struct RunMethodResult { 104 | #[tl(flags)] 105 | pub mode: (), 106 | pub id: BlockIdExt, 107 | pub shardblk: BlockIdExt, 108 | #[tl(flags_bit = "mode.0")] 109 | #[derivative(Debug(format_with="fmt_opt_bytes"))] 110 | pub shard_proof: Option>, 111 | #[tl(flags_bit = "mode.0")] 112 | #[derivative(Debug(format_with="fmt_opt_bytes"))] 113 | pub proof: Option>, 114 | #[tl(flags_bit = "mode.1")] 115 | #[derivative(Debug(format_with="fmt_opt_bytes"))] 116 | pub state_proof: Option>, 117 | #[tl(flags_bit = "mode.3")] 118 | #[derivative(Debug(format_with="fmt_opt_bytes"))] 119 | pub init_c7: Option>, 120 | #[tl(flags_bit = "mode.4")] 121 | #[derivative(Debug(format_with="fmt_opt_bytes"))] 122 | pub lib_extras: Option>, 123 | pub exit_code: i32, 124 | #[tl(flags_bit = "mode.2")] 125 | #[derivative(Debug(format_with="fmt_opt_bytes"))] 126 | pub result: Option>, 127 | } 128 | 129 | #[derive(TlRead, TlWrite, Derivative)] 130 | #[derivative(Debug, Clone, PartialEq)] 131 | pub struct ShardInfo { 132 | pub id: BlockIdExt, 133 | pub shardblk: BlockIdExt, 134 | #[derivative(Debug(format_with = "fmt_bytes"))] 135 | pub shard_proof: Vec, 136 | #[derivative(Debug(format_with = "fmt_bytes"))] 137 | pub shard_descr: Vec, 138 | } 139 | 140 | #[derive(TlRead, TlWrite, Derivative)] 141 | #[derivative(Debug, Clone, PartialEq)] 142 | pub struct AllShardsInfo { 143 | pub id: BlockIdExt, 144 | #[derivative(Debug(format_with = "fmt_bytes"))] 145 | pub proof: Vec, 146 | #[derivative(Debug(format_with = "fmt_bytes"))] 147 | pub data: Vec, 148 | } 149 | 150 | #[derive(TlRead, TlWrite, Derivative)] 151 | #[derivative(Debug, Clone, PartialEq)] 152 | pub struct TransactionInfo { 153 | pub id: BlockIdExt, 154 | #[derivative(Debug(format_with = "fmt_bytes"))] 155 | pub proof: Vec, 156 | #[derivative(Debug(format_with = "fmt_bytes"))] 157 | pub transaction: Vec, 158 | } 159 | 160 | #[derive(TlRead, TlWrite, Derivative)] 161 | #[derivative(Debug, Clone, PartialEq)] 162 | pub struct TransactionList { 163 | pub ids: Vec, 164 | #[derivative(Debug(format_with = "fmt_bytes"))] 165 | pub transactions: Vec, 166 | } 167 | 168 | #[derive(TlRead, TlWrite, Derivative)] 169 | #[derivative(Debug, Clone, PartialEq)] 170 | pub struct TransactionMetadata { 171 | #[tl(flags)] 172 | mode: (), 173 | depth: u32, 174 | initiator: AccountId, 175 | initiator_lt: u64, 176 | } 177 | 178 | #[derive(TlRead, TlWrite, Derivative)] 179 | #[derivative(Debug, Clone, PartialEq)] 180 | pub struct TransactionId { 181 | #[tl(flags)] 182 | pub mode: (), 183 | #[tl(flags_bit = "mode.0")] 184 | pub account: Option, 185 | #[tl(flags_bit = "mode.1")] 186 | pub lt: Option, 187 | #[tl(flags_bit = "mode.2")] 188 | pub hash: Option, 189 | #[tl(flags_bit = "mode.8")] 190 | pub metadata: Option, 191 | } 192 | 193 | #[derive(TlRead, TlWrite, Derivative)] 194 | #[derivative(Debug, Clone, PartialEq)] 195 | pub struct BlockTransactions { 196 | pub id: BlockIdExt, 197 | pub req_count: u32, 198 | pub incomplete: bool, 199 | pub ids: Vec, 200 | #[derivative(Debug(format_with = "fmt_bytes"))] 201 | pub proof: Vec, 202 | } 203 | 204 | #[derive(TlRead, TlWrite, Derivative)] 205 | #[derivative(Debug, Clone, PartialEq)] 206 | pub struct BlockTransactionsExt { 207 | pub id: BlockIdExt, 208 | pub req_count: u32, 209 | pub incomplete: bool, 210 | #[derivative(Debug(format_with = "fmt_bytes"))] 211 | pub transactions: Vec, 212 | #[derivative(Debug(format_with = "fmt_bytes"))] 213 | pub proof: Vec, 214 | } 215 | 216 | #[derive(TlRead, TlWrite, Derivative)] 217 | #[derivative(Debug, Clone, PartialEq)] 218 | pub struct PartialBlockProof { 219 | pub complete: bool, 220 | pub from: BlockIdExt, 221 | pub to: BlockIdExt, 222 | pub steps: Vec, 223 | } 224 | 225 | #[derive(TlRead, TlWrite, Derivative)] 226 | #[derivative(Debug, Clone, PartialEq)] 227 | pub struct ConfigInfo { 228 | #[tl(flags)] 229 | pub mode: (), 230 | pub id: BlockIdExt, 231 | #[derivative(Debug(format_with = "fmt_bytes"))] 232 | pub state_proof: Vec, 233 | #[derivative(Debug(format_with = "fmt_bytes"))] 234 | pub config_proof: Vec, 235 | #[tl(flags_bit = "mode.0")] 236 | pub with_state_root: Option<()>, 237 | #[tl(flags_bit = "mode.1")] 238 | pub with_libraries: Option<()>, 239 | #[tl(flags_bit = "mode.2")] 240 | pub with_state_extra_root: Option<()>, 241 | #[tl(flags_bit = "mode.3")] 242 | pub with_shard_hashes: Option<()>, 243 | #[tl(flags_bit = "mode.4")] 244 | pub with_validator_set: Option<()>, 245 | #[tl(flags_bit = "mode.5")] 246 | pub with_special_smc: Option<()>, 247 | #[tl(flags_bit = "mode.6")] 248 | pub with_accounts_root: Option<()>, 249 | #[tl(flags_bit = "mode.7")] 250 | pub with_prev_blocks: Option<()>, 251 | #[tl(flags_bit = "mode.8")] 252 | pub with_workchain_info: Option<()>, 253 | #[tl(flags_bit = "mode.9")] 254 | pub with_capabilities: Option<()>, 255 | #[tl(flags_bit = "mode.15")] 256 | pub extract_from_key_block: Option<()>, 257 | } 258 | 259 | #[derive(TlRead, TlWrite, Derivative)] 260 | #[derivative(Debug, Clone, PartialEq)] 261 | pub struct ValidatorStats { 262 | #[tl(flags)] 263 | pub mode: (), 264 | pub id: BlockIdExt, 265 | pub count: u32, 266 | pub complete: bool, 267 | #[derivative(Debug(format_with = "fmt_bytes"))] 268 | pub state_proof: Vec, 269 | #[derivative(Debug(format_with = "fmt_bytes"))] 270 | pub data_proof: Vec, 271 | } 272 | 273 | #[derive(TlRead, TlWrite, Derivative)] 274 | #[derivative(Debug, Clone, PartialEq)] 275 | pub struct LibraryResult { 276 | pub result: Vec, 277 | } 278 | 279 | #[derive(TlRead, TlWrite, Derivative)] 280 | #[derivative(Debug, Clone, PartialEq)] 281 | pub struct LibraryResultWithProof { 282 | pub id: BlockIdExt, 283 | #[tl(flags)] 284 | pub mode: (), 285 | pub result: Vec, 286 | #[derivative(Debug(format_with = "fmt_bytes"))] 287 | pub state_proof: Vec, 288 | #[derivative(Debug(format_with = "fmt_bytes"))] 289 | pub data_proof: Vec, 290 | } 291 | 292 | #[derive(TlRead, TlWrite, Derivative)] 293 | #[derivative(Debug, Clone, PartialEq)] 294 | pub struct ShardBlockLink { 295 | pub id: BlockIdExt, 296 | #[derivative(Debug(format_with = "fmt_bytes"))] 297 | pub proof: Vec, 298 | } 299 | 300 | #[derive(TlRead, TlWrite, Derivative)] 301 | #[derivative(Debug, Clone, PartialEq)] 302 | pub struct ShardBlockProof { 303 | pub masterchain_id: BlockIdExt, 304 | pub links: Vec, 305 | } 306 | 307 | #[derive(TlRead, TlWrite, Derivative)] 308 | #[derivative(Debug, Clone, PartialEq)] 309 | pub struct LookupBlockResult { 310 | pub id: BlockIdExt, 311 | #[tl(flags)] 312 | pub mode: (), 313 | pub mc_block_id: BlockIdExt, 314 | #[derivative(Debug(format_with = "fmt_bytes"))] 315 | pub client_mc_state_proof: Vec, 316 | #[derivative(Debug(format_with = "fmt_bytes"))] 317 | pub mc_block_proof: Vec, 318 | pub shard_links: Vec, 319 | #[derivative(Debug(format_with = "fmt_bytes"))] 320 | pub header: Vec, 321 | #[derivative(Debug(format_with = "fmt_bytes"))] 322 | pub prev_header: Vec, 323 | } 324 | 325 | #[derive(TlRead, TlWrite, Derivative)] 326 | #[derivative(Debug, Clone, PartialEq)] 327 | pub struct OutMsgQueueSize { 328 | pub id: BlockIdExt, 329 | pub size: u32, 330 | } 331 | 332 | #[derive(TlRead, TlWrite, Derivative)] 333 | #[derivative(Debug, Clone, PartialEq)] 334 | pub struct OutMsgQueueSizes { 335 | pub shards: Vec, 336 | pub ext_msg_queue_size_limit: u32, 337 | } 338 | 339 | #[derive(TlRead, TlWrite, Derivative)] 340 | #[derivative(Debug, Clone, PartialEq)] 341 | pub struct BlockOutMsgQueueSize { 342 | #[tl(flags)] 343 | pub mode: (), 344 | pub id: BlockIdExt, 345 | pub size: u64, 346 | #[tl(flags_bit = "mode.0")] 347 | #[derivative(Debug(format_with = "fmt_opt_bytes"))] 348 | pub proof: Option>, 349 | } 350 | 351 | #[derive(TlRead, TlWrite, Derivative)] 352 | #[derivative(Debug, Clone, PartialEq)] 353 | pub struct AccountDispatchQueueInfo { 354 | pub addr: Int256, 355 | pub size: u64, 356 | pub min_lt: u64, 357 | pub max_lt: u64, 358 | } 359 | 360 | #[derive(TlRead, TlWrite, Derivative)] 361 | #[derivative(Debug, Clone, PartialEq)] 362 | pub struct DispatchQueueInfo { 363 | #[tl(flags)] 364 | pub mode: (), 365 | pub id: BlockIdExt, 366 | pub account_dispatch_queues: Vec, 367 | pub complete: bool, 368 | #[tl(flags_bit = "mode.0")] 369 | #[derivative(Debug(format_with = "fmt_opt_bytes"))] 370 | pub proof: Option>, 371 | } 372 | 373 | #[derive(TlRead, TlWrite, Derivative)] 374 | #[derivative(Debug, Clone, PartialEq)] 375 | pub struct DispatchQueueMessage { 376 | pub addr: Int256, 377 | pub lt: u64, 378 | pub hash: Int256, 379 | pub metadata: TransactionMetadata, 380 | } 381 | 382 | #[derive(TlRead, TlWrite, Derivative)] 383 | #[derivative(Debug, Clone, PartialEq)] 384 | pub struct DispatchQueueMessages { 385 | #[tl(flags)] 386 | pub mode: (), 387 | pub id: BlockIdExt, 388 | pub messages: Vec, 389 | pub complete: bool, 390 | #[tl(flags_bit = "mode.0")] 391 | #[derivative(Debug(format_with = "fmt_opt_bytes"))] 392 | pub proof: Option>, 393 | #[tl(flags_bit = "mode.2")] 394 | #[derivative(Debug(format_with = "fmt_opt_bytes"))] 395 | pub messages_boc: Option>, 396 | } 397 | 398 | #[derive(TlRead, TlWrite, Derivative)] 399 | #[derivative(Debug, Clone, PartialEq)] 400 | pub struct Error { 401 | pub code: i32, 402 | #[derivative(Debug(format_with = "String::fmt"))] 403 | pub message: String, 404 | } 405 | 406 | #[derive(TlRead, TlWrite, Derivative)] 407 | #[derivative(Debug, Clone, PartialEq)] 408 | #[tl(boxed)] 409 | pub enum Response { 410 | /// liteServer.masterchainInfo last:tonNode.blockIdExt state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfo; 411 | #[tl(id = 0x85832881)] 412 | MasterchainInfo(MasterchainInfo), 413 | 414 | /// liteServer.masterchainInfoExt mode:# version:int capabilities:long last:tonNode.blockIdExt last_utime:int now:int state_root_hash:int256 init:tonNode.zeroStateIdExt = liteServer.MasterchainInfoExt; 415 | #[tl(id = 0xa8cce0f5)] 416 | MasterchainInfoExt(MasterchainInfoExt), 417 | 418 | /// liteServer.currentTime now:int = liteServer.CurrentTime; 419 | #[tl(id = 0xe953000d)] 420 | CurrentTime(CurrentTime), 421 | 422 | /// liteServer.version mode:# version:int capabilities:long now:int = liteServer.Version; 423 | #[tl(id = 0x5a0491e5)] 424 | Version(Version), 425 | 426 | /// liteServer.blockData id:tonNode.blockIdExt data:bytes = liteServer.BlockData; 427 | #[tl(id = 0xa574ed6c)] 428 | BlockData(BlockData), 429 | 430 | /// liteServer.blockState id:tonNode.blockIdExt root_hash:int256 file_hash:int256 data:bytes = liteServer.BlockState; 431 | #[tl(id = 0xabaddc0c)] 432 | BlockState(BlockState), 433 | 434 | /// liteServer.blockHeader id:tonNode.blockIdExt mode:# header_proof:bytes = liteServer.BlockHeader; 435 | #[tl(id = 0x752d8219)] 436 | BlockHeader(BlockHeader), 437 | 438 | /// liteServer.sendMsgStatus status:int = liteServer.SendMsgStatus; 439 | #[tl(id = 0x3950e597)] 440 | SendMsgStatus(SendMsgStatus), 441 | 442 | /// liteServer.accountState id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes proof:bytes state:bytes = liteServer.AccountState; 443 | #[tl(id = 0x7079c751)] 444 | AccountState(AccountState), 445 | 446 | /// liteServer.runMethodResult mode:# id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:mode.0?bytes proof:mode.0?bytes state_proof:mode.1?bytes init_c7:mode.3?bytes lib_extras:mode.4?bytes exit_code:int result:mode.2?bytes = liteServer.RunMethodResult; 447 | #[tl(id = 0xa39a616b)] 448 | RunMethodResult(RunMethodResult), 449 | 450 | /// liteServer.shardInfo id:tonNode.blockIdExt shardblk:tonNode.blockIdExt shard_proof:bytes shard_descr:bytes = liteServer.ShardInfo; 451 | #[tl(id = 0x9fe6cd84)] 452 | ShardInfo(ShardInfo), 453 | 454 | /// liteServer.allShardsInfo id:tonNode.blockIdExt proof:bytes data:bytes = liteServer.AllShardsInfo; 455 | #[tl(id = 0x098fe72d)] 456 | AllShardsInfo(AllShardsInfo), 457 | 458 | /// liteServer.transactionInfo id:tonNode.blockIdExt proof:bytes transaction:bytes = liteServer.TransactionInfo; 459 | #[tl(id = 0x0edeed47)] 460 | TransactionInfo(TransactionInfo), 461 | 462 | /// liteServer.transactionList ids:(vector tonNode.blockIdExt) transactions:bytes = liteServer.TransactionList; 463 | #[tl(id = 0x6f26c60b)] 464 | TransactionList(TransactionList), 465 | 466 | /// liteServer.transactionId mode:# account:mode.0?int256 lt:mode.1?long hash:mode.2?int256 metadata:mode.8?liteServer.transactionMetadata = liteServer.TransactionId; 467 | #[tl(id = 0xb12f65af)] 468 | TransactionId(TransactionId), 469 | 470 | /// liteServer.blockTransactions id:tonNode.blockIdExt req_count:# incomplete:Bool ids:(vector liteServer.transactionId) proof:bytes = liteServer.BlockTransactions; 471 | #[tl(id = 0xbd8cad2b)] 472 | BlockTransactions(BlockTransactions), 473 | 474 | /// liteServer.partialBlockProof complete:Bool from:tonNode.blockIdExt to:tonNode.blockIdExt steps:(vector liteServer.BlockLink) = liteServer.PartialBlockProof; 475 | #[tl(id = 0x8ed0d2c1)] 476 | PartialBlockProof(PartialBlockProof), 477 | 478 | /// liteServer.configInfo mode:# id:tonNode.blockIdExt state_proof:bytes config_proof:bytes = liteServer.ConfigInfo; 479 | #[tl(id = 0xae7b272f)] 480 | ConfigInfo(ConfigInfo), 481 | 482 | /// liteServer.validatorStats mode:# id:tonNode.blockIdExt count:int complete:Bool state_proof:bytes data_proof:bytes = liteServer.ValidatorStats; 483 | #[tl(id = 0xb9f796d8)] 484 | ValidatorStats(ValidatorStats), 485 | 486 | /// liteServer.libraryResult result:(vector liteServer.libraryEntry) = liteServer.LibraryResult; 487 | #[tl(id = 0x117ab96b)] 488 | LibraryResult(LibraryResult), 489 | 490 | /// liteServer.libraryResult result:(vector liteServer.libraryEntry) = liteServer.LibraryResult; 491 | #[tl(id = 0x10a927bf)] 492 | LibraryResultWithProof(LibraryResultWithProof), 493 | 494 | /// liteServer.shardBlockProof masterchain_id:tonNode.blockIdExt links:(vector liteServer.shardBlockLink) = liteServer.ShardBlockProof; 495 | #[tl(id = 0x1d62a07a)] 496 | ShardBlockProof(ShardBlockProof), 497 | 498 | /// liteServer.lookupBlockResult id:tonNode.blockIdExt mode:# mc_block_id:tonNode.blockIdExt client_mc_state_proof:bytes mc_block_proof:bytes shard_links:(vector liteServer.shardBlockLink) header:bytes prev_header:bytes = liteServer.LookupBlockResult; 499 | #[tl(id = 0x99786be7)] 500 | LookupBlockResult(LookupBlockResult), 501 | 502 | /// liteServer.outMsgQueueSizes shards:(vector liteServer.outMsgQueueSize) ext_msg_queue_size_limit:int = liteServer.OutMsgQueueSizes; 503 | #[tl(id = 0xf8504a03)] 504 | OutMsgQueueSizes(OutMsgQueueSizes), 505 | 506 | /// liteServer.blockOutMsgQueueSize mode:# id:tonNode.blockIdExt size:long proof:mode.0?bytes = liteServer.BlockOutMsgQueueSize; 507 | #[tl(id = 0x8acdbe1b)] 508 | BlockOutMsgQueueSize(BlockOutMsgQueueSize), 509 | 510 | /// liteServer.dispatchQueueInfo mode:# id:tonNode.blockIdExt account_dispatch_queues:(vector liteServer.accountDispatchQueueInfo) complete:Bool proof:mode.0?bytes = liteServer.DispatchQueueInfo; 511 | #[tl(id = 0x5d1132d0)] 512 | DispatchQueueInfo(DispatchQueueInfo), 513 | 514 | /// liteServer.dispatchQueueMessages mode:# id:tonNode.blockIdExt messages:(vector liteServer.dispatchQueueMessage) complete:Bool proof:mode.0?bytes messages_boc:mode.2?bytes = liteServer.DispatchQueueMessages; 515 | #[tl(id = 0x4b407931)] 516 | DispatchQueueMessages(DispatchQueueMessages), 517 | 518 | /// liteServer.error code:int message:string = liteServer.Error; 519 | #[tl(id = 0xbba9e148)] 520 | Error(Error), 521 | } -------------------------------------------------------------------------------- /liteapi/src/tl/tests.rs: -------------------------------------------------------------------------------- 1 | use std::error::Error; 2 | 3 | use tests::{adnl::Message, common::Int256, request::WrappedRequest}; 4 | 5 | use crate::tl::*; 6 | 7 | use self::request::Request; 8 | 9 | #[test] 10 | fn test_time() -> Result<(), Box> { 11 | let raw = hex::decode("7af98bb435263e6c95d6fecb497dfd0aa5f031e7d412986b5ce720496db512052e8f2d100cdf068c7904345aad16000000000000")?; 12 | let message = Message::Query { 13 | query_id: Int256::from_hex("35263e6c95d6fecb497dfd0aa5f031e7d412986b5ce720496db512052e8f2d10")?, 14 | query: request::LiteQuery { 15 | wrapped_request: WrappedRequest { 16 | request: Request::GetTime, 17 | wait_masterchain_seqno: None, 18 | } 19 | } 20 | }; 21 | let constructed = tl_proto::serialize(message.clone()); 22 | assert_eq!(raw, constructed); 23 | let deserialized = tl_proto::deserialize::(raw.as_slice())?; 24 | assert_eq!(deserialized, message); 25 | Ok(()) 26 | } -------------------------------------------------------------------------------- /liteapi/src/tl/utils.rs: -------------------------------------------------------------------------------- 1 | use tl_proto::{TlRead, TlResult}; 2 | 3 | use crate::types::LiteError; 4 | 5 | use super::response::*; 6 | 7 | pub fn lossy_read<'tl, T: TlRead<'tl>>(packet: &'tl [u8], offset: &mut usize) -> TlResult> { 8 | let orig_offset = *offset; 9 | let result = T::read_from(packet, offset); 10 | if let Ok(x) = result { 11 | Ok(Some(x)) 12 | } else { 13 | *offset = orig_offset; 14 | Ok(None) 15 | } 16 | } 17 | 18 | pub fn fmt_string(bytes: &[u8], f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { 19 | write!( 20 | f, 21 | "{}", 22 | std::string::String::from_utf8(bytes.to_vec()).unwrap() 23 | ) 24 | } 25 | 26 | pub fn fmt_bytes(bytes: &[u8], f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { 27 | write!(f, "0x{}", hex::encode(bytes)) 28 | } 29 | 30 | pub fn fmt_opt_bytes>(bytes: &Option, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { 31 | if let Some(bytes) = bytes { 32 | write!(f, "Some(0x{})", hex::encode(bytes)) 33 | } else { 34 | write!(f, "None") 35 | } 36 | } 37 | 38 | pub mod struct_as_bytes { 39 | use tl_proto::{TlPacket, TlRead, TlResult, TlWrite}; 40 | 41 | pub fn size_hint(v: &T) -> usize { 42 | tl_proto::serialize(v).len() 43 | } 44 | 45 | pub fn write(v: &T, packet: &mut P) { 46 | tl_proto::serialize(v).write_to(packet) 47 | } 48 | 49 | pub fn read<'tl, T: TlRead<'tl>>(packet: &'tl [u8], offset: &mut usize) -> TlResult { 50 | <&'tl [u8]>::read_from(packet, offset).and_then(|x| tl_proto::deserialize(x)) 51 | } 52 | } 53 | 54 | pub trait FromResponse: Sized { 55 | fn from_response(response: Response) -> Result; 56 | } 57 | 58 | impl FromResponse for MasterchainInfo { 59 | fn from_response(response: Response) -> Result { 60 | match response { 61 | Response::MasterchainInfo(s) => Ok(s), 62 | _ => Err(LiteError::UnexpectedMessage) 63 | } 64 | } 65 | } 66 | 67 | impl FromResponse for MasterchainInfoExt { 68 | fn from_response(response: Response) -> Result { 69 | match response { 70 | Response::MasterchainInfoExt(s) => Ok(s), 71 | _ => Err(LiteError::UnexpectedMessage) 72 | } 73 | } 74 | } 75 | 76 | impl FromResponse for CurrentTime { 77 | fn from_response(response: Response) -> Result { 78 | match response { 79 | Response::CurrentTime(s) => Ok(s), 80 | _ => Err(LiteError::UnexpectedMessage) 81 | } 82 | } 83 | } 84 | 85 | impl FromResponse for Version { 86 | fn from_response(response: Response) -> Result { 87 | match response { 88 | Response::Version(s) => Ok(s), 89 | _ => Err(LiteError::UnexpectedMessage) 90 | } 91 | } 92 | } 93 | 94 | impl FromResponse for BlockData { 95 | fn from_response(response: Response) -> Result { 96 | match response { 97 | Response::BlockData(s) => Ok(s), 98 | _ => Err(LiteError::UnexpectedMessage) 99 | } 100 | } 101 | } 102 | 103 | impl FromResponse for BlockState { 104 | fn from_response(response: Response) -> Result { 105 | match response { 106 | Response::BlockState(s) => Ok(s), 107 | _ => Err(LiteError::UnexpectedMessage) 108 | } 109 | } 110 | } 111 | 112 | impl FromResponse for BlockHeader { 113 | fn from_response(response: Response) -> Result { 114 | match response { 115 | Response::BlockHeader(s) => Ok(s), 116 | _ => Err(LiteError::UnexpectedMessage) 117 | } 118 | } 119 | } 120 | 121 | impl FromResponse for SendMsgStatus { 122 | fn from_response(response: Response) -> Result { 123 | match response { 124 | Response::SendMsgStatus(s) => Ok(s), 125 | _ => Err(LiteError::UnexpectedMessage) 126 | } 127 | } 128 | } 129 | 130 | impl FromResponse for AccountState { 131 | fn from_response(response: Response) -> Result { 132 | match response { 133 | Response::AccountState(s) => Ok(s), 134 | _ => Err(LiteError::UnexpectedMessage) 135 | } 136 | } 137 | } 138 | 139 | impl FromResponse for RunMethodResult { 140 | fn from_response(response: Response) -> Result { 141 | match response { 142 | Response::RunMethodResult(s) => Ok(s), 143 | _ => Err(LiteError::UnexpectedMessage) 144 | } 145 | } 146 | } 147 | 148 | impl FromResponse for ShardInfo { 149 | fn from_response(response: Response) -> Result { 150 | match response { 151 | Response::ShardInfo(s) => Ok(s), 152 | _ => Err(LiteError::UnexpectedMessage) 153 | } 154 | } 155 | } 156 | 157 | impl FromResponse for AllShardsInfo { 158 | fn from_response(response: Response) -> Result { 159 | match response { 160 | Response::AllShardsInfo(s) => Ok(s), 161 | _ => Err(LiteError::UnexpectedMessage) 162 | } 163 | } 164 | } 165 | 166 | impl FromResponse for TransactionInfo { 167 | fn from_response(response: Response) -> Result { 168 | match response { 169 | Response::TransactionInfo(s) => Ok(s), 170 | _ => Err(LiteError::UnexpectedMessage) 171 | } 172 | } 173 | } 174 | 175 | impl FromResponse for TransactionList { 176 | fn from_response(response: Response) -> Result { 177 | match response { 178 | Response::TransactionList(s) => Ok(s), 179 | _ => Err(LiteError::UnexpectedMessage) 180 | } 181 | } 182 | } 183 | 184 | impl FromResponse for TransactionId { 185 | fn from_response(response: Response) -> Result { 186 | match response { 187 | Response::TransactionId(s) => Ok(s), 188 | _ => Err(LiteError::UnexpectedMessage) 189 | } 190 | } 191 | } 192 | 193 | impl FromResponse for BlockTransactions { 194 | fn from_response(response: Response) -> Result { 195 | match response { 196 | Response::BlockTransactions(s) => Ok(s), 197 | _ => Err(LiteError::UnexpectedMessage) 198 | } 199 | } 200 | } 201 | 202 | impl FromResponse for PartialBlockProof { 203 | fn from_response(response: Response) -> Result { 204 | match response { 205 | Response::PartialBlockProof(s) => Ok(s), 206 | _ => Err(LiteError::UnexpectedMessage) 207 | } 208 | } 209 | } 210 | 211 | impl FromResponse for ConfigInfo { 212 | fn from_response(response: Response) -> Result { 213 | match response { 214 | Response::ConfigInfo(s) => Ok(s), 215 | _ => Err(LiteError::UnexpectedMessage) 216 | } 217 | } 218 | } 219 | 220 | impl FromResponse for ValidatorStats { 221 | fn from_response(response: Response) -> Result { 222 | match response { 223 | Response::ValidatorStats(s) => Ok(s), 224 | _ => Err(LiteError::UnexpectedMessage) 225 | } 226 | } 227 | } 228 | 229 | impl FromResponse for LibraryResult { 230 | fn from_response(response: Response) -> Result { 231 | match response { 232 | Response::LibraryResult(s) => Ok(s), 233 | _ => Err(LiteError::UnexpectedMessage) 234 | } 235 | } 236 | } 237 | 238 | impl FromResponse for Error { 239 | fn from_response(response: Response) -> Result { 240 | match response { 241 | Response::Error(s) => Ok(s), 242 | _ => Err(LiteError::UnexpectedMessage) 243 | } 244 | } 245 | } -------------------------------------------------------------------------------- /liteapi/src/types.rs: -------------------------------------------------------------------------------- 1 | use adnl::AdnlError; 2 | use thiserror::Error; 3 | use tl_proto::TlError; 4 | use tower::Service; 5 | 6 | use crate::tl::{request::WrappedRequest, response::Response}; 7 | 8 | #[derive(Debug, Error)] 9 | pub enum LiteError { 10 | #[error("Liteserver error")] 11 | ServerError(crate::tl::response::Error), 12 | #[error("TL parsing error")] 13 | TlError(TlError), 14 | #[error("Unexpected TL message")] 15 | UnexpectedMessage, 16 | #[error("ADNL error")] 17 | AdnlError(#[from] AdnlError), 18 | #[error("Unknown error")] 19 | UnknownError(#[from] Box) 20 | } 21 | 22 | pub trait LiteService: Service where Self::Future: Send + 'static {} 23 | 24 | impl LiteService for T where T: Service, T::Future: Send + 'static {} -------------------------------------------------------------------------------- /network-config/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ton_networkconfig" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "Implementation of TON config.json structures with network parameters" 6 | repository = "https://github.com/tonstack/lite-client" 7 | keywords = ["ton"] 8 | categories = ["network-programming"] 9 | license = "MIT" 10 | authors = ["Vladimir Lebedev "] 11 | 12 | [dependencies] 13 | serde = { version = "1.0.136", features = ["derive"] } 14 | serde_json = "1.0.79" 15 | serde_with = { version = "1.12.0", features = ["base64"] } -------------------------------------------------------------------------------- /network-config/src/lib.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use std::net::{Ipv4Addr, SocketAddrV4}; 3 | use std::ops::{Deref, DerefMut}; 4 | use std::str::FromStr; 5 | 6 | #[serde_with::serde_as] 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | #[serde(tag = "@type")] 9 | pub enum ConfigPublicKey { 10 | #[serde(rename = "pub.ed25519")] 11 | Ed25519 { 12 | #[serde_as(as = "serde_with::base64::Base64")] 13 | key: [u8; 32], 14 | }, 15 | } 16 | 17 | #[derive(Debug, Clone)] 18 | pub struct LiteServerAddress(Ipv4Addr); 19 | 20 | #[serde_with::serde_as] 21 | #[derive(Serialize, Deserialize, Debug)] 22 | pub struct ConfigLiteServer { 23 | #[serde_as(as = "serde_with::FromInto")] 24 | pub ip: LiteServerAddress, 25 | pub port: u16, 26 | pub id: ConfigPublicKey, 27 | } 28 | 29 | #[derive(Serialize, Deserialize, Debug)] 30 | pub struct ConfigGlobal { 31 | pub liteservers: Vec, 32 | } 33 | 34 | impl FromStr for ConfigGlobal { 35 | type Err = serde_json::Error; 36 | 37 | fn from_str(s: &str) -> Result { 38 | serde_json::from_str(s) 39 | } 40 | } 41 | 42 | impl Into<[u8; 32]> for ConfigPublicKey { 43 | fn into(self) -> [u8; 32] { 44 | match self { 45 | ConfigPublicKey::Ed25519 { key } => key, 46 | } 47 | } 48 | } 49 | 50 | impl Deref for LiteServerAddress { 51 | type Target = Ipv4Addr; 52 | 53 | fn deref(&self) -> &Self::Target { 54 | &self.0 55 | } 56 | } 57 | 58 | impl DerefMut for LiteServerAddress { 59 | fn deref_mut(&mut self) -> &mut Self::Target { 60 | &mut self.0 61 | } 62 | } 63 | 64 | impl From for LiteServerAddress { 65 | fn from(v: i32) -> Self { 66 | Self(Ipv4Addr::from(v as u32)) 67 | } 68 | } 69 | 70 | impl From for i32 { 71 | fn from(v: LiteServerAddress) -> Self { 72 | u32::from(v.0) as i32 73 | } 74 | } 75 | 76 | impl ConfigLiteServer { 77 | pub fn socket_addr(&self) -> SocketAddrV4 { 78 | SocketAddrV4::new(*self.ip, self.port) 79 | } 80 | } 81 | --------------------------------------------------------------------------------