crypto-aio 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +144 -14
- package/dist/adapters/avalanche/address.d.ts +15 -0
- package/dist/adapters/avalanche/address.js +74 -0
- package/dist/adapters/avalanche/address.js.map +1 -0
- package/dist/adapters/avalanche/api.d.ts +100 -0
- package/dist/adapters/avalanche/api.js +381 -0
- package/dist/adapters/avalanche/api.js.map +1 -0
- package/dist/adapters/avalanche/builder.d.ts +13 -0
- package/dist/adapters/avalanche/builder.js +336 -0
- package/dist/adapters/avalanche/builder.js.map +1 -0
- package/dist/adapters/avalanche/cb58.d.ts +7 -0
- package/dist/adapters/avalanche/cb58.js +49 -0
- package/dist/adapters/avalanche/cb58.js.map +1 -0
- package/dist/adapters/avalanche/chains.d.ts +21 -0
- package/dist/adapters/avalanche/chains.js +79 -0
- package/dist/adapters/avalanche/chains.js.map +1 -0
- package/dist/adapters/avalanche/codec.d.ts +94 -0
- package/dist/adapters/avalanche/codec.js +371 -0
- package/dist/adapters/avalanche/codec.js.map +1 -0
- package/dist/adapters/avalanche/context.d.ts +59 -0
- package/dist/adapters/avalanche/context.js +114 -0
- package/dist/adapters/avalanche/context.js.map +1 -0
- package/dist/adapters/avalanche/decode.d.ts +16 -0
- package/dist/adapters/avalanche/decode.js +101 -0
- package/dist/adapters/avalanche/decode.js.map +1 -0
- package/dist/adapters/avalanche/driver.d.ts +22 -0
- package/dist/adapters/avalanche/driver.js +81 -0
- package/dist/adapters/avalanche/driver.js.map +1 -0
- package/dist/adapters/avalanche/errors.d.ts +18 -0
- package/dist/adapters/avalanche/errors.js +61 -0
- package/dist/adapters/avalanche/errors.js.map +1 -0
- package/dist/adapters/avalanche/fees.d.ts +23 -0
- package/dist/adapters/avalanche/fees.js +105 -0
- package/dist/adapters/avalanche/fees.js.map +1 -0
- package/dist/adapters/avalanche/index.d.ts +19 -0
- package/dist/adapters/avalanche/index.js +8 -0
- package/dist/adapters/avalanche/index.js.map +1 -0
- package/dist/adapters/avalanche/network.d.ts +37 -0
- package/dist/adapters/avalanche/network.js +135 -0
- package/dist/adapters/avalanche/network.js.map +1 -0
- package/dist/adapters/avalanche/plugin.d.ts +21 -0
- package/dist/adapters/avalanche/plugin.js +46 -0
- package/dist/adapters/avalanche/plugin.js.map +1 -0
- package/dist/adapters/avalanche/presets.d.ts +6 -0
- package/dist/adapters/avalanche/presets.js +86 -0
- package/dist/adapters/avalanche/presets.js.map +1 -0
- package/dist/adapters/avalanche/proofs.d.ts +41 -0
- package/dist/adapters/avalanche/proofs.js +270 -0
- package/dist/adapters/avalanche/proofs.js.map +1 -0
- package/dist/adapters/avalanche/reader.d.ts +40 -0
- package/dist/adapters/avalanche/reader.js +231 -0
- package/dist/adapters/avalanche/reader.js.map +1 -0
- package/dist/adapters/avalanche/sdk.d.ts +182 -0
- package/dist/adapters/avalanche/sdk.js +21 -0
- package/dist/adapters/avalanche/sdk.js.map +1 -0
- package/dist/adapters/avalanche/types.d.ts +86 -0
- package/dist/{type/common.js → adapters/avalanche/types.js} +1 -1
- package/dist/adapters/avalanche/types.js.map +1 -0
- package/dist/adapters/evm/builder.d.ts +11 -0
- package/dist/adapters/evm/builder.js +326 -0
- package/dist/adapters/evm/builder.js.map +1 -0
- package/dist/adapters/evm/chains.d.ts +6 -0
- package/dist/adapters/evm/chains.js +203 -0
- package/dist/adapters/evm/chains.js.map +1 -0
- package/dist/adapters/evm/client.d.ts +84 -0
- package/dist/adapters/evm/client.js +335 -0
- package/dist/adapters/evm/client.js.map +1 -0
- package/dist/adapters/evm/decode.d.ts +35 -0
- package/dist/adapters/evm/decode.js +170 -0
- package/dist/adapters/evm/decode.js.map +1 -0
- package/dist/adapters/evm/driver.d.ts +8 -0
- package/dist/adapters/evm/driver.js +61 -0
- package/dist/adapters/evm/driver.js.map +1 -0
- package/dist/adapters/evm/errors.d.ts +20 -0
- package/dist/adapters/evm/errors.js +110 -0
- package/dist/adapters/evm/errors.js.map +1 -0
- package/dist/adapters/evm/ethers-client.d.ts +43 -0
- package/dist/adapters/evm/ethers-client.js +135 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -0
- package/dist/adapters/evm/fees.d.ts +79 -0
- package/dist/adapters/evm/fees.js +234 -0
- package/dist/adapters/evm/fees.js.map +1 -0
- package/dist/adapters/evm/index.d.ts +20 -0
- package/dist/adapters/evm/index.js +11 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/adapters/evm/network.d.ts +60 -0
- package/dist/adapters/evm/network.js +131 -0
- package/dist/adapters/evm/network.js.map +1 -0
- package/dist/adapters/evm/plugin.d.ts +36 -0
- package/dist/adapters/evm/plugin.js +102 -0
- package/dist/adapters/evm/plugin.js.map +1 -0
- package/dist/adapters/evm/presets.d.ts +2 -0
- package/dist/adapters/evm/presets.js +105 -0
- package/dist/adapters/evm/presets.js.map +1 -0
- package/dist/adapters/evm/proofs.d.ts +19 -0
- package/dist/adapters/evm/proofs.js +358 -0
- package/dist/adapters/evm/proofs.js.map +1 -0
- package/dist/adapters/evm/rawtx.d.ts +25 -0
- package/dist/adapters/evm/rawtx.js +176 -0
- package/dist/adapters/evm/rawtx.js.map +1 -0
- package/dist/adapters/evm/reader.d.ts +65 -0
- package/dist/adapters/evm/reader.js +292 -0
- package/dist/adapters/evm/reader.js.map +1 -0
- package/dist/adapters/evm/rpc.d.ts +39 -0
- package/dist/adapters/evm/rpc.js +152 -0
- package/dist/adapters/evm/rpc.js.map +1 -0
- package/dist/adapters/evm/tokens.d.ts +7 -0
- package/dist/adapters/evm/tokens.js +23 -0
- package/dist/adapters/evm/tokens.js.map +1 -0
- package/dist/adapters/evm/types.d.ts +255 -0
- package/dist/{type/account.js → adapters/evm/types.js} +1 -1
- package/dist/adapters/evm/types.js.map +1 -0
- package/dist/adapters/evm/web3-client.d.ts +23 -0
- package/dist/adapters/evm/web3-client.js +159 -0
- package/dist/adapters/evm/web3-client.js.map +1 -0
- package/dist/adapters/solana/builder.d.ts +18 -0
- package/dist/adapters/solana/builder.js +545 -0
- package/dist/adapters/solana/builder.js.map +1 -0
- package/dist/adapters/solana/chains.d.ts +13 -0
- package/dist/adapters/solana/chains.js +37 -0
- package/dist/adapters/solana/chains.js.map +1 -0
- package/dist/adapters/solana/decode.d.ts +111 -0
- package/dist/adapters/solana/decode.js +595 -0
- package/dist/adapters/solana/decode.js.map +1 -0
- package/dist/adapters/solana/driver.d.ts +15 -0
- package/dist/adapters/solana/driver.js +72 -0
- package/dist/adapters/solana/driver.js.map +1 -0
- package/dist/adapters/solana/errors.d.ts +36 -0
- package/dist/adapters/solana/errors.js +154 -0
- package/dist/adapters/solana/errors.js.map +1 -0
- package/dist/adapters/solana/fees.d.ts +68 -0
- package/dist/adapters/solana/fees.js +205 -0
- package/dist/adapters/solana/fees.js.map +1 -0
- package/dist/adapters/solana/heights.d.ts +47 -0
- package/dist/adapters/solana/heights.js +185 -0
- package/dist/adapters/solana/heights.js.map +1 -0
- package/dist/adapters/solana/history.d.ts +10 -0
- package/dist/adapters/solana/history.js +71 -0
- package/dist/adapters/solana/history.js.map +1 -0
- package/dist/adapters/solana/index.d.ts +16 -0
- package/dist/adapters/solana/index.js +9 -0
- package/dist/adapters/solana/index.js.map +1 -0
- package/dist/adapters/solana/keys.d.ts +13 -0
- package/dist/adapters/solana/keys.js +69 -0
- package/dist/adapters/solana/keys.js.map +1 -0
- package/dist/adapters/solana/network.d.ts +24 -0
- package/dist/adapters/solana/network.js +95 -0
- package/dist/adapters/solana/network.js.map +1 -0
- package/dist/adapters/solana/plugin.d.ts +18 -0
- package/dist/adapters/solana/plugin.js +41 -0
- package/dist/adapters/solana/plugin.js.map +1 -0
- package/dist/adapters/solana/presets.d.ts +2 -0
- package/dist/adapters/solana/presets.js +77 -0
- package/dist/adapters/solana/presets.js.map +1 -0
- package/dist/adapters/solana/programs.d.ts +44 -0
- package/dist/adapters/solana/programs.js +159 -0
- package/dist/adapters/solana/programs.js.map +1 -0
- package/dist/adapters/solana/proofs.d.ts +56 -0
- package/dist/adapters/solana/proofs.js +540 -0
- package/dist/adapters/solana/proofs.js.map +1 -0
- package/dist/adapters/solana/reader.d.ts +82 -0
- package/dist/adapters/solana/reader.js +326 -0
- package/dist/adapters/solana/reader.js.map +1 -0
- package/dist/adapters/solana/rpc.d.ts +102 -0
- package/dist/adapters/solana/rpc.js +301 -0
- package/dist/adapters/solana/rpc.js.map +1 -0
- package/dist/adapters/solana/tokens.d.ts +7 -0
- package/dist/adapters/solana/tokens.js +19 -0
- package/dist/adapters/solana/tokens.js.map +1 -0
- package/dist/adapters/solana/types.d.ts +121 -0
- package/dist/{type/contract.js → adapters/solana/types.js} +1 -1
- package/dist/adapters/solana/types.js.map +1 -0
- package/dist/adapters/solana/web3.d.ts +5 -0
- package/dist/adapters/solana/web3.js +83 -0
- package/dist/adapters/solana/web3.js.map +1 -0
- package/dist/adapters/solana/wire.d.ts +62 -0
- package/dist/adapters/solana/wire.js +168 -0
- package/dist/adapters/solana/wire.js.map +1 -0
- package/dist/adapters/ton/address.d.ts +43 -0
- package/dist/adapters/ton/address.js +168 -0
- package/dist/adapters/ton/address.js.map +1 -0
- package/dist/adapters/ton/api.d.ts +344 -0
- package/dist/adapters/ton/api.js +942 -0
- package/dist/adapters/ton/api.js.map +1 -0
- package/dist/adapters/ton/builder.d.ts +18 -0
- package/dist/adapters/ton/builder.js +701 -0
- package/dist/adapters/ton/builder.js.map +1 -0
- package/dist/adapters/ton/chains.d.ts +16 -0
- package/dist/adapters/ton/chains.js +39 -0
- package/dist/adapters/ton/chains.js.map +1 -0
- package/dist/adapters/ton/decode.d.ts +43 -0
- package/dist/adapters/ton/decode.js +219 -0
- package/dist/adapters/ton/decode.js.map +1 -0
- package/dist/adapters/ton/driver.d.ts +10 -0
- package/dist/adapters/ton/driver.js +117 -0
- package/dist/adapters/ton/driver.js.map +1 -0
- package/dist/adapters/ton/errors.d.ts +36 -0
- package/dist/adapters/ton/errors.js +89 -0
- package/dist/adapters/ton/errors.js.map +1 -0
- package/dist/adapters/ton/fees.d.ts +28 -0
- package/dist/adapters/ton/fees.js +121 -0
- package/dist/adapters/ton/fees.js.map +1 -0
- package/dist/adapters/ton/index.d.ts +16 -0
- package/dist/adapters/ton/index.js +9 -0
- package/dist/adapters/ton/index.js.map +1 -0
- package/dist/adapters/ton/messages.d.ts +157 -0
- package/dist/adapters/ton/messages.js +397 -0
- package/dist/adapters/ton/messages.js.map +1 -0
- package/dist/adapters/ton/native-client.d.ts +10 -0
- package/dist/adapters/ton/native-client.js +47 -0
- package/dist/adapters/ton/native-client.js.map +1 -0
- package/dist/adapters/ton/network.d.ts +58 -0
- package/dist/adapters/ton/network.js +207 -0
- package/dist/adapters/ton/network.js.map +1 -0
- package/dist/adapters/ton/plugin.d.ts +24 -0
- package/dist/adapters/ton/plugin.js +57 -0
- package/dist/adapters/ton/plugin.js.map +1 -0
- package/dist/adapters/ton/presets.d.ts +6 -0
- package/dist/adapters/ton/presets.js +94 -0
- package/dist/adapters/ton/presets.js.map +1 -0
- package/dist/adapters/ton/proofs.d.ts +66 -0
- package/dist/adapters/ton/proofs.js +813 -0
- package/dist/adapters/ton/proofs.js.map +1 -0
- package/dist/adapters/ton/reader.d.ts +194 -0
- package/dist/adapters/ton/reader.js +781 -0
- package/dist/adapters/ton/reader.js.map +1 -0
- package/dist/adapters/ton/tokens.d.ts +10 -0
- package/dist/adapters/ton/tokens.js +27 -0
- package/dist/adapters/ton/tokens.js.map +1 -0
- package/dist/adapters/ton/trace.d.ts +48 -0
- package/dist/adapters/ton/trace.js +277 -0
- package/dist/adapters/ton/trace.js.map +1 -0
- package/dist/adapters/ton/types.d.ts +105 -0
- package/dist/{type/transact.js → adapters/ton/types.js} +1 -1
- package/dist/adapters/ton/types.js.map +1 -0
- package/dist/adapters/ton/wallets.d.ts +86 -0
- package/dist/adapters/ton/wallets.js +373 -0
- package/dist/adapters/ton/wallets.js.map +1 -0
- package/dist/adapters/tron/abi.d.ts +39 -0
- package/dist/adapters/tron/abi.js +110 -0
- package/dist/adapters/tron/abi.js.map +1 -0
- package/dist/adapters/tron/address.d.ts +20 -0
- package/dist/adapters/tron/address.js +110 -0
- package/dist/adapters/tron/address.js.map +1 -0
- package/dist/adapters/tron/builder.d.ts +12 -0
- package/dist/adapters/tron/builder.js +553 -0
- package/dist/adapters/tron/builder.js.map +1 -0
- package/dist/adapters/tron/chains.d.ts +12 -0
- package/dist/adapters/tron/chains.js +35 -0
- package/dist/adapters/tron/chains.js.map +1 -0
- package/dist/adapters/tron/codec.d.ts +10 -0
- package/dist/adapters/tron/codec.js +322 -0
- package/dist/adapters/tron/codec.js.map +1 -0
- package/dist/adapters/tron/decode.d.ts +50 -0
- package/dist/adapters/tron/decode.js +280 -0
- package/dist/adapters/tron/decode.js.map +1 -0
- package/dist/adapters/tron/driver.d.ts +12 -0
- package/dist/adapters/tron/driver.js +106 -0
- package/dist/adapters/tron/driver.js.map +1 -0
- package/dist/adapters/tron/errors.d.ts +74 -0
- package/dist/adapters/tron/errors.js +261 -0
- package/dist/adapters/tron/errors.js.map +1 -0
- package/dist/adapters/tron/fees.d.ts +49 -0
- package/dist/adapters/tron/fees.js +166 -0
- package/dist/adapters/tron/fees.js.map +1 -0
- package/dist/adapters/tron/http.d.ts +173 -0
- package/dist/adapters/tron/http.js +729 -0
- package/dist/adapters/tron/http.js.map +1 -0
- package/dist/adapters/tron/index.d.ts +16 -0
- package/dist/adapters/tron/index.js +15 -0
- package/dist/adapters/tron/index.js.map +1 -0
- package/dist/adapters/tron/network.d.ts +44 -0
- package/dist/adapters/tron/network.js +163 -0
- package/dist/adapters/tron/network.js.map +1 -0
- package/dist/adapters/tron/plugin.d.ts +17 -0
- package/dist/adapters/tron/plugin.js +39 -0
- package/dist/adapters/tron/plugin.js.map +1 -0
- package/dist/adapters/tron/presets.d.ts +5 -0
- package/dist/adapters/tron/presets.js +68 -0
- package/dist/adapters/tron/presets.js.map +1 -0
- package/dist/adapters/tron/proofs.d.ts +80 -0
- package/dist/adapters/tron/proofs.js +370 -0
- package/dist/adapters/tron/proofs.js.map +1 -0
- package/dist/adapters/tron/protobuf.d.ts +36 -0
- package/dist/adapters/tron/protobuf.js +90 -0
- package/dist/adapters/tron/protobuf.js.map +1 -0
- package/dist/adapters/tron/reader.d.ts +47 -0
- package/dist/adapters/tron/reader.js +203 -0
- package/dist/adapters/tron/reader.js.map +1 -0
- package/dist/adapters/tron/tokens.d.ts +7 -0
- package/dist/adapters/tron/tokens.js +14 -0
- package/dist/adapters/tron/tokens.js.map +1 -0
- package/dist/adapters/tron/types.d.ts +166 -0
- package/dist/adapters/tron/types.js +3 -0
- package/dist/adapters/tron/types.js.map +1 -0
- package/dist/adapters/utxo/address.d.ts +51 -0
- package/dist/adapters/utxo/address.js +341 -0
- package/dist/adapters/utxo/address.js.map +1 -0
- package/dist/adapters/utxo/builder.d.ts +35 -0
- package/dist/adapters/utxo/builder.js +380 -0
- package/dist/adapters/utxo/builder.js.map +1 -0
- package/dist/adapters/utxo/chains.d.ts +17 -0
- package/dist/adapters/utxo/chains.js +99 -0
- package/dist/adapters/utxo/chains.js.map +1 -0
- package/dist/adapters/utxo/codec.d.ts +120 -0
- package/dist/adapters/utxo/codec.js +408 -0
- package/dist/adapters/utxo/codec.js.map +1 -0
- package/dist/adapters/utxo/coinselect.d.ts +48 -0
- package/dist/adapters/utxo/coinselect.js +131 -0
- package/dist/adapters/utxo/coinselect.js.map +1 -0
- package/dist/adapters/utxo/context.d.ts +57 -0
- package/dist/adapters/utxo/context.js +118 -0
- package/dist/adapters/utxo/context.js.map +1 -0
- package/dist/adapters/utxo/decode.d.ts +14 -0
- package/dist/adapters/utxo/decode.js +85 -0
- package/dist/adapters/utxo/decode.js.map +1 -0
- package/dist/adapters/utxo/driver.d.ts +16 -0
- package/dist/adapters/utxo/driver.js +74 -0
- package/dist/adapters/utxo/driver.js.map +1 -0
- package/dist/adapters/utxo/ecc.d.ts +9 -0
- package/dist/adapters/utxo/ecc.js +26 -0
- package/dist/adapters/utxo/ecc.js.map +1 -0
- package/dist/adapters/utxo/errors.d.ts +52 -0
- package/dist/adapters/utxo/errors.js +191 -0
- package/dist/adapters/utxo/errors.js.map +1 -0
- package/dist/adapters/utxo/esplora.d.ts +79 -0
- package/dist/adapters/utxo/esplora.js +451 -0
- package/dist/adapters/utxo/esplora.js.map +1 -0
- package/dist/adapters/utxo/fees.d.ts +41 -0
- package/dist/adapters/utxo/fees.js +125 -0
- package/dist/adapters/utxo/fees.js.map +1 -0
- package/dist/adapters/utxo/index.d.ts +17 -0
- package/dist/adapters/utxo/index.js +8 -0
- package/dist/adapters/utxo/index.js.map +1 -0
- package/dist/adapters/utxo/network.d.ts +50 -0
- package/dist/adapters/utxo/network.js +165 -0
- package/dist/adapters/utxo/network.js.map +1 -0
- package/dist/adapters/utxo/plugin.d.ts +17 -0
- package/dist/adapters/utxo/plugin.js +41 -0
- package/dist/adapters/utxo/plugin.js.map +1 -0
- package/dist/adapters/utxo/presets.d.ts +12 -0
- package/dist/adapters/utxo/presets.js +47 -0
- package/dist/adapters/utxo/presets.js.map +1 -0
- package/dist/adapters/utxo/preview.d.ts +3 -0
- package/dist/adapters/utxo/preview.js +65 -0
- package/dist/adapters/utxo/preview.js.map +1 -0
- package/dist/adapters/utxo/proofs.d.ts +57 -0
- package/dist/adapters/utxo/proofs.js +331 -0
- package/dist/adapters/utxo/proofs.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +59 -0
- package/dist/adapters/utxo/rawtx.js +234 -0
- package/dist/adapters/utxo/rawtx.js.map +1 -0
- package/dist/adapters/utxo/reader.d.ts +36 -0
- package/dist/adapters/utxo/reader.js +265 -0
- package/dist/adapters/utxo/reader.js.map +1 -0
- package/dist/adapters/utxo/sdk.d.ts +18 -0
- package/dist/adapters/utxo/sdk.js +17 -0
- package/dist/adapters/utxo/sdk.js.map +1 -0
- package/dist/adapters/utxo/signed-psbt.d.ts +36 -0
- package/dist/adapters/utxo/signed-psbt.js +428 -0
- package/dist/adapters/utxo/signed-psbt.js.map +1 -0
- package/dist/adapters/utxo/spend.d.ts +59 -0
- package/dist/adapters/utxo/spend.js +230 -0
- package/dist/adapters/utxo/spend.js.map +1 -0
- package/dist/adapters/utxo/types.d.ts +167 -0
- package/dist/adapters/utxo/types.js +3 -0
- package/dist/adapters/utxo/types.js.map +1 -0
- package/dist/core/assets/service.d.ts +18 -0
- package/dist/core/assets/service.js +69 -0
- package/dist/core/assets/service.js.map +1 -0
- package/dist/core/blockchain/default-ref.d.ts +4 -0
- package/dist/core/blockchain/default-ref.js +16 -0
- package/dist/core/blockchain/default-ref.js.map +1 -0
- package/dist/core/blockchain/handle.d.ts +200 -0
- package/dist/core/blockchain/handle.js +579 -0
- package/dist/core/blockchain/handle.js.map +1 -0
- package/dist/core/blockchain/internal.d.ts +19 -0
- package/dist/core/blockchain/internal.js +16 -0
- package/dist/core/blockchain/internal.js.map +1 -0
- package/dist/core/blockchain/mapping.d.ts +22 -0
- package/dist/core/blockchain/mapping.js +136 -0
- package/dist/core/blockchain/mapping.js.map +1 -0
- package/dist/core/config/env.d.ts +8 -0
- package/dist/core/config/env.js +60 -0
- package/dist/core/config/env.js.map +1 -0
- package/dist/core/config/merge.d.ts +26 -0
- package/dist/core/config/merge.js +144 -0
- package/dist/core/config/merge.js.map +1 -0
- package/dist/core/config/resolve.d.ts +12 -0
- package/dist/core/config/resolve.js +251 -0
- package/dist/core/config/resolve.js.map +1 -0
- package/dist/core/config/types.d.ts +165 -0
- package/dist/core/config/types.js +3 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/container/builtins.d.ts +4 -0
- package/dist/core/container/builtins.js +13 -0
- package/dist/core/container/builtins.js.map +1 -0
- package/dist/core/container/container.d.ts +69 -0
- package/dist/core/container/container.js +466 -0
- package/dist/core/container/container.js.map +1 -0
- package/dist/core/container/default.d.ts +15 -0
- package/dist/core/container/default.js +70 -0
- package/dist/core/container/default.js.map +1 -0
- package/dist/core/container/internals.d.ts +54 -0
- package/dist/core/container/internals.js +21 -0
- package/dist/core/container/internals.js.map +1 -0
- package/dist/core/container/pool.d.ts +27 -0
- package/dist/core/container/pool.js +77 -0
- package/dist/core/container/pool.js.map +1 -0
- package/dist/core/driver/types.d.ts +346 -0
- package/dist/core/driver/types.js +3 -0
- package/dist/core/driver/types.js.map +1 -0
- package/dist/core/errors/codes.d.ts +153 -0
- package/dist/core/errors/codes.js +49 -0
- package/dist/core/errors/codes.js.map +1 -0
- package/dist/core/errors/error.d.ts +66 -0
- package/dist/core/errors/error.js +129 -0
- package/dist/core/errors/error.js.map +1 -0
- package/dist/core/events/bus.d.ts +12 -0
- package/dist/core/events/bus.js +46 -0
- package/dist/core/events/bus.js.map +1 -0
- package/dist/core/events/logger.d.ts +13 -0
- package/dist/core/events/logger.js +42 -0
- package/dist/core/events/logger.js.map +1 -0
- package/dist/core/events/types.d.ts +131 -0
- package/dist/core/events/types.js +3 -0
- package/dist/core/events/types.js.map +1 -0
- package/dist/core/lifecycle/engine-rules.d.ts +107 -0
- package/dist/core/lifecycle/engine-rules.js +257 -0
- package/dist/core/lifecycle/engine-rules.js.map +1 -0
- package/dist/core/lifecycle/engine.d.ts +500 -0
- package/dist/core/lifecycle/engine.js +1732 -0
- package/dist/core/lifecycle/engine.js.map +1 -0
- package/dist/core/lifecycle/evaluate.d.ts +19 -0
- package/dist/core/lifecycle/evaluate.js +72 -0
- package/dist/core/lifecycle/evaluate.js.map +1 -0
- package/dist/core/lifecycle/intent.d.ts +11 -0
- package/dist/core/lifecycle/intent.js +88 -0
- package/dist/core/lifecycle/intent.js.map +1 -0
- package/dist/core/lifecycle/monitor.d.ts +138 -0
- package/dist/core/lifecycle/monitor.js +606 -0
- package/dist/core/lifecycle/monitor.js.map +1 -0
- package/dist/core/lifecycle/observations.d.ts +17 -0
- package/dist/core/lifecycle/observations.js +59 -0
- package/dist/core/lifecycle/observations.js.map +1 -0
- package/dist/core/lifecycle/reconcile.d.ts +58 -0
- package/dist/core/lifecycle/reconcile.js +112 -0
- package/dist/core/lifecycle/reconcile.js.map +1 -0
- package/dist/core/lifecycle/views.d.ts +49 -0
- package/dist/core/lifecycle/views.js +57 -0
- package/dist/core/lifecycle/views.js.map +1 -0
- package/dist/core/lifecycle/workers.d.ts +82 -0
- package/dist/core/lifecycle/workers.js +329 -0
- package/dist/core/lifecycle/workers.js.map +1 -0
- package/dist/core/model/address.d.ts +32 -0
- package/dist/core/model/address.js +43 -0
- package/dist/core/model/address.js.map +1 -0
- package/dist/core/model/amount.d.ts +25 -0
- package/dist/core/model/amount.js +102 -0
- package/dist/core/model/amount.js.map +1 -0
- package/dist/core/model/asset.d.ts +28 -0
- package/dist/core/model/asset.js +47 -0
- package/dist/core/model/asset.js.map +1 -0
- package/dist/core/model/capability.d.ts +3 -0
- package/dist/core/model/capability.js +18 -0
- package/dist/core/model/capability.js.map +1 -0
- package/dist/core/model/chain.d.ts +63 -0
- package/dist/core/model/chain.js +8 -0
- package/dist/core/model/chain.js.map +1 -0
- package/dist/core/model/fee.d.ts +36 -0
- package/dist/core/model/fee.js +17 -0
- package/dist/core/model/fee.js.map +1 -0
- package/dist/core/model/ids.d.ts +37 -0
- package/dist/core/model/ids.js +13 -0
- package/dist/core/model/ids.js.map +1 -0
- package/dist/core/model/intent.d.ts +63 -0
- package/dist/core/model/intent.js +81 -0
- package/dist/core/model/intent.js.map +1 -0
- package/dist/core/model/ordering.d.ts +20 -0
- package/dist/core/model/ordering.js +29 -0
- package/dist/core/model/ordering.js.map +1 -0
- package/dist/core/model/transaction.d.ts +116 -0
- package/dist/{type/lib-types.js → core/model/transaction.js} +1 -1
- package/dist/core/model/transaction.js.map +1 -0
- package/dist/core/observe/scanner.d.ts +135 -0
- package/dist/core/observe/scanner.js +355 -0
- package/dist/core/observe/scanner.js.map +1 -0
- package/dist/core/ordering/reservations.d.ts +16 -0
- package/dist/core/ordering/reservations.js +53 -0
- package/dist/core/ordering/reservations.js.map +1 -0
- package/dist/core/ordering/sequence.d.ts +61 -0
- package/dist/core/ordering/sequence.js +155 -0
- package/dist/core/ordering/sequence.js.map +1 -0
- package/dist/core/registry/adapters.d.ts +10 -0
- package/dist/core/registry/adapters.js +56 -0
- package/dist/core/registry/adapters.js.map +1 -0
- package/dist/core/registry/assets.d.ts +18 -0
- package/dist/core/registry/assets.js +90 -0
- package/dist/core/registry/assets.js.map +1 -0
- package/dist/core/registry/chains.d.ts +10 -0
- package/dist/core/registry/chains.js +80 -0
- package/dist/core/registry/chains.js.map +1 -0
- package/dist/core/registry/plugin.d.ts +41 -0
- package/dist/core/registry/plugin.js +109 -0
- package/dist/core/registry/plugin.js.map +1 -0
- package/dist/core/registry/providers.d.ts +31 -0
- package/dist/core/registry/providers.js +43 -0
- package/dist/core/registry/providers.js.map +1 -0
- package/dist/core/registry/schemes.d.ts +30 -0
- package/dist/core/registry/schemes.js +84 -0
- package/dist/core/registry/schemes.js.map +1 -0
- package/dist/core/secret/fragments.d.ts +33 -0
- package/dist/core/secret/fragments.js +110 -0
- package/dist/core/secret/fragments.js.map +1 -0
- package/dist/core/secret/redact.d.ts +10 -0
- package/dist/core/secret/redact.js +110 -0
- package/dist/core/secret/redact.js.map +1 -0
- package/dist/core/secret/secret.d.ts +14 -0
- package/dist/core/secret/secret.js +42 -0
- package/dist/core/secret/secret.js.map +1 -0
- package/dist/core/signing/callback.d.ts +10 -0
- package/dist/core/signing/callback.js +22 -0
- package/dist/core/signing/callback.js.map +1 -0
- package/dist/core/signing/guard.d.ts +18 -0
- package/dist/core/signing/guard.js +72 -0
- package/dist/core/signing/guard.js.map +1 -0
- package/dist/core/signing/hd.d.ts +36 -0
- package/dist/core/signing/hd.js +167 -0
- package/dist/core/signing/hd.js.map +1 -0
- package/dist/core/signing/local.d.ts +48 -0
- package/dist/core/signing/local.js +190 -0
- package/dist/core/signing/local.js.map +1 -0
- package/dist/core/signing/orchestrator.d.ts +40 -0
- package/dist/core/signing/orchestrator.js +300 -0
- package/dist/core/signing/orchestrator.js.map +1 -0
- package/dist/core/signing/types.d.ts +64 -0
- package/dist/core/signing/types.js +3 -0
- package/dist/core/signing/types.js.map +1 -0
- package/dist/core/signing/wallet.d.ts +48 -0
- package/dist/core/signing/wallet.js +153 -0
- package/dist/core/signing/wallet.js.map +1 -0
- package/dist/core/store/clone.d.ts +25 -0
- package/dist/core/store/clone.js +71 -0
- package/dist/core/store/clone.js.map +1 -0
- package/dist/core/store/memory.d.ts +38 -0
- package/dist/core/store/memory.js +325 -0
- package/dist/core/store/memory.js.map +1 -0
- package/dist/core/store/types.d.ts +246 -0
- package/dist/core/store/types.js +117 -0
- package/dist/core/store/types.js.map +1 -0
- package/dist/core/transport/backoff.d.ts +8 -0
- package/dist/core/transport/backoff.js +27 -0
- package/dist/core/transport/backoff.js.map +1 -0
- package/dist/core/transport/circuit.d.ts +25 -0
- package/dist/core/transport/circuit.js +61 -0
- package/dist/core/transport/circuit.js.map +1 -0
- package/dist/core/transport/http-transport.d.ts +30 -0
- package/dist/core/transport/http-transport.js +1695 -0
- package/dist/core/transport/http-transport.js.map +1 -0
- package/dist/core/transport/rate-limit.d.ts +27 -0
- package/dist/core/transport/rate-limit.js +78 -0
- package/dist/core/transport/rate-limit.js.map +1 -0
- package/dist/core/transport/stale-view.d.ts +11 -0
- package/dist/core/transport/stale-view.js +17 -0
- package/dist/core/transport/stale-view.js.map +1 -0
- package/dist/core/transport/types.d.ts +144 -0
- package/dist/core/transport/types.js +6 -0
- package/dist/core/transport/types.js.map +1 -0
- package/dist/core/util/bytes.d.ts +9 -0
- package/dist/core/util/bytes.js +40 -0
- package/dist/core/util/bytes.js.map +1 -0
- package/dist/core/util/clock.d.ts +6 -0
- package/dist/core/util/clock.js +26 -0
- package/dist/core/util/clock.js.map +1 -0
- package/dist/core/util/freeze.d.ts +8 -0
- package/dist/core/util/freeze.js +31 -0
- package/dist/core/util/freeze.js.map +1 -0
- package/dist/core/util/json.d.ts +29 -0
- package/dist/core/util/json.js +165 -0
- package/dist/core/util/json.js.map +1 -0
- package/dist/core/util/names.d.ts +21 -0
- package/dist/core/util/names.js +46 -0
- package/dist/core/util/names.js.map +1 -0
- package/dist/index.d.ts +64 -14
- package/dist/index.js +105 -49
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +21 -0
- package/dist/native.js +44 -0
- package/dist/native.js.map +1 -0
- package/dist/testing/contracts/api.d.ts +12 -0
- package/dist/testing/contracts/api.js +58 -0
- package/dist/testing/contracts/api.js.map +1 -0
- package/dist/testing/contracts/cursors.d.ts +6 -0
- package/dist/testing/contracts/cursors.js +43 -0
- package/dist/testing/contracts/cursors.js.map +1 -0
- package/dist/testing/contracts/locks.d.ts +10 -0
- package/dist/testing/contracts/locks.js +63 -0
- package/dist/testing/contracts/locks.js.map +1 -0
- package/dist/testing/contracts/operations.d.ts +21 -0
- package/dist/testing/contracts/operations.js +718 -0
- package/dist/testing/contracts/operations.js.map +1 -0
- package/dist/testing/contracts/sequences.d.ts +6 -0
- package/dist/testing/contracts/sequences.js +68 -0
- package/dist/testing/contracts/sequences.js.map +1 -0
- package/dist/testing/env.d.ts +63 -0
- package/dist/testing/env.js +105 -0
- package/dist/testing/env.js.map +1 -0
- package/dist/testing/fake-chain.d.ts +118 -0
- package/dist/testing/fake-chain.js +536 -0
- package/dist/testing/fake-chain.js.map +1 -0
- package/dist/testing/fake-clock.d.ts +15 -0
- package/dist/testing/fake-clock.js +86 -0
- package/dist/testing/fake-clock.js.map +1 -0
- package/dist/testing/fake-driver.d.ts +15 -0
- package/dist/testing/fake-driver.js +458 -0
- package/dist/testing/fake-driver.js.map +1 -0
- package/dist/testing/fake-fetch.d.ts +32 -0
- package/dist/testing/fake-fetch.js +81 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-plugin.d.ts +30 -0
- package/dist/testing/fake-plugin.js +66 -0
- package/dist/testing/fake-plugin.js.map +1 -0
- package/dist/testing/faulty-store.d.ts +36 -0
- package/dist/testing/faulty-store.js +66 -0
- package/dist/testing/faulty-store.js.map +1 -0
- package/dist/testing/generation.d.ts +60 -0
- package/dist/testing/generation.js +252 -0
- package/dist/testing/generation.js.map +1 -0
- package/dist/testing/index.d.ts +28 -0
- package/dist/testing/index.js +51 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +188 -45
- package/dist/libs/eth/account.d.ts +0 -9
- package/dist/libs/eth/account.js +0 -58
- package/dist/libs/eth/account.js.map +0 -1
- package/dist/libs/eth/contract.d.ts +0 -7
- package/dist/libs/eth/contract.js +0 -42
- package/dist/libs/eth/contract.js.map +0 -1
- package/dist/libs/eth/index.d.ts +0 -24
- package/dist/libs/eth/index.js +0 -72
- package/dist/libs/eth/index.js.map +0 -1
- package/dist/libs/eth/transact.d.ts +0 -7
- package/dist/libs/eth/transact.js +0 -26
- package/dist/libs/eth/transact.js.map +0 -1
- package/dist/libs/index.d.ts +0 -2
- package/dist/libs/index.js +0 -19
- package/dist/libs/index.js.map +0 -1
- package/dist/libs/trx/account.d.ts +0 -9
- package/dist/libs/trx/account.js +0 -55
- package/dist/libs/trx/account.js.map +0 -1
- package/dist/libs/trx/contract.d.ts +0 -7
- package/dist/libs/trx/contract.js +0 -27
- package/dist/libs/trx/contract.js.map +0 -1
- package/dist/libs/trx/index.d.ts +0 -22
- package/dist/libs/trx/index.js +0 -64
- package/dist/libs/trx/index.js.map +0 -1
- package/dist/libs/trx/transact.d.ts +0 -7
- package/dist/libs/trx/transact.js +0 -26
- package/dist/libs/trx/transact.js.map +0 -1
- package/dist/tool/common.d.ts +0 -28
- package/dist/tool/common.js +0 -33
- package/dist/tool/common.js.map +0 -1
- package/dist/tool/eth-tools.d.ts +0 -3
- package/dist/tool/eth-tools.js +0 -33
- package/dist/tool/eth-tools.js.map +0 -1
- package/dist/tool/index.d.ts +0 -5
- package/dist/tool/index.js +0 -22
- package/dist/tool/index.js.map +0 -1
- package/dist/tool/logging.d.ts +0 -3
- package/dist/tool/logging.js +0 -11
- package/dist/tool/logging.js.map +0 -1
- package/dist/tool/options.d.ts +0 -6
- package/dist/tool/options.js +0 -41
- package/dist/tool/options.js.map +0 -1
- package/dist/tool/trx-tools.d.ts +0 -3
- package/dist/tool/trx-tools.js +0 -20
- package/dist/tool/trx-tools.js.map +0 -1
- package/dist/type/account.d.ts +0 -9
- package/dist/type/account.js.map +0 -1
- package/dist/type/common.d.ts +0 -18
- package/dist/type/common.js.map +0 -1
- package/dist/type/contract.d.ts +0 -10
- package/dist/type/contract.js.map +0 -1
- package/dist/type/index.d.ts +0 -5
- package/dist/type/index.js +0 -22
- package/dist/type/index.js.map +0 -1
- package/dist/type/lib-types.d.ts +0 -9
- package/dist/type/lib-types.js.map +0 -1
- package/dist/type/transact.d.ts +0 -7
- package/dist/type/transact.js.map +0 -1
|
@@ -0,0 +1,942 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TonApi = exports.sameBlock = exports.MAX_STATE_BOC_LENGTH = exports.MAX_STATE_CELLS = exports.MAX_BODY_BOC_LENGTH = exports.MAX_BODY_CELLS = exports.MASTERCHAIN_SHARD = exports.withSignal = exports.BROADCAST = exports.PROOF = exports.MONITOR = exports.READ = void 0;
|
|
4
|
+
exports.bocWithinLimits = bocWithinLimits;
|
|
5
|
+
exports.hashHex = hashHex;
|
|
6
|
+
exports.rawOf = rawOf;
|
|
7
|
+
exports.transactionOf = transactionOf;
|
|
8
|
+
exports.masterchainInfoSeqno = masterchainInfoSeqno;
|
|
9
|
+
exports.indexedHeadOf = indexedHeadOf;
|
|
10
|
+
exports.configParamBoc = configParamBoc;
|
|
11
|
+
exports.runResultOf = runResultOf;
|
|
12
|
+
exports.boundRunResultOf = boundRunResultOf;
|
|
13
|
+
exports.jettonDataOf = jettonDataOf;
|
|
14
|
+
/**
|
|
15
|
+
* The TON driver's only path to the network: toncenter API v2 (the `rpc` transport: live
|
|
16
|
+
* liteserver state, get-methods at a fixed masterchain block, fee emulation, sending) and
|
|
17
|
+
* API v3 (the `indexer` transport: message → transaction, traces, history, jetton
|
|
18
|
+
* metadata), as REST calls through the core transports. Not JSON-RPC: toncenter's
|
|
19
|
+
* `/jsonRPC` answers carry no `id`, which `transport.rpc` refuses, and `TonClient` would
|
|
20
|
+
* put a real timer on the request path. Each call carries its driver method's tags and a
|
|
21
|
+
* `route` with no identifiers in it (events and logs show it), and reads integers exactly
|
|
22
|
+
* (toncenter writes some u64 values as JSON numbers). Answers are validated here: a
|
|
23
|
+
* malformed one, including a missing or ill-typed field a verdict reads, is a retryable
|
|
24
|
+
* `PROVIDER_UNAVAILABLE`, never a default or a foreign error. Lookups by id keep only
|
|
25
|
+
* what they asked for, so a dropped server-side filter reads as "none yet"; a history
|
|
26
|
+
* that breaks its query is malformed. Numbers, cells and metadata are bounded before use.
|
|
27
|
+
* Under a quorum, every method compares the parsed facts it returns (so honest endpoints
|
|
28
|
+
* that format a fact differently agree), or the caller's predicate key. SDK-free.
|
|
29
|
+
*/
|
|
30
|
+
const error_1 = require("../../core/errors/error");
|
|
31
|
+
const fees_1 = require("./fees");
|
|
32
|
+
exports.READ = { purpose: 'read', retry: 'safe' };
|
|
33
|
+
exports.MONITOR = { purpose: 'monitor', retry: 'safe' };
|
|
34
|
+
exports.PROOF = { purpose: 'proof', retry: 'safe', quorum: 'proof' };
|
|
35
|
+
exports.BROADCAST = {
|
|
36
|
+
purpose: 'broadcast',
|
|
37
|
+
retry: 'ambiguous-on-failure',
|
|
38
|
+
};
|
|
39
|
+
const withSignal = (tags, signal) => signal ? { ...tags, signal } : tags;
|
|
40
|
+
exports.withSignal = withSignal;
|
|
41
|
+
/** The masterchain's one shard, as toncenter v2 writes it. */
|
|
42
|
+
exports.MASTERCHAIN_SHARD = '-9223372036854775808';
|
|
43
|
+
/**
|
|
44
|
+
* The most cells a message body may hold, checked in the BOC header before the
|
|
45
|
+
* SDK parses anything. TON refuses a message of more than 2^13 cells or 2^21 bits (config
|
|
46
|
+
* param 43, "account and message limits", docs.ton.org/foundations/config; the node's
|
|
47
|
+
* defaults `max_msg_cells = 1 << 13` and `max_msg_bits = 1 << 21` in `SizeLimitsConfig`,
|
|
48
|
+
* ton-blockchain/ton `crypto/block/mc-config.h`), so no body the chain carried holds more.
|
|
49
|
+
* The text length alone does not bound the work: minimal cells cost about 4 bytes each,
|
|
50
|
+
* and `Cell.fromBoc` takes about 20-50 µs per cell.
|
|
51
|
+
*/
|
|
52
|
+
exports.MAX_BODY_CELLS = 1 << 13;
|
|
53
|
+
/**
|
|
54
|
+
* The longest message body BOC text `cellFromBoc` decodes. The same limits give
|
|
55
|
+
* at most 2^21 / 8 bytes of data in 2^13 cells, each with 2 descriptor bytes, 4 two-byte
|
|
56
|
+
* refs, a rounding byte and a 3-byte index entry, plus a header and a checksum: under
|
|
57
|
+
* 377,000 bytes, about 502,500 base64 characters.
|
|
58
|
+
*/
|
|
59
|
+
exports.MAX_BODY_BOC_LENGTH = 1 << 19;
|
|
60
|
+
/**
|
|
61
|
+
* The most cells of a jetton master's content that `jettonData` hands
|
|
62
|
+
* on. The content is part of the master's account state, not a message, and TON caps a state
|
|
63
|
+
* at 2^16 cells and 2^16 × 1023 bits (config param 43, `max_acc_state_cells` and
|
|
64
|
+
* `max_acc_state_bits`, the node's defaults in `SizeLimitsConfig`, ton-blockchain/ton
|
|
65
|
+
* `crypto/block/mc-config.h`), so no content the chain holds is larger.
|
|
66
|
+
*/
|
|
67
|
+
exports.MAX_STATE_CELLS = 1 << 16;
|
|
68
|
+
/**
|
|
69
|
+
* The longest content BOC text `jettonData` hands on. The same limits
|
|
70
|
+
* give at most 2^16 × 1023 / 8 bytes of data in 2^16 cells, each with 2 descriptor bytes, 4
|
|
71
|
+
* three-byte refs, a rounding byte and a 4-byte index entry, plus a header and a checksum:
|
|
72
|
+
* under 9.7 MB, about 12.9 million base64 characters. Decoding a state of that size takes
|
|
73
|
+
* about 2 s (`@ton/core` 0.63.1, measured); only a master's metadata, read once per token
|
|
74
|
+
* and cached, can be that large.
|
|
75
|
+
*/
|
|
76
|
+
exports.MAX_STATE_BOC_LENGTH = 1 << 24;
|
|
77
|
+
/**
|
|
78
|
+
* The cell count a BOC header declares, for the three layouts `@ton/core` reads (magic,
|
|
79
|
+
* then the size byte or flags with the size in their low 3 bits, the offset size, and the
|
|
80
|
+
* count in `size` bytes); undefined for anything else.
|
|
81
|
+
*/
|
|
82
|
+
function bocCellCount(bytes) {
|
|
83
|
+
if (bytes.length < 6)
|
|
84
|
+
return undefined;
|
|
85
|
+
const magic = bytes.readUInt32BE(0);
|
|
86
|
+
const head = bytes[4];
|
|
87
|
+
const size = magic === 0xb5ee9c72
|
|
88
|
+
? head & 0x07
|
|
89
|
+
: magic === 0x68ff65f3 || magic === 0xacc3a728
|
|
90
|
+
? head
|
|
91
|
+
: 0;
|
|
92
|
+
if (size < 1 || size > 4 || bytes.length < 6 + size)
|
|
93
|
+
return undefined;
|
|
94
|
+
return bytes.readUIntBE(6, size);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A base64 BOC measured against limits, by default one message's (at most
|
|
98
|
+
* `maxLength` characters, and a header, its first 16 characters, declaring at most
|
|
99
|
+
* `maxCells` cells): `oversized` beyond them, `malformed` without a BOC header.
|
|
100
|
+
*/
|
|
101
|
+
function bocSize(boc, maxCells = exports.MAX_BODY_CELLS, maxLength = exports.MAX_BODY_BOC_LENGTH) {
|
|
102
|
+
if (boc.length === 0)
|
|
103
|
+
return 'malformed';
|
|
104
|
+
const count = bocCellCount(Buffer.from(boc.slice(0, 16), 'base64'));
|
|
105
|
+
if (count === undefined)
|
|
106
|
+
return 'malformed';
|
|
107
|
+
return boc.length > maxLength || count > maxCells ? 'oversized' : 'ok';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Whether a base64 BOC is within one message's limits. SDK-free, so the API layer
|
|
111
|
+
* bounds the cells it hands on (config params, get-method stacks) and `cellFromBoc` the
|
|
112
|
+
* bodies it decodes.
|
|
113
|
+
*/
|
|
114
|
+
function bocWithinLimits(boc) {
|
|
115
|
+
return bocSize(boc) === 'ok';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The longest token metadata texts read from the indexer (decimals: 0..255). A longer or
|
|
119
|
+
* ill-typed `symbol` is reported unreadable; a `name` beyond its limit is absent, never
|
|
120
|
+
* an error: it is author-set text every endpoint agrees on, so a refusal would retry
|
|
121
|
+
* forever.
|
|
122
|
+
*/
|
|
123
|
+
const CONTENT_LIMITS = { symbol: 256, name: 256 };
|
|
124
|
+
function malformed(route) {
|
|
125
|
+
return new error_1.ProviderError('PROVIDER_UNAVAILABLE', `malformed toncenter answer to ${route}`, {
|
|
126
|
+
retryable: true,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
130
|
+
/** Checks, else throws the retryable malformed-answer error. */
|
|
131
|
+
function need(value, route) {
|
|
132
|
+
if (value === undefined || value === null)
|
|
133
|
+
throw malformed(route);
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
/** An optional field: absent (undefined or null), else `read` must accept it. */
|
|
137
|
+
function optional(value, read, route) {
|
|
138
|
+
return value === undefined || value === null ? undefined : need(read(value), route);
|
|
139
|
+
}
|
|
140
|
+
const str = (value) => typeof value === 'string' ? value : undefined;
|
|
141
|
+
const bool = (value) => typeof value === 'boolean' ? value : undefined;
|
|
142
|
+
const record = (value) => isRecord(value) ? value : undefined;
|
|
143
|
+
const int = (value) => typeof value === 'number' && Number.isSafeInteger(value)
|
|
144
|
+
? value
|
|
145
|
+
: typeof value === 'string' && /^-?\d{1,15}$/.test(value)
|
|
146
|
+
? Number(value)
|
|
147
|
+
: undefined;
|
|
148
|
+
/**
|
|
149
|
+
* An integer as a decimal string, a safe number or an exactly read bigint (the
|
|
150
|
+
* transport's `exactIntegers`). At most 80 digits (the core's exact-integer cap; u256 has
|
|
151
|
+
* 78), refused before `BigInt`.
|
|
152
|
+
*/
|
|
153
|
+
const big = (value) => typeof value === 'bigint'
|
|
154
|
+
? value
|
|
155
|
+
: typeof value === 'string' && /^-?\d{1,80}$/.test(value)
|
|
156
|
+
? BigInt(value)
|
|
157
|
+
: typeof value === 'number' && Number.isSafeInteger(value)
|
|
158
|
+
? BigInt(value)
|
|
159
|
+
: undefined;
|
|
160
|
+
const U64_MAX = 2n ** 64n - 1n;
|
|
161
|
+
/** An unsigned integer up to `max`. */
|
|
162
|
+
function unsigned(value, max) {
|
|
163
|
+
const n = big(value);
|
|
164
|
+
return n !== undefined && n >= 0n && n <= max ? n : undefined;
|
|
165
|
+
}
|
|
166
|
+
/** An amount of nanograms (`Coins`, a VarUInteger 16: below 2^120). */
|
|
167
|
+
const coins = (value) => unsigned(value, fees_1.MAX_COINS);
|
|
168
|
+
/** A logical time (u64). */
|
|
169
|
+
const u64 = (value) => unsigned(value, U64_MAX);
|
|
170
|
+
const INT64_MIN = -(2n ** 63n);
|
|
171
|
+
const INT64_MAX = 2n ** 63n - 1n;
|
|
172
|
+
/** A shard id (a signed 64-bit integer) as canonical decimal, however it was written. */
|
|
173
|
+
function shardOf(value) {
|
|
174
|
+
const shard = big(value);
|
|
175
|
+
return shard !== undefined && shard >= INT64_MIN && shard <= INT64_MAX
|
|
176
|
+
? shard.toString()
|
|
177
|
+
: undefined;
|
|
178
|
+
}
|
|
179
|
+
/** A 32-byte hash given in base64 (toncenter's form) as lower-case hex. */
|
|
180
|
+
function hashHex(value) {
|
|
181
|
+
if (typeof value !== 'string')
|
|
182
|
+
return undefined;
|
|
183
|
+
if (/^[0-9a-fA-F]{64}$/.test(value))
|
|
184
|
+
return value.toLowerCase();
|
|
185
|
+
if (!/^[A-Za-z0-9+/_-]{43}=?$/.test(value))
|
|
186
|
+
return undefined;
|
|
187
|
+
const bytes = Buffer.from(value.replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
|
188
|
+
return bytes.length === 32 ? bytes.toString('hex') : undefined;
|
|
189
|
+
}
|
|
190
|
+
/** toncenter v3 writes raw addresses in upper case; the canonical form is lower case. */
|
|
191
|
+
function rawOf(value) {
|
|
192
|
+
if (value === null)
|
|
193
|
+
return null;
|
|
194
|
+
if (typeof value !== 'string' || !/^(0|-1):[0-9a-fA-F]{64}$/.test(value))
|
|
195
|
+
return undefined;
|
|
196
|
+
return value.toLowerCase();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A lookup that filters its answer by address needs the address's raw form (the
|
|
200
|
+
* codec's canonical form); anything else is refused before any request, never retried as a
|
|
201
|
+
* provider fault.
|
|
202
|
+
*/
|
|
203
|
+
function rawAddress(address) {
|
|
204
|
+
const raw = rawOf(address);
|
|
205
|
+
if (!raw) {
|
|
206
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'a toncenter lookup needs a raw address');
|
|
207
|
+
}
|
|
208
|
+
return raw;
|
|
209
|
+
}
|
|
210
|
+
/** Whether two block ids name the same block: workchain, shard, seqno and both hashes. */
|
|
211
|
+
const sameBlock = (a, b) => a.workchain === b.workchain &&
|
|
212
|
+
a.shard === b.shard &&
|
|
213
|
+
a.seqno === b.seqno &&
|
|
214
|
+
a.rootHash === b.rootHash &&
|
|
215
|
+
a.fileHash === b.fileHash;
|
|
216
|
+
exports.sameBlock = sameBlock;
|
|
217
|
+
// ---- parsers ------------------------------------------------------------------------------
|
|
218
|
+
// A field a verdict reads is required, or optional and then well typed; a missing or
|
|
219
|
+
// ill-typed one is malformed (retryable), never `false` or `0`. Every endpoint running
|
|
220
|
+
// the same indexer would agree on a drifted answer, so a quorum does not catch what the
|
|
221
|
+
// parser lets through: a truncated answer read as `false` would end a delivered transfer
|
|
222
|
+
// `failed`, and a caller's retry with a new seqno would pay twice.
|
|
223
|
+
function blockIdOf(value, route) {
|
|
224
|
+
const v = need(record(value), route);
|
|
225
|
+
return {
|
|
226
|
+
workchain: need(int(v.workchain), route),
|
|
227
|
+
shard: need(shardOf(v.shard), route),
|
|
228
|
+
seqno: need(int(v.seqno), route),
|
|
229
|
+
rootHash: need(hashHex(v.root_hash), route),
|
|
230
|
+
fileHash: need(hashHex(v.file_hash), route),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function v2Result(body, route) {
|
|
234
|
+
if (!isRecord(body) || body.ok !== true || !('result' in body))
|
|
235
|
+
throw malformed(route);
|
|
236
|
+
return body.result;
|
|
237
|
+
}
|
|
238
|
+
/** A cell's base64 BOC, within one message's limits. */
|
|
239
|
+
function cellOf(value, route) {
|
|
240
|
+
const boc = need(str(value), route);
|
|
241
|
+
if (!bocWithinLimits(boc))
|
|
242
|
+
throw malformed(route);
|
|
243
|
+
return boc;
|
|
244
|
+
}
|
|
245
|
+
function stackOf(value, route) {
|
|
246
|
+
if (!Array.isArray(value))
|
|
247
|
+
throw malformed(route);
|
|
248
|
+
return value.map((entry) => {
|
|
249
|
+
if (!Array.isArray(entry) || entry.length !== 2)
|
|
250
|
+
throw malformed(route);
|
|
251
|
+
const [type, data] = entry;
|
|
252
|
+
if (type === 'num') {
|
|
253
|
+
const text = need(str(data), route);
|
|
254
|
+
const negative = text.startsWith('-');
|
|
255
|
+
const digits = negative ? text.slice(1) : text;
|
|
256
|
+
// A TVM integer has 257 bits (65 hex digits); bounded before `BigInt`.
|
|
257
|
+
if (!/^0x[0-9a-fA-F]{1,80}$/.test(digits))
|
|
258
|
+
throw malformed(route);
|
|
259
|
+
const value = BigInt(digits);
|
|
260
|
+
return { type: 'num', value: negative ? -value : value };
|
|
261
|
+
}
|
|
262
|
+
if (type === 'cell' ||
|
|
263
|
+
type === 'slice' ||
|
|
264
|
+
type === 'tvm.Cell' ||
|
|
265
|
+
type === 'tvm.Slice') {
|
|
266
|
+
return { type: 'cell', boc: cellOf(isRecord(data) ? data.bytes : data, route) };
|
|
267
|
+
}
|
|
268
|
+
return { type: 'other' };
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function messageOf(value, route) {
|
|
272
|
+
const m = need(record(value), route);
|
|
273
|
+
const content = optional(m.message_content, record, route);
|
|
274
|
+
const source = rawOf(m.source ?? null);
|
|
275
|
+
const destination = rawOf(m.destination ?? null);
|
|
276
|
+
if (source === undefined || destination === undefined)
|
|
277
|
+
throw malformed(route);
|
|
278
|
+
const hashNorm = optional(m.hash_norm, hashHex, route);
|
|
279
|
+
const bodyHash = content ? optional(content.hash, hashHex, route) : undefined;
|
|
280
|
+
const body = content ? optional(content.body, str, route) : undefined;
|
|
281
|
+
return {
|
|
282
|
+
hash: need(hashHex(m.hash), route),
|
|
283
|
+
...(hashNorm !== undefined ? { hashNorm } : {}),
|
|
284
|
+
source,
|
|
285
|
+
destination,
|
|
286
|
+
value: optional(m.value, coins, route) ?? null,
|
|
287
|
+
bounce: optional(m.bounce, bool, route) ?? null,
|
|
288
|
+
bounced: optional(m.bounced, bool, route) ?? null,
|
|
289
|
+
...(bodyHash !== undefined ? { bodyHash } : {}),
|
|
290
|
+
...(body !== undefined ? { body } : {}),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/** Transaction types with a compute phase (block.tlb `trans_ord`, `trans_tick_tock`). */
|
|
294
|
+
const COMPUTING = new Set(['ord', 'tick_tock']);
|
|
295
|
+
/** Bounce phase types (block.tlb `tr_phase_bounce_ok`, `_nofunds`, `_negfunds`). */
|
|
296
|
+
const BOUNCES = new Set(['ok', 'nofunds', 'negfunds']);
|
|
297
|
+
/** The compute phase; an ord or tick-tock transaction always has one. */
|
|
298
|
+
function computeOf(d, route) {
|
|
299
|
+
const type = need(str(d.type), route);
|
|
300
|
+
if (d.compute_ph === undefined || d.compute_ph === null) {
|
|
301
|
+
if (COMPUTING.has(type))
|
|
302
|
+
throw malformed(route);
|
|
303
|
+
return { skipped: true, success: false };
|
|
304
|
+
}
|
|
305
|
+
const c = need(record(d.compute_ph), route);
|
|
306
|
+
const skipped = need(bool(c.skipped), route);
|
|
307
|
+
// A skipped phase (`tr_phase_compute_skipped`) carries only its reason.
|
|
308
|
+
const success = skipped
|
|
309
|
+
? (optional(c.success, bool, route) ?? false)
|
|
310
|
+
: need(bool(c.success), route);
|
|
311
|
+
const exitCode = optional(c.exit_code, int, route);
|
|
312
|
+
return { skipped, success, ...(exitCode !== undefined ? { exitCode } : {}) };
|
|
313
|
+
}
|
|
314
|
+
/** The action phase, when there was one, with every field a verdict reads. */
|
|
315
|
+
function actionOf(value, route) {
|
|
316
|
+
const a = optional(value, record, route);
|
|
317
|
+
if (!a)
|
|
318
|
+
return undefined;
|
|
319
|
+
return {
|
|
320
|
+
success: need(bool(a.success), route),
|
|
321
|
+
resultCode: need(int(a.result_code), route),
|
|
322
|
+
skippedActions: need(int(a.skipped_actions), route),
|
|
323
|
+
msgsCreated: need(int(a.msgs_created), route),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/** The bounce phase's type, one of block.tlb's three. */
|
|
327
|
+
function bounceOf(value, route) {
|
|
328
|
+
const b = optional(value, record, route);
|
|
329
|
+
if (!b)
|
|
330
|
+
return undefined;
|
|
331
|
+
const type = need(str(b.type), route);
|
|
332
|
+
if (!BOUNCES.has(type))
|
|
333
|
+
throw malformed(route);
|
|
334
|
+
return type;
|
|
335
|
+
}
|
|
336
|
+
const V3_STATUSES = new Set([
|
|
337
|
+
'nonexist',
|
|
338
|
+
'uninit',
|
|
339
|
+
'active',
|
|
340
|
+
'frozen',
|
|
341
|
+
]);
|
|
342
|
+
/** A v3 account status: one of the four (well typed when present). */
|
|
343
|
+
const accountStatus = (value) => V3_STATUSES.has(value) ? value : undefined;
|
|
344
|
+
function transactionOf(value, route) {
|
|
345
|
+
const t = need(record(value), route);
|
|
346
|
+
const d = need(record(t.description), route);
|
|
347
|
+
const action = actionOf(d.action, route);
|
|
348
|
+
const bounce = bounceOf(d.bounce, route);
|
|
349
|
+
const origStatus = optional(t.orig_status, accountStatus, route);
|
|
350
|
+
const endStatus = optional(t.end_status, accountStatus, route);
|
|
351
|
+
return {
|
|
352
|
+
hash: need(hashHex(t.hash), route),
|
|
353
|
+
lt: need(u64(t.lt), route),
|
|
354
|
+
account: need(rawOf(t.account) ?? undefined, route),
|
|
355
|
+
now: need(int(t.now), route),
|
|
356
|
+
mcSeqno: need(int(t.mc_block_seqno), route),
|
|
357
|
+
traceId: need(hashHex(t.trace_id), route),
|
|
358
|
+
totalFees: need(coins(t.total_fees), route),
|
|
359
|
+
aborted: need(bool(d.aborted), route),
|
|
360
|
+
compute: computeOf(d, route),
|
|
361
|
+
...(action ? { action } : {}),
|
|
362
|
+
...(bounce !== undefined ? { bounce } : {}),
|
|
363
|
+
...(origStatus !== undefined ? { origStatus } : {}),
|
|
364
|
+
...(endStatus !== undefined ? { endStatus } : {}),
|
|
365
|
+
inMsg: t.in_msg === null || t.in_msg === undefined ? null : messageOf(t.in_msg, route),
|
|
366
|
+
outMsgs: need(Array.isArray(t.out_msgs) ? t.out_msgs : undefined, route).map((m) => messageOf(m, route)),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Whether a v3 `finality` is the masterchain's: live answers name the state (`finalized`),
|
|
371
|
+
* the swagger declares an int enum (0 pending, 1 confirmed, 2 finalized). An indexer that
|
|
372
|
+
* writes none is read as before: every transaction still needs its masterchain block.
|
|
373
|
+
*/
|
|
374
|
+
function finalized(f) {
|
|
375
|
+
return f === undefined || f === null || f === 'finalized' || f === 2;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Only chain evidence counts: an emulated (pending) transaction is toncenter's guess, and
|
|
379
|
+
* one not yet `finalized` (a shard block the masterchain has not committed) is not final;
|
|
380
|
+
* either reads as "not yet", and a trace holding one is incomplete.
|
|
381
|
+
*/
|
|
382
|
+
const committed = (value) => !(isRecord(value) && (value.emulated === true || !finalized(value.finality)));
|
|
383
|
+
/**
|
|
384
|
+
* A v3 transaction list, emulated or not yet finalized ones dropped; more than `limit`
|
|
385
|
+
* items is malformed.
|
|
386
|
+
*/
|
|
387
|
+
function transactionsOf(body, route, limit) {
|
|
388
|
+
if (!isRecord(body) ||
|
|
389
|
+
!Array.isArray(body.transactions) ||
|
|
390
|
+
body.transactions.length > limit) {
|
|
391
|
+
throw malformed(route);
|
|
392
|
+
}
|
|
393
|
+
return body.transactions.filter(committed).map((t) => transactionOf(t, route));
|
|
394
|
+
}
|
|
395
|
+
/** A block header, parsed. */
|
|
396
|
+
function headerOf(result, route) {
|
|
397
|
+
const h = need(record(result), route);
|
|
398
|
+
return {
|
|
399
|
+
id: blockIdOf(h.id, route),
|
|
400
|
+
globalId: need(int(h.global_id), route),
|
|
401
|
+
genUtime: need(int(h.gen_utime), route),
|
|
402
|
+
prev: Array.isArray(h.prev_blocks)
|
|
403
|
+
? h.prev_blocks.map((p) => blockIdOf(p, route))
|
|
404
|
+
: [],
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* The one parser of a masterchain block id's seqno, for the proofs' head reads and the
|
|
409
|
+
* driver's health probes alike (a node's height is a claim): only a
|
|
410
|
+
* masterchain id (workchain -1), and only within a masterchain seqno's range (u32).
|
|
411
|
+
*/
|
|
412
|
+
function masterchainIdSeqno(value, route) {
|
|
413
|
+
const id = record(value);
|
|
414
|
+
const seqno = int(id?.seqno);
|
|
415
|
+
if (id?.workchain !== -1 || seqno === undefined || seqno < 0 || seqno > 0xffff_ffff) {
|
|
416
|
+
throw malformed(route);
|
|
417
|
+
}
|
|
418
|
+
return seqno;
|
|
419
|
+
}
|
|
420
|
+
/** The newest masterchain block's seqno in a v2 `getMasterchainInfo` answer body. */
|
|
421
|
+
function masterchainInfoSeqno(body, route) {
|
|
422
|
+
return masterchainIdSeqno(record(v2Result(body, route))?.last, route);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* A v3 `masterchainInfo` answer body: the indexed head's seqno (`masterchainSeqnoOf`) and the
|
|
426
|
+
* network's global id, an int32.
|
|
427
|
+
*/
|
|
428
|
+
function indexedHeadOf(body, route) {
|
|
429
|
+
const last = record(record(body)?.last);
|
|
430
|
+
const globalId = int(last?.global_id);
|
|
431
|
+
if (globalId === undefined || globalId < -(2 ** 31) || globalId > 2 ** 31 - 1) {
|
|
432
|
+
throw malformed(route);
|
|
433
|
+
}
|
|
434
|
+
return { seqno: masterchainIdSeqno(last, route), globalId };
|
|
435
|
+
}
|
|
436
|
+
/** A config param's cell (base64 BOC, within one message's limits) in a v2 answer body. */
|
|
437
|
+
function configParamBoc(body, route) {
|
|
438
|
+
const result = v2Result(body, route);
|
|
439
|
+
return cellOf(need(isRecord(result) ? record(result.config) : undefined, route).bytes, route);
|
|
440
|
+
}
|
|
441
|
+
/** An account state, parsed. */
|
|
442
|
+
function accountOf(result, route) {
|
|
443
|
+
const r = need(record(result), route);
|
|
444
|
+
const state = r.state;
|
|
445
|
+
const status = state === 'active' || state === 'frozen'
|
|
446
|
+
? state
|
|
447
|
+
: state === 'uninitialized' || state === 'uninit' || state === 'nonexist'
|
|
448
|
+
? 'uninitialized'
|
|
449
|
+
: undefined;
|
|
450
|
+
const last = transactionIdOf(r.last_transaction_id, route);
|
|
451
|
+
const block = blockIdOf(r.block_id, route);
|
|
452
|
+
return {
|
|
453
|
+
balance: need(coins(r.balance), route),
|
|
454
|
+
status: need(status, route),
|
|
455
|
+
lastLt: last.lt,
|
|
456
|
+
lastHash: last.hash,
|
|
457
|
+
blockSeqno: block.seqno,
|
|
458
|
+
block,
|
|
459
|
+
syncUtime: need(int(r.sync_utime), route),
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/** A v2 `internal.transactionId`: lt and hash. */
|
|
463
|
+
function transactionIdOf(value, route) {
|
|
464
|
+
const id = need(record(value), route);
|
|
465
|
+
return { lt: need(u64(id.lt), route), hash: need(hashHex(id.hash), route) };
|
|
466
|
+
}
|
|
467
|
+
function runOf(result, route) {
|
|
468
|
+
if (!isRecord(result))
|
|
469
|
+
throw malformed(route);
|
|
470
|
+
return {
|
|
471
|
+
exitCode: need(int(result.exit_code), route),
|
|
472
|
+
stack: stackOf(result.stack, route),
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/** A v2 `runGetMethod` answer body, parsed; for callers' quorum predicates. */
|
|
476
|
+
function runResultOf(body) {
|
|
477
|
+
return runOf(v2Result(body, '/runGetMethod'), '/runGetMethod');
|
|
478
|
+
}
|
|
479
|
+
/** A get-method's result with its block and the account's last transaction. */
|
|
480
|
+
function boundRunOf(result, route) {
|
|
481
|
+
const r = need(record(result), route);
|
|
482
|
+
return {
|
|
483
|
+
...runOf(result, route),
|
|
484
|
+
block: blockIdOf(r.block_id, route),
|
|
485
|
+
lastTransaction: transactionIdOf(r.last_transaction_id, route),
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
/** A v2 `runGetMethod` answer body with its binding, parsed; for callers' quorum keys. */
|
|
489
|
+
function boundRunResultOf(body) {
|
|
490
|
+
return boundRunOf(v2Result(body, '/runGetMethod'), '/runGetMethod');
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* A v2 `getTransactions` result: at most `limit` rows, each with its id and a raw cell
|
|
494
|
+
* within an account state's limits, checked in the BOC header before anyone decodes it.
|
|
495
|
+
* What the rows are is for the caller to prove by their hashes.
|
|
496
|
+
*/
|
|
497
|
+
function rawTransactionsOf(result, route, limit) {
|
|
498
|
+
if (!Array.isArray(result) || result.length > limit)
|
|
499
|
+
throw malformed(route);
|
|
500
|
+
return result.map((item) => {
|
|
501
|
+
const row = need(record(item), route);
|
|
502
|
+
const { lt, hash } = transactionIdOf(row.transaction_id, route);
|
|
503
|
+
const boc = need(str(row.data), route);
|
|
504
|
+
if (bocSize(boc, exports.MAX_STATE_CELLS, exports.MAX_STATE_BOC_LENGTH) !== 'ok')
|
|
505
|
+
throw malformed(route);
|
|
506
|
+
return { lt, hash, boc };
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* `get_jetton_data`'s exit code and content cell (TEP-74: total supply, mintable, admin,
|
|
511
|
+
* content, wallet code). Only the content is read, so no other entry (a supply, a large
|
|
512
|
+
* wallet code) is held to anything. A content cell beyond an account state's limits
|
|
513
|
+
* (`MAX_STATE_CELLS`, `MAX_STATE_BOC_LENGTH`) is reported `oversized`, never decoded:
|
|
514
|
+
* no chain content is that large, and a caller that agrees on it under the proof quorum
|
|
515
|
+
* takes it as the token's own, not as an answer to retry forever.
|
|
516
|
+
* A stack that is not one, or a content entry without a BOC header, is malformed.
|
|
517
|
+
*/
|
|
518
|
+
function jettonDataFrom(result, route) {
|
|
519
|
+
const r = need(record(result), route);
|
|
520
|
+
const exitCode = need(int(r.exit_code), route);
|
|
521
|
+
const stack = need(Array.isArray(r.stack) ? r.stack : undefined, route);
|
|
522
|
+
if (exitCode !== 0)
|
|
523
|
+
return { exitCode };
|
|
524
|
+
const entry = stack[3];
|
|
525
|
+
if (entry === undefined)
|
|
526
|
+
return { exitCode };
|
|
527
|
+
if (!Array.isArray(entry) || entry.length !== 2)
|
|
528
|
+
throw malformed(route);
|
|
529
|
+
const [type, data] = entry;
|
|
530
|
+
if (type !== 'cell' &&
|
|
531
|
+
type !== 'slice' &&
|
|
532
|
+
type !== 'tvm.Cell' &&
|
|
533
|
+
type !== 'tvm.Slice') {
|
|
534
|
+
return { exitCode };
|
|
535
|
+
}
|
|
536
|
+
const boc = need(str(isRecord(data) ? data.bytes : data), route);
|
|
537
|
+
const size = bocSize(boc, exports.MAX_STATE_CELLS, exports.MAX_STATE_BOC_LENGTH);
|
|
538
|
+
if (size === 'malformed')
|
|
539
|
+
throw malformed(route);
|
|
540
|
+
return {
|
|
541
|
+
exitCode,
|
|
542
|
+
content: size === 'oversized' ? { kind: 'oversized' } : { kind: 'cell', boc },
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
/** A v2 `get_jetton_data` answer body, parsed; for callers' quorum keys. */
|
|
546
|
+
function jettonDataOf(body) {
|
|
547
|
+
return jettonDataFrom(v2Result(body, '/runGetMethod'), '/runGetMethod');
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* A trace, parsed: its transactions in trace order, each listed once under its own hash
|
|
551
|
+
* (a transaction counted twice would count its transfer twice). An emulated or not yet
|
|
552
|
+
* finalized one is left out and leaves the trace incomplete.
|
|
553
|
+
*/
|
|
554
|
+
function traceOf(value, route) {
|
|
555
|
+
const t = need(record(value), route);
|
|
556
|
+
const info = isRecord(t.trace_info) ? t.trace_info : {};
|
|
557
|
+
const txs = need(record(t.transactions), route);
|
|
558
|
+
const order = need(Array.isArray(t.transactions_order) ? t.transactions_order : undefined, route);
|
|
559
|
+
const listed = new Set();
|
|
560
|
+
const entries = order.map((item) => {
|
|
561
|
+
const key = need(str(item), route);
|
|
562
|
+
const hash = need(hashHex(key), route);
|
|
563
|
+
if (listed.has(hash) || !Object.hasOwn(txs, key))
|
|
564
|
+
throw malformed(route);
|
|
565
|
+
listed.add(hash);
|
|
566
|
+
const value = txs[key];
|
|
567
|
+
if (!committed(value))
|
|
568
|
+
return undefined;
|
|
569
|
+
const tx = transactionOf(value, route);
|
|
570
|
+
if (tx.hash !== hash)
|
|
571
|
+
throw malformed(route);
|
|
572
|
+
return tx;
|
|
573
|
+
});
|
|
574
|
+
return {
|
|
575
|
+
traceId: need(hashHex(t.trace_id), route),
|
|
576
|
+
complete: t.is_incomplete === false &&
|
|
577
|
+
info.trace_state === 'complete' &&
|
|
578
|
+
entries.every((tx) => tx !== undefined),
|
|
579
|
+
transactions: entries.filter((tx) => tx !== undefined),
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* One `/metadata` token entry, the indexer's copy of the token's
|
|
584
|
+
* off-chain JSON. Only the fields a caller may use are read, and each as the token wrote it:
|
|
585
|
+
* a symbol or decimals that are not one are `null` (the token's own data, which every
|
|
586
|
+
* endpoint agrees on, so never malformed and retried forever); a name beyond its limit is
|
|
587
|
+
* absent. toncenter writes the JSON's decimals under `extra` (live, 2026-09-28).
|
|
588
|
+
*/
|
|
589
|
+
function tokenInfoOf(token) {
|
|
590
|
+
const info = {};
|
|
591
|
+
const { symbol, name, extra } = token;
|
|
592
|
+
if (symbol !== undefined && symbol !== null) {
|
|
593
|
+
info.symbol =
|
|
594
|
+
typeof symbol === 'string' && symbol.length <= CONTENT_LIMITS.symbol
|
|
595
|
+
? symbol
|
|
596
|
+
: null;
|
|
597
|
+
}
|
|
598
|
+
if (typeof name === 'string' && name.length <= CONTENT_LIMITS.name)
|
|
599
|
+
info.name = name;
|
|
600
|
+
if (extra !== undefined && extra !== null) {
|
|
601
|
+
const decimals = isRecord(extra) ? extra.decimals : null;
|
|
602
|
+
const value = int(decimals);
|
|
603
|
+
if (!isRecord(extra))
|
|
604
|
+
info.decimals = null;
|
|
605
|
+
else if (decimals !== undefined && decimals !== null) {
|
|
606
|
+
info.decimals =
|
|
607
|
+
value !== undefined && value >= 0 && value <= 255 ? String(value) : null;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return info;
|
|
611
|
+
}
|
|
612
|
+
// ---- quorum facts -------------------------------------------------------------------------
|
|
613
|
+
// Each method's key is its parsed value: honest endpoints that format a fact
|
|
614
|
+
// differently (a number or a string, `uninit` or `uninitialized`, v2's `@extra`) agree, and
|
|
615
|
+
// a key that throws is a disagreement. A key covers every field a verdict reads;
|
|
616
|
+
// message bodies are left out (their serialization varies) and are bound to the keyed body
|
|
617
|
+
// hash where they are decoded (`messageBody`). The transport compares keys as canonical
|
|
618
|
+
// JSON, bigints included.
|
|
619
|
+
/** Every fact of a transaction a verdict or a decoding reads, bodies as their hashes. */
|
|
620
|
+
function factsOf(tx) {
|
|
621
|
+
const { inMsg, outMsgs, ...facts } = tx;
|
|
622
|
+
const message = (m) => {
|
|
623
|
+
if (!m)
|
|
624
|
+
return null;
|
|
625
|
+
const { body: _body, ...rest } = m;
|
|
626
|
+
return rest;
|
|
627
|
+
};
|
|
628
|
+
return { ...facts, inMsg: message(inMsg), outMsgs: outMsgs.map(message) };
|
|
629
|
+
}
|
|
630
|
+
/** A trace's id, completeness and every transaction's facts, in trace order. */
|
|
631
|
+
function traceFacts(trace) {
|
|
632
|
+
return trace && { ...trace, transactions: trace.transactions.map(factsOf) };
|
|
633
|
+
}
|
|
634
|
+
const itself = (value) => value;
|
|
635
|
+
/** The most transactions a message hash can name (a few forks of one external, retried). */
|
|
636
|
+
const BY_MESSAGE_LIMIT = 8;
|
|
637
|
+
class TonApi {
|
|
638
|
+
rpc;
|
|
639
|
+
indexer;
|
|
640
|
+
constructor(rpc, indexer) {
|
|
641
|
+
this.rpc = rpc;
|
|
642
|
+
this.indexer = indexer;
|
|
643
|
+
}
|
|
644
|
+
/** The rpc transport's lag tolerance, as the pool resolved it; proofs' last skew. */
|
|
645
|
+
get lagTolerance() {
|
|
646
|
+
return this.rpc.maxLagBlocks;
|
|
647
|
+
}
|
|
648
|
+
async #call(transport, request, tags, quorumKey) {
|
|
649
|
+
// The caller's key (a predicate) replaces the call's consensus facts.
|
|
650
|
+
const key = tags.quorumKey ?? quorumKey;
|
|
651
|
+
const options = {
|
|
652
|
+
...tags,
|
|
653
|
+
exactIntegers: true,
|
|
654
|
+
...(tags.quorum !== undefined ? { quorumKey: key } : {}),
|
|
655
|
+
};
|
|
656
|
+
try {
|
|
657
|
+
return await transport.http(request, options);
|
|
658
|
+
}
|
|
659
|
+
catch (error) {
|
|
660
|
+
// On a proof or monitor read, any definitive RPC error,
|
|
661
|
+
// whatever its text (a block the endpoint does not hold yet, pruned state, a provider
|
|
662
|
+
// that answers 4xx rather than toncenter's 500), decides nothing. TON's negatives come
|
|
663
|
+
// only from attested state, never from an error, so no error text is read here.
|
|
664
|
+
// A misconfigured endpoint (`PROVIDER_MISCONFIGURED`) still surfaces as the
|
|
665
|
+
// configuration error it is.
|
|
666
|
+
if ((tags.purpose === 'proof' || tags.purpose === 'monitor') &&
|
|
667
|
+
(0, error_1.isCryptoAioError)(error, 'RPC_ERROR') &&
|
|
668
|
+
!error.retryable) {
|
|
669
|
+
throw new error_1.ProviderError('PROVIDER_UNAVAILABLE', `${request.route ?? 'a state read'} was refused; deciding nothing`, { retryable: true, cause: error });
|
|
670
|
+
}
|
|
671
|
+
throw error;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* One request whose answer `parse` validates. Under a quorum, each endpoint's answer is
|
|
676
|
+
* keyed on `facts` of its parsed value: the fields a verdict reads, never the envelope.
|
|
677
|
+
*/
|
|
678
|
+
async #read(transport, request, tags, parse, facts = itself) {
|
|
679
|
+
const body = await this.#call(transport, request, tags, (answer) => facts(parse(answer, 'quorum')));
|
|
680
|
+
return parse(body, request.route);
|
|
681
|
+
}
|
|
682
|
+
#v2(route, query, tags, parse, facts) {
|
|
683
|
+
return this.#read(this.rpc, { method: 'GET', path: route, query, route }, tags, (body, label) => parse(v2Result(body, label), label), facts);
|
|
684
|
+
}
|
|
685
|
+
#v2Post(route, body, tags, parse, facts) {
|
|
686
|
+
return this.#read(this.rpc, { method: 'POST', path: route, body, route }, tags, (answer, label) => parse(v2Result(answer, label), label), facts);
|
|
687
|
+
}
|
|
688
|
+
#v3(route, query, tags, parse, facts) {
|
|
689
|
+
return this.#read(this.indexer, { method: 'GET', path: route, query, route }, tags, parse, facts);
|
|
690
|
+
}
|
|
691
|
+
/** The newest masterchain block the liteserver knows. */
|
|
692
|
+
masterchainHead(tags) {
|
|
693
|
+
return this.#v2('/getMasterchainInfo', {}, tags, (result, route) => masterchainIdSeqno(record(result)?.last, route));
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Whether the liteserver holds masterchain block `seqno` (every masterchain block is
|
|
697
|
+
* final once it exists). Under a quorum the key is this predicate: endpoints
|
|
698
|
+
* past `seqno` agree whatever their heads.
|
|
699
|
+
*/
|
|
700
|
+
reachedMasterchain(seqno, tags) {
|
|
701
|
+
return this.#v2('/getMasterchainInfo', {}, tags, (result, route) => masterchainIdSeqno(record(result)?.last, route) >= seqno);
|
|
702
|
+
}
|
|
703
|
+
/** A block's header; `seqno` above the endpoint's head fails (retryable). */
|
|
704
|
+
blockHeader(block, tags) {
|
|
705
|
+
return this.#v2('/getBlockHeader', {
|
|
706
|
+
workchain: String(block.workchain),
|
|
707
|
+
shard: block.shard,
|
|
708
|
+
seqno: String(block.seqno),
|
|
709
|
+
}, tags, headerOf,
|
|
710
|
+
// The facts a proof reads; `prev_blocks` only feeds `getBlock`'s parent hash (a `read`).
|
|
711
|
+
({ prev: _prev, ...facts }) => facts);
|
|
712
|
+
}
|
|
713
|
+
masterchainHeader(seqno, tags) {
|
|
714
|
+
return this.blockHeader({ workchain: -1, shard: exports.MASTERCHAIN_SHARD, seqno }, tags);
|
|
715
|
+
}
|
|
716
|
+
/** The shard blocks masterchain block `seqno` commits. */
|
|
717
|
+
shards(seqno, tags) {
|
|
718
|
+
return this.#v2('/getShards', { seqno: String(seqno) }, tags, (result, route) => need(isRecord(result) && Array.isArray(result.shards) ? result.shards : undefined, route).map((s) => blockIdOf(s, route)));
|
|
719
|
+
}
|
|
720
|
+
/** A config param's cell (base64 BOC, within one message's limits). */
|
|
721
|
+
configParam(param, tags, seqno) {
|
|
722
|
+
return this.#v2('/getConfigParam', {
|
|
723
|
+
param: String(param),
|
|
724
|
+
...(seqno !== undefined ? { seqno: String(seqno) } : {}),
|
|
725
|
+
}, tags, (result, route) => cellOf(need(isRecord(result) ? record(result.config) : undefined, route).bytes, route));
|
|
726
|
+
}
|
|
727
|
+
/** An account's state, at masterchain block `seqno` when given. */
|
|
728
|
+
account(address, tags, seqno) {
|
|
729
|
+
return this.#v2('/getAddressInformation', { address, ...(seqno !== undefined ? { seqno: String(seqno) } : {}) }, tags, accountOf,
|
|
730
|
+
// `sync_utime` is when the endpoint answered, not a fact of the state at that block.
|
|
731
|
+
({ syncUtime: _syncUtime, ...facts }) => facts);
|
|
732
|
+
}
|
|
733
|
+
/** A get-method, at masterchain block `seqno` when given. */
|
|
734
|
+
runGetMethod(address, method, stack, tags, seqno) {
|
|
735
|
+
return this.#v2Post('/runGetMethod', { address, method, stack, ...(seqno !== undefined ? { seqno } : {}) }, tags, runOf);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* A get-method at masterchain block `seqno`, with the block and the account's last
|
|
739
|
+
* transaction the answer names: a caller binds the result to the state it
|
|
740
|
+
* read, since an endpoint that drops the block answers at its own latest state.
|
|
741
|
+
*/
|
|
742
|
+
runGetMethodAt(address, method, stack, tags, seqno) {
|
|
743
|
+
return this.#v2Post('/runGetMethod', { address, method, stack, seqno }, tags, boundRunOf);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Up to `limit` of an account's transactions (a raw address) from `from` back, as the
|
|
747
|
+
* liteserver serves them (v2 `getTransactions`), each with its raw cell. Under a quorum
|
|
748
|
+
* the endpoints agree on the ids; the cells are the caller's to hash.
|
|
749
|
+
*/
|
|
750
|
+
async rawTransactions(address, from, limit, tags) {
|
|
751
|
+
rawAddress(address);
|
|
752
|
+
return this.#v2('/getTransactions', {
|
|
753
|
+
address,
|
|
754
|
+
lt: from.lt.toString(),
|
|
755
|
+
hash: from.hash,
|
|
756
|
+
limit: String(limit),
|
|
757
|
+
// A walk may reach old history, which only archive liteservers hold.
|
|
758
|
+
archival: 'true',
|
|
759
|
+
}, tags, (result, route) => rawTransactionsOf(result, route, limit), (rows) => rows.map(({ lt, hash }) => ({ lt, hash })));
|
|
760
|
+
}
|
|
761
|
+
/** A jetton master's `get_jetton_data`: its exit code and content cell (`jettonDataOf`). */
|
|
762
|
+
jettonData(master, tags, seqno) {
|
|
763
|
+
return this.#v2Post('/runGetMethod', {
|
|
764
|
+
address: master,
|
|
765
|
+
method: 'get_jetton_data',
|
|
766
|
+
stack: [],
|
|
767
|
+
...(seqno !== undefined ? { seqno } : {}),
|
|
768
|
+
}, tags, jettonDataFrom);
|
|
769
|
+
}
|
|
770
|
+
/** The emulated source fees of an external message body (signature check skipped). */
|
|
771
|
+
estimateFee(request, tags) {
|
|
772
|
+
return this.#v2Post('/estimateFee', {
|
|
773
|
+
address: request.address,
|
|
774
|
+
body: request.body,
|
|
775
|
+
init_code: request.initCode ?? '',
|
|
776
|
+
init_data: request.initData ?? '',
|
|
777
|
+
ignore_chksig: true,
|
|
778
|
+
}, tags, (result, route) => {
|
|
779
|
+
// toncenter writes these fees as JSON numbers: read exactly, as coins.
|
|
780
|
+
const fees = need(isRecord(result) ? record(result.source_fees) : undefined, route);
|
|
781
|
+
return {
|
|
782
|
+
importFee: need(coins(fees.in_fwd_fee), route),
|
|
783
|
+
storageFee: need(coins(fees.storage_fee), route),
|
|
784
|
+
gasFee: need(coins(fees.gas_fee), route),
|
|
785
|
+
forwardFee: need(coins(fees.fwd_fee), route),
|
|
786
|
+
};
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
/** Sends an external message; resolves with the node's hashes (hex). */
|
|
790
|
+
send(boc, tags) {
|
|
791
|
+
return this.#v2Post('/sendBocReturnHash', { boc }, tags, (result, route) => {
|
|
792
|
+
const r = need(record(result), route);
|
|
793
|
+
return {
|
|
794
|
+
hash: need(hashHex(r.hash), route),
|
|
795
|
+
hashNorm: need(hashHex(r.hash_norm), route),
|
|
796
|
+
};
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
/** The indexer's newest indexed masterchain block and the network's global id. */
|
|
800
|
+
indexerHead(tags) {
|
|
801
|
+
return this.#v3('/masterchainInfo', {}, tags, indexedHeadOf);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Whether the indexer has indexed masterchain block `seqno`. Under a quorum the key is
|
|
805
|
+
* this predicate: indexers past `seqno` agree whatever their heads.
|
|
806
|
+
*/
|
|
807
|
+
indexerReached(seqno, tags) {
|
|
808
|
+
return this.#v3('/masterchainInfo', {}, tags, (body, route) => indexedHeadOf(body, route).seqno >= seqno);
|
|
809
|
+
}
|
|
810
|
+
/** The seqno of the masterchain block with this root hash (hex); null if unknown. */
|
|
811
|
+
masterchainSeqnoOf(rootHash, tags) {
|
|
812
|
+
const wanted = hashHex(rootHash);
|
|
813
|
+
return this.#v3('/blocks', { workchain: '-1', root_hash: rootHash, limit: '1' }, tags, (body, route) => {
|
|
814
|
+
if (!isRecord(body) || !Array.isArray(body.blocks) || body.blocks.length > 1) {
|
|
815
|
+
throw malformed(route);
|
|
816
|
+
}
|
|
817
|
+
for (const item of body.blocks) {
|
|
818
|
+
const block = need(record(item), route);
|
|
819
|
+
const workchain = need(int(block.workchain), route);
|
|
820
|
+
// A lookup by id keeps only the block asked for.
|
|
821
|
+
if (workchain === -1 && need(hashHex(block.root_hash), route) === wanted) {
|
|
822
|
+
return need(int(block.seqno), route);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return null;
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Committed transactions whose inbound message has this raw or normalized hash (hex).
|
|
830
|
+
* Only those; a dropped filter's strangers read as "none yet".
|
|
831
|
+
*/
|
|
832
|
+
transactionsByMessage(hash, tags) {
|
|
833
|
+
const wanted = hashHex(hash);
|
|
834
|
+
return this.#v3('/transactionsByMessage', { msg_hash: hash, direction: 'in', limit: String(BY_MESSAGE_LIMIT) }, tags, (body, route) => transactionsOf(body, route, BY_MESSAGE_LIMIT).filter((tx) => wanted !== undefined &&
|
|
835
|
+
tx.inMsg !== null &&
|
|
836
|
+
(tx.inMsg.hash === wanted || tx.inMsg.hashNorm === wanted)), (txs) => txs.map(factsOf));
|
|
837
|
+
}
|
|
838
|
+
/** The committed transaction with this hash; null when the indexer has none (yet). */
|
|
839
|
+
transaction(hash, tags) {
|
|
840
|
+
const wanted = hashHex(hash);
|
|
841
|
+
return this.#v3('/transactions', { hash, limit: '1' }, tags, (body, route) => transactionsOf(body, route, 1).find((tx) => tx.hash === wanted) ?? null, (tx) => (tx ? factsOf(tx) : null));
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* One page of an account's transactions (a raw address), newest first, at or below
|
|
845
|
+
* `endLt` when given, with the next page's `endLt` when this one was full. An answer that
|
|
846
|
+
* breaks the query (another account, an lt out of order or above `endLt`, more than
|
|
847
|
+
* `limit`), counting the transactions not yet final, is malformed: a verdict reads it as
|
|
848
|
+
* the account's history. `next` comes from the page as served, so a page whose
|
|
849
|
+
* newest transactions are not yet final still leads to the older ones.
|
|
850
|
+
*/
|
|
851
|
+
async accountTransactionsPage(account, options, tags) {
|
|
852
|
+
const wanted = rawAddress(account);
|
|
853
|
+
return this.#v3('/transactions', {
|
|
854
|
+
account,
|
|
855
|
+
limit: String(options.limit),
|
|
856
|
+
sort: 'desc',
|
|
857
|
+
...(options.endLt !== undefined ? { end_lt: options.endLt.toString() } : {}),
|
|
858
|
+
}, tags, (body, route) => {
|
|
859
|
+
if (!isRecord(body) ||
|
|
860
|
+
!Array.isArray(body.transactions) ||
|
|
861
|
+
body.transactions.length > options.limit) {
|
|
862
|
+
throw malformed(route);
|
|
863
|
+
}
|
|
864
|
+
const transactions = [];
|
|
865
|
+
let below = options.endLt === undefined ? undefined : options.endLt + 1n;
|
|
866
|
+
let last;
|
|
867
|
+
for (const item of body.transactions) {
|
|
868
|
+
const t = need(record(item), route);
|
|
869
|
+
const lt = need(u64(t.lt), route);
|
|
870
|
+
if (rawOf(t.account) !== wanted || (below !== undefined && lt >= below)) {
|
|
871
|
+
throw malformed(route);
|
|
872
|
+
}
|
|
873
|
+
below = lt;
|
|
874
|
+
last = lt;
|
|
875
|
+
if (committed(item))
|
|
876
|
+
transactions.push(transactionOf(item, route));
|
|
877
|
+
}
|
|
878
|
+
const full = body.transactions.length === options.limit;
|
|
879
|
+
return {
|
|
880
|
+
transactions,
|
|
881
|
+
...(full && last !== undefined && last > 0n ? { next: last - 1n } : {}),
|
|
882
|
+
};
|
|
883
|
+
}, (page) => ({
|
|
884
|
+
transactions: page.transactions.map(factsOf),
|
|
885
|
+
next: page.next ?? null,
|
|
886
|
+
}));
|
|
887
|
+
}
|
|
888
|
+
/** An account's committed transactions: one page (`accountTransactionsPage`). */
|
|
889
|
+
async accountTransactions(account, options, tags) {
|
|
890
|
+
return (await this.accountTransactionsPage(account, options, tags)).transactions;
|
|
891
|
+
}
|
|
892
|
+
/** The trace that holds this transaction; null when the indexer has none (yet). */
|
|
893
|
+
trace(txHash, tags) {
|
|
894
|
+
const wanted = hashHex(txHash);
|
|
895
|
+
return this.#v3('/traces', { tx_hash: txHash, include_actions: 'false', limit: '1' }, tags, (body, route) => {
|
|
896
|
+
if (!isRecord(body) || !Array.isArray(body.traces) || body.traces.length > 1) {
|
|
897
|
+
throw malformed(route);
|
|
898
|
+
}
|
|
899
|
+
for (const value of body.traces) {
|
|
900
|
+
const trace = traceOf(value, route);
|
|
901
|
+
// A lookup by id keeps only the trace asked for.
|
|
902
|
+
if (trace.transactions.some((tx) => tx.hash === wanted))
|
|
903
|
+
return trace;
|
|
904
|
+
}
|
|
905
|
+
return null;
|
|
906
|
+
}, traceFacts);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* The indexer's metadata for a raw token address: its first valid jetton entry
|
|
910
|
+
* (`tokenInfoOf`). Undefined while the indexer has none: no entry (an unknown address, a
|
|
911
|
+
* lagging index or a dropped filter all read alike), an entry not indexed yet, or no
|
|
912
|
+
* valid metadata fetched (yet), so a caller never takes it for a definitive answer.
|
|
913
|
+
*/
|
|
914
|
+
async tokenInfo(address, tags) {
|
|
915
|
+
const wanted = rawAddress(address);
|
|
916
|
+
return this.#v3('/metadata', { address }, tags, (body, route) => {
|
|
917
|
+
if (!isRecord(body))
|
|
918
|
+
throw malformed(route);
|
|
919
|
+
for (const [key, value] of Object.entries(body)) {
|
|
920
|
+
// The answer is keyed by address; a lookup by id reads only its own entry.
|
|
921
|
+
if (rawOf(key) !== wanted)
|
|
922
|
+
continue;
|
|
923
|
+
const entry = need(record(value), route);
|
|
924
|
+
if (optional(entry.is_indexed, bool, route) === false)
|
|
925
|
+
return undefined;
|
|
926
|
+
const info = optional(entry.token_info, (v) => (Array.isArray(v) ? v : undefined), route) ?? [];
|
|
927
|
+
for (const item of info) {
|
|
928
|
+
const token = need(record(item), route);
|
|
929
|
+
const type = optional(token.type, str, route);
|
|
930
|
+
if (token.valid === false ||
|
|
931
|
+
(type !== undefined && type !== 'jetton_masters')) {
|
|
932
|
+
continue;
|
|
933
|
+
}
|
|
934
|
+
return tokenInfoOf(token);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return undefined;
|
|
938
|
+
}, (info) => info ?? null);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
exports.TonApi = TonApi;
|
|
942
|
+
//# sourceMappingURL=api.js.map
|