crypto-aio 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +144 -14
- package/dist/adapters/avalanche/address.d.ts +15 -0
- package/dist/adapters/avalanche/address.js +74 -0
- package/dist/adapters/avalanche/address.js.map +1 -0
- package/dist/adapters/avalanche/api.d.ts +100 -0
- package/dist/adapters/avalanche/api.js +381 -0
- package/dist/adapters/avalanche/api.js.map +1 -0
- package/dist/adapters/avalanche/builder.d.ts +13 -0
- package/dist/adapters/avalanche/builder.js +336 -0
- package/dist/adapters/avalanche/builder.js.map +1 -0
- package/dist/adapters/avalanche/cb58.d.ts +7 -0
- package/dist/adapters/avalanche/cb58.js +49 -0
- package/dist/adapters/avalanche/cb58.js.map +1 -0
- package/dist/adapters/avalanche/chains.d.ts +21 -0
- package/dist/adapters/avalanche/chains.js +79 -0
- package/dist/adapters/avalanche/chains.js.map +1 -0
- package/dist/adapters/avalanche/codec.d.ts +94 -0
- package/dist/adapters/avalanche/codec.js +371 -0
- package/dist/adapters/avalanche/codec.js.map +1 -0
- package/dist/adapters/avalanche/context.d.ts +59 -0
- package/dist/adapters/avalanche/context.js +114 -0
- package/dist/adapters/avalanche/context.js.map +1 -0
- package/dist/adapters/avalanche/decode.d.ts +16 -0
- package/dist/adapters/avalanche/decode.js +101 -0
- package/dist/adapters/avalanche/decode.js.map +1 -0
- package/dist/adapters/avalanche/driver.d.ts +22 -0
- package/dist/adapters/avalanche/driver.js +81 -0
- package/dist/adapters/avalanche/driver.js.map +1 -0
- package/dist/adapters/avalanche/errors.d.ts +18 -0
- package/dist/adapters/avalanche/errors.js +61 -0
- package/dist/adapters/avalanche/errors.js.map +1 -0
- package/dist/adapters/avalanche/fees.d.ts +23 -0
- package/dist/adapters/avalanche/fees.js +105 -0
- package/dist/adapters/avalanche/fees.js.map +1 -0
- package/dist/adapters/avalanche/index.d.ts +19 -0
- package/dist/adapters/avalanche/index.js +8 -0
- package/dist/adapters/avalanche/index.js.map +1 -0
- package/dist/adapters/avalanche/network.d.ts +37 -0
- package/dist/adapters/avalanche/network.js +135 -0
- package/dist/adapters/avalanche/network.js.map +1 -0
- package/dist/adapters/avalanche/plugin.d.ts +21 -0
- package/dist/adapters/avalanche/plugin.js +46 -0
- package/dist/adapters/avalanche/plugin.js.map +1 -0
- package/dist/adapters/avalanche/presets.d.ts +6 -0
- package/dist/adapters/avalanche/presets.js +86 -0
- package/dist/adapters/avalanche/presets.js.map +1 -0
- package/dist/adapters/avalanche/proofs.d.ts +41 -0
- package/dist/adapters/avalanche/proofs.js +270 -0
- package/dist/adapters/avalanche/proofs.js.map +1 -0
- package/dist/adapters/avalanche/reader.d.ts +40 -0
- package/dist/adapters/avalanche/reader.js +231 -0
- package/dist/adapters/avalanche/reader.js.map +1 -0
- package/dist/adapters/avalanche/sdk.d.ts +182 -0
- package/dist/adapters/avalanche/sdk.js +21 -0
- package/dist/adapters/avalanche/sdk.js.map +1 -0
- package/dist/adapters/avalanche/types.d.ts +86 -0
- package/dist/{type/common.js → adapters/avalanche/types.js} +1 -1
- package/dist/adapters/avalanche/types.js.map +1 -0
- package/dist/adapters/evm/builder.d.ts +11 -0
- package/dist/adapters/evm/builder.js +326 -0
- package/dist/adapters/evm/builder.js.map +1 -0
- package/dist/adapters/evm/chains.d.ts +6 -0
- package/dist/adapters/evm/chains.js +203 -0
- package/dist/adapters/evm/chains.js.map +1 -0
- package/dist/adapters/evm/client.d.ts +84 -0
- package/dist/adapters/evm/client.js +335 -0
- package/dist/adapters/evm/client.js.map +1 -0
- package/dist/adapters/evm/decode.d.ts +35 -0
- package/dist/adapters/evm/decode.js +170 -0
- package/dist/adapters/evm/decode.js.map +1 -0
- package/dist/adapters/evm/driver.d.ts +8 -0
- package/dist/adapters/evm/driver.js +61 -0
- package/dist/adapters/evm/driver.js.map +1 -0
- package/dist/adapters/evm/errors.d.ts +20 -0
- package/dist/adapters/evm/errors.js +110 -0
- package/dist/adapters/evm/errors.js.map +1 -0
- package/dist/adapters/evm/ethers-client.d.ts +43 -0
- package/dist/adapters/evm/ethers-client.js +135 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -0
- package/dist/adapters/evm/fees.d.ts +79 -0
- package/dist/adapters/evm/fees.js +234 -0
- package/dist/adapters/evm/fees.js.map +1 -0
- package/dist/adapters/evm/index.d.ts +20 -0
- package/dist/adapters/evm/index.js +11 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/adapters/evm/network.d.ts +60 -0
- package/dist/adapters/evm/network.js +131 -0
- package/dist/adapters/evm/network.js.map +1 -0
- package/dist/adapters/evm/plugin.d.ts +36 -0
- package/dist/adapters/evm/plugin.js +102 -0
- package/dist/adapters/evm/plugin.js.map +1 -0
- package/dist/adapters/evm/presets.d.ts +2 -0
- package/dist/adapters/evm/presets.js +105 -0
- package/dist/adapters/evm/presets.js.map +1 -0
- package/dist/adapters/evm/proofs.d.ts +19 -0
- package/dist/adapters/evm/proofs.js +358 -0
- package/dist/adapters/evm/proofs.js.map +1 -0
- package/dist/adapters/evm/rawtx.d.ts +25 -0
- package/dist/adapters/evm/rawtx.js +176 -0
- package/dist/adapters/evm/rawtx.js.map +1 -0
- package/dist/adapters/evm/reader.d.ts +65 -0
- package/dist/adapters/evm/reader.js +292 -0
- package/dist/adapters/evm/reader.js.map +1 -0
- package/dist/adapters/evm/rpc.d.ts +39 -0
- package/dist/adapters/evm/rpc.js +152 -0
- package/dist/adapters/evm/rpc.js.map +1 -0
- package/dist/adapters/evm/tokens.d.ts +7 -0
- package/dist/adapters/evm/tokens.js +23 -0
- package/dist/adapters/evm/tokens.js.map +1 -0
- package/dist/adapters/evm/types.d.ts +255 -0
- package/dist/{type/account.js → adapters/evm/types.js} +1 -1
- package/dist/adapters/evm/types.js.map +1 -0
- package/dist/adapters/evm/web3-client.d.ts +23 -0
- package/dist/adapters/evm/web3-client.js +159 -0
- package/dist/adapters/evm/web3-client.js.map +1 -0
- package/dist/adapters/solana/builder.d.ts +18 -0
- package/dist/adapters/solana/builder.js +545 -0
- package/dist/adapters/solana/builder.js.map +1 -0
- package/dist/adapters/solana/chains.d.ts +13 -0
- package/dist/adapters/solana/chains.js +37 -0
- package/dist/adapters/solana/chains.js.map +1 -0
- package/dist/adapters/solana/decode.d.ts +111 -0
- package/dist/adapters/solana/decode.js +595 -0
- package/dist/adapters/solana/decode.js.map +1 -0
- package/dist/adapters/solana/driver.d.ts +15 -0
- package/dist/adapters/solana/driver.js +72 -0
- package/dist/adapters/solana/driver.js.map +1 -0
- package/dist/adapters/solana/errors.d.ts +36 -0
- package/dist/adapters/solana/errors.js +154 -0
- package/dist/adapters/solana/errors.js.map +1 -0
- package/dist/adapters/solana/fees.d.ts +68 -0
- package/dist/adapters/solana/fees.js +205 -0
- package/dist/adapters/solana/fees.js.map +1 -0
- package/dist/adapters/solana/heights.d.ts +47 -0
- package/dist/adapters/solana/heights.js +185 -0
- package/dist/adapters/solana/heights.js.map +1 -0
- package/dist/adapters/solana/history.d.ts +10 -0
- package/dist/adapters/solana/history.js +71 -0
- package/dist/adapters/solana/history.js.map +1 -0
- package/dist/adapters/solana/index.d.ts +16 -0
- package/dist/adapters/solana/index.js +9 -0
- package/dist/adapters/solana/index.js.map +1 -0
- package/dist/adapters/solana/keys.d.ts +13 -0
- package/dist/adapters/solana/keys.js +69 -0
- package/dist/adapters/solana/keys.js.map +1 -0
- package/dist/adapters/solana/network.d.ts +24 -0
- package/dist/adapters/solana/network.js +95 -0
- package/dist/adapters/solana/network.js.map +1 -0
- package/dist/adapters/solana/plugin.d.ts +18 -0
- package/dist/adapters/solana/plugin.js +41 -0
- package/dist/adapters/solana/plugin.js.map +1 -0
- package/dist/adapters/solana/presets.d.ts +2 -0
- package/dist/adapters/solana/presets.js +77 -0
- package/dist/adapters/solana/presets.js.map +1 -0
- package/dist/adapters/solana/programs.d.ts +44 -0
- package/dist/adapters/solana/programs.js +159 -0
- package/dist/adapters/solana/programs.js.map +1 -0
- package/dist/adapters/solana/proofs.d.ts +56 -0
- package/dist/adapters/solana/proofs.js +540 -0
- package/dist/adapters/solana/proofs.js.map +1 -0
- package/dist/adapters/solana/reader.d.ts +82 -0
- package/dist/adapters/solana/reader.js +326 -0
- package/dist/adapters/solana/reader.js.map +1 -0
- package/dist/adapters/solana/rpc.d.ts +102 -0
- package/dist/adapters/solana/rpc.js +301 -0
- package/dist/adapters/solana/rpc.js.map +1 -0
- package/dist/adapters/solana/tokens.d.ts +7 -0
- package/dist/adapters/solana/tokens.js +19 -0
- package/dist/adapters/solana/tokens.js.map +1 -0
- package/dist/adapters/solana/types.d.ts +121 -0
- package/dist/{type/lib-types.js → adapters/solana/types.js} +1 -1
- package/dist/adapters/solana/types.js.map +1 -0
- package/dist/adapters/solana/web3.d.ts +5 -0
- package/dist/adapters/solana/web3.js +83 -0
- package/dist/adapters/solana/web3.js.map +1 -0
- package/dist/adapters/solana/wire.d.ts +62 -0
- package/dist/adapters/solana/wire.js +168 -0
- package/dist/adapters/solana/wire.js.map +1 -0
- package/dist/adapters/ton/address.d.ts +43 -0
- package/dist/adapters/ton/address.js +168 -0
- package/dist/adapters/ton/address.js.map +1 -0
- package/dist/adapters/ton/api.d.ts +344 -0
- package/dist/adapters/ton/api.js +942 -0
- package/dist/adapters/ton/api.js.map +1 -0
- package/dist/adapters/ton/builder.d.ts +18 -0
- package/dist/adapters/ton/builder.js +701 -0
- package/dist/adapters/ton/builder.js.map +1 -0
- package/dist/adapters/ton/chains.d.ts +16 -0
- package/dist/adapters/ton/chains.js +39 -0
- package/dist/adapters/ton/chains.js.map +1 -0
- package/dist/adapters/ton/decode.d.ts +43 -0
- package/dist/adapters/ton/decode.js +219 -0
- package/dist/adapters/ton/decode.js.map +1 -0
- package/dist/adapters/ton/driver.d.ts +10 -0
- package/dist/adapters/ton/driver.js +117 -0
- package/dist/adapters/ton/driver.js.map +1 -0
- package/dist/adapters/ton/errors.d.ts +36 -0
- package/dist/adapters/ton/errors.js +89 -0
- package/dist/adapters/ton/errors.js.map +1 -0
- package/dist/adapters/ton/fees.d.ts +28 -0
- package/dist/adapters/ton/fees.js +121 -0
- package/dist/adapters/ton/fees.js.map +1 -0
- package/dist/adapters/ton/index.d.ts +16 -0
- package/dist/adapters/ton/index.js +9 -0
- package/dist/adapters/ton/index.js.map +1 -0
- package/dist/adapters/ton/messages.d.ts +157 -0
- package/dist/adapters/ton/messages.js +397 -0
- package/dist/adapters/ton/messages.js.map +1 -0
- package/dist/adapters/ton/native-client.d.ts +10 -0
- package/dist/adapters/ton/native-client.js +47 -0
- package/dist/adapters/ton/native-client.js.map +1 -0
- package/dist/adapters/ton/network.d.ts +58 -0
- package/dist/adapters/ton/network.js +207 -0
- package/dist/adapters/ton/network.js.map +1 -0
- package/dist/adapters/ton/plugin.d.ts +24 -0
- package/dist/adapters/ton/plugin.js +57 -0
- package/dist/adapters/ton/plugin.js.map +1 -0
- package/dist/adapters/ton/presets.d.ts +6 -0
- package/dist/adapters/ton/presets.js +94 -0
- package/dist/adapters/ton/presets.js.map +1 -0
- package/dist/adapters/ton/proofs.d.ts +66 -0
- package/dist/adapters/ton/proofs.js +813 -0
- package/dist/adapters/ton/proofs.js.map +1 -0
- package/dist/adapters/ton/reader.d.ts +194 -0
- package/dist/adapters/ton/reader.js +781 -0
- package/dist/adapters/ton/reader.js.map +1 -0
- package/dist/adapters/ton/tokens.d.ts +10 -0
- package/dist/adapters/ton/tokens.js +27 -0
- package/dist/adapters/ton/tokens.js.map +1 -0
- package/dist/adapters/ton/trace.d.ts +48 -0
- package/dist/adapters/ton/trace.js +277 -0
- package/dist/adapters/ton/trace.js.map +1 -0
- package/dist/adapters/ton/types.d.ts +105 -0
- package/dist/adapters/ton/types.js +3 -0
- package/dist/adapters/ton/types.js.map +1 -0
- package/dist/adapters/ton/wallets.d.ts +86 -0
- package/dist/adapters/ton/wallets.js +373 -0
- package/dist/adapters/ton/wallets.js.map +1 -0
- package/dist/adapters/tron/abi.d.ts +39 -0
- package/dist/adapters/tron/abi.js +110 -0
- package/dist/adapters/tron/abi.js.map +1 -0
- package/dist/adapters/tron/address.d.ts +20 -0
- package/dist/adapters/tron/address.js +110 -0
- package/dist/adapters/tron/address.js.map +1 -0
- package/dist/adapters/tron/builder.d.ts +12 -0
- package/dist/adapters/tron/builder.js +553 -0
- package/dist/adapters/tron/builder.js.map +1 -0
- package/dist/adapters/tron/chains.d.ts +12 -0
- package/dist/adapters/tron/chains.js +35 -0
- package/dist/adapters/tron/chains.js.map +1 -0
- package/dist/adapters/tron/codec.d.ts +10 -0
- package/dist/adapters/tron/codec.js +322 -0
- package/dist/adapters/tron/codec.js.map +1 -0
- package/dist/adapters/tron/decode.d.ts +50 -0
- package/dist/adapters/tron/decode.js +280 -0
- package/dist/adapters/tron/decode.js.map +1 -0
- package/dist/adapters/tron/driver.d.ts +12 -0
- package/dist/adapters/tron/driver.js +106 -0
- package/dist/adapters/tron/driver.js.map +1 -0
- package/dist/adapters/tron/errors.d.ts +74 -0
- package/dist/adapters/tron/errors.js +261 -0
- package/dist/adapters/tron/errors.js.map +1 -0
- package/dist/adapters/tron/fees.d.ts +49 -0
- package/dist/adapters/tron/fees.js +166 -0
- package/dist/adapters/tron/fees.js.map +1 -0
- package/dist/adapters/tron/http.d.ts +173 -0
- package/dist/adapters/tron/http.js +729 -0
- package/dist/adapters/tron/http.js.map +1 -0
- package/dist/adapters/tron/index.d.ts +16 -0
- package/dist/adapters/tron/index.js +15 -0
- package/dist/adapters/tron/index.js.map +1 -0
- package/dist/adapters/tron/network.d.ts +44 -0
- package/dist/adapters/tron/network.js +163 -0
- package/dist/adapters/tron/network.js.map +1 -0
- package/dist/adapters/tron/plugin.d.ts +17 -0
- package/dist/adapters/tron/plugin.js +39 -0
- package/dist/adapters/tron/plugin.js.map +1 -0
- package/dist/adapters/tron/presets.d.ts +5 -0
- package/dist/adapters/tron/presets.js +68 -0
- package/dist/adapters/tron/presets.js.map +1 -0
- package/dist/adapters/tron/proofs.d.ts +80 -0
- package/dist/adapters/tron/proofs.js +370 -0
- package/dist/adapters/tron/proofs.js.map +1 -0
- package/dist/adapters/tron/protobuf.d.ts +36 -0
- package/dist/adapters/tron/protobuf.js +90 -0
- package/dist/adapters/tron/protobuf.js.map +1 -0
- package/dist/adapters/tron/reader.d.ts +47 -0
- package/dist/adapters/tron/reader.js +203 -0
- package/dist/adapters/tron/reader.js.map +1 -0
- package/dist/adapters/tron/tokens.d.ts +7 -0
- package/dist/adapters/tron/tokens.js +14 -0
- package/dist/adapters/tron/tokens.js.map +1 -0
- package/dist/adapters/tron/types.d.ts +166 -0
- package/dist/adapters/tron/types.js +3 -0
- package/dist/adapters/tron/types.js.map +1 -0
- package/dist/adapters/utxo/address.d.ts +51 -0
- package/dist/adapters/utxo/address.js +341 -0
- package/dist/adapters/utxo/address.js.map +1 -0
- package/dist/adapters/utxo/builder.d.ts +35 -0
- package/dist/adapters/utxo/builder.js +380 -0
- package/dist/adapters/utxo/builder.js.map +1 -0
- package/dist/adapters/utxo/chains.d.ts +17 -0
- package/dist/adapters/utxo/chains.js +99 -0
- package/dist/adapters/utxo/chains.js.map +1 -0
- package/dist/adapters/utxo/codec.d.ts +120 -0
- package/dist/adapters/utxo/codec.js +408 -0
- package/dist/adapters/utxo/codec.js.map +1 -0
- package/dist/adapters/utxo/coinselect.d.ts +48 -0
- package/dist/adapters/utxo/coinselect.js +131 -0
- package/dist/adapters/utxo/coinselect.js.map +1 -0
- package/dist/adapters/utxo/context.d.ts +57 -0
- package/dist/adapters/utxo/context.js +118 -0
- package/dist/adapters/utxo/context.js.map +1 -0
- package/dist/adapters/utxo/decode.d.ts +14 -0
- package/dist/adapters/utxo/decode.js +85 -0
- package/dist/adapters/utxo/decode.js.map +1 -0
- package/dist/adapters/utxo/driver.d.ts +16 -0
- package/dist/adapters/utxo/driver.js +74 -0
- package/dist/adapters/utxo/driver.js.map +1 -0
- package/dist/adapters/utxo/ecc.d.ts +9 -0
- package/dist/adapters/utxo/ecc.js +26 -0
- package/dist/adapters/utxo/ecc.js.map +1 -0
- package/dist/adapters/utxo/errors.d.ts +52 -0
- package/dist/adapters/utxo/errors.js +191 -0
- package/dist/adapters/utxo/errors.js.map +1 -0
- package/dist/adapters/utxo/esplora.d.ts +79 -0
- package/dist/adapters/utxo/esplora.js +451 -0
- package/dist/adapters/utxo/esplora.js.map +1 -0
- package/dist/adapters/utxo/fees.d.ts +41 -0
- package/dist/adapters/utxo/fees.js +125 -0
- package/dist/adapters/utxo/fees.js.map +1 -0
- package/dist/adapters/utxo/index.d.ts +17 -0
- package/dist/adapters/utxo/index.js +8 -0
- package/dist/adapters/utxo/index.js.map +1 -0
- package/dist/adapters/utxo/network.d.ts +50 -0
- package/dist/adapters/utxo/network.js +165 -0
- package/dist/adapters/utxo/network.js.map +1 -0
- package/dist/adapters/utxo/plugin.d.ts +17 -0
- package/dist/adapters/utxo/plugin.js +41 -0
- package/dist/adapters/utxo/plugin.js.map +1 -0
- package/dist/adapters/utxo/presets.d.ts +12 -0
- package/dist/adapters/utxo/presets.js +47 -0
- package/dist/adapters/utxo/presets.js.map +1 -0
- package/dist/adapters/utxo/preview.d.ts +3 -0
- package/dist/adapters/utxo/preview.js +65 -0
- package/dist/adapters/utxo/preview.js.map +1 -0
- package/dist/adapters/utxo/proofs.d.ts +57 -0
- package/dist/adapters/utxo/proofs.js +331 -0
- package/dist/adapters/utxo/proofs.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +59 -0
- package/dist/adapters/utxo/rawtx.js +234 -0
- package/dist/adapters/utxo/rawtx.js.map +1 -0
- package/dist/adapters/utxo/reader.d.ts +36 -0
- package/dist/adapters/utxo/reader.js +265 -0
- package/dist/adapters/utxo/reader.js.map +1 -0
- package/dist/adapters/utxo/sdk.d.ts +18 -0
- package/dist/adapters/utxo/sdk.js +17 -0
- package/dist/adapters/utxo/sdk.js.map +1 -0
- package/dist/adapters/utxo/signed-psbt.d.ts +36 -0
- package/dist/adapters/utxo/signed-psbt.js +428 -0
- package/dist/adapters/utxo/signed-psbt.js.map +1 -0
- package/dist/adapters/utxo/spend.d.ts +59 -0
- package/dist/adapters/utxo/spend.js +230 -0
- package/dist/adapters/utxo/spend.js.map +1 -0
- package/dist/adapters/utxo/types.d.ts +167 -0
- package/dist/adapters/utxo/types.js +3 -0
- package/dist/adapters/utxo/types.js.map +1 -0
- package/dist/core/assets/service.d.ts +18 -0
- package/dist/core/assets/service.js +69 -0
- package/dist/core/assets/service.js.map +1 -0
- package/dist/core/blockchain/default-ref.d.ts +4 -0
- package/dist/core/blockchain/default-ref.js +16 -0
- package/dist/core/blockchain/default-ref.js.map +1 -0
- package/dist/core/blockchain/handle.d.ts +200 -0
- package/dist/core/blockchain/handle.js +579 -0
- package/dist/core/blockchain/handle.js.map +1 -0
- package/dist/core/blockchain/internal.d.ts +19 -0
- package/dist/core/blockchain/internal.js +16 -0
- package/dist/core/blockchain/internal.js.map +1 -0
- package/dist/core/blockchain/mapping.d.ts +22 -0
- package/dist/core/blockchain/mapping.js +136 -0
- package/dist/core/blockchain/mapping.js.map +1 -0
- package/dist/core/config/env.d.ts +8 -0
- package/dist/core/config/env.js +60 -0
- package/dist/core/config/env.js.map +1 -0
- package/dist/core/config/merge.d.ts +26 -0
- package/dist/core/config/merge.js +144 -0
- package/dist/core/config/merge.js.map +1 -0
- package/dist/core/config/resolve.d.ts +12 -0
- package/dist/core/config/resolve.js +251 -0
- package/dist/core/config/resolve.js.map +1 -0
- package/dist/core/config/types.d.ts +165 -0
- package/dist/core/config/types.js +3 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/container/builtins.d.ts +4 -0
- package/dist/core/container/builtins.js +13 -0
- package/dist/core/container/builtins.js.map +1 -0
- package/dist/core/container/container.d.ts +69 -0
- package/dist/core/container/container.js +466 -0
- package/dist/core/container/container.js.map +1 -0
- package/dist/core/container/default.d.ts +15 -0
- package/dist/core/container/default.js +70 -0
- package/dist/core/container/default.js.map +1 -0
- package/dist/core/container/internals.d.ts +54 -0
- package/dist/core/container/internals.js +21 -0
- package/dist/core/container/internals.js.map +1 -0
- package/dist/core/container/pool.d.ts +27 -0
- package/dist/core/container/pool.js +77 -0
- package/dist/core/container/pool.js.map +1 -0
- package/dist/core/driver/types.d.ts +346 -0
- package/dist/core/driver/types.js +3 -0
- package/dist/core/driver/types.js.map +1 -0
- package/dist/core/errors/codes.d.ts +153 -0
- package/dist/core/errors/codes.js +49 -0
- package/dist/core/errors/codes.js.map +1 -0
- package/dist/core/errors/error.d.ts +66 -0
- package/dist/core/errors/error.js +129 -0
- package/dist/core/errors/error.js.map +1 -0
- package/dist/core/events/bus.d.ts +12 -0
- package/dist/core/events/bus.js +46 -0
- package/dist/core/events/bus.js.map +1 -0
- package/dist/core/events/logger.d.ts +13 -0
- package/dist/core/events/logger.js +42 -0
- package/dist/core/events/logger.js.map +1 -0
- package/dist/core/events/types.d.ts +131 -0
- package/dist/core/events/types.js +3 -0
- package/dist/core/events/types.js.map +1 -0
- package/dist/core/lifecycle/engine-rules.d.ts +107 -0
- package/dist/core/lifecycle/engine-rules.js +257 -0
- package/dist/core/lifecycle/engine-rules.js.map +1 -0
- package/dist/core/lifecycle/engine.d.ts +500 -0
- package/dist/core/lifecycle/engine.js +1732 -0
- package/dist/core/lifecycle/engine.js.map +1 -0
- package/dist/core/lifecycle/evaluate.d.ts +19 -0
- package/dist/core/lifecycle/evaluate.js +72 -0
- package/dist/core/lifecycle/evaluate.js.map +1 -0
- package/dist/core/lifecycle/intent.d.ts +11 -0
- package/dist/core/lifecycle/intent.js +88 -0
- package/dist/core/lifecycle/intent.js.map +1 -0
- package/dist/core/lifecycle/monitor.d.ts +138 -0
- package/dist/core/lifecycle/monitor.js +606 -0
- package/dist/core/lifecycle/monitor.js.map +1 -0
- package/dist/core/lifecycle/observations.d.ts +17 -0
- package/dist/core/lifecycle/observations.js +59 -0
- package/dist/core/lifecycle/observations.js.map +1 -0
- package/dist/core/lifecycle/reconcile.d.ts +58 -0
- package/dist/core/lifecycle/reconcile.js +112 -0
- package/dist/core/lifecycle/reconcile.js.map +1 -0
- package/dist/core/lifecycle/views.d.ts +49 -0
- package/dist/core/lifecycle/views.js +57 -0
- package/dist/core/lifecycle/views.js.map +1 -0
- package/dist/core/lifecycle/workers.d.ts +82 -0
- package/dist/core/lifecycle/workers.js +329 -0
- package/dist/core/lifecycle/workers.js.map +1 -0
- package/dist/core/model/address.d.ts +32 -0
- package/dist/core/model/address.js +43 -0
- package/dist/core/model/address.js.map +1 -0
- package/dist/core/model/amount.d.ts +25 -0
- package/dist/core/model/amount.js +102 -0
- package/dist/core/model/amount.js.map +1 -0
- package/dist/core/model/asset.d.ts +28 -0
- package/dist/core/model/asset.js +47 -0
- package/dist/core/model/asset.js.map +1 -0
- package/dist/core/model/capability.d.ts +3 -0
- package/dist/core/model/capability.js +18 -0
- package/dist/core/model/capability.js.map +1 -0
- package/dist/core/model/chain.d.ts +63 -0
- package/dist/core/model/chain.js +8 -0
- package/dist/core/model/chain.js.map +1 -0
- package/dist/core/model/fee.d.ts +36 -0
- package/dist/core/model/fee.js +17 -0
- package/dist/core/model/fee.js.map +1 -0
- package/dist/core/model/ids.d.ts +37 -0
- package/dist/core/model/ids.js +13 -0
- package/dist/core/model/ids.js.map +1 -0
- package/dist/core/model/intent.d.ts +63 -0
- package/dist/core/model/intent.js +81 -0
- package/dist/core/model/intent.js.map +1 -0
- package/dist/core/model/ordering.d.ts +20 -0
- package/dist/core/model/ordering.js +29 -0
- package/dist/core/model/ordering.js.map +1 -0
- package/dist/core/model/transaction.d.ts +116 -0
- package/dist/core/model/transaction.js +3 -0
- package/dist/core/model/transaction.js.map +1 -0
- package/dist/core/observe/scanner.d.ts +135 -0
- package/dist/core/observe/scanner.js +355 -0
- package/dist/core/observe/scanner.js.map +1 -0
- package/dist/core/ordering/reservations.d.ts +16 -0
- package/dist/core/ordering/reservations.js +53 -0
- package/dist/core/ordering/reservations.js.map +1 -0
- package/dist/core/ordering/sequence.d.ts +61 -0
- package/dist/core/ordering/sequence.js +155 -0
- package/dist/core/ordering/sequence.js.map +1 -0
- package/dist/core/registry/adapters.d.ts +10 -0
- package/dist/core/registry/adapters.js +56 -0
- package/dist/core/registry/adapters.js.map +1 -0
- package/dist/core/registry/assets.d.ts +18 -0
- package/dist/core/registry/assets.js +90 -0
- package/dist/core/registry/assets.js.map +1 -0
- package/dist/core/registry/chains.d.ts +10 -0
- package/dist/core/registry/chains.js +80 -0
- package/dist/core/registry/chains.js.map +1 -0
- package/dist/core/registry/plugin.d.ts +41 -0
- package/dist/core/registry/plugin.js +109 -0
- package/dist/core/registry/plugin.js.map +1 -0
- package/dist/core/registry/providers.d.ts +31 -0
- package/dist/core/registry/providers.js +43 -0
- package/dist/core/registry/providers.js.map +1 -0
- package/dist/core/registry/schemes.d.ts +30 -0
- package/dist/core/registry/schemes.js +84 -0
- package/dist/core/registry/schemes.js.map +1 -0
- package/dist/core/secret/fragments.d.ts +33 -0
- package/dist/core/secret/fragments.js +110 -0
- package/dist/core/secret/fragments.js.map +1 -0
- package/dist/core/secret/redact.d.ts +10 -0
- package/dist/core/secret/redact.js +110 -0
- package/dist/core/secret/redact.js.map +1 -0
- package/dist/core/secret/secret.d.ts +14 -0
- package/dist/core/secret/secret.js +42 -0
- package/dist/core/secret/secret.js.map +1 -0
- package/dist/core/signing/callback.d.ts +10 -0
- package/dist/core/signing/callback.js +22 -0
- package/dist/core/signing/callback.js.map +1 -0
- package/dist/core/signing/guard.d.ts +18 -0
- package/dist/core/signing/guard.js +72 -0
- package/dist/core/signing/guard.js.map +1 -0
- package/dist/core/signing/hd.d.ts +36 -0
- package/dist/core/signing/hd.js +167 -0
- package/dist/core/signing/hd.js.map +1 -0
- package/dist/core/signing/local.d.ts +48 -0
- package/dist/core/signing/local.js +190 -0
- package/dist/core/signing/local.js.map +1 -0
- package/dist/core/signing/orchestrator.d.ts +40 -0
- package/dist/core/signing/orchestrator.js +300 -0
- package/dist/core/signing/orchestrator.js.map +1 -0
- package/dist/core/signing/types.d.ts +64 -0
- package/dist/core/signing/types.js +3 -0
- package/dist/core/signing/types.js.map +1 -0
- package/dist/core/signing/wallet.d.ts +48 -0
- package/dist/core/signing/wallet.js +153 -0
- package/dist/core/signing/wallet.js.map +1 -0
- package/dist/core/store/clone.d.ts +25 -0
- package/dist/core/store/clone.js +71 -0
- package/dist/core/store/clone.js.map +1 -0
- package/dist/core/store/memory.d.ts +38 -0
- package/dist/core/store/memory.js +325 -0
- package/dist/core/store/memory.js.map +1 -0
- package/dist/core/store/types.d.ts +246 -0
- package/dist/core/store/types.js +117 -0
- package/dist/core/store/types.js.map +1 -0
- package/dist/core/transport/backoff.d.ts +8 -0
- package/dist/core/transport/backoff.js +27 -0
- package/dist/core/transport/backoff.js.map +1 -0
- package/dist/core/transport/circuit.d.ts +25 -0
- package/dist/core/transport/circuit.js +61 -0
- package/dist/core/transport/circuit.js.map +1 -0
- package/dist/core/transport/http-transport.d.ts +30 -0
- package/dist/core/transport/http-transport.js +1695 -0
- package/dist/core/transport/http-transport.js.map +1 -0
- package/dist/core/transport/rate-limit.d.ts +27 -0
- package/dist/core/transport/rate-limit.js +78 -0
- package/dist/core/transport/rate-limit.js.map +1 -0
- package/dist/core/transport/stale-view.d.ts +11 -0
- package/dist/core/transport/stale-view.js +17 -0
- package/dist/core/transport/stale-view.js.map +1 -0
- package/dist/core/transport/types.d.ts +144 -0
- package/dist/core/transport/types.js +6 -0
- package/dist/core/transport/types.js.map +1 -0
- package/dist/core/util/bytes.d.ts +9 -0
- package/dist/core/util/bytes.js +40 -0
- package/dist/core/util/bytes.js.map +1 -0
- package/dist/core/util/clock.d.ts +6 -0
- package/dist/core/util/clock.js +26 -0
- package/dist/core/util/clock.js.map +1 -0
- package/dist/core/util/freeze.d.ts +8 -0
- package/dist/core/util/freeze.js +31 -0
- package/dist/core/util/freeze.js.map +1 -0
- package/dist/core/util/json.d.ts +29 -0
- package/dist/core/util/json.js +165 -0
- package/dist/core/util/json.js.map +1 -0
- package/dist/core/util/names.d.ts +21 -0
- package/dist/core/util/names.js +46 -0
- package/dist/core/util/names.js.map +1 -0
- package/dist/index.d.ts +64 -14
- package/dist/index.js +105 -49
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +21 -0
- package/dist/native.js +44 -0
- package/dist/native.js.map +1 -0
- package/dist/testing/contracts/api.d.ts +12 -0
- package/dist/testing/contracts/api.js +58 -0
- package/dist/testing/contracts/api.js.map +1 -0
- package/dist/testing/contracts/cursors.d.ts +6 -0
- package/dist/testing/contracts/cursors.js +43 -0
- package/dist/testing/contracts/cursors.js.map +1 -0
- package/dist/testing/contracts/locks.d.ts +10 -0
- package/dist/testing/contracts/locks.js +63 -0
- package/dist/testing/contracts/locks.js.map +1 -0
- package/dist/testing/contracts/operations.d.ts +21 -0
- package/dist/testing/contracts/operations.js +718 -0
- package/dist/testing/contracts/operations.js.map +1 -0
- package/dist/testing/contracts/sequences.d.ts +6 -0
- package/dist/testing/contracts/sequences.js +68 -0
- package/dist/testing/contracts/sequences.js.map +1 -0
- package/dist/testing/env.d.ts +63 -0
- package/dist/testing/env.js +105 -0
- package/dist/testing/env.js.map +1 -0
- package/dist/testing/fake-chain.d.ts +118 -0
- package/dist/testing/fake-chain.js +536 -0
- package/dist/testing/fake-chain.js.map +1 -0
- package/dist/testing/fake-clock.d.ts +15 -0
- package/dist/testing/fake-clock.js +86 -0
- package/dist/testing/fake-clock.js.map +1 -0
- package/dist/testing/fake-driver.d.ts +15 -0
- package/dist/testing/fake-driver.js +458 -0
- package/dist/testing/fake-driver.js.map +1 -0
- package/dist/testing/fake-fetch.d.ts +32 -0
- package/dist/testing/fake-fetch.js +81 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-plugin.d.ts +30 -0
- package/dist/testing/fake-plugin.js +66 -0
- package/dist/testing/fake-plugin.js.map +1 -0
- package/dist/testing/faulty-store.d.ts +36 -0
- package/dist/testing/faulty-store.js +66 -0
- package/dist/testing/faulty-store.js.map +1 -0
- package/dist/testing/generation.d.ts +60 -0
- package/dist/testing/generation.js +252 -0
- package/dist/testing/generation.js.map +1 -0
- package/dist/testing/index.d.ts +28 -0
- package/dist/testing/index.js +51 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +188 -44
- package/dist/libs/eth/account.d.ts +0 -9
- package/dist/libs/eth/account.js +0 -58
- package/dist/libs/eth/account.js.map +0 -1
- package/dist/libs/eth/contract.d.ts +0 -2
- package/dist/libs/eth/contract.js +0 -7
- package/dist/libs/eth/contract.js.map +0 -1
- package/dist/libs/eth/index.d.ts +0 -20
- package/dist/libs/eth/index.js +0 -62
- package/dist/libs/eth/index.js.map +0 -1
- package/dist/libs/eth/transact.d.ts +0 -2
- package/dist/libs/eth/transact.js +0 -7
- package/dist/libs/eth/transact.js.map +0 -1
- package/dist/libs/index.d.ts +0 -1
- package/dist/libs/index.js +0 -18
- package/dist/libs/index.js.map +0 -1
- package/dist/tool/common.d.ts +0 -28
- package/dist/tool/common.js +0 -33
- package/dist/tool/common.js.map +0 -1
- package/dist/tool/eth-tools.d.ts +0 -3
- package/dist/tool/eth-tools.js +0 -33
- package/dist/tool/eth-tools.js.map +0 -1
- package/dist/tool/index.d.ts +0 -4
- package/dist/tool/index.js +0 -21
- package/dist/tool/index.js.map +0 -1
- package/dist/tool/logging.d.ts +0 -3
- package/dist/tool/logging.js +0 -11
- package/dist/tool/logging.js.map +0 -1
- package/dist/tool/options.d.ts +0 -4
- package/dist/tool/options.js +0 -28
- package/dist/tool/options.js.map +0 -1
- package/dist/type/account.d.ts +0 -9
- package/dist/type/account.js.map +0 -1
- package/dist/type/common.d.ts +0 -18
- package/dist/type/common.js.map +0 -1
- package/dist/type/index.d.ts +0 -3
- package/dist/type/index.js +0 -20
- package/dist/type/index.js.map +0 -1
- package/dist/type/lib-types.d.ts +0 -7
- package/dist/type/lib-types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proofs.js","sourceRoot":"","sources":["../../../src/adapters/evm/proofs.ts"],"names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AI;oBAAE,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC9E,iFAAiF;gBACjF,oCAAoC;gBACpC,OAAO,IAAA,0BAAiB,EAAC,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Proofs and block scanning. Every proof read is a quorum read under `PROOF`, comparing\n * only consensus facts (`rpc.ts`). No proof lets one endpoint choose the final height: a\n * proof attests the fact it needs at that fact's own\n * height, so honest endpoints disagree only while it is final on one and not yet on another,\n * which decides nothing. The block source serves dense heights with native transfers and\n * ERC-20 `Transfer` logs, as the chain reports them. Every error thrown here is a\n * `PROVIDER_*` code, retryable by the code table: look again later.\n */\nimport { keccak_256 } from '@noble/hashes/sha3';\nimport { hexToBytes } from '@noble/hashes/utils';\nimport type { BlockSource, ProofSource } from '../../core/driver/types';\nimport { ProviderError, isCryptoAioError } from '../../core/errors/error';\nimport type { OrderingData } from '../../core/model/ordering';\nimport { quantity } from './client';\nimport { decodeTransaction, tokenTransferLanded } from './decode';\nimport {\n MONITOR,\n PROOF,\n finalBlockAt,\n provenFinal,\n toDriverBlock,\n type EvmContext,\n} from './reader';\nimport { blockTransactionsKey } from './rpc';\nimport type { EvmClient, EvmFullBlock, EvmLog, EvmReceipt, EvmTx } from './types';\n\n/**\n * A quorum key under which every endpoint whose nonce is past `nonce` agrees. A\n * malformed answer throws, which the transport counts as a disagreement.\n */\nconst nonceAbove =\n (nonce: bigint) =>\n (result: unknown): boolean =>\n quantity(result, 'nonce') > nonce;\n\n/**\n * Node texts for state it does not hold: pruned, beyond its recent-state window, or\n * not served at a tag (geth, op-geth, Nitro, BSC, Erigon, Reth, Besu wordings).\n */\nconst STATE_UNAVAILABLE =\n /missing trie node|historical state .* not available|header not found|state (is )?not available|pruned/i;\n\n/**\n * The boundary of every proof. Only a definitive negative answer may\n * say \"no\", and a JSON-RPC error answer is none: state the node does not hold, an index it\n * is still building (geth's \"transaction indexing is in progress\"), or any other error,\n * ambiguous or not. Every `RPC_ERROR` becomes a retryable `PROVIDER_UNAVAILABLE` (look again\n * later, or elsewhere) that carries it as its cause, so no caller takes it for an answer and\n * the monitor keeps watching. Every other error passes unchanged: `PROVIDER_MISCONFIGURED`\n * stays final, and aborts and foreign errors stay what they are.\n */\nasync function undecided<T>(proof: () => Promise<T>): Promise<T> {\n try {\n return await proof();\n } catch (error) {\n if (!isCryptoAioError(error, 'RPC_ERROR')) throw error;\n const message = String(error.details?.rpcMessage ?? error.message);\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n STATE_UNAVAILABLE.test(message)\n ? 'finalized state not available'\n : 'the endpoints gave no answer',\n { cause: error },\n );\n }\n}\n\n/** A retryable \"decide nothing\": look again later, or elsewhere. */\nconst undecidable = (reason: string) => new ProviderError('PROVIDER_UNAVAILABLE', reason);\n\n/**\n * At most this many nonce reads look for the height that consumed a nonce. The gallop\n * and the bisection take about two reads per doubling of the distance back: at worst 60\n * reads below a final height of 2^30, and 64 below 2^32, so this reaches every consumption\n * on any chain served today.\n */\nconst MAX_SEARCH_READS = 64;\n\n/**\n * The lowest height at or below `final` where `consumed` holds, given that it holds at\n * `final`. A gallop back (`final` less 1, 2, 4, …) finds a height where it does not, then a\n * bisection the first where it does. `consumed` never turns false again as the height\n * grows, since an account's nonce never falls. Beyond `MAX_SEARCH_READS` reads, it decides\n * nothing.\n */\nexport async function consumptionHeight(\n consumed: (height: bigint) => Promise<boolean>,\n final: bigint,\n): Promise<bigint> {\n let reads = 0;\n const read = (height: bigint): Promise<boolean> => {\n if (reads === MAX_SEARCH_READS) {\n throw undecidable('the nonce was consumed too far back to look up');\n }\n reads += 1;\n return consumed(height);\n };\n // Consumed at `high`; not at `low` (below genesis, until a read says otherwise).\n let high = final;\n let low = -1n;\n for (let step = 1n; high > 0n && low < 0n; step *= 2n) {\n const height = final > step ? final - step : 0n;\n if (await read(height)) high = height;\n else low = height;\n }\n while (high - low > 1n) {\n const middle = (low + high) / 2n;\n if (await read(middle)) high = middle;\n else low = middle;\n }\n return high;\n}\n\ntype Inclusion = Awaited<ReturnType<ProofSource['includedFinal']>>;\n\n/**\n * Whether `txHash` is final, when no endpoint serves its\n * receipt. `null` is no proof of absence: a node answers it for every transaction outside its\n * index (geth indexes the last 2,350,000 blocks by default, and pruning nodes of other\n * clients drop theirs), so \"not included\" would prove a final, executed transfer `replaced`.\n * The nonce's consumer decides instead. The quorum attests the nonce consumed at a final\n * height, a search finds the block that consumed it, and the sender's transaction at that\n * nonce there answers: another one proves ours is not included; ours is included, with the\n * verdict its receipt in that block gives. Anything else decides nothing, and so does\n * an endpoint without the historical state the search reads.\n *\n * Known gap: nothing caches the consumer per sender and nonce, so an undecided Attempt\n * repeats the search on every monitor pass. A nonce that an EIP-7702 authorization\n * consumed (no transaction from the sender) is never decided, the safe direction.\n */\nasync function nonceConsumer(\n ctx: EvmContext,\n txHash: string,\n ordering: OrderingData,\n from: string,\n): Promise<Inclusion> {\n if (ordering.kind !== 'nonce')\n throw undecidable('no nonce to look the transaction up by');\n const { client } = ctx;\n const { nonce } = ordering;\n const tags = { ...PROOF, quorumKey: nonceAbove(nonce) };\n const consumed = async (height: bigint) =>\n (await client.getTransactionCount(from, height, tags)) > nonce;\n const { height: final } = await provenFinal(ctx, PROOF);\n if (!(await consumed(final)))\n throw undecidable('the nonce is not consumed at finality');\n const height = await consumptionHeight(consumed, final);\n const block = await client.getBlockWithTransactions(height, {\n ...PROOF,\n quorumKey: blockTransactionsKey,\n });\n if (block?.number !== height) throw undecidable('the endpoints serve no final block');\n const sender = from.toLowerCase();\n const consumer = block.transactions.find(\n (tx) => tx.from.toLowerCase() === sender && tx.nonce === nonce,\n );\n // No transaction from the sender used the nonce: an EIP-7702 authorization can.\n if (!consumer) throw undecidable('no transaction in its block used the nonce');\n // Another transaction is final at our nonce: ours can never be included.\n if (consumer.hash !== txHash.toLowerCase()) return { included: false };\n const receipts = await client.getBlockReceipts(block.hash, PROOF);\n const receipt = receipts?.find((r) => r.transactionHash === consumer.hash);\n if (receipt?.blockHash !== block.hash) {\n throw undecidable('the final block has no receipts on the endpoints');\n }\n return {\n included: true,\n success: receipt.status === 1 && tokenTransferLanded(client.abi, consumer, receipt),\n blockHeight: height,\n blockHash: block.hash,\n txHash: consumer.hash,\n };\n}\n\nexport function createEvmProofs(ctx: EvmContext): ProofSource {\n const { client } = ctx;\n return {\n finalizedHead: () =>\n undecided(async () => {\n const { height, block } = await provenFinal(ctx, PROOF);\n const final = block ?? (await client.getBlock(height, PROOF));\n if (!final) {\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'the endpoints serve no finalized block',\n );\n }\n return { height: final.number, hash: final.hash, timestamp: final.timestamp };\n }),\n\n includedFinal: (ref, ordering, from) =>\n undecided(async () => {\n const receipt = await client.getReceipt(ref.id, PROOF);\n // No receipt is no proof of absence; the transaction at our nonce decides.\n if (!receipt) return nonceConsumer(ctx, ref.id, ordering, from);\n const final = await finalBlockAt(ctx, receipt.blockNumber, PROOF);\n // The transaction is in a block, just not a final one on these endpoints yet.\n // \"Not included\" would let the core prove a final transfer `replaced` (whenAbsent,\n // after the slot was proven consumed on endpoints whose finality is further along),\n // so this decides nothing.\n if (!final) {\n throw new ProviderError('PROVIDER_UNAVAILABLE', 'receipt not yet final');\n }\n // The endpoints agree on a receipt from a block that is not the final one at its\n // height: the chain reorganized between the reads, or their receipt index lags. The\n // transaction may be final elsewhere, so this decides nothing.\n if (final.hash !== receipt.blockHash) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the receipt is not in the final block at its height',\n );\n }\n let success = receipt.status === 1;\n if (success) {\n // A token transfer that logged no transfer to its recipient paid it nothing\n // (read from the ref alone, the call's arguments from its keyed calldata). The\n // core proves only its own Attempts, so this is always a verdict.\n const tx = await client.getTransaction(ref.id, PROOF);\n if (!tx) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'a receipt without its transaction',\n );\n }\n success = tokenTransferLanded(client.abi, tx, receipt);\n }\n return {\n included: true,\n success,\n blockHeight: receipt.blockNumber,\n blockHash: receipt.blockHash,\n txHash: receipt.transactionHash,\n };\n }),\n\n slotConsumed: (ordering, from, level) =>\n undecided(async () => {\n if (ordering.kind !== 'nonce') return false;\n if (level === 'latest') {\n return (\n (await client.getTransactionCount(from, 'latest', MONITOR)) > ordering.nonce\n );\n }\n // The nonce at a height the quorum attests final (one endpoint's view proposes\n // it, trailed by PEER_SKEW), on tag and confirmation networks alike. State at a final\n // height never changes, so honest endpoints agree however their heads move, and one\n // that over-reports its finalized block cannot advance the height. A number,\n // not the `finalized` tag: some nodes (BSC's) serve no state at the tag.\n const { height } = await provenFinal(ctx, PROOF);\n const count = await client.getTransactionCount(from, height, {\n ...PROOF,\n quorumKey: nonceAbove(ordering.nonce),\n });\n return count > ordering.nonce;\n }),\n\n // Nonce ordering: an EVM transaction never expires.\n expired: async () => false,\n\n blockHash: (height, level) =>\n undecided(async () => {\n if (level === 'finalized') {\n return (await finalBlockAt(ctx, height, PROOF))?.hash ?? null;\n }\n return (await client.getBlock(height, PROOF))?.hash ?? null;\n }),\n };\n}\n\nconst changed = (height: bigint) =>\n new ProviderError('PROVIDER_INCONSISTENT', `block ${height} changed while scanning`);\n\n/**\n * Whether a block's `logsBloom` may hold `value` (a log's address or topic), by the\n * yellow paper's M3:2048: three bits, each the low 11 bits of a byte pair of the value's\n * keccak-256. `false` is definitive; `true` may be a false positive. No bloom may hold\n * anything.\n */\nexport function mayHold(bloom: string | undefined, value: string): boolean {\n if (bloom === undefined) return true;\n const hash = keccak_256(hexToBytes(value.slice(2)));\n for (let i = 0; i < 6; i += 2) {\n const bit = (((hash[i] as number) << 8) | (hash[i + 1] as number)) & 2047;\n // Bit 0 is the last byte's lowest bit.\n const byte = 255 - (bit >> 3);\n const bits = Number.parseInt(bloom.slice(2 + 2 * byte, 4 + 2 * byte), 16);\n if ((bits & (1 << (bit & 7))) === 0) return false;\n }\n return true;\n}\n\n/** Provider texts for a method they do not serve, whatever their error code. */\nconst METHOD_MISSING =\n /method .*(not found|not supported|does not exist|is not available)/i;\n\n/**\n * A definitive answer that the node does not serve `eth_getBlockReceipts`: JSON-RPC's\n * \"method not found\" (-32601), EIP-1474's \"method not supported\" (-32004), or a provider's\n * own code with a text that says so.\n */\nfunction methodMissing(error: unknown): boolean {\n if (!isCryptoAioError(error, 'RPC_ERROR') || error.ambiguous) return false;\n const { rpcCode, rpcMessage } = error.details ?? {};\n return (\n rpcCode === -32601 ||\n rpcCode === -32004 ||\n METHOD_MISSING.test(String(rpcMessage ?? ''))\n );\n}\n\ntype Receipts = ReadonlyMap<string, EvmReceipt>;\n\n/**\n * Every receipt of `block` in one call, by transaction hash. The node reads them by\n * block, never through a log or transaction index that may lag. `undefined` when the node\n * does not serve `eth_getBlockReceipts`.\n */\nasync function blockReceipts(\n client: EvmClient,\n block: EvmFullBlock,\n): Promise<Receipts | undefined> {\n let receipts: readonly EvmReceipt[] | null;\n try {\n receipts = await client.getBlockReceipts(block.hash, MONITOR);\n } catch (error) {\n if (methodMissing(error)) return undefined;\n throw error;\n }\n if (receipts === null) throw changed(block.number);\n return new Map(receipts.map((receipt) => [receipt.transactionHash, receipt]));\n}\n\n/** The fallback: one `eth_getTransactionReceipt` per transaction. */\nasync function receiptsOf(client: EvmClient, txs: readonly EvmTx[]): Promise<Receipts> {\n const receipts = await Promise.all(\n txs.map((tx) => client.getReceipt(tx.hash, MONITOR)),\n );\n return new Map(\n receipts.flatMap((receipt, i) =>\n receipt ? [[txs[i]?.hash as string, receipt]] : [],\n ),\n );\n}\n\n/**\n * The logs of every transaction of `block`. A receipt missing, or from another block, could\n * hide a deposit, so it fails the scan retryably instead.\n */\nfunction blockLogs(block: EvmFullBlock, receipts: Receipts): readonly EvmLog[] {\n return block.transactions.flatMap((tx) => {\n const receipt = receipts.get(tx.hash);\n if (receipt?.blockHash !== block.hash) throw changed(block.number);\n return receipt.logs;\n });\n}\n\nexport function createEvmBlocks(ctx: EvmContext): BlockSource {\n const { client, config } = ctx;\n /**\n * The block's `Transfer` logs without block receipts: `eth_getLogs`, which a lagging\n * log index answers empty without an error. So when it answers nothing while the header's\n * bloom may hold the topic, every transaction's receipt is read before the empty answer\n * is trusted: any call may have logged one.\n */\n const transferLogs = async (\n block: EvmFullBlock,\n ): Promise<{ readonly logs: readonly EvmLog[]; readonly receipts?: Receipts }> => {\n const topic = client.abi.transferTopic;\n const logs = await client.getLogs(\n { blockHash: block.hash, topics: [topic] },\n MONITOR,\n );\n if (logs.length > 0 || !mayHold(block.logsBloom, topic)) return { logs };\n const receipts = await receiptsOf(client, block.transactions);\n return { logs: blockLogs(block, receipts), receipts };\n };\n\n return {\n async header(height) {\n const block = await client.getBlock(height, MONITOR);\n return block ? toDriverBlock(block) : null;\n },\n\n async transactions(block, filter) {\n const full = await client.getBlockWithTransactions(block.height, MONITOR);\n if (!full || full.hash !== block.hash) throw changed(block.height);\n // One call for every receipt of the block, filtered scans included.\n let receipts = await blockReceipts(client, full);\n let selected: readonly EvmTx[] = full.transactions;\n if (filter?.addresses?.length) {\n const wanted = new Set(filter.addresses.map((a) => a.toLowerCase()));\n const watched = (address: string | null) =>\n address !== null && wanted.has(address.toLowerCase());\n let logs: readonly EvmLog[];\n if (receipts) logs = blockLogs(full, receipts);\n else ({ logs, receipts } = await transferLogs(full));\n const tokenTxs = new Set(\n logs\n .filter((log) => {\n const transfer = client.abi.decodeTransfer(log);\n return (\n transfer !== null && (watched(transfer.from) || watched(transfer.to))\n );\n })\n .map((log) => log.transactionHash),\n );\n // A contract creation's recipient is only in its receipt, so every creation stays.\n selected = full.transactions.filter(\n (tx) =>\n tx.to === null || watched(tx.from) || watched(tx.to) || tokenTxs.has(tx.hash),\n );\n }\n receipts ??= await receiptsOf(client, selected);\n return selected.map((tx) => {\n const receipt = receipts.get(tx.hash);\n if (!receipt || receipt.blockHash !== block.hash) throw changed(block.height);\n // The chain's view, with the network's config so bor's system logs do not make a\n // plain Polygon transfer `partial`.\n return decodeTransaction(client.abi, tx, receipt, full.timestamp, config);\n });\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The fields a rejection check reads, of one signed legacy, EIP-2930 or EIP-1559 tx. */
|
|
2
|
+
export interface EvmSentTx {
|
|
3
|
+
readonly type: 0 | 1 | 2;
|
|
4
|
+
/** Absent for a legacy transaction signed without EIP-155 (v of 27 or 28). */
|
|
5
|
+
readonly chainId?: bigint;
|
|
6
|
+
readonly maxFeePerGas?: bigint;
|
|
7
|
+
readonly maxPriorityFeePerGas?: bigint;
|
|
8
|
+
/** The recovery id: `yParity`, or the legacy `v` reduced to 0 or 1; -1 when neither. */
|
|
9
|
+
readonly recovery: number;
|
|
10
|
+
readonly r: bigint;
|
|
11
|
+
readonly s: bigint;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Twice geth's 128 KiB pool limit, checked before any decoding: a bare broadcast may
|
|
15
|
+
* carry any bytes, and untrusted input is capped before it is decoded.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MAX_SENT_BYTES: number;
|
|
18
|
+
/**
|
|
19
|
+
* The sent bytes as the checks read them: the fields, `'malformed'` when geth could not
|
|
20
|
+
* decode them either, or `undefined` when they are unreadable here but may be valid (an
|
|
21
|
+
* EIP-4844 or EIP-7702 transaction, or more than `MAX_SENT_BYTES`): no claim holds for those.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readSentTx(hex: string): EvmSentTx | 'malformed' | undefined;
|
|
24
|
+
/** geth's `ValidateSignatureValues` with Homestead's low-s rule, over the recovery id. */
|
|
25
|
+
export declare function signatureValuesValid(tx: EvmSentTx): boolean;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_SENT_BYTES = void 0;
|
|
4
|
+
exports.readSentTx = readSentTx;
|
|
5
|
+
exports.signatureValuesValid = signatureValuesValid;
|
|
6
|
+
/**
|
|
7
|
+
* What a node's rejection claims is checked against the bytes we sent,
|
|
8
|
+
* read here SDK-free. The reader is never stricter than geth: it calls bytes `malformed`
|
|
9
|
+
* only for what geth's RLP decoder also refuses (a broken or non-canonical encoding, an
|
|
10
|
+
* integer with a leading zero or over 256 bits, the wrong number of fields, a `to` that is
|
|
11
|
+
* not 20 bytes), and it reads no access list, so a claim it cannot confirm stays a refusal.
|
|
12
|
+
*/
|
|
13
|
+
const bytes_1 = require("../../core/util/bytes");
|
|
14
|
+
/**
|
|
15
|
+
* Twice geth's 128 KiB pool limit, checked before any decoding: a bare broadcast may
|
|
16
|
+
* carry any bytes, and untrusted input is capped before it is decoded.
|
|
17
|
+
*/
|
|
18
|
+
exports.MAX_SENT_BYTES = 2 * 128 * 1024;
|
|
19
|
+
class Malformed extends Error {
|
|
20
|
+
}
|
|
21
|
+
/** One canonical RLP item at `at`, and the offset after it; throws `Malformed`. */
|
|
22
|
+
function item(bytes, at) {
|
|
23
|
+
const lead = bytes[at];
|
|
24
|
+
if (lead === undefined)
|
|
25
|
+
throw new Malformed();
|
|
26
|
+
const span = (offset, length) => {
|
|
27
|
+
const end = offset + length;
|
|
28
|
+
if (end > bytes.length)
|
|
29
|
+
throw new Malformed();
|
|
30
|
+
return [offset, end];
|
|
31
|
+
};
|
|
32
|
+
const longLength = (width) => {
|
|
33
|
+
const [start, end] = span(at + 1, width);
|
|
34
|
+
if (bytes[start] === 0)
|
|
35
|
+
throw new Malformed();
|
|
36
|
+
let length = 0;
|
|
37
|
+
for (let i = start; i < end; i++)
|
|
38
|
+
length = length * 256 + bytes[i];
|
|
39
|
+
if (length < 56)
|
|
40
|
+
throw new Malformed();
|
|
41
|
+
return length;
|
|
42
|
+
};
|
|
43
|
+
if (lead < 0x80)
|
|
44
|
+
return [bytes.subarray(at, at + 1), at + 1];
|
|
45
|
+
if (lead <= 0xbf) {
|
|
46
|
+
const long = lead > 0xb7;
|
|
47
|
+
const width = long ? lead - 0xb7 : 0;
|
|
48
|
+
const length = long ? longLength(width) : lead - 0x80;
|
|
49
|
+
const [start, end] = span(at + 1 + width, length);
|
|
50
|
+
if (!long && length === 1 && bytes[start] < 0x80)
|
|
51
|
+
throw new Malformed();
|
|
52
|
+
return [bytes.subarray(start, end), end];
|
|
53
|
+
}
|
|
54
|
+
const long = lead > 0xf7;
|
|
55
|
+
const width = long ? lead - 0xf7 : 0;
|
|
56
|
+
const length = long ? longLength(width) : lead - 0xc0;
|
|
57
|
+
const [start, end] = span(at + 1 + width, length);
|
|
58
|
+
const items = [];
|
|
59
|
+
for (let offset = start; offset < end;) {
|
|
60
|
+
const [next, after] = item(bytes, offset);
|
|
61
|
+
if (after > end)
|
|
62
|
+
throw new Malformed();
|
|
63
|
+
items.push(next);
|
|
64
|
+
offset = after;
|
|
65
|
+
}
|
|
66
|
+
return [items, end];
|
|
67
|
+
}
|
|
68
|
+
/** A whole buffer as one list of exactly `fields` items. */
|
|
69
|
+
function list(bytes, fields) {
|
|
70
|
+
const [value, end] = item(bytes, 0);
|
|
71
|
+
if (end !== bytes.length || !Array.isArray(value) || value.length !== fields)
|
|
72
|
+
throw new Malformed();
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
/** A canonical unsigned integer of at most `bits` bits. */
|
|
76
|
+
function uint(value, bits) {
|
|
77
|
+
if (!(value instanceof Uint8Array) || value.length * 8 > bits || value[0] === 0)
|
|
78
|
+
throw new Malformed();
|
|
79
|
+
let out = 0n;
|
|
80
|
+
for (const byte of value)
|
|
81
|
+
out = (out << 8n) | BigInt(byte);
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function address(value) {
|
|
85
|
+
if (!(value instanceof Uint8Array) || (value.length !== 0 && value.length !== 20))
|
|
86
|
+
throw new Malformed();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The sent bytes as the checks read them: the fields, `'malformed'` when geth could not
|
|
90
|
+
* decode them either, or `undefined` when they are unreadable here but may be valid (an
|
|
91
|
+
* EIP-4844 or EIP-7702 transaction, or more than `MAX_SENT_BYTES`): no claim holds for those.
|
|
92
|
+
*/
|
|
93
|
+
function readSentTx(hex) {
|
|
94
|
+
if (typeof hex !== 'string' || hex.length > 2 + 2 * exports.MAX_SENT_BYTES)
|
|
95
|
+
return undefined;
|
|
96
|
+
let bytes;
|
|
97
|
+
try {
|
|
98
|
+
bytes = (0, bytes_1.fromHex)(hex);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return 'malformed';
|
|
102
|
+
}
|
|
103
|
+
const type = bytes[0];
|
|
104
|
+
if (type === undefined)
|
|
105
|
+
return 'malformed';
|
|
106
|
+
try {
|
|
107
|
+
if (type >= 0xc0) {
|
|
108
|
+
const [nonce, gasPrice, gas, to, value, , v, r, s] = list(bytes, 9);
|
|
109
|
+
uint(nonce, 64);
|
|
110
|
+
uint(gasPrice, 256);
|
|
111
|
+
uint(gas, 64);
|
|
112
|
+
address(to);
|
|
113
|
+
uint(value, 256);
|
|
114
|
+
const vv = uint(v, 256);
|
|
115
|
+
const eip155 = vv >= 35n;
|
|
116
|
+
return {
|
|
117
|
+
type: 0,
|
|
118
|
+
...(eip155 ? { chainId: (vv - 35n) / 2n } : {}),
|
|
119
|
+
recovery: eip155
|
|
120
|
+
? Number((vv - 35n) % 2n)
|
|
121
|
+
: vv === 27n || vv === 28n
|
|
122
|
+
? Number(vv - 27n)
|
|
123
|
+
: -1,
|
|
124
|
+
r: uint(r, 256),
|
|
125
|
+
s: uint(s, 256),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (type === 1 || type === 2) {
|
|
129
|
+
const fields = list(bytes.subarray(1), type === 1 ? 11 : 12);
|
|
130
|
+
const chainId = uint(fields[0], 256);
|
|
131
|
+
uint(fields[1], 64);
|
|
132
|
+
const prices = type === 2 ? [uint(fields[2], 256), uint(fields[3], 256)] : [];
|
|
133
|
+
if (type === 1)
|
|
134
|
+
uint(fields[2], 256);
|
|
135
|
+
const rest = type === 1 ? 3 : 4;
|
|
136
|
+
uint(fields[rest], 64);
|
|
137
|
+
address(fields[rest + 1]);
|
|
138
|
+
uint(fields[rest + 2], 256);
|
|
139
|
+
const [yParity, r, s] = fields.slice(-3);
|
|
140
|
+
const parity = uint(yParity, 256);
|
|
141
|
+
return {
|
|
142
|
+
type,
|
|
143
|
+
chainId,
|
|
144
|
+
...(type === 2
|
|
145
|
+
? {
|
|
146
|
+
maxPriorityFeePerGas: prices[0],
|
|
147
|
+
maxFeePerGas: prices[1],
|
|
148
|
+
}
|
|
149
|
+
: {}),
|
|
150
|
+
recovery: parity <= 1n ? Number(parity) : -1,
|
|
151
|
+
r: uint(r, 256),
|
|
152
|
+
s: uint(s, 256),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// geth reads any other first byte above 0x7f as a legacy list, and fails.
|
|
156
|
+
if (type >= 0x80)
|
|
157
|
+
return 'malformed';
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
if (error instanceof Malformed)
|
|
162
|
+
return 'malformed';
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** secp256k1's group order. */
|
|
167
|
+
const N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
|
|
168
|
+
/** geth's `ValidateSignatureValues` with Homestead's low-s rule, over the recovery id. */
|
|
169
|
+
function signatureValuesValid(tx) {
|
|
170
|
+
return ((tx.recovery === 0 || tx.recovery === 1) &&
|
|
171
|
+
tx.r >= 1n &&
|
|
172
|
+
tx.r < N &&
|
|
173
|
+
tx.s >= 1n &&
|
|
174
|
+
tx.s <= N / 2n);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=rawtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawtx.js","sourceRoot":"","sources":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C;QACxC,EAAE,CAAC,CAAC,IAAI,EAAE;QACV,EAAE,CAAC,CAAC,GAAG,CAAC;QACR,EAAE,CAAC,CAAC,IAAI,EAAE;QACV,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACf,CAAC;AACJ,CAAC","sourcesContent":["/**\n * What a node's rejection claims is checked against the bytes we sent,\n * read here SDK-free. The reader is never stricter than geth: it calls bytes `malformed`\n * only for what geth's RLP decoder also refuses (a broken or non-canonical encoding, an\n * integer with a leading zero or over 256 bits, the wrong number of fields, a `to` that is\n * not 20 bytes), and it reads no access list, so a claim it cannot confirm stays a refusal.\n */\nimport { fromHex } from '../../core/util/bytes';\n\n/** The fields a rejection check reads, of one signed legacy, EIP-2930 or EIP-1559 tx. */\nexport interface EvmSentTx {\n readonly type: 0 | 1 | 2;\n /** Absent for a legacy transaction signed without EIP-155 (v of 27 or 28). */\n readonly chainId?: bigint;\n readonly maxFeePerGas?: bigint;\n readonly maxPriorityFeePerGas?: bigint;\n /** The recovery id: `yParity`, or the legacy `v` reduced to 0 or 1; -1 when neither. */\n readonly recovery: number;\n readonly r: bigint;\n readonly s: bigint;\n}\n\n/**\n * Twice geth's 128 KiB pool limit, checked before any decoding: a bare broadcast may\n * carry any bytes, and untrusted input is capped before it is decoded.\n */\nexport const MAX_SENT_BYTES = 2 * 128 * 1024;\n\nclass Malformed extends Error {}\ntype Item = Uint8Array | readonly Item[];\n\n/** One canonical RLP item at `at`, and the offset after it; throws `Malformed`. */\nfunction item(bytes: Uint8Array, at: number): [Item, number] {\n const lead = bytes[at];\n if (lead === undefined) throw new Malformed();\n const span = (offset: number, length: number): [number, number] => {\n const end = offset + length;\n if (end > bytes.length) throw new Malformed();\n return [offset, end];\n };\n const longLength = (width: number): number => {\n const [start, end] = span(at + 1, width);\n if (bytes[start] === 0) throw new Malformed();\n let length = 0;\n for (let i = start; i < end; i++) length = length * 256 + (bytes[i] as number);\n if (length < 56) throw new Malformed();\n return length;\n };\n if (lead < 0x80) return [bytes.subarray(at, at + 1), at + 1];\n if (lead <= 0xbf) {\n const long = lead > 0xb7;\n const width = long ? lead - 0xb7 : 0;\n const length = long ? longLength(width) : lead - 0x80;\n const [start, end] = span(at + 1 + width, length);\n if (!long && length === 1 && (bytes[start] as number) < 0x80) throw new Malformed();\n return [bytes.subarray(start, end), end];\n }\n const long = lead > 0xf7;\n const width = long ? lead - 0xf7 : 0;\n const length = long ? longLength(width) : lead - 0xc0;\n const [start, end] = span(at + 1 + width, length);\n const items: Item[] = [];\n for (let offset = start; offset < end;) {\n const [next, after] = item(bytes, offset);\n if (after > end) throw new Malformed();\n items.push(next);\n offset = after;\n }\n return [items, end];\n}\n\n/** A whole buffer as one list of exactly `fields` items. */\nfunction list(bytes: Uint8Array, fields: number): readonly Item[] {\n const [value, end] = item(bytes, 0);\n if (end !== bytes.length || !Array.isArray(value) || value.length !== fields)\n throw new Malformed();\n return value as readonly Item[];\n}\n\n/** A canonical unsigned integer of at most `bits` bits. */\nfunction uint(value: Item | undefined, bits: number): bigint {\n if (!(value instanceof Uint8Array) || value.length * 8 > bits || value[0] === 0)\n throw new Malformed();\n let out = 0n;\n for (const byte of value) out = (out << 8n) | BigInt(byte);\n return out;\n}\n\nfunction address(value: Item | undefined): void {\n if (!(value instanceof Uint8Array) || (value.length !== 0 && value.length !== 20))\n throw new Malformed();\n}\n\n/**\n * The sent bytes as the checks read them: the fields, `'malformed'` when geth could not\n * decode them either, or `undefined` when they are unreadable here but may be valid (an\n * EIP-4844 or EIP-7702 transaction, or more than `MAX_SENT_BYTES`): no claim holds for those.\n */\nexport function readSentTx(hex: string): EvmSentTx | 'malformed' | undefined {\n if (typeof hex !== 'string' || hex.length > 2 + 2 * MAX_SENT_BYTES) return undefined;\n let bytes: Uint8Array;\n try {\n bytes = fromHex(hex);\n } catch {\n return 'malformed';\n }\n const type = bytes[0];\n if (type === undefined) return 'malformed';\n try {\n if (type >= 0xc0) {\n const [nonce, gasPrice, gas, to, value, , v, r, s] = list(bytes, 9);\n uint(nonce, 64);\n uint(gasPrice, 256);\n uint(gas, 64);\n address(to);\n uint(value, 256);\n const vv = uint(v, 256);\n const eip155 = vv >= 35n;\n return {\n type: 0,\n ...(eip155 ? { chainId: (vv - 35n) / 2n } : {}),\n recovery: eip155\n ? Number((vv - 35n) % 2n)\n : vv === 27n || vv === 28n\n ? Number(vv - 27n)\n : -1,\n r: uint(r, 256),\n s: uint(s, 256),\n };\n }\n if (type === 1 || type === 2) {\n const fields = list(bytes.subarray(1), type === 1 ? 11 : 12);\n const chainId = uint(fields[0], 256);\n uint(fields[1], 64);\n const prices = type === 2 ? [uint(fields[2], 256), uint(fields[3], 256)] : [];\n if (type === 1) uint(fields[2], 256);\n const rest = type === 1 ? 3 : 4;\n uint(fields[rest], 64);\n address(fields[rest + 1]);\n uint(fields[rest + 2], 256);\n const [yParity, r, s] = fields.slice(-3);\n const parity = uint(yParity, 256);\n return {\n type,\n chainId,\n ...(type === 2\n ? {\n maxPriorityFeePerGas: prices[0] as bigint,\n maxFeePerGas: prices[1] as bigint,\n }\n : {}),\n recovery: parity <= 1n ? Number(parity) : -1,\n r: uint(r, 256),\n s: uint(s, 256),\n };\n }\n // geth reads any other first byte above 0x7f as a legacy list, and fails.\n if (type >= 0x80) return 'malformed';\n return undefined;\n } catch (error) {\n if (error instanceof Malformed) return 'malformed';\n throw error;\n }\n}\n\n/** secp256k1's group order. */\nconst N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;\n\n/** geth's `ValidateSignatureValues` with Homestead's low-s rule, over the recovery id. */\nexport function signatureValuesValid(tx: EvmSentTx): boolean {\n return (\n (tx.recovery === 0 || tx.recovery === 1) &&\n tx.r >= 1n &&\n tx.r < N &&\n tx.s >= 1n &&\n tx.s <= N / 2n\n );\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EVM addresses, reads, nonces, finality and the `ext.evm` API. Every call carries the tags
|
|
3
|
+
* of the `ChainDriver` contract table (`src/core/driver/types.ts`): `read` for point
|
|
4
|
+
* queries, `monitor` for heights, observations and nonces, and `proof` for the finality
|
|
5
|
+
* that proofs attest.
|
|
6
|
+
*/
|
|
7
|
+
import type { AddressCodec, ChainReader, DriverBlock, SequenceSource } from '../../core/driver/types';
|
|
8
|
+
import type { Logger } from '../../core/events/logger';
|
|
9
|
+
import type { ChainInfo, NetworkInfo } from '../../core/model/chain';
|
|
10
|
+
import type { EvmNetworkConfig } from './network';
|
|
11
|
+
import type { EvmBlock, EvmCallTags, EvmClient, EvmExt } from './types';
|
|
12
|
+
/** What every EVM port is built from. */
|
|
13
|
+
export interface EvmContext {
|
|
14
|
+
readonly client: EvmClient;
|
|
15
|
+
readonly chain: ChainInfo;
|
|
16
|
+
readonly network: NetworkInfo;
|
|
17
|
+
readonly config: EvmNetworkConfig;
|
|
18
|
+
readonly log: Logger;
|
|
19
|
+
}
|
|
20
|
+
export declare const READ: EvmCallTags;
|
|
21
|
+
export declare const MONITOR: EvmCallTags;
|
|
22
|
+
export declare const PROOF: EvmCallTags;
|
|
23
|
+
export declare const withSignal: (tags: EvmCallTags, signal?: AbortSignal) => EvmCallTags;
|
|
24
|
+
export declare function toDriverBlock(block: EvmBlock): DriverBlock;
|
|
25
|
+
/** Whether a definitive (non-ambiguous) JSON-RPC error says the call reverted. */
|
|
26
|
+
export declare function isRevert(error: unknown): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* How many blocks a proof's final height trails the one endpoint that proposed it, so
|
|
29
|
+
* a quorum peer up to this far behind that endpoint still attests it.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PEER_SKEW = 2n;
|
|
32
|
+
/**
|
|
33
|
+
* The highest final block as one endpoint sees it (a `monitor` view): the `finalized` tag,
|
|
34
|
+
* or the head minus the confirmations; the head read carries the signal of `tags`. Proofs
|
|
35
|
+
* never use it as a final height: `provenFinal` attests one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function finalizedHeight(ctx: EvmContext, tags: EvmCallTags): Promise<bigint>;
|
|
38
|
+
/**
|
|
39
|
+
* A height that is final on every endpoint of the proof quorum (`tags`), and the quorum's
|
|
40
|
+
* block at it when the proof read that block anyway. One endpoint's view (a `monitor` read)
|
|
41
|
+
* only proposes: the height trails it by `PEER_SKEW` blocks, and the quorum attests it. On
|
|
42
|
+
* tag networks every quorum endpoint's `finalized` block must be at or past it; on
|
|
43
|
+
* confirmation networks every one must hold the block that confirms it. So an
|
|
44
|
+
* endpoint that over-reports cannot advance finality, and a peer that trails the proposer
|
|
45
|
+
* by up to `PEER_SKEW` blocks still agrees.
|
|
46
|
+
*/
|
|
47
|
+
export declare function provenFinal(ctx: EvmContext, tags: EvmCallTags): Promise<{
|
|
48
|
+
readonly height: bigint;
|
|
49
|
+
readonly block?: EvmBlock;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* The quorum's block at `height` when `height` is final on every endpoint of the proof
|
|
53
|
+
* quorum (`tags`), else `null`. Anchored at `height` itself, not at any endpoint's view:
|
|
54
|
+
* honest endpoints disagree only while `height` is final on one and not yet on another, and
|
|
55
|
+
* that decides nothing (a retryable `PROVIDER_INCONSISTENT`).
|
|
56
|
+
*/
|
|
57
|
+
export declare function finalBlockAt(ctx: EvmContext, height: bigint, tags: EvmCallTags): Promise<EvmBlock | null>;
|
|
58
|
+
export declare function createEvmAddressCodec(client: EvmClient): AddressCodec;
|
|
59
|
+
/** Whether a definitive (non-ambiguous) JSON-RPC error says the EVM stopped the code. */
|
|
60
|
+
export declare function isExecutionFailure(error: unknown): boolean;
|
|
61
|
+
/** An ERC-20 `balanceOf` at `latest`; `ASSET_RESOLUTION` when the contract gives none. */
|
|
62
|
+
export declare function erc20Balance(client: EvmClient, token: string, owner: string, tags: EvmCallTags): Promise<bigint>;
|
|
63
|
+
export declare function createEvmReader(ctx: EvmContext): ChainReader;
|
|
64
|
+
export declare function createEvmSequence(client: EvmClient): SequenceSource;
|
|
65
|
+
export declare function createEvmExt(client: EvmClient): EvmExt;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PEER_SKEW = exports.withSignal = exports.PROOF = exports.MONITOR = exports.READ = void 0;
|
|
4
|
+
exports.toDriverBlock = toDriverBlock;
|
|
5
|
+
exports.isRevert = isRevert;
|
|
6
|
+
exports.finalizedHeight = finalizedHeight;
|
|
7
|
+
exports.provenFinal = provenFinal;
|
|
8
|
+
exports.finalBlockAt = finalBlockAt;
|
|
9
|
+
exports.createEvmAddressCodec = createEvmAddressCodec;
|
|
10
|
+
exports.isExecutionFailure = isExecutionFailure;
|
|
11
|
+
exports.erc20Balance = erc20Balance;
|
|
12
|
+
exports.createEvmReader = createEvmReader;
|
|
13
|
+
exports.createEvmSequence = createEvmSequence;
|
|
14
|
+
exports.createEvmExt = createEvmExt;
|
|
15
|
+
const error_1 = require("../../core/errors/error");
|
|
16
|
+
const client_1 = require("./client");
|
|
17
|
+
const decode_1 = require("./decode");
|
|
18
|
+
exports.READ = { purpose: 'read', retry: 'safe' };
|
|
19
|
+
exports.MONITOR = { purpose: 'monitor', retry: 'safe' };
|
|
20
|
+
exports.PROOF = { purpose: 'proof', retry: 'safe', quorum: 'proof' };
|
|
21
|
+
const withSignal = (tags, signal) => signal ? { ...tags, signal } : tags;
|
|
22
|
+
exports.withSignal = withSignal;
|
|
23
|
+
function toDriverBlock(block) {
|
|
24
|
+
return {
|
|
25
|
+
height: block.number,
|
|
26
|
+
hash: block.hash,
|
|
27
|
+
parentHash: block.parentHash,
|
|
28
|
+
timestamp: block.timestamp,
|
|
29
|
+
transactionIds: block.transactions,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Whether a definitive (non-ambiguous) JSON-RPC error says the call reverted. */
|
|
33
|
+
function isRevert(error) {
|
|
34
|
+
if (!(0, error_1.isCryptoAioError)(error, 'RPC_ERROR') || error.ambiguous)
|
|
35
|
+
return false;
|
|
36
|
+
const { rpcCode, rpcMessage } = error.details ?? {};
|
|
37
|
+
return rpcCode === 3 || /revert/i.test(String(rpcMessage ?? error.message));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How many blocks a proof's final height trails the one endpoint that proposed it, so
|
|
41
|
+
* a quorum peer up to this far behind that endpoint still attests it.
|
|
42
|
+
*/
|
|
43
|
+
exports.PEER_SKEW = 2n;
|
|
44
|
+
/** `height - depth`, or genesis. */
|
|
45
|
+
const below = (height, depth) => height > depth ? height - depth : 0n;
|
|
46
|
+
/**
|
|
47
|
+
* A quorum key under which every endpoint whose block is at or past `height` agrees,
|
|
48
|
+
* so honest endpoints at different heights agree, and one that is not there disagrees.
|
|
49
|
+
* A malformed answer throws, which the transport counts as a disagreement.
|
|
50
|
+
*/
|
|
51
|
+
const atOrPast = (height) => (result) => result !== null &&
|
|
52
|
+
(0, client_1.quantity)(result.number, 'block number') >= height;
|
|
53
|
+
/** Whether every quorum endpoint's `finalized` block is at or past `height`. */
|
|
54
|
+
async function finalizedAtOrPast(ctx, height, tags) {
|
|
55
|
+
const block = await ctx.client.getBlock('finalized', {
|
|
56
|
+
...tags,
|
|
57
|
+
quorumKey: atOrPast(height),
|
|
58
|
+
});
|
|
59
|
+
// The endpoints agreed on the predicate, so the first one's block states it for all.
|
|
60
|
+
return block !== null && block.number >= height;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The highest final block as one endpoint sees it (a `monitor` view): the `finalized` tag,
|
|
64
|
+
* or the head minus the confirmations; the head read carries the signal of `tags`. Proofs
|
|
65
|
+
* never use it as a final height: `provenFinal` attests one.
|
|
66
|
+
*/
|
|
67
|
+
async function finalizedHeight(ctx, tags) {
|
|
68
|
+
const { finality } = ctx.config;
|
|
69
|
+
if (finality.kind === 'confirmations') {
|
|
70
|
+
const head = await ctx.client.blockNumber((0, exports.withSignal)(exports.MONITOR, tags.signal));
|
|
71
|
+
return below(head, BigInt(finality.confirmations - 1));
|
|
72
|
+
}
|
|
73
|
+
const block = await ctx.client.getBlock('finalized', tags);
|
|
74
|
+
if (!block) {
|
|
75
|
+
throw new error_1.ProviderError('PROVIDER_UNAVAILABLE', 'the endpoint reports no finalized block');
|
|
76
|
+
}
|
|
77
|
+
return block.number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A height that is final on every endpoint of the proof quorum (`tags`), and the quorum's
|
|
81
|
+
* block at it when the proof read that block anyway. One endpoint's view (a `monitor` read)
|
|
82
|
+
* only proposes: the height trails it by `PEER_SKEW` blocks, and the quorum attests it. On
|
|
83
|
+
* tag networks every quorum endpoint's `finalized` block must be at or past it; on
|
|
84
|
+
* confirmation networks every one must hold the block that confirms it. So an
|
|
85
|
+
* endpoint that over-reports cannot advance finality, and a peer that trails the proposer
|
|
86
|
+
* by up to `PEER_SKEW` blocks still agrees.
|
|
87
|
+
*/
|
|
88
|
+
async function provenFinal(ctx, tags) {
|
|
89
|
+
const { finality } = ctx.config;
|
|
90
|
+
const view = (0, exports.withSignal)(exports.MONITOR, tags.signal);
|
|
91
|
+
if (finality.kind === 'confirmations') {
|
|
92
|
+
const confirming = below(await ctx.client.blockNumber(view), exports.PEER_SKEW);
|
|
93
|
+
const block = await ctx.client.getBlock(confirming, tags);
|
|
94
|
+
if (block?.number !== confirming) {
|
|
95
|
+
throw new error_1.ProviderError('PROVIDER_INCONSISTENT', 'the endpoints do not hold the confirming block');
|
|
96
|
+
}
|
|
97
|
+
const height = below(confirming, BigInt(finality.confirmations - 1));
|
|
98
|
+
return height === confirming ? { height, block } : { height };
|
|
99
|
+
}
|
|
100
|
+
const height = below(await finalizedHeight(ctx, view), exports.PEER_SKEW);
|
|
101
|
+
if (!(await finalizedAtOrPast(ctx, height, tags))) {
|
|
102
|
+
throw new error_1.ProviderError('PROVIDER_INCONSISTENT', 'the endpoints do not attest the proposed finalized block');
|
|
103
|
+
}
|
|
104
|
+
return { height };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The quorum's block at `height` when `height` is final on every endpoint of the proof
|
|
108
|
+
* quorum (`tags`), else `null`. Anchored at `height` itself, not at any endpoint's view:
|
|
109
|
+
* honest endpoints disagree only while `height` is final on one and not yet on another, and
|
|
110
|
+
* that decides nothing (a retryable `PROVIDER_INCONSISTENT`).
|
|
111
|
+
*/
|
|
112
|
+
async function finalBlockAt(ctx, height, tags) {
|
|
113
|
+
const { client } = ctx;
|
|
114
|
+
const { finality } = ctx.config;
|
|
115
|
+
if (finality.kind === 'tag') {
|
|
116
|
+
if (!(await finalizedAtOrPast(ctx, height, tags)))
|
|
117
|
+
return null;
|
|
118
|
+
return client.getBlock(height, tags);
|
|
119
|
+
}
|
|
120
|
+
// The block that gives `height` its confirmations; with one, it is `height`'s own.
|
|
121
|
+
const depth = BigInt(finality.confirmations - 1);
|
|
122
|
+
const confirming = await client.getBlock(height + depth, tags);
|
|
123
|
+
if (confirming === null)
|
|
124
|
+
return null;
|
|
125
|
+
return depth === 0n ? confirming : client.getBlock(height, tags);
|
|
126
|
+
}
|
|
127
|
+
function createEvmAddressCodec(client) {
|
|
128
|
+
return {
|
|
129
|
+
validate: (value) => client.isAddress(value),
|
|
130
|
+
normalize: (value) => {
|
|
131
|
+
if (!client.isAddress(value)) {
|
|
132
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'not an EVM address');
|
|
133
|
+
}
|
|
134
|
+
const canonical = client.checksum(value);
|
|
135
|
+
return { canonical, display: canonical };
|
|
136
|
+
},
|
|
137
|
+
fromPublicKey: (publicKey) => {
|
|
138
|
+
// The client's strict decode already throws a specific `INVALID_ADDRESS`.
|
|
139
|
+
const canonical = client.addressFromPublicKey(publicKey);
|
|
140
|
+
return { canonical, display: canonical };
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const assetError = (reason) => new error_1.ValidationError('ASSET_RESOLUTION', reason);
|
|
145
|
+
/** geth's texts for an EVM that stopped the called code itself (`core/vm/errors.go`). */
|
|
146
|
+
const VM_FAILURE = /^(out of gas|invalid opcode|invalid jump destination|stack (underflow|limit reached)|write protection|return data out of bounds)/i;
|
|
147
|
+
/** Whether a definitive (non-ambiguous) JSON-RPC error says the EVM stopped the code. */
|
|
148
|
+
function isExecutionFailure(error) {
|
|
149
|
+
if (!(0, error_1.isCryptoAioError)(error, 'RPC_ERROR') || error.ambiguous)
|
|
150
|
+
return false;
|
|
151
|
+
const { rpcMessage } = error.details ?? {};
|
|
152
|
+
return typeof rpcMessage === 'string' && VM_FAILURE.test(rpcMessage);
|
|
153
|
+
}
|
|
154
|
+
/** An ERC-20 `balanceOf` at `latest`; `ASSET_RESOLUTION` when the contract gives none. */
|
|
155
|
+
async function erc20Balance(client, token, owner, tags) {
|
|
156
|
+
const data = await client.call({ to: token, data: client.abi.encodeBalanceOf(owner) }, 'latest', tags);
|
|
157
|
+
try {
|
|
158
|
+
return client.abi.decodeUint256(data);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
throw assetError('the token contract returned no balance');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function tokenOf(asset) {
|
|
165
|
+
if (asset === 'native' || asset.standard !== 'erc20') {
|
|
166
|
+
throw assetError(`EVM tokens use the 'erc20' standard`);
|
|
167
|
+
}
|
|
168
|
+
return asset.contract;
|
|
169
|
+
}
|
|
170
|
+
/** The text of an ABI `string`, or of a `bytes32` (older tokens such as MKR return one). */
|
|
171
|
+
function symbolText(client, data) {
|
|
172
|
+
try {
|
|
173
|
+
return client.abi.decodeString(data);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(data))
|
|
177
|
+
throw assetError('the token symbol is unreadable');
|
|
178
|
+
return Buffer.from(data.slice(2), 'hex').toString('utf8').replace(/\0+$/, '');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Token metadata is read under the proof quorum, stricter than the contract table's
|
|
183
|
+
* minimum. The core caches it for the container's life, and one endpoint's wrong `decimals`
|
|
184
|
+
* (a lagging, misrouted or buggy backend) would mis-scale every amount by orders of
|
|
185
|
+
* magnitude until restart. `decimals` never changes, so honest endpoints always agree.
|
|
186
|
+
*/
|
|
187
|
+
const METADATA = { ...exports.READ, quorum: 'proof' };
|
|
188
|
+
function createEvmReader(ctx) {
|
|
189
|
+
const { client } = ctx;
|
|
190
|
+
/**
|
|
191
|
+
* A revert or a VM execution failure is the token's own permanent problem
|
|
192
|
+
* (`ASSET_RESOLUTION`, which the core caches until restart, even if the call would
|
|
193
|
+
* later run). Any other JSON-RPC error is the node's, so it is rethrown retryable: a
|
|
194
|
+
* provider fault never pins a token. Everything else propagates unchanged: a
|
|
195
|
+
* misconfigured endpoint stays final, and a retryable failure is already retryable.
|
|
196
|
+
*/
|
|
197
|
+
const tokenCall = async (contract, data) => {
|
|
198
|
+
try {
|
|
199
|
+
return await client.call({ to: contract, data }, 'latest', METADATA);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (isRevert(error))
|
|
203
|
+
throw assetError('the token contract reverted');
|
|
204
|
+
if (isExecutionFailure(error))
|
|
205
|
+
throw assetError('the token contract failed to run');
|
|
206
|
+
if ((0, error_1.isCryptoAioError)(error, 'RPC_ERROR')) {
|
|
207
|
+
throw (0, error_1.withContext)(error, {}, { retryable: true });
|
|
208
|
+
}
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
getBalance: async (address, asset) => {
|
|
214
|
+
if (asset === 'native')
|
|
215
|
+
return client.getBalance(address, 'latest', exports.READ);
|
|
216
|
+
return erc20Balance(client, tokenOf(asset), address, exports.READ);
|
|
217
|
+
},
|
|
218
|
+
getBlockHeight: () => client.blockNumber(exports.MONITOR),
|
|
219
|
+
getFinalizedHeight: () => finalizedHeight(ctx, exports.MONITOR),
|
|
220
|
+
getBlock: async (ref) => {
|
|
221
|
+
const block = await client.getBlock(ref, exports.READ);
|
|
222
|
+
return block ? toDriverBlock(block) : null;
|
|
223
|
+
},
|
|
224
|
+
getTransaction: async (id) => {
|
|
225
|
+
const tx = await client.getTransaction(id, exports.READ);
|
|
226
|
+
if (!tx)
|
|
227
|
+
return null;
|
|
228
|
+
const receipt = tx.blockHash !== null ? await client.getReceipt(id, exports.READ) : null;
|
|
229
|
+
return (0, decode_1.decodeTransaction)(client.abi, tx, receipt, undefined, ctx.config);
|
|
230
|
+
},
|
|
231
|
+
/**
|
|
232
|
+
* With an ordering, the token verdict on one of our own Attempts. Without one (a
|
|
233
|
+
* status lookup by id, for a transaction the library does not manage) the chain's
|
|
234
|
+
* view, so a third party's call that shares the `transfer` selector is not reported
|
|
235
|
+
* failed.
|
|
236
|
+
*/
|
|
237
|
+
observe: async (ref, ordering) => {
|
|
238
|
+
const tx = await client.getTransaction(ref.id, exports.MONITOR);
|
|
239
|
+
if (!tx)
|
|
240
|
+
return { seen: 'none' };
|
|
241
|
+
const receipt = tx.blockHash === null ? null : await client.getReceipt(ref.id, exports.MONITOR);
|
|
242
|
+
return ordering === undefined
|
|
243
|
+
? (0, decode_1.chainObservation)(tx, receipt)
|
|
244
|
+
: (0, decode_1.evmObservation)(client.abi, tx, receipt);
|
|
245
|
+
},
|
|
246
|
+
getTokenMetadata: async (ref) => {
|
|
247
|
+
const contract = tokenOf(ref);
|
|
248
|
+
const decimalsData = await tokenCall(contract, client.abi.encodeDecimals());
|
|
249
|
+
if (decimalsData === '0x')
|
|
250
|
+
throw assetError('no token contract at this address');
|
|
251
|
+
let decimals;
|
|
252
|
+
try {
|
|
253
|
+
decimals = client.abi.decodeUint256(decimalsData);
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
throw assetError('the token decimals are unreadable');
|
|
257
|
+
}
|
|
258
|
+
if (decimals > 255n)
|
|
259
|
+
throw assetError('the token decimals are out of range');
|
|
260
|
+
const symbol = symbolText(client, await tokenCall(contract, client.abi.encodeSymbol()));
|
|
261
|
+
if (!symbol)
|
|
262
|
+
throw assetError('the token has no symbol');
|
|
263
|
+
return { symbol, decimals: Number(decimals) };
|
|
264
|
+
},
|
|
265
|
+
normalizeTokenRef: (ref) => {
|
|
266
|
+
const contract = tokenOf(ref);
|
|
267
|
+
if (!client.isAddress(contract))
|
|
268
|
+
throw assetError('not an EVM contract address');
|
|
269
|
+
return { standard: 'erc20', contract: client.checksum(contract) };
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function createEvmSequence(client) {
|
|
274
|
+
return {
|
|
275
|
+
pending: (address) => client.getTransactionCount(address, 'pending', exports.MONITOR),
|
|
276
|
+
latest: (address) => client.getTransactionCount(address, 'latest', exports.MONITOR),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function createEvmExt(client) {
|
|
280
|
+
return {
|
|
281
|
+
evm: {
|
|
282
|
+
getNonce: async (address, block = 'latest') => {
|
|
283
|
+
if (block !== 'latest' && block !== 'pending') {
|
|
284
|
+
throw new error_1.ValidationError('INVALID_INTENT', `block must be 'latest' or 'pending'`);
|
|
285
|
+
}
|
|
286
|
+
const codec = createEvmAddressCodec(client);
|
|
287
|
+
return client.getTransactionCount(codec.normalize(address).canonical, block, exports.READ);
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=reader.js.map
|