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,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bandwidthOf = bandwidthOf;
|
|
4
|
+
exports.createTronBuilder = createTronBuilder;
|
|
5
|
+
/**
|
|
6
|
+
* The Tron `TxBuilder` and `Broadcaster`. One output (TRX or TRC-20), an optional memo in
|
|
7
|
+
* `raw_data.data`, `expiry` ordering (`expiresAtMs`), one `secp256k1-ecdsa` digest request
|
|
8
|
+
* over the txID, and the txID as the Attempt ref, known before signing.
|
|
9
|
+
*
|
|
10
|
+
* Reference block and expiration: the reference is the head block (TaPoS), and the
|
|
11
|
+
* transaction expires `expirationMs` after the earlier of the head's time and the local
|
|
12
|
+
* clock, as tronweb does from the head. A head older than half the window is refused
|
|
13
|
+
* (retryable) instead of producing a transaction that is born nearly expired, and so is a
|
|
14
|
+
* head dated more than half the window ahead of the local clock (a clock behind the chain
|
|
15
|
+
* would build transactions born expired); a head dated less far in the future cannot push
|
|
16
|
+
* the expiration beyond the window from now. The ordering records the signed expiration and
|
|
17
|
+
* the reference block's TaPoS bound (`lastValidHeight`: its height, read from its id, plus
|
|
18
|
+
* `TAPOS_WINDOW`), so the negative inclusion proof scans from the attested reference block
|
|
19
|
+
* up to the expiration, whatever the head or the clock claimed: a floor derived from the
|
|
20
|
+
* clock could sit above the block that holds the transaction. The expiration stays inside
|
|
21
|
+
* java-tron's own window (at least the next slot, at most 24 h past its head).
|
|
22
|
+
*
|
|
23
|
+
* Uniqueness: Tron has no nonce, so two identical transfers built on the same head in
|
|
24
|
+
* the same millisecond would share one txID and one on-chain effect. The core refuses an
|
|
25
|
+
* Attempt whose ref another Operation holds; as defense in depth, each build takes a
|
|
26
|
+
* `timestamp` strictly above the previous one from this driver, plus crypto-random offsets
|
|
27
|
+
* on `timestamp` (up to +999 ms) and `expiration` (up to −999 ms); java-tron never
|
|
28
|
+
* validates `raw_data.timestamp`.
|
|
29
|
+
*
|
|
30
|
+
* Nothing is signed before the built bytes are decoded back and shown to carry exactly the
|
|
31
|
+
* intent: owner, recipient, amount, token contract, canonical `transfer(to, amount)` call
|
|
32
|
+
* data with no value, memo, expiration and fee limit. `assemble` checks the same against the
|
|
33
|
+
* stored summary, ordering and fee limit, so the signature goes out only with the transfer
|
|
34
|
+
* that was authorized.
|
|
35
|
+
*
|
|
36
|
+
* Broadcasts are classified here (`classifyOwnBroadcast`), never under a quorum: a transport
|
|
37
|
+
* failure, an unreadable reply or a node answer that may follow pooling is thrown ambiguous
|
|
38
|
+
* (possibly sent). A node's rejection is a claim: it stands only when its reason
|
|
39
|
+
* holds for the bytes that were sent, read back from them; otherwise it is a refusal. A
|
|
40
|
+
* `TX_EXPIRED` refusal is the node's view at its own head, a hint and not proof: Tron has no
|
|
41
|
+
* nonce, so a second Attempt could land beside the first. The broadcaster never re-sends or
|
|
42
|
+
* rebuilds on it; only an attested expiry (the proofs) lets the core build again.
|
|
43
|
+
*/
|
|
44
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
45
|
+
const error_1 = require("../../core/errors/error");
|
|
46
|
+
const asset_1 = require("../../core/model/asset");
|
|
47
|
+
const schemes_1 = require("../../core/registry/schemes");
|
|
48
|
+
const bytes_1 = require("../../core/util/bytes");
|
|
49
|
+
const abi_1 = require("./abi");
|
|
50
|
+
const address_1 = require("./address");
|
|
51
|
+
const errors_1 = require("./errors");
|
|
52
|
+
const fees_1 = require("./fees");
|
|
53
|
+
const http_1 = require("./http");
|
|
54
|
+
const network_1 = require("./network");
|
|
55
|
+
const reader_1 = require("./reader");
|
|
56
|
+
/** The largest `int64` the codec writes from a JS number. */
|
|
57
|
+
const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
|
|
58
|
+
/** A positive base-unit amount in a stored summary: at most a `uint256` (78 digits). */
|
|
59
|
+
const SUMMARY_AMOUNT = /^[1-9][0-9]{0,77}$/;
|
|
60
|
+
/** Linear on any input: one character class, no repeated group. */
|
|
61
|
+
const HEX_DIGITS = /^[0-9a-fA-F]+$/;
|
|
62
|
+
function invalid(message) {
|
|
63
|
+
return new error_1.ValidationError('INVALID_INTENT', message);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether an address holds a contract, read under the proof quorum: a node's word
|
|
67
|
+
* alone must not refuse a valid transfer, and endpoints that disagree decide nothing.
|
|
68
|
+
*/
|
|
69
|
+
const CONFIRMED = { ...http_1.READ, quorum: 'proof' };
|
|
70
|
+
/** The memo's UTF-8 bytes as hex, or undefined; refused when over `MAX_MEMO_BYTES`. */
|
|
71
|
+
function memoHex(memo) {
|
|
72
|
+
if (memo === undefined || memo.length === 0)
|
|
73
|
+
return undefined;
|
|
74
|
+
const tooLong = () => invalid(`a Tron memo is at most ${network_1.MAX_MEMO_BYTES} UTF-8 bytes`);
|
|
75
|
+
// Each UTF-16 unit is at least one UTF-8 byte, so a longer string is refused unencoded.
|
|
76
|
+
if (memo.length > network_1.MAX_MEMO_BYTES)
|
|
77
|
+
throw tooLong();
|
|
78
|
+
const bytes = (0, bytes_1.utf8ToBytes)(memo);
|
|
79
|
+
if (bytes.length > network_1.MAX_MEMO_BYTES)
|
|
80
|
+
throw tooLong();
|
|
81
|
+
// A lone surrogate would be written as U+FFFD: the chain would carry another memo.
|
|
82
|
+
if ((0, bytes_1.bytesToUtf8)(bytes) !== memo)
|
|
83
|
+
throw invalid('a Tron memo must be well-formed text');
|
|
84
|
+
return (0, bytes_1.toHex)(bytes);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The validated transfer, before any I/O: one output, a positive amount, TRX or TRC-20,
|
|
88
|
+
* valid addresses, a memo within bounds, amounts the encoders can write exactly (a TRX
|
|
89
|
+
* transfer above 2^53 − 1 sun must be split), and TRX never to the sender (java-tron:
|
|
90
|
+
* "Cannot transfer TRX to yourself.", for the bytes alone). A TRC-20 transfer to the
|
|
91
|
+
* sender is valid on chain and is allowed.
|
|
92
|
+
*/
|
|
93
|
+
function prepare(intent) {
|
|
94
|
+
const output = intent.outputs[0];
|
|
95
|
+
if (!output || intent.outputs.length !== 1) {
|
|
96
|
+
throw invalid('a Tron transfer has exactly one output');
|
|
97
|
+
}
|
|
98
|
+
if (output.amount <= 0n) {
|
|
99
|
+
throw new error_1.ValidationError('INVALID_AMOUNT', 'the amount must be positive');
|
|
100
|
+
}
|
|
101
|
+
const token = intent.asset === 'native' ? undefined : (0, reader_1.trc20Contract)(intent.asset);
|
|
102
|
+
const owner = (0, address_1.toHexAddress)(intent.from);
|
|
103
|
+
const recipient = (0, address_1.toHexAddress)(output.to);
|
|
104
|
+
const memo = memoHex(intent.memo);
|
|
105
|
+
let contract;
|
|
106
|
+
if (token === undefined) {
|
|
107
|
+
if (output.amount > MAX_SAFE) {
|
|
108
|
+
throw new error_1.ValidationError('INVALID_AMOUNT', 'a TRX amount must be at most the largest safe integer of sun');
|
|
109
|
+
}
|
|
110
|
+
if (recipient === owner)
|
|
111
|
+
throw invalid('a TRX transfer cannot go to its sender');
|
|
112
|
+
contract = { type: 'TransferContract', owner, to: recipient, amount: output.amount };
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// encodeTransfer refuses an amount outside uint256 (INVALID_AMOUNT).
|
|
116
|
+
const data = (0, abi_1.encodeTransfer)(recipient, output.amount);
|
|
117
|
+
contract = { type: 'TriggerSmartContract', owner, contract: token, data };
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
to: output.to,
|
|
121
|
+
amount: output.amount,
|
|
122
|
+
owner,
|
|
123
|
+
recipient,
|
|
124
|
+
contract,
|
|
125
|
+
...(token !== undefined ? { token } : {}),
|
|
126
|
+
...(memo !== undefined ? { memo } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether decoded raw data carries exactly `t`. A TRC-20 call must be the canonical
|
|
131
|
+
* `transfer(to, amount)` (selector, zero-padded recipient, one amount word, nothing more)
|
|
132
|
+
* with no TRX or TRC-10 value: the verdict reads only that shape.
|
|
133
|
+
*/
|
|
134
|
+
function carries(raw, t) {
|
|
135
|
+
const c = raw.contract;
|
|
136
|
+
if (c.owner !== t.owner || raw.data !== t.memo)
|
|
137
|
+
return false;
|
|
138
|
+
if (t.token === undefined) {
|
|
139
|
+
return c.type === 'TransferContract' && c.to === t.recipient && c.amount === t.amount;
|
|
140
|
+
}
|
|
141
|
+
if (c.type !== 'TriggerSmartContract' || c.contract !== t.token)
|
|
142
|
+
return false;
|
|
143
|
+
if (c.callValue !== undefined ||
|
|
144
|
+
c.callTokenValue !== undefined ||
|
|
145
|
+
c.tokenId !== undefined) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
const call = (0, abi_1.decodeTransferCall)(c.data);
|
|
149
|
+
return call !== null && call.to === t.recipient && call.amount === t.amount;
|
|
150
|
+
}
|
|
151
|
+
/** The transfer a stored summary describes, signed by `owner`; null when it describes none. */
|
|
152
|
+
function summaryTransfer(ctx, summary, owner) {
|
|
153
|
+
try {
|
|
154
|
+
const { chain, network, ref } = (0, asset_1.parseAssetId)(summary.asset);
|
|
155
|
+
const output = summary.outputs[0];
|
|
156
|
+
if (chain !== ctx.chain.id ||
|
|
157
|
+
network !== ctx.network.id ||
|
|
158
|
+
!output ||
|
|
159
|
+
summary.outputs.length !== 1 ||
|
|
160
|
+
!SUMMARY_AMOUNT.test(output.amount)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const token = ref === 'native' ? undefined : (0, reader_1.trc20Contract)(ref);
|
|
164
|
+
const memo = memoHex(summary.memo);
|
|
165
|
+
return {
|
|
166
|
+
owner,
|
|
167
|
+
recipient: (0, address_1.toHexAddress)(output.to),
|
|
168
|
+
amount: BigInt(output.amount),
|
|
169
|
+
...(token !== undefined ? { token } : {}),
|
|
170
|
+
...(memo !== undefined ? { memo } : {}),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The fee fields a build writes, from this transfer's own `tron` estimate: the bandwidth
|
|
179
|
+
* the estimate covers and, for TRC-20 only, a positive fee limit within the handle's
|
|
180
|
+
* `maxFeeLimit`, wherever the estimate came from. The limit is handed to the codec
|
|
181
|
+
* as a number and its `safe()` refuses one it cannot hold exactly: it is never
|
|
182
|
+
* rounded into the bytes.
|
|
183
|
+
*/
|
|
184
|
+
function feeFields(fee, p, maxFeeLimit) {
|
|
185
|
+
const details = fee.details;
|
|
186
|
+
const mismatch = () => invalid('the fee estimate is not a Tron estimate for this transfer');
|
|
187
|
+
if (fee.kind !== 'tron' ||
|
|
188
|
+
typeof details.bandwidth !== 'bigint' ||
|
|
189
|
+
details.bandwidth <= 0n) {
|
|
190
|
+
throw mismatch();
|
|
191
|
+
}
|
|
192
|
+
if (p.token === undefined) {
|
|
193
|
+
if (details.feeLimit !== undefined)
|
|
194
|
+
throw mismatch();
|
|
195
|
+
return { bandwidth: details.bandwidth };
|
|
196
|
+
}
|
|
197
|
+
if (typeof details.feeLimit !== 'bigint' || details.feeLimit <= 0n)
|
|
198
|
+
throw mismatch();
|
|
199
|
+
if (details.feeLimit > maxFeeLimit) {
|
|
200
|
+
throw invalid('the fee limit is above maxFeeLimit, the Tron handle option that bounds it (in sun)');
|
|
201
|
+
}
|
|
202
|
+
return { bandwidth: details.bandwidth, feeLimit: Number(details.feeLimit) };
|
|
203
|
+
}
|
|
204
|
+
/** The sender's own key: a signature from any other key would not authorize the owner. */
|
|
205
|
+
function signingKey(keys, owner) {
|
|
206
|
+
for (const key of keys) {
|
|
207
|
+
if (key.scheme !== 'secp256k1-ecdsa')
|
|
208
|
+
continue;
|
|
209
|
+
try {
|
|
210
|
+
if ((0, address_1.toHexAddress)((0, address_1.addressFromPublicKey)(key.publicKey)) === owner)
|
|
211
|
+
return key;
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// Not a secp256k1 point: not this sender's key.
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
throw new error_1.SigningError('SIGNER_UNAVAILABLE', 'no secp256k1 key for the sending address');
|
|
218
|
+
}
|
|
219
|
+
function varint(value) {
|
|
220
|
+
const out = [];
|
|
221
|
+
let v = value;
|
|
222
|
+
do {
|
|
223
|
+
let byte = v & 0x7f;
|
|
224
|
+
v = Math.floor(v / 128);
|
|
225
|
+
if (v > 0)
|
|
226
|
+
byte |= 0x80;
|
|
227
|
+
out.push(byte);
|
|
228
|
+
} while (v > 0);
|
|
229
|
+
return Uint8Array.from(out);
|
|
230
|
+
}
|
|
231
|
+
/** `Transaction { raw raw_data = 1; repeated bytes signature = 2; }` with one signature. */
|
|
232
|
+
function signedTransaction(raw, signature) {
|
|
233
|
+
return (0, bytes_1.concatBytes)(Uint8Array.of(0x0a), varint(raw.length), raw, Uint8Array.of(0x12), varint(signature.length), signature);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* java-tron's bandwidth for a transaction whose `raw_data` is `rawBytes` long
|
|
237
|
+
* (`BandwidthProcessor.consume`): the signed size without `ret` (field 1 with its length and
|
|
238
|
+
* the raw bytes, field 2 with its length and one 65-byte signature) plus 64 result bytes.
|
|
239
|
+
*/
|
|
240
|
+
function bandwidthOf(rawBytes) {
|
|
241
|
+
return BigInt(1 + varint(rawBytes).length + rawBytes + 2 + 65 + 64);
|
|
242
|
+
}
|
|
243
|
+
/** A crypto-random integer in [0, 1000). */
|
|
244
|
+
function jitter() {
|
|
245
|
+
const bytes = (0, bytes_1.randomBytes)(2);
|
|
246
|
+
return ((bytes[0] << 8) | bytes[1]) % 1000;
|
|
247
|
+
}
|
|
248
|
+
const expiresAt = (ordering) => ordering.kind === 'expiry' ? ordering.expiresAtMs : undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Whether an ordering names the signed reference block: a reference height
|
|
251
|
+
* (`lastValidHeight − TAPOS_WINDOW`) whose bytes 6..8 are the signed `ref_block_bytes`, and
|
|
252
|
+
* the signed `ref_block_hash` itself. The proofs trust the height only with the hash.
|
|
253
|
+
*/
|
|
254
|
+
function boundToReference(ordering, raw) {
|
|
255
|
+
if (ordering.kind !== 'expiry')
|
|
256
|
+
return false;
|
|
257
|
+
const { lastValidHeight: last, refBlockHash } = ordering;
|
|
258
|
+
if (typeof last !== 'bigint' || last < network_1.TAPOS_WINDOW)
|
|
259
|
+
return false;
|
|
260
|
+
return (((last - network_1.TAPOS_WINDOW) & 0xffffn) === BigInt(`0x${raw.refBlockBytes}`) &&
|
|
261
|
+
refBlockHash === raw.refBlockHash);
|
|
262
|
+
}
|
|
263
|
+
function createTronBuilder(ctx) {
|
|
264
|
+
const { api, codec, config } = ctx;
|
|
265
|
+
let lastTimestamp = 0;
|
|
266
|
+
const refFields = (head) => ({
|
|
267
|
+
refBlockBytes: head.id.slice(12, 16),
|
|
268
|
+
refBlockHash: head.id.slice(16, 32),
|
|
269
|
+
});
|
|
270
|
+
async function head(signal) {
|
|
271
|
+
// `block` throws a malformed answer rather than return no head.
|
|
272
|
+
return (await api.block('full', undefined, (0, http_1.withSignal)(http_1.READ, signal)));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The simulated energy of a TRC-20 transfer, after the balance check: a shortfall is
|
|
276
|
+
* `INSUFFICIENT_FUNDS`, never a revert; a token that refuses a transfer its balance
|
|
277
|
+
* allows (a blacklist, say) is `INVALID_INTENT`.
|
|
278
|
+
*/
|
|
279
|
+
async function tokenEnergy(p, signal) {
|
|
280
|
+
const tags = (0, http_1.withSignal)(http_1.READ, signal);
|
|
281
|
+
const token = p.token;
|
|
282
|
+
const available = await (0, reader_1.trc20Balance)(ctx, token, p.owner, tags);
|
|
283
|
+
if (available < p.amount) {
|
|
284
|
+
throw new error_1.ChainError('INSUFFICIENT_FUNDS', 'insufficient token balance for this transfer', { details: { required: p.amount.toString(), available: available.toString() } });
|
|
285
|
+
}
|
|
286
|
+
const data = p.contract
|
|
287
|
+
.data;
|
|
288
|
+
const call = await api.constantCall(p.owner, token, data, tags);
|
|
289
|
+
if (call.kind === 'no-contract') {
|
|
290
|
+
// Its balanceOf just answered: two reads disagree, which decides nothing.
|
|
291
|
+
throw new error_1.ProviderError('PROVIDER_INCONSISTENT', 'the node both holds and lacks this token contract', { retryable: true });
|
|
292
|
+
}
|
|
293
|
+
if (call.kind === 'failed')
|
|
294
|
+
throw invalid('the token contract refuses this transfer');
|
|
295
|
+
return call.energy;
|
|
296
|
+
}
|
|
297
|
+
const builder = {
|
|
298
|
+
async estimateFee(intent, build) {
|
|
299
|
+
const p = prepare(intent);
|
|
300
|
+
const tags = (0, http_1.withSignal)(http_1.READ, build.signal);
|
|
301
|
+
const [params, resources, block, recipient, energy] = await Promise.all([
|
|
302
|
+
api.chainParameters(tags),
|
|
303
|
+
api.resources(p.owner, tags),
|
|
304
|
+
head(build.signal),
|
|
305
|
+
p.token === undefined ? api.account(p.recipient, tags) : undefined,
|
|
306
|
+
p.token === undefined ? undefined : tokenEnergy(p, build.signal),
|
|
307
|
+
]);
|
|
308
|
+
// Where the chain forbids TRX to a contract, such a transfer is refused before
|
|
309
|
+
// signing (it would only be refused, stall and expire). Elsewhere it is valid on
|
|
310
|
+
// chain: the flag is 0 on mainnet, Nile and Shasta.
|
|
311
|
+
// Known gap: the flag is one endpoint's word, read without a quorum, so a false 1
|
|
312
|
+
// refuses a valid transfer before signing and a false 0 lets the chain refuse it;
|
|
313
|
+
// liveness only, never a wrong payment.
|
|
314
|
+
if (p.token === undefined &&
|
|
315
|
+
params.forbidTransferToContract &&
|
|
316
|
+
(await api.contractExists(p.recipient, (0, http_1.withSignal)(CONFIRMED, build.signal)))) {
|
|
317
|
+
throw invalid('this network refuses TRX sent to a contract (getForbidTransferToContract)');
|
|
318
|
+
}
|
|
319
|
+
// An upper bound of the built size: no expiration jitter, a later timestamp, and the
|
|
320
|
+
// largest fee limit a build can carry (the ceiling `tronFee` applies).
|
|
321
|
+
const now = ctx.clock.now();
|
|
322
|
+
const ceiling = (0, fees_1.feeLimitCeiling)(params, config.maxFeeLimit).value;
|
|
323
|
+
const provisional = codec.encodeRaw({
|
|
324
|
+
...refFields(block),
|
|
325
|
+
expiration: Math.min(block.timestamp, now) + config.expirationMs,
|
|
326
|
+
timestamp: Math.max(now + 1_000, lastTimestamp + 1),
|
|
327
|
+
...(p.token !== undefined ? { feeLimit: Number(ceiling) } : {}),
|
|
328
|
+
...(p.memo !== undefined ? { data: p.memo } : {}),
|
|
329
|
+
contract: p.contract,
|
|
330
|
+
});
|
|
331
|
+
return (0, fees_1.tronFee)({
|
|
332
|
+
fee: intent.fee,
|
|
333
|
+
params,
|
|
334
|
+
resources,
|
|
335
|
+
bandwidth: bandwidthOf(provisional.length / 2),
|
|
336
|
+
activation: recipient !== undefined && !recipient.exists,
|
|
337
|
+
memo: p.memo !== undefined,
|
|
338
|
+
...(energy !== undefined ? { energy } : {}),
|
|
339
|
+
marginPercent: config.energyMarginPercent,
|
|
340
|
+
maxFeeLimit: config.maxFeeLimit,
|
|
341
|
+
});
|
|
342
|
+
},
|
|
343
|
+
async checkFunds(intent, fee, build) {
|
|
344
|
+
const p = prepare(intent);
|
|
345
|
+
const tags = (0, http_1.withSignal)(http_1.READ, build.signal);
|
|
346
|
+
const [account, tokens] = await Promise.all([
|
|
347
|
+
api.account(p.owner, tags),
|
|
348
|
+
p.token === undefined ? undefined : (0, reader_1.trc20Balance)(ctx, p.token, p.owner, tags),
|
|
349
|
+
]);
|
|
350
|
+
if (tokens !== undefined && tokens < p.amount) {
|
|
351
|
+
return { ok: false, asset: intent.asset, required: p.amount, available: tokens };
|
|
352
|
+
}
|
|
353
|
+
const required = (0, fees_1.feeSun)(fee) + (p.token === undefined ? p.amount : 0n);
|
|
354
|
+
// An account that was never activated has no free bandwidth and cannot send.
|
|
355
|
+
return account.exists && account.balance >= required
|
|
356
|
+
? { ok: true }
|
|
357
|
+
: { ok: false, asset: 'native', required, available: account.balance };
|
|
358
|
+
},
|
|
359
|
+
async build(intent, fee, build) {
|
|
360
|
+
const p = prepare(intent);
|
|
361
|
+
const key = signingKey(build.keys, p.owner);
|
|
362
|
+
const fees = feeFields(fee, p, config.maxFeeLimit);
|
|
363
|
+
const block = await head(build.signal);
|
|
364
|
+
const now = ctx.clock.now();
|
|
365
|
+
if (now - block.timestamp > config.expirationMs / 2) {
|
|
366
|
+
throw new error_1.ProviderError('PROVIDER_UNAVAILABLE', 'the head block is too old to reference; try again');
|
|
367
|
+
}
|
|
368
|
+
// A head dated more than half the window ahead means a local clock behind
|
|
369
|
+
// the chain, whose every build would be born expired (and cost a signature per
|
|
370
|
+
// rebuild), or a lying endpoint. Either way nothing is built on it.
|
|
371
|
+
if (block.timestamp - now > config.expirationMs / 2) {
|
|
372
|
+
throw new error_1.ProviderError('PROVIDER_UNAVAILABLE', 'the head block is dated ahead of the local clock; check the clock or try again');
|
|
373
|
+
}
|
|
374
|
+
// The reference block's height, from its id (java-tron's block id is the
|
|
375
|
+
// height's 8 bytes followed by 24 bytes of the header hash, `generateBlockId`): the
|
|
376
|
+
// same bytes TaPoS reads. A head whose id and number disagree is not a block.
|
|
377
|
+
const reference = BigInt(`0x${block.id.slice(0, 16)}`);
|
|
378
|
+
if (reference !== block.number)
|
|
379
|
+
throw (0, http_1.malformed)('head block id');
|
|
380
|
+
const anchor = Math.min(block.timestamp, now);
|
|
381
|
+
const expiration = anchor + config.expirationMs - jitter();
|
|
382
|
+
// The window stays within MAX_EXPIRATION_MS, and java-tron wants at least the next
|
|
383
|
+
// slot. The network config bounds the window; this holds it.
|
|
384
|
+
if (expiration - anchor > network_1.MAX_EXPIRATION_MS) {
|
|
385
|
+
throw new error_1.ConfigError('CONFIG_INVALID', 'the expiration window exceeds the maximum');
|
|
386
|
+
}
|
|
387
|
+
if (expiration - anchor < network_1.MIN_EXPIRATION_MS - 1_000) {
|
|
388
|
+
throw new error_1.ConfigError('CONFIG_INVALID', 'the expiration window is below the minimum');
|
|
389
|
+
}
|
|
390
|
+
const timestamp = Math.max(now + jitter(), lastTimestamp + 1);
|
|
391
|
+
lastTimestamp = timestamp;
|
|
392
|
+
const raw = {
|
|
393
|
+
...refFields(block),
|
|
394
|
+
expiration,
|
|
395
|
+
timestamp,
|
|
396
|
+
...(fees.feeLimit !== undefined ? { feeLimit: fees.feeLimit } : {}),
|
|
397
|
+
...(p.memo !== undefined ? { data: p.memo } : {}),
|
|
398
|
+
contract: p.contract,
|
|
399
|
+
};
|
|
400
|
+
const payload = codec.encodeRaw(raw);
|
|
401
|
+
// Before anything is signed: the bytes decode strictly to exactly this transfer.
|
|
402
|
+
let built;
|
|
403
|
+
try {
|
|
404
|
+
built = codec.decodeRaw(payload);
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
built = undefined;
|
|
408
|
+
}
|
|
409
|
+
if (!built ||
|
|
410
|
+
!carries(built, p) ||
|
|
411
|
+
built.expiration !== expiration ||
|
|
412
|
+
built.feeLimit !== raw.feeLimit) {
|
|
413
|
+
throw invalid('the built transaction does not carry this transfer');
|
|
414
|
+
}
|
|
415
|
+
if (bandwidthOf(payload.length / 2) > fees.bandwidth) {
|
|
416
|
+
throw invalid("the fee estimate does not cover this transaction's bandwidth");
|
|
417
|
+
}
|
|
418
|
+
const txId = (0, bytes_1.toHex)((0, sha256_1.sha256)((0, bytes_1.fromHex)(payload)));
|
|
419
|
+
// The negative proof scans from the reference block to the signed expiration; the
|
|
420
|
+
// height is the head's claim, so the signed hash bytes go with it, and the proof
|
|
421
|
+
// trusts the height only where the attested block carries them.
|
|
422
|
+
const ordering = {
|
|
423
|
+
kind: 'expiry',
|
|
424
|
+
expiresAtMs: expiration,
|
|
425
|
+
lastValidHeight: reference + network_1.TAPOS_WINDOW,
|
|
426
|
+
refBlockHash: raw.refBlockHash,
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
payload: { encoding: 'hex', data: payload },
|
|
430
|
+
expectedRef: { id: txId, idKind: 'tx-hash', canonical: true },
|
|
431
|
+
signingRequests: [
|
|
432
|
+
{
|
|
433
|
+
id: 'r0',
|
|
434
|
+
scheme: 'secp256k1-ecdsa',
|
|
435
|
+
payload: (0, bytes_1.fromHex)(txId),
|
|
436
|
+
payloadKind: 'digest',
|
|
437
|
+
publicKey: key.publicKey,
|
|
438
|
+
...(key.keyRef ? { keyRef: key.keyRef } : {}),
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
ordering,
|
|
442
|
+
fee,
|
|
443
|
+
summary: {
|
|
444
|
+
asset: (0, asset_1.assetId)(ctx.chain.id, ctx.network.id, intent.asset),
|
|
445
|
+
outputs: [{ to: p.to, amount: p.amount.toString() }],
|
|
446
|
+
...(intent.memo !== undefined ? { memo: intent.memo } : {}),
|
|
447
|
+
},
|
|
448
|
+
};
|
|
449
|
+
},
|
|
450
|
+
async assemble(unsigned, signatures) {
|
|
451
|
+
const fail = (message) => new error_1.SigningError('SIGNING_FAILED', message);
|
|
452
|
+
const request = unsigned.signingRequests[0];
|
|
453
|
+
const signature = signatures.find((s) => s.requestId === 'r0');
|
|
454
|
+
if (!request ||
|
|
455
|
+
request.id !== 'r0' ||
|
|
456
|
+
unsigned.signingRequests.length !== 1 ||
|
|
457
|
+
!signature ||
|
|
458
|
+
signature.bytes.length !== 64 ||
|
|
459
|
+
(signature.recovery !== 0 && signature.recovery !== 1)) {
|
|
460
|
+
throw fail('missing or malformed signature for request r0');
|
|
461
|
+
}
|
|
462
|
+
const mismatch = () => fail('the unsigned payload does not match its txID');
|
|
463
|
+
if (unsigned.payload.encoding !== 'hex')
|
|
464
|
+
throw mismatch();
|
|
465
|
+
let raw;
|
|
466
|
+
try {
|
|
467
|
+
raw = (0, bytes_1.fromHex)(unsigned.payload.data);
|
|
468
|
+
}
|
|
469
|
+
catch {
|
|
470
|
+
throw mismatch();
|
|
471
|
+
}
|
|
472
|
+
const txId = (0, bytes_1.toHex)((0, sha256_1.sha256)(raw));
|
|
473
|
+
if (txId !== (0, bytes_1.toHex)(request.payload) || txId !== unsigned.expectedRef?.id) {
|
|
474
|
+
throw mismatch();
|
|
475
|
+
}
|
|
476
|
+
// The stored bytes decode strictly, and their owner is the signing key's
|
|
477
|
+
// account, so a signature never authorizes another account's transaction.
|
|
478
|
+
let decoded;
|
|
479
|
+
try {
|
|
480
|
+
decoded = codec.decodeRaw(unsigned.payload.data);
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
throw fail('the unsigned payload is not a Tron transfer');
|
|
484
|
+
}
|
|
485
|
+
let signer;
|
|
486
|
+
try {
|
|
487
|
+
signer = (0, address_1.toHexAddress)((0, address_1.addressFromPublicKey)(request.publicKey));
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
throw fail('the signing request has no valid public key');
|
|
491
|
+
}
|
|
492
|
+
if (decoded.contract.owner !== signer) {
|
|
493
|
+
throw fail("the payload's owner is not the signing key's account");
|
|
494
|
+
}
|
|
495
|
+
// Only a signature the node will take for the owner's goes out, low s and
|
|
496
|
+
// recovery bit included, as the core's scheme checks it; a signer fault is a signing
|
|
497
|
+
// failure here, never a refusal on chain.
|
|
498
|
+
if (!schemes_1.secp256k1Ecdsa.verify({
|
|
499
|
+
publicKey: request.publicKey,
|
|
500
|
+
payload: (0, bytes_1.fromHex)(txId),
|
|
501
|
+
signature: signature.bytes,
|
|
502
|
+
recovery: signature.recovery,
|
|
503
|
+
})) {
|
|
504
|
+
throw fail('the signature does not verify against the signing key');
|
|
505
|
+
}
|
|
506
|
+
// The bytes carry the authorized summary; the proofs read the expiration and the
|
|
507
|
+
// reference height from the ordering; only the named fee field is read (the core may
|
|
508
|
+
// add others).
|
|
509
|
+
const expected = summaryTransfer(ctx, unsigned.summary, signer);
|
|
510
|
+
const feeLimit = unsigned.fee.details.feeLimit;
|
|
511
|
+
if (!expected ||
|
|
512
|
+
!carries(decoded, expected) ||
|
|
513
|
+
expiresAt(unsigned.ordering) !== decoded.expiration ||
|
|
514
|
+
!boundToReference(unsigned.ordering, decoded) ||
|
|
515
|
+
unsigned.fee.kind !== 'tron' ||
|
|
516
|
+
(expected.token === undefined
|
|
517
|
+
? decoded.feeLimit !== undefined
|
|
518
|
+
: typeof feeLimit !== 'bigint' ||
|
|
519
|
+
decoded.feeLimit === undefined ||
|
|
520
|
+
BigInt(decoded.feeLimit) !== feeLimit)) {
|
|
521
|
+
throw fail('the unsigned payload does not match its summary, expiry or fee limit');
|
|
522
|
+
}
|
|
523
|
+
const sig = (0, bytes_1.concatBytes)(signature.bytes, Uint8Array.of(27 + signature.recovery));
|
|
524
|
+
return {
|
|
525
|
+
raw: { encoding: 'hex', data: (0, bytes_1.toHex)(signedTransaction(raw, sig)) },
|
|
526
|
+
ref: { id: txId, idKind: 'tx-hash', canonical: true },
|
|
527
|
+
};
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
const broadcaster = {
|
|
531
|
+
async broadcast(signed, options = {}) {
|
|
532
|
+
const { raw } = signed;
|
|
533
|
+
if (raw.encoding !== 'hex' ||
|
|
534
|
+
typeof raw.data !== 'string' ||
|
|
535
|
+
raw.data.length % 2 !== 0 ||
|
|
536
|
+
!HEX_DIGITS.test(raw.data)) {
|
|
537
|
+
throw new error_1.UnsupportedCapabilityError('UNSUPPORTED_CAPABILITY', 'Tron broadcasts take the signed transaction as hex');
|
|
538
|
+
}
|
|
539
|
+
// The broadcast tags carry no quorum: one node's answer is classified, never compared.
|
|
540
|
+
const hex = raw.data.toLowerCase();
|
|
541
|
+
const answer = await api.broadcastHex(hex, {
|
|
542
|
+
...http_1.BROADCAST,
|
|
543
|
+
...(options.fanout !== undefined ? { fanout: options.fanout } : {}),
|
|
544
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
545
|
+
});
|
|
546
|
+
// Inside the broadcaster, so a possibly-sent throw reaches the engine's recordAmbiguous.
|
|
547
|
+
// A rejection stands only when its reason holds for these bytes.
|
|
548
|
+
return (0, errors_1.classifyOwnBroadcast)(answer, (0, errors_1.txBytesOf)(hex));
|
|
549
|
+
},
|
|
550
|
+
};
|
|
551
|
+
return { builder, broadcaster };
|
|
552
|
+
}
|
|
553
|
+
//# sourceMappingURL=builder.js.map
|