@getomnichain/omnichain 0.2.0 → 0.2.1
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/dist/cjs/abstract_gas_pricing.js +27 -0
- package/dist/cjs/abstract_gas_pricing.js.map +1 -0
- package/dist/cjs/address.factory.js +81 -0
- package/dist/cjs/address.factory.js.map +1 -0
- package/dist/cjs/address.js +17 -0
- package/dist/cjs/address.js.map +1 -0
- package/dist/cjs/address_field.decorator.js +37 -0
- package/dist/cjs/address_field.decorator.js.map +1 -0
- package/dist/cjs/chain.base.js +118 -0
- package/dist/cjs/chain.base.js.map +1 -0
- package/dist/cjs/chain_ids.js +205 -0
- package/dist/cjs/chain_ids.js.map +1 -0
- package/dist/cjs/errors.js +69 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/evm/evm_address.js +63 -0
- package/dist/cjs/evm/evm_address.js.map +1 -0
- package/dist/cjs/evm/evm_chain.js +690 -0
- package/dist/cjs/evm/evm_chain.js.map +1 -0
- package/dist/cjs/evm/evm_chains.js +530 -0
- package/dist/cjs/evm/evm_chains.js.map +1 -0
- package/dist/cjs/evm/evm_gas_estimate.js +76 -0
- package/dist/cjs/evm/evm_gas_estimate.js.map +1 -0
- package/dist/cjs/evm/evm_gas_pricing.js +62 -0
- package/dist/cjs/evm/evm_gas_pricing.js.map +1 -0
- package/dist/cjs/evm/evm_token.js +26 -0
- package/dist/cjs/evm/evm_token.js.map +1 -0
- package/dist/cjs/evm/evm_tokens.js +109 -0
- package/dist/cjs/evm/evm_tokens.js.map +1 -0
- package/dist/cjs/evm/evm_transaction_status.js +183 -0
- package/dist/cjs/evm/evm_transaction_status.js.map +1 -0
- package/dist/cjs/evm/index.js +26 -0
- package/dist/cjs/evm/index.js.map +1 -0
- package/dist/cjs/evm/unsigned_evm_transaction.js +22 -0
- package/dist/cjs/evm/unsigned_evm_transaction.js.map +1 -0
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/is_address.decorator.js +54 -0
- package/dist/cjs/is_address.decorator.js.map +1 -0
- package/dist/cjs/network_type.js +152 -0
- package/dist/cjs/network_type.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/priority.js +26 -0
- package/dist/cjs/priority.js.map +1 -0
- package/dist/cjs/solana/index.js +25 -0
- package/dist/cjs/solana/index.js.map +1 -0
- package/dist/cjs/solana/solana_address.js +49 -0
- package/dist/cjs/solana/solana_address.js.map +1 -0
- package/dist/cjs/solana/solana_chain.js +708 -0
- package/dist/cjs/solana/solana_chain.js.map +1 -0
- package/dist/cjs/solana/solana_chains.js +88 -0
- package/dist/cjs/solana/solana_chains.js.map +1 -0
- package/dist/cjs/solana/solana_gas_pricing.js +30 -0
- package/dist/cjs/solana/solana_gas_pricing.js.map +1 -0
- package/dist/cjs/solana/solana_token.js +38 -0
- package/dist/cjs/solana/solana_token.js.map +1 -0
- package/dist/cjs/solana/solana_tokens.js +29 -0
- package/dist/cjs/solana/solana_tokens.js.map +1 -0
- package/dist/cjs/solana/solana_transaction_status.js +149 -0
- package/dist/cjs/solana/solana_transaction_status.js.map +1 -0
- package/dist/cjs/solana/unsigned_solana_transaction.js +30 -0
- package/dist/cjs/solana/unsigned_solana_transaction.js.map +1 -0
- package/dist/cjs/token.js +66 -0
- package/dist/cjs/token.js.map +1 -0
- package/dist/cjs/ton/index.js +18 -0
- package/dist/cjs/ton/index.js.map +1 -0
- package/dist/cjs/ton/ton_address.js +57 -0
- package/dist/cjs/ton/ton_address.js.map +1 -0
- package/dist/cjs/transaction_status.js +283 -0
- package/dist/cjs/transaction_status.js.map +1 -0
- package/dist/cjs/unsigned_transaction.js +13 -0
- package/dist/cjs/unsigned_transaction.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_address.js +43 -0
- package/dist/cjs/utxo/btc/btc_address.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_chain.js +66 -0
- package/dist/cjs/utxo/btc/btc_chain.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_chains.js +49 -0
- package/dist/cjs/utxo/btc/btc_chains.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_token.js +15 -0
- package/dist/cjs/utxo/btc/btc_token.js.map +1 -0
- package/dist/cjs/utxo/btc/index.js +30 -0
- package/dist/cjs/utxo/btc/index.js.map +1 -0
- package/dist/cjs/utxo/btc/network_params.js +196 -0
- package/dist/cjs/utxo/btc/network_params.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/asset_outpoint.js +16 -0
- package/dist/cjs/utxo/btc/tools/asset_outpoint.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/bitcoin_core.tool.js +179 -0
- package/dist/cjs/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/esplora.tool.js +120 -0
- package/dist/cjs/utxo/btc/tools/esplora.tool.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/inscription_index.js +3 -0
- package/dist/cjs/utxo/btc/tools/inscription_index.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/ordiscan.tool.js +60 -0
- package/dist/cjs/utxo/btc/tools/ordiscan.tool.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/rare_sat_index.js +3 -0
- package/dist/cjs/utxo/btc/tools/rare_sat_index.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/rune_index.js +3 -0
- package/dist/cjs/utxo/btc/tools/rune_index.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/unisat.tool.js +56 -0
- package/dist/cjs/utxo/btc/tools/unisat.tool.js.map +1 -0
- package/dist/cjs/utxo/coin_selection.js +160 -0
- package/dist/cjs/utxo/coin_selection.js.map +1 -0
- package/dist/cjs/utxo/doge/doge_chains.js +32 -0
- package/dist/cjs/utxo/doge/doge_chains.js.map +1 -0
- package/dist/cjs/utxo/doge/index.js +19 -0
- package/dist/cjs/utxo/doge/index.js.map +1 -0
- package/dist/cjs/utxo/doge/network_params.js +30 -0
- package/dist/cjs/utxo/doge/network_params.js.map +1 -0
- package/dist/cjs/utxo/ecc.js +47 -0
- package/dist/cjs/utxo/ecc.js.map +1 -0
- package/dist/cjs/utxo/fee.js +61 -0
- package/dist/cjs/utxo/fee.js.map +1 -0
- package/dist/cjs/utxo/index.js +36 -0
- package/dist/cjs/utxo/index.js.map +1 -0
- package/dist/cjs/utxo/ltc/index.js +19 -0
- package/dist/cjs/utxo/ltc/index.js.map +1 -0
- package/dist/cjs/utxo/ltc/ltc_chains.js +32 -0
- package/dist/cjs/utxo/ltc/ltc_chains.js.map +1 -0
- package/dist/cjs/utxo/ltc/network_params.js +33 -0
- package/dist/cjs/utxo/ltc/network_params.js.map +1 -0
- package/dist/cjs/utxo/script.js +59 -0
- package/dist/cjs/utxo/script.js.map +1 -0
- package/dist/cjs/utxo/tools/broadcaster.js +3 -0
- package/dist/cjs/utxo/tools/broadcaster.js.map +1 -0
- package/dist/cjs/utxo/tools/chain_tip_provider.js +3 -0
- package/dist/cjs/utxo/tools/chain_tip_provider.js.map +1 -0
- package/dist/cjs/utxo/tools/fee_estimator.js +3 -0
- package/dist/cjs/utxo/tools/fee_estimator.js.map +1 -0
- package/dist/cjs/utxo/tools/raw_transaction_provider.js +3 -0
- package/dist/cjs/utxo/tools/raw_transaction_provider.js.map +1 -0
- package/dist/cjs/utxo/tools/utxo_provider.js +3 -0
- package/dist/cjs/utxo/tools/utxo_provider.js.map +1 -0
- package/dist/cjs/utxo/unsigned_utxo_transaction.js +36 -0
- package/dist/cjs/utxo/unsigned_utxo_transaction.js.map +1 -0
- package/dist/cjs/utxo/utxo.js +3 -0
- package/dist/{utxo → cjs/utxo}/utxo.js.map +1 -1
- package/dist/cjs/utxo/utxo_chain.js +528 -0
- package/dist/cjs/utxo/utxo_chain.js.map +1 -0
- package/dist/cjs/utxo/utxo_chains.js +68 -0
- package/dist/cjs/utxo/utxo_chains.js.map +1 -0
- package/dist/cjs/utxo/utxo_gas_pricing.js +24 -0
- package/dist/cjs/utxo/utxo_gas_pricing.js.map +1 -0
- package/dist/cjs/utxo/utxo_network_params.js +18 -0
- package/dist/cjs/utxo/utxo_network_params.js.map +1 -0
- package/dist/cjs/utxo/utxo_transaction_status.js +95 -0
- package/dist/cjs/utxo/utxo_transaction_status.js.map +1 -0
- package/dist/esm/abstract_gas_pricing.d.ts.map +1 -0
- package/dist/esm/abstract_gas_pricing.js.map +1 -0
- package/dist/esm/address.d.ts.map +1 -0
- package/dist/esm/address.factory.d.ts.map +1 -0
- package/dist/esm/address.factory.js.map +1 -0
- package/dist/esm/address.js.map +1 -0
- package/dist/esm/address_field.decorator.d.ts.map +1 -0
- package/dist/esm/address_field.decorator.js.map +1 -0
- package/dist/esm/chain.base.d.ts.map +1 -0
- package/dist/esm/chain.base.js.map +1 -0
- package/dist/esm/chain_ids.d.ts.map +1 -0
- package/dist/esm/chain_ids.js.map +1 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/evm/evm_address.d.ts.map +1 -0
- package/dist/esm/evm/evm_address.js.map +1 -0
- package/dist/esm/evm/evm_chain.d.ts.map +1 -0
- package/dist/esm/evm/evm_chain.js.map +1 -0
- package/dist/esm/evm/evm_chains.d.ts.map +1 -0
- package/dist/esm/evm/evm_chains.js.map +1 -0
- package/dist/esm/evm/evm_gas_estimate.d.ts.map +1 -0
- package/dist/esm/evm/evm_gas_estimate.js.map +1 -0
- package/dist/esm/evm/evm_gas_pricing.d.ts.map +1 -0
- package/dist/esm/evm/evm_gas_pricing.js.map +1 -0
- package/dist/esm/evm/evm_token.d.ts.map +1 -0
- package/dist/esm/evm/evm_token.js.map +1 -0
- package/dist/esm/evm/evm_tokens.d.ts.map +1 -0
- package/dist/esm/evm/evm_tokens.js.map +1 -0
- package/dist/esm/evm/evm_transaction_status.d.ts.map +1 -0
- package/dist/esm/evm/evm_transaction_status.js.map +1 -0
- package/dist/esm/evm/index.d.ts.map +1 -0
- package/dist/esm/evm/index.js.map +1 -0
- package/dist/esm/evm/unsigned_evm_transaction.d.ts.map +1 -0
- package/dist/esm/evm/unsigned_evm_transaction.js.map +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/is_address.decorator.d.ts.map +1 -0
- package/dist/esm/is_address.decorator.js.map +1 -0
- package/dist/esm/network_type.d.ts.map +1 -0
- package/dist/esm/network_type.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/priority.d.ts.map +1 -0
- package/dist/esm/priority.js.map +1 -0
- package/dist/esm/solana/index.d.ts.map +1 -0
- package/dist/esm/solana/index.js.map +1 -0
- package/dist/esm/solana/solana_address.d.ts.map +1 -0
- package/dist/esm/solana/solana_address.js.map +1 -0
- package/dist/esm/solana/solana_chain.d.ts.map +1 -0
- package/dist/esm/solana/solana_chain.js.map +1 -0
- package/dist/esm/solana/solana_chains.d.ts.map +1 -0
- package/dist/esm/solana/solana_chains.js.map +1 -0
- package/dist/esm/solana/solana_gas_pricing.d.ts.map +1 -0
- package/dist/esm/solana/solana_gas_pricing.js.map +1 -0
- package/dist/esm/solana/solana_token.d.ts.map +1 -0
- package/dist/esm/solana/solana_token.js.map +1 -0
- package/dist/esm/solana/solana_tokens.d.ts.map +1 -0
- package/dist/esm/solana/solana_tokens.js.map +1 -0
- package/dist/esm/solana/solana_transaction_status.d.ts.map +1 -0
- package/dist/esm/solana/solana_transaction_status.js.map +1 -0
- package/dist/esm/solana/unsigned_solana_transaction.d.ts.map +1 -0
- package/dist/esm/solana/unsigned_solana_transaction.js.map +1 -0
- package/dist/esm/token.d.ts.map +1 -0
- package/dist/esm/token.js.map +1 -0
- package/dist/esm/ton/index.d.ts.map +1 -0
- package/dist/esm/ton/index.js.map +1 -0
- package/dist/esm/ton/ton_address.d.ts.map +1 -0
- package/dist/esm/ton/ton_address.js.map +1 -0
- package/dist/esm/transaction_status.d.ts.map +1 -0
- package/dist/esm/transaction_status.js.map +1 -0
- package/dist/esm/unsigned_transaction.d.ts.map +1 -0
- package/dist/esm/unsigned_transaction.js.map +1 -0
- package/dist/esm/utxo/btc/btc_address.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_address.js.map +1 -0
- package/dist/esm/utxo/btc/btc_chain.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_chain.js.map +1 -0
- package/dist/esm/utxo/btc/btc_chains.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_chains.js.map +1 -0
- package/dist/esm/utxo/btc/btc_token.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_token.js.map +1 -0
- package/dist/esm/utxo/btc/index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/index.js.map +1 -0
- package/dist/esm/utxo/btc/network_params.d.ts.map +1 -0
- package/dist/esm/utxo/btc/network_params.js.map +1 -0
- package/dist/esm/utxo/btc/tools/asset_outpoint.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/asset_outpoint.js.map +1 -0
- package/dist/esm/utxo/btc/tools/bitcoin_core.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
- package/dist/esm/utxo/btc/tools/esplora.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/esplora.tool.js.map +1 -0
- package/dist/esm/utxo/btc/tools/inscription_index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/inscription_index.js.map +1 -0
- package/dist/esm/utxo/btc/tools/ordiscan.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/ordiscan.tool.js.map +1 -0
- package/dist/esm/utxo/btc/tools/rare_sat_index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/rare_sat_index.js.map +1 -0
- package/dist/esm/utxo/btc/tools/rune_index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/rune_index.js.map +1 -0
- package/dist/esm/utxo/btc/tools/unisat.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/unisat.tool.js.map +1 -0
- package/dist/esm/utxo/coin_selection.d.ts.map +1 -0
- package/dist/esm/utxo/coin_selection.js.map +1 -0
- package/dist/esm/utxo/doge/doge_chains.d.ts.map +1 -0
- package/dist/esm/utxo/doge/doge_chains.js.map +1 -0
- package/dist/esm/utxo/doge/index.d.ts.map +1 -0
- package/dist/esm/utxo/doge/index.js.map +1 -0
- package/dist/esm/utxo/doge/network_params.d.ts.map +1 -0
- package/dist/esm/utxo/doge/network_params.js.map +1 -0
- package/dist/esm/utxo/ecc.d.ts.map +1 -0
- package/dist/esm/utxo/ecc.js.map +1 -0
- package/dist/esm/utxo/fee.d.ts.map +1 -0
- package/dist/esm/utxo/fee.js.map +1 -0
- package/dist/esm/utxo/index.d.ts.map +1 -0
- package/dist/esm/utxo/index.js.map +1 -0
- package/dist/esm/utxo/ltc/index.d.ts.map +1 -0
- package/dist/esm/utxo/ltc/index.js.map +1 -0
- package/dist/{utxo/doge/doge_chains.d.ts.map → esm/utxo/ltc/ltc_chains.d.ts.map} +1 -1
- package/dist/{utxo/doge/doge_chains.js.map → esm/utxo/ltc/ltc_chains.js.map} +1 -1
- package/dist/esm/utxo/ltc/network_params.d.ts.map +1 -0
- package/dist/esm/utxo/ltc/network_params.js.map +1 -0
- package/dist/esm/utxo/script.d.ts.map +1 -0
- package/dist/esm/utxo/script.js.map +1 -0
- package/dist/esm/utxo/tools/broadcaster.d.ts.map +1 -0
- package/dist/esm/utxo/tools/broadcaster.js.map +1 -0
- package/dist/esm/utxo/tools/chain_tip_provider.d.ts.map +1 -0
- package/dist/esm/utxo/tools/chain_tip_provider.js.map +1 -0
- package/dist/esm/utxo/tools/fee_estimator.d.ts.map +1 -0
- package/dist/esm/utxo/tools/fee_estimator.js.map +1 -0
- package/dist/esm/utxo/tools/raw_transaction_provider.d.ts.map +1 -0
- package/dist/esm/utxo/tools/raw_transaction_provider.js.map +1 -0
- package/dist/esm/utxo/tools/utxo_provider.d.ts.map +1 -0
- package/dist/esm/utxo/tools/utxo_provider.js.map +1 -0
- package/dist/esm/utxo/unsigned_utxo_transaction.d.ts.map +1 -0
- package/dist/esm/utxo/unsigned_utxo_transaction.js.map +1 -0
- package/dist/esm/utxo/utxo.d.ts.map +1 -0
- package/dist/esm/utxo/utxo.js.map +1 -0
- package/dist/esm/utxo/utxo_chain.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_chain.js.map +1 -0
- package/dist/esm/utxo/utxo_chains.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_chains.js.map +1 -0
- package/dist/esm/utxo/utxo_gas_pricing.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_gas_pricing.js.map +1 -0
- package/dist/esm/utxo/utxo_network_params.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_network_params.js.map +1 -0
- package/dist/esm/utxo/utxo_transaction_status.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_transaction_status.js.map +1 -0
- package/package.json +32 -16
- package/dist/abstract_gas_pricing.d.ts.map +0 -1
- package/dist/abstract_gas_pricing.js.map +0 -1
- package/dist/address.d.ts.map +0 -1
- package/dist/address.factory.d.ts.map +0 -1
- package/dist/address.factory.js.map +0 -1
- package/dist/address.js.map +0 -1
- package/dist/address_field.decorator.d.ts.map +0 -1
- package/dist/address_field.decorator.js.map +0 -1
- package/dist/chain.base.d.ts.map +0 -1
- package/dist/chain.base.js.map +0 -1
- package/dist/chain_ids.d.ts.map +0 -1
- package/dist/chain_ids.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/evm/evm_address.d.ts.map +0 -1
- package/dist/evm/evm_address.js.map +0 -1
- package/dist/evm/evm_chain.d.ts.map +0 -1
- package/dist/evm/evm_chain.js.map +0 -1
- package/dist/evm/evm_chains.d.ts.map +0 -1
- package/dist/evm/evm_chains.js.map +0 -1
- package/dist/evm/evm_gas_estimate.d.ts.map +0 -1
- package/dist/evm/evm_gas_estimate.js.map +0 -1
- package/dist/evm/evm_gas_pricing.d.ts.map +0 -1
- package/dist/evm/evm_gas_pricing.js.map +0 -1
- package/dist/evm/evm_token.d.ts.map +0 -1
- package/dist/evm/evm_token.js.map +0 -1
- package/dist/evm/evm_tokens.d.ts.map +0 -1
- package/dist/evm/evm_tokens.js.map +0 -1
- package/dist/evm/evm_transaction_status.d.ts.map +0 -1
- package/dist/evm/evm_transaction_status.js.map +0 -1
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/unsigned_evm_transaction.d.ts.map +0 -1
- package/dist/evm/unsigned_evm_transaction.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/is_address.decorator.d.ts.map +0 -1
- package/dist/is_address.decorator.js.map +0 -1
- package/dist/network_type.d.ts.map +0 -1
- package/dist/network_type.js.map +0 -1
- package/dist/priority.d.ts.map +0 -1
- package/dist/priority.js.map +0 -1
- package/dist/solana/index.d.ts.map +0 -1
- package/dist/solana/index.js.map +0 -1
- package/dist/solana/solana_address.d.ts.map +0 -1
- package/dist/solana/solana_address.js.map +0 -1
- package/dist/solana/solana_chain.d.ts.map +0 -1
- package/dist/solana/solana_chain.js.map +0 -1
- package/dist/solana/solana_chains.d.ts.map +0 -1
- package/dist/solana/solana_chains.js.map +0 -1
- package/dist/solana/solana_gas_pricing.d.ts.map +0 -1
- package/dist/solana/solana_gas_pricing.js.map +0 -1
- package/dist/solana/solana_token.d.ts.map +0 -1
- package/dist/solana/solana_token.js.map +0 -1
- package/dist/solana/solana_tokens.d.ts.map +0 -1
- package/dist/solana/solana_tokens.js.map +0 -1
- package/dist/solana/solana_transaction_status.d.ts.map +0 -1
- package/dist/solana/solana_transaction_status.js.map +0 -1
- package/dist/solana/unsigned_solana_transaction.d.ts.map +0 -1
- package/dist/solana/unsigned_solana_transaction.js.map +0 -1
- package/dist/token.d.ts.map +0 -1
- package/dist/token.js.map +0 -1
- package/dist/ton/index.d.ts.map +0 -1
- package/dist/ton/index.js.map +0 -1
- package/dist/ton/ton_address.d.ts.map +0 -1
- package/dist/ton/ton_address.js.map +0 -1
- package/dist/transaction_status.d.ts.map +0 -1
- package/dist/transaction_status.js.map +0 -1
- package/dist/unsigned_transaction.d.ts.map +0 -1
- package/dist/unsigned_transaction.js.map +0 -1
- package/dist/utxo/btc/btc_address.d.ts.map +0 -1
- package/dist/utxo/btc/btc_address.js.map +0 -1
- package/dist/utxo/btc/btc_chain.d.ts.map +0 -1
- package/dist/utxo/btc/btc_chain.js.map +0 -1
- package/dist/utxo/btc/btc_chains.d.ts.map +0 -1
- package/dist/utxo/btc/btc_chains.js.map +0 -1
- package/dist/utxo/btc/btc_token.d.ts.map +0 -1
- package/dist/utxo/btc/btc_token.js.map +0 -1
- package/dist/utxo/btc/index.d.ts.map +0 -1
- package/dist/utxo/btc/index.js.map +0 -1
- package/dist/utxo/btc/network_params.d.ts.map +0 -1
- package/dist/utxo/btc/network_params.js.map +0 -1
- package/dist/utxo/btc/tools/asset_outpoint.d.ts.map +0 -1
- package/dist/utxo/btc/tools/asset_outpoint.js.map +0 -1
- package/dist/utxo/btc/tools/bitcoin_core.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/bitcoin_core.tool.js.map +0 -1
- package/dist/utxo/btc/tools/esplora.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/esplora.tool.js.map +0 -1
- package/dist/utxo/btc/tools/inscription_index.d.ts.map +0 -1
- package/dist/utxo/btc/tools/inscription_index.js.map +0 -1
- package/dist/utxo/btc/tools/ordiscan.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/ordiscan.tool.js.map +0 -1
- package/dist/utxo/btc/tools/rare_sat_index.d.ts.map +0 -1
- package/dist/utxo/btc/tools/rare_sat_index.js.map +0 -1
- package/dist/utxo/btc/tools/rune_index.d.ts.map +0 -1
- package/dist/utxo/btc/tools/rune_index.js.map +0 -1
- package/dist/utxo/btc/tools/unisat.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/unisat.tool.js.map +0 -1
- package/dist/utxo/coin_selection.d.ts.map +0 -1
- package/dist/utxo/coin_selection.js.map +0 -1
- package/dist/utxo/doge/index.d.ts.map +0 -1
- package/dist/utxo/doge/index.js.map +0 -1
- package/dist/utxo/doge/network_params.d.ts.map +0 -1
- package/dist/utxo/doge/network_params.js.map +0 -1
- package/dist/utxo/ecc.d.ts.map +0 -1
- package/dist/utxo/ecc.js.map +0 -1
- package/dist/utxo/fee.d.ts.map +0 -1
- package/dist/utxo/fee.js.map +0 -1
- package/dist/utxo/index.d.ts.map +0 -1
- package/dist/utxo/index.js.map +0 -1
- package/dist/utxo/ltc/index.d.ts.map +0 -1
- package/dist/utxo/ltc/index.js.map +0 -1
- package/dist/utxo/ltc/ltc_chains.d.ts.map +0 -1
- package/dist/utxo/ltc/ltc_chains.js.map +0 -1
- package/dist/utxo/ltc/network_params.d.ts.map +0 -1
- package/dist/utxo/ltc/network_params.js.map +0 -1
- package/dist/utxo/script.d.ts.map +0 -1
- package/dist/utxo/script.js.map +0 -1
- package/dist/utxo/tools/broadcaster.d.ts.map +0 -1
- package/dist/utxo/tools/broadcaster.js.map +0 -1
- package/dist/utxo/tools/chain_tip_provider.d.ts.map +0 -1
- package/dist/utxo/tools/chain_tip_provider.js.map +0 -1
- package/dist/utxo/tools/fee_estimator.d.ts.map +0 -1
- package/dist/utxo/tools/fee_estimator.js.map +0 -1
- package/dist/utxo/tools/raw_transaction_provider.d.ts.map +0 -1
- package/dist/utxo/tools/raw_transaction_provider.js.map +0 -1
- package/dist/utxo/tools/utxo_provider.d.ts.map +0 -1
- package/dist/utxo/tools/utxo_provider.js.map +0 -1
- package/dist/utxo/unsigned_utxo_transaction.d.ts.map +0 -1
- package/dist/utxo/unsigned_utxo_transaction.js.map +0 -1
- package/dist/utxo/utxo.d.ts.map +0 -1
- package/dist/utxo/utxo_chain.d.ts.map +0 -1
- package/dist/utxo/utxo_chain.js.map +0 -1
- package/dist/utxo/utxo_chains.d.ts.map +0 -1
- package/dist/utxo/utxo_chains.js.map +0 -1
- package/dist/utxo/utxo_gas_pricing.d.ts.map +0 -1
- package/dist/utxo/utxo_gas_pricing.js.map +0 -1
- package/dist/utxo/utxo_network_params.d.ts.map +0 -1
- package/dist/utxo/utxo_network_params.js.map +0 -1
- package/dist/utxo/utxo_transaction_status.d.ts.map +0 -1
- package/dist/utxo/utxo_transaction_status.js.map +0 -1
- /package/dist/{abstract_gas_pricing.d.ts → esm/abstract_gas_pricing.d.ts} +0 -0
- /package/dist/{abstract_gas_pricing.js → esm/abstract_gas_pricing.js} +0 -0
- /package/dist/{address.d.ts → esm/address.d.ts} +0 -0
- /package/dist/{address.factory.d.ts → esm/address.factory.d.ts} +0 -0
- /package/dist/{address.factory.js → esm/address.factory.js} +0 -0
- /package/dist/{address.js → esm/address.js} +0 -0
- /package/dist/{address_field.decorator.d.ts → esm/address_field.decorator.d.ts} +0 -0
- /package/dist/{address_field.decorator.js → esm/address_field.decorator.js} +0 -0
- /package/dist/{chain.base.d.ts → esm/chain.base.d.ts} +0 -0
- /package/dist/{chain.base.js → esm/chain.base.js} +0 -0
- /package/dist/{chain_ids.d.ts → esm/chain_ids.d.ts} +0 -0
- /package/dist/{chain_ids.js → esm/chain_ids.js} +0 -0
- /package/dist/{errors.d.ts → esm/errors.d.ts} +0 -0
- /package/dist/{errors.js → esm/errors.js} +0 -0
- /package/dist/{evm → esm/evm}/evm_address.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_address.js +0 -0
- /package/dist/{evm → esm/evm}/evm_chain.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_chain.js +0 -0
- /package/dist/{evm → esm/evm}/evm_chains.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_chains.js +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_estimate.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_estimate.js +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_pricing.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_pricing.js +0 -0
- /package/dist/{evm → esm/evm}/evm_token.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_token.js +0 -0
- /package/dist/{evm → esm/evm}/evm_tokens.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_tokens.js +0 -0
- /package/dist/{evm → esm/evm}/evm_transaction_status.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_transaction_status.js +0 -0
- /package/dist/{evm → esm/evm}/index.d.ts +0 -0
- /package/dist/{evm → esm/evm}/index.js +0 -0
- /package/dist/{evm → esm/evm}/unsigned_evm_transaction.d.ts +0 -0
- /package/dist/{evm → esm/evm}/unsigned_evm_transaction.js +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{is_address.decorator.d.ts → esm/is_address.decorator.d.ts} +0 -0
- /package/dist/{is_address.decorator.js → esm/is_address.decorator.js} +0 -0
- /package/dist/{network_type.d.ts → esm/network_type.d.ts} +0 -0
- /package/dist/{network_type.js → esm/network_type.js} +0 -0
- /package/dist/{priority.d.ts → esm/priority.d.ts} +0 -0
- /package/dist/{priority.js → esm/priority.js} +0 -0
- /package/dist/{solana → esm/solana}/index.d.ts +0 -0
- /package/dist/{solana → esm/solana}/index.js +0 -0
- /package/dist/{solana → esm/solana}/solana_address.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_address.js +0 -0
- /package/dist/{solana → esm/solana}/solana_chain.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_chain.js +0 -0
- /package/dist/{solana → esm/solana}/solana_chains.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_chains.js +0 -0
- /package/dist/{solana → esm/solana}/solana_gas_pricing.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_gas_pricing.js +0 -0
- /package/dist/{solana → esm/solana}/solana_token.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_token.js +0 -0
- /package/dist/{solana → esm/solana}/solana_tokens.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_tokens.js +0 -0
- /package/dist/{solana → esm/solana}/solana_transaction_status.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_transaction_status.js +0 -0
- /package/dist/{solana → esm/solana}/unsigned_solana_transaction.d.ts +0 -0
- /package/dist/{solana → esm/solana}/unsigned_solana_transaction.js +0 -0
- /package/dist/{token.d.ts → esm/token.d.ts} +0 -0
- /package/dist/{token.js → esm/token.js} +0 -0
- /package/dist/{ton → esm/ton}/index.d.ts +0 -0
- /package/dist/{ton → esm/ton}/index.js +0 -0
- /package/dist/{ton → esm/ton}/ton_address.d.ts +0 -0
- /package/dist/{ton → esm/ton}/ton_address.js +0 -0
- /package/dist/{transaction_status.d.ts → esm/transaction_status.d.ts} +0 -0
- /package/dist/{transaction_status.js → esm/transaction_status.js} +0 -0
- /package/dist/{unsigned_transaction.d.ts → esm/unsigned_transaction.d.ts} +0 -0
- /package/dist/{unsigned_transaction.js → esm/unsigned_transaction.js} +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_address.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_address.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chain.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chain.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_token.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_token.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/asset_outpoint.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/asset_outpoint.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/bitcoin_core.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/bitcoin_core.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/esplora.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/esplora.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/inscription_index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/inscription_index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/ordiscan.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/ordiscan.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rare_sat_index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rare_sat_index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rune_index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rune_index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/unisat.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/unisat.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/coin_selection.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/coin_selection.js +0 -0
- /package/dist/{utxo → esm/utxo}/doge/doge_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/doge/doge_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/doge/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/doge/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/doge/network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/doge/network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/ecc.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ecc.js +0 -0
- /package/dist/{utxo → esm/utxo}/fee.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/fee.js +0 -0
- /package/dist/{utxo → esm/utxo}/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/ltc_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/ltc_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/script.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/script.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/broadcaster.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/broadcaster.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/chain_tip_provider.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/chain_tip_provider.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/fee_estimator.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/fee_estimator.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/raw_transaction_provider.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/raw_transaction_provider.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/utxo_provider.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/utxo_provider.js +0 -0
- /package/dist/{utxo → esm/utxo}/unsigned_utxo_transaction.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/unsigned_utxo_transaction.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_chain.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_chain.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_gas_pricing.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_gas_pricing.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_transaction_status.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_transaction_status.js +0 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EvmChain = void 0;
|
|
4
|
+
exports.decodeRevertData = decodeRevertData;
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const network_type_ts_1 = require("../network_type.js");
|
|
7
|
+
const chain_base_ts_1 = require("../chain.base.js");
|
|
8
|
+
const errors_ts_1 = require("../errors.js");
|
|
9
|
+
const priority_ts_1 = require("../priority.js");
|
|
10
|
+
const evm_gas_estimate_ts_1 = require("./evm_gas_estimate.js");
|
|
11
|
+
const transaction_status_ts_1 = require("../transaction_status.js");
|
|
12
|
+
const evm_transaction_status_ts_1 = require("./evm_transaction_status.js");
|
|
13
|
+
const evm_address_ts_1 = require("./evm_address.js");
|
|
14
|
+
const evm_token_ts_1 = require("./evm_token.js");
|
|
15
|
+
const unsigned_evm_transaction_ts_1 = require("./unsigned_evm_transaction.js");
|
|
16
|
+
// Priority profile mirrors omnichain-py/impl/evm/base.py:440-444
|
|
17
|
+
// (`_FEE_PRIORITY_PROFILE`): the reward-percentile is used for the 1559
|
|
18
|
+
// path (get_1559_fees's reward_percentile arg); the legacy multiplier
|
|
19
|
+
// applies ONLY when supportsEip1559 is false (Python does not fall back
|
|
20
|
+
// to the multiplier on the 1559 path).
|
|
21
|
+
const PRIORITY_REWARD_PERCENTILE = {
|
|
22
|
+
[priority_ts_1.Priority.SLOW]: 25,
|
|
23
|
+
[priority_ts_1.Priority.NORMAL]: 50,
|
|
24
|
+
[priority_ts_1.Priority.FAST]: 75,
|
|
25
|
+
};
|
|
26
|
+
// Legacy gas-price multiplier per priority tier — for the legacy branch only.
|
|
27
|
+
// Expressed as basis points × 100 so integer bigint arithmetic works.
|
|
28
|
+
const GAS_MULTIPLIER_PCT = {
|
|
29
|
+
[priority_ts_1.Priority.SLOW]: 100n,
|
|
30
|
+
[priority_ts_1.Priority.NORMAL]: 120n,
|
|
31
|
+
[priority_ts_1.Priority.FAST]: 150n,
|
|
32
|
+
};
|
|
33
|
+
// Empty-reward fallback tip: 2 gwei — matches Python `Web3.to_wei(2, 'gwei')`
|
|
34
|
+
// at impl/evm/base.py:1124.
|
|
35
|
+
const EMPTY_REWARD_FALLBACK_TIP = 2000000000n;
|
|
36
|
+
// Number of latest blocks sampled by eth_feeHistory. Python default 10
|
|
37
|
+
// (impl/evm/base.py:1099).
|
|
38
|
+
const FEE_HISTORY_BLOCK_COUNT = 10;
|
|
39
|
+
// Final-tip percentile picked across the sampled blocks after sorting.
|
|
40
|
+
// Python default 90.0 (impl/evm/base.py:1102).
|
|
41
|
+
const FINAL_TIP_PERCENTILE = 90;
|
|
42
|
+
// TS-only safety floor applied to any suggested gas price / tip. Python does
|
|
43
|
+
// NOT enforce a minimum: `sorted_tips[idx]` can be 0 on quiet L2 blocks.
|
|
44
|
+
// Silently unmineable transactions are unacceptable for a signing SDK, so
|
|
45
|
+
// TS clamps to 0.05 gwei.
|
|
46
|
+
const MIN_GAS_PRICE_FLOOR = 50000000n;
|
|
47
|
+
function atLeast(n, min) {
|
|
48
|
+
return n < min ? min : n;
|
|
49
|
+
}
|
|
50
|
+
const ERC20_TRANSFER_TOPIC = evm_transaction_status_ts_1.ERC20_TRANSFER_TOPIC;
|
|
51
|
+
const ERC20_ABI = [
|
|
52
|
+
'function balanceOf(address owner) view returns (uint256)',
|
|
53
|
+
'function decimals() view returns (uint8)',
|
|
54
|
+
'function symbol() view returns (string)',
|
|
55
|
+
'function transfer(address to, uint256 value)',
|
|
56
|
+
];
|
|
57
|
+
const ERC20_INTERFACE = new ethers_1.Interface(ERC20_ABI);
|
|
58
|
+
class EvmChain extends chain_base_ts_1.Chain {
|
|
59
|
+
rpcUrl;
|
|
60
|
+
supportsEip1559;
|
|
61
|
+
hasL1Fee;
|
|
62
|
+
/**
|
|
63
|
+
* Default gas limit for native transfers. Matches Python's public attribute
|
|
64
|
+
* at `impl/evm/base.py:495` — v0 does not consume it inside the TS SDK
|
|
65
|
+
* (see `createTransferUnsignedTransaction`) but exposes it so consumers
|
|
66
|
+
* building their own transfer paths get identical numbers to Python. Wired
|
|
67
|
+
* into the SDK-owned transfer builder in a follow-up branch.
|
|
68
|
+
*/
|
|
69
|
+
nativeTransferGasLimit;
|
|
70
|
+
/**
|
|
71
|
+
* Legacy `eth_gasPrice` multiplier for native transfers on non-1559 chains.
|
|
72
|
+
* Matches Python's public attribute at `impl/evm/base.py:496`. Same
|
|
73
|
+
* "declarative for consumers, unused internally in v0" note as
|
|
74
|
+
* `nativeTransferGasLimit`.
|
|
75
|
+
*/
|
|
76
|
+
nativeTransferGasMultiplier;
|
|
77
|
+
_nativeToken;
|
|
78
|
+
_provider = null;
|
|
79
|
+
_resolvedRpcUrl = null;
|
|
80
|
+
constructor(init) {
|
|
81
|
+
// Conflict guard — refuse to construct an EvmChain over a chainId that
|
|
82
|
+
// the static family seeds have already registered as non-EVM. Prevents
|
|
83
|
+
// the case where `new EvmChain({ chainId: 728126428, … })` would silently
|
|
84
|
+
// succeed and then contradict `addressFor(728126428, …)` /
|
|
85
|
+
// `networkTypeOf(728126428)` (both return TRON). Mirrors
|
|
86
|
+
// `registerNonEvmChain`'s throw-on-conflict guard.
|
|
87
|
+
const existing = (0, network_type_ts_1.tryNetworkTypeOf)(init.chainId);
|
|
88
|
+
if (existing !== undefined && existing !== network_type_ts_1.NetworkType.EVM) {
|
|
89
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `chainId ${init.chainId} is registered as ${existing}; refusing to construct EvmChain for it`, { chainId: init.chainId });
|
|
90
|
+
}
|
|
91
|
+
super(init.chainId, init.name, network_type_ts_1.NetworkType.EVM, init.blockTimeSeconds, init.nativeSymbol, init.explorerBaseUrl);
|
|
92
|
+
this.rpcUrl = init.rpcUrl;
|
|
93
|
+
this.supportsEip1559 = init.supportsEip1559 ?? true;
|
|
94
|
+
this.hasL1Fee = init.hasL1Fee ?? false;
|
|
95
|
+
this.nativeTransferGasLimit = init.nativeTransferGasLimit ?? 21000;
|
|
96
|
+
this.nativeTransferGasMultiplier = init.nativeTransferGasMultiplier ?? 1.4;
|
|
97
|
+
this._nativeToken = evm_token_ts_1.EvmToken.native(init.chainId, init.nativeSymbol, init.nativeDecimals ?? 18);
|
|
98
|
+
// NOTE: no `registerNonEvmChain(id, EVM)` call — a module-scope write on
|
|
99
|
+
// 48 pre-baked chains would let a consumer's earlier
|
|
100
|
+
// `registerNonEvmChain(id, COSMOS)` turn `import '@getomnichain/omnichain'`
|
|
101
|
+
// into a permanently-poisoned module. Conflict detection lives in a
|
|
102
|
+
// single place: `registerNonEvmChain` reads `tryNetworkTypeOf` (which
|
|
103
|
+
// synthesizes EVM for positive-unregistered ids), so claiming a positive
|
|
104
|
+
// id for a non-EVM family requires `unregisterChain(id)` first.
|
|
105
|
+
}
|
|
106
|
+
get nativeToken() {
|
|
107
|
+
return this._nativeToken;
|
|
108
|
+
}
|
|
109
|
+
getErc20Token(symbol, contractAddress, decimals) {
|
|
110
|
+
// `EvmToken.erc20` → `new EvmToken` normalizes the identifier internally;
|
|
111
|
+
// no need to checksum here as well.
|
|
112
|
+
return evm_token_ts_1.EvmToken.erc20(this.chainId, symbol, contractAddress, decimals);
|
|
113
|
+
}
|
|
114
|
+
getProvider() {
|
|
115
|
+
if (this._provider)
|
|
116
|
+
return this._provider;
|
|
117
|
+
const rpcUrl = this.readRpcUrl();
|
|
118
|
+
this._resolvedRpcUrl = rpcUrl;
|
|
119
|
+
this._provider = new ethers_1.JsonRpcProvider(rpcUrl);
|
|
120
|
+
return this._provider;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Suggest gas fees for a priority tier. Mirrors Python's `_resolve_gas_pricing`
|
|
124
|
+
* dispatch (impl/evm/base.py:807-833):
|
|
125
|
+
*
|
|
126
|
+
* - legacy chains (`supportsEip1559 === false`): scale `eth_gasPrice` by
|
|
127
|
+
* the priority tier's legacy multiplier.
|
|
128
|
+
* - 1559 chains: sample eth_feeHistory across the last 10 blocks at the
|
|
129
|
+
* tier's reward percentile, sort, pick the p90 across blocks. On empty
|
|
130
|
+
* rewards, use 2 gwei. On RPC failure, bubble as `ChainError(RpcError)`
|
|
131
|
+
* (Python bubbles too — no defensive fallback).
|
|
132
|
+
*/
|
|
133
|
+
async suggestGas(priority) {
|
|
134
|
+
const provider = this.getProvider();
|
|
135
|
+
if (!this.supportsEip1559) {
|
|
136
|
+
const mult = GAS_MULTIPLIER_PCT[priority];
|
|
137
|
+
// Direct `eth_gasPrice` — one round-trip, matches Python
|
|
138
|
+
// impl/evm/base.py:831-833. Avoids getFeeData's implicit
|
|
139
|
+
// `getBlock("latest")` + potential `eth_maxPriorityFeePerGas` extra
|
|
140
|
+
// calls, and dodges the trap where getFeeData's maxFeePerGas is
|
|
141
|
+
// `2×baseFee + tip` (not a legacy price) — using that as the legacy
|
|
142
|
+
// gasPrice would 3-4× overpay.
|
|
143
|
+
let gasPriceHex;
|
|
144
|
+
try {
|
|
145
|
+
gasPriceHex = (await provider.send('eth_gasPrice', []));
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
throw this.rpcError('legacy eth_gasPrice transport failed', err);
|
|
149
|
+
}
|
|
150
|
+
let providerHint;
|
|
151
|
+
try {
|
|
152
|
+
providerHint = BigInt(gasPriceHex);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// Genuinely unparseable response — bubble as RpcError so on-call
|
|
156
|
+
// triage sees the RPC returned nonsense, not "0 gas price".
|
|
157
|
+
throw this.rpcError(`legacy eth_gasPrice returned unparseable response`, new Error(`could not parse ${String(gasPriceHex)} as bigint`));
|
|
158
|
+
}
|
|
159
|
+
// Zero-or-negative gasPrice: clamp up to MIN_GAS_PRICE_FLOOR, mirroring
|
|
160
|
+
// the 1559 branch's floor-on-sub-floor-tips behavior (evm_chain.ts:307).
|
|
161
|
+
// Python (`impl/evm/base.py:831-833`) multiplies whatever `eth_gasPrice`
|
|
162
|
+
// returns and never throws; the TS floor is the safety measure that
|
|
163
|
+
// prevents an unmineable suggestion. Consistent policy across branches.
|
|
164
|
+
const base = providerHint > 0n ? providerHint : MIN_GAS_PRICE_FLOOR;
|
|
165
|
+
const scaled = atLeast((base * mult) / 100n, MIN_GAS_PRICE_FLOOR);
|
|
166
|
+
// Legacy chains: only `gasPrice` is authoritative — matches Python
|
|
167
|
+
// (`impl/evm/base.py:830-833` returns `EvmGasPricing(gas_price=...)`).
|
|
168
|
+
// Populating maxFeePerGas/maxPriorityFeePerGas as duplicates would let
|
|
169
|
+
// a consumer build a type-2 tx paying the full gasPrice as a tip on
|
|
170
|
+
// top of base fee.
|
|
171
|
+
return new evm_gas_estimate_ts_1.EvmGasEstimate({ kind: 'legacy', gasPrice: scaled });
|
|
172
|
+
}
|
|
173
|
+
// 1559 path — mirrors omnichain-py get_1559_fees (impl/evm/base.py:1098-1132).
|
|
174
|
+
// NB: Python reads `base_fee_per_gas` from `eth_getBlock("latest")` (line
|
|
175
|
+
// 1109-1110); TS reuses `feeHistory.baseFeePerGas[-1]` — the JSON-RPC
|
|
176
|
+
// "next block projection", up to ±12.5% off. Deliberate: saves an RPC
|
|
177
|
+
// round-trip. (See the local SINAN questions doc for the upstream
|
|
178
|
+
// discussion — TS uses feeHistory's projection to skip the extra RPC.)
|
|
179
|
+
const rewardPercentile = PRIORITY_REWARD_PERCENTILE[priority];
|
|
180
|
+
let raw;
|
|
181
|
+
// Narrow try — only the RPC call. Response-shape and parse errors are
|
|
182
|
+
// distinct from transport failures and get a distinct ChainError kind.
|
|
183
|
+
try {
|
|
184
|
+
raw = (await provider.send('eth_feeHistory', [
|
|
185
|
+
`0x${FEE_HISTORY_BLOCK_COUNT.toString(16)}`,
|
|
186
|
+
'latest',
|
|
187
|
+
[rewardPercentile],
|
|
188
|
+
]));
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
throw this.rpcError('eth_feeHistory transport failed', err);
|
|
192
|
+
}
|
|
193
|
+
// Narrow parse — only the shape checks + BigInt() coercions can throw
|
|
194
|
+
// for structural reasons here. `EvmGasEstimate` construction and the
|
|
195
|
+
// pure-arithmetic tip selection happen outside so that a defect there
|
|
196
|
+
// isn't mislabelled as an RPC-response malformed error.
|
|
197
|
+
let latestBaseFee;
|
|
198
|
+
let tips;
|
|
199
|
+
try {
|
|
200
|
+
const baseFees = raw.baseFeePerGas;
|
|
201
|
+
if (!Array.isArray(baseFees) || baseFees.length === 0) {
|
|
202
|
+
throw new Error('missing baseFeePerGas');
|
|
203
|
+
}
|
|
204
|
+
latestBaseFee = BigInt(baseFees[baseFees.length - 1] ?? '0x0');
|
|
205
|
+
const rewardRows = Array.isArray(raw.reward) ? raw.reward : [];
|
|
206
|
+
tips = rewardRows
|
|
207
|
+
.map((row) => (Array.isArray(row) ? row[0] : undefined))
|
|
208
|
+
.filter((v) => typeof v === 'string')
|
|
209
|
+
.map((v) => BigInt(v));
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
// Distinct from the RpcError raised by the provider.send catch above:
|
|
213
|
+
// parse/shape failures indict the response, not the transport. Routed
|
|
214
|
+
// through rpcError() so the URL sanitizer scrubs the response body.
|
|
215
|
+
throw this.rpcError(`eth_feeHistory response malformed`, err);
|
|
216
|
+
}
|
|
217
|
+
let selectedTip;
|
|
218
|
+
if (tips.length === 0) {
|
|
219
|
+
selectedTip = EMPTY_REWARD_FALLBACK_TIP;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
const sortedTips = [...tips].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
223
|
+
const idx = Math.min(Math.floor((sortedTips.length * FINAL_TIP_PERCENTILE) / 100), sortedTips.length - 1);
|
|
224
|
+
selectedTip = sortedTips[idx] ?? 0n;
|
|
225
|
+
}
|
|
226
|
+
// TS safety floor — Python doesn't clamp (see MIN_GAS_PRICE_FLOOR).
|
|
227
|
+
const finalTip = atLeast(selectedTip, MIN_GAS_PRICE_FLOOR);
|
|
228
|
+
// Safety buffer: base fee can climb 12.5%/block; caller may wait multiple blocks.
|
|
229
|
+
const maxFeePerGas = latestBaseFee * 2n + finalTip;
|
|
230
|
+
return new evm_gas_estimate_ts_1.EvmGasEstimate({
|
|
231
|
+
kind: 'eip1559',
|
|
232
|
+
maxPriorityFeePerGas: finalTip,
|
|
233
|
+
maxFeePerGas,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
readRpcUrl() {
|
|
237
|
+
if (this.rpcUrl && this.rpcUrl.trim().length > 0)
|
|
238
|
+
return this.rpcUrl.trim();
|
|
239
|
+
const env = globalThis.process?.env;
|
|
240
|
+
const candidates = envCandidatesFor(this.name, this.chainId);
|
|
241
|
+
for (const key of candidates) {
|
|
242
|
+
const value = env?.[key];
|
|
243
|
+
if (value && value.trim().length > 0)
|
|
244
|
+
return value.trim();
|
|
245
|
+
}
|
|
246
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcNotConfigured, `${this.name} RPC URL is not configured (pass rpcUrl at construction, or set one of: ${candidates.join(', ')})`, { chainId: this.chainId, envCandidates: candidates });
|
|
247
|
+
}
|
|
248
|
+
rpcHost() {
|
|
249
|
+
const url = this._resolvedRpcUrl ?? this.rpcUrl;
|
|
250
|
+
if (!url)
|
|
251
|
+
return undefined;
|
|
252
|
+
try {
|
|
253
|
+
const u = new URL(url);
|
|
254
|
+
return `${u.protocol}//${u.host}`;
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
getWalletExplorerUrl(address) {
|
|
261
|
+
return `${this.explorerBaseUrl}/address/${address}`;
|
|
262
|
+
}
|
|
263
|
+
getTokenExplorerUrl(tokenIdentifier) {
|
|
264
|
+
if (tokenIdentifier === undefined) {
|
|
265
|
+
return this.explorerBaseUrl;
|
|
266
|
+
}
|
|
267
|
+
return `${this.explorerBaseUrl}/token/${tokenIdentifier}`;
|
|
268
|
+
}
|
|
269
|
+
getTransactionExplorerUrl(txHash) {
|
|
270
|
+
const prefixed = txHash.startsWith('0x') ? txHash : `0x${txHash}`;
|
|
271
|
+
return `${this.explorerBaseUrl}/tx/${prefixed}`;
|
|
272
|
+
}
|
|
273
|
+
validateAddress(raw) {
|
|
274
|
+
try {
|
|
275
|
+
new evm_address_ts_1.EvmAddress(raw);
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
validateTokenIdentifier(raw) {
|
|
283
|
+
if (raw === undefined)
|
|
284
|
+
return true;
|
|
285
|
+
return this.validateAddress(raw);
|
|
286
|
+
}
|
|
287
|
+
async getBalance(owner, tokenIdentifier) {
|
|
288
|
+
if (!this.validateAddress(owner)) {
|
|
289
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid EVM address: ${owner}`, {
|
|
290
|
+
chainId: this.chainId,
|
|
291
|
+
address: owner,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (!this.validateTokenIdentifier(tokenIdentifier)) {
|
|
295
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `Invalid EVM token identifier: ${tokenIdentifier}`, { chainId: this.chainId, identifier: tokenIdentifier });
|
|
296
|
+
}
|
|
297
|
+
const provider = this.getProvider();
|
|
298
|
+
try {
|
|
299
|
+
if (tokenIdentifier === undefined) {
|
|
300
|
+
return await provider.getBalance(owner);
|
|
301
|
+
}
|
|
302
|
+
const contract = new ethers_1.Contract(tokenIdentifier, ERC20_ABI, provider);
|
|
303
|
+
return (await contract.balanceOf(owner));
|
|
304
|
+
}
|
|
305
|
+
catch (err) {
|
|
306
|
+
throw this.rpcError(`Failed to read balance for ${owner}`, err);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
async createTransferUnsignedTransaction(req) {
|
|
310
|
+
if (!this.validateAddress(req.to)) {
|
|
311
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid recipient address: ${req.to}`, {
|
|
312
|
+
chainId: this.chainId,
|
|
313
|
+
address: req.to,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (req.from !== undefined && !this.validateAddress(req.from)) {
|
|
317
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid sender address: ${req.from}`, {
|
|
318
|
+
chainId: this.chainId,
|
|
319
|
+
address: req.from,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (!this.validateTokenIdentifier(req.tokenIdentifier)) {
|
|
323
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `Invalid token identifier: ${req.tokenIdentifier}`, { chainId: this.chainId, identifier: req.tokenIdentifier });
|
|
324
|
+
}
|
|
325
|
+
// gasPricing is on the CreateTransferRequest interface (Python
|
|
326
|
+
// parity) but per-chain wiring is deferred to a follow-up card.
|
|
327
|
+
// Rejecting it here rather than silently ignoring — a money knob
|
|
328
|
+
// that fails open is worse than not shipping it.
|
|
329
|
+
if (req.gasPricing !== undefined) {
|
|
330
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'CreateTransferRequest.gasPricing is not yet consumed by EvmChain (Phase 2 follow-up). Use ethers tx builder options directly for now.', { chainId: this.chainId });
|
|
331
|
+
}
|
|
332
|
+
// isFullBalance is on the CreateTransferRequest interface (Python
|
|
333
|
+
// parity) but needs a fee-reserve computation before it can be
|
|
334
|
+
// safely wired — sending `value = balance` on native leaves 0 for
|
|
335
|
+
// gas → guaranteed insufficient-funds; on SPL it leaves 0 for rent.
|
|
336
|
+
// Deferred to a follow-up card that lands the estimated-fee subtract.
|
|
337
|
+
if (req.isFullBalance === true) {
|
|
338
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'CreateTransferRequest.isFullBalance is not yet supported on EvmChain — pass `amount` or `amountHr` explicitly and reserve fees yourself.', { chainId: this.chainId });
|
|
339
|
+
}
|
|
340
|
+
// Only fetch decimals when amountHr is the input form — avoids two
|
|
341
|
+
// extra eth_calls on every bigint-amount transfer. Native path uses
|
|
342
|
+
// the SDK-declared decimals; ERC-20 path uses a STRICT resolver
|
|
343
|
+
// that throws on RPC failure (the defensive fallback to decimals=0
|
|
344
|
+
// would silently produce a wildly wrong minor-units amount).
|
|
345
|
+
let tokenDecimals = 0;
|
|
346
|
+
if (req.amountHr !== undefined) {
|
|
347
|
+
tokenDecimals =
|
|
348
|
+
req.tokenIdentifier === undefined
|
|
349
|
+
? this._nativeToken.decimals
|
|
350
|
+
: await this.resolveErc20DecimalsStrict(req.tokenIdentifier);
|
|
351
|
+
}
|
|
352
|
+
const resolved = (0, chain_base_ts_1.resolveTransferAmount)(req, tokenDecimals);
|
|
353
|
+
const amountMr = resolved.kind === 'exact' ? resolved.amountMr : 0n;
|
|
354
|
+
if (req.tokenIdentifier === undefined) {
|
|
355
|
+
return new unsigned_evm_transaction_ts_1.UnsignedEvmTransaction({
|
|
356
|
+
chainId: this.chainId,
|
|
357
|
+
from: req.from,
|
|
358
|
+
to: req.to,
|
|
359
|
+
value: amountMr,
|
|
360
|
+
data: '0x',
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
const data = ERC20_INTERFACE.encodeFunctionData('transfer', [req.to, amountMr]);
|
|
364
|
+
return new unsigned_evm_transaction_ts_1.UnsignedEvmTransaction({
|
|
365
|
+
chainId: this.chainId,
|
|
366
|
+
from: req.from,
|
|
367
|
+
to: req.tokenIdentifier,
|
|
368
|
+
value: 0n,
|
|
369
|
+
data,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
async getChainTipHeight() {
|
|
373
|
+
try {
|
|
374
|
+
return await this.getProvider().getBlockNumber();
|
|
375
|
+
}
|
|
376
|
+
catch (err) {
|
|
377
|
+
throw this.rpcError('Failed to read chain tip', err);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
async getTransactionStatus(txHash) {
|
|
381
|
+
const provider = this.getProvider();
|
|
382
|
+
let tx = null;
|
|
383
|
+
let receipt = null;
|
|
384
|
+
try {
|
|
385
|
+
[tx, receipt] = await Promise.all([
|
|
386
|
+
provider.getTransaction(txHash),
|
|
387
|
+
provider.getTransactionReceipt(txHash),
|
|
388
|
+
]);
|
|
389
|
+
}
|
|
390
|
+
catch (err) {
|
|
391
|
+
throw this.rpcError(`Failed to read tx ${txHash}`, err, { txHash });
|
|
392
|
+
}
|
|
393
|
+
if (tx === null && receipt === null)
|
|
394
|
+
return evm_transaction_status_ts_1.EvmTransactionStatus.notFound(this.chainId, null);
|
|
395
|
+
if (receipt === null)
|
|
396
|
+
return evm_transaction_status_ts_1.EvmTransactionStatus.pending(this.chainId);
|
|
397
|
+
// Receipt exists but the tx body doesn't — real race on load-balanced/
|
|
398
|
+
// pruned RPC endpoints where getTransactionReceipt succeeds while
|
|
399
|
+
// getTransactionByHash returns null. `tx.value` and `tx.to` are load-
|
|
400
|
+
// bearing for the native transfer legs of decodeBalanceChanges; falling
|
|
401
|
+
// back to `?? 0n` / `?? null` would emit a Success with a silently
|
|
402
|
+
// truncated balanceChanges map (recipient row missing entirely,
|
|
403
|
+
// sender debit off by the transfer value). Python parity: omnichain-py's
|
|
404
|
+
// impl/evm/base.py accesses `tx.value` directly and blows up on a
|
|
405
|
+
// missing body. TS returns Pending — receipt-only is transient node
|
|
406
|
+
// state; the consumer's next poll will land on a node with the full tx.
|
|
407
|
+
if (tx === null)
|
|
408
|
+
return evm_transaction_status_ts_1.EvmTransactionStatus.pending(this.chainId);
|
|
409
|
+
const succeeded = receipt.status === 1;
|
|
410
|
+
// Parallelize the two independent post-receipt lookups: getBlock (for
|
|
411
|
+
// inclusionAt) and the OP-stack raw-receipt fetch (for l1Fee). Both
|
|
412
|
+
// depend only on receipt.blockNumber / txHash, not on each other.
|
|
413
|
+
const [inclusionAt, l1Fee] = await Promise.all([
|
|
414
|
+
(async () => {
|
|
415
|
+
try {
|
|
416
|
+
const block = await provider.getBlock(receipt.blockNumber);
|
|
417
|
+
if (block?.timestamp !== undefined) {
|
|
418
|
+
return new Date(Number(block.timestamp) * 1000);
|
|
419
|
+
}
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
// leave null — a 1970-01-01 sentinel would silently pass
|
|
424
|
+
// through consumer SLA/age math as a real inclusion time.
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
})(),
|
|
428
|
+
(async () => {
|
|
429
|
+
// OP-stack rollups charge an L1 data fee (`l1Fee` on the raw
|
|
430
|
+
// receipt). ethers v6 strips it in its parsed TransactionReceipt
|
|
431
|
+
// shape, so a second raw fetch is required. Gated on `hasL1Fee`.
|
|
432
|
+
// Return undefined for "provider did not surface it" (either
|
|
433
|
+
// hasL1Fee=false or the raw send failed/omitted the field) —
|
|
434
|
+
// tracked separately from "l1Fee is genuinely 0n" so
|
|
435
|
+
// fees.l1FeeWei reflects presence, not value.
|
|
436
|
+
if (!this.hasL1Fee)
|
|
437
|
+
return undefined;
|
|
438
|
+
try {
|
|
439
|
+
const raw = (await provider.send('eth_getTransactionReceipt', [txHash]));
|
|
440
|
+
const rawL1 = raw?.l1Fee;
|
|
441
|
+
if (rawL1 === undefined || rawL1 === null)
|
|
442
|
+
return undefined;
|
|
443
|
+
if (typeof rawL1 === 'bigint')
|
|
444
|
+
return rawL1;
|
|
445
|
+
if (typeof rawL1 === 'number')
|
|
446
|
+
return BigInt(rawL1);
|
|
447
|
+
if (typeof rawL1 === 'string' && rawL1.length > 0)
|
|
448
|
+
return BigInt(rawL1);
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
return undefined;
|
|
453
|
+
}
|
|
454
|
+
})(),
|
|
455
|
+
]);
|
|
456
|
+
// gasLimit: the sender-set limit from tx.gasLimit. `null` when the tx
|
|
457
|
+
// body isn't available (pruned/receipt-only) — falling back to
|
|
458
|
+
// receipt.gasUsed here would fabricate a "100% utilization" that
|
|
459
|
+
// consumers can't distinguish from a real observation.
|
|
460
|
+
const fees = new evm_transaction_status_ts_1.EvmTransactionGasFees({
|
|
461
|
+
gasLimit: tx?.gasLimit ?? null,
|
|
462
|
+
gasLimitUsed: receipt.gasUsed,
|
|
463
|
+
effectiveGasPrice: receipt.gasPrice,
|
|
464
|
+
gasPrice: tx?.gasPrice ?? undefined,
|
|
465
|
+
maxFeePerGas: tx?.maxFeePerGas ?? undefined,
|
|
466
|
+
maxPriorityFeePerGas: tx?.maxPriorityFeePerGas ?? undefined,
|
|
467
|
+
l1FeeWei: l1Fee,
|
|
468
|
+
});
|
|
469
|
+
if (!succeeded) {
|
|
470
|
+
const errorInfo = await extractRevertInfo(provider, tx, receipt);
|
|
471
|
+
return evm_transaction_status_ts_1.EvmTransactionStatus.failed({
|
|
472
|
+
chainId: this.chainId,
|
|
473
|
+
inclusionAt,
|
|
474
|
+
error: errorInfo,
|
|
475
|
+
fees,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
// Only allocated on the Success path — failed txs carry logs: null.
|
|
479
|
+
const logs = (receipt.logs ?? []).map((l) => new evm_transaction_status_ts_1.EvmParsedTransactionLog(l.address, [...l.topics], l.data));
|
|
480
|
+
const nativeValue = tx?.value ?? 0n;
|
|
481
|
+
let balanceChanges;
|
|
482
|
+
try {
|
|
483
|
+
balanceChanges = await this.decodeBalanceChanges({
|
|
484
|
+
from: tx ? tx.from : (receipt.from ?? ''),
|
|
485
|
+
to: tx?.to ?? receipt.to ?? null,
|
|
486
|
+
value: nativeValue,
|
|
487
|
+
gasCost: fees.totalNativeDebitWei,
|
|
488
|
+
receipt,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
if (err instanceof errors_ts_1.ChainError)
|
|
493
|
+
throw err;
|
|
494
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.TransactionDecodeFailed, `Failed to decode receipt logs for tx ${txHash}`, { chainId: this.chainId, txHash, rpcHost: this.rpcHost() }, err);
|
|
495
|
+
}
|
|
496
|
+
return evm_transaction_status_ts_1.EvmTransactionStatus.successful({
|
|
497
|
+
chainId: this.chainId,
|
|
498
|
+
inclusionAt,
|
|
499
|
+
balanceChanges,
|
|
500
|
+
logs,
|
|
501
|
+
fees,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
async decodeBalanceChanges(args) {
|
|
505
|
+
const { from, to, value, gasCost, receipt } = args;
|
|
506
|
+
if (!receipt || !Array.isArray(receipt.logs)) {
|
|
507
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.TransactionDecodeFailed, 'Receipt is missing required fields', { chainId: this.chainId, txHash: receipt?.hash, rpcHost: this.rpcHost() });
|
|
508
|
+
}
|
|
509
|
+
const rawChanges = new Map();
|
|
510
|
+
const fromAddr = (from ?? '').toLowerCase();
|
|
511
|
+
const toAddr = to ? to.toLowerCase() : null;
|
|
512
|
+
// Sender's native debit = value + gasCost (matches Python
|
|
513
|
+
// impl/evm/base.py:_get_balance_changes fee-inclusive semantics).
|
|
514
|
+
// Credit toAddr whenever value>0 — for self-transfers (from===to) the
|
|
515
|
+
// per-(wallet,token) netting in upsert cancels the +value against the
|
|
516
|
+
// -value component of the debit, leaving the -gasCost we actually want.
|
|
517
|
+
if (fromAddr) {
|
|
518
|
+
addRaw(rawChanges, fromAddr, '', -(value + gasCost));
|
|
519
|
+
}
|
|
520
|
+
if (value > 0n && toAddr) {
|
|
521
|
+
addRaw(rawChanges, toAddr, '', value);
|
|
522
|
+
}
|
|
523
|
+
const tokenContracts = new Set();
|
|
524
|
+
const transferLogs = [];
|
|
525
|
+
for (const log of receipt.logs) {
|
|
526
|
+
if (log.topics.length !== 3)
|
|
527
|
+
continue;
|
|
528
|
+
if (log.topics[0].toLowerCase() !== ERC20_TRANSFER_TOPIC)
|
|
529
|
+
continue;
|
|
530
|
+
const contractAddr = log.address.toLowerCase();
|
|
531
|
+
const logFrom = `0x${log.topics[1].slice(26)}`.toLowerCase();
|
|
532
|
+
const logTo = `0x${log.topics[2].slice(26)}`.toLowerCase();
|
|
533
|
+
let amount;
|
|
534
|
+
try {
|
|
535
|
+
amount = BigInt(log.data);
|
|
536
|
+
}
|
|
537
|
+
catch {
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
tokenContracts.add(contractAddr);
|
|
541
|
+
transferLogs.push({ contract: contractAddr, from: logFrom, to: logTo, amount });
|
|
542
|
+
}
|
|
543
|
+
const tokensByContract = new Map();
|
|
544
|
+
const resolved = await Promise.all([...tokenContracts].map((addr) => this.resolveErc20TokenDefensive(addr).then((t) => ({ addr, token: t }))));
|
|
545
|
+
for (const { addr, token } of resolved)
|
|
546
|
+
tokensByContract.set(addr, token);
|
|
547
|
+
for (const t of transferLogs) {
|
|
548
|
+
// Symmetric with the native path: always add both legs. Self-transfer
|
|
549
|
+
// nets to zero at the per-(wallet, contract) map level and is dropped
|
|
550
|
+
// by the `delta === 0n` filter below — the explicit gate here would
|
|
551
|
+
// over-suppress the credit if a future decoder gained non-cancelling
|
|
552
|
+
// side effects.
|
|
553
|
+
addRaw(rawChanges, t.from, t.contract, -t.amount);
|
|
554
|
+
addRaw(rawChanges, t.to, t.contract, t.amount);
|
|
555
|
+
}
|
|
556
|
+
const result = new Map();
|
|
557
|
+
for (const [wallet, perTokenAddr] of rawChanges) {
|
|
558
|
+
for (const [tokenAddr, delta] of perTokenAddr) {
|
|
559
|
+
if (delta === 0n)
|
|
560
|
+
continue;
|
|
561
|
+
const token = tokenAddr === '' ? this._nativeToken : tokensByContract.get(tokenAddr);
|
|
562
|
+
if (!token)
|
|
563
|
+
continue;
|
|
564
|
+
transaction_status_ts_1.AssetBalanceChange.upsert(result, wallet, token, transaction_status_ts_1.AssetBalanceChange.fromMr(delta, token.decimals));
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return result;
|
|
568
|
+
}
|
|
569
|
+
async resolveErc20TokenDefensive(contractAddress) {
|
|
570
|
+
const checksum = (() => {
|
|
571
|
+
try {
|
|
572
|
+
return new evm_address_ts_1.EvmAddress(contractAddress).toChecksum();
|
|
573
|
+
}
|
|
574
|
+
catch {
|
|
575
|
+
return contractAddress;
|
|
576
|
+
}
|
|
577
|
+
})();
|
|
578
|
+
const placeholder = () => new evm_token_ts_1.EvmToken(this.chainId, `UNKNOWN_${checksum.slice(2, 8)}`, checksum, 0);
|
|
579
|
+
let provider;
|
|
580
|
+
try {
|
|
581
|
+
provider = this.getProvider();
|
|
582
|
+
}
|
|
583
|
+
catch {
|
|
584
|
+
return placeholder();
|
|
585
|
+
}
|
|
586
|
+
const contract = new ethers_1.Contract(contractAddress, ERC20_ABI, provider);
|
|
587
|
+
try {
|
|
588
|
+
const [symbol, decimals] = await Promise.all([
|
|
589
|
+
contract.symbol(),
|
|
590
|
+
contract.decimals(),
|
|
591
|
+
]);
|
|
592
|
+
return new evm_token_ts_1.EvmToken(this.chainId, symbol, checksum, Number(decimals));
|
|
593
|
+
}
|
|
594
|
+
catch {
|
|
595
|
+
return placeholder();
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* STRICT decimals resolver for the transfer builder — throws
|
|
600
|
+
* `ChainError(RpcError)` on any failure to reach the contract.
|
|
601
|
+
* Used exclusively when converting `amountHr: Decimal` →
|
|
602
|
+
* `amountMr: bigint`, where a defensive fallback to `decimals=0`
|
|
603
|
+
* would silently sign a transaction for a wildly wrong amount
|
|
604
|
+
* (e.g. `1.5 USDC` → `1n` minor units instead of `1_500_000n`).
|
|
605
|
+
* The receipt-decoder still uses the defensive variant, since a
|
|
606
|
+
* placeholder token there is a display concern, not a money one.
|
|
607
|
+
*/
|
|
608
|
+
async resolveErc20DecimalsStrict(contractAddress) {
|
|
609
|
+
const provider = this.getProvider();
|
|
610
|
+
const contract = new ethers_1.Contract(contractAddress, ERC20_ABI, provider);
|
|
611
|
+
try {
|
|
612
|
+
const decimals = (await contract.decimals());
|
|
613
|
+
return Number(decimals);
|
|
614
|
+
}
|
|
615
|
+
catch (err) {
|
|
616
|
+
throw this.rpcError(`Failed to read ERC-20 decimals for ${contractAddress}`, err);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
rpcError(message, cause, extra = {}) {
|
|
620
|
+
const sanitizedMessage = (0, errors_ts_1.sanitizeMessage)(`${message}: ${stringifyErr(cause)}`, this._resolvedRpcUrl);
|
|
621
|
+
return new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, sanitizedMessage, { chainId: this.chainId, rpcHost: this.rpcHost(), ...extra }, (0, errors_ts_1.sanitizeCause)(cause, this._resolvedRpcUrl));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
exports.EvmChain = EvmChain;
|
|
625
|
+
function addRaw(container, wallet, tokenAddr, delta) {
|
|
626
|
+
let perToken = container.get(wallet);
|
|
627
|
+
if (!perToken) {
|
|
628
|
+
perToken = new Map();
|
|
629
|
+
container.set(wallet, perToken);
|
|
630
|
+
}
|
|
631
|
+
perToken.set(tokenAddr, (perToken.get(tokenAddr) ?? 0n) + delta);
|
|
632
|
+
}
|
|
633
|
+
const ERROR_STRING_SELECTOR = '0x08c379a0';
|
|
634
|
+
const PANIC_UINT256_SELECTOR = '0x4e487b71';
|
|
635
|
+
const ABI_CODER = ethers_1.AbiCoder.defaultAbiCoder();
|
|
636
|
+
function decodeRevertData(data) {
|
|
637
|
+
if (typeof data !== 'string' || data.length < 10)
|
|
638
|
+
return undefined;
|
|
639
|
+
const selector = data.slice(0, 10).toLowerCase();
|
|
640
|
+
const payload = '0x' + data.slice(10);
|
|
641
|
+
if (selector === ERROR_STRING_SELECTOR) {
|
|
642
|
+
try {
|
|
643
|
+
const reason = ABI_CODER.decode(['string'], payload)[0];
|
|
644
|
+
return typeof reason === 'string' ? reason : undefined;
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
return undefined;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
if (selector === PANIC_UINT256_SELECTOR) {
|
|
651
|
+
try {
|
|
652
|
+
const code = ABI_CODER.decode(['uint256'], payload)[0];
|
|
653
|
+
return typeof code === 'bigint' ? `Panic(0x${code.toString(16)})` : undefined;
|
|
654
|
+
}
|
|
655
|
+
catch {
|
|
656
|
+
return undefined;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return undefined;
|
|
660
|
+
}
|
|
661
|
+
async function extractRevertInfo(provider, tx, receipt) {
|
|
662
|
+
if (!tx)
|
|
663
|
+
return { code: 'REVERTED' };
|
|
664
|
+
try {
|
|
665
|
+
await provider.call({
|
|
666
|
+
from: tx.from,
|
|
667
|
+
to: tx.to ?? undefined,
|
|
668
|
+
data: tx.data,
|
|
669
|
+
value: tx.value,
|
|
670
|
+
blockTag: receipt.blockNumber,
|
|
671
|
+
});
|
|
672
|
+
return { code: 'REVERTED' };
|
|
673
|
+
}
|
|
674
|
+
catch (err) {
|
|
675
|
+
const data = err?.data ??
|
|
676
|
+
err?.info?.error?.data;
|
|
677
|
+
const reason = typeof data === 'string' ? decodeRevertData(data) : undefined;
|
|
678
|
+
return reason !== undefined ? { code: 'REVERTED', reason } : { code: 'REVERTED' };
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function stringifyErr(err) {
|
|
682
|
+
if (err instanceof Error)
|
|
683
|
+
return err.message;
|
|
684
|
+
return String(err);
|
|
685
|
+
}
|
|
686
|
+
function envCandidatesFor(name, chainId) {
|
|
687
|
+
const normalized = name.replace(/ /g, '_').toUpperCase() + '_RPC_URL';
|
|
688
|
+
return [normalized, `EVM_${chainId}_RPC_URL`];
|
|
689
|
+
}
|
|
690
|
+
//# sourceMappingURL=evm_chain.js.map
|