crypto-aio 0.0.3 → 0.2.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 +167 -0
- package/README.md +163 -13
- 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 +386 -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 +175 -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 +139 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -0
- package/dist/adapters/evm/fees.d.ts +103 -0
- package/dist/adapters/evm/fees.js +277 -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 +12 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/adapters/evm/network.d.ts +65 -0
- package/dist/adapters/evm/network.js +150 -0
- package/dist/adapters/evm/network.js.map +1 -0
- package/dist/adapters/evm/plugin.d.ts +35 -0
- package/dist/adapters/evm/plugin.js +150 -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 +370 -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 +83 -0
- package/dist/adapters/evm/reader.js +326 -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 +10 -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 +265 -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 +26 -0
- package/dist/adapters/evm/web3-client.js +176 -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 +556 -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 +77 -0
- package/dist/adapters/solana/fees.js +214 -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/message.d.ts +15 -0
- package/dist/adapters/solana/message.js +120 -0
- package/dist/adapters/solana/message.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 +44 -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 +124 -0
- package/dist/{type/contract.js → adapters/solana/types.js} +1 -1
- package/dist/adapters/solana/types.js.map +1 -0
- package/dist/adapters/solana/web3.d.ts +5 -0
- package/dist/adapters/solana/web3.js +61 -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 +755 -0
- package/dist/adapters/ton/proofs.js.map +1 -0
- package/dist/adapters/ton/reader.d.ts +235 -0
- package/dist/adapters/ton/reader.js +976 -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 +74 -0
- package/dist/adapters/ton/trace.js +303 -0
- package/dist/adapters/ton/trace.js.map +1 -0
- package/dist/adapters/ton/types.d.ts +105 -0
- package/dist/{type/transact.js → adapters/ton/types.js} +1 -1
- package/dist/adapters/ton/types.js.map +1 -0
- package/dist/adapters/ton/wallets.d.ts +86 -0
- package/dist/adapters/ton/wallets.js +373 -0
- package/dist/adapters/ton/wallets.js.map +1 -0
- package/dist/adapters/tron/abi.d.ts +41 -0
- package/dist/adapters/tron/abi.js +112 -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 +569 -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 +52 -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 +371 -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 +57 -0
- package/dist/adapters/tron/reader.js +220 -0
- package/dist/adapters/tron/reader.js.map +1 -0
- package/dist/adapters/tron/tokens.d.ts +9 -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 +100 -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 +63 -0
- package/dist/adapters/utxo/context.js +125 -0
- package/dist/adapters/utxo/context.js.map +1 -0
- package/dist/adapters/utxo/decode.d.ts +22 -0
- package/dist/adapters/utxo/decode.js +121 -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 +79 -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 +100 -0
- package/dist/adapters/utxo/esplora.js +498 -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 +66 -0
- package/dist/adapters/utxo/proofs.js +469 -0
- package/dist/adapters/utxo/proofs.js.map +1 -0
- package/dist/adapters/utxo/rawblock.d.ts +46 -0
- package/dist/adapters/utxo/rawblock.js +159 -0
- package/dist/adapters/utxo/rawblock.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +73 -0
- package/dist/adapters/utxo/rawtx.js +264 -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 +179 -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 +180 -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 +62 -0
- package/dist/core/container/container.js +500 -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 +379 -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 +163 -0
- package/dist/core/errors/codes.js +53 -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 +106 -0
- package/dist/core/lifecycle/engine-rules.js +267 -0
- package/dist/core/lifecycle/engine-rules.js.map +1 -0
- package/dist/core/lifecycle/engine.d.ts +502 -0
- package/dist/core/lifecycle/engine.js +1750 -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 +77 -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 +616 -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 +88 -0
- package/dist/core/lifecycle/workers.js +347 -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 +38 -0
- package/dist/core/model/ids.js +14 -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 +28 -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 +123 -0
- package/dist/{type/lib-types.js → core/model/transaction.js} +1 -1
- package/dist/core/model/transaction.js.map +1 -0
- package/dist/core/observe/scanner.d.ts +135 -0
- package/dist/core/observe/scanner.js +358 -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 +161 -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/format.d.ts +20 -0
- package/dist/core/store/format.js +86 -0
- package/dist/core/store/format.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 +258 -0
- package/dist/core/store/types.js +119 -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 +1703 -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 +159 -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 +35 -0
- package/dist/core/util/json.js +174 -0
- package/dist/core/util/json.js.map +1 -0
- package/dist/core/util/names.d.ts +27 -0
- package/dist/core/util/names.js +56 -0
- package/dist/core/util/names.js.map +1 -0
- package/dist/index.d.ts +65 -14
- package/dist/index.js +107 -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 +737 -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 +68 -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 +38 -0
- package/dist/testing/faulty-store.js +71 -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 +198 -45
- package/dist/libs/eth/account.d.ts +0 -9
- package/dist/libs/eth/account.js +0 -58
- package/dist/libs/eth/account.js.map +0 -1
- package/dist/libs/eth/contract.d.ts +0 -7
- package/dist/libs/eth/contract.js +0 -42
- package/dist/libs/eth/contract.js.map +0 -1
- package/dist/libs/eth/index.d.ts +0 -24
- package/dist/libs/eth/index.js +0 -72
- package/dist/libs/eth/index.js.map +0 -1
- package/dist/libs/eth/transact.d.ts +0 -7
- package/dist/libs/eth/transact.js +0 -26
- package/dist/libs/eth/transact.js.map +0 -1
- package/dist/libs/index.d.ts +0 -2
- package/dist/libs/index.js +0 -19
- package/dist/libs/index.js.map +0 -1
- package/dist/libs/trx/account.d.ts +0 -9
- package/dist/libs/trx/account.js +0 -55
- package/dist/libs/trx/account.js.map +0 -1
- package/dist/libs/trx/contract.d.ts +0 -7
- package/dist/libs/trx/contract.js +0 -27
- package/dist/libs/trx/contract.js.map +0 -1
- package/dist/libs/trx/index.d.ts +0 -22
- package/dist/libs/trx/index.js +0 -64
- package/dist/libs/trx/index.js.map +0 -1
- package/dist/libs/trx/transact.d.ts +0 -7
- package/dist/libs/trx/transact.js +0 -26
- package/dist/libs/trx/transact.js.map +0 -1
- package/dist/tool/common.d.ts +0 -28
- package/dist/tool/common.js +0 -33
- package/dist/tool/common.js.map +0 -1
- package/dist/tool/eth-tools.d.ts +0 -3
- package/dist/tool/eth-tools.js +0 -33
- package/dist/tool/eth-tools.js.map +0 -1
- package/dist/tool/index.d.ts +0 -5
- package/dist/tool/index.js +0 -22
- package/dist/tool/index.js.map +0 -1
- package/dist/tool/logging.d.ts +0 -3
- package/dist/tool/logging.js +0 -11
- package/dist/tool/logging.js.map +0 -1
- package/dist/tool/options.d.ts +0 -6
- package/dist/tool/options.js +0 -41
- package/dist/tool/options.js.map +0 -1
- package/dist/tool/trx-tools.d.ts +0 -3
- package/dist/tool/trx-tools.js +0 -20
- package/dist/tool/trx-tools.js.map +0 -1
- package/dist/type/account.d.ts +0 -9
- package/dist/type/account.js.map +0 -1
- package/dist/type/common.d.ts +0 -18
- package/dist/type/common.js.map +0 -1
- package/dist/type/contract.d.ts +0 -10
- package/dist/type/contract.js.map +0 -1
- package/dist/type/index.d.ts +0 -5
- package/dist/type/index.js +0 -22
- package/dist/type/index.js.map +0 -1
- package/dist/type/lib-types.d.ts +0 -9
- package/dist/type/lib-types.js.map +0 -1
- package/dist/type/transact.d.ts +0 -7
- package/dist/type/transact.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.0] - 2026-10-21
|
|
11
|
+
|
|
12
|
+
crypto-aio 0.2.0 settles everything 1.0 will promise: the API is locked by reports in CI,
|
|
13
|
+
the driver port is final, stored Operations carry a record format, and the gaps that could
|
|
14
|
+
make a paid transfer look failed are closed. Entries marked **Breaking** need a change from
|
|
15
|
+
some users; [Upgrade to 1.0](https://vhidvz.github.io/crypto-aio/reference/upgrading.html)
|
|
16
|
+
says what to do for each.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `SECURITY.md`: how to report a vulnerability privately, and what is in scope.
|
|
21
|
+
- Operation records carry `format` (`OPERATION_FORMAT`, 1), the record format they were
|
|
22
|
+
stored in; a record without one (0.1.0) reads as format 1. A process never reads a record
|
|
23
|
+
of a newer format: the read throws the new `RECORD_FORMAT_UNSUPPORTED`, and a worker
|
|
24
|
+
releases its claim for a newer process. The `OperationStore` contract suite checks that
|
|
25
|
+
a store keeps `format`, and tests pin the intent hash and the store keys as 0.1.0 wrote
|
|
26
|
+
them.
|
|
27
|
+
- API reports (`etc/api/*.api.md`, one per entry point), generated by API Extractor: CI fails
|
|
28
|
+
when the public API changes without its report (`pnpm api:update`).
|
|
29
|
+
- Release tooling: a tag such as `1.0.0-rc.1` publishes under npm's `next` dist-tag, a
|
|
30
|
+
release tag must match `package.json` and have a `CHANGELOG.md` section, which becomes the
|
|
31
|
+
GitHub Release's notes, and a release runs every CI check before it publishes.
|
|
32
|
+
- CI runs on Node.js 22.12.0, 22, 24 and 26, audits the runtime dependencies, and checks the
|
|
33
|
+
package's exports and types with `publint` and `@arethetypeswrong/cli`
|
|
34
|
+
(`pnpm lint:package`). CodeQL and Dependabot are configured.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- **Breaking:** crypto-aio needs Node.js 22.12 or later (`engines.node` is `>=22.12`), the
|
|
39
|
+
version every family already needed for Solana. `engines` no longer names an npm version,
|
|
40
|
+
so npm 11 installs without an engine warning.
|
|
41
|
+
- `package.json` declares `"type": "commonjs"`.
|
|
42
|
+
- **Breaking:** a transfer whose transaction executed but shows no transfer to the
|
|
43
|
+
recipient fails with the new `TX_UNEVIDENCED`, not `TX_REVERTED`: an EVM or Tron token
|
|
44
|
+
that logged no `Transfer` to the recipient, or TON jettons sent to a wallet the master
|
|
45
|
+
does not name. Value may have moved, so check the chain before paying again; a
|
|
46
|
+
`TX_REVERTED` now always means the execution failed. Drivers say which with
|
|
47
|
+
`failure: 'reverted' | 'unevidenced'` (`TxFailure`) on `observe` and `includedFinal`, and
|
|
48
|
+
the core keeps it on the Attempt's observation (`failure`, a field stores must keep).
|
|
49
|
+
- **Breaking:** an endpoint reads `healthy` in `status()` and `getNetworkStatus()` only
|
|
50
|
+
once its height is known, when its family probes heights: before that it is `unknown`,
|
|
51
|
+
where a confirmed identity alone used to make it `healthy`.
|
|
52
|
+
- **Breaking:** a proof needs `proofQuorum` endpoints even after some drop out of its count
|
|
53
|
+
(down for three health intervals): the quorum is capped by the endpoints configured, not
|
|
54
|
+
by those still counted, so the one endpoint left never proves alone; proofs wait for the
|
|
55
|
+
others instead. The new `transport.degradedProofs: true` restores the old behavior, which
|
|
56
|
+
favours liveness.
|
|
57
|
+
- `lifecycle.leaseWaitMs` (default: `leaseMs`): how long a transfer waits for its wallet's
|
|
58
|
+
address lease before `SEQUENCE_BUSY`, so transfers can queue behind a slow signer.
|
|
59
|
+
- Fuzz tests feed every decoder of untrusted bytes (Solana messages and transactions, Tron
|
|
60
|
+
protobuf, Bitcoin and EVM raw transactions, Avalanche transactions, cb58, exact-integer
|
|
61
|
+
JSON) random and mutated input; they may refuse it, never throw an unclassified error.
|
|
62
|
+
A nightly workflow runs them deeper, runs the live read-only integration suites, and
|
|
63
|
+
runs the unit suites on the newest release of every SDK.
|
|
64
|
+
- The pack check compiles a project that imports every entry point with TypeScript 5.3 (the
|
|
65
|
+
oldest supported, with `skipLibCheck`), the tested 5.9 and 7, under `nodenext` and
|
|
66
|
+
`bundler` resolution.
|
|
67
|
+
- `@solana/web3.js` 3 is supported next to 1.99 (peer range `^1.99.0 || ^3.0.0`). The
|
|
68
|
+
Solana driver now compiles its messages and derives token account addresses itself
|
|
69
|
+
(checked byte for byte against the SDK), so signed bytes no longer depend on the SDK
|
|
70
|
+
version; the SDK only backs `native()`. The pack check loads the family with 3.x too.
|
|
71
|
+
- `BuildContext.decimals`: the decimals the core scaled a transfer's amounts with. The
|
|
72
|
+
Solana driver refuses a token transfer whose mint has other decimals
|
|
73
|
+
(`ASSET_RESOLUTION`), which a wrong registration would otherwise sign as a mis-scaled
|
|
74
|
+
`transferChecked`.
|
|
75
|
+
- `ReplacementPolicy.comparePrice` (optional): the EVM family ranks earlier cancels by
|
|
76
|
+
price, so a repeat cancel climbs from the highest one without an explicit `fee`.
|
|
77
|
+
- `assets` on the root container's options registers tokens (decimals, symbol, aliases)
|
|
78
|
+
without writing a plugin.
|
|
79
|
+
- `PROVIDER_MISCONFIGURED` for refused credentials carries `details.httpStatus` (401 or 403).
|
|
80
|
+
- Solana: the signature fee is computed (5,000 lamports per signature), and an endpoint's
|
|
81
|
+
`getFeeForMessage` quote must match the message's fee exactly; any other quote fails the
|
|
82
|
+
estimate with a retryable `PROVIDER_UNAVAILABLE`, so one endpoint can neither inflate an
|
|
83
|
+
estimate (refusing a payable transfer) nor deflate it. Whether an explicit fee fits in
|
|
84
|
+
u64 is decided locally.
|
|
85
|
+
- **Breaking:** Bitcoin: a wallet whose signer does not declare the scheme its address type
|
|
86
|
+
signs with (a `p2tr` wallet on an ECDSA-only signer, such as a KMS key) is refused with
|
|
87
|
+
`CONFIG_INVALID` when the wallet resolves (`ready()`, `walletAddress()`, `transfer()`,
|
|
88
|
+
`prepareTransfer()`), before anything is built or reserved, instead of failing at
|
|
89
|
+
signing. A Schnorr-only signer on a non-`p2tr` wallet gets the same error, where it got
|
|
90
|
+
`INVALID_ADDRESS`. Watch-only wallets are unaffected. Drivers declare this with the
|
|
91
|
+
optional `ChainDriver.signingSchemes(wallet)`.
|
|
92
|
+
- **Breaking:** EVM and Tron: a token whose contract answers `deprecated()` with `true`
|
|
93
|
+
(Tether's `TetherToken`, USDT on Ethereum and Tron) is refused before signing with
|
|
94
|
+
`ASSET_RESOLUTION`, rather than sent through a contract that forwards it and logs no
|
|
95
|
+
`Transfer`. Every token estimate makes one more read.
|
|
96
|
+
- **Breaking:** EVM: the `maxGasLimit` option (`chains.<id>.options`, a handle's `options`,
|
|
97
|
+
or a network's `params.maxGasLimit`) bounds the gas limit of every transfer, replacement
|
|
98
|
+
and cancel, by default 2^24 (`DEFAULT_MAX_GAS_LIMIT`, Ethereum's EIP-7825 cap). An
|
|
99
|
+
estimate (with its headroom) or an override above it fails with `INVALID_INTENT` before
|
|
100
|
+
signing (`details.required`, `details.maxGasLimit`).
|
|
101
|
+
- EVM: on OP Stack chains since Isthmus, the operator fee (`GasPriceOracle.getOperatorFee`
|
|
102
|
+
for the gas limit) is its own `operator` charge and `details.operatorFee`, counted in
|
|
103
|
+
`details.expected` and the funds check.
|
|
104
|
+
- **Breaking:** the Bitcoin scanner reads each block's own bytes (`/block/:hash/raw`) and
|
|
105
|
+
delivers only transactions its header commits to: the merkle root (refusing the
|
|
106
|
+
CVE-2012-2459 duplicate), a coinbase first, and the BIP141 witness commitment; the header
|
|
107
|
+
read at the height must match those bytes. A scanned transaction's `from`, input values and
|
|
108
|
+
fee come from the previous transactions' bytes, checked against the txids its inputs name.
|
|
109
|
+
A block that does not match is a retryable `PROVIDER_INCONSISTENT` and decides nothing. A
|
|
110
|
+
filtered scan uses the indexer's JSON pages only to find spends from watched addresses,
|
|
111
|
+
checked against the bytes; an unfiltered one reads one previous transaction per distinct
|
|
112
|
+
parent outside the block, so scan with `filter.addresses`. `details.vout[].type` is named
|
|
113
|
+
from the script, as Blockstream electrs names it.
|
|
114
|
+
- The transport's `http` reads a binary answer with `responseType: 'bytes'`, within
|
|
115
|
+
`maxResponseBytes`.
|
|
116
|
+
- A reference PostgreSQL implementation of the four store ports, in
|
|
117
|
+
`examples/postgres-store` (schema, source, README; not part of the package), passes every
|
|
118
|
+
store contract suite and an engine crash-and-recover run against PostgreSQL 16 in CI.
|
|
119
|
+
- `pnpm test:evm-local` proves the EVM write path on a local anvil node, with ethers and
|
|
120
|
+
web3: proven finality, idempotent repeats, concurrent nonces, an ERC-20, replace, cancel,
|
|
121
|
+
crash recovery, funds checks and a reorg. CI runs it on every change.
|
|
122
|
+
- **Breaking:** an idempotency key and a scanner's `cursorKey` must be well-formed text
|
|
123
|
+
without U+0000 (`INVALID_INTENT`, `CONFIG_INVALID`): a database may refuse U+0000, and a
|
|
124
|
+
driver may turn a lone surrogate into U+FFFD, so two keys would become one.
|
|
125
|
+
- The store ports say which clock stamps times (the container's, or a wall clock the
|
|
126
|
+
processes share), and that a store may refuse an attempt id another Operation holds; the
|
|
127
|
+
contract suite no longer reuses one. `createFakeEnv` takes a `clock`, so stores built
|
|
128
|
+
beforehand can share it, and `FaultyOperationStore` passes `purge` through. The memory
|
|
129
|
+
store lists and purges nothing for a negative `limit`, as for 0.
|
|
130
|
+
- `RecoveryReport.unresent`: a `signed` or ambiguous Operation whose wallet no longer
|
|
131
|
+
resolves is now checked on chain and counted `unresent`, where it was counted `failed`
|
|
132
|
+
without its check.
|
|
133
|
+
- **Breaking (types only):** `Blockchain`'s constructor is private (handles come from
|
|
134
|
+
`aio.blockchain()` or `Blockchain.create()`), and its internal `protected` methods are gone
|
|
135
|
+
from the type declarations. `CryptoAio`'s constructor has one signature, `(options?)`.
|
|
136
|
+
|
|
137
|
+
### Deprecated
|
|
138
|
+
|
|
139
|
+
- `library: 'web3'` (and `Library.WEB3`): web3.js is no longer maintained upstream (4.16.0 is
|
|
140
|
+
its last release). It keeps working through 1.x, warns once per process with a
|
|
141
|
+
`DeprecationWarning` (code `CRYPTO_AIO_WEB3`), and is removed in 2.0. Use `ethers`.
|
|
142
|
+
|
|
143
|
+
### Fixed
|
|
144
|
+
|
|
145
|
+
- `evmChainPlugin` registers each `assets` ERC-20 under its EIP-55 checksummed contract,
|
|
146
|
+
whatever case it is given in, so a token's alias, its ref, its transfers and its balances
|
|
147
|
+
share one asset id (a lower-case contract made two assets, and deposits missed the
|
|
148
|
+
alias's). A token of another standard, a malformed contract, or a mixed-case contract with
|
|
149
|
+
a wrong checksum is refused with `CONFIG_INVALID` at registration.
|
|
150
|
+
- `stringifyTagged` encodes a Node.js `Buffer` as bytes, as the memory store keeps it; it was
|
|
151
|
+
written as `{ type: 'Buffer', data }` and read back as a plain object by a durable store.
|
|
152
|
+
- TON: `transfer bounced` and `jetton transfer bounced` no longer rest on the indexer's
|
|
153
|
+
word. The provider's raw records of the wallet transaction and of each delivery, checked
|
|
154
|
+
against their hashes and linked by message hash, must show the bounce; until they do, or
|
|
155
|
+
while the provider's endpoints disagree, the transfer stays undecided (a warning with code
|
|
156
|
+
`BOUNCE_UNPROVEN` when they contradict the indexer). A lone lying indexer can delay a
|
|
157
|
+
verdict, never fail a transfer that landed.
|
|
158
|
+
|
|
159
|
+
## [0.1.0] - 2026-10-01
|
|
160
|
+
|
|
161
|
+
### Added
|
|
162
|
+
|
|
163
|
+
- initial release 🎉🎊.
|
|
164
|
+
|
|
165
|
+
[Unreleased]: https://github.com/vhidvz/crypto-aio/compare/0.2.0...HEAD
|
|
166
|
+
[0.2.0]: https://github.com/vhidvz/crypto-aio/compare/0.1.0...0.2.0
|
|
167
|
+
[0.1.0]: https://github.com/vhidvz/crypto-aio/releases/tag/0.1.0
|
package/README.md
CHANGED
|
@@ -1,25 +1,175 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<a href="https://vhidvz.github.io/crypto-aio/">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/vhidvz/crypto-aio/main/docs/public/crypto-aio-logo-dark.svg">
|
|
5
|
+
<img alt="crypto-aio" src="https://raw.githubusercontent.com/vhidvz/crypto-aio/main/docs/public/crypto-aio-logo.svg" width="420">
|
|
6
|
+
</picture>
|
|
7
|
+
</a>
|
|
8
|
+
</h1>
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
<div align="center">
|
|
4
11
|
|
|
5
|
-
[](https://github.com/vhidvz/crypto-aio/actions/workflows/npm-ci.yml)
|
|
6
12
|
[](https://www.npmjs.com/package/crypto-aio)
|
|
13
|
+
[](https://github.com/vhidvz/crypto-aio/actions/workflows/ci.yml)
|
|
7
14
|

|
|
8
|
-
[](https://htmlpreview.github.io/?https://github.com/vhidvz/crypto-aio/blob/main/coverage/lcov-report/index.html)
|
|
16
|
+
[](LICENSE)
|
|
17
|
+
[](https://vhidvz.github.io/crypto-aio/)
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
**One TypeScript API for moving money on blockchains.** Balances, transfers, confirmations
|
|
20
|
+
and deposit scanning across EVM chains, Bitcoin, Tron, Solana, TON and the Avalanche X-Chain and
|
|
21
|
+
P-Chain, built for exchanges, wallets and payment systems.
|
|
13
22
|
|
|
23
|
+
[Documentation](https://vhidvz.github.io/crypto-aio/) ·
|
|
24
|
+
[Quick start](https://vhidvz.github.io/crypto-aio/start/quick-start.html) ·
|
|
25
|
+
[Learn from zero](https://vhidvz.github.io/crypto-aio/learn/) ·
|
|
26
|
+
[Examples](https://vhidvz.github.io/crypto-aio/build/examples.html) ·
|
|
27
|
+
[API](https://vhidvz.github.io/crypto-aio/reference/api.html)
|
|
28
|
+
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
## Why crypto-aio
|
|
32
|
+
|
|
33
|
+
Every chain has an SDK that can build, sign and send a transaction. None of them is a payment
|
|
34
|
+
system. The hard part of moving money is everything around the transaction: a reply that never
|
|
35
|
+
arrives, a process that dies between signing and sending, two servers sending from one wallet, a
|
|
36
|
+
node that says "final" about a block that is later replaced. crypto-aio is the layer that handles
|
|
37
|
+
those cases, written once, with the same API on every chain:
|
|
38
|
+
|
|
39
|
+
- **Pay exactly once.** Every transfer carries your own idempotency key. Repeat the call after a
|
|
40
|
+
timeout, a crash or a lost reply, and you get the same payment back, never a second one.
|
|
41
|
+
- **Crash-safe.** A signed transaction is stored before it is sent. After a restart, the library
|
|
42
|
+
sends those exact bytes again; recovery never signs.
|
|
43
|
+
- **Final means proven.** A transfer is final only on finalized chain data that a quorum of
|
|
44
|
+
independent endpoints agree on, never on one node's word.
|
|
45
|
+
- **Deposits that survive reorgs.** Durable scanners deliver every block at least once, and roll
|
|
46
|
+
back when the chain reorganizes.
|
|
47
|
+
- **Keys stay with signers.** In memory, or behind your HSM, KMS or MPC custody, with a policy
|
|
48
|
+
hook before every signature. Logs, errors and events never carry a secret.
|
|
49
|
+
- **One shape, explicit differences.** What a chain cannot do is a named capability, not a silent
|
|
50
|
+
difference.
|
|
51
|
+
|
|
52
|
+
**Who it is for:** backend developers building exchanges, custodial wallets, payment processors
|
|
53
|
+
and treasury systems on Node.js. New to crypto? The documentation teaches everything from first
|
|
54
|
+
principles, starting with [what a ledger is](https://vhidvz.github.io/crypto-aio/learn/foundations/ledgers.html).
|
|
55
|
+
|
|
56
|
+
## Supported networks
|
|
57
|
+
|
|
58
|
+
| Family | Chains | Through |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| EVM | Ethereum, BNB Smart Chain, Polygon, Avalanche C-Chain, Arbitrum, Optimism, Base, and any EVM chain you add | `ethers` 6 (or the deprecated `web3` 4) |
|
|
61
|
+
| Bitcoin | mainnet, testnet, testnet4, signet, regtest | `bitcoinjs-lib` 7 and an Esplora indexer |
|
|
62
|
+
| Tron | mainnet, Shasta, Nile | `tronweb` 6 |
|
|
63
|
+
| Solana | mainnet, devnet, testnet | `@solana/web3.js` 1 or 3 |
|
|
64
|
+
| TON | mainnet, testnet | `@ton/ton` 16 and toncenter |
|
|
65
|
+
| Avalanche X-Chain and P-Chain | mainnet, Fuji | `@avalabs/avalanchejs` 5 and the Avalanche Data API |
|
|
66
|
+
|
|
67
|
+
What each network supports, family by family, is in
|
|
68
|
+
[Networks](https://vhidvz.github.io/crypto-aio/reference/networks/).
|
|
69
|
+
|
|
70
|
+
## Install
|
|
71
|
+
|
|
72
|
+
crypto-aio needs Node.js 22.12 or later. Install the package, and only the
|
|
73
|
+
SDK of each family you use:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
npm install crypto-aio ethers # EVM chains
|
|
77
|
+
npm install crypto-aio bitcoinjs-lib # Bitcoin
|
|
78
|
+
npm install crypto-aio tronweb # Tron
|
|
79
|
+
npm install crypto-aio @solana/web3.js # Solana
|
|
80
|
+
npm install crypto-aio @ton/ton @ton/core @ton/crypto # TON
|
|
81
|
+
npm install crypto-aio @avalabs/avalanchejs # Avalanche X-Chain and P-Chain
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A handle whose SDK is missing fails with `DEPENDENCY_MISSING` and names the install command.
|
|
85
|
+
The type declarations need TypeScript 5.3 or later, and each family's entry point
|
|
86
|
+
(`crypto-aio/evm`, …) the types of its SDK; some SDKs' own declarations need TypeScript 5.7
|
|
87
|
+
unless `skipLibCheck` is on. TypeScript 7 is supported.
|
|
88
|
+
|
|
89
|
+
## Your first transfer, with no network and no keys
|
|
90
|
+
|
|
91
|
+
`crypto-aio/testing` ships an in-memory chain, so you can see the whole flow before you configure
|
|
92
|
+
anything:
|
|
93
|
+
|
|
94
|
+
<!-- runnable -->
|
|
14
95
|
```ts
|
|
15
|
-
import {
|
|
96
|
+
import { createFakeEnv } from 'crypto-aio/testing';
|
|
97
|
+
|
|
98
|
+
const env = await createFakeEnv(); // an in-memory chain, a funded wallet, and a handle
|
|
99
|
+
const sub = await env.run(
|
|
100
|
+
env.bc.transfer({ to: env.stranger(), amount: '0.001' }, { idempotencyKey: 'order-42' }),
|
|
101
|
+
);
|
|
102
|
+
env.chain.mine(4); // the fake chain makes blocks when you ask
|
|
103
|
+
const { status } = await env.run(sub.wait({ finality: 'final' }));
|
|
104
|
+
console.log(status.state, status.evidence); // final proven
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The [Quick start](https://vhidvz.github.io/crypto-aio/start/quick-start.html) explains each line.
|
|
16
108
|
|
|
17
|
-
|
|
109
|
+
## On a real network
|
|
18
110
|
|
|
19
|
-
|
|
111
|
+
```ts
|
|
112
|
+
import { Blockchain, configure, localSigner, secret } from 'crypto-aio';
|
|
113
|
+
|
|
114
|
+
configure({
|
|
115
|
+
providers: {
|
|
116
|
+
alchemy: { preset: 'alchemy', apiKey: secret(process.env.ALCHEMY_KEY ?? '') },
|
|
117
|
+
infura: { preset: 'infura', apiKey: secret(process.env.INFURA_KEY ?? '') },
|
|
118
|
+
},
|
|
119
|
+
signers: { hot: localSigner({ id: 'hot', secp256k1: secret(process.env.HOT_KEY ?? '') }) },
|
|
120
|
+
wallets: { treasury: { signer: 'hot' } },
|
|
121
|
+
chains: { ethereum: { network: 'sepolia', provider: ['alchemy', 'infura'], wallet: 'treasury' } },
|
|
122
|
+
lifecycle: { requireIdempotencyKey: true },
|
|
123
|
+
});
|
|
20
124
|
|
|
21
|
-
|
|
22
|
-
|
|
125
|
+
const eth = Blockchain.create({ chain: 'ethereum' });
|
|
126
|
+
const me = await eth.walletAddress();
|
|
127
|
+
console.log((await eth.getBalance(me.canonical)).amount.format()); // e.g. '0.5 ETH'
|
|
23
128
|
|
|
24
|
-
|
|
129
|
+
const sub = await eth.transfer(
|
|
130
|
+
{ to: '0x3535353535353535353535353535353535353535', amount: '0.01' },
|
|
131
|
+
{ idempotencyKey: 'withdrawal-42' }, // your own id: repeating the call never pays twice
|
|
132
|
+
);
|
|
133
|
+
const { status } = await sub.wait({ finality: 'final' });
|
|
134
|
+
console.log(status.state, status.evidence); // 'final' 'proven'
|
|
25
135
|
```
|
|
136
|
+
|
|
137
|
+
The same calls work on every chain above. [Connect to a real
|
|
138
|
+
network](https://vhidvz.github.io/crypto-aio/build/connect.html) has the configuration for each
|
|
139
|
+
family.
|
|
140
|
+
|
|
141
|
+
## Where to go next
|
|
142
|
+
|
|
143
|
+
| If you… | Start here |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| Are new to cryptocurrency or blockchains | The [learning path](https://vhidvz.github.io/crypto-aio/learn/): money, keys, transactions and finality, then the engineering of safe payments, then a tour of crypto-aio |
|
|
146
|
+
| Know blockchains and want the model fast | [crypto-aio in 10 minutes](https://vhidvz.github.io/crypto-aio/start/mental-model.html), then the [hands-on tutorial](https://vhidvz.github.io/crypto-aio/start/tutorial.html) |
|
|
147
|
+
| Want to build now | [Examples](https://vhidvz.github.io/crypto-aio/build/examples.html) and the [Build guides](https://vhidvz.github.io/crypto-aio/build/) |
|
|
148
|
+
| Need an exact answer | [API](https://vhidvz.github.io/crypto-aio/reference/api.html), [Configuration](https://vhidvz.github.io/crypto-aio/reference/configuration.html), [Errors](https://vhidvz.github.io/crypto-aio/reference/errors.html) |
|
|
149
|
+
| Are going to production | [Production architecture](https://vhidvz.github.io/crypto-aio/tour/production.html) and the [checklist](https://vhidvz.github.io/crypto-aio/build/production.html) |
|
|
150
|
+
| Want to add a chain or a store | [Explore](https://vhidvz.github.io/crypto-aio/explore/): plugins, stores and the source map |
|
|
151
|
+
|
|
152
|
+
## Status
|
|
153
|
+
|
|
154
|
+
crypto-aio is at **0.2.0**, on its way to 1.0, from which [semantic
|
|
155
|
+
versioning](https://vhidvz.github.io/crypto-aio/reference/stability.html) covers the whole API,
|
|
156
|
+
the driver port and what a process stores; the 0.0.x releases on npm are an older, unrelated
|
|
157
|
+
API. [Known limitations](https://vhidvz.github.io/crypto-aio/reference/limitations.html) lists
|
|
158
|
+
what it does not do yet, and [Upgrade to 1.0](https://vhidvz.github.io/crypto-aio/reference/upgrading.html)
|
|
159
|
+
what changes from 0.1.0. Only in-memory stores ship: production needs durable stores of your
|
|
160
|
+
own, proven with the contract suites in `crypto-aio/testing`; [examples/postgres-store](examples/postgres-store)
|
|
161
|
+
is a reference implementation on PostgreSQL. Release notes are in the [changelog](CHANGELOG.md).
|
|
162
|
+
|
|
163
|
+
## Contributing
|
|
164
|
+
|
|
165
|
+
Issues and pull requests are welcome. `pnpm install` and `pnpm check` (lint, typecheck and tests)
|
|
166
|
+
are all a change needs locally, plus `pnpm api:update` when it changes the public API (CI
|
|
167
|
+
compares the API with the reports in `etc/api/`). `pnpm test:evm-local` also signs, broadcasts
|
|
168
|
+
and proves real EVM transactions on a local anvil node, which it starts and stops; CI runs it
|
|
169
|
+
on every change. The [source map](https://vhidvz.github.io/crypto-aio/explore/source-map.html)
|
|
170
|
+
explains the repository, and [docs/README.md](docs/README.md) how the documentation is built and
|
|
171
|
+
tested.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NormalizedAddress } from '../../core/model/address';
|
|
2
|
+
import type { AvalancheNetworkConfig } from './network';
|
|
3
|
+
export declare const ADDRESS_BYTES = 20;
|
|
4
|
+
type AddressParams = Pick<AvalancheNetworkConfig, 'alias' | 'hrp'>;
|
|
5
|
+
/** The 20 address bytes of a compressed secp256k1 public key. */
|
|
6
|
+
export declare function addressBytesOf(publicKey: Uint8Array): Uint8Array;
|
|
7
|
+
/** `X-avax1…`: the canonical form of 20 address bytes on this chain. */
|
|
8
|
+
export declare function formatAddress(bytes: Uint8Array, params: AddressParams): string;
|
|
9
|
+
/**
|
|
10
|
+
* The address bytes of `address`; throws `INVALID_ADDRESS` with a fixed text that never
|
|
11
|
+
* repeats the input, which may be a pasted secret.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decodeAddress(address: string, params: AddressParams): Uint8Array;
|
|
14
|
+
export declare function normalizeAddress(address: string, params: AddressParams): NormalizedAddress;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADDRESS_BYTES = void 0;
|
|
4
|
+
exports.addressBytesOf = addressBytesOf;
|
|
5
|
+
exports.formatAddress = formatAddress;
|
|
6
|
+
exports.decodeAddress = decodeAddress;
|
|
7
|
+
exports.normalizeAddress = normalizeAddress;
|
|
8
|
+
/**
|
|
9
|
+
* X-Chain and P-Chain addresses (SDK-free). An address is 20 bytes, the RIPEMD-160 of the
|
|
10
|
+
* SHA-256 of a compressed secp256k1 public key, written in bech32 with the network's
|
|
11
|
+
* human-readable part (`avax`, `fuji`) behind the chain's alias: `X-avax1…`, `P-avax1…`.
|
|
12
|
+
* The canonical form carries the alias, lower case. A bare `avax1…` is accepted and
|
|
13
|
+
* normalized to this chain's alias; the other chain's alias (`P-` on the X-Chain), a
|
|
14
|
+
* C-Chain or another network's address, and anything that is not 20 bytes are refused: the
|
|
15
|
+
* same key's bytes on another chain are a cross-chain transfer, which a transfer never is.
|
|
16
|
+
*/
|
|
17
|
+
const ripemd160_1 = require("@noble/hashes/ripemd160");
|
|
18
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
19
|
+
const base_1 = require("@scure/base");
|
|
20
|
+
const error_1 = require("../../core/errors/error");
|
|
21
|
+
exports.ADDRESS_BYTES = 20;
|
|
22
|
+
/** Bech32 allows at most 90 characters; the alias and `-` add two. */
|
|
23
|
+
const MAX_ADDRESS_LENGTH = 92;
|
|
24
|
+
const invalid = (reason) => new error_1.ValidationError('INVALID_ADDRESS', `not an address of this chain: ${reason}`);
|
|
25
|
+
/** The 20 address bytes of a compressed secp256k1 public key. */
|
|
26
|
+
function addressBytesOf(publicKey) {
|
|
27
|
+
if (publicKey.length !== 33 || (publicKey[0] !== 2 && publicKey[0] !== 3)) {
|
|
28
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'an Avalanche address needs a 33-byte compressed secp256k1 public key');
|
|
29
|
+
}
|
|
30
|
+
return (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)(publicKey));
|
|
31
|
+
}
|
|
32
|
+
/** `X-avax1…`: the canonical form of 20 address bytes on this chain. */
|
|
33
|
+
function formatAddress(bytes, params) {
|
|
34
|
+
return `${params.alias}-${base_1.bech32.encode(params.hrp, base_1.bech32.toWords(bytes))}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The address bytes of `address`; throws `INVALID_ADDRESS` with a fixed text that never
|
|
38
|
+
* repeats the input, which may be a pasted secret.
|
|
39
|
+
*/
|
|
40
|
+
function decodeAddress(address, params) {
|
|
41
|
+
if (typeof address !== 'string' || address.length > MAX_ADDRESS_LENGTH) {
|
|
42
|
+
throw invalid('malformed');
|
|
43
|
+
}
|
|
44
|
+
const dash = address.indexOf('-');
|
|
45
|
+
if (dash !== -1 && address.slice(0, dash) !== params.alias) {
|
|
46
|
+
throw invalid(`the chain alias is not '${params.alias}'`);
|
|
47
|
+
}
|
|
48
|
+
const body = dash === -1 ? address : address.slice(dash + 1);
|
|
49
|
+
let decoded;
|
|
50
|
+
try {
|
|
51
|
+
decoded = base_1.bech32.decode(body, 90);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw invalid('malformed bech32');
|
|
55
|
+
}
|
|
56
|
+
if (decoded.prefix !== params.hrp) {
|
|
57
|
+
throw invalid(`the network prefix is not '${params.hrp}'`);
|
|
58
|
+
}
|
|
59
|
+
let bytes;
|
|
60
|
+
try {
|
|
61
|
+
bytes = base_1.bech32.fromWords(decoded.words);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw invalid('malformed bech32');
|
|
65
|
+
}
|
|
66
|
+
if (bytes.length !== exports.ADDRESS_BYTES)
|
|
67
|
+
throw invalid('not 20 bytes');
|
|
68
|
+
return bytes;
|
|
69
|
+
}
|
|
70
|
+
function normalizeAddress(address, params) {
|
|
71
|
+
const canonical = formatAddress(decodeAddress(address, params), params);
|
|
72
|
+
return { canonical, display: canonical };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../../src/adapters/avalanche/address.ts"],"names":[],"mappings":";;;AA2BA,wCAQC;AAGD,sCAEC;AAMD,sCA0BC;AAED,4CAMC;AAhFD;;;;;;;;GAQG;AACH,uDAAoD;AACpD,iDAA8C;AAC9C,sCAAqC;AACrC,mDAA0D;AAI7C,QAAA,aAAa,GAAG,EAAE,CAAC;AAEhC,sEAAsE;AACtE,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAI9B,MAAM,OAAO,GAAG,CAAC,MAAc,EAAmB,EAAE,CAClD,IAAI,uBAAe,CAAC,iBAAiB,EAAE,iCAAiC,MAAM,EAAE,CAAC,CAAC;AAEpF,iEAAiE;AACjE,SAAgB,cAAc,CAAC,SAAqB;IAClD,IAAI,SAAS,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1E,MAAM,IAAI,uBAAe,CACvB,iBAAiB,EACjB,sEAAsE,CACvE,CAAC;IACJ,CAAC;IACD,OAAO,IAAA,qBAAS,EAAC,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,wEAAwE;AACxE,SAAgB,aAAa,CAAC,KAAiB,EAAE,MAAqB;IACpE,OAAO,GAAG,MAAM,CAAC,KAAK,IAAI,aAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,aAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,MAAqB;IAClE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACvE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;QAC3D,MAAM,OAAO,CAAC,2BAA2B,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IAC7D,IAAI,OAA4C,CAAC;IACjD,IAAI,CAAC;QACH,OAAO,GAAG,aAAM,CAAC,MAAM,CAAC,IAA6B,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,OAAO,CAAC,8BAA8B,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,KAAiB,CAAC;IACtB,IAAI,CAAC;QACH,KAAK,GAAG,aAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,qBAAa;QAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAAe,EACf,MAAqB;IAErB,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IACxE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["/**\n * X-Chain and P-Chain addresses (SDK-free). An address is 20 bytes, the RIPEMD-160 of the\n * SHA-256 of a compressed secp256k1 public key, written in bech32 with the network's\n * human-readable part (`avax`, `fuji`) behind the chain's alias: `X-avax1…`, `P-avax1…`.\n * The canonical form carries the alias, lower case. A bare `avax1…` is accepted and\n * normalized to this chain's alias; the other chain's alias (`P-` on the X-Chain), a\n * C-Chain or another network's address, and anything that is not 20 bytes are refused: the\n * same key's bytes on another chain are a cross-chain transfer, which a transfer never is.\n */\nimport { ripemd160 } from '@noble/hashes/ripemd160';\nimport { sha256 } from '@noble/hashes/sha256';\nimport { bech32 } from '@scure/base';\nimport { ValidationError } from '../../core/errors/error';\nimport type { NormalizedAddress } from '../../core/model/address';\nimport type { AvalancheNetworkConfig } from './network';\n\nexport const ADDRESS_BYTES = 20;\n\n/** Bech32 allows at most 90 characters; the alias and `-` add two. */\nconst MAX_ADDRESS_LENGTH = 92;\n\ntype AddressParams = Pick<AvalancheNetworkConfig, 'alias' | 'hrp'>;\n\nconst invalid = (reason: string): ValidationError =>\n new ValidationError('INVALID_ADDRESS', `not an address of this chain: ${reason}`);\n\n/** The 20 address bytes of a compressed secp256k1 public key. */\nexport function addressBytesOf(publicKey: Uint8Array): Uint8Array {\n if (publicKey.length !== 33 || (publicKey[0] !== 2 && publicKey[0] !== 3)) {\n throw new ValidationError(\n 'INVALID_ADDRESS',\n 'an Avalanche address needs a 33-byte compressed secp256k1 public key',\n );\n }\n return ripemd160(sha256(publicKey));\n}\n\n/** `X-avax1…`: the canonical form of 20 address bytes on this chain. */\nexport function formatAddress(bytes: Uint8Array, params: AddressParams): string {\n return `${params.alias}-${bech32.encode(params.hrp, bech32.toWords(bytes))}`;\n}\n\n/**\n * The address bytes of `address`; throws `INVALID_ADDRESS` with a fixed text that never\n * repeats the input, which may be a pasted secret.\n */\nexport function decodeAddress(address: string, params: AddressParams): Uint8Array {\n if (typeof address !== 'string' || address.length > MAX_ADDRESS_LENGTH) {\n throw invalid('malformed');\n }\n const dash = address.indexOf('-');\n if (dash !== -1 && address.slice(0, dash) !== params.alias) {\n throw invalid(`the chain alias is not '${params.alias}'`);\n }\n const body = dash === -1 ? address : address.slice(dash + 1);\n let decoded: { prefix: string; words: number[] };\n try {\n decoded = bech32.decode(body as `${string}1${string}`, 90);\n } catch {\n throw invalid('malformed bech32');\n }\n if (decoded.prefix !== params.hrp) {\n throw invalid(`the network prefix is not '${params.hrp}'`);\n }\n let bytes: Uint8Array;\n try {\n bytes = bech32.fromWords(decoded.words);\n } catch {\n throw invalid('malformed bech32');\n }\n if (bytes.length !== ADDRESS_BYTES) throw invalid('not 20 bytes');\n return bytes;\n}\n\nexport function normalizeAddress(\n address: string,\n params: AddressParams,\n): NormalizedAddress {\n const canonical = formatAddress(decodeAddress(address, params), params);\n return { canonical, display: canonical };\n}\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ProviderError } from '../../core/errors/error';
|
|
2
|
+
import type { Transport } from '../../core/transport/types';
|
|
3
|
+
import type { AvalancheCallTags, AvalancheVm } from './types';
|
|
4
|
+
/** A block as the node reports it; ids are CB58. */
|
|
5
|
+
export interface NodeBlock {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly parentId: string;
|
|
8
|
+
readonly height: bigint;
|
|
9
|
+
/** Unix seconds; absent on P-Chain blocks from before the Banff upgrade. */
|
|
10
|
+
readonly timestamp?: number;
|
|
11
|
+
/** Every transaction the block carries, decision and proposal alike. */
|
|
12
|
+
readonly txIds: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** The P-Chain's view of a transaction (`platform.getTxStatus`). */
|
|
15
|
+
export type PlatformStatus = 'Committed' | 'Aborted' | 'Processing' | 'Dropped' | 'Unknown';
|
|
16
|
+
export interface FeeState {
|
|
17
|
+
readonly capacity: bigint;
|
|
18
|
+
readonly excess: bigint;
|
|
19
|
+
readonly price: bigint;
|
|
20
|
+
readonly timestamp: string;
|
|
21
|
+
}
|
|
22
|
+
/** The P-Chain's fee dimensions' weights: bandwidth, reads, writes, compute. */
|
|
23
|
+
export type FeeWeights = readonly [number, number, number, number];
|
|
24
|
+
/** Where the indexer says a transaction is. */
|
|
25
|
+
export interface Location {
|
|
26
|
+
readonly height: bigint;
|
|
27
|
+
readonly hash: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const malformed: (what: string) => ProviderError;
|
|
30
|
+
/** A definitive JSON-RPC "not found" (`not found`, `couldn't get tx: not found`, …). */
|
|
31
|
+
export declare function isNodeNotFound(error: unknown): boolean;
|
|
32
|
+
/** A definitive HTTP 404 from the Data API. */
|
|
33
|
+
export declare function isHttpNotFound(error: unknown): boolean;
|
|
34
|
+
/** A non-negative integer height, as a number, a bigint or a decimal string. */
|
|
35
|
+
export declare function parseHeight(value: unknown, what?: string): bigint;
|
|
36
|
+
/** `0x…` hex with a trailing 4-byte SHA-256 checksum, as AvalancheGo encodes bytes. */
|
|
37
|
+
export declare function decodeChecked(value: unknown, what: string): Uint8Array;
|
|
38
|
+
/** `0x…` hex of `bytes` with AvalancheGo's checksum. */
|
|
39
|
+
export declare function encodeChecked(bytes: Uint8Array): string;
|
|
40
|
+
/** The JSON block of `getBlock`/`getBlockByHeight`, X-Chain or P-Chain, any block type. */
|
|
41
|
+
export declare function parseBlock(answer: unknown): NodeBlock;
|
|
42
|
+
export declare function parsePlatformStatus(answer: unknown): PlatformStatus;
|
|
43
|
+
/** `getUTXOs` asks for at most this many outputs per page (AvalancheGo's maximum). */
|
|
44
|
+
export declare const UTXO_PAGE = 1024;
|
|
45
|
+
export declare class AvalancheNode {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(transport: Transport, vm: AvalancheVm);
|
|
48
|
+
height(tags: AvalancheCallTags): Promise<bigint>;
|
|
49
|
+
/** The accepted block at `height`; `null` when the node has none there (yet). */
|
|
50
|
+
blockAt(height: bigint, tags: AvalancheCallTags): Promise<NodeBlock | null>;
|
|
51
|
+
blockById(blockId: string, tags: AvalancheCallTags): Promise<NodeBlock | null>;
|
|
52
|
+
/**
|
|
53
|
+
* An accepted transaction's signed bytes, which must hash to `txId`; `null` when the node
|
|
54
|
+
* does not have it in its accepted state.
|
|
55
|
+
*/
|
|
56
|
+
txBytes(txId: string, tags: AvalancheCallTags): Promise<Uint8Array | null>;
|
|
57
|
+
/** P-Chain only: committed, aborted, in a mempool, dropped by one, or unknown. */
|
|
58
|
+
txStatus(txId: string, tags: AvalancheCallTags): Promise<PlatformStatus>;
|
|
59
|
+
/**
|
|
60
|
+
* Every output the node lists for `address` (its UTXO set), as raw UTXO bytes, read page
|
|
61
|
+
* by page. An output listed twice alike is kept once; listed twice differently, the
|
|
62
|
+
* answer is malformed.
|
|
63
|
+
*/
|
|
64
|
+
utxos(address: string, tags: AvalancheCallTags): Promise<Uint8Array[]>;
|
|
65
|
+
/** Issues signed bytes; resolves to the id the node gives them. */
|
|
66
|
+
issueTx(bytes: Uint8Array, tags: AvalancheCallTags): Promise<string>;
|
|
67
|
+
/** X-Chain: the fixed fee of a transaction (`txFee`), in nAVAX. */
|
|
68
|
+
txFee(tags: AvalancheCallTags): Promise<bigint>;
|
|
69
|
+
/** P-Chain: the current gas price and capacity (Etna's dynamic fees). */
|
|
70
|
+
feeState(tags: AvalancheCallTags): Promise<FeeState>;
|
|
71
|
+
/** P-Chain: the weights of the four fee dimensions and the minimum gas price. */
|
|
72
|
+
feeConfig(tags: AvalancheCallTags): Promise<{
|
|
73
|
+
readonly weights: FeeWeights;
|
|
74
|
+
readonly minPrice: bigint;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/** One transaction of an address's history, as the Data API lists it (newest first). */
|
|
78
|
+
export interface HistoryEntry {
|
|
79
|
+
readonly txId: string;
|
|
80
|
+
/** Absent for an X-Chain transaction from before its linearization (no block). */
|
|
81
|
+
readonly location?: Location;
|
|
82
|
+
}
|
|
83
|
+
export declare class DataApi {
|
|
84
|
+
#private;
|
|
85
|
+
constructor(transport: Transport);
|
|
86
|
+
/** Where the indexer says `txId` is; `null` when it does not know it (404). */
|
|
87
|
+
locate(txId: string, tags: AvalancheCallTags): Promise<Location | null | 'no-block'>;
|
|
88
|
+
/** A page of `address`'s transactions, newest first. */
|
|
89
|
+
history(address: string, options: {
|
|
90
|
+
readonly cursor?: string;
|
|
91
|
+
readonly pageSize: number;
|
|
92
|
+
}, tags: AvalancheCallTags): Promise<{
|
|
93
|
+
readonly items: readonly HistoryEntry[];
|
|
94
|
+
readonly next?: string;
|
|
95
|
+
}>;
|
|
96
|
+
/** The hash of the indexer's block at height 0 (its identity probe). */
|
|
97
|
+
static blockZero(answer: unknown): string;
|
|
98
|
+
/** The indexer's newest block height (its height probe). */
|
|
99
|
+
static latestHeight(answer: unknown): bigint;
|
|
100
|
+
}
|