crypto-aio 0.0.2 → 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/lib-types.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/adapters/ton/types.js +3 -0
- 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/core/model/transaction.js +3 -0
- 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 -44
- 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 -2
- package/dist/libs/eth/contract.js +0 -7
- package/dist/libs/eth/contract.js.map +0 -1
- package/dist/libs/eth/index.d.ts +0 -20
- package/dist/libs/eth/index.js +0 -62
- package/dist/libs/eth/index.js.map +0 -1
- package/dist/libs/eth/transact.d.ts +0 -2
- package/dist/libs/eth/transact.js +0 -7
- package/dist/libs/eth/transact.js.map +0 -1
- package/dist/libs/index.d.ts +0 -1
- package/dist/libs/index.js +0 -18
- package/dist/libs/index.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 -4
- package/dist/tool/index.js +0 -21
- 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 -4
- package/dist/tool/options.js +0 -28
- package/dist/tool/options.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/index.d.ts +0 -3
- package/dist/type/index.js +0 -20
- package/dist/type/index.js.map +0 -1
- package/dist/type/lib-types.d.ts +0 -7
- package/dist/type/lib-types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protobuf.js","sourceRoot":"","sources":["../../../src/adapters/tron/protobuf.ts"],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AAE,KAAK,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACpE,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;gBAC9E,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,4EAA4E;AACrE,MAAM,OAAO,GAAG,CAAC,KAA4B,EAAqB,EAAE,CACzE,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AADhC,QAAA,OAAO,WACyB","sourcesContent":["/**\n * The protobuf wire reader the Tron family shares: the codec (`codec.ts`) reads\n * chain transactions with it, and the broadcast classifier (`errors.ts`) the bytes it sent.\n * SDK-free, so the classifier never loads tronweb. Linear in the input: each\n * length is checked against the bytes left before it is used, a varint stops at 64 bits,\n * and field number 0, a group or an unknown wire type makes the message unreadable (`null`),\n * as does a truncated field.\n */\n\n/** A varint as a bigint, length-delimited bytes, or `null` for an opaque fixed-width field. */\nexport type WireValue = bigint | Uint8Array | null;\n\nexport interface WireField {\n readonly field: number;\n readonly value: WireValue;\n /** The field's encoded length, tag included. */\n readonly length: number;\n}\n\n/**\n * What a reader does with a fixed-width field (wire types 1 and 5): `opaque` keeps it as a\n * `null` value, for chain data that may carry fields the reader never reads (the codec);\n * `refuse` makes the message unreadable, for a reader that names every field it accepts\n * (the classifier).\n */\nexport type FixedWidth = 'opaque' | 'refuse';\n\n/** The wire type a known field must have (`singular`). */\nexport type FieldKinds = Readonly<Record<number, 'varint' | 'bytes'>>;\n\n/** One protobuf message's fields, in order; `null` when the bytes do not read. */\nexport function wireFields(bytes: Uint8Array, fixed: FixedWidth): WireField[] | null {\n const out: WireField[] = [];\n let i = 0;\n const varint = (): bigint | null => {\n let result = 0n;\n for (let shift = 0n; shift < 64n; shift += 7n) {\n const byte = bytes[i++];\n // The tenth byte carries the 64th bit only.\n if (byte === undefined || (shift === 63n && byte > 1)) return null;\n result |= BigInt(byte & 0x7f) << shift;\n if ((byte & 0x80) === 0) return result;\n }\n return null;\n };\n while (i < bytes.length) {\n const start = i;\n const key = varint();\n if (key === null || key >> 3n === 0n) return null;\n const wire = key & 7n;\n let value: WireValue;\n if (wire === 0n) {\n value = varint();\n if (value === null) return null;\n } else if (wire === 2n) {\n const length = varint();\n if (length === null || length > BigInt(bytes.length - i)) return null;\n value = bytes.subarray(i, i + Number(length));\n i += Number(length);\n } else if ((wire === 1n || wire === 5n) && fixed === 'opaque') {\n i += wire === 1n ? 8 : 4;\n if (i > bytes.length) return null;\n value = null;\n } else {\n return null;\n }\n out.push({ field: Number(key >> 3n), value, length: i - start });\n }\n return out;\n}\n\n/**\n * A message whose fields are each singular, by number; `null` when the bytes do not read or\n * a field number repeats, so a value is never guessed between protobuf's merge and last-wins\n * rules. With `kinds`, only the listed fields are accepted, each of its wire type, and a\n * fixed-width field is refused; without, any field is kept and a fixed-width one is opaque.\n */\nexport function singular(\n bytes: Uint8Array | null,\n kinds?: FieldKinds,\n): Map<number, WireValue> | null {\n const fields = bytes ? wireFields(bytes, kinds ? 'refuse' : 'opaque') : null;\n if (!fields) return null;\n const out = new Map<number, WireValue>();\n for (const { field, value } of fields) {\n if (out.has(field)) return null;\n if (kinds) {\n const kind = Object.hasOwn(kinds, field) ? kinds[field] : undefined;\n if (kind === undefined || (kind === 'varint') !== (typeof value === 'bigint')) {\n return null;\n }\n }\n out.set(field, value);\n }\n return out;\n}\n\n/** A field's bytes, or `null` when it is absent or not length-delimited. */\nexport const bytesOf = (value: WireValue | undefined): Uint8Array | null =>\n value instanceof Uint8Array ? value : null;\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tron `ChainReader` and `ext.tron`. Tags follow the `ChainDriver` contract table:
|
|
3
|
+
* reads `read`, heights and `observe` `monitor`. Addresses reach the node as `41…` hex.
|
|
4
|
+
* A transaction the node holds but cannot serve whole yet (its receipt, its block) is a
|
|
5
|
+
* retryable `PROVIDER_UNAVAILABLE`, never "not seen".
|
|
6
|
+
*/
|
|
7
|
+
import type { ChainReader, DriverTxObservation } from '../../core/driver/types';
|
|
8
|
+
import type { Logger } from '../../core/events/logger';
|
|
9
|
+
import type { AssetRef } from '../../core/model/asset';
|
|
10
|
+
import type { ChainInfo, NetworkInfo } from '../../core/model/chain';
|
|
11
|
+
import type { Clock } from '../../core/util/clock';
|
|
12
|
+
import { type TronApi } from './http';
|
|
13
|
+
import type { TronNetworkConfig } from './network';
|
|
14
|
+
import type { TronCallTags, TronCodec, TronExt } from './types';
|
|
15
|
+
export interface TronContext {
|
|
16
|
+
readonly api: TronApi;
|
|
17
|
+
readonly codec: TronCodec;
|
|
18
|
+
readonly chain: ChainInfo;
|
|
19
|
+
readonly network: NetworkInfo;
|
|
20
|
+
readonly config: TronNetworkConfig;
|
|
21
|
+
readonly clock: Clock;
|
|
22
|
+
readonly log: Logger;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The `41…` hex contract of a TRC-20 ref. `UNSUPPORTED_CAPABILITY` for TRX or another token
|
|
26
|
+
* standard; `ASSET_RESOLUTION` for a contract that is not a Tron address.
|
|
27
|
+
*/
|
|
28
|
+
export declare function trc20Contract(ref: AssetRef): string;
|
|
29
|
+
/**
|
|
30
|
+
* A constant call on a token: a revert, a VM failure or no contract is the
|
|
31
|
+
* token's own permanent problem (`ASSET_RESOLUTION`, cached by the core); node refusals stay
|
|
32
|
+
* retryable and every other error propagates unchanged. "No contract" is a node's text, so
|
|
33
|
+
* it counts only once `/wallet/getcontract` confirms it structurally with the same tags; a
|
|
34
|
+
* node that shows a contract there decides nothing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tokenCall(ctx: TronContext, owner: string, contract: string, data: string, tags: TronCallTags): Promise<string>;
|
|
37
|
+
/** A holder's TRC-20 balance. */
|
|
38
|
+
export declare function trc20Balance(ctx: TronContext, contract: string, holder: string, tags?: TronCallTags): Promise<bigint>;
|
|
39
|
+
/**
|
|
40
|
+
* An included transaction's observation. `guard` applies the verdict guard (on-chain
|
|
41
|
+
* evidence that value moved) to our own Attempts; without it (a status lookup by id,
|
|
42
|
+
* `ordering === undefined`), the chain's own view is reported.
|
|
43
|
+
*/
|
|
44
|
+
export declare function observeIncluded(ctx: TronContext, id: string, tags: TronCallTags, guard: boolean): Promise<DriverTxObservation | null>;
|
|
45
|
+
export declare function createTronReader(ctx: TronContext): ChainReader;
|
|
46
|
+
/** `ext.tron`, the Tron family extension. */
|
|
47
|
+
export declare function createTronExt(ctx: TronContext): TronExt;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trc20Contract = trc20Contract;
|
|
4
|
+
exports.tokenCall = tokenCall;
|
|
5
|
+
exports.trc20Balance = trc20Balance;
|
|
6
|
+
exports.observeIncluded = observeIncluded;
|
|
7
|
+
exports.createTronReader = createTronReader;
|
|
8
|
+
exports.createTronExt = createTronExt;
|
|
9
|
+
const error_1 = require("../../core/errors/error");
|
|
10
|
+
const abi_1 = require("./abi");
|
|
11
|
+
const address_1 = require("./address");
|
|
12
|
+
const decode_1 = require("./decode");
|
|
13
|
+
const http_1 = require("./http");
|
|
14
|
+
const TX_ID = /^[0-9a-f]{64}$/;
|
|
15
|
+
/** java-tron's block heights are `long`s. */
|
|
16
|
+
const INT64_MAX = 2n ** 63n - 1n;
|
|
17
|
+
/** A lower-case transaction or block id, or `null` (length checked before any work). */
|
|
18
|
+
function idOf(value) {
|
|
19
|
+
if (typeof value !== 'string' || value.length !== 64)
|
|
20
|
+
return null;
|
|
21
|
+
const id = value.toLowerCase();
|
|
22
|
+
return TX_ID.test(id) ? id : null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Token metadata is read under the proof quorum: the core caches a token's decimals,
|
|
26
|
+
* symbol and "no such token" for the container's life, so one lagging or buggy endpoint
|
|
27
|
+
* must not decide them. The constant call's quorum key compares the verdict only, since
|
|
28
|
+
* honest nodes never agree on its whole answer; endpoints that disagree throw retryable
|
|
29
|
+
* `PROVIDER_INCONSISTENT`.
|
|
30
|
+
*/
|
|
31
|
+
const METADATA = { ...http_1.READ, quorum: 'proof' };
|
|
32
|
+
function tokenProblem(reason) {
|
|
33
|
+
return new error_1.ValidationError('ASSET_RESOLUTION', `TRC-20 token unusable: ${reason}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The `41…` hex contract of a TRC-20 ref. `UNSUPPORTED_CAPABILITY` for TRX or another token
|
|
37
|
+
* standard; `ASSET_RESOLUTION` for a contract that is not a Tron address.
|
|
38
|
+
*/
|
|
39
|
+
function trc20Contract(ref) {
|
|
40
|
+
if (ref === 'native' || ref.standard !== 'trc20') {
|
|
41
|
+
throw new error_1.UnsupportedCapabilityError('UNSUPPORTED_CAPABILITY', 'Tron supports TRX and TRC-20 tokens only');
|
|
42
|
+
}
|
|
43
|
+
if (!(0, address_1.isTronAddress)(ref.contract))
|
|
44
|
+
throw tokenProblem('not a Tron contract address');
|
|
45
|
+
return (0, address_1.toHexAddress)(ref.contract);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A constant call on a token: a revert, a VM failure or no contract is the
|
|
49
|
+
* token's own permanent problem (`ASSET_RESOLUTION`, cached by the core); node refusals stay
|
|
50
|
+
* retryable and every other error propagates unchanged. "No contract" is a node's text, so
|
|
51
|
+
* it counts only once `/wallet/getcontract` confirms it structurally with the same tags; a
|
|
52
|
+
* node that shows a contract there decides nothing.
|
|
53
|
+
*/
|
|
54
|
+
async function tokenCall(ctx, owner, contract, data, tags) {
|
|
55
|
+
const answer = await ctx.api.constantCall(owner, contract, data, tags);
|
|
56
|
+
if (answer.kind === 'no-contract') {
|
|
57
|
+
if (await ctx.api.contractExists(contract, tags)) {
|
|
58
|
+
throw new error_1.ProviderError('PROVIDER_INCONSISTENT', 'the node both holds and lacks this contract', { retryable: true });
|
|
59
|
+
}
|
|
60
|
+
throw tokenProblem('no contract at this address');
|
|
61
|
+
}
|
|
62
|
+
if (answer.kind === 'failed')
|
|
63
|
+
throw tokenProblem('the call failed');
|
|
64
|
+
return answer.result;
|
|
65
|
+
}
|
|
66
|
+
/** A holder's TRC-20 balance. */
|
|
67
|
+
async function trc20Balance(ctx, contract, holder, tags = http_1.READ) {
|
|
68
|
+
const result = await tokenCall(ctx, (0, address_1.toHexAddress)(holder), contract, (0, abi_1.encodeBalanceOf)(holder), tags);
|
|
69
|
+
try {
|
|
70
|
+
return (0, abi_1.decodeUint256)(result);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
throw tokenProblem('balanceOf returned no uint256');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* An included transaction's observation. `guard` applies the verdict guard (on-chain
|
|
78
|
+
* evidence that value moved) to our own Attempts; without it (a status lookup by id,
|
|
79
|
+
* `ordering === undefined`), the chain's own view is reported.
|
|
80
|
+
*/
|
|
81
|
+
async function observeIncluded(ctx, id, tags, guard) {
|
|
82
|
+
const info = await ctx.api.transactionInfo('full', id, tags);
|
|
83
|
+
if (!info)
|
|
84
|
+
return null;
|
|
85
|
+
const [tx, header] = await Promise.all([
|
|
86
|
+
ctx.api.transaction('full', id, tags),
|
|
87
|
+
ctx.api.block('full', info.blockNumber, tags),
|
|
88
|
+
]);
|
|
89
|
+
// The node indexed the info but cannot serve the transaction or its block yet: decide
|
|
90
|
+
// nothing now (the core keeps its current observation on a retryable error).
|
|
91
|
+
if (!tx || !header)
|
|
92
|
+
throw (0, http_1.notServable)();
|
|
93
|
+
const verdict = guard
|
|
94
|
+
? (0, decode_1.verdictOf)(ctx.codec, tx, info)
|
|
95
|
+
: (0, decode_1.chainVerdict)(ctx.codec, tx, info);
|
|
96
|
+
return {
|
|
97
|
+
seen: 'block',
|
|
98
|
+
txHash: id,
|
|
99
|
+
blockHeight: info.blockNumber,
|
|
100
|
+
blockHash: header.id,
|
|
101
|
+
success: verdict.success,
|
|
102
|
+
...(verdict.reason ? { reason: verdict.reason } : {}),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function createTronReader(ctx) {
|
|
106
|
+
const { api } = ctx;
|
|
107
|
+
async function getTransaction(id) {
|
|
108
|
+
const txId = idOf(id);
|
|
109
|
+
if (txId === null)
|
|
110
|
+
return null;
|
|
111
|
+
const tx = await api.transaction('full', txId, http_1.READ);
|
|
112
|
+
if (!tx) {
|
|
113
|
+
const pending = await api.pending(txId, http_1.READ);
|
|
114
|
+
return pending
|
|
115
|
+
? (0, decode_1.decodeTransaction)(ctx.codec, pending, null, undefined, true)
|
|
116
|
+
: null;
|
|
117
|
+
}
|
|
118
|
+
// java-tron serves only included transactions here: without its receipt or its block
|
|
119
|
+
// the answer is "not yet", never "not seen".
|
|
120
|
+
const info = await api.transactionInfo('full', txId, http_1.READ);
|
|
121
|
+
if (!info)
|
|
122
|
+
throw (0, http_1.notServable)();
|
|
123
|
+
const header = await api.block('full', info.blockNumber, http_1.READ);
|
|
124
|
+
if (!header)
|
|
125
|
+
throw (0, http_1.notServable)();
|
|
126
|
+
return (0, decode_1.decodeTransaction)(ctx.codec, tx, info, header.id);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
async getBalance(address, asset) {
|
|
130
|
+
if (asset === 'native')
|
|
131
|
+
return (await api.account((0, address_1.toHexAddress)(address), http_1.READ)).balance;
|
|
132
|
+
return trc20Balance(ctx, trc20Contract(asset), address);
|
|
133
|
+
},
|
|
134
|
+
async getBlockHeight() {
|
|
135
|
+
return (await api.block('full', undefined, http_1.MONITOR)).number;
|
|
136
|
+
},
|
|
137
|
+
async getFinalizedHeight() {
|
|
138
|
+
return (await api.block('solid', undefined, http_1.MONITOR))
|
|
139
|
+
.number;
|
|
140
|
+
},
|
|
141
|
+
async getBlock(ref) {
|
|
142
|
+
const key = typeof ref === 'string' ? idOf(ref) : ref;
|
|
143
|
+
if (key === null || (typeof key === 'bigint' && (key < 0n || key > INT64_MAX))) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const header = await api.block('full', key, http_1.READ);
|
|
147
|
+
return header
|
|
148
|
+
? {
|
|
149
|
+
height: header.number,
|
|
150
|
+
hash: header.id,
|
|
151
|
+
parentHash: header.parentId,
|
|
152
|
+
timestamp: header.timestamp,
|
|
153
|
+
}
|
|
154
|
+
: null;
|
|
155
|
+
},
|
|
156
|
+
getTransaction,
|
|
157
|
+
async observe(ref, ordering) {
|
|
158
|
+
const id = idOf(ref.id);
|
|
159
|
+
if (id === null)
|
|
160
|
+
return { seen: 'none' };
|
|
161
|
+
const included = await observeIncluded(ctx, id, http_1.MONITOR, ordering !== undefined);
|
|
162
|
+
if (included)
|
|
163
|
+
return included;
|
|
164
|
+
return (await api.pending(id, http_1.MONITOR)) ? { seen: 'mempool' } : { seen: 'none' };
|
|
165
|
+
},
|
|
166
|
+
async getTokenMetadata(ref) {
|
|
167
|
+
const contract = trc20Contract(ref);
|
|
168
|
+
// The contract's own account is the caller: it always exists.
|
|
169
|
+
const decimalsWord = await tokenCall(ctx, contract, contract, abi_1.SELECTORS.decimals, METADATA);
|
|
170
|
+
const symbolWord = await tokenCall(ctx, contract, contract, abi_1.SELECTORS.symbol, METADATA);
|
|
171
|
+
let decimals;
|
|
172
|
+
let symbol;
|
|
173
|
+
try {
|
|
174
|
+
decimals = (0, abi_1.decodeUint256)(decimalsWord);
|
|
175
|
+
symbol = (0, abi_1.decodeString)(symbolWord);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
throw tokenProblem('unreadable decimals or symbol');
|
|
179
|
+
}
|
|
180
|
+
if (decimals > 255n || symbol.length === 0) {
|
|
181
|
+
throw tokenProblem('decimals or symbol out of range');
|
|
182
|
+
}
|
|
183
|
+
return { symbol, decimals: Number(decimals) };
|
|
184
|
+
},
|
|
185
|
+
normalizeTokenRef(ref) {
|
|
186
|
+
if (ref.standard !== 'trc20') {
|
|
187
|
+
throw new error_1.ValidationError('ASSET_RESOLUTION', 'Tron tokens use the trc20 standard');
|
|
188
|
+
}
|
|
189
|
+
if (!(0, address_1.isTronAddress)(ref.contract))
|
|
190
|
+
throw tokenProblem('not a Tron contract address');
|
|
191
|
+
return { standard: 'trc20', contract: (0, address_1.toBase58Address)(ref.contract) };
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/** `ext.tron`, the Tron family extension. */
|
|
196
|
+
function createTronExt(ctx) {
|
|
197
|
+
return {
|
|
198
|
+
tron: {
|
|
199
|
+
getResources: (address) => ctx.api.resources((0, address_1.toHexAddress)(address), http_1.READ),
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../src/adapters/tron/reader.ts"],"names":[],"mappings":";;AAkEA,sCASC;AASD,8BAoBC;AAGD,oCAkBC;AAOD,0CA0BC;AAED,4CAmGC;AAGD,sCAOC;AAjQD,mDAIiC;AAKjC,+BAAgF;AAChF,uCAAyE;AACzE,qCAAsE;AACtE,iCAAmF;AAcnF,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAC/B,6CAA6C;AAC7C,MAAM,SAAS,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC;AAEjC,wFA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QACL,IAAI,EAAE;YACJ,YAAY,EAAE,CAAC,OAAe,EAA0B,EAAE,CACxD,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAA,sBAAY,EAAC,OAAO,CAAC,EAAE,WAAI,CAAC;SACjD;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The Tron `ChainReader` and `ext.tron`. Tags follow the `ChainDriver` contract table:\n * reads `read`, heights and `observe` `monitor`. Addresses reach the node as `41…` hex.\n * A transaction the node holds but cannot serve whole yet (its receipt, its block) is a\n * retryable `PROVIDER_UNAVAILABLE`, never \"not seen\".\n */\nimport type {\n ChainReader,\n DriverBlock,\n DriverTransaction,\n DriverTxObservation,\n} from '../../core/driver/types';\nimport {\n ProviderError,\n UnsupportedCapabilityError,\n ValidationError,\n} from '../../core/errors/error';\nimport type { Logger } from '../../core/events/logger';\nimport type { AssetMetadata, AssetRef, TokenRef } from '../../core/model/asset';\nimport type { ChainInfo, NetworkInfo } from '../../core/model/chain';\nimport type { Clock } from '../../core/util/clock';\nimport { SELECTORS, decodeString, decodeUint256, encodeBalanceOf } from './abi';\nimport { isTronAddress, toBase58Address, toHexAddress } from './address';\nimport { chainVerdict, decodeTransaction, verdictOf } from './decode';\nimport { MONITOR, READ, notServable, type TronApi, type TronTxJson } from './http';\nimport type { TronNetworkConfig } from './network';\nimport type { TronCallTags, TronCodec, TronExt, TronResources } from './types';\n\nexport interface TronContext {\n readonly api: TronApi;\n readonly codec: TronCodec;\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly config: TronNetworkConfig;\n readonly clock: Clock;\n readonly log: Logger;\n}\n\nconst TX_ID = /^[0-9a-f]{64}$/;\n/** java-tron's block heights are `long`s. */\nconst INT64_MAX = 2n ** 63n - 1n;\n\n/** A lower-case transaction or block id, or `null` (length checked before any work). */\nfunction idOf(value: string): string | null {\n if (typeof value !== 'string' || value.length !== 64) return null;\n const id = value.toLowerCase();\n return TX_ID.test(id) ? id : null;\n}\n\n/**\n * Token metadata is read under the proof quorum: the core caches a token's decimals,\n * symbol and \"no such token\" for the container's life, so one lagging or buggy endpoint\n * must not decide them. The constant call's quorum key compares the verdict only, since\n * honest nodes never agree on its whole answer; endpoints that disagree throw retryable\n * `PROVIDER_INCONSISTENT`.\n */\nconst METADATA: TronCallTags = { ...READ, quorum: 'proof' };\n\nfunction tokenProblem(reason: string): ValidationError {\n return new ValidationError('ASSET_RESOLUTION', `TRC-20 token unusable: ${reason}`);\n}\n\n/**\n * The `41…` hex contract of a TRC-20 ref. `UNSUPPORTED_CAPABILITY` for TRX or another token\n * standard; `ASSET_RESOLUTION` for a contract that is not a Tron address.\n */\nexport function trc20Contract(ref: AssetRef): string {\n if (ref === 'native' || ref.standard !== 'trc20') {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n 'Tron supports TRX and TRC-20 tokens only',\n );\n }\n if (!isTronAddress(ref.contract)) throw tokenProblem('not a Tron contract address');\n return toHexAddress(ref.contract);\n}\n\n/**\n * A constant call on a token: a revert, a VM failure or no contract is the\n * token's own permanent problem (`ASSET_RESOLUTION`, cached by the core); node refusals stay\n * retryable and every other error propagates unchanged. \"No contract\" is a node's text, so\n * it counts only once `/wallet/getcontract` confirms it structurally with the same tags; a\n * node that shows a contract there decides nothing.\n */\nexport async function tokenCall(\n ctx: TronContext,\n owner: string,\n contract: string,\n data: string,\n tags: TronCallTags,\n): Promise<string> {\n const answer = await ctx.api.constantCall(owner, contract, data, tags);\n if (answer.kind === 'no-contract') {\n if (await ctx.api.contractExists(contract, tags)) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the node both holds and lacks this contract',\n { retryable: true },\n );\n }\n throw tokenProblem('no contract at this address');\n }\n if (answer.kind === 'failed') throw tokenProblem('the call failed');\n return answer.result;\n}\n\n/** A holder's TRC-20 balance. */\nexport async function trc20Balance(\n ctx: TronContext,\n contract: string,\n holder: string,\n tags: TronCallTags = READ,\n): Promise<bigint> {\n const result = await tokenCall(\n ctx,\n toHexAddress(holder),\n contract,\n encodeBalanceOf(holder),\n tags,\n );\n try {\n return decodeUint256(result);\n } catch {\n throw tokenProblem('balanceOf returned no uint256');\n }\n}\n\n/**\n * An included transaction's observation. `guard` applies the verdict guard (on-chain\n * evidence that value moved) to our own Attempts; without it (a status lookup by id,\n * `ordering === undefined`), the chain's own view is reported.\n */\nexport async function observeIncluded(\n ctx: TronContext,\n id: string,\n tags: TronCallTags,\n guard: boolean,\n): Promise<DriverTxObservation | null> {\n const info = await ctx.api.transactionInfo('full', id, tags);\n if (!info) return null;\n const [tx, header] = await Promise.all([\n ctx.api.transaction('full', id, tags),\n ctx.api.block('full', info.blockNumber, tags),\n ]);\n // The node indexed the info but cannot serve the transaction or its block yet: decide\n // nothing now (the core keeps its current observation on a retryable error).\n if (!tx || !header) throw notServable();\n const verdict = guard\n ? verdictOf(ctx.codec, tx, info)\n : chainVerdict(ctx.codec, tx, info);\n return {\n seen: 'block',\n txHash: id,\n blockHeight: info.blockNumber,\n blockHash: header.id,\n success: verdict.success,\n ...(verdict.reason ? { reason: verdict.reason } : {}),\n };\n}\n\nexport function createTronReader(ctx: TronContext): ChainReader {\n const { api } = ctx;\n\n async function getTransaction(id: string): Promise<DriverTransaction | null> {\n const txId = idOf(id);\n if (txId === null) return null;\n const tx = await api.transaction('full', txId, READ);\n if (!tx) {\n const pending: TronTxJson | null = await api.pending(txId, READ);\n return pending\n ? decodeTransaction(ctx.codec, pending, null, undefined, true)\n : null;\n }\n // java-tron serves only included transactions here: without its receipt or its block\n // the answer is \"not yet\", never \"not seen\".\n const info = await api.transactionInfo('full', txId, READ);\n if (!info) throw notServable();\n const header = await api.block('full', info.blockNumber, READ);\n if (!header) throw notServable();\n return decodeTransaction(ctx.codec, tx, info, header.id);\n }\n\n return {\n async getBalance(address, asset) {\n if (asset === 'native')\n return (await api.account(toHexAddress(address), READ)).balance;\n return trc20Balance(ctx, trc20Contract(asset), address);\n },\n async getBlockHeight() {\n return ((await api.block('full', undefined, MONITOR)) as { number: bigint }).number;\n },\n async getFinalizedHeight() {\n return ((await api.block('solid', undefined, MONITOR)) as { number: bigint })\n .number;\n },\n async getBlock(ref): Promise<DriverBlock | null> {\n const key = typeof ref === 'string' ? idOf(ref) : ref;\n if (key === null || (typeof key === 'bigint' && (key < 0n || key > INT64_MAX))) {\n return null;\n }\n const header = await api.block('full', key, READ);\n return header\n ? {\n height: header.number,\n hash: header.id,\n parentHash: header.parentId,\n timestamp: header.timestamp,\n }\n : null;\n },\n getTransaction,\n async observe(ref, ordering) {\n const id = idOf(ref.id);\n if (id === null) return { seen: 'none' };\n const included = await observeIncluded(ctx, id, MONITOR, ordering !== undefined);\n if (included) return included;\n return (await api.pending(id, MONITOR)) ? { seen: 'mempool' } : { seen: 'none' };\n },\n async getTokenMetadata(ref: TokenRef): Promise<AssetMetadata> {\n const contract = trc20Contract(ref);\n // The contract's own account is the caller: it always exists.\n const decimalsWord = await tokenCall(\n ctx,\n contract,\n contract,\n SELECTORS.decimals,\n METADATA,\n );\n const symbolWord = await tokenCall(\n ctx,\n contract,\n contract,\n SELECTORS.symbol,\n METADATA,\n );\n let decimals: bigint;\n let symbol: string;\n try {\n decimals = decodeUint256(decimalsWord);\n symbol = decodeString(symbolWord);\n } catch {\n throw tokenProblem('unreadable decimals or symbol');\n }\n if (decimals > 255n || symbol.length === 0) {\n throw tokenProblem('decimals or symbol out of range');\n }\n return { symbol, decimals: Number(decimals) };\n },\n normalizeTokenRef(ref: TokenRef): TokenRef {\n if (ref.standard !== 'trc20') {\n throw new ValidationError(\n 'ASSET_RESOLUTION',\n 'Tron tokens use the trc20 standard',\n );\n }\n if (!isTronAddress(ref.contract)) throw tokenProblem('not a Tron contract address');\n return { standard: 'trc20', contract: toBase58Address(ref.contract) };\n },\n };\n}\n\n/** `ext.tron`, the Tron family extension. */\nexport function createTronExt(ctx: TronContext): TronExt {\n return {\n tron: {\n getResources: (address: string): Promise<TronResources> =>\n ctx.api.resources(toHexAddress(address), READ),\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known tokens: USDT, which Tether deploys natively on Tron mainnet
|
|
3
|
+
* (Tether's supported-protocols page); decimals and symbol read from the contract. Circle
|
|
4
|
+
* lists no Tron USDC, so there is none. The contract is the base58 form, the canonical one.
|
|
5
|
+
*/
|
|
6
|
+
import type { AssetRegistration } from '../../core/registry/assets';
|
|
7
|
+
export declare const TRON_TOKENS: readonly AssetRegistration[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRON_TOKENS = void 0;
|
|
4
|
+
const freeze_1 = require("../../core/util/freeze");
|
|
5
|
+
exports.TRON_TOKENS = (0, freeze_1.deepFreeze)([
|
|
6
|
+
{
|
|
7
|
+
chain: 'tron',
|
|
8
|
+
network: 'mainnet',
|
|
9
|
+
ref: { standard: 'trc20', contract: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' },
|
|
10
|
+
metadata: { symbol: 'USDT', decimals: 6 },
|
|
11
|
+
aliases: ['USDT'],
|
|
12
|
+
},
|
|
13
|
+
]);
|
|
14
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/adapters/tron/tokens.ts"],"names":[],"mappings":";;;AAMA,mDAAoD;AAEvC,QAAA,WAAW,GAAiC,IAAA,mBAAU,EAAC;IAClE;QACE,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,oCAAoC,EAAE;QAC1E,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE;QACzC,OAAO,EAAE,CAAC,MAAM,CAAC;KAClB;CACF,CAAC,CAAC","sourcesContent":["/**\n * Well-known tokens: USDT, which Tether deploys natively on Tron mainnet\n * (Tether's supported-protocols page); decimals and symbol read from the contract. Circle\n * lists no Tron USDC, so there is none. The contract is the base58 form, the canonical one.\n */\nimport type { AssetRegistration } from '../../core/registry/assets';\nimport { deepFreeze } from '../../core/util/freeze';\n\nexport const TRON_TOKENS: readonly AssetRegistration[] = deepFreeze([\n {\n chain: 'tron',\n network: 'mainnet',\n ref: { standard: 'trc20', contract: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t' },\n metadata: { symbol: 'USDT', decimals: 6 },\n aliases: ['USDT'],\n },\n]);\n"]}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK-free types of the Tron family: the `ext.tron` API, fee details and overrides, the
|
|
3
|
+
* plain raw-data model the driver builds, and the narrow `TronCodec` strategy that the
|
|
4
|
+
* tronweb module implements (protobuf serialization and the native client only). Nothing
|
|
5
|
+
* here imports an SDK, so the composition root can export these types.
|
|
6
|
+
*/
|
|
7
|
+
import type { DisposableNativeClient } from '../../core/driver/types';
|
|
8
|
+
import type { CallOptions, Transport } from '../../core/transport/types';
|
|
9
|
+
declare module '../../index' {
|
|
10
|
+
interface ChainRegistry {
|
|
11
|
+
tron: {
|
|
12
|
+
family: 'tron';
|
|
13
|
+
network: 'mainnet' | 'shasta' | 'nile';
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface FamilyRegistry {
|
|
17
|
+
tron: {
|
|
18
|
+
library: 'tronweb';
|
|
19
|
+
ext: TronExt;
|
|
20
|
+
fee: TronFeeDetails;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** An account's resources (`ext.tron.getResources`), from `getaccountresource`. */
|
|
25
|
+
export interface TronResources {
|
|
26
|
+
/** Whether the account exists on chain (it was activated by a first TRX transfer). */
|
|
27
|
+
readonly activated: boolean;
|
|
28
|
+
/** Free bandwidth left today, in bytes. */
|
|
29
|
+
readonly freeBandwidth: bigint;
|
|
30
|
+
/** Bandwidth left from staked or delegated TRX, in bytes. */
|
|
31
|
+
readonly stakedBandwidth: bigint;
|
|
32
|
+
/** Energy left from staked or delegated TRX. */
|
|
33
|
+
readonly energy: bigint;
|
|
34
|
+
}
|
|
35
|
+
/** `bc.ext.tron`: the Tron family extension. */
|
|
36
|
+
export interface TronExt {
|
|
37
|
+
readonly tron: {
|
|
38
|
+
/** The account's bandwidth and energy, as the full node reports them now. */
|
|
39
|
+
getResources(address: string): Promise<TronResources>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `FeeEstimate.details` of the `tron` fee kind. Sun (1 TRX = 10^6 sun), bytes and energy
|
|
44
|
+
* units. The charges are upper bounds for the account's resources at estimate time.
|
|
45
|
+
*/
|
|
46
|
+
export interface TronFeeDetails {
|
|
47
|
+
/** Bandwidth the signed transaction consumes, in bytes (its size plus 64). */
|
|
48
|
+
readonly bandwidth: bigint;
|
|
49
|
+
/** The chain's price of one byte of bandwidth, in sun (`getTransactionFee`). */
|
|
50
|
+
readonly bandwidthPrice: bigint;
|
|
51
|
+
/** TRC-20 only: the simulated energy plus the safety margin. */
|
|
52
|
+
readonly energy?: bigint;
|
|
53
|
+
/** TRC-20 only: the chain's price of one energy unit, in sun (`getEnergyFee`). */
|
|
54
|
+
readonly energyPrice?: bigint;
|
|
55
|
+
/**
|
|
56
|
+
* TRC-20 only: `raw_data.fee_limit`, which caps the energy the call may use:
|
|
57
|
+
* min(energy × price, the network's maximum, the handle's `maxFeeLimit`).
|
|
58
|
+
*/
|
|
59
|
+
readonly feeLimit?: bigint;
|
|
60
|
+
/** A TRX transfer to an address that is not activated yet pays account creation. */
|
|
61
|
+
readonly activation: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An explicit Tron fee (`TransferIntent.fee`): TRC-20 transfers only. `feeLimit` (sun)
|
|
65
|
+
* replaces the estimated fee limit; it may not be lower than the estimated energy cost,
|
|
66
|
+
* because a lower cap makes the transaction fail on chain (`OUT_OF_ENERGY`) and still pay,
|
|
67
|
+
* nor higher than the network's maximum or the handle's `maxFeeLimit` option.
|
|
68
|
+
*/
|
|
69
|
+
export type TronFeeOverride = {
|
|
70
|
+
readonly feeLimit: bigint;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The expiry ordering a Tron build records: the signed expiration, and the reference
|
|
74
|
+
* block the transaction names for TaPoS. `lastValidHeight` is the height the build-time
|
|
75
|
+
* head claimed plus the TaPoS window (65,536 blocks), so only its low 16 bits are signed
|
|
76
|
+
* (`ref_block_bytes`); `refBlockHash` is the signed `ref_block_hash`. A proof trusts the
|
|
77
|
+
* height only when the solidified block there carries `refBlockHash`, because a forged
|
|
78
|
+
* head can claim a height whose low 16 bits name a block 65,536 lower; otherwise it
|
|
79
|
+
* searches the heights TaPoS can match. It is a core `expiry` ordering with one more
|
|
80
|
+
* property, which the core stores whole. A durable store must keep it exact: a changed
|
|
81
|
+
* hash or height, or a rounded-down `expiresAtMs`, can prove the transfer expired while
|
|
82
|
+
* a block holds it.
|
|
83
|
+
*/
|
|
84
|
+
export interface TronExpiryOrdering {
|
|
85
|
+
readonly kind: 'expiry';
|
|
86
|
+
/** `raw_data.expiration`, in milliseconds: invalid in a block whose parent is at or past it. */
|
|
87
|
+
readonly expiresAtMs: number;
|
|
88
|
+
/** The reference block's height (as the build-time head claimed it) plus 65,536. */
|
|
89
|
+
readonly lastValidHeight: bigint;
|
|
90
|
+
/** `raw_data.ref_block_hash`: bytes 8..16 of the reference block's id, 16 lower-case hex digits. */
|
|
91
|
+
readonly refBlockHash: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The transport tags every Tron I/O call carries: purpose, retry, quorum, fanout,
|
|
95
|
+
* signal, an optional caller `quorumKey` that replaces the path's default consensus key
|
|
96
|
+
* (for a monotone predicate attested at its own height), and `exactIntegers`,
|
|
97
|
+
* which `TronApi` always sets: java-tron answers sun and energy as JSON numbers.
|
|
98
|
+
*/
|
|
99
|
+
export type TronCallTags = Pick<CallOptions, 'purpose' | 'retry' | 'quorum' | 'quorumKey' | 'exactIntegers' | 'fanout' | 'signal'>;
|
|
100
|
+
/** A TRX transfer (`TransferContract`); addresses are 21-byte hex with the `41` prefix. */
|
|
101
|
+
export interface TronTransferContract {
|
|
102
|
+
readonly type: 'TransferContract';
|
|
103
|
+
readonly owner: string;
|
|
104
|
+
readonly to: string;
|
|
105
|
+
/** Sun; at most `Number.MAX_SAFE_INTEGER` (the codec refuses more). */
|
|
106
|
+
readonly amount: bigint;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A contract call (`TriggerSmartContract`), e.g. a TRC-20 `transfer`. The driver builds calls
|
|
110
|
+
* without value; a chain call may also send TRX or a TRC-10 token, which `readRaw` reports
|
|
111
|
+
* (exactly, and only when non-zero) and `encodeRaw` refuses.
|
|
112
|
+
*/
|
|
113
|
+
export interface TronTriggerContract {
|
|
114
|
+
readonly type: 'TriggerSmartContract';
|
|
115
|
+
readonly owner: string;
|
|
116
|
+
readonly contract: string;
|
|
117
|
+
/** ABI call data, lower-case hex without `0x`. */
|
|
118
|
+
readonly data: string;
|
|
119
|
+
/** Read only: TRX sent to the contract with the call (`call_value`), in sun. */
|
|
120
|
+
readonly callValue?: bigint;
|
|
121
|
+
/** Read only: a TRC-10 amount sent with the call (`call_token_value`). */
|
|
122
|
+
readonly callTokenValue?: bigint;
|
|
123
|
+
/** Read only: the TRC-10 token id of `callTokenValue` (`token_id`). */
|
|
124
|
+
readonly tokenId?: bigint;
|
|
125
|
+
}
|
|
126
|
+
export type TronContract = TronTransferContract | TronTriggerContract;
|
|
127
|
+
/** `Transaction.raw` as plain data: what the driver builds and the signer's txID covers. */
|
|
128
|
+
export interface TronRawData {
|
|
129
|
+
/** Bytes 6..8 of the reference block's id (4 hex digits). */
|
|
130
|
+
readonly refBlockBytes: string;
|
|
131
|
+
/** Bytes 8..16 of the reference block's id (16 hex digits). */
|
|
132
|
+
readonly refBlockHash: string;
|
|
133
|
+
/** Milliseconds since the epoch; the transaction is invalid in a block whose parent is at or past it. */
|
|
134
|
+
readonly expiration: number;
|
|
135
|
+
/** Milliseconds since the epoch, informational. */
|
|
136
|
+
readonly timestamp: number;
|
|
137
|
+
/** TRC-20 calls: the energy cap in sun. */
|
|
138
|
+
readonly feeLimit?: number;
|
|
139
|
+
/** The memo bytes, lower-case hex; absent when there is no memo. */
|
|
140
|
+
readonly data?: string;
|
|
141
|
+
readonly contract: TronContract;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The SDK part of the Tron driver: protobuf work and the native client. Codec
|
|
145
|
+
* methods are synchronous and pure; they never perform I/O.
|
|
146
|
+
*/
|
|
147
|
+
export interface TronCodec {
|
|
148
|
+
readonly library: 'tronweb';
|
|
149
|
+
/** `Transaction.raw` protobuf bytes as lower-case hex. Throws `ValidationError` on out-of-range values. */
|
|
150
|
+
encodeRaw(raw: TronRawData): string;
|
|
151
|
+
/**
|
|
152
|
+
* Decodes `Transaction.raw` bytes holding exactly one Transfer or TriggerSmartContract.
|
|
153
|
+
* Throws `ValidationError('INVALID_INTENT')` for anything else.
|
|
154
|
+
*/
|
|
155
|
+
decodeRaw(hex: string): TronRawData;
|
|
156
|
+
/**
|
|
157
|
+
* Lenient reading of any chain transaction's raw bytes (already bound to its txID): the
|
|
158
|
+
* contract of a Transfer or TriggerSmartContract even with fields this model does not
|
|
159
|
+
* carry (a call's TRX or TRC-10 value is reported), or `null` for other contract types and
|
|
160
|
+
* anything unreadable. Display only: `timestamp` (client-set, so it may be rounded or
|
|
161
|
+
* negative), and `feeLimit` (left out when a number cannot hold it exactly). Never throws.
|
|
162
|
+
*/
|
|
163
|
+
readRaw(hex: string): TronRawData | null;
|
|
164
|
+
/** A fresh TronWeb instance whose providers send through `transport`. */
|
|
165
|
+
createNative(transport: Transport): DisposableNativeClient;
|
|
166
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/tron/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * SDK-free types of the Tron family: the `ext.tron` API, fee details and overrides, the\n * plain raw-data model the driver builds, and the narrow `TronCodec` strategy that the\n * tronweb module implements (protobuf serialization and the native client only). Nothing\n * here imports an SDK, so the composition root can export these types.\n */\nimport type { DisposableNativeClient } from '../../core/driver/types';\nimport type { CallOptions, Transport } from '../../core/transport/types';\n\n// Augment the registries through the package entry, as users do with 'crypto-aio'.\ndeclare module '../../index' {\n interface ChainRegistry {\n tron: { family: 'tron'; network: 'mainnet' | 'shasta' | 'nile' };\n }\n interface FamilyRegistry {\n tron: { library: 'tronweb'; ext: TronExt; fee: TronFeeDetails };\n }\n}\n\n/** An account's resources (`ext.tron.getResources`), from `getaccountresource`. */\nexport interface TronResources {\n /** Whether the account exists on chain (it was activated by a first TRX transfer). */\n readonly activated: boolean;\n /** Free bandwidth left today, in bytes. */\n readonly freeBandwidth: bigint;\n /** Bandwidth left from staked or delegated TRX, in bytes. */\n readonly stakedBandwidth: bigint;\n /** Energy left from staked or delegated TRX. */\n readonly energy: bigint;\n}\n\n/** `bc.ext.tron`: the Tron family extension. */\nexport interface TronExt {\n readonly tron: {\n /** The account's bandwidth and energy, as the full node reports them now. */\n getResources(address: string): Promise<TronResources>;\n };\n}\n\n/**\n * `FeeEstimate.details` of the `tron` fee kind. Sun (1 TRX = 10^6 sun), bytes and energy\n * units. The charges are upper bounds for the account's resources at estimate time.\n */\nexport interface TronFeeDetails {\n /** Bandwidth the signed transaction consumes, in bytes (its size plus 64). */\n readonly bandwidth: bigint;\n /** The chain's price of one byte of bandwidth, in sun (`getTransactionFee`). */\n readonly bandwidthPrice: bigint;\n /** TRC-20 only: the simulated energy plus the safety margin. */\n readonly energy?: bigint;\n /** TRC-20 only: the chain's price of one energy unit, in sun (`getEnergyFee`). */\n readonly energyPrice?: bigint;\n /**\n * TRC-20 only: `raw_data.fee_limit`, which caps the energy the call may use:\n * min(energy × price, the network's maximum, the handle's `maxFeeLimit`).\n */\n readonly feeLimit?: bigint;\n /** A TRX transfer to an address that is not activated yet pays account creation. */\n readonly activation: boolean;\n}\n\n/**\n * An explicit Tron fee (`TransferIntent.fee`): TRC-20 transfers only. `feeLimit` (sun)\n * replaces the estimated fee limit; it may not be lower than the estimated energy cost,\n * because a lower cap makes the transaction fail on chain (`OUT_OF_ENERGY`) and still pay,\n * nor higher than the network's maximum or the handle's `maxFeeLimit` option.\n */\nexport type TronFeeOverride = { readonly feeLimit: bigint };\n\n/**\n * The expiry ordering a Tron build records: the signed expiration, and the reference\n * block the transaction names for TaPoS. `lastValidHeight` is the height the build-time\n * head claimed plus the TaPoS window (65,536 blocks), so only its low 16 bits are signed\n * (`ref_block_bytes`); `refBlockHash` is the signed `ref_block_hash`. A proof trusts the\n * height only when the solidified block there carries `refBlockHash`, because a forged\n * head can claim a height whose low 16 bits name a block 65,536 lower; otherwise it\n * searches the heights TaPoS can match. It is a core `expiry` ordering with one more\n * property, which the core stores whole. A durable store must keep it exact: a changed\n * hash or height, or a rounded-down `expiresAtMs`, can prove the transfer expired while\n * a block holds it.\n */\nexport interface TronExpiryOrdering {\n readonly kind: 'expiry';\n /** `raw_data.expiration`, in milliseconds: invalid in a block whose parent is at or past it. */\n readonly expiresAtMs: number;\n /** The reference block's height (as the build-time head claimed it) plus 65,536. */\n readonly lastValidHeight: bigint;\n /** `raw_data.ref_block_hash`: bytes 8..16 of the reference block's id, 16 lower-case hex digits. */\n readonly refBlockHash: string;\n}\n\n/**\n * The transport tags every Tron I/O call carries: purpose, retry, quorum, fanout,\n * signal, an optional caller `quorumKey` that replaces the path's default consensus key\n * (for a monotone predicate attested at its own height), and `exactIntegers`,\n * which `TronApi` always sets: java-tron answers sun and energy as JSON numbers.\n */\nexport type TronCallTags = Pick<\n CallOptions,\n 'purpose' | 'retry' | 'quorum' | 'quorumKey' | 'exactIntegers' | 'fanout' | 'signal'\n>;\n\n/** A TRX transfer (`TransferContract`); addresses are 21-byte hex with the `41` prefix. */\nexport interface TronTransferContract {\n readonly type: 'TransferContract';\n readonly owner: string;\n readonly to: string;\n /** Sun; at most `Number.MAX_SAFE_INTEGER` (the codec refuses more). */\n readonly amount: bigint;\n}\n\n/**\n * A contract call (`TriggerSmartContract`), e.g. a TRC-20 `transfer`. The driver builds calls\n * without value; a chain call may also send TRX or a TRC-10 token, which `readRaw` reports\n * (exactly, and only when non-zero) and `encodeRaw` refuses.\n */\nexport interface TronTriggerContract {\n readonly type: 'TriggerSmartContract';\n readonly owner: string;\n readonly contract: string;\n /** ABI call data, lower-case hex without `0x`. */\n readonly data: string;\n /** Read only: TRX sent to the contract with the call (`call_value`), in sun. */\n readonly callValue?: bigint;\n /** Read only: a TRC-10 amount sent with the call (`call_token_value`). */\n readonly callTokenValue?: bigint;\n /** Read only: the TRC-10 token id of `callTokenValue` (`token_id`). */\n readonly tokenId?: bigint;\n}\n\nexport type TronContract = TronTransferContract | TronTriggerContract;\n\n/** `Transaction.raw` as plain data: what the driver builds and the signer's txID covers. */\nexport interface TronRawData {\n /** Bytes 6..8 of the reference block's id (4 hex digits). */\n readonly refBlockBytes: string;\n /** Bytes 8..16 of the reference block's id (16 hex digits). */\n readonly refBlockHash: string;\n /** Milliseconds since the epoch; the transaction is invalid in a block whose parent is at or past it. */\n readonly expiration: number;\n /** Milliseconds since the epoch, informational. */\n readonly timestamp: number;\n /** TRC-20 calls: the energy cap in sun. */\n readonly feeLimit?: number;\n /** The memo bytes, lower-case hex; absent when there is no memo. */\n readonly data?: string;\n readonly contract: TronContract;\n}\n\n/**\n * The SDK part of the Tron driver: protobuf work and the native client. Codec\n * methods are synchronous and pure; they never perform I/O.\n */\nexport interface TronCodec {\n readonly library: 'tronweb';\n /** `Transaction.raw` protobuf bytes as lower-case hex. Throws `ValidationError` on out-of-range values. */\n encodeRaw(raw: TronRawData): string;\n /**\n * Decodes `Transaction.raw` bytes holding exactly one Transfer or TriggerSmartContract.\n * Throws `ValidationError('INVALID_INTENT')` for anything else.\n */\n decodeRaw(hex: string): TronRawData;\n /**\n * Lenient reading of any chain transaction's raw bytes (already bound to its txID): the\n * contract of a Transfer or TriggerSmartContract even with fields this model does not\n * carry (a call's TRX or TRC-10 value is reported), or `null` for other contract types and\n * anything unreadable. Display only: `timestamp` (client-set, so it may be rounded or\n * negative), and `feeLimit` (left out when a number cannot hold it exactly). Never throws.\n */\n readRaw(hex: string): TronRawData | null;\n /** A fresh TronWeb instance whose providers send through `transport`. */\n createNative(transport: Transport): DisposableNativeClient;\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AddressParams, UtxoAddressType, UtxoOutputType } from './types';
|
|
2
|
+
export type { AddressParams } from './types';
|
|
3
|
+
export interface DecodedAddress {
|
|
4
|
+
readonly type: UtxoOutputType;
|
|
5
|
+
/** Lowercase bech32, or the base58 string as given. */
|
|
6
|
+
readonly canonical: string;
|
|
7
|
+
readonly script: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
export declare const hash160: (data: Uint8Array) => Uint8Array;
|
|
10
|
+
/** The standard output script of each type; the program must have that type's length. */
|
|
11
|
+
export declare function outputScript(type: UtxoOutputType, program: Uint8Array): Uint8Array;
|
|
12
|
+
/** Whether 32 bytes are the x coordinate of a curve point (BIP340 `lift_x`). */
|
|
13
|
+
export declare function isXOnlyPoint(bytes: Uint8Array): boolean;
|
|
14
|
+
/** Decodes an address of this network; throws `INVALID_ADDRESS`. */
|
|
15
|
+
export declare function decodeAddress(address: string, params: AddressParams): DecodedAddress;
|
|
16
|
+
/**
|
|
17
|
+
* The address an output script pays on this network: the inverse of `outputScript` for the
|
|
18
|
+
* five standard types, as `decodeAddress` returns it. Any other script (a bare key or
|
|
19
|
+
* multisig, a data carrier, a future witness version or program length) has no address, and
|
|
20
|
+
* neither has a taproot key off the curve, which `decodeAddress` refuses.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addressFromScript(script: Uint8Array, params: AddressParams): DecodedAddress | undefined;
|
|
23
|
+
/** BIP341/BIP86 key-path tweak of an internal key with no script tree. */
|
|
24
|
+
export declare function taprootTweak(internalKey: Uint8Array): {
|
|
25
|
+
readonly tweak: Uint8Array;
|
|
26
|
+
readonly outputKey: Uint8Array;
|
|
27
|
+
};
|
|
28
|
+
export interface WalletAddress {
|
|
29
|
+
readonly address: string;
|
|
30
|
+
readonly type: UtxoAddressType;
|
|
31
|
+
readonly script: Uint8Array;
|
|
32
|
+
/** The key the wallet signs with: compressed (ECDSA) or x-only internal key (p2tr). */
|
|
33
|
+
readonly publicKey: Uint8Array;
|
|
34
|
+
/** p2sh-p2wpkh: the redeem script pushed in the scriptSig. */
|
|
35
|
+
readonly redeemScript?: Uint8Array;
|
|
36
|
+
/** p2tr: the BIP341 tweak and the tweaked output key the signature verifies against. */
|
|
37
|
+
readonly tweak?: Uint8Array;
|
|
38
|
+
readonly outputKey?: Uint8Array;
|
|
39
|
+
}
|
|
40
|
+
/** The wallet address of `type` for this public key. */
|
|
41
|
+
export declare function walletAddress(publicKey: Uint8Array, type: UtxoAddressType, params: AddressParams): WalletAddress;
|
|
42
|
+
/** The wallet address type a sending address implies (a p2sh wallet is p2sh-p2wpkh). */
|
|
43
|
+
export declare function walletTypeOf(decoded: DecodedAddress): UtxoAddressType;
|
|
44
|
+
/** The byte length of Bitcoin's CompactSize encoding of `n` (a count or a length). */
|
|
45
|
+
export declare const compactSize: (n: number) => number;
|
|
46
|
+
/**
|
|
47
|
+
* Bitcoin Core's `GetDustThreshold` (policy.cpp) at `dustRelayFee` sat/kvB, rounded up.
|
|
48
|
+
* An unspendable script (`IsUnspendable`: OP_RETURN first, or over `MAX_SCRIPT_SIZE`) has
|
|
49
|
+
* no dust threshold.
|
|
50
|
+
*/
|
|
51
|
+
export declare function dustThreshold(script: Uint8Array, dustRelayFee: bigint): bigint;
|