diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 14:47:23 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 14:47:23 +0000 |
commit | 9ef74b936aea52a36ba684da1f64f4baf37d50b4 (patch) | |
tree | 3aa0208b6fbff6f47bae7dcd17dfdb71b04595c9 | |
parent | 99621254e5ed066122f28a5b6562f3a36ea4b69d (diff) |
automatic import of python-ethtxopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-ethtx.spec | 606 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 608 insertions, 0 deletions
@@ -0,0 +1 @@ +/EthTx-0.3.21.tar.gz diff --git a/python-ethtx.spec b/python-ethtx.spec new file mode 100644 index 0000000..032a839 --- /dev/null +++ b/python-ethtx.spec @@ -0,0 +1,606 @@ +%global _empty_manifest_terminate_build 0 +Name: python-EthTx +Version: 0.3.21 +Release: 1 +Summary: EthTx transaction decoder. +License: Apache-2.0 License +URL: https://github.com/EthTx/ethtx +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/bf/7b/723716abdaeea80f61d2e2006ee677790776306daf12109350bb4e337e27/EthTx-0.3.21.tar.gz +BuildArch: noarch + +Requires: python3-toml +Requires: python3-pymongo +Requires: python3-dnspython +Requires: python3-mongoengine +Requires: python3-mongomock +Requires: python3-web3 +Requires: python3-pydantic +Requires: python3-dotenv +Requires: python3-requests + +%description + +<h1 align='center' style='border-bottom: none'> + <p>EthTx - Ethereum transactions decoder </p> +</h1> + +<p align="center"> +<a target="_blank"> + <img src="https://img.shields.io/badge/Made%20with-Python-1f425f.svg" alt="Python"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black"> +</a> +<a target="_blank"> + <img src="https://badgen.net/badge/Open%20Source%20%3F/Yes%21/blue?icon=github" alt="OpenSource"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="Apache"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/pypi/v/EthTx?label=pypi%20package" alt="EthTxPyPi"> +</a> +</p> + +## Introduction + +Source Code: [https://github.com/ethtx/ethtx](https://github.com/ethtx/ethtx) + +## Installation + +```shell +pip install ethtx +``` + +## Requirements + +The package needs a few external resources, defined in `EthTxConfig` object: + +1. **Erigon/Geth node** - required to have access to the raw Ethereum data; it must be a full archive node with + the `debug` option ON +2. **Etherscan API key** - required to get the source code and ABI for smart contracts used in transaction +3. (Optional) **MongoDB database** - required to store smart contracts' ABI and semantics used in the decoding process. + If you don't want to setup permanent database, you can enter `mongomock://localhost/ethtx`, then in-memory mongo will be + set up that discards all data with every run. + +## Getting started + +```python +from ethtx import EthTx, EthTxConfig +from ethtx.models.decoded_model import DecodedTransaction + +ethtx_config = EthTxConfig( + mongo_connection_string="mongomock://localhost/ethtx", ##MongoDB connection string, + etherscan_api_key="", ##Etherscan API key, + web3nodes={ + "mainnet": { + "hook": "_Geth_archive_node_URL_", # multiple nodes supported, separate them with comma + "poa": _POA_chain_indicator_ # represented by bool value + } + }, + default_chain="mainnet", + etherscan_urls={"mainnet": "https://api.etherscan.io/api", }, +) + +ethtx = EthTx.initialize(ethtx_config) +decoded_transaction: DecodedTransaction = ethtx.decoders.decode_transaction( + '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d') +``` + +## Features + +EthTx most important functions: + +1. Raw node data access: + +```python +web3provider = ethtx.providers.web3provider + +from ethtx.models.w3_model import W3Transaction, W3Block, W3Receipt, W3CallTree + +# read raw transaction data directly from the node +w3transaction: W3Transaction = web3provider.get_transaction( + '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d') +w3block: W3Block = web3provider.get_block(w3transaction.blockNumber) +w3receipt: W3Receipt = web3provider.get_receipt(w3transaction.hash.hex()) +w3calls: W3CallTree = web3provider.get_calls(w3transaction.hash.hex()) +``` + +2. ABI decoding: + +```python +from ethtx.models.decoded_model import ( + DecodedTransfer, + DecodedBalance, + DecodedEvent, DecodedCall, +) +from ethtx.models.objects_model import Transaction, Event, Block, Call + +# read the raw transaction from the node +transaction = Transaction.from_raw( + w3transaction=w3transaction, w3receipt=w3receipt, w3calltree=w3calls +) + +# get proxies used in the transaction +proxies = ethtx.decoders.get_proxies(transaction.root_call, "mainnet") + +block: Block = Block.from_raw( + w3block=web3provider.get_block(transaction.metadata.block_number), + chain_id="mainnet", +) + +# decode transaction components +abi_decoded_events: List[Event] = ethtx.decoders.abi_decoder.decode_events( + transaction.events, block.metadata, transaction.metadata +) +abi_decoded_calls: DecodedCall = ethtx.decoders.abi_decoder.decode_calls( + transaction.root_call, block.metadata, transaction.metadata, proxies +) +abi_decoded_transfers: List[ + DecodedTransfer +] = ethtx.decoders.abi_decoder.decode_transfers(abi_decoded_calls, abi_decoded_events) +abi_decoded_balances: List[DecodedBalance] = ethtx.decoders.abi_decoder.decode_balances( + abi_decoded_transfers +) + +# decode a single event +raw_event: Event = transaction.events[3] +abi_decoded_event: DecodedEvent = ethtx.decoders.abi_decoder.decode_event( + raw_event, block.metadata, transaction.metadata +) + +# decode a single call +raw_call: Call = transaction.root_call.subcalls[0] +abi_decoded_call: DecodedCall = ethtx.decoders.abi_decoder.decode_call( + raw_call, block.metadata, transaction.metadata, proxies +) +``` + +3. Semantic decoding: + +```python +from ethtx.models.decoded_model import DecodedTransactionMetadata + +# semantically decode transaction components +decoded_metadata: DecodedTransactionMetadata = ( + ethtx.decoders.semantic_decoder.decode_metadata( + block.metadata, transaction.metadata, "mainnet" + ) +) +decoded_events: List[DecodedEvent] = ethtx.decoders.semantic_decoder.decode_events( + abi_decoded_events, decoded_metadata, proxies +) + +decoded_calls: Call = ethtx.decoders.semantic_decoder.decode_calls( + abi_decoded_calls, decoded_metadata, proxies +) +decoded_transfers: List[ + DecodedTransfer +] = ethtx.decoders.semantic_decoder.decode_transfers( + abi_decoded_transfers, decoded_metadata +) +decoded_balances: List[ + DecodedBalance +] = ethtx.decoders.semantic_decoder.decode_balances( + abi_decoded_balances, decoded_metadata +) + +# semantically decode a single event +decoded_event: DecodedEvent = ethtx.decoders.semantic_decoder.decode_event( + abi_decoded_events[0], decoded_metadata, proxies +) +# semantically decode a single call +decoded_call: Call = ethtx.decoders.semantic_decoder.decode_call( + abi_decoded_calls.subcalls[0], decoded_metadata, proxies +) +``` + + +%package -n python3-EthTx +Summary: EthTx transaction decoder. +Provides: python-EthTx +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-EthTx + +<h1 align='center' style='border-bottom: none'> + <p>EthTx - Ethereum transactions decoder </p> +</h1> + +<p align="center"> +<a target="_blank"> + <img src="https://img.shields.io/badge/Made%20with-Python-1f425f.svg" alt="Python"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black"> +</a> +<a target="_blank"> + <img src="https://badgen.net/badge/Open%20Source%20%3F/Yes%21/blue?icon=github" alt="OpenSource"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="Apache"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/pypi/v/EthTx?label=pypi%20package" alt="EthTxPyPi"> +</a> +</p> + +## Introduction + +Source Code: [https://github.com/ethtx/ethtx](https://github.com/ethtx/ethtx) + +## Installation + +```shell +pip install ethtx +``` + +## Requirements + +The package needs a few external resources, defined in `EthTxConfig` object: + +1. **Erigon/Geth node** - required to have access to the raw Ethereum data; it must be a full archive node with + the `debug` option ON +2. **Etherscan API key** - required to get the source code and ABI for smart contracts used in transaction +3. (Optional) **MongoDB database** - required to store smart contracts' ABI and semantics used in the decoding process. + If you don't want to setup permanent database, you can enter `mongomock://localhost/ethtx`, then in-memory mongo will be + set up that discards all data with every run. + +## Getting started + +```python +from ethtx import EthTx, EthTxConfig +from ethtx.models.decoded_model import DecodedTransaction + +ethtx_config = EthTxConfig( + mongo_connection_string="mongomock://localhost/ethtx", ##MongoDB connection string, + etherscan_api_key="", ##Etherscan API key, + web3nodes={ + "mainnet": { + "hook": "_Geth_archive_node_URL_", # multiple nodes supported, separate them with comma + "poa": _POA_chain_indicator_ # represented by bool value + } + }, + default_chain="mainnet", + etherscan_urls={"mainnet": "https://api.etherscan.io/api", }, +) + +ethtx = EthTx.initialize(ethtx_config) +decoded_transaction: DecodedTransaction = ethtx.decoders.decode_transaction( + '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d') +``` + +## Features + +EthTx most important functions: + +1. Raw node data access: + +```python +web3provider = ethtx.providers.web3provider + +from ethtx.models.w3_model import W3Transaction, W3Block, W3Receipt, W3CallTree + +# read raw transaction data directly from the node +w3transaction: W3Transaction = web3provider.get_transaction( + '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d') +w3block: W3Block = web3provider.get_block(w3transaction.blockNumber) +w3receipt: W3Receipt = web3provider.get_receipt(w3transaction.hash.hex()) +w3calls: W3CallTree = web3provider.get_calls(w3transaction.hash.hex()) +``` + +2. ABI decoding: + +```python +from ethtx.models.decoded_model import ( + DecodedTransfer, + DecodedBalance, + DecodedEvent, DecodedCall, +) +from ethtx.models.objects_model import Transaction, Event, Block, Call + +# read the raw transaction from the node +transaction = Transaction.from_raw( + w3transaction=w3transaction, w3receipt=w3receipt, w3calltree=w3calls +) + +# get proxies used in the transaction +proxies = ethtx.decoders.get_proxies(transaction.root_call, "mainnet") + +block: Block = Block.from_raw( + w3block=web3provider.get_block(transaction.metadata.block_number), + chain_id="mainnet", +) + +# decode transaction components +abi_decoded_events: List[Event] = ethtx.decoders.abi_decoder.decode_events( + transaction.events, block.metadata, transaction.metadata +) +abi_decoded_calls: DecodedCall = ethtx.decoders.abi_decoder.decode_calls( + transaction.root_call, block.metadata, transaction.metadata, proxies +) +abi_decoded_transfers: List[ + DecodedTransfer +] = ethtx.decoders.abi_decoder.decode_transfers(abi_decoded_calls, abi_decoded_events) +abi_decoded_balances: List[DecodedBalance] = ethtx.decoders.abi_decoder.decode_balances( + abi_decoded_transfers +) + +# decode a single event +raw_event: Event = transaction.events[3] +abi_decoded_event: DecodedEvent = ethtx.decoders.abi_decoder.decode_event( + raw_event, block.metadata, transaction.metadata +) + +# decode a single call +raw_call: Call = transaction.root_call.subcalls[0] +abi_decoded_call: DecodedCall = ethtx.decoders.abi_decoder.decode_call( + raw_call, block.metadata, transaction.metadata, proxies +) +``` + +3. Semantic decoding: + +```python +from ethtx.models.decoded_model import DecodedTransactionMetadata + +# semantically decode transaction components +decoded_metadata: DecodedTransactionMetadata = ( + ethtx.decoders.semantic_decoder.decode_metadata( + block.metadata, transaction.metadata, "mainnet" + ) +) +decoded_events: List[DecodedEvent] = ethtx.decoders.semantic_decoder.decode_events( + abi_decoded_events, decoded_metadata, proxies +) + +decoded_calls: Call = ethtx.decoders.semantic_decoder.decode_calls( + abi_decoded_calls, decoded_metadata, proxies +) +decoded_transfers: List[ + DecodedTransfer +] = ethtx.decoders.semantic_decoder.decode_transfers( + abi_decoded_transfers, decoded_metadata +) +decoded_balances: List[ + DecodedBalance +] = ethtx.decoders.semantic_decoder.decode_balances( + abi_decoded_balances, decoded_metadata +) + +# semantically decode a single event +decoded_event: DecodedEvent = ethtx.decoders.semantic_decoder.decode_event( + abi_decoded_events[0], decoded_metadata, proxies +) +# semantically decode a single call +decoded_call: Call = ethtx.decoders.semantic_decoder.decode_call( + abi_decoded_calls.subcalls[0], decoded_metadata, proxies +) +``` + + +%package help +Summary: Development documents and examples for EthTx +Provides: python3-EthTx-doc +%description help + +<h1 align='center' style='border-bottom: none'> + <p>EthTx - Ethereum transactions decoder </p> +</h1> + +<p align="center"> +<a target="_blank"> + <img src="https://img.shields.io/badge/Made%20with-Python-1f425f.svg" alt="Python"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black"> +</a> +<a target="_blank"> + <img src="https://badgen.net/badge/Open%20Source%20%3F/Yes%21/blue?icon=github" alt="OpenSource"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="Apache"> +</a> +<a target="_blank"> + <img src="https://img.shields.io/pypi/v/EthTx?label=pypi%20package" alt="EthTxPyPi"> +</a> +</p> + +## Introduction + +Source Code: [https://github.com/ethtx/ethtx](https://github.com/ethtx/ethtx) + +## Installation + +```shell +pip install ethtx +``` + +## Requirements + +The package needs a few external resources, defined in `EthTxConfig` object: + +1. **Erigon/Geth node** - required to have access to the raw Ethereum data; it must be a full archive node with + the `debug` option ON +2. **Etherscan API key** - required to get the source code and ABI for smart contracts used in transaction +3. (Optional) **MongoDB database** - required to store smart contracts' ABI and semantics used in the decoding process. + If you don't want to setup permanent database, you can enter `mongomock://localhost/ethtx`, then in-memory mongo will be + set up that discards all data with every run. + +## Getting started + +```python +from ethtx import EthTx, EthTxConfig +from ethtx.models.decoded_model import DecodedTransaction + +ethtx_config = EthTxConfig( + mongo_connection_string="mongomock://localhost/ethtx", ##MongoDB connection string, + etherscan_api_key="", ##Etherscan API key, + web3nodes={ + "mainnet": { + "hook": "_Geth_archive_node_URL_", # multiple nodes supported, separate them with comma + "poa": _POA_chain_indicator_ # represented by bool value + } + }, + default_chain="mainnet", + etherscan_urls={"mainnet": "https://api.etherscan.io/api", }, +) + +ethtx = EthTx.initialize(ethtx_config) +decoded_transaction: DecodedTransaction = ethtx.decoders.decode_transaction( + '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d') +``` + +## Features + +EthTx most important functions: + +1. Raw node data access: + +```python +web3provider = ethtx.providers.web3provider + +from ethtx.models.w3_model import W3Transaction, W3Block, W3Receipt, W3CallTree + +# read raw transaction data directly from the node +w3transaction: W3Transaction = web3provider.get_transaction( + '0x50051e0a6f216ab9484c2080001c7e12d5138250acee1f4b7c725b8fb6bb922d') +w3block: W3Block = web3provider.get_block(w3transaction.blockNumber) +w3receipt: W3Receipt = web3provider.get_receipt(w3transaction.hash.hex()) +w3calls: W3CallTree = web3provider.get_calls(w3transaction.hash.hex()) +``` + +2. ABI decoding: + +```python +from ethtx.models.decoded_model import ( + DecodedTransfer, + DecodedBalance, + DecodedEvent, DecodedCall, +) +from ethtx.models.objects_model import Transaction, Event, Block, Call + +# read the raw transaction from the node +transaction = Transaction.from_raw( + w3transaction=w3transaction, w3receipt=w3receipt, w3calltree=w3calls +) + +# get proxies used in the transaction +proxies = ethtx.decoders.get_proxies(transaction.root_call, "mainnet") + +block: Block = Block.from_raw( + w3block=web3provider.get_block(transaction.metadata.block_number), + chain_id="mainnet", +) + +# decode transaction components +abi_decoded_events: List[Event] = ethtx.decoders.abi_decoder.decode_events( + transaction.events, block.metadata, transaction.metadata +) +abi_decoded_calls: DecodedCall = ethtx.decoders.abi_decoder.decode_calls( + transaction.root_call, block.metadata, transaction.metadata, proxies +) +abi_decoded_transfers: List[ + DecodedTransfer +] = ethtx.decoders.abi_decoder.decode_transfers(abi_decoded_calls, abi_decoded_events) +abi_decoded_balances: List[DecodedBalance] = ethtx.decoders.abi_decoder.decode_balances( + abi_decoded_transfers +) + +# decode a single event +raw_event: Event = transaction.events[3] +abi_decoded_event: DecodedEvent = ethtx.decoders.abi_decoder.decode_event( + raw_event, block.metadata, transaction.metadata +) + +# decode a single call +raw_call: Call = transaction.root_call.subcalls[0] +abi_decoded_call: DecodedCall = ethtx.decoders.abi_decoder.decode_call( + raw_call, block.metadata, transaction.metadata, proxies +) +``` + +3. Semantic decoding: + +```python +from ethtx.models.decoded_model import DecodedTransactionMetadata + +# semantically decode transaction components +decoded_metadata: DecodedTransactionMetadata = ( + ethtx.decoders.semantic_decoder.decode_metadata( + block.metadata, transaction.metadata, "mainnet" + ) +) +decoded_events: List[DecodedEvent] = ethtx.decoders.semantic_decoder.decode_events( + abi_decoded_events, decoded_metadata, proxies +) + +decoded_calls: Call = ethtx.decoders.semantic_decoder.decode_calls( + abi_decoded_calls, decoded_metadata, proxies +) +decoded_transfers: List[ + DecodedTransfer +] = ethtx.decoders.semantic_decoder.decode_transfers( + abi_decoded_transfers, decoded_metadata +) +decoded_balances: List[ + DecodedBalance +] = ethtx.decoders.semantic_decoder.decode_balances( + abi_decoded_balances, decoded_metadata +) + +# semantically decode a single event +decoded_event: DecodedEvent = ethtx.decoders.semantic_decoder.decode_event( + abi_decoded_events[0], decoded_metadata, proxies +) +# semantically decode a single call +decoded_call: Call = ethtx.decoders.semantic_decoder.decode_call( + abi_decoded_calls.subcalls[0], decoded_metadata, proxies +) +``` + + +%prep +%autosetup -n EthTx-0.3.21 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-EthTx -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.3.21-1 +- Package Spec generated @@ -0,0 +1 @@ +40a62467ab8010b4fbb6d4c65d31acba EthTx-0.3.21.tar.gz |