├── .coverage ├── .github └── workflows │ └── ci.yaml ├── .gitignore ├── README.md ├── examples ├── ledger_example.py ├── request_data_example.py └── send_band_example.py ├── pyband ├── __init__.py ├── client.py ├── constants.py ├── cosmos_app.py ├── data.py ├── exceptions.py ├── messages │ ├── __init__.py │ ├── band │ │ ├── __init__.py │ │ ├── bandtss │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ ├── __init__.py │ │ │ │ └── msgs.py │ │ ├── feeds │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ ├── __init__.py │ │ │ │ └── msgs.py │ │ ├── globalfee │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ ├── __init__.py │ │ │ │ └── msgs.py │ │ ├── oracle │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ ├── __init__.py │ │ │ │ └── msgs.py │ │ ├── restake │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ ├── __init__.py │ │ │ │ └── msgs.py │ │ ├── tss │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ ├── __init__.py │ │ │ │ └── msgs.py │ │ └── tunnel │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ ├── __init__.py │ │ │ └── msgs.py │ ├── base.py │ └── cosmos │ │ ├── __init__.py │ │ ├── bank │ │ ├── __init__.py │ │ └── v1beta1 │ │ │ ├── __init__.py │ │ │ └── msgs.py │ │ ├── distribution │ │ ├── __init__.py │ │ └── v1beta1 │ │ │ ├── __init__.py │ │ │ └── msgs.py │ │ ├── gov │ │ ├── __init__.py │ │ └── v1beta1 │ │ │ ├── __init__.py │ │ │ └── msgs.py │ │ └── staking │ │ ├── __init__.py │ │ └── v1beta1 │ │ ├── __init__.py │ │ └── msgs.py ├── obi.py ├── proto │ ├── __init__.py │ ├── amino │ │ └── __init__.py │ ├── band │ │ ├── __init__.py │ │ ├── bandtss │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── base │ │ │ ├── __init__.py │ │ │ ├── node │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── oracle │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── feeds │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── globalfee │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── oracle │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── restake │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── rollingseed │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── tss │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ └── tunnel │ │ │ ├── __init__.py │ │ │ └── v1beta1 │ │ │ └── __init__.py │ ├── cosmos │ │ ├── __init__.py │ │ ├── app │ │ │ ├── __init__.py │ │ │ ├── runtime │ │ │ │ ├── __init__.py │ │ │ │ └── v1alpha1 │ │ │ │ │ └── __init__.py │ │ │ └── v1alpha1 │ │ │ │ └── __init__.py │ │ ├── auth │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── authz │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── autocli │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── bank │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── base │ │ │ ├── __init__.py │ │ │ ├── abci │ │ │ │ ├── __init__.py │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ ├── node │ │ │ │ ├── __init__.py │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ ├── query │ │ │ │ ├── __init__.py │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ ├── reflection │ │ │ │ ├── __init__.py │ │ │ │ ├── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ │ └── v2alpha1 │ │ │ │ │ └── __init__.py │ │ │ ├── tendermint │ │ │ │ ├── __init__.py │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── circuit │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── consensus │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── crisis │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── crypto │ │ │ ├── __init__.py │ │ │ ├── ed25519 │ │ │ │ └── __init__.py │ │ │ ├── hd │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ ├── keyring │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ ├── multisig │ │ │ │ ├── __init__.py │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ ├── secp256k1 │ │ │ │ └── __init__.py │ │ │ └── secp256r1 │ │ │ │ └── __init__.py │ │ ├── distribution │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── evidence │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── feegrant │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── genutil │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── gov │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ ├── v1 │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── group │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── mint │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── msg │ │ │ ├── __init__.py │ │ │ ├── textual │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── nft │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── orm │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1alpha1 │ │ │ │ │ └── __init__.py │ │ │ ├── query │ │ │ │ ├── __init__.py │ │ │ │ └── v1alpha1 │ │ │ │ │ └── __init__.py │ │ │ ├── v1 │ │ │ │ └── __init__.py │ │ │ └── v1alpha1 │ │ │ │ └── __init__.py │ │ ├── params │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── query │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── reflection │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ ├── slashing │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── staking │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── store │ │ │ ├── __init__.py │ │ │ ├── internal │ │ │ │ ├── __init__.py │ │ │ │ └── kv │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ ├── snapshots │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ ├── streaming │ │ │ │ ├── __init__.py │ │ │ │ └── abci │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── tx │ │ │ ├── __init__.py │ │ │ ├── config │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ ├── signing │ │ │ │ ├── __init__.py │ │ │ │ └── v1beta1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ ├── upgrade │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ │ ├── __init__.py │ │ │ │ └── v1 │ │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ │ └── __init__.py │ │ └── vesting │ │ │ ├── __init__.py │ │ │ ├── module │ │ │ ├── __init__.py │ │ │ └── v1 │ │ │ │ └── __init__.py │ │ │ └── v1beta1 │ │ │ └── __init__.py │ ├── cosmos_proto │ │ └── __init__.py │ ├── gogoproto │ │ └── __init__.py │ ├── google │ │ ├── __init__.py │ │ └── api │ │ │ └── __init__.py │ └── tendermint │ │ ├── __init__.py │ │ ├── abci │ │ └── __init__.py │ │ ├── crypto │ │ └── __init__.py │ │ ├── libs │ │ ├── __init__.py │ │ └── bits │ │ │ └── __init__.py │ │ ├── p2p │ │ └── __init__.py │ │ ├── types │ │ └── __init__.py │ │ └── version │ │ └── __init__.py ├── transaction.py ├── utils.py └── wallet │ ├── __init__.py │ ├── address.py │ ├── constants.py │ ├── private_key.py │ ├── public_key.py │ ├── signer.py │ └── wallet.py ├── pyproject.toml ├── tests ├── __init__.py ├── client │ ├── client_test.py │ ├── connect_testnet_test.py │ └── send_tx_test.py ├── cosmos_app_test.py ├── obi_test.py ├── transaction_test.py ├── utils_test.py └── wallet_test.py └── uv.lock /.coverage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/.coverage -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: PyBand Workflow 2 | on: pull_request 3 | 4 | jobs: 5 | pyband-test: 6 | runs-on: ubuntu-24.04 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] 11 | 12 | steps: 13 | - name: Install libs 14 | run: | 15 | sudo apt update 16 | sudo apt install -y python3-dev libsecp256k1-dev 17 | 18 | - name: Code Checkout 19 | uses: actions/checkout@v3 20 | 21 | - name: Install uv 22 | uses: astral-sh/setup-uv@v5 23 | with: 24 | enable-cache: true 25 | cache-dependency-glob: "uv.lock" 26 | python-version: ${{ matrix.python-version }} 27 | 28 | - name: Install the project 29 | run: uv sync --all-extras --dev 30 | 31 | - name: Run tests 32 | run: uv run pytest tests 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /venv/ 2 | /dist/ 3 | /build/ 4 | /.vscode/ 5 | /MANIFEST 6 | __pycache__/ 7 | .pytest_cache/ 8 | *.egg-info 9 | .env 10 | **/.DS_Store 11 | .idea 12 | .venv -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

PyBand

3 |
BandChain Python Library
4 |
5 | 6 | Pyband is a library that is used to interact with BandChain through the `gRPC` protocol. Querying data and sending 7 | transaction can be done here! 8 | 9 | ## ⭐️ Features 10 | 11 | This helper library allows users to interact with BandChain. 12 | 13 | PyBand supports the following features: 14 | 15 | - Getting the information of a specific oracle script, data source, and request ID. 16 | - Getting the account information of specific address. 17 | - Getting the latest request for a specific oracle script with its matching calldata and validator ask_count and 18 | min_count. 19 | - Querying all the reporters associated with a specific validator. 20 | - Seeing what client_id you are using and getting BandChain's latest block data. 21 | - Able to send transaction in 3 modes: block mode, async mode, and sync mode. 22 | 23 | ## 📦 Installation 24 | 25 | This library is available on [PyPI](https://pypi.org/project/pyband/) 26 | 27 | ```bash 28 | pip install pyband 29 | ``` 30 | 31 | ## 💎 Example Usage 32 | 33 | The example below shows how this library can be used to get the result of the latest request for the price of any 34 | cryptocurrency. In this example, we will get the latest price of BTC on BandChain's testnet. 35 | 36 | The specified parameters are: 37 | 38 | - `oracleScriptID`: 111 39 | - `calldata`: The hex string representing the [OBI]()-encoded value of `{'symbols': ['BTC'], 'multiplier': 100000000}` 40 | - `minCount`: 10 41 | - `askCount`: 16 42 | 43 | ```python 44 | import asyncio 45 | 46 | from pyband import Client, PyObi 47 | 48 | 49 | async def main(): 50 | grpc_url = "laozi-testnet6.bandchain.org" 51 | c = Client.from_endpoint(grpc_url, 443) 52 | 53 | oid = 111 54 | calldata = "00000001000000034254430000000005f5e100" 55 | min_count = 10 56 | ask_count = 16 57 | 58 | req_info = await c.get_latest_request(oid, calldata, min_count, ask_count) 59 | oracle_script = await c.get_oracle_script(oid) 60 | obi = PyObi(oracle_script.schema) 61 | 62 | # Converts the calldata into a readable syntax 63 | print(obi.decode_input(bytes.fromhex(calldata))) 64 | 65 | # Prints the result 66 | print(obi.decode_output(req_info.request.result.result)) 67 | 68 | 69 | if __name__ == "__main__": 70 | asyncio.run(main()) 71 | ``` 72 | 73 | Below is the results of the example above. 74 | 75 | ``` 76 | {'symbols': ['BTC'], 'multiplier': 100000000} 77 | {'rates': [1936488410000]} 78 | ``` 79 | 80 | This example shows how to send a transaction on BandChain using block mode. 81 | 82 | ```python 83 | import asyncio 84 | import os 85 | 86 | from pyband import Client, Transaction, Wallet 87 | from pyband.messages.cosmos.bank.v1beta1 import MsgSend 88 | from pyband.proto.cosmos.base.v1beta1 import Coin 89 | 90 | 91 | async def main(): 92 | # Create a GRPC connection 93 | grpc_url = "laozi-testnet6.bandchain.org" 94 | c = Client.from_endpoint(grpc_url, 443) 95 | 96 | # Convert a mnemonic to a wallet 97 | wallet = Wallet.from_mnemonic(os.getenv("MNEMONIC")) 98 | sender = wallet.get_address().to_acc_bech32() 99 | 100 | # Prepare a transaction's properties 101 | msg_send = MsgSend( 102 | from_address=sender, 103 | to_address="band19ajhdg6maw0ja0a7qd9sq7nm4ym9f4wjg8r96w", 104 | amount=[Coin(amount="1000000", denom="uband")], 105 | ) 106 | 107 | account = await c.get_account(sender) 108 | account_num = account.account_number 109 | sequence = account.sequence 110 | 111 | fee = [Coin(amount="50000", denom="uband")] 112 | chain_id = await c.get_chain_id() 113 | 114 | # Step 4 Construct a transaction 115 | txn = ( 116 | Transaction() 117 | .with_messages(msg_send) 118 | .with_sequence(sequence) 119 | .with_account_num(account_num) 120 | .with_chain_id(chain_id) 121 | .with_gas(2000000) 122 | .with_fee(fee) 123 | .with_memo("") 124 | ) 125 | 126 | # Sign and broadcast a transaction 127 | tx_block = await c.send_tx_sync_mode(wallet.sign_and_build(txn)) 128 | 129 | # Converting to JSON for readability 130 | print(tx_block.to_json(indent=4)) 131 | 132 | 133 | if __name__ == "__main__": 134 | asyncio.run(main()) 135 | ``` 136 | 137 | ## 🧀 Notes 138 | 139 | For more examples, please go to [`examples`](/examples/request_data_example.py). 140 | -------------------------------------------------------------------------------- /examples/ledger_example.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | 3 | from pyband import Client, Transaction, Wallet 4 | from pyband.messages.band.oracle.v1 import MsgEditDataSource 5 | from pyband.proto.cosmos.base.v1beta1 import Coin 6 | 7 | 8 | async def main(): 9 | # Create the gRPC connection 10 | grpc_url = "laozi-testnet6.bandchain.org" 11 | c = Client.from_endpoint(grpc_url, 443) 12 | 13 | # Get the public key and sender from the ledger 14 | wallet = Wallet.from_ledger() 15 | sender = wallet.get_address().to_acc_bech32() 16 | 17 | # Prepare the transaction's properties 18 | edit_ds_msg = MsgEditDataSource( 19 | data_source_id=426, 20 | name="[do-not-modify]", 21 | description="edited v2", 22 | executable="[do-not-modify]".encode(), 23 | fee=[], 24 | treasury=sender, 25 | owner=sender, 26 | sender=sender, 27 | ) 28 | 29 | account = await c.get_account(sender) 30 | account_num = account.account_number 31 | sequence = account.sequence 32 | 33 | chain_id = await c.get_chain_id() 34 | 35 | # Construct the transaction 36 | txn = ( 37 | Transaction() 38 | .with_messages(edit_ds_msg) 39 | .with_sequence(sequence) 40 | .with_account_num(account_num) 41 | .with_chain_id(chain_id) 42 | .with_gas_limit(200000) 43 | .with_gas_price(0.0025) 44 | ) 45 | 46 | # Sign and broadcast a transaction 47 | tx_block = await c.send_tx_sync_mode(wallet.sign_and_build(txn)) 48 | 49 | # Convert to JSON for readability 50 | print(tx_block.to_json(indent=4)) 51 | 52 | 53 | if __name__ == "__main__": 54 | asyncio.run(main()) 55 | -------------------------------------------------------------------------------- /examples/request_data_example.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import os 3 | 4 | from pyband import Client, Transaction, Wallet 5 | from pyband.messages.band.oracle.v1 import MsgRequestData 6 | from pyband.proto.cosmos.base.v1beta1 import Coin 7 | 8 | 9 | async def main(): 10 | # Create a GRPC connection 11 | grpc_url = "laozi-testnet6.bandchain.org" 12 | c = Client.from_endpoint(grpc_url, 443) 13 | 14 | # Convert a mnemonic to a wallet 15 | wallet = Wallet.from_mnemonic(os.getenv("MNEMONIC")) 16 | sender = wallet.get_address().to_acc_bech32() 17 | 18 | # Prepare a transaction's properties 19 | request_msg = MsgRequestData( 20 | oracle_script_id=37, 21 | calldata=bytes.fromhex("0000000200000003425443000000034554480000000000000064"), 22 | ask_count=4, 23 | min_count=3, 24 | client_id="BandProtocol", 25 | fee_limit=[Coin(amount="112", denom="uband")], 26 | prepare_gas=50000, 27 | execute_gas=200000, 28 | sender=sender, 29 | ) 30 | 31 | account = await c.get_account(sender) 32 | account_num = account.account_number 33 | sequence = account.sequence 34 | 35 | chain_id = await c.get_chain_id() 36 | 37 | # Step 4 Construct a transaction 38 | txn = ( 39 | Transaction() 40 | .with_messages(request_msg) 41 | .with_sequence(sequence) 42 | .with_account_num(account_num) 43 | .with_chain_id(chain_id) 44 | .with_gas_limit(650000) 45 | .with_gas_price(0.0025) 46 | .with_memo("") 47 | ) 48 | 49 | # Sign and broadcast a transaction 50 | tx_block = await c.send_tx_sync_mode(wallet.sign_and_build(txn)) 51 | 52 | # Converting to JSON for readability 53 | print(tx_block.to_json(indent=4)) 54 | 55 | 56 | if __name__ == "__main__": 57 | asyncio.run(main()) 58 | -------------------------------------------------------------------------------- /examples/send_band_example.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import os 3 | 4 | from pyband import Client, Transaction, Wallet 5 | from pyband.messages.cosmos.bank.v1beta1 import MsgSend 6 | from pyband.proto.cosmos.base.v1beta1 import Coin 7 | 8 | 9 | async def main(): 10 | # Create a GRPC connection 11 | grpc_url = "laozi-testnet6.bandchain.org" 12 | c = Client.from_endpoint(grpc_url, 443) 13 | 14 | # Convert a mnemonic to a wallet 15 | wallet = Wallet.from_mnemonic(os.getenv("MNEMONIC")) 16 | sender = wallet.get_address().to_acc_bech32() 17 | 18 | # Prepare a transaction's properties 19 | msg_send = MsgSend( 20 | from_address=sender, 21 | to_address="band19ajhdg6maw0ja0a7qd9sq7nm4ym9f4wjg8r96w", 22 | amount=[Coin(amount="1000000", denom="uband")], 23 | ) 24 | 25 | account = await c.get_account(sender) 26 | account_num = account.account_number 27 | sequence = account.sequence 28 | 29 | chain_id = await c.get_chain_id() 30 | 31 | # Step 4 Construct a transaction 32 | txn = ( 33 | Transaction() 34 | .with_messages(msg_send) 35 | .with_sequence(sequence) 36 | .with_account_num(account_num) 37 | .with_chain_id(chain_id) 38 | .with_gas_limit(100000) 39 | .with_gas_price(0.0025) 40 | .with_memo("") 41 | ) 42 | 43 | # Sign and broadcast a transaction 44 | tx_block = await c.send_tx_sync_mode(wallet.sign_and_build(txn)) 45 | 46 | # Converting to JSON for readability 47 | print(tx_block.to_json(indent=4)) 48 | 49 | 50 | if __name__ == "__main__": 51 | asyncio.run(main()) 52 | -------------------------------------------------------------------------------- /pyband/__init__.py: -------------------------------------------------------------------------------- 1 | from .client import Client 2 | from .obi import PyObi 3 | from .wallet import PrivateKey, PublicKey, Address, Wallet 4 | from .transaction import Transaction 5 | -------------------------------------------------------------------------------- /pyband/constants.py: -------------------------------------------------------------------------------- 1 | MAX_CLIENT_ID_LENGTH = 128 2 | MAX_DATA_SIZE = 256 3 | MAX_MEMO_CHARACTERS = 256 4 | -------------------------------------------------------------------------------- /pyband/cosmos_app.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass, fields 2 | from typing import Optional, List 3 | 4 | from ledgerblue.Dongle import Dongle 5 | from ledgerblue.comm import getDongle 6 | from ledgerblue.commException import CommException 7 | 8 | from .exceptions import CosmosAppError 9 | from .utils import get_bip32_byte, split_packet 10 | 11 | 12 | @dataclass 13 | class CosmosAppCommand: 14 | CLA: bytes 15 | INS: bytes 16 | P1: bytes 17 | P2: bytes 18 | L: Optional[bytes] = None 19 | data: Optional[bytes] = None 20 | 21 | def __post_init__(self): 22 | self.set_l() 23 | 24 | def set_l(self): 25 | if self.data is None: 26 | self.L = b"\x00" 27 | else: 28 | self.L = len(self.data).to_bytes(1, "little") 29 | 30 | def get_message(self): 31 | message = b"" 32 | for field in fields(self.__class__): 33 | field_value = getattr(self, field.name) 34 | if field_value is not None: 35 | message += field_value 36 | return message 37 | 38 | 39 | class CosmosAppResults: 40 | def __iter__(self): 41 | for var in self.__slots__: 42 | yield getattr(self, var) 43 | 44 | 45 | class AppVersion(CosmosAppResults): 46 | __slots__ = ("cla", "major", "minor", "patch") 47 | 48 | def __init__(self, cla: int, major: int, minor: int, patch: int): 49 | self.cla = cla 50 | self.major = major 51 | self.minor = minor 52 | self.patch = patch 53 | 54 | def __repr__(self): 55 | return "AppVersion(cla={}, major={}, minor={}, patch={})".format( 56 | *self.__iter__() 57 | ) 58 | 59 | 60 | class SepcAddr(CosmosAppResults): 61 | __slots__ = ("public_key", "address") 62 | 63 | def __init__(self, public_key: bytes, address: bytes): 64 | self.public_key = public_key 65 | self.address = address 66 | 67 | def __repr__(self): 68 | return "SepcAddr(public_key={}, address={})".format(*self.__iter__()) 69 | 70 | 71 | class CosmosApp: 72 | """Class for interacting with the CosmosApp on Ledger. 73 | 74 | Attributes: 75 | dongle: The dongle connection. 76 | derivation_path: The derivation path of the account to interact with. 77 | """ 78 | 79 | def __init__(self, derivation_path: List[int], *, dongle: Optional[Dongle] = None): 80 | self.dongle = getDongle() if dongle is None else dongle 81 | self.derivation_path = derivation_path 82 | 83 | def __del__(self): 84 | self.disconnect() 85 | 86 | def disconnect(self) -> None: 87 | """Disconnects the ledger connection.""" 88 | 89 | try: 90 | self.dongle.close() 91 | except AttributeError: 92 | pass 93 | 94 | def get_version(self) -> AppVersion: 95 | """Gets the app version. 96 | 97 | Returns: 98 | The connected ledger's app version. 99 | 100 | Raises: 101 | CosmosAppError: Error returned from the ledger. 102 | """ 103 | 104 | command = CosmosAppCommand( 105 | CLA=b"\x55", 106 | INS=b"\x00", 107 | P1=b"\x00", 108 | P2=b"\x00", 109 | ) 110 | 111 | try: 112 | resp = self.dongle.exchange(command.get_message()) 113 | except CommException as e: 114 | raise CosmosAppError(hex(e.sw)) 115 | return AppVersion(*(resp[i] for i in range(4))) 116 | 117 | def ins_get_addr_secp256k1(self, hrp: str, req_confirm: bool = True) -> SepcAddr: 118 | """Gets the address using secp256k1. 119 | 120 | Args: 121 | hrp: Human-readable part of a Bech32 string. 122 | req_confirm: If confirmation is required on ledger before returning a result. 123 | 124 | Returns: 125 | The account address. 126 | 127 | Raises: 128 | CosmosAppError: Error returned from the ledger. 129 | """ 130 | 131 | try: 132 | bip32_byte = get_bip32_byte(self.derivation_path, 3) 133 | except Exception as e: 134 | raise e 135 | 136 | command = CosmosAppCommand( 137 | CLA=b"\x55", 138 | INS=b"\x04", 139 | P1=req_confirm.to_bytes(1, "little"), 140 | P2=b"\x00", 141 | data=len(hrp).to_bytes(1, "little") + hrp.encode() + bip32_byte, 142 | ) 143 | 144 | try: 145 | resp = self.dongle.exchange(command.get_message()) 146 | except CommException as e: 147 | raise CosmosAppError(hex(e.sw)) 148 | return SepcAddr(resp[:33], resp[33:]) 149 | 150 | def sign_secp256k1(self, msg: bytes) -> bytearray: 151 | """Signs a given message using a private key generated on curve secp256k1. 152 | 153 | Args: 154 | msg: Message to sign. 155 | 156 | Returns: 157 | Signed message. 158 | 159 | Raises: 160 | CosmosAppError: Error returned from the ledger. 161 | """ 162 | 163 | command = CosmosAppCommand( 164 | CLA=b"\x55", 165 | INS=b"\x02", 166 | P1=b"\x00", 167 | P2=b"\x00", 168 | data=get_bip32_byte(self.derivation_path, 3), 169 | ) 170 | try: 171 | resp = self.dongle.exchange(command.get_message()) 172 | except CommException as e: 173 | raise CosmosAppError(hex(e.sw)) 174 | 175 | packets = split_packet(msg) 176 | for i, packet in enumerate(packets): 177 | if i == len(packets) - 1: 178 | payload_desc = b"\x02" 179 | else: 180 | payload_desc = b"\x01" 181 | command = CosmosAppCommand( 182 | CLA=b"\x55", 183 | INS=b"\x02", 184 | P1=payload_desc, 185 | P2=b"\x00", 186 | L=len(packet).to_bytes(1, "big"), 187 | data=bytes(packet), 188 | ) 189 | try: 190 | resp = self.dongle.exchange(command.get_message()) 191 | except CommException as e: 192 | raise CosmosAppError(hex(e.sw)) 193 | return resp 194 | -------------------------------------------------------------------------------- /pyband/data.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass 2 | 3 | 4 | @dataclass 5 | class ReferencePriceUpdated(object): 6 | base: int 7 | quote: int 8 | 9 | 10 | @dataclass 11 | class ReferencePrice(object): 12 | pair: str 13 | rate: float 14 | updated_at: ReferencePriceUpdated 15 | -------------------------------------------------------------------------------- /pyband/exceptions.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | LEDGER_RETURN_CODES = { 4 | "0x6400": "Execution error", 5 | "0x6700": "Wrong length", 6 | "0x6802": "Error deriving keys", 7 | "0x6982": "Empty buffer", 8 | "0x6983": "Output buffer too small", 9 | "0x6984": "Data is invalid", 10 | "0x6985": "Conditions not satisfied", 11 | "0x6986": "Command not allowed", 12 | "0x6a80": "Bad key handle", 13 | "0x6b00": "Invalid P1/P2", 14 | "0x6d00": "Instruction not supported", 15 | "0x6e00": "CLA not supported", 16 | "0x6f00": "Unknown", 17 | "0x6f01": "Sign/verify error", 18 | "0x9000": "Success", 19 | "0x9001": "Device is busy", 20 | } 21 | 22 | 23 | class PybandError(Exception): 24 | pass 25 | 26 | 27 | class ValueTooLargeError(PybandError): 28 | pass 29 | 30 | 31 | class EmptyMsgError(PybandError): 32 | pass 33 | 34 | 35 | class NotFoundError(PybandError): 36 | pass 37 | 38 | 39 | class UndefinedError(PybandError): 40 | pass 41 | 42 | 43 | class DecodeError(PybandError): 44 | pass 45 | 46 | 47 | class ConvertError(PybandError): 48 | pass 49 | 50 | 51 | class SchemaError(PybandError): 52 | pass 53 | 54 | 55 | class NotBip44Error(PybandError): 56 | pass 57 | 58 | 59 | class IncorrectLengthError(PybandError): 60 | pass 61 | 62 | 63 | class CosmosAppError(PybandError): 64 | def __init__(self, return_code: Optional[str] = None): 65 | if return_code: 66 | self.msg = LEDGER_RETURN_CODES.get(return_code, "Unknown error") 67 | else: 68 | self.msg = "Unknown error" 69 | 70 | def __str__(self): 71 | return self.msg 72 | -------------------------------------------------------------------------------- /pyband/messages/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/bandtss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/bandtss/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/bandtss/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import ( 2 | MsgRequestSignature, 3 | MsgActivate, 4 | MsgUpdateParams, 5 | MsgTransitionGroup, 6 | MsgForceTransitionGroup, 7 | ) 8 | -------------------------------------------------------------------------------- /pyband/messages/band/bandtss/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from pyband.messages.base import BaseMessageWrapper 2 | from pyband.proto.band.bandtss.v1beta1 import ( 3 | MsgRequestSignature as MsgRequestSignatureProto, 4 | MsgActivate as MsgActivateProto, 5 | MsgUpdateParams as MsgUpdateParamsProto, 6 | MsgTransitionGroup as MsgTransitionGroupProto, 7 | MsgForceTransitionGroup as MsgForceTransitionGroupProto, 8 | ) 9 | 10 | 11 | class MsgRequestSignature(BaseMessageWrapper, MsgRequestSignatureProto): 12 | @property 13 | def type_url(self): 14 | return "/band.bandtss.v1beta1.MsgRequestData" 15 | 16 | @property 17 | def legacy_url(self): 18 | return "bandtss/MsgRequestSignature" 19 | 20 | 21 | class MsgActivate(BaseMessageWrapper, MsgActivateProto): 22 | @property 23 | def type_url(self): 24 | return "/band.bandtss.v1beta1.MsgActivate" 25 | 26 | @property 27 | def legacy_url(self): 28 | return "bandtss/MsgActivate" 29 | 30 | 31 | class MsgUpdateParams(BaseMessageWrapper, MsgUpdateParamsProto): 32 | @property 33 | def type_url(self): 34 | return "/band.bandtss.v1beta1.MsgUpdateParams" 35 | 36 | @property 37 | def legacy_url(self): 38 | return "bandtss/MsgUpdateParams" 39 | 40 | 41 | class MsgTransitionGroup(BaseMessageWrapper, MsgTransitionGroupProto): 42 | @property 43 | def type_url(self): 44 | return "/band.bandtss.v1beta1.MsgTransitionGroup" 45 | 46 | @property 47 | def legacy_url(self): 48 | return "bandtss/MsgTransitionGroup" 49 | 50 | 51 | class MsgForceTransitionGroup(BaseMessageWrapper, MsgForceTransitionGroupProto): 52 | @property 53 | def type_url(self): 54 | return "/band.bandtss.v1beta1.MsgForceTransitionGroup" 55 | 56 | @property 57 | def legacy_url(self): 58 | return "bandtss/MsgForceTransitionGroup" 59 | -------------------------------------------------------------------------------- /pyband/messages/band/feeds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/feeds/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/feeds/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import ( 2 | MsgVote, 3 | MsgSubmitSignalPrices, 4 | MsgUpdateReferenceSourceConfig, 5 | MsgUpdateParams, 6 | ) 7 | -------------------------------------------------------------------------------- /pyband/messages/band/feeds/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from pyband.messages.base import BaseMessageWrapper 2 | from pyband.proto.band.feeds.v1beta1 import ( 3 | MsgVote as MsgVoteProto, 4 | MsgSubmitSignalPrices as MsgSubmitSignalPricesProto, 5 | MsgUpdateReferenceSourceConfig as MsgUpdateReferenceSourceConfigProto, 6 | MsgUpdateParams as MsgUpdateParamsProto, 7 | ) 8 | 9 | 10 | class MsgVote(BaseMessageWrapper, MsgVoteProto): 11 | @property 12 | def type_url(self): 13 | return "/band.feeds.v1beta1.MsgVote" 14 | 15 | @property 16 | def legacy_url(self): 17 | return "feeds/MsgVote" 18 | 19 | 20 | class MsgSubmitSignalPrices(BaseMessageWrapper, MsgSubmitSignalPricesProto): 21 | @property 22 | def type_url(self): 23 | return "/band.feeds.v1beta1.MsgSubmitSignalPrices" 24 | 25 | @property 26 | def legacy_url(self): 27 | return "feeds/MsgSubmitSignalPrices" 28 | 29 | 30 | class MsgUpdateReferenceSourceConfig( 31 | BaseMessageWrapper, MsgUpdateReferenceSourceConfigProto 32 | ): 33 | @property 34 | def type_url(self): 35 | return "/band.feeds.v1beta1.MsgUpdateReferenceSourceConfig" 36 | 37 | @property 38 | def legacy_url(self): 39 | return "feeds/MsgUpdateReferenceSourceConfig" 40 | 41 | 42 | class MsgUpdateParams(BaseMessageWrapper, MsgUpdateParamsProto): 43 | @property 44 | def type_url(self): 45 | return "/band.feeds.v1beta1.MsgUpdateParams" 46 | 47 | @property 48 | def legacy_url(self): 49 | return "feeds/MsgUpdateParams" 50 | -------------------------------------------------------------------------------- /pyband/messages/band/globalfee/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/globalfee/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/globalfee/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgUpdateParams 2 | -------------------------------------------------------------------------------- /pyband/messages/band/globalfee/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from pyband.messages.base import BaseMessageWrapper 2 | from pyband.proto.band.globalfee.v1beta1 import ( 3 | MsgUpdateParams as MsgUpdateParamsProto, 4 | ) 5 | 6 | 7 | class MsgUpdateParams(BaseMessageWrapper, MsgUpdateParamsProto): 8 | @property 9 | def type_url(self): 10 | return "/band.globalfee.v1beta1.MsgUpdateParams" 11 | 12 | @property 13 | def legacy_url(self): 14 | return "globalfee/MsgUpdateParams" 15 | -------------------------------------------------------------------------------- /pyband/messages/band/oracle/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/oracle/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/oracle/v1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgCreateDataSource, MsgRequestData, MsgCreateOracleScript, MsgEditDataSource, MsgEditOracleScript 2 | -------------------------------------------------------------------------------- /pyband/messages/band/oracle/v1/msgs.py: -------------------------------------------------------------------------------- 1 | import dataclasses 2 | 3 | from ....base import BaseMessageWrapper 4 | from .....proto.cosmos.base import v1beta1 as __cosmos_base_v1_beta1__ 5 | from .....proto.band.oracle.v1 import MsgCreateDataSource as MsgCreateDataSourceProto 6 | from .....proto.band.oracle.v1 import MsgCreateOracleScript as MsgCreateOracleScriptProto 7 | from .....proto.band.oracle.v1 import MsgEditDataSource as MsgEditDataSourceProto 8 | from .....proto.band.oracle.v1 import MsgEditOracleScript as MsgEditOracleScriptProto 9 | from .....proto.band.oracle.v1 import MsgRequestData as MsgRequestDataProto 10 | 11 | assert __cosmos_base_v1_beta1__ 12 | 13 | 14 | class MsgRequestData(BaseMessageWrapper, MsgRequestDataProto): 15 | @property 16 | def type_url(self): 17 | return "/band.oracle.v1.MsgRequestData" 18 | 19 | @property 20 | def legacy_url(self): 21 | return "oracle/Request" 22 | 23 | 24 | @dataclasses.dataclass 25 | class MsgCreateDataSource(BaseMessageWrapper, MsgCreateDataSourceProto): 26 | @property 27 | def type_url(self): 28 | return "/band.oracle.v1.MsgCreateDataSource" 29 | 30 | @property 31 | def legacy_url(self): 32 | return "oracle/CreateDataSource" 33 | 34 | 35 | class MsgEditDataSource(BaseMessageWrapper, MsgEditDataSourceProto): 36 | @property 37 | def type_url(self): 38 | return "/band.oracle.v1.MsgEditDataSource" 39 | 40 | @property 41 | def legacy_url(self): 42 | return "oracle/EditDataSource" 43 | 44 | 45 | class MsgCreateOracleScript(BaseMessageWrapper, MsgCreateOracleScriptProto): 46 | @property 47 | def type_url(self): 48 | return "/band.oracle.v1.MsgCreateOracleScript" 49 | 50 | @property 51 | def legacy_url(self): 52 | return "oracle/CreateOracleScript" 53 | 54 | 55 | class MsgEditOracleScript(BaseMessageWrapper, MsgEditOracleScriptProto): 56 | @property 57 | def type_url(self): 58 | return "/band.oracle.v1.MsgEditOracleScript" 59 | 60 | @property 61 | def legacy_url(self): 62 | return "oracle/EditOracleScript" 63 | -------------------------------------------------------------------------------- /pyband/messages/band/restake/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/restake/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/restake/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgStake, MsgUnstake, MsgUpdateParams 2 | -------------------------------------------------------------------------------- /pyband/messages/band/restake/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from pyband.messages.base import BaseMessageWrapper 2 | from pyband.proto.band.restake.v1beta1 import ( 3 | MsgStake as MsgStakeProto, 4 | MsgUnstake as MsgUnstakeProto, 5 | MsgUpdateParams as MsgUpdateParamsProto, 6 | ) 7 | 8 | 9 | class MsgStake(BaseMessageWrapper, MsgStakeProto): 10 | @property 11 | def type_url(self): 12 | return "/band.restake.v1beta1.MsgStake" 13 | 14 | @property 15 | def legacy_url(self): 16 | return "restake/MsgStake" 17 | 18 | 19 | class MsgUnstake(BaseMessageWrapper, MsgUnstakeProto): 20 | @property 21 | def type_url(self): 22 | return "/band.restake.v1beta1.MsgUnstake" 23 | 24 | @property 25 | def legacy_url(self): 26 | return "restake/MsgUnstake" 27 | 28 | 29 | class MsgUpdateParams(BaseMessageWrapper, MsgUpdateParamsProto): 30 | @property 31 | def type_url(self): 32 | return "/band.restake.v1beta1.MsgUpdateParams" 33 | 34 | @property 35 | def legacy_url(self): 36 | return "restake/MsgUpdateParams" 37 | -------------------------------------------------------------------------------- /pyband/messages/band/tss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/tss/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/tss/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import ( 2 | MsgSubmitDkgRound1, 3 | MsgSubmitDkgRound2, 4 | MsgComplain, 5 | MsgConfirm, 6 | MsgSubmitDEs, 7 | MsgResetDE, 8 | MsgSubmitSignature, 9 | MsgUpdateParams, 10 | ) 11 | -------------------------------------------------------------------------------- /pyband/messages/band/tss/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from pyband.messages.base import BaseMessageWrapper 2 | from pyband.proto.band.tss.v1beta1 import ( 3 | MsgSubmitDkgRound1 as MsgSubmitDkgRound1Proto, 4 | MsgSubmitDkgRound2 as MsgSubmitDkgRound2Proto, 5 | MsgComplain as MsgComplainProto, 6 | MsgConfirm as MsgConfirmProto, 7 | MsgSubmitDEs as MsgSubmitDEsProto, 8 | MsgResetDe as MsgResetDEProto, 9 | MsgSubmitSignature as MsgSubmitSignatureProto, 10 | MsgUpdateParams as MsgUpdateParamsProto, 11 | ) 12 | 13 | 14 | class MsgSubmitDkgRound1(BaseMessageWrapper, MsgSubmitDkgRound1Proto): 15 | @property 16 | def type_url(self): 17 | return "/band.tss.v1beta1.MsgSubmitDkgRound1" 18 | 19 | @property 20 | def legacy_url(self): 21 | return "tss/MsgSubmitDkgRound1" 22 | 23 | 24 | class MsgSubmitDkgRound2(BaseMessageWrapper, MsgSubmitDkgRound2Proto): 25 | @property 26 | def type_url(self): 27 | return "/band.tss.v1beta1.MsgSubmitDkgRound2" 28 | 29 | @property 30 | def legacy_url(self): 31 | return "tss/MsgSubmitDkgRound2" 32 | 33 | 34 | class MsgComplain(BaseMessageWrapper, MsgComplainProto): 35 | @property 36 | def type_url(self): 37 | return "/band.tss.v1beta1.MsgComplaint" 38 | 39 | @property 40 | def legacy_url(self): 41 | return "tss/MsgComplaint" 42 | 43 | 44 | class MsgConfirm(BaseMessageWrapper, MsgConfirmProto): 45 | @property 46 | def type_url(self): 47 | return "/band.tss.v1beta1.MsgConfirm" 48 | 49 | @property 50 | def legacy_url(self): 51 | return "tss/MsgConfirm" 52 | 53 | 54 | class MsgSubmitDEs(BaseMessageWrapper, MsgSubmitDEsProto): 55 | @property 56 | def type_url(self): 57 | return "/band.tss.v1beta1.MsgSubmitDEs" 58 | 59 | @property 60 | def legacy_url(self): 61 | return "tss/MsgSubmitDEs" 62 | 63 | 64 | class MsgResetDE(BaseMessageWrapper, MsgResetDEProto): 65 | @property 66 | def type_url(self): 67 | return "/band.tss.v1beta1.MsgResetDE" 68 | 69 | @property 70 | def legacy_url(self): 71 | return "tss/MsgResetDE" 72 | 73 | 74 | class MsgSubmitSignature(BaseMessageWrapper, MsgSubmitSignatureProto): 75 | @property 76 | def type_url(self): 77 | return "/band.tss.v1beta1.MsgSubmitSignature" 78 | 79 | @property 80 | def legacy_url(self): 81 | return "tss/MsgSubmitSignature" 82 | 83 | 84 | class MsgUpdateParams(BaseMessageWrapper, MsgUpdateParamsProto): 85 | @property 86 | def type_url(self): 87 | return "/band.tss.v1beta1.MsgUpdateParams" 88 | 89 | @property 90 | def legacy_url(self): 91 | return "tss/MsgUpdateParams" 92 | -------------------------------------------------------------------------------- /pyband/messages/band/tunnel/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/band/tunnel/__init__.py -------------------------------------------------------------------------------- /pyband/messages/band/tunnel/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import ( 2 | MsgCreateTunnel, 3 | MsgUpdateAndResetTunnel, 4 | MsgActivateTunnel, 5 | MsgDeactivateTunnel, 6 | MsgTriggerTunnel, 7 | MsgDepositToTunnel, 8 | MsgWithdrawFromTunnel, 9 | ) 10 | -------------------------------------------------------------------------------- /pyband/messages/band/tunnel/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from pyband.messages.base import BaseMessageWrapper 2 | from pyband.proto.band.tunnel.v1beta1 import ( 3 | MsgCreateTunnel as MsgCreateTunnelProto, 4 | MsgUpdateRoute as MsgUpdateRouteProto, 5 | MsgUpdateSignalsAndInterval as MsgUpdateSignalsAndIntervalProto, 6 | MsgActivateTunnel as MsgActivateTunnelProto, 7 | MsgDeactivateTunnel as MsgDeactivateTunnelProto, 8 | MsgTriggerTunnel as MsgTriggerTunnelProto, 9 | MsgDepositToTunnel as MsgDepositToTunnelProto, 10 | MsgWithdrawFromTunnel as MsgWithdrawFromTunnelProto, 11 | ) 12 | 13 | 14 | class MsgCreateTunnel(BaseMessageWrapper, MsgCreateTunnelProto): 15 | @property 16 | def type_url(self): 17 | return "/band.tunnel.v1beta1.MsgCreateTunnel" 18 | 19 | @property 20 | def legacy_url(self): 21 | return "tunnel/MsgCreateTunnel" 22 | 23 | 24 | class MsgUpdateRoute(BaseMessageWrapper, MsgUpdateRouteProto): 25 | @property 26 | def type_url(self): 27 | return "/band.tunnel.v1beta1.MsgUpdateRoute" 28 | 29 | @property 30 | def legacy_url(self): 31 | return "tunnel/MsgUpdateRoute" 32 | 33 | 34 | class MsgUpdateSignalsAndInterval(BaseMessageWrapper, MsgUpdateSignalsAndIntervalProto): 35 | @property 36 | def type_url(self): 37 | return "/band.tunnel.v1beta1.MsgUpdateSignalsAndInterval" 38 | 39 | @property 40 | def legacy_url(self): 41 | return "tunnel/MsgUpdateSignalsAndInterval" 42 | 43 | 44 | class MsgActivateTunnel(BaseMessageWrapper, MsgActivateTunnelProto): 45 | @property 46 | def type_url(self): 47 | return "/band.tunnel.v1beta1.MsgActivateTunnel" 48 | 49 | @property 50 | def legacy_url(self): 51 | return "tunnel/MsgActivateTunnel" 52 | 53 | 54 | class MsgDeactivateTunnel(BaseMessageWrapper, MsgDeactivateTunnelProto): 55 | @property 56 | def type_url(self): 57 | return "/band.tunnel.v1beta1.MsgDeactivateTunnel" 58 | 59 | @property 60 | def legacy_url(self): 61 | return "tunnel/MsgDeactivateTunnel" 62 | 63 | 64 | class MsgTriggerTunnel(BaseMessageWrapper, MsgTriggerTunnelProto): 65 | @property 66 | def type_url(self): 67 | return "/band.tunnel.v1beta1.MsgTriggerTunnel" 68 | 69 | @property 70 | def legacy_url(self): 71 | return "tunnel/MsgTriggerTunnel" 72 | 73 | 74 | class MsgDepositToTunnel(BaseMessageWrapper, MsgDepositToTunnelProto): 75 | @property 76 | def type_url(self): 77 | return "/band.tunnel.v1beta1.MsgDepositToTunnel" 78 | 79 | @property 80 | def legacy_url(self): 81 | return "tunnel/MsgDepositToTunnel" 82 | 83 | 84 | class MsgWithdrawFromTunnel(BaseMessageWrapper, MsgWithdrawFromTunnelProto): 85 | @property 86 | def type_url(self): 87 | return "/band.tunnel.v1beta1.MsgWithdrawFromTunnel" 88 | 89 | @property 90 | def legacy_url(self): 91 | return "tunnel/MsgWithdrawFromTunnel" 92 | -------------------------------------------------------------------------------- /pyband/messages/base.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | 3 | from betterproto import Message, Casing 4 | 5 | 6 | class BaseMessageWrapper(Message): 7 | @property 8 | @abstractmethod 9 | def type_url(self): 10 | return "" 11 | 12 | @property 13 | @abstractmethod 14 | def legacy_url(self): 15 | return "" 16 | 17 | def to_data(self): 18 | return {"@type": self.type_url} | self.to_dict(include_default_values=True) 19 | 20 | def to_legacy_codec(self): 21 | return { 22 | "type": self.legacy_url, 23 | "value": self.to_dict(include_default_values=False, casing=Casing.SNAKE), 24 | } 25 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/cosmos/__init__.py -------------------------------------------------------------------------------- /pyband/messages/cosmos/bank/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/cosmos/bank/__init__.py -------------------------------------------------------------------------------- /pyband/messages/cosmos/bank/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgSend, MsgMultiSend 2 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/bank/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from ....base import BaseMessageWrapper 2 | from .....proto.cosmos.bank.v1beta1 import MsgMultiSend as MsgMultiSendProto 3 | from .....proto.cosmos.bank.v1beta1 import MsgSend as MsgSendProto 4 | from .....proto.cosmos.base import v1beta1 as __base_v1_beta1__ 5 | from .....proto.cosmos.base.query import v1beta1 as __base_query_v1_beta1__ 6 | 7 | assert __base_v1_beta1__ 8 | assert __base_query_v1_beta1__ 9 | 10 | 11 | class MsgSend(BaseMessageWrapper, MsgSendProto): 12 | @property 13 | def type_url(self): 14 | return "/cosmos.bank.v1beta1.MsgSend" 15 | 16 | @property 17 | def legacy_url(self): 18 | return "cosmos-sdk/MsgSend" 19 | 20 | 21 | class MsgMultiSend(BaseMessageWrapper, MsgMultiSendProto): 22 | @property 23 | def type_url(self): 24 | return "/cosmos.bank.v1beta1.MsgMultiSend" 25 | 26 | @property 27 | def legacy_url(self): 28 | return "cosmos-sdk/MsgMultiSend" 29 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/distribution/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/cosmos/distribution/__init__.py -------------------------------------------------------------------------------- /pyband/messages/cosmos/distribution/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgWithdrawDelegationReward 2 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/distribution/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from ....base import BaseMessageWrapper 2 | from .....proto.cosmos.base import v1beta1 as __base_v1_beta1__ 3 | from .....proto.cosmos.base.query import v1beta1 as __base_query_v1_beta1__ 4 | from .....proto.cosmos.distribution.v1beta1 import ( 5 | MsgWithdrawDelegatorReward as MsgWithdrawDelegatorRewardProto, 6 | ) 7 | 8 | assert __base_v1_beta1__ 9 | assert __base_query_v1_beta1__ 10 | 11 | 12 | class MsgWithdrawDelegationReward(BaseMessageWrapper, MsgWithdrawDelegatorRewardProto): 13 | @property 14 | def type_url(self): 15 | return "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward" 16 | 17 | @property 18 | def legacy_url(self): 19 | return "cosmos-sdk/MsgWithdrawDelegationReward" 20 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/gov/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/cosmos/gov/__init__.py -------------------------------------------------------------------------------- /pyband/messages/cosmos/gov/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgVote 2 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/gov/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from ....base import BaseMessageWrapper 2 | from .....proto.cosmos.base import v1beta1 as __base_v1_beta1__ 3 | from .....proto.cosmos.base.query import v1beta1 as __base_query_v1_beta1__ 4 | from .....proto.cosmos.gov.v1beta1 import MsgVote as MsgVoteProto 5 | 6 | assert __base_v1_beta1__ 7 | assert __base_query_v1_beta1__ 8 | 9 | 10 | class MsgVote(BaseMessageWrapper, MsgVoteProto): 11 | @property 12 | def type_url(self): 13 | return "/cosmos.gov.v1beta1.MsgVote" 14 | 15 | @property 16 | def legacy_url(self): 17 | return "cosmos-sdk/MsgVote" 18 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/staking/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/messages/cosmos/staking/__init__.py -------------------------------------------------------------------------------- /pyband/messages/cosmos/staking/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | from .msgs import MsgBeginRedelegate, MsgDelegate, MsgUndelegate 2 | -------------------------------------------------------------------------------- /pyband/messages/cosmos/staking/v1beta1/msgs.py: -------------------------------------------------------------------------------- 1 | from ....base import BaseMessageWrapper 2 | from .....proto.cosmos.base import v1beta1 as __base_v1_beta1__ 3 | from .....proto.cosmos.base.query import v1beta1 as __base_query_v1_beta1__ 4 | from .....proto.cosmos.staking.v1beta1 import ( 5 | MsgBeginRedelegate as MsgBeginRedelegateProto, 6 | ) 7 | from .....proto.cosmos.staking.v1beta1 import MsgDelegate as MsgDelegateProto 8 | from .....proto.cosmos.staking.v1beta1 import MsgUndelegate as MsgUndelegateProto 9 | from .....proto.tendermint import types as __tendermint_types__ 10 | 11 | assert __base_v1_beta1__ 12 | assert __base_query_v1_beta1__ 13 | assert __tendermint_types__ 14 | 15 | 16 | class MsgBeginRedelegate(BaseMessageWrapper, MsgBeginRedelegateProto): 17 | @property 18 | def type_url(self): 19 | return "/cosmos.staking.v1beta1.MsgBeginRedelegate" 20 | 21 | @property 22 | def legacy_url(self): 23 | return "cosmos-sdk/MsgBeginRedelegate" 24 | 25 | 26 | class MsgDelegate(BaseMessageWrapper, MsgDelegateProto): 27 | @property 28 | def type_url(self): 29 | return "/cosmos.staking.v1beta1.MsgDelegate" 30 | 31 | @property 32 | def legacy_url(self): 33 | return "cosmos-sdk/MsgDelegate" 34 | 35 | 36 | class MsgUndelegate(BaseMessageWrapper, MsgUndelegateProto): 37 | @property 38 | def type_url(self): 39 | return "/cosmos.staking.v1beta1.MsgUndelegate" 40 | 41 | @property 42 | def legacy_url(self): 43 | return "cosmos-sdk/MsgUndelegate" 44 | -------------------------------------------------------------------------------- /pyband/proto/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/__init__.py -------------------------------------------------------------------------------- /pyband/proto/amino/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: amino/amino.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | -------------------------------------------------------------------------------- /pyband/proto/band/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/bandtss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/bandtss/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/base/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/base/node/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/base/node/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/base/node/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: band/base/node/v1/query.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | List, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import grpclib 16 | from betterproto.grpc.grpclib_server import ServiceBase 17 | 18 | 19 | if TYPE_CHECKING: 20 | import grpclib.server 21 | from betterproto.grpc.grpclib_client import MetadataLike 22 | from grpclib.metadata import Deadline 23 | 24 | 25 | @dataclass(eq=False, repr=False) 26 | class ChainIdRequest(betterproto.Message): 27 | """ChainIDRequest is request type for the Service/ChainID RPC method.""" 28 | 29 | pass 30 | 31 | 32 | @dataclass(eq=False, repr=False) 33 | class ChainIdResponse(betterproto.Message): 34 | """ChainIDResponse is response type for the Service/ChainID RPC method.""" 35 | 36 | chain_id: str = betterproto.string_field(1) 37 | 38 | 39 | @dataclass(eq=False, repr=False) 40 | class EvmValidatorsRequest(betterproto.Message): 41 | """ 42 | EVMValidatorsRequest is request type for the Service/EVMValidators RPC method. 43 | """ 44 | 45 | pass 46 | 47 | 48 | @dataclass(eq=False, repr=False) 49 | class EvmValidatorsResponse(betterproto.Message): 50 | """ 51 | EVMValidatorsResponse is response type for the Service/EVMValidators RPC method. 52 | """ 53 | 54 | block_height: int = betterproto.int64_field(1) 55 | """BlockHeight is the latest block height""" 56 | 57 | validators: List["ValidatorMinimal"] = betterproto.message_field(2) 58 | """Validators is list of validator's addresss and voting power""" 59 | 60 | 61 | @dataclass(eq=False, repr=False) 62 | class ValidatorMinimal(betterproto.Message): 63 | """ 64 | ValidatorMinimal is the data structure for storing validator's address and voting power 65 | """ 66 | 67 | address: str = betterproto.string_field(1) 68 | voting_power: int = betterproto.int64_field(2) 69 | 70 | 71 | class ServiceStub(betterproto.ServiceStub): 72 | async def chain_id( 73 | self, 74 | chain_id_request: "ChainIdRequest", 75 | *, 76 | timeout: Optional[float] = None, 77 | deadline: Optional["Deadline"] = None, 78 | metadata: Optional["MetadataLike"] = None 79 | ) -> "ChainIdResponse": 80 | return await self._unary_unary( 81 | "/band.base.node.v1.Service/ChainID", 82 | chain_id_request, 83 | ChainIdResponse, 84 | timeout=timeout, 85 | deadline=deadline, 86 | metadata=metadata, 87 | ) 88 | 89 | async def evm_validators( 90 | self, 91 | evm_validators_request: "EvmValidatorsRequest", 92 | *, 93 | timeout: Optional[float] = None, 94 | deadline: Optional["Deadline"] = None, 95 | metadata: Optional["MetadataLike"] = None 96 | ) -> "EvmValidatorsResponse": 97 | return await self._unary_unary( 98 | "/band.base.node.v1.Service/EVMValidators", 99 | evm_validators_request, 100 | EvmValidatorsResponse, 101 | timeout=timeout, 102 | deadline=deadline, 103 | metadata=metadata, 104 | ) 105 | 106 | 107 | class ServiceBase(ServiceBase): 108 | 109 | async def chain_id(self, chain_id_request: "ChainIdRequest") -> "ChainIdResponse": 110 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 111 | 112 | async def evm_validators( 113 | self, evm_validators_request: "EvmValidatorsRequest" 114 | ) -> "EvmValidatorsResponse": 115 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 116 | 117 | async def __rpc_chain_id( 118 | self, stream: "grpclib.server.Stream[ChainIdRequest, ChainIdResponse]" 119 | ) -> None: 120 | request = await stream.recv_message() 121 | response = await self.chain_id(request) 122 | await stream.send_message(response) 123 | 124 | async def __rpc_evm_validators( 125 | self, 126 | stream: "grpclib.server.Stream[EvmValidatorsRequest, EvmValidatorsResponse]", 127 | ) -> None: 128 | request = await stream.recv_message() 129 | response = await self.evm_validators(request) 130 | await stream.send_message(response) 131 | 132 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 133 | return { 134 | "/band.base.node.v1.Service/ChainID": grpclib.const.Handler( 135 | self.__rpc_chain_id, 136 | grpclib.const.Cardinality.UNARY_UNARY, 137 | ChainIdRequest, 138 | ChainIdResponse, 139 | ), 140 | "/band.base.node.v1.Service/EVMValidators": grpclib.const.Handler( 141 | self.__rpc_evm_validators, 142 | grpclib.const.Cardinality.UNARY_UNARY, 143 | EvmValidatorsRequest, 144 | EvmValidatorsResponse, 145 | ), 146 | } 147 | -------------------------------------------------------------------------------- /pyband/proto/band/base/oracle/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/base/oracle/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/feeds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/feeds/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/globalfee/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/globalfee/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/globalfee/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: band/globalfee/v1beta1/genesis.proto, band/globalfee/v1beta1/query.proto, band/globalfee/v1beta1/tx.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | List, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import grpclib 16 | from betterproto.grpc.grpclib_server import ServiceBase 17 | 18 | from ....cosmos.base import v1beta1 as __cosmos_base_v1_beta1__ 19 | 20 | 21 | if TYPE_CHECKING: 22 | import grpclib.server 23 | from betterproto.grpc.grpclib_client import MetadataLike 24 | from grpclib.metadata import Deadline 25 | 26 | 27 | @dataclass(eq=False, repr=False) 28 | class GenesisState(betterproto.Message): 29 | """GenesisState - initial state of module""" 30 | 31 | params: "Params" = betterproto.message_field(1) 32 | """Params of this module""" 33 | 34 | 35 | @dataclass(eq=False, repr=False) 36 | class Params(betterproto.Message): 37 | """Params defines the set of module parameters.""" 38 | 39 | minimum_gas_prices: List["__cosmos_base_v1_beta1__.DecCoin"] = ( 40 | betterproto.message_field(1) 41 | ) 42 | """ 43 | Minimum stores the minimum gas price(s) for all TX on the chain. 44 | When multiple coins are defined then they are accepted alternatively. 45 | The list must be sorted by denoms asc. No duplicate denoms or zero amount 46 | values allowed. For more information see 47 | https://docs.cosmos.network/main/modules/auth#concepts 48 | """ 49 | 50 | 51 | @dataclass(eq=False, repr=False) 52 | class MsgUpdateParams(betterproto.Message): 53 | """ 54 | MsgUpdateParams is the Msg/UpdateParams request type. 55 | 56 | Since: cosmos-sdk 0.47 57 | """ 58 | 59 | authority: str = betterproto.string_field(1) 60 | """authority is the address of the governance account.""" 61 | 62 | params: "Params" = betterproto.message_field(2) 63 | """ 64 | params defines the x/globalfee parameters to update. 65 | 66 | NOTE: All parameters must be supplied. 67 | """ 68 | 69 | 70 | @dataclass(eq=False, repr=False) 71 | class MsgUpdateParamsResponse(betterproto.Message): 72 | """ 73 | MsgUpdateParamsResponse defines the response structure for executing a 74 | MsgUpdateParams message. 75 | 76 | Since: cosmos-sdk 0.47 77 | """ 78 | 79 | pass 80 | 81 | 82 | @dataclass(eq=False, repr=False) 83 | class QueryParamsRequest(betterproto.Message): 84 | """QueryParamsRequest is request type for the Query/Params RPC method.""" 85 | 86 | pass 87 | 88 | 89 | @dataclass(eq=False, repr=False) 90 | class QueryParamsResponse(betterproto.Message): 91 | """ 92 | QueryParamsResponse is response type for the Query/Params RPC method. 93 | """ 94 | 95 | params: "Params" = betterproto.message_field(1) 96 | """pagination defines an optional pagination for the request.""" 97 | 98 | 99 | class MsgStub(betterproto.ServiceStub): 100 | async def update_params( 101 | self, 102 | msg_update_params: "MsgUpdateParams", 103 | *, 104 | timeout: Optional[float] = None, 105 | deadline: Optional["Deadline"] = None, 106 | metadata: Optional["MetadataLike"] = None, 107 | ) -> "MsgUpdateParamsResponse": 108 | return await self._unary_unary( 109 | "/band.globalfee.v1beta1.Msg/UpdateParams", 110 | msg_update_params, 111 | MsgUpdateParamsResponse, 112 | timeout=timeout, 113 | deadline=deadline, 114 | metadata=metadata, 115 | ) 116 | 117 | 118 | class QueryStub(betterproto.ServiceStub): 119 | async def params( 120 | self, 121 | query_params_request: "QueryParamsRequest", 122 | *, 123 | timeout: Optional[float] = None, 124 | deadline: Optional["Deadline"] = None, 125 | metadata: Optional["MetadataLike"] = None, 126 | ) -> "QueryParamsResponse": 127 | return await self._unary_unary( 128 | "/band.globalfee.v1beta1.Query/Params", 129 | query_params_request, 130 | QueryParamsResponse, 131 | timeout=timeout, 132 | deadline=deadline, 133 | metadata=metadata, 134 | ) 135 | 136 | 137 | class MsgBase(ServiceBase): 138 | async def update_params( 139 | self, msg_update_params: "MsgUpdateParams" 140 | ) -> "MsgUpdateParamsResponse": 141 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 142 | 143 | async def __rpc_update_params( 144 | self, stream: "grpclib.server.Stream[MsgUpdateParams, MsgUpdateParamsResponse]" 145 | ) -> None: 146 | request = await stream.recv_message() 147 | response = await self.update_params(request) 148 | await stream.send_message(response) 149 | 150 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 151 | return { 152 | "/band.globalfee.v1beta1.Msg/UpdateParams": grpclib.const.Handler( 153 | self.__rpc_update_params, 154 | grpclib.const.Cardinality.UNARY_UNARY, 155 | MsgUpdateParams, 156 | MsgUpdateParamsResponse, 157 | ), 158 | } 159 | 160 | 161 | class QueryBase(ServiceBase): 162 | async def params( 163 | self, query_params_request: "QueryParamsRequest" 164 | ) -> "QueryParamsResponse": 165 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 166 | 167 | async def __rpc_params( 168 | self, stream: "grpclib.server.Stream[QueryParamsRequest, QueryParamsResponse]" 169 | ) -> None: 170 | request = await stream.recv_message() 171 | response = await self.params(request) 172 | await stream.send_message(response) 173 | 174 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 175 | return { 176 | "/band.globalfee.v1beta1.Query/Params": grpclib.const.Handler( 177 | self.__rpc_params, 178 | grpclib.const.Cardinality.UNARY_UNARY, 179 | QueryParamsRequest, 180 | QueryParamsResponse, 181 | ), 182 | } 183 | -------------------------------------------------------------------------------- /pyband/proto/band/oracle/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/oracle/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/restake/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/restake/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/rollingseed/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/rollingseed/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/rollingseed/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: band/rollingseed/v1beta1/genesis.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class GenesisState(betterproto.Message): 13 | """GenesisState defines the rollingseed module's genesis state.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/band/tss/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/tss/__init__.py -------------------------------------------------------------------------------- /pyband/proto/band/tunnel/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/band/tunnel/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/app/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/app/runtime/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/app/runtime/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/app/runtime/v1alpha1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/app/runtime/v1alpha1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Module(betterproto.Message): 14 | """Module is the config object for the runtime module.""" 15 | 16 | app_name: str = betterproto.string_field(1) 17 | """app_name is the name of the app.""" 18 | 19 | begin_blockers: List[str] = betterproto.string_field(2) 20 | """ 21 | begin_blockers specifies the module names of begin blockers 22 | to call in the order in which they should be called. If this is left empty 23 | no begin blocker will be registered. 24 | """ 25 | 26 | end_blockers: List[str] = betterproto.string_field(3) 27 | """ 28 | end_blockers specifies the module names of the end blockers 29 | to call in the order in which they should be called. If this is left empty 30 | no end blocker will be registered. 31 | """ 32 | 33 | init_genesis: List[str] = betterproto.string_field(4) 34 | """ 35 | init_genesis specifies the module names of init genesis functions 36 | to call in the order in which they should be called. If this is left empty 37 | no init genesis function will be registered. 38 | """ 39 | 40 | export_genesis: List[str] = betterproto.string_field(5) 41 | """ 42 | export_genesis specifies the order in which to export module genesis data. 43 | If this is left empty, the init_genesis order will be used for export genesis 44 | if it is specified. 45 | """ 46 | 47 | override_store_keys: List["StoreKeyConfig"] = betterproto.message_field(6) 48 | """ 49 | override_store_keys is an optional list of overrides for the module store keys 50 | to be used in keeper construction. 51 | """ 52 | 53 | order_migrations: List[str] = betterproto.string_field(7) 54 | """ 55 | order_migrations defines the order in which module migrations are performed. 56 | If this is left empty, it uses the default migration order. 57 | https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.47.0-alpha2/types/module#DefaultMigrationsOrder 58 | """ 59 | 60 | precommiters: List[str] = betterproto.string_field(8) 61 | """ 62 | precommiters specifies the module names of the precommiters 63 | to call in the order in which they should be called. If this is left empty 64 | no precommit function will be registered. 65 | """ 66 | 67 | prepare_check_staters: List[str] = betterproto.string_field(9) 68 | """ 69 | prepare_check_staters specifies the module names of the prepare_check_staters 70 | to call in the order in which they should be called. If this is left empty 71 | no preparecheckstate function will be registered. 72 | """ 73 | 74 | 75 | @dataclass(eq=False, repr=False) 76 | class StoreKeyConfig(betterproto.Message): 77 | """ 78 | StoreKeyConfig may be supplied to override the default module store key, which 79 | is the module name. 80 | """ 81 | 82 | module_name: str = betterproto.string_field(1) 83 | """name of the module to override the store key of""" 84 | 85 | kv_store_key: str = betterproto.string_field(2) 86 | """the kv store key to use instead of the module name.""" 87 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/auth/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/auth/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/auth/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/auth/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/auth/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/auth/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Module(betterproto.Message): 14 | """Module is the config object for the auth module.""" 15 | 16 | bech32_prefix: str = betterproto.string_field(1) 17 | """bech32_prefix is the bech32 account prefix for the app.""" 18 | 19 | module_account_permissions: List["ModuleAccountPermission"] = ( 20 | betterproto.message_field(2) 21 | ) 22 | """module_account_permissions are module account permissions.""" 23 | 24 | authority: str = betterproto.string_field(3) 25 | """ 26 | authority defines the custom module authority. If not set, defaults to the governance module. 27 | """ 28 | 29 | 30 | @dataclass(eq=False, repr=False) 31 | class ModuleAccountPermission(betterproto.Message): 32 | """ModuleAccountPermission represents permissions for a module account.""" 33 | 34 | account: str = betterproto.string_field(1) 35 | """account is the name of the module.""" 36 | 37 | permissions: List[str] = betterproto.string_field(2) 38 | """ 39 | permissions are the permissions this module has. Currently recognized 40 | values are minter, burner and staking. 41 | """ 42 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/authz/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/authz/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/authz/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/authz/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/authz/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/authz/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the authz module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/autocli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/autocli/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/bank/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/bank/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/bank/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/bank/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/bank/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/bank/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Module(betterproto.Message): 14 | """Module is the config object of the bank module.""" 15 | 16 | blocked_module_accounts_override: List[str] = betterproto.string_field(1) 17 | """ 18 | blocked_module_accounts_override configures exceptional module accounts which should be blocked from receiving 19 | funds. If left empty it defaults to the list of account names supplied in the auth module configuration as 20 | module_account_permissions 21 | """ 22 | 23 | authority: str = betterproto.string_field(2) 24 | """ 25 | authority defines the custom module authority. If not set, defaults to the governance module. 26 | """ 27 | 28 | restrictions_order: List[str] = betterproto.string_field(3) 29 | """ 30 | restrictions_order specifies the order of send restrictions and should be 31 | a list of module names which provide a send restriction instance. If no 32 | order is provided, then restrictions will be applied in alphabetical order 33 | of module names. 34 | """ 35 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/base/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/abci/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/base/abci/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/node/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/base/node/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/node/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/base/node/v1beta1/query.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from datetime import datetime 8 | from typing import ( 9 | TYPE_CHECKING, 10 | Dict, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import grpclib 16 | from betterproto.grpc.grpclib_server import ServiceBase 17 | 18 | 19 | if TYPE_CHECKING: 20 | import grpclib.server 21 | from betterproto.grpc.grpclib_client import MetadataLike 22 | from grpclib.metadata import Deadline 23 | 24 | 25 | @dataclass(eq=False, repr=False) 26 | class ConfigRequest(betterproto.Message): 27 | """ 28 | ConfigRequest defines the request structure for the Config gRPC query. 29 | """ 30 | 31 | pass 32 | 33 | 34 | @dataclass(eq=False, repr=False) 35 | class ConfigResponse(betterproto.Message): 36 | """ 37 | ConfigResponse defines the response structure for the Config gRPC query. 38 | """ 39 | 40 | minimum_gas_price: str = betterproto.string_field(1) 41 | pruning_keep_recent: str = betterproto.string_field(2) 42 | pruning_interval: str = betterproto.string_field(3) 43 | halt_height: int = betterproto.uint64_field(4) 44 | 45 | 46 | @dataclass(eq=False, repr=False) 47 | class StatusRequest(betterproto.Message): 48 | """StateRequest defines the request structure for the status of a node.""" 49 | 50 | pass 51 | 52 | 53 | @dataclass(eq=False, repr=False) 54 | class StatusResponse(betterproto.Message): 55 | """ 56 | StateResponse defines the response structure for the status of a node. 57 | """ 58 | 59 | earliest_store_height: int = betterproto.uint64_field(1) 60 | height: int = betterproto.uint64_field(2) 61 | timestamp: datetime = betterproto.message_field(3) 62 | app_hash: bytes = betterproto.bytes_field(4) 63 | validator_hash: bytes = betterproto.bytes_field(5) 64 | 65 | 66 | class ServiceStub(betterproto.ServiceStub): 67 | async def config( 68 | self, 69 | config_request: "ConfigRequest", 70 | *, 71 | timeout: Optional[float] = None, 72 | deadline: Optional["Deadline"] = None, 73 | metadata: Optional["MetadataLike"] = None 74 | ) -> "ConfigResponse": 75 | return await self._unary_unary( 76 | "/cosmos.base.node.v1beta1.Service/Config", 77 | config_request, 78 | ConfigResponse, 79 | timeout=timeout, 80 | deadline=deadline, 81 | metadata=metadata, 82 | ) 83 | 84 | async def status( 85 | self, 86 | status_request: "StatusRequest", 87 | *, 88 | timeout: Optional[float] = None, 89 | deadline: Optional["Deadline"] = None, 90 | metadata: Optional["MetadataLike"] = None 91 | ) -> "StatusResponse": 92 | return await self._unary_unary( 93 | "/cosmos.base.node.v1beta1.Service/Status", 94 | status_request, 95 | StatusResponse, 96 | timeout=timeout, 97 | deadline=deadline, 98 | metadata=metadata, 99 | ) 100 | 101 | 102 | class ServiceBase(ServiceBase): 103 | 104 | async def config(self, config_request: "ConfigRequest") -> "ConfigResponse": 105 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 106 | 107 | async def status(self, status_request: "StatusRequest") -> "StatusResponse": 108 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 109 | 110 | async def __rpc_config( 111 | self, stream: "grpclib.server.Stream[ConfigRequest, ConfigResponse]" 112 | ) -> None: 113 | request = await stream.recv_message() 114 | response = await self.config(request) 115 | await stream.send_message(response) 116 | 117 | async def __rpc_status( 118 | self, stream: "grpclib.server.Stream[StatusRequest, StatusResponse]" 119 | ) -> None: 120 | request = await stream.recv_message() 121 | response = await self.status(request) 122 | await stream.send_message(response) 123 | 124 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 125 | return { 126 | "/cosmos.base.node.v1beta1.Service/Config": grpclib.const.Handler( 127 | self.__rpc_config, 128 | grpclib.const.Cardinality.UNARY_UNARY, 129 | ConfigRequest, 130 | ConfigResponse, 131 | ), 132 | "/cosmos.base.node.v1beta1.Service/Status": grpclib.const.Handler( 133 | self.__rpc_status, 134 | grpclib.const.Cardinality.UNARY_UNARY, 135 | StatusRequest, 136 | StatusResponse, 137 | ), 138 | } 139 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/query/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/base/query/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/query/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/base/query/v1beta1/pagination.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class PageRequest(betterproto.Message): 13 | """ 14 | PageRequest is to be embedded in gRPC request messages for efficient 15 | pagination. Ex: 16 | 17 | message SomeRequest { 18 | Foo some_parameter = 1; 19 | PageRequest pagination = 2; 20 | } 21 | """ 22 | 23 | key: bytes = betterproto.bytes_field(1) 24 | """ 25 | key is a value returned in PageResponse.next_key to begin 26 | querying the next page most efficiently. Only one of offset or key 27 | should be set. 28 | """ 29 | 30 | offset: int = betterproto.uint64_field(2) 31 | """ 32 | offset is a numeric offset that can be used when key is unavailable. 33 | It is less efficient than using key. Only one of offset or key should 34 | be set. 35 | """ 36 | 37 | limit: int = betterproto.uint64_field(3) 38 | """ 39 | limit is the total number of results to be returned in the result page. 40 | If left empty it will default to a value to be set by each app. 41 | """ 42 | 43 | count_total: bool = betterproto.bool_field(4) 44 | """ 45 | count_total is set to true to indicate that the result set should include 46 | a count of the total number of items available for pagination in UIs. 47 | count_total is only respected when offset is used. It is ignored when key 48 | is set. 49 | """ 50 | 51 | reverse: bool = betterproto.bool_field(5) 52 | """ 53 | reverse is set to true if results are to be returned in the descending order. 54 | 55 | Since: cosmos-sdk 0.43 56 | """ 57 | 58 | 59 | @dataclass(eq=False, repr=False) 60 | class PageResponse(betterproto.Message): 61 | """ 62 | PageResponse is to be embedded in gRPC response messages where the 63 | corresponding request message has used PageRequest. 64 | 65 | message SomeResponse { 66 | repeated Bar results = 1; 67 | PageResponse page = 2; 68 | } 69 | """ 70 | 71 | next_key: bytes = betterproto.bytes_field(1) 72 | """ 73 | next_key is the key to be passed to PageRequest.key to 74 | query the next page most efficiently. It will be empty if 75 | there are no more results. 76 | """ 77 | 78 | total: int = betterproto.uint64_field(2) 79 | """ 80 | total is total number of results available if PageRequest.count_total 81 | was set, its value is undefined otherwise 82 | """ 83 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/reflection/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/base/reflection/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/reflection/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/base/reflection/v1beta1/reflection.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | List, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import grpclib 16 | from betterproto.grpc.grpclib_server import ServiceBase 17 | 18 | 19 | if TYPE_CHECKING: 20 | import grpclib.server 21 | from betterproto.grpc.grpclib_client import MetadataLike 22 | from grpclib.metadata import Deadline 23 | 24 | 25 | @dataclass(eq=False, repr=False) 26 | class ListAllInterfacesRequest(betterproto.Message): 27 | """ 28 | ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. 29 | """ 30 | 31 | pass 32 | 33 | 34 | @dataclass(eq=False, repr=False) 35 | class ListAllInterfacesResponse(betterproto.Message): 36 | """ 37 | ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. 38 | """ 39 | 40 | interface_names: List[str] = betterproto.string_field(1) 41 | """interface_names is an array of all the registered interfaces.""" 42 | 43 | 44 | @dataclass(eq=False, repr=False) 45 | class ListImplementationsRequest(betterproto.Message): 46 | """ 47 | ListImplementationsRequest is the request type of the ListImplementations 48 | RPC. 49 | """ 50 | 51 | interface_name: str = betterproto.string_field(1) 52 | """ 53 | interface_name defines the interface to query the implementations for. 54 | """ 55 | 56 | 57 | @dataclass(eq=False, repr=False) 58 | class ListImplementationsResponse(betterproto.Message): 59 | """ 60 | ListImplementationsResponse is the response type of the ListImplementations 61 | RPC. 62 | """ 63 | 64 | implementation_message_names: List[str] = betterproto.string_field(1) 65 | 66 | 67 | class ReflectionServiceStub(betterproto.ServiceStub): 68 | async def list_all_interfaces( 69 | self, 70 | list_all_interfaces_request: "ListAllInterfacesRequest", 71 | *, 72 | timeout: Optional[float] = None, 73 | deadline: Optional["Deadline"] = None, 74 | metadata: Optional["MetadataLike"] = None 75 | ) -> "ListAllInterfacesResponse": 76 | return await self._unary_unary( 77 | "/cosmos.base.reflection.v1beta1.ReflectionService/ListAllInterfaces", 78 | list_all_interfaces_request, 79 | ListAllInterfacesResponse, 80 | timeout=timeout, 81 | deadline=deadline, 82 | metadata=metadata, 83 | ) 84 | 85 | async def list_implementations( 86 | self, 87 | list_implementations_request: "ListImplementationsRequest", 88 | *, 89 | timeout: Optional[float] = None, 90 | deadline: Optional["Deadline"] = None, 91 | metadata: Optional["MetadataLike"] = None 92 | ) -> "ListImplementationsResponse": 93 | return await self._unary_unary( 94 | "/cosmos.base.reflection.v1beta1.ReflectionService/ListImplementations", 95 | list_implementations_request, 96 | ListImplementationsResponse, 97 | timeout=timeout, 98 | deadline=deadline, 99 | metadata=metadata, 100 | ) 101 | 102 | 103 | class ReflectionServiceBase(ServiceBase): 104 | 105 | async def list_all_interfaces( 106 | self, list_all_interfaces_request: "ListAllInterfacesRequest" 107 | ) -> "ListAllInterfacesResponse": 108 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 109 | 110 | async def list_implementations( 111 | self, list_implementations_request: "ListImplementationsRequest" 112 | ) -> "ListImplementationsResponse": 113 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 114 | 115 | async def __rpc_list_all_interfaces( 116 | self, 117 | stream: "grpclib.server.Stream[ListAllInterfacesRequest, ListAllInterfacesResponse]", 118 | ) -> None: 119 | request = await stream.recv_message() 120 | response = await self.list_all_interfaces(request) 121 | await stream.send_message(response) 122 | 123 | async def __rpc_list_implementations( 124 | self, 125 | stream: "grpclib.server.Stream[ListImplementationsRequest, ListImplementationsResponse]", 126 | ) -> None: 127 | request = await stream.recv_message() 128 | response = await self.list_implementations(request) 129 | await stream.send_message(response) 130 | 131 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 132 | return { 133 | "/cosmos.base.reflection.v1beta1.ReflectionService/ListAllInterfaces": grpclib.const.Handler( 134 | self.__rpc_list_all_interfaces, 135 | grpclib.const.Cardinality.UNARY_UNARY, 136 | ListAllInterfacesRequest, 137 | ListAllInterfacesResponse, 138 | ), 139 | "/cosmos.base.reflection.v1beta1.ReflectionService/ListImplementations": grpclib.const.Handler( 140 | self.__rpc_list_implementations, 141 | grpclib.const.Cardinality.UNARY_UNARY, 142 | ListImplementationsRequest, 143 | ListImplementationsResponse, 144 | ), 145 | } 146 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/tendermint/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/base/tendermint/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/base/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/base/v1beta1/coin.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Coin(betterproto.Message): 13 | """ 14 | Coin defines a token with a denomination and an amount. 15 | 16 | NOTE: The amount field is an Int which implements the custom method 17 | signatures required by gogoproto. 18 | """ 19 | 20 | denom: str = betterproto.string_field(1) 21 | amount: str = betterproto.string_field(2) 22 | 23 | 24 | @dataclass(eq=False, repr=False) 25 | class DecCoin(betterproto.Message): 26 | """ 27 | DecCoin defines a token with a denomination and a decimal amount. 28 | 29 | NOTE: The amount field is an Dec which implements the custom method 30 | signatures required by gogoproto. 31 | """ 32 | 33 | denom: str = betterproto.string_field(1) 34 | amount: str = betterproto.string_field(2) 35 | 36 | 37 | @dataclass(eq=False, repr=False) 38 | class IntProto(betterproto.Message): 39 | """ 40 | IntProto defines a Protobuf wrapper around an Int object. 41 | Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal. 42 | """ 43 | 44 | int: str = betterproto.string_field(1) 45 | 46 | 47 | @dataclass(eq=False, repr=False) 48 | class DecProto(betterproto.Message): 49 | """ 50 | DecProto defines a Protobuf wrapper around a Dec object. 51 | Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal. 52 | """ 53 | 54 | dec: str = betterproto.string_field(1) 55 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/circuit/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/circuit/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/circuit/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/circuit/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/circuit/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/circuit/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the circuit module.""" 14 | 15 | authority: str = betterproto.string_field(1) 16 | """ 17 | authority defines the custom module authority. If not set, defaults to the governance module. 18 | """ 19 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/consensus/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/consensus/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/consensus/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/consensus/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/consensus/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/consensus/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the consensus module.""" 14 | 15 | authority: str = betterproto.string_field(1) 16 | """ 17 | authority defines the custom module authority. If not set, defaults to the governance module. 18 | """ 19 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/consensus/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/consensus/v1/query.proto, cosmos/consensus/v1/tx.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | Optional, 11 | ) 12 | 13 | import betterproto 14 | import grpclib 15 | from betterproto.grpc.grpclib_server import ServiceBase 16 | 17 | from ....tendermint import types as __tendermint_types__ 18 | 19 | 20 | if TYPE_CHECKING: 21 | import grpclib.server 22 | from betterproto.grpc.grpclib_client import MetadataLike 23 | from grpclib.metadata import Deadline 24 | 25 | 26 | @dataclass(eq=False, repr=False) 27 | class MsgUpdateParams(betterproto.Message): 28 | """MsgUpdateParams is the Msg/UpdateParams request type.""" 29 | 30 | authority: str = betterproto.string_field(1) 31 | """ 32 | authority is the address that controls the module (defaults to x/gov unless overwritten). 33 | """ 34 | 35 | block: "__tendermint_types__.BlockParams" = betterproto.message_field(2) 36 | """ 37 | params defines the x/consensus parameters to update. 38 | VersionsParams is not included in this Msg because it is tracked 39 | separarately in x/upgrade. 40 | 41 | NOTE: All parameters must be supplied. 42 | """ 43 | 44 | evidence: "__tendermint_types__.EvidenceParams" = betterproto.message_field(3) 45 | validator: "__tendermint_types__.ValidatorParams" = betterproto.message_field(4) 46 | abci: "__tendermint_types__.AbciParams" = betterproto.message_field(5) 47 | """Since: cosmos-sdk 0.50""" 48 | 49 | 50 | @dataclass(eq=False, repr=False) 51 | class MsgUpdateParamsResponse(betterproto.Message): 52 | """ 53 | MsgUpdateParamsResponse defines the response structure for executing a 54 | MsgUpdateParams message. 55 | """ 56 | 57 | pass 58 | 59 | 60 | @dataclass(eq=False, repr=False) 61 | class QueryParamsRequest(betterproto.Message): 62 | """ 63 | QueryParamsRequest defines the request type for querying x/consensus parameters. 64 | """ 65 | 66 | pass 67 | 68 | 69 | @dataclass(eq=False, repr=False) 70 | class QueryParamsResponse(betterproto.Message): 71 | """ 72 | QueryParamsResponse defines the response type for querying x/consensus parameters. 73 | """ 74 | 75 | params: "__tendermint_types__.ConsensusParams" = betterproto.message_field(1) 76 | """ 77 | params are the tendermint consensus params stored in the consensus module. 78 | Please note that `params.version` is not populated in this response, it is 79 | tracked separately in the x/upgrade module. 80 | """ 81 | 82 | 83 | class MsgStub(betterproto.ServiceStub): 84 | async def update_params( 85 | self, 86 | msg_update_params: "MsgUpdateParams", 87 | *, 88 | timeout: Optional[float] = None, 89 | deadline: Optional["Deadline"] = None, 90 | metadata: Optional["MetadataLike"] = None, 91 | ) -> "MsgUpdateParamsResponse": 92 | return await self._unary_unary( 93 | "/cosmos.consensus.v1.Msg/UpdateParams", 94 | msg_update_params, 95 | MsgUpdateParamsResponse, 96 | timeout=timeout, 97 | deadline=deadline, 98 | metadata=metadata, 99 | ) 100 | 101 | 102 | class QueryStub(betterproto.ServiceStub): 103 | async def params( 104 | self, 105 | query_params_request: "QueryParamsRequest", 106 | *, 107 | timeout: Optional[float] = None, 108 | deadline: Optional["Deadline"] = None, 109 | metadata: Optional["MetadataLike"] = None, 110 | ) -> "QueryParamsResponse": 111 | return await self._unary_unary( 112 | "/cosmos.consensus.v1.Query/Params", 113 | query_params_request, 114 | QueryParamsResponse, 115 | timeout=timeout, 116 | deadline=deadline, 117 | metadata=metadata, 118 | ) 119 | 120 | 121 | class MsgBase(ServiceBase): 122 | 123 | async def update_params( 124 | self, msg_update_params: "MsgUpdateParams" 125 | ) -> "MsgUpdateParamsResponse": 126 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 127 | 128 | async def __rpc_update_params( 129 | self, stream: "grpclib.server.Stream[MsgUpdateParams, MsgUpdateParamsResponse]" 130 | ) -> None: 131 | request = await stream.recv_message() 132 | response = await self.update_params(request) 133 | await stream.send_message(response) 134 | 135 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 136 | return { 137 | "/cosmos.consensus.v1.Msg/UpdateParams": grpclib.const.Handler( 138 | self.__rpc_update_params, 139 | grpclib.const.Cardinality.UNARY_UNARY, 140 | MsgUpdateParams, 141 | MsgUpdateParamsResponse, 142 | ), 143 | } 144 | 145 | 146 | class QueryBase(ServiceBase): 147 | 148 | async def params( 149 | self, query_params_request: "QueryParamsRequest" 150 | ) -> "QueryParamsResponse": 151 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 152 | 153 | async def __rpc_params( 154 | self, stream: "grpclib.server.Stream[QueryParamsRequest, QueryParamsResponse]" 155 | ) -> None: 156 | request = await stream.recv_message() 157 | response = await self.params(request) 158 | await stream.send_message(response) 159 | 160 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 161 | return { 162 | "/cosmos.consensus.v1.Query/Params": grpclib.const.Handler( 163 | self.__rpc_params, 164 | grpclib.const.Cardinality.UNARY_UNARY, 165 | QueryParamsRequest, 166 | QueryParamsResponse, 167 | ), 168 | } 169 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crisis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/crisis/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/crisis/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/crisis/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/crisis/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crisis/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the crisis module.""" 14 | 15 | fee_collector_name: str = betterproto.string_field(1) 16 | """fee_collector_name is the name of the FeeCollector ModuleAccount.""" 17 | 18 | authority: str = betterproto.string_field(2) 19 | """ 20 | authority defines the custom module authority. If not set, defaults to the governance module. 21 | """ 22 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crisis/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crisis/v1beta1/genesis.proto, cosmos/crisis/v1beta1/tx.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | Optional, 11 | ) 12 | 13 | import betterproto 14 | import grpclib 15 | from betterproto.grpc.grpclib_server import ServiceBase 16 | 17 | from ...base import v1beta1 as __base_v1_beta1__ 18 | 19 | 20 | if TYPE_CHECKING: 21 | import grpclib.server 22 | from betterproto.grpc.grpclib_client import MetadataLike 23 | from grpclib.metadata import Deadline 24 | 25 | 26 | @dataclass(eq=False, repr=False) 27 | class MsgVerifyInvariant(betterproto.Message): 28 | """ 29 | MsgVerifyInvariant represents a message to verify a particular invariance. 30 | """ 31 | 32 | sender: str = betterproto.string_field(1) 33 | """ 34 | sender is the account address of private key to send coins to fee collector account. 35 | """ 36 | 37 | invariant_module_name: str = betterproto.string_field(2) 38 | """name of the invariant module.""" 39 | 40 | invariant_route: str = betterproto.string_field(3) 41 | """invariant_route is the msg's invariant route.""" 42 | 43 | 44 | @dataclass(eq=False, repr=False) 45 | class MsgVerifyInvariantResponse(betterproto.Message): 46 | """ 47 | MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. 48 | """ 49 | 50 | pass 51 | 52 | 53 | @dataclass(eq=False, repr=False) 54 | class MsgUpdateParams(betterproto.Message): 55 | """ 56 | MsgUpdateParams is the Msg/UpdateParams request type. 57 | 58 | Since: cosmos-sdk 0.47 59 | """ 60 | 61 | authority: str = betterproto.string_field(1) 62 | """ 63 | authority is the address that controls the module (defaults to x/gov unless overwritten). 64 | """ 65 | 66 | constant_fee: "__base_v1_beta1__.Coin" = betterproto.message_field(2) 67 | """constant_fee defines the x/crisis parameter.""" 68 | 69 | 70 | @dataclass(eq=False, repr=False) 71 | class MsgUpdateParamsResponse(betterproto.Message): 72 | """ 73 | MsgUpdateParamsResponse defines the response structure for executing a 74 | MsgUpdateParams message. 75 | 76 | Since: cosmos-sdk 0.47 77 | """ 78 | 79 | pass 80 | 81 | 82 | @dataclass(eq=False, repr=False) 83 | class GenesisState(betterproto.Message): 84 | """GenesisState defines the crisis module's genesis state.""" 85 | 86 | constant_fee: "__base_v1_beta1__.Coin" = betterproto.message_field(3) 87 | """ 88 | constant_fee is the fee used to verify the invariant in the crisis 89 | module. 90 | """ 91 | 92 | 93 | class MsgStub(betterproto.ServiceStub): 94 | async def verify_invariant( 95 | self, 96 | msg_verify_invariant: "MsgVerifyInvariant", 97 | *, 98 | timeout: Optional[float] = None, 99 | deadline: Optional["Deadline"] = None, 100 | metadata: Optional["MetadataLike"] = None 101 | ) -> "MsgVerifyInvariantResponse": 102 | return await self._unary_unary( 103 | "/cosmos.crisis.v1beta1.Msg/VerifyInvariant", 104 | msg_verify_invariant, 105 | MsgVerifyInvariantResponse, 106 | timeout=timeout, 107 | deadline=deadline, 108 | metadata=metadata, 109 | ) 110 | 111 | async def update_params( 112 | self, 113 | msg_update_params: "MsgUpdateParams", 114 | *, 115 | timeout: Optional[float] = None, 116 | deadline: Optional["Deadline"] = None, 117 | metadata: Optional["MetadataLike"] = None 118 | ) -> "MsgUpdateParamsResponse": 119 | return await self._unary_unary( 120 | "/cosmos.crisis.v1beta1.Msg/UpdateParams", 121 | msg_update_params, 122 | MsgUpdateParamsResponse, 123 | timeout=timeout, 124 | deadline=deadline, 125 | metadata=metadata, 126 | ) 127 | 128 | 129 | class MsgBase(ServiceBase): 130 | 131 | async def verify_invariant( 132 | self, msg_verify_invariant: "MsgVerifyInvariant" 133 | ) -> "MsgVerifyInvariantResponse": 134 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 135 | 136 | async def update_params( 137 | self, msg_update_params: "MsgUpdateParams" 138 | ) -> "MsgUpdateParamsResponse": 139 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 140 | 141 | async def __rpc_verify_invariant( 142 | self, 143 | stream: "grpclib.server.Stream[MsgVerifyInvariant, MsgVerifyInvariantResponse]", 144 | ) -> None: 145 | request = await stream.recv_message() 146 | response = await self.verify_invariant(request) 147 | await stream.send_message(response) 148 | 149 | async def __rpc_update_params( 150 | self, stream: "grpclib.server.Stream[MsgUpdateParams, MsgUpdateParamsResponse]" 151 | ) -> None: 152 | request = await stream.recv_message() 153 | response = await self.update_params(request) 154 | await stream.send_message(response) 155 | 156 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 157 | return { 158 | "/cosmos.crisis.v1beta1.Msg/VerifyInvariant": grpclib.const.Handler( 159 | self.__rpc_verify_invariant, 160 | grpclib.const.Cardinality.UNARY_UNARY, 161 | MsgVerifyInvariant, 162 | MsgVerifyInvariantResponse, 163 | ), 164 | "/cosmos.crisis.v1beta1.Msg/UpdateParams": grpclib.const.Handler( 165 | self.__rpc_update_params, 166 | grpclib.const.Cardinality.UNARY_UNARY, 167 | MsgUpdateParams, 168 | MsgUpdateParamsResponse, 169 | ), 170 | } 171 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/crypto/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/ed25519/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/ed25519/keys.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class PubKey(betterproto.Message): 13 | """ 14 | PubKey is an ed25519 public key for handling Tendermint keys in SDK. 15 | It's needed for Any serialization and SDK compatibility. 16 | It must not be used in a non Tendermint key context because it doesn't implement 17 | ADR-28. Nevertheless, you will like to use ed25519 in app user level 18 | then you must create a new proto message and follow ADR-28 for Address construction. 19 | """ 20 | 21 | key: bytes = betterproto.bytes_field(1) 22 | 23 | 24 | @dataclass(eq=False, repr=False) 25 | class PrivKey(betterproto.Message): 26 | """ 27 | PrivKey defines a ed25519 private key. 28 | NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. 29 | """ 30 | 31 | key: bytes = betterproto.bytes_field(1) 32 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/hd/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/crypto/hd/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/hd/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/hd/v1/hd.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Bip44Params(betterproto.Message): 13 | """BIP44Params is used as path field in ledger item in Record.""" 14 | 15 | purpose: int = betterproto.uint32_field(1) 16 | """ 17 | purpose is a constant set to 44' (or 0x8000002C) following the BIP43 recommendation 18 | """ 19 | 20 | coin_type: int = betterproto.uint32_field(2) 21 | """coin_type is a constant that improves privacy""" 22 | 23 | account: int = betterproto.uint32_field(3) 24 | """account splits the key space into independent user identities""" 25 | 26 | change: bool = betterproto.bool_field(4) 27 | """ 28 | change is a constant used for public derivation. Constant 0 is used for external chain and constant 1 for internal 29 | chain. 30 | """ 31 | 32 | address_index: int = betterproto.uint32_field(5) 33 | """address_index is used as child index in BIP32 derivation""" 34 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/keyring/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/crypto/keyring/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/keyring/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/keyring/v1/record.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf 10 | 11 | from ...hd import v1 as __hd_v1__ 12 | 13 | 14 | @dataclass(eq=False, repr=False) 15 | class Record(betterproto.Message): 16 | """Record is used for representing a key in the keyring.""" 17 | 18 | name: str = betterproto.string_field(1) 19 | """name represents a name of Record""" 20 | 21 | pub_key: "betterproto_lib_google_protobuf.Any" = betterproto.message_field(2) 22 | """pub_key represents a public key in any format""" 23 | 24 | local: "RecordLocal" = betterproto.message_field(3, group="item") 25 | """local stores the private key locally.""" 26 | 27 | ledger: "RecordLedger" = betterproto.message_field(4, group="item") 28 | """ledger stores the information about a Ledger key.""" 29 | 30 | multi: "RecordMulti" = betterproto.message_field(5, group="item") 31 | """Multi does not store any other information.""" 32 | 33 | offline: "RecordOffline" = betterproto.message_field(6, group="item") 34 | """Offline does not store any other information.""" 35 | 36 | 37 | @dataclass(eq=False, repr=False) 38 | class RecordLocal(betterproto.Message): 39 | """ 40 | Item is a keyring item stored in a keyring backend. 41 | Local item 42 | """ 43 | 44 | priv_key: "betterproto_lib_google_protobuf.Any" = betterproto.message_field(1) 45 | 46 | 47 | @dataclass(eq=False, repr=False) 48 | class RecordLedger(betterproto.Message): 49 | """Ledger item""" 50 | 51 | path: "__hd_v1__.Bip44Params" = betterproto.message_field(1) 52 | 53 | 54 | @dataclass(eq=False, repr=False) 55 | class RecordMulti(betterproto.Message): 56 | """Multi item""" 57 | 58 | pass 59 | 60 | 61 | @dataclass(eq=False, repr=False) 62 | class RecordOffline(betterproto.Message): 63 | """Offline item""" 64 | 65 | pass 66 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/multisig/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/multisig/keys.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf 11 | 12 | 13 | @dataclass(eq=False, repr=False) 14 | class LegacyAminoPubKey(betterproto.Message): 15 | """ 16 | LegacyAminoPubKey specifies a public key type 17 | which nests multiple public keys and a threshold, 18 | it uses legacy amino address rules. 19 | """ 20 | 21 | threshold: int = betterproto.uint32_field(1) 22 | public_keys: List["betterproto_lib_google_protobuf.Any"] = ( 23 | betterproto.message_field(2) 24 | ) 25 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/multisig/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/multisig/v1beta1/multisig.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class MultiSignature(betterproto.Message): 14 | """ 15 | MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. 16 | See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers 17 | signed and with which modes. 18 | """ 19 | 20 | signatures: List[bytes] = betterproto.bytes_field(1) 21 | 22 | 23 | @dataclass(eq=False, repr=False) 24 | class CompactBitArray(betterproto.Message): 25 | """ 26 | CompactBitArray is an implementation of a space efficient bit array. 27 | This is used to ensure that the encoded data takes up a minimal amount of 28 | space after proto encoding. 29 | This is not thread safe, and is not intended for concurrent usage. 30 | """ 31 | 32 | extra_bits_stored: int = betterproto.uint32_field(1) 33 | elems: bytes = betterproto.bytes_field(2) 34 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/secp256k1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/secp256k1/keys.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class PubKey(betterproto.Message): 13 | """ 14 | PubKey defines a secp256k1 public key 15 | Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte 16 | if the y-coordinate is the lexicographically largest of the two associated with 17 | the x-coordinate. Otherwise the first byte is a 0x03. 18 | This prefix is followed with the x-coordinate. 19 | """ 20 | 21 | key: bytes = betterproto.bytes_field(1) 22 | 23 | 24 | @dataclass(eq=False, repr=False) 25 | class PrivKey(betterproto.Message): 26 | """PrivKey defines a secp256k1 private key.""" 27 | 28 | key: bytes = betterproto.bytes_field(1) 29 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/crypto/secp256r1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/crypto/secp256r1/keys.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class PubKey(betterproto.Message): 13 | """PubKey defines a secp256r1 ECDSA public key.""" 14 | 15 | key: bytes = betterproto.bytes_field(1) 16 | """ 17 | Point on secp256r1 curve in a compressed representation as specified in section 18 | 4.3.6 of ANSI X9.62: https://webstore.ansi.org/standards/ascx9/ansix9621998 19 | """ 20 | 21 | 22 | @dataclass(eq=False, repr=False) 23 | class PrivKey(betterproto.Message): 24 | """PrivKey defines a secp256r1 ECDSA private key.""" 25 | 26 | secret: bytes = betterproto.bytes_field(1) 27 | """secret number serialized using big-endian encoding""" 28 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/distribution/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/distribution/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/distribution/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/distribution/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/distribution/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/distribution/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the distribution module.""" 14 | 15 | fee_collector_name: str = betterproto.string_field(1) 16 | authority: str = betterproto.string_field(2) 17 | """ 18 | authority defines the custom module authority. If not set, defaults to the governance module. 19 | """ 20 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/evidence/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/evidence/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/evidence/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/evidence/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/evidence/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/evidence/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the evidence module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/feegrant/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/feegrant/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/feegrant/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/feegrant/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/feegrant/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/feegrant/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the feegrant module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/genutil/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/genutil/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/genutil/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/genutil/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/genutil/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/genutil/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object for the genutil module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/genutil/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/genutil/v1beta1/genesis.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class GenesisState(betterproto.Message): 14 | """GenesisState defines the raw genesis transaction in JSON.""" 15 | 16 | gen_txs: List[bytes] = betterproto.bytes_field(1) 17 | """gen_txs defines the genesis transactions.""" 18 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/gov/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/gov/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/gov/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/gov/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/gov/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/gov/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the gov module.""" 14 | 15 | max_metadata_len: int = betterproto.uint64_field(1) 16 | """ 17 | max_metadata_len defines the maximum proposal metadata length. 18 | Defaults to 255 if not explicitly set. 19 | """ 20 | 21 | authority: str = betterproto.string_field(2) 22 | """ 23 | authority defines the custom module authority. If not set, defaults to the governance module. 24 | """ 25 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/group/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/group/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/group/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/group/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/group/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/group/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from datetime import timedelta 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Module(betterproto.Message): 14 | """Module is the config object of the group module.""" 15 | 16 | max_execution_period: timedelta = betterproto.message_field(1) 17 | """ 18 | max_execution_period defines the max duration after a proposal's voting period ends that members can send a MsgExec 19 | to execute the proposal. 20 | """ 21 | 22 | max_metadata_len: int = betterproto.uint64_field(2) 23 | """ 24 | max_metadata_len defines the max length of the metadata bytes field for various entities within the group module. 25 | Defaults to 255 if not explicitly set. 26 | """ 27 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/mint/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/mint/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/mint/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/mint/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/mint/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/mint/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the mint module.""" 14 | 15 | fee_collector_name: str = betterproto.string_field(1) 16 | authority: str = betterproto.string_field(2) 17 | """ 18 | authority defines the custom module authority. If not set, defaults to the governance module. 19 | """ 20 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/msg/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/msg/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/msg/textual/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/msg/textual/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/msg/textual/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/msg/textual/v1/textual.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/msg/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/msg/v1/msg.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/nft/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/nft/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/nft/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/nft/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/nft/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/nft/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the nft module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/orm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/orm/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/orm/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/orm/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/orm/module/v1alpha1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/orm/module/v1alpha1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """ 14 | Module defines the ORM module which adds providers to the app container for 15 | ORM ModuleDB's and in the future will automatically register query 16 | services for modules that use the ORM. 17 | """ 18 | 19 | pass 20 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/orm/query/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/orm/query/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/orm/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/orm/v1/orm.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class TableDescriptor(betterproto.Message): 14 | """TableDescriptor describes an ORM table.""" 15 | 16 | primary_key: "PrimaryKeyDescriptor" = betterproto.message_field(1) 17 | """primary_key defines the primary key for the table.""" 18 | 19 | index: List["SecondaryIndexDescriptor"] = betterproto.message_field(2) 20 | """index defines one or more secondary indexes.""" 21 | 22 | id: int = betterproto.uint32_field(3) 23 | """ 24 | id is a non-zero integer ID that must be unique within the 25 | tables and singletons in this file. It may be deprecated in the future when this 26 | can be auto-generated. 27 | """ 28 | 29 | 30 | @dataclass(eq=False, repr=False) 31 | class PrimaryKeyDescriptor(betterproto.Message): 32 | """PrimaryKeyDescriptor describes a table primary key.""" 33 | 34 | fields: str = betterproto.string_field(1) 35 | """ 36 | fields is a comma-separated list of fields in the primary key. Spaces are 37 | not allowed. Supported field types, their encodings, and any applicable constraints 38 | are described below. 39 | - uint32 are encoded as 2,3,4 or 5 bytes using a compact encoding that 40 | is suitable for sorted iteration (not varint encoding). This type is 41 | well-suited for small integers. 42 | - uint64 are encoded as 2,4,6 or 9 bytes using a compact encoding that 43 | is suitable for sorted iteration (not varint encoding). This type is 44 | well-suited for small integers such as auto-incrementing sequences. 45 | - fixed32, fixed64 are encoded as big-endian fixed width bytes and support 46 | sorted iteration. These types are well-suited for encoding fixed with 47 | decimals as integers. 48 | - string's are encoded as raw bytes in terminal key segments and null-terminated 49 | in non-terminal segments. Null characters are thus forbidden in strings. 50 | string fields support sorted iteration. 51 | - bytes are encoded as raw bytes in terminal segments and length-prefixed 52 | with a 32-bit unsigned varint in non-terminal segments. 53 | - int32, sint32, int64, sint64, sfixed32, sfixed64 are encoded as fixed width bytes with 54 | an encoding that enables sorted iteration. 55 | - google.protobuf.Timestamp is encoded such that values with only seconds occupy 6 bytes, 56 | values including nanos occupy 9 bytes, and nil values occupy 1 byte. When iterating, nil 57 | values will always be ordered last. Seconds and nanos values must conform to the officially 58 | specified ranges of 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z and 0 to 999,999,999 respectively. 59 | - google.protobuf.Duration is encoded as 12 bytes using an encoding that enables sorted iteration. 60 | - enum fields are encoded using varint encoding and do not support sorted 61 | iteration. 62 | - bool fields are encoded as a single byte 0 or 1. 63 | 64 | All other fields types are unsupported in keys including repeated and 65 | oneof fields. 66 | 67 | Primary keys are prefixed by the varint encoded table id and the byte 0x0 68 | plus any additional prefix specified by the schema. 69 | """ 70 | 71 | auto_increment: bool = betterproto.bool_field(2) 72 | """ 73 | auto_increment specifies that the primary key is generated by an 74 | auto-incrementing integer. If this is set to true fields must only 75 | contain one field of that is of type uint64. 76 | """ 77 | 78 | 79 | @dataclass(eq=False, repr=False) 80 | class SecondaryIndexDescriptor(betterproto.Message): 81 | """PrimaryKeyDescriptor describes a table secondary index.""" 82 | 83 | fields: str = betterproto.string_field(1) 84 | """ 85 | fields is a comma-separated list of fields in the index. The supported 86 | field types are the same as those for PrimaryKeyDescriptor.fields. 87 | Index keys are prefixed by the varint encoded table id and the varint 88 | encoded index id plus any additional prefix specified by the schema. 89 | 90 | In addition the field segments, non-unique index keys are suffixed with 91 | any additional primary key fields not present in the index fields so that the 92 | primary key can be reconstructed. Unique indexes instead of being suffixed 93 | store the remaining primary key fields in the value.. 94 | """ 95 | 96 | id: int = betterproto.uint32_field(2) 97 | """ 98 | id is a non-zero integer ID that must be unique within the indexes for this 99 | table and less than 32768. It may be deprecated in the future when this can 100 | be auto-generated. 101 | """ 102 | 103 | unique: bool = betterproto.bool_field(3) 104 | """unique specifies that this an unique index.""" 105 | 106 | 107 | @dataclass(eq=False, repr=False) 108 | class SingletonDescriptor(betterproto.Message): 109 | """ 110 | TableDescriptor describes an ORM singleton table which has at most one instance. 111 | """ 112 | 113 | id: int = betterproto.uint32_field(1) 114 | """ 115 | id is a non-zero integer ID that must be unique within the 116 | tables and singletons in this file. It may be deprecated in the future when this 117 | can be auto-generated. 118 | """ 119 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/orm/v1alpha1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/orm/v1alpha1/schema.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | class StorageType(betterproto.Enum): 13 | """StorageType""" 14 | 15 | DEFAULT_UNSPECIFIED = 0 16 | """ 17 | STORAGE_TYPE_DEFAULT_UNSPECIFIED indicates the persistent storage where all 18 | data is stored in the regular Merkle-tree backed KV-store. 19 | """ 20 | 21 | MEMORY = 1 22 | """ 23 | STORAGE_TYPE_MEMORY indicates in-memory storage that will be 24 | reloaded every time an app restarts. Tables with this type of storage 25 | will by default be ignored when importing and exporting a module's 26 | state from JSON. 27 | """ 28 | 29 | TRANSIENT = 2 30 | """ 31 | STORAGE_TYPE_TRANSIENT indicates transient storage that is reset 32 | at the end of every block. Tables with this type of storage 33 | will by default be ignored when importing and exporting a module's 34 | state from JSON. 35 | """ 36 | 37 | 38 | @dataclass(eq=False, repr=False) 39 | class ModuleSchemaDescriptor(betterproto.Message): 40 | """ModuleSchemaDescriptor describe's a module's ORM schema.""" 41 | 42 | schema_file: List["ModuleSchemaDescriptorFileEntry"] = betterproto.message_field(1) 43 | prefix: bytes = betterproto.bytes_field(2) 44 | """ 45 | prefix is an optional prefix that precedes all keys in this module's 46 | store. 47 | """ 48 | 49 | 50 | @dataclass(eq=False, repr=False) 51 | class ModuleSchemaDescriptorFileEntry(betterproto.Message): 52 | """FileEntry describes an ORM file used in a module.""" 53 | 54 | id: int = betterproto.uint32_field(1) 55 | """ 56 | id is a prefix that will be varint encoded and prepended to all the 57 | table keys specified in the file's tables. 58 | """ 59 | 60 | proto_file_name: str = betterproto.string_field(2) 61 | """ 62 | proto_file_name is the name of a file .proto in that contains 63 | table definitions. The .proto file must be in a package that the 64 | module has referenced using cosmos.app.v1.ModuleDescriptor.use_package. 65 | """ 66 | 67 | storage_type: "StorageType" = betterproto.enum_field(3) 68 | """ 69 | storage_type optionally indicates the type of storage this file's 70 | tables should used. If it is left unspecified, the default KV-storage 71 | of the app will be used. 72 | """ 73 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/params/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/params/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/params/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/params/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/params/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/params/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the params module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/params/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/params/v1beta1/params.proto, cosmos/params/v1beta1/query.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | List, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import grpclib 16 | from betterproto.grpc.grpclib_server import ServiceBase 17 | 18 | 19 | if TYPE_CHECKING: 20 | import grpclib.server 21 | from betterproto.grpc.grpclib_client import MetadataLike 22 | from grpclib.metadata import Deadline 23 | 24 | 25 | @dataclass(eq=False, repr=False) 26 | class ParameterChangeProposal(betterproto.Message): 27 | """ 28 | ParameterChangeProposal defines a proposal to change one or more parameters. 29 | """ 30 | 31 | title: str = betterproto.string_field(1) 32 | description: str = betterproto.string_field(2) 33 | changes: List["ParamChange"] = betterproto.message_field(3) 34 | 35 | 36 | @dataclass(eq=False, repr=False) 37 | class ParamChange(betterproto.Message): 38 | """ 39 | ParamChange defines an individual parameter change, for use in 40 | ParameterChangeProposal. 41 | """ 42 | 43 | subspace: str = betterproto.string_field(1) 44 | key: str = betterproto.string_field(2) 45 | value: str = betterproto.string_field(3) 46 | 47 | 48 | @dataclass(eq=False, repr=False) 49 | class QueryParamsRequest(betterproto.Message): 50 | """QueryParamsRequest is request type for the Query/Params RPC method.""" 51 | 52 | subspace: str = betterproto.string_field(1) 53 | """subspace defines the module to query the parameter for.""" 54 | 55 | key: str = betterproto.string_field(2) 56 | """key defines the key of the parameter in the subspace.""" 57 | 58 | 59 | @dataclass(eq=False, repr=False) 60 | class QueryParamsResponse(betterproto.Message): 61 | """ 62 | QueryParamsResponse is response type for the Query/Params RPC method. 63 | """ 64 | 65 | param: "ParamChange" = betterproto.message_field(1) 66 | """param defines the queried parameter.""" 67 | 68 | 69 | @dataclass(eq=False, repr=False) 70 | class QuerySubspacesRequest(betterproto.Message): 71 | """ 72 | QuerySubspacesRequest defines a request type for querying for all registered 73 | subspaces and all keys for a subspace. 74 | 75 | Since: cosmos-sdk 0.46 76 | """ 77 | 78 | pass 79 | 80 | 81 | @dataclass(eq=False, repr=False) 82 | class QuerySubspacesResponse(betterproto.Message): 83 | """ 84 | QuerySubspacesResponse defines the response types for querying for all 85 | registered subspaces and all keys for a subspace. 86 | 87 | Since: cosmos-sdk 0.46 88 | """ 89 | 90 | subspaces: List["Subspace"] = betterproto.message_field(1) 91 | 92 | 93 | @dataclass(eq=False, repr=False) 94 | class Subspace(betterproto.Message): 95 | """ 96 | Subspace defines a parameter subspace name and all the keys that exist for 97 | the subspace. 98 | 99 | Since: cosmos-sdk 0.46 100 | """ 101 | 102 | subspace: str = betterproto.string_field(1) 103 | keys: List[str] = betterproto.string_field(2) 104 | 105 | 106 | class QueryStub(betterproto.ServiceStub): 107 | async def params( 108 | self, 109 | query_params_request: "QueryParamsRequest", 110 | *, 111 | timeout: Optional[float] = None, 112 | deadline: Optional["Deadline"] = None, 113 | metadata: Optional["MetadataLike"] = None 114 | ) -> "QueryParamsResponse": 115 | return await self._unary_unary( 116 | "/cosmos.params.v1beta1.Query/Params", 117 | query_params_request, 118 | QueryParamsResponse, 119 | timeout=timeout, 120 | deadline=deadline, 121 | metadata=metadata, 122 | ) 123 | 124 | async def subspaces( 125 | self, 126 | query_subspaces_request: "QuerySubspacesRequest", 127 | *, 128 | timeout: Optional[float] = None, 129 | deadline: Optional["Deadline"] = None, 130 | metadata: Optional["MetadataLike"] = None 131 | ) -> "QuerySubspacesResponse": 132 | return await self._unary_unary( 133 | "/cosmos.params.v1beta1.Query/Subspaces", 134 | query_subspaces_request, 135 | QuerySubspacesResponse, 136 | timeout=timeout, 137 | deadline=deadline, 138 | metadata=metadata, 139 | ) 140 | 141 | 142 | class QueryBase(ServiceBase): 143 | 144 | async def params( 145 | self, query_params_request: "QueryParamsRequest" 146 | ) -> "QueryParamsResponse": 147 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 148 | 149 | async def subspaces( 150 | self, query_subspaces_request: "QuerySubspacesRequest" 151 | ) -> "QuerySubspacesResponse": 152 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 153 | 154 | async def __rpc_params( 155 | self, stream: "grpclib.server.Stream[QueryParamsRequest, QueryParamsResponse]" 156 | ) -> None: 157 | request = await stream.recv_message() 158 | response = await self.params(request) 159 | await stream.send_message(response) 160 | 161 | async def __rpc_subspaces( 162 | self, 163 | stream: "grpclib.server.Stream[QuerySubspacesRequest, QuerySubspacesResponse]", 164 | ) -> None: 165 | request = await stream.recv_message() 166 | response = await self.subspaces(request) 167 | await stream.send_message(response) 168 | 169 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 170 | return { 171 | "/cosmos.params.v1beta1.Query/Params": grpclib.const.Handler( 172 | self.__rpc_params, 173 | grpclib.const.Cardinality.UNARY_UNARY, 174 | QueryParamsRequest, 175 | QueryParamsResponse, 176 | ), 177 | "/cosmos.params.v1beta1.Query/Subspaces": grpclib.const.Handler( 178 | self.__rpc_subspaces, 179 | grpclib.const.Cardinality.UNARY_UNARY, 180 | QuerySubspacesRequest, 181 | QuerySubspacesResponse, 182 | ), 183 | } 184 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/query/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/query/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/query/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/query/v1/query.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/reflection/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/reflection/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/reflection/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/reflection/v1/reflection.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | List, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf 16 | import grpclib 17 | from betterproto.grpc.grpclib_server import ServiceBase 18 | 19 | 20 | if TYPE_CHECKING: 21 | import grpclib.server 22 | from betterproto.grpc.grpclib_client import MetadataLike 23 | from grpclib.metadata import Deadline 24 | 25 | 26 | @dataclass(eq=False, repr=False) 27 | class FileDescriptorsRequest(betterproto.Message): 28 | """FileDescriptorsRequest is the Query/FileDescriptors request type.""" 29 | 30 | pass 31 | 32 | 33 | @dataclass(eq=False, repr=False) 34 | class FileDescriptorsResponse(betterproto.Message): 35 | """FileDescriptorsResponse is the Query/FileDescriptors response type.""" 36 | 37 | files: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = ( 38 | betterproto.message_field(1) 39 | ) 40 | """files is the file descriptors.""" 41 | 42 | 43 | class ReflectionServiceStub(betterproto.ServiceStub): 44 | async def file_descriptors( 45 | self, 46 | file_descriptors_request: "FileDescriptorsRequest", 47 | *, 48 | timeout: Optional[float] = None, 49 | deadline: Optional["Deadline"] = None, 50 | metadata: Optional["MetadataLike"] = None 51 | ) -> "FileDescriptorsResponse": 52 | return await self._unary_unary( 53 | "/cosmos.reflection.v1.ReflectionService/FileDescriptors", 54 | file_descriptors_request, 55 | FileDescriptorsResponse, 56 | timeout=timeout, 57 | deadline=deadline, 58 | metadata=metadata, 59 | ) 60 | 61 | 62 | class ReflectionServiceBase(ServiceBase): 63 | 64 | async def file_descriptors( 65 | self, file_descriptors_request: "FileDescriptorsRequest" 66 | ) -> "FileDescriptorsResponse": 67 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 68 | 69 | async def __rpc_file_descriptors( 70 | self, 71 | stream: "grpclib.server.Stream[FileDescriptorsRequest, FileDescriptorsResponse]", 72 | ) -> None: 73 | request = await stream.recv_message() 74 | response = await self.file_descriptors(request) 75 | await stream.send_message(response) 76 | 77 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 78 | return { 79 | "/cosmos.reflection.v1.ReflectionService/FileDescriptors": grpclib.const.Handler( 80 | self.__rpc_file_descriptors, 81 | grpclib.const.Cardinality.UNARY_UNARY, 82 | FileDescriptorsRequest, 83 | FileDescriptorsResponse, 84 | ), 85 | } 86 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/slashing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/slashing/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/slashing/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/slashing/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/slashing/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/slashing/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the slashing module.""" 14 | 15 | authority: str = betterproto.string_field(1) 16 | """ 17 | authority defines the custom module authority. If not set, defaults to the governance module. 18 | """ 19 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/staking/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/staking/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/staking/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/staking/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/staking/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/staking/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Module(betterproto.Message): 14 | """Module is the config object of the staking module.""" 15 | 16 | hooks_order: List[str] = betterproto.string_field(1) 17 | """ 18 | hooks_order specifies the order of staking hooks and should be a list 19 | of module names which provide a staking hooks instance. If no order is 20 | provided, then hooks will be applied in alphabetical order of module names. 21 | """ 22 | 23 | authority: str = betterproto.string_field(2) 24 | """ 25 | authority defines the custom module authority. If not set, defaults to the governance module. 26 | """ 27 | 28 | bech32_prefix_validator: str = betterproto.string_field(3) 29 | """bech32_prefix_validator is the bech32 validator prefix for the app.""" 30 | 31 | bech32_prefix_consensus: str = betterproto.string_field(4) 32 | """ 33 | bech32_prefix_consensus is the bech32 consensus node prefix for the app. 34 | """ 35 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/store/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/internal/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/store/internal/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/internal/kv/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/store/internal/kv/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/internal/kv/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/store/internal/kv/v1beta1/kv.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Pairs(betterproto.Message): 14 | """Pairs defines a repeated slice of Pair objects.""" 15 | 16 | pairs: List["Pair"] = betterproto.message_field(1) 17 | 18 | 19 | @dataclass(eq=False, repr=False) 20 | class Pair(betterproto.Message): 21 | """Pair defines a key/value bytes tuple.""" 22 | 23 | key: bytes = betterproto.bytes_field(1) 24 | value: bytes = betterproto.bytes_field(2) 25 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/snapshots/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/store/snapshots/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/snapshots/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/store/snapshots/v1/snapshot.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Snapshot(betterproto.Message): 14 | """Snapshot contains Tendermint state sync snapshot info.""" 15 | 16 | height: int = betterproto.uint64_field(1) 17 | format: int = betterproto.uint32_field(2) 18 | chunks: int = betterproto.uint32_field(3) 19 | hash: bytes = betterproto.bytes_field(4) 20 | metadata: "Metadata" = betterproto.message_field(5) 21 | 22 | 23 | @dataclass(eq=False, repr=False) 24 | class Metadata(betterproto.Message): 25 | """Metadata contains SDK-specific snapshot metadata.""" 26 | 27 | chunk_hashes: List[bytes] = betterproto.bytes_field(1) 28 | 29 | 30 | @dataclass(eq=False, repr=False) 31 | class SnapshotItem(betterproto.Message): 32 | """ 33 | SnapshotItem is an item contained in a rootmulti.Store snapshot. 34 | 35 | Since: cosmos-sdk 0.46 36 | """ 37 | 38 | store: "SnapshotStoreItem" = betterproto.message_field(1, group="item") 39 | iavl: "SnapshotIavlItem" = betterproto.message_field(2, group="item") 40 | extension: "SnapshotExtensionMeta" = betterproto.message_field(3, group="item") 41 | extension_payload: "SnapshotExtensionPayload" = betterproto.message_field( 42 | 4, group="item" 43 | ) 44 | 45 | 46 | @dataclass(eq=False, repr=False) 47 | class SnapshotStoreItem(betterproto.Message): 48 | """ 49 | SnapshotStoreItem contains metadata about a snapshotted store. 50 | 51 | Since: cosmos-sdk 0.46 52 | """ 53 | 54 | name: str = betterproto.string_field(1) 55 | 56 | 57 | @dataclass(eq=False, repr=False) 58 | class SnapshotIavlItem(betterproto.Message): 59 | """ 60 | SnapshotIAVLItem is an exported IAVL node. 61 | 62 | Since: cosmos-sdk 0.46 63 | """ 64 | 65 | key: bytes = betterproto.bytes_field(1) 66 | value: bytes = betterproto.bytes_field(2) 67 | version: int = betterproto.int64_field(3) 68 | """version is block height""" 69 | 70 | height: int = betterproto.int32_field(4) 71 | """height is depth of the tree.""" 72 | 73 | 74 | @dataclass(eq=False, repr=False) 75 | class SnapshotExtensionMeta(betterproto.Message): 76 | """ 77 | SnapshotExtensionMeta contains metadata about an external snapshotter. 78 | 79 | Since: cosmos-sdk 0.46 80 | """ 81 | 82 | name: str = betterproto.string_field(1) 83 | format: int = betterproto.uint32_field(2) 84 | 85 | 86 | @dataclass(eq=False, repr=False) 87 | class SnapshotExtensionPayload(betterproto.Message): 88 | """ 89 | SnapshotExtensionPayload contains payloads of an external snapshotter. 90 | 91 | Since: cosmos-sdk 0.46 92 | """ 93 | 94 | payload: bytes = betterproto.bytes_field(1) 95 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/streaming/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/store/streaming/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/streaming/abci/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/store/streaming/abci/grpc.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import ( 8 | TYPE_CHECKING, 9 | Dict, 10 | List, 11 | Optional, 12 | ) 13 | 14 | import betterproto 15 | import grpclib 16 | from betterproto.grpc.grpclib_server import ServiceBase 17 | 18 | from .....tendermint import abci as __tendermint_abci__ 19 | from ... import v1beta1 as __v1_beta1__ 20 | 21 | 22 | if TYPE_CHECKING: 23 | import grpclib.server 24 | from betterproto.grpc.grpclib_client import MetadataLike 25 | from grpclib.metadata import Deadline 26 | 27 | 28 | @dataclass(eq=False, repr=False) 29 | class ListenFinalizeBlockRequest(betterproto.Message): 30 | """ 31 | ListenEndBlockRequest is the request type for the ListenEndBlock RPC method 32 | """ 33 | 34 | req: "__tendermint_abci__.RequestFinalizeBlock" = betterproto.message_field(1) 35 | res: "__tendermint_abci__.ResponseFinalizeBlock" = betterproto.message_field(2) 36 | 37 | 38 | @dataclass(eq=False, repr=False) 39 | class ListenFinalizeBlockResponse(betterproto.Message): 40 | """ 41 | ListenEndBlockResponse is the response type for the ListenEndBlock RPC method 42 | """ 43 | 44 | pass 45 | 46 | 47 | @dataclass(eq=False, repr=False) 48 | class ListenCommitRequest(betterproto.Message): 49 | """ 50 | ListenCommitRequest is the request type for the ListenCommit RPC method 51 | """ 52 | 53 | block_height: int = betterproto.int64_field(1) 54 | """ 55 | explicitly pass in block height as ResponseCommit does not contain this info 56 | """ 57 | 58 | res: "__tendermint_abci__.ResponseCommit" = betterproto.message_field(2) 59 | change_set: List["__v1_beta1__.StoreKvPair"] = betterproto.message_field(3) 60 | 61 | 62 | @dataclass(eq=False, repr=False) 63 | class ListenCommitResponse(betterproto.Message): 64 | """ 65 | ListenCommitResponse is the response type for the ListenCommit RPC method 66 | """ 67 | 68 | pass 69 | 70 | 71 | class AbciListenerServiceStub(betterproto.ServiceStub): 72 | async def listen_finalize_block( 73 | self, 74 | listen_finalize_block_request: "ListenFinalizeBlockRequest", 75 | *, 76 | timeout: Optional[float] = None, 77 | deadline: Optional["Deadline"] = None, 78 | metadata: Optional["MetadataLike"] = None, 79 | ) -> "ListenFinalizeBlockResponse": 80 | return await self._unary_unary( 81 | "/cosmos.store.streaming.abci.ABCIListenerService/ListenFinalizeBlock", 82 | listen_finalize_block_request, 83 | ListenFinalizeBlockResponse, 84 | timeout=timeout, 85 | deadline=deadline, 86 | metadata=metadata, 87 | ) 88 | 89 | async def listen_commit( 90 | self, 91 | listen_commit_request: "ListenCommitRequest", 92 | *, 93 | timeout: Optional[float] = None, 94 | deadline: Optional["Deadline"] = None, 95 | metadata: Optional["MetadataLike"] = None, 96 | ) -> "ListenCommitResponse": 97 | return await self._unary_unary( 98 | "/cosmos.store.streaming.abci.ABCIListenerService/ListenCommit", 99 | listen_commit_request, 100 | ListenCommitResponse, 101 | timeout=timeout, 102 | deadline=deadline, 103 | metadata=metadata, 104 | ) 105 | 106 | 107 | class AbciListenerServiceBase(ServiceBase): 108 | async def listen_finalize_block( 109 | self, listen_finalize_block_request: "ListenFinalizeBlockRequest" 110 | ) -> "ListenFinalizeBlockResponse": 111 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 112 | 113 | async def listen_commit( 114 | self, listen_commit_request: "ListenCommitRequest" 115 | ) -> "ListenCommitResponse": 116 | raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED) 117 | 118 | async def __rpc_listen_finalize_block( 119 | self, 120 | stream: "grpclib.server.Stream[ListenFinalizeBlockRequest, ListenFinalizeBlockResponse]", 121 | ) -> None: 122 | request = await stream.recv_message() 123 | response = await self.listen_finalize_block(request) 124 | await stream.send_message(response) 125 | 126 | async def __rpc_listen_commit( 127 | self, stream: "grpclib.server.Stream[ListenCommitRequest, ListenCommitResponse]" 128 | ) -> None: 129 | request = await stream.recv_message() 130 | response = await self.listen_commit(request) 131 | await stream.send_message(response) 132 | 133 | def __mapping__(self) -> Dict[str, grpclib.const.Handler]: 134 | return { 135 | "/cosmos.store.streaming.abci.ABCIListenerService/ListenFinalizeBlock": grpclib.const.Handler( 136 | self.__rpc_listen_finalize_block, 137 | grpclib.const.Cardinality.UNARY_UNARY, 138 | ListenFinalizeBlockRequest, 139 | ListenFinalizeBlockResponse, 140 | ), 141 | "/cosmos.store.streaming.abci.ABCIListenerService/ListenCommit": grpclib.const.Handler( 142 | self.__rpc_listen_commit, 143 | grpclib.const.Cardinality.UNARY_UNARY, 144 | ListenCommitRequest, 145 | ListenCommitResponse, 146 | ), 147 | } 148 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/store/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/store/v1beta1/commit_info.proto, cosmos/store/v1beta1/listening.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from datetime import datetime 8 | from typing import List 9 | 10 | import betterproto 11 | 12 | from ....tendermint import abci as __tendermint_abci__ 13 | 14 | 15 | @dataclass(eq=False, repr=False) 16 | class StoreKvPair(betterproto.Message): 17 | """ 18 | StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) 19 | It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and 20 | Deletes 21 | 22 | Since: cosmos-sdk 0.43 23 | """ 24 | 25 | store_key: str = betterproto.string_field(1) 26 | delete: bool = betterproto.bool_field(2) 27 | key: bytes = betterproto.bytes_field(3) 28 | value: bytes = betterproto.bytes_field(4) 29 | 30 | 31 | @dataclass(eq=False, repr=False) 32 | class BlockMetadata(betterproto.Message): 33 | """ 34 | BlockMetadata contains all the abci event data of a block 35 | the file streamer dump them into files together with the state changes. 36 | """ 37 | 38 | response_commit: "__tendermint_abci__.ResponseCommit" = betterproto.message_field(6) 39 | request_finalize_block: "__tendermint_abci__.RequestFinalizeBlock" = ( 40 | betterproto.message_field(7) 41 | ) 42 | response_finalize_block: "__tendermint_abci__.ResponseFinalizeBlock" = ( 43 | betterproto.message_field(8) 44 | ) 45 | 46 | 47 | @dataclass(eq=False, repr=False) 48 | class CommitInfo(betterproto.Message): 49 | """ 50 | CommitInfo defines commit information used by the multi-store when committing 51 | a version/height. 52 | """ 53 | 54 | version: int = betterproto.int64_field(1) 55 | store_infos: List["StoreInfo"] = betterproto.message_field(2) 56 | timestamp: datetime = betterproto.message_field(3) 57 | 58 | 59 | @dataclass(eq=False, repr=False) 60 | class StoreInfo(betterproto.Message): 61 | """ 62 | StoreInfo defines store-specific commit information. It contains a reference 63 | between a store name and the commit ID. 64 | """ 65 | 66 | name: str = betterproto.string_field(1) 67 | commit_id: "CommitId" = betterproto.message_field(2) 68 | 69 | 70 | @dataclass(eq=False, repr=False) 71 | class CommitId(betterproto.Message): 72 | """ 73 | CommitID defines the commitment information when a specific store is 74 | committed. 75 | """ 76 | 77 | version: int = betterproto.int64_field(1) 78 | hash: bytes = betterproto.bytes_field(2) 79 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/tx/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/tx/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/tx/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/tx/config/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/tx/config/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/tx/config/v1/config.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Config(betterproto.Message): 13 | """Config is the config object of the x/auth/tx package.""" 14 | 15 | skip_ante_handler: bool = betterproto.bool_field(1) 16 | """ 17 | skip_ante_handler defines whether the ante handler registration should be skipped in case an app wants to override 18 | this functionality. 19 | """ 20 | 21 | skip_post_handler: bool = betterproto.bool_field(2) 22 | """ 23 | skip_post_handler defines whether the post handler registration should be skipped in case an app wants to override 24 | this functionality. 25 | """ 26 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/tx/signing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/tx/signing/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/tx/signing/v1beta1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/tx/signing/v1beta1/signing.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf 11 | 12 | from ....crypto.multisig import v1beta1 as __crypto_multisig_v1_beta1__ 13 | 14 | 15 | class SignMode(betterproto.Enum): 16 | """ 17 | SignMode represents a signing mode with its own security guarantees. 18 | 19 | This enum should be considered a registry of all known sign modes 20 | in the Cosmos ecosystem. Apps are not expected to support all known 21 | sign modes. Apps that would like to support custom sign modes are 22 | encouraged to open a small PR against this file to add a new case 23 | to this SignMode enum describing their sign mode so that different 24 | apps have a consistent version of this enum. 25 | """ 26 | 27 | UNSPECIFIED = 0 28 | """ 29 | SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be 30 | rejected. 31 | """ 32 | 33 | DIRECT = 1 34 | """ 35 | SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is 36 | verified with raw bytes from Tx. 37 | """ 38 | 39 | TEXTUAL = 2 40 | """ 41 | SIGN_MODE_TEXTUAL is a future signing mode that will verify some 42 | human-readable textual representation on top of the binary representation 43 | from SIGN_MODE_DIRECT. 44 | 45 | Since: cosmos-sdk 0.50 46 | """ 47 | 48 | DIRECT_AUX = 3 49 | """ 50 | SIGN_MODE_DIRECT_AUX specifies a signing mode which uses 51 | SignDocDirectAux. As opposed to SIGN_MODE_DIRECT, this sign mode does not 52 | require signers signing over other signers' `signer_info`. 53 | 54 | Since: cosmos-sdk 0.46 55 | """ 56 | 57 | LEGACY_AMINO_JSON = 127 58 | """ 59 | SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses 60 | Amino JSON and will be removed in the future. 61 | """ 62 | 63 | EIP_191 = 191 64 | """ 65 | SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos 66 | SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 67 | 68 | Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, 69 | but is not implemented on the SDK by default. To enable EIP-191, you need 70 | to pass a custom `TxConfig` that has an implementation of 71 | `SignModeHandler` for EIP-191. The SDK may decide to fully support 72 | EIP-191 in the future. 73 | 74 | Since: cosmos-sdk 0.45.2 75 | """ 76 | 77 | 78 | @dataclass(eq=False, repr=False) 79 | class SignatureDescriptors(betterproto.Message): 80 | """SignatureDescriptors wraps multiple SignatureDescriptor's.""" 81 | 82 | signatures: List["SignatureDescriptor"] = betterproto.message_field(1) 83 | """signatures are the signature descriptors""" 84 | 85 | 86 | @dataclass(eq=False, repr=False) 87 | class SignatureDescriptor(betterproto.Message): 88 | """ 89 | SignatureDescriptor is a convenience type which represents the full data for 90 | a signature including the public key of the signer, signing modes and the 91 | signature itself. It is primarily used for coordinating signatures between 92 | clients. 93 | """ 94 | 95 | public_key: "betterproto_lib_google_protobuf.Any" = betterproto.message_field(1) 96 | """public_key is the public key of the signer""" 97 | 98 | data: "SignatureDescriptorData" = betterproto.message_field(2) 99 | sequence: int = betterproto.uint64_field(3) 100 | """ 101 | sequence is the sequence of the account, which describes the 102 | number of committed transactions signed by a given address. It is used to prevent 103 | replay attacks. 104 | """ 105 | 106 | 107 | @dataclass(eq=False, repr=False) 108 | class SignatureDescriptorData(betterproto.Message): 109 | """Data represents signature data""" 110 | 111 | single: "SignatureDescriptorDataSingle" = betterproto.message_field(1, group="sum") 112 | """single represents a single signer""" 113 | 114 | multi: "SignatureDescriptorDataMulti" = betterproto.message_field(2, group="sum") 115 | """multi represents a multisig signer""" 116 | 117 | 118 | @dataclass(eq=False, repr=False) 119 | class SignatureDescriptorDataSingle(betterproto.Message): 120 | """Single is the signature data for a single signer""" 121 | 122 | mode: "SignMode" = betterproto.enum_field(1) 123 | """mode is the signing mode of the single signer""" 124 | 125 | signature: bytes = betterproto.bytes_field(2) 126 | """signature is the raw signature bytes""" 127 | 128 | 129 | @dataclass(eq=False, repr=False) 130 | class SignatureDescriptorDataMulti(betterproto.Message): 131 | """Multi is the signature data for a multisig public key""" 132 | 133 | bitarray: "__crypto_multisig_v1_beta1__.CompactBitArray" = ( 134 | betterproto.message_field(1) 135 | ) 136 | """bitarray specifies which keys within the multisig are signing""" 137 | 138 | signatures: List["SignatureDescriptorData"] = betterproto.message_field(2) 139 | """signatures is the signatures of the multi-signature""" 140 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/upgrade/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/upgrade/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/upgrade/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/upgrade/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/upgrade/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/upgrade/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the upgrade module.""" 14 | 15 | authority: str = betterproto.string_field(1) 16 | """ 17 | authority defines the custom module authority. If not set, defaults to the governance module. 18 | """ 19 | -------------------------------------------------------------------------------- /pyband/proto/cosmos/vesting/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/vesting/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/vesting/module/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/cosmos/vesting/module/__init__.py -------------------------------------------------------------------------------- /pyband/proto/cosmos/vesting/module/v1/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos/vesting/module/v1/module.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class Module(betterproto.Message): 13 | """Module is the config object of the vesting module.""" 14 | 15 | pass 16 | -------------------------------------------------------------------------------- /pyband/proto/cosmos_proto/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: cosmos_proto/cosmos.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | class ScalarType(betterproto.Enum): 13 | UNSPECIFIED = 0 14 | STRING = 1 15 | BYTES = 2 16 | 17 | 18 | @dataclass(eq=False, repr=False) 19 | class InterfaceDescriptor(betterproto.Message): 20 | """ 21 | InterfaceDescriptor describes an interface type to be used with 22 | accepts_interface and implements_interface and declared by declare_interface. 23 | """ 24 | 25 | name: str = betterproto.string_field(1) 26 | """ 27 | name is the name of the interface. It should be a short-name (without 28 | a period) such that the fully qualified name of the interface will be 29 | package.name, ex. for the package a.b and interface named C, the 30 | fully-qualified name will be a.b.C. 31 | """ 32 | 33 | description: str = betterproto.string_field(2) 34 | """ 35 | description is a human-readable description of the interface and its 36 | purpose. 37 | """ 38 | 39 | 40 | @dataclass(eq=False, repr=False) 41 | class ScalarDescriptor(betterproto.Message): 42 | """ 43 | ScalarDescriptor describes an scalar type to be used with 44 | the scalar field option and declared by declare_scalar. 45 | Scalars extend simple protobuf built-in types with additional 46 | syntax and semantics, for instance to represent big integers. 47 | Scalars should ideally define an encoding such that there is only one 48 | valid syntactical representation for a given semantic meaning, 49 | i.e. the encoding should be deterministic. 50 | """ 51 | 52 | name: str = betterproto.string_field(1) 53 | """ 54 | name is the name of the scalar. It should be a short-name (without 55 | a period) such that the fully qualified name of the scalar will be 56 | package.name, ex. for the package a.b and scalar named C, the 57 | fully-qualified name will be a.b.C. 58 | """ 59 | 60 | description: str = betterproto.string_field(2) 61 | """ 62 | description is a human-readable description of the scalar and its 63 | encoding format. For instance a big integer or decimal scalar should 64 | specify precisely the expected encoding format. 65 | """ 66 | 67 | field_type: List["ScalarType"] = betterproto.enum_field(3) 68 | """ 69 | field_type is the type of field with which this scalar can be used. 70 | Scalars can be used with one and only one type of field so that 71 | encoding standards and simple and clear. Currently only string and 72 | bytes fields are supported for scalars. 73 | """ 74 | -------------------------------------------------------------------------------- /pyband/proto/gogoproto/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: gogoproto/gogo.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | -------------------------------------------------------------------------------- /pyband/proto/google/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/google/__init__.py -------------------------------------------------------------------------------- /pyband/proto/tendermint/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/tendermint/__init__.py -------------------------------------------------------------------------------- /pyband/proto/tendermint/crypto/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: tendermint/crypto/keys.proto, tendermint/crypto/proof.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class Proof(betterproto.Message): 14 | total: int = betterproto.int64_field(1) 15 | index: int = betterproto.int64_field(2) 16 | leaf_hash: bytes = betterproto.bytes_field(3) 17 | aunts: List[bytes] = betterproto.bytes_field(4) 18 | 19 | 20 | @dataclass(eq=False, repr=False) 21 | class ValueOp(betterproto.Message): 22 | key: bytes = betterproto.bytes_field(1) 23 | """Encoded in ProofOp.Key.""" 24 | 25 | proof: "Proof" = betterproto.message_field(2) 26 | """To encode in ProofOp.Data""" 27 | 28 | 29 | @dataclass(eq=False, repr=False) 30 | class DominoOp(betterproto.Message): 31 | key: str = betterproto.string_field(1) 32 | input: str = betterproto.string_field(2) 33 | output: str = betterproto.string_field(3) 34 | 35 | 36 | @dataclass(eq=False, repr=False) 37 | class ProofOp(betterproto.Message): 38 | """ 39 | ProofOp defines an operation used for calculating Merkle root 40 | The data could be arbitrary format, providing nessecary data 41 | for example neighbouring node hash 42 | """ 43 | 44 | type: str = betterproto.string_field(1) 45 | key: bytes = betterproto.bytes_field(2) 46 | data: bytes = betterproto.bytes_field(3) 47 | 48 | 49 | @dataclass(eq=False, repr=False) 50 | class ProofOps(betterproto.Message): 51 | """ProofOps is Merkle proof defined by the list of ProofOps""" 52 | 53 | ops: List["ProofOp"] = betterproto.message_field(1) 54 | 55 | 56 | @dataclass(eq=False, repr=False) 57 | class PublicKey(betterproto.Message): 58 | """PublicKey defines the keys available for use with Validators""" 59 | 60 | ed25519: bytes = betterproto.bytes_field(1, group="sum") 61 | secp256_k1: bytes = betterproto.bytes_field(2, group="sum") 62 | -------------------------------------------------------------------------------- /pyband/proto/tendermint/libs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/pyband/proto/tendermint/libs/__init__.py -------------------------------------------------------------------------------- /pyband/proto/tendermint/libs/bits/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: tendermint/libs/bits/types.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | from typing import List 8 | 9 | import betterproto 10 | 11 | 12 | @dataclass(eq=False, repr=False) 13 | class BitArray(betterproto.Message): 14 | bits: int = betterproto.int64_field(1) 15 | elems: List[int] = betterproto.uint64_field(2) 16 | -------------------------------------------------------------------------------- /pyband/proto/tendermint/p2p/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: tendermint/p2p/types.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class NetAddress(betterproto.Message): 13 | id: str = betterproto.string_field(1) 14 | ip: str = betterproto.string_field(2) 15 | port: int = betterproto.uint32_field(3) 16 | 17 | 18 | @dataclass(eq=False, repr=False) 19 | class ProtocolVersion(betterproto.Message): 20 | p2_p: int = betterproto.uint64_field(1) 21 | block: int = betterproto.uint64_field(2) 22 | app: int = betterproto.uint64_field(3) 23 | 24 | 25 | @dataclass(eq=False, repr=False) 26 | class DefaultNodeInfo(betterproto.Message): 27 | protocol_version: "ProtocolVersion" = betterproto.message_field(1) 28 | default_node_id: str = betterproto.string_field(2) 29 | listen_addr: str = betterproto.string_field(3) 30 | network: str = betterproto.string_field(4) 31 | version: str = betterproto.string_field(5) 32 | channels: bytes = betterproto.bytes_field(6) 33 | moniker: str = betterproto.string_field(7) 34 | other: "DefaultNodeInfoOther" = betterproto.message_field(8) 35 | 36 | 37 | @dataclass(eq=False, repr=False) 38 | class DefaultNodeInfoOther(betterproto.Message): 39 | tx_index: str = betterproto.string_field(1) 40 | rpc_address: str = betterproto.string_field(2) 41 | -------------------------------------------------------------------------------- /pyband/proto/tendermint/version/__init__.py: -------------------------------------------------------------------------------- 1 | # Generated by the protocol buffer compiler. DO NOT EDIT! 2 | # sources: tendermint/version/types.proto 3 | # plugin: python-betterproto 4 | # This file has been @generated 5 | 6 | from dataclasses import dataclass 7 | 8 | import betterproto 9 | 10 | 11 | @dataclass(eq=False, repr=False) 12 | class App(betterproto.Message): 13 | """ 14 | App includes the protocol and software version for the application. 15 | This information is included in ResponseInfo. The App.Protocol can be 16 | updated in ResponseEndBlock. 17 | """ 18 | 19 | protocol: int = betterproto.uint64_field(1) 20 | software: str = betterproto.string_field(2) 21 | 22 | 23 | @dataclass(eq=False, repr=False) 24 | class Consensus(betterproto.Message): 25 | """ 26 | Consensus captures the consensus rules for processing a block in the blockchain, 27 | including all blockchain data structures and the rules of the application's 28 | state transition machine. 29 | """ 30 | 31 | block: int = betterproto.uint64_field(1) 32 | app: int = betterproto.uint64_field(2) 33 | -------------------------------------------------------------------------------- /pyband/utils.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import List 3 | 4 | from .exceptions import NotBip44Error, IncorrectLengthError 5 | 6 | 7 | def is_bip44(derivation_path: str) -> bool: 8 | """Checks if the given derivation path is a valid bip44 path. 9 | 10 | Args: 11 | derivation_path: Derivation path as a string 12 | 13 | Returns: 14 | Whether the path is valid or not 15 | """ 16 | if re.search("^m(/[0-9]+['hH]?)*$", derivation_path) is not None: 17 | return True 18 | else: 19 | return False 20 | 21 | 22 | def bip44_to_list(derivation_path: str) -> List[int]: 23 | """Converts the given string formatted derivation path into a list 24 | Args: 25 | derivation_path: Derivation path as a string 26 | 27 | Returns: 28 | Derivation path as a list 29 | 30 | Raises: 31 | NotBip44Error: If derivation path is not valid 32 | """ 33 | try: 34 | return [int(x) for x in derivation_path.replace("'", "").split("/")[1:]] 35 | except ValueError: 36 | raise NotBip44Error() 37 | except Exception as e: 38 | raise e 39 | 40 | 41 | def get_bip32_byte(derivation_path: List[int], harden_count: int) -> bytes: 42 | """Encodes BIP32 as a byte 43 | 44 | Args: 45 | derivation_path: The derivation path as a list 46 | harden_count: The depth level of keys to harden 47 | 48 | Returns: 49 | BIP32 as a byte 50 | """ 51 | if len(derivation_path) != 5: 52 | raise IncorrectLengthError("Incorrect path length") 53 | 54 | path_bytes = b"" 55 | for i, idx in enumerate(derivation_path): 56 | if i < harden_count: 57 | idx = 0x80000000 | idx 58 | path_bytes += idx.to_bytes(4, "little") 59 | return path_bytes 60 | 61 | 62 | def split_packet(byte_message: bytes) -> List[bytes]: 63 | """ 64 | Splits a message into packets of size 250 bytes each 65 | 66 | Args: 67 | byte_message: Message as in bytes 68 | 69 | Returns: 70 | Message split into packets 71 | """ 72 | return [bytes(byte_message[i : i + 250]) for i in range(0, len(byte_message), 250)] 73 | -------------------------------------------------------------------------------- /pyband/wallet/__init__.py: -------------------------------------------------------------------------------- 1 | from .private_key import PrivateKey 2 | from .public_key import PublicKey 3 | from .address import Address 4 | from .wallet import Wallet 5 | -------------------------------------------------------------------------------- /pyband/wallet/address.py: -------------------------------------------------------------------------------- 1 | from bech32 import bech32_encode, bech32_decode, convertbits 2 | 3 | from .constants import BECH32_ADDR_ACC_PREFIX, BECH32_ADDR_CONS_PREFIX, BECH32_ADDR_VAL_PREFIX 4 | from ..exceptions import ConvertError, DecodeError 5 | 6 | 7 | class Address: 8 | """Class for wrapping address. Contains methods to encode or decode Bech32. 9 | 10 | Attributes: 11 | addr: 12 | """ 13 | 14 | def __init__(self, addr: bytes) -> None: 15 | self.addr = addr 16 | 17 | def __eq__(self, o: "Address") -> bool: 18 | return self.addr == o.addr 19 | 20 | @classmethod 21 | def _from_bech32(cls, bech: str, prefix: str) -> "Address": 22 | hrp, bz = bech32_decode(bech) 23 | assert hrp == prefix, "Invalid bech32 prefix" 24 | if bz is None: 25 | raise DecodeError("Cannot decode bech32") 26 | eight_bit_r = convertbits(bz, 5, 8, False) 27 | if eight_bit_r is None: 28 | raise ConvertError("Cannot convert to 8 bit") 29 | 30 | return cls(bytes(eight_bit_r)) 31 | 32 | @classmethod 33 | def from_acc_bech32(cls, bech: str) -> "Address": 34 | """Creates an address instance from a bech32 account address. 35 | 36 | Args: 37 | bech: Bech32 account address. 38 | 39 | Returns: 40 | An Address instance. 41 | """ 42 | 43 | return cls._from_bech32(bech, BECH32_ADDR_ACC_PREFIX) 44 | 45 | @classmethod 46 | def from_val_bech32(cls, bech: str) -> "Address": 47 | """Creates an address instance from a bech32 validator address. 48 | 49 | Args: 50 | bech: Bech32 validator address. 51 | 52 | Returns: 53 | An Address instance. 54 | """ 55 | 56 | return cls._from_bech32(bech, BECH32_ADDR_VAL_PREFIX) 57 | 58 | @classmethod 59 | def from_cons_bech32(cls, bech: str) -> "Address": 60 | """Creates an address instance from a bech32 validator consensus address. 61 | 62 | Args: 63 | bech: Bech32 validator consensus address. 64 | 65 | Returns: 66 | An Address instance. 67 | """ 68 | 69 | return cls._from_bech32(bech, BECH32_ADDR_CONS_PREFIX) 70 | 71 | def _to_bech32(self, prefix: str) -> str: 72 | five_bit_r = convertbits(self.addr, 8, 5) 73 | assert five_bit_r is not None, "Unsuccessful bech32.convertbits call" 74 | return bech32_encode(prefix, five_bit_r) 75 | 76 | def to_acc_bech32(self) -> str: 77 | """Returns a bech32 account address. 78 | 79 | Returns: 80 | A bech32 address as a string. 81 | """ 82 | 83 | return self._to_bech32(BECH32_ADDR_ACC_PREFIX) 84 | 85 | def to_val_bech32(self) -> str: 86 | """Returns a bech32 validator address. 87 | 88 | Returns: 89 | A bech32 address as a string. 90 | """ 91 | 92 | return self._to_bech32(BECH32_ADDR_VAL_PREFIX) 93 | 94 | def to_cons_bech32(self) -> str: 95 | """Returns a bech32 validator consensus address. 96 | 97 | Returns: 98 | A bech32 address as a string. 99 | """ 100 | 101 | return self._to_bech32(BECH32_ADDR_CONS_PREFIX) 102 | 103 | def to_hex(self) -> str: 104 | """Returns a hex representation of the address. 105 | 106 | Returns: 107 | A hex representation of address. 108 | """ 109 | 110 | return self.addr.hex() 111 | -------------------------------------------------------------------------------- /pyband/wallet/constants.py: -------------------------------------------------------------------------------- 1 | BECH32_ADDR_ACC_PREFIX = "band" 2 | BECH32_ADDR_VAL_PREFIX = "bandvaloper" 3 | BECH32_ADDR_CONS_PREFIX = "bandvalcons" 4 | 5 | BECH32_PUBKEY_ACC_PREFIX = "bandpub" 6 | BECH32_PUBKEY_VAL_PREFIX = "bandvaloperpub" 7 | BECH32_PUBKEY_CONS_PREFIX = "bandvalconspub" 8 | 9 | DEFAULT_DERIVATION_PATH = "m/44'/494'/0'/0/0" 10 | DEFAULT_LEDGER_DERIVATION_PATH = "m/44'/118'/0'/0/0" 11 | -------------------------------------------------------------------------------- /pyband/wallet/private_key.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | from typing import Tuple, Optional 3 | 4 | from bip32 import BIP32 5 | from ecdsa.curves import SECP256k1 6 | from ecdsa.keys import SigningKey 7 | from ecdsa.util import sigencode_string_canonize 8 | from mnemonic import Mnemonic 9 | 10 | from .constants import DEFAULT_DERIVATION_PATH 11 | from .public_key import PublicKey 12 | 13 | 14 | class PrivateKey: 15 | """Class for wrapping SigningKey, used to sign messages and derive the associated public key. 16 | 17 | Attributes: 18 | signing_key: The ecdsa SigningKey instance. 19 | """ 20 | 21 | def __init__(self, _error_do_not_use_init_directly=None) -> None: 22 | """Unsupported, please use from_mnemonic to initialize.""" 23 | 24 | if not _error_do_not_use_init_directly: 25 | raise TypeError("Please use PrivateKey.from_mnemonic() to construct me") 26 | self.signing_key: Optional[SigningKey] = None 27 | 28 | @classmethod 29 | def generate(cls, path=DEFAULT_DERIVATION_PATH) -> Tuple[str, "PrivateKey"]: 30 | """Generates a new private key with a derivation path and random mnemonic phrase. 31 | 32 | Args: 33 | path: The derivation path, if omitted, defaults to Band's default HD prefix 494 with all other indexes being zeroes. 34 | 35 | Returns: 36 | A tuple containing the mnemonic phrase and the PrivateKey instance. 37 | """ 38 | 39 | phrase = Mnemonic(language="english").generate(strength=256) 40 | return phrase, cls.from_mnemonic(phrase, path) 41 | 42 | @classmethod 43 | def from_mnemonic(cls, words: str, path=DEFAULT_DERIVATION_PATH) -> "PrivateKey": 44 | """Create a PrivateKey instance from a given mnemonic phrase and derivation path. 45 | 46 | Args: 47 | words: The mnemonic phrase. 48 | path: The derivation path, if omitted, defaults to Band's default HD prefix 494 with all other indexes being zeroes. 49 | 50 | Returns: 51 | A PrivateKey instance. 52 | """ 53 | 54 | seed = Mnemonic("english").to_seed(words) 55 | self = cls(_error_do_not_use_init_directly=True) 56 | self.signing_key = SigningKey.from_string( 57 | BIP32.from_seed(seed).get_privkey_from_path(path), curve=SECP256k1, hashfunc=hashlib.sha256 58 | ) 59 | return self 60 | 61 | @classmethod 62 | def from_hex(cls, priv: str) -> "PrivateKey": 63 | """Create a PrivateKey instance from a hex representation of the signing key. 64 | 65 | Args: 66 | priv: A hex representation of the signing key. 67 | 68 | Returns: 69 | A PrivateKey instance. 70 | """ 71 | 72 | self = cls(_error_do_not_use_init_directly=True) 73 | self.signing_key = SigningKey.from_string(bytes.fromhex(priv), curve=SECP256k1, hashfunc=hashlib.sha256) 74 | return self 75 | 76 | def to_hex(self) -> str: 77 | """Returns a hex representation of the signing key. 78 | 79 | Returns: 80 | A hex representation of signing key. 81 | """ 82 | 83 | return self.signing_key.to_string().hex() 84 | 85 | def to_public_key(self) -> PublicKey: 86 | """Gets the associated PublicKey. 87 | 88 | Returns: 89 | A PublicKey instance associated with the object's PrivateKey. 90 | """ 91 | 92 | public_key = PublicKey(_error_do_not_use_init_directly=True) 93 | public_key.verify_key = self.signing_key.get_verifying_key() 94 | return public_key 95 | 96 | def sign(self, msg: bytes) -> bytes: 97 | """Sign the given message using the edcsa sign_deterministic function. 98 | 99 | Args: 100 | msg: Message to be signed and hashed. 101 | 102 | Returns: 103 | A signature of this private key over the given message. 104 | """ 105 | 106 | return self.signing_key.sign_deterministic(msg, hashfunc=hashlib.sha256, sigencode=sigencode_string_canonize) 107 | -------------------------------------------------------------------------------- /pyband/wallet/public_key.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | from typing import Optional 3 | 4 | from bech32 import bech32_decode, convertbits, bech32_encode 5 | from ecdsa.curves import SECP256k1 6 | from ecdsa.keys import VerifyingKey, BadSignatureError 7 | 8 | from .address import Address 9 | from .constants import BECH32_PUBKEY_ACC_PREFIX, BECH32_PUBKEY_VAL_PREFIX, BECH32_PUBKEY_CONS_PREFIX 10 | from ..exceptions import DecodeError 11 | from ..proto.cosmos.crypto.secp256k1 import PubKey as PubKeyProto 12 | 13 | 14 | class PublicKey: 15 | """Class for wrapping VerifyKey used for signature verification. Contains methods to encode or decode Bech32. 16 | 17 | Attributes: 18 | verify_key: the ecdsa VerifyingKey instance 19 | """ 20 | 21 | def __init__(self, _error_do_not_use_init_directly=None) -> None: 22 | """Unsupported, please do not construct it directly.""" 23 | 24 | if not _error_do_not_use_init_directly: 25 | raise TypeError("Please use PublicKey's factory methods to construct me") 26 | self.verify_key: Optional[VerifyingKey] = None 27 | 28 | @classmethod 29 | def _from_bech32(cls, bech: str, prefix: str) -> "PublicKey": 30 | hrp, bz = bech32_decode(bech) 31 | assert hrp == prefix, "Invalid bech32 prefix" 32 | if bz is None: 33 | raise DecodeError("Cannot decode bech32") 34 | bz = convertbits(bz, 5, 8, False) 35 | self = cls(_error_do_not_use_init_directly=True) 36 | self.verify_key = VerifyingKey.from_string(bytes(bz[5:]), curve=SECP256k1, hashfunc=hashlib.sha256) 37 | return self 38 | 39 | @classmethod 40 | def from_acc_bech32(cls, bech: str) -> "PublicKey": 41 | """Creates a PublicKey from a bech32 string with an account public key prefix. 42 | 43 | Args: 44 | bech: Bech32 string with an account public key prefix. 45 | 46 | Returns: 47 | A PublicKey instance. 48 | """ 49 | 50 | return cls._from_bech32(bech, BECH32_PUBKEY_ACC_PREFIX) 51 | 52 | @classmethod 53 | def from_val_bech32(cls, bech: str) -> "PublicKey": 54 | """Creates a PublicKey from a bech32 string with a validator public key prefix. 55 | 56 | Args: 57 | bech: Bech32 string with a validator public key prefix. 58 | 59 | Returns: 60 | A PublicKey instance. 61 | """ 62 | 63 | return cls._from_bech32(bech, BECH32_PUBKEY_VAL_PREFIX) 64 | 65 | @classmethod 66 | def from_cons_bech32(cls, bech: str) -> "PublicKey": 67 | """Creates a PublicKey from a bech32 string with a validator consensus public key prefix. 68 | 69 | Args: 70 | bech: Bech32 string with a validator consensus public key prefix. 71 | 72 | Returns: 73 | A PublicKey instance. 74 | """ 75 | 76 | return cls._from_bech32(bech, BECH32_PUBKEY_CONS_PREFIX) 77 | 78 | @classmethod 79 | def from_hex(cls, pub: bytes) -> "PublicKey": 80 | """Creates a PublicKey from a hex representation of the verifying key. 81 | 82 | Args: 83 | pub: A hex representation of the verifying key. 84 | 85 | Returns: 86 | A PublicKey instance. 87 | """ 88 | 89 | self = cls(_error_do_not_use_init_directly=True) 90 | self.verify_key = VerifyingKey.from_string(pub, curve=SECP256k1, hashfunc=hashlib.sha256) 91 | return self 92 | 93 | def to_hex(self) -> str: 94 | """Returns a hex representation of the verifying key. 95 | 96 | Returns: 97 | A hex representation of verified key. 98 | """ 99 | 100 | return self.verify_key.to_string("compressed").hex() 101 | 102 | def to_public_key_proto(self) -> PubKeyProto: 103 | """Returns a public key of type protobuf. 104 | 105 | Returns: 106 | A PubKeyProto instance. 107 | """ 108 | 109 | return PubKeyProto(key=self.verify_key.to_string("compressed")) 110 | 111 | def _to_bech32(self, prefix: str) -> str: 112 | five_bit_r = convertbits( 113 | # Append prefix public key type follow amino spec. 114 | bytes.fromhex("eb5ae98721") + self.verify_key.to_string("compressed"), 115 | 8, 116 | 5, 117 | ) 118 | assert five_bit_r is not None, "Unsuccessful bech32.convertbits call" 119 | return bech32_encode(prefix, five_bit_r) 120 | 121 | def to_acc_bech32(self) -> str: 122 | """Returns a bech32 string with an account public key prefix. 123 | 124 | Returns: 125 | A bech32 address as a string. 126 | """ 127 | 128 | return self._to_bech32(BECH32_PUBKEY_ACC_PREFIX) 129 | 130 | def to_val_bech32(self) -> str: 131 | """Returns a bech32 string with a validator public key prefix. 132 | 133 | Returns: 134 | A bech32 address as a string. 135 | """ 136 | 137 | return self._to_bech32(BECH32_PUBKEY_VAL_PREFIX) 138 | 139 | def to_cons_bech32(self) -> str: 140 | """Returns a bech32 string with a validator consensus public key prefix. 141 | 142 | Returns: 143 | A bech32 address as a string. 144 | """ 145 | 146 | return self._to_bech32(BECH32_PUBKEY_CONS_PREFIX) 147 | 148 | def to_address(self) -> Address: 149 | """Return address instance from this public key. 150 | 151 | Returns: 152 | An Address instance. 153 | """ 154 | 155 | hash = hashlib.new("sha256", self.verify_key.to_string("compressed")).digest() 156 | return Address(hashlib.new("ripemd160", hash).digest()) 157 | 158 | def verify(self, msg: bytes, sig: bytes) -> bool: 159 | """Verify a signature made from the given message. 160 | 161 | Args: 162 | msg: Data signed by the signature. 163 | sig: The encoded signature. 164 | 165 | Raises: 166 | BadSignatureError: If the signature is invalid or malformed. 167 | 168 | Returns: 169 | True if the verification was successful, false otherwise. 170 | """ 171 | 172 | try: 173 | return self.verify_key.verify(sig, msg, hashfunc=hashlib.sha256) 174 | except BadSignatureError: 175 | return False 176 | -------------------------------------------------------------------------------- /pyband/wallet/signer.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | 3 | from ecdsa.der import remove_sequence, UnexpectedDER, remove_integer 4 | 5 | from .address import Address 6 | from .constants import BECH32_ADDR_ACC_PREFIX 7 | from .private_key import PrivateKey 8 | from .public_key import PublicKey 9 | from ..cosmos_app import CosmosApp 10 | from ..utils import bip44_to_list 11 | 12 | 13 | class Signer: 14 | @abstractmethod 15 | def get_public_key(self) -> PublicKey: 16 | """Gets public key associated with the signer. 17 | 18 | Returns: 19 | A PublicKey instance. 20 | """ 21 | 22 | pass 23 | 24 | @abstractmethod 25 | def get_address(self) -> Address: 26 | """Gets address associated with the signer. 27 | 28 | Returns: 29 | An Address instance. 30 | """ 31 | 32 | pass 33 | 34 | @abstractmethod 35 | def sign(self, msg: bytes) -> bytes: 36 | """Signs a message with the signer. 37 | 38 | Args: 39 | msg: The message to sign in bytes. 40 | 41 | Returns: 42 | Signature in bytes. 43 | """ 44 | 45 | pass 46 | 47 | 48 | class PrivateKeySigner(Signer): 49 | def __init__(self, private_key: PrivateKey): 50 | self.private_key = private_key 51 | 52 | def get_public_key(self) -> PublicKey: 53 | return self.private_key.to_public_key() 54 | 55 | def get_address(self) -> Address: 56 | return self.private_key.to_public_key().to_address() 57 | 58 | def sign(self, msg: bytes) -> bytes: 59 | return self.private_key.sign(bytes(msg)) 60 | 61 | 62 | class LedgerSigner(Signer): 63 | def __init__(self, path: str, app: CosmosApp): 64 | self.cosmos_app = app if app is not None else CosmosApp(bip44_to_list(path)) 65 | 66 | def get_public_key(self) -> PublicKey: 67 | return PublicKey.from_hex( 68 | self.cosmos_app.ins_get_addr_secp256k1( 69 | BECH32_ADDR_ACC_PREFIX, False 70 | ).public_key 71 | ) 72 | 73 | def get_address(self) -> Address: 74 | return Address.from_acc_bech32( 75 | self.cosmos_app.ins_get_addr_secp256k1( 76 | BECH32_ADDR_ACC_PREFIX, False 77 | ).address.decode() 78 | ) 79 | 80 | def sign(self, msg: bytes) -> bytes: 81 | data, remaining_data = remove_sequence(self.cosmos_app.sign_secp256k1(msg)) 82 | if remaining_data: 83 | raise UnexpectedDER("Unexpected remainder") 84 | 85 | r, remaining_content = remove_integer(data) 86 | s, remaining_content = remove_integer(remaining_content) 87 | if remaining_content: 88 | raise UnexpectedDER("Unexpected remainder") 89 | 90 | return r.to_bytes(32, "big") + s.to_bytes(32, "big") 91 | -------------------------------------------------------------------------------- /pyband/wallet/wallet.py: -------------------------------------------------------------------------------- 1 | from .address import Address 2 | from .constants import DEFAULT_DERIVATION_PATH, DEFAULT_LEDGER_DERIVATION_PATH 3 | from .private_key import PrivateKey 4 | from .public_key import PublicKey 5 | from .signer import Signer, PrivateKeySigner, LedgerSigner 6 | from ..cosmos_app import CosmosApp 7 | from ..proto.cosmos.tx.signing.v1beta1 import SignMode 8 | from ..transaction import Transaction 9 | from ..utils import bip44_to_list 10 | 11 | 12 | class Wallet: 13 | def __init__(self, signer: Signer, sign_mode: SignMode): 14 | self._signer = signer 15 | self._sign_mode = sign_mode 16 | 17 | @classmethod 18 | def from_mnemonic(cls, mnemonic: str, path: str = DEFAULT_DERIVATION_PATH): 19 | """Creates a Wallet instance from a mnemonic phrase and derivation path. 20 | 21 | Args: 22 | mnemonic: The mnemonic phrase. 23 | path: The derivation path. If omitted, defaults to Band's default HD prefix. 24 | 25 | Returns: 26 | A Wallet instance. 27 | """ 28 | 29 | return cls( 30 | PrivateKeySigner(PrivateKey.from_mnemonic(mnemonic, path)), SignMode.DIRECT 31 | ) 32 | 33 | @classmethod 34 | def from_private_key(cls, private_key: str): 35 | """Creates a Wallet instance from a hexadecimal private key. 36 | 37 | Args: 38 | private_key: A private key represented as a hexadecimal. 39 | 40 | Returns: 41 | A Wallet instance. 42 | """ 43 | 44 | return cls(PrivateKeySigner(PrivateKey.from_hex(private_key)), SignMode.DIRECT) 45 | 46 | @classmethod 47 | def from_ledger( 48 | cls, path: str = DEFAULT_LEDGER_DERIVATION_PATH, *, app: CosmosApp = None 49 | ): 50 | """Creates a Wallet instance from a connected Ledger. 51 | 52 | Args: 53 | path: The derivation path. If omitted, defaults to Cosmos's default HD prefix. 54 | app: A CosmosApp instance. 55 | 56 | Returns: 57 | A Wallet instance. 58 | """ 59 | 60 | return cls( 61 | LedgerSigner( 62 | path=path, 63 | app=app if app is not None else CosmosApp(bip44_to_list(path)), 64 | ), 65 | SignMode.LEGACY_AMINO_JSON, 66 | ) 67 | 68 | def get_public_key(self) -> PublicKey: 69 | """Gets the public key associated with this wallet 70 | 71 | Returns: 72 | A PublicKey instance 73 | """ 74 | 75 | return self._signer.get_public_key() 76 | 77 | def get_address(self) -> Address: 78 | """Gets the address associated with this wallet 79 | 80 | Returns: 81 | An Address instance 82 | """ 83 | 84 | return self._signer.get_address() 85 | 86 | def sign_and_build(self, tx: Transaction) -> bytes: 87 | """Signs and builds a broadcastable transaction. 88 | 89 | Args: 90 | tx: A transaction instance to create a broadcastable transaction from. 91 | 92 | Returns: 93 | A transaction as bytes. 94 | """ 95 | public_key = self.get_public_key() 96 | 97 | if self._sign_mode == SignMode.LEGACY_AMINO_JSON: 98 | sign_msg = tx.get_sign_message_for_legacy_codec() 99 | elif self._sign_mode == SignMode.DIRECT: 100 | sign_msg = tx.get_sign_doc(public_key) 101 | else: 102 | raise NotImplementedError(f"Sign mode {self._sign_mode} is not supported") 103 | 104 | signature = self._signer.sign(bytes(sign_msg)) 105 | return tx.get_tx_data(signature, public_key, sign_mode=self._sign_mode) 106 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | authors = [{name = "Band Protocol"}] 3 | license = {text = "MIT"} 4 | requires-python = "<4.0,>=3.7" 5 | dependencies = [ 6 | "bech32==1.2.0", 7 | "betterproto==2.0.0b7", 8 | "bip32==0.0.8", 9 | "ecdsa==0.19.0", 10 | "grpclib==0.4.3", 11 | "ledgerblue==0.1.54", 12 | "mnemonic==0.19", 13 | "python-dateutil==2.8.2" 14 | ] 15 | classifiers = [ 16 | "Development Status :: 3 - Alpha", 17 | "Intended Audience :: Developers", 18 | "License :: OSI Approved :: MIT License", 19 | "Programming Language :: Python :: 3", 20 | "Programming Language :: Python :: 3.7", 21 | "Programming Language :: Python :: 3.8", 22 | "Programming Language :: Python :: 3.9", 23 | "Programming Language :: Python :: 3.10", 24 | "Programming Language :: Python :: 3.11" 25 | ] 26 | description = "Python library for BandChain" 27 | keywords = ["BAND", "BLOCKCHAIN", "ORACLE"] 28 | name = "pyband" 29 | readme = "README.md" 30 | version = "0.4.0-rc3" 31 | 32 | [project.urls] 33 | homepage = "https://bandprotocol.com/" 34 | repository = "https://github.com/bandprotocol/pyband" 35 | documentation = "https://docs.bandchain.org/client-library/pyband/getting-started.html" 36 | 37 | [dependency-groups] 38 | dev = ["pytest==7.1.3", "pytest-asyncio==0.19.0"] 39 | 40 | [tool.ruff] 41 | line-length = 99 42 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bandprotocol/pyband/729384b4eb7aa9ecdc4b1c3858e6c070c6c1266f/tests/__init__.py -------------------------------------------------------------------------------- /tests/client/connect_testnet_test.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import pytest 3 | import pytest_asyncio 4 | from pyband import Client 5 | 6 | 7 | @pytest_asyncio.fixture(scope="module") 8 | async def pyband_client(): 9 | yield Client.from_endpoint("laozi-testnet6.bandchain.org", 443) 10 | 11 | 12 | @pytest.fixture(scope="module") 13 | def event_loop(): 14 | """Change event_loop fixture to module level.""" 15 | policy = asyncio.get_event_loop_policy() 16 | loop = policy.new_event_loop() 17 | yield loop 18 | loop.close() 19 | 20 | 21 | @pytest.mark.asyncio 22 | async def test_get_chain_id(pyband_client): 23 | chain_id = await pyband_client.get_chain_id() 24 | assert chain_id == "band-laozi-testnet6" 25 | -------------------------------------------------------------------------------- /tests/client/send_tx_test.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | 3 | import pytest 4 | import pytest_asyncio 5 | from grpclib.testing import ChannelFor 6 | 7 | from pyband import Client 8 | from pyband.proto.cosmos.base.abci.v1beta1 import ( 9 | TxResponse, 10 | AbciMessageLog, 11 | StringEvent, 12 | Attribute, 13 | ) 14 | from pyband.proto.cosmos.tx.v1beta1 import BroadcastTxRequest, BroadcastTxResponse 15 | from pyband.proto.cosmos.tx.v1beta1 import ServiceBase as CosmosTxServiceBase 16 | 17 | 18 | # Note: Success, if code = 0 19 | class CosmosTransactionService(CosmosTxServiceBase): 20 | async def broadcast_tx( 21 | self, broadcast_tx_request: BroadcastTxRequest 22 | ) -> BroadcastTxResponse: 23 | if broadcast_tx_request.tx_bytes == b"async_any_hash": 24 | return BroadcastTxResponse( 25 | tx_response=TxResponse( 26 | txhash="txhash", 27 | ) 28 | ) 29 | elif broadcast_tx_request.tx_bytes == b"sync_success": 30 | return BroadcastTxResponse( 31 | tx_response=TxResponse( 32 | txhash="6E9A3A8145A0A6562AAE4A4066125006A392620A5656E3CCB145C22FF3CC8AA0", 33 | raw_log="[]", 34 | ) 35 | ) 36 | elif broadcast_tx_request.tx_bytes == b"sync_fail_wrong_bytes": 37 | return BroadcastTxResponse( 38 | tx_response=TxResponse( 39 | txhash="C278EC5A69C34AACE42773E41B1163E6CE40C906F2A14F807D39D1B2A1C2DFF5", 40 | codespace="sdk", 41 | code=2, 42 | raw_log='errUnknownField "*tx.TxRaw": {TagNum: 13, WireType:"bytes"}: tx parse error', 43 | ) 44 | ) 45 | elif broadcast_tx_request.tx_bytes == b"block_success": 46 | return block_mode_success_result 47 | elif broadcast_tx_request.tx_bytes == b"block_out_of_gas": 48 | return BroadcastTxResponse( 49 | tx_response=TxResponse( 50 | height=1284491, 51 | txhash="2CE53A417435AD62F14C27535E19E6B5B2B0FDBF4CDC3532148DAE29BE5666BE", 52 | codespace="sdk", 53 | code=11, 54 | raw_log="out of gas in location: PER_VALIDATOR_REQUEST_FEE; gasWanted: 200000, gasUsed: 517238: out of gas", 55 | gas_wanted=200000, 56 | gas_used=517238, 57 | ) 58 | ) 59 | elif broadcast_tx_request.tx_bytes == b"block_fail": 60 | return BroadcastTxResponse( 61 | tx_response=TxResponse( 62 | txhash="CC06ABAE35591E6668451D9B05D04A0E0C4257A582E4D714975363260A092233", 63 | codespace="sdk", 64 | code=5, 65 | raw_log="0uband, is smaller than 9000000uband: insufficient funds: insufficient funds", 66 | gas_wanted=5000000, 67 | gas_used=21747, 68 | ) 69 | ) 70 | elif broadcast_tx_request.tx_bytes == b"block_fail_wrong_bytes": 71 | return BroadcastTxResponse( 72 | tx_response=TxResponse( 73 | txhash="7CA12506E88CF8B814E20848B229460F91FC0370C44A7C4FEE786960CE30C36D", 74 | codespace="sdk", 75 | code=2, 76 | raw_log='errUnknownField "*tx.TxRaw": {TagNum: 14, WireType:"start_group"}: tx parse error', 77 | gas_used=6429, 78 | ) 79 | ) 80 | 81 | 82 | @pytest_asyncio.fixture(scope="module") 83 | async def pyband_client(): 84 | channel_for = ChannelFor(services=[CosmosTransactionService()]) 85 | channel = await channel_for.__aenter__() 86 | yield Client(channel) 87 | channel.close() 88 | 89 | 90 | @pytest.fixture(scope="module") 91 | def event_loop(): 92 | """Change event_loop fixture to module level.""" 93 | policy = asyncio.get_event_loop_policy() 94 | loop = policy.new_event_loop() 95 | yield loop 96 | loop.close() 97 | 98 | 99 | # Async mode: returns immediately (transaction might fail) 100 | # send any bytes value -> will result in response txhash 101 | @pytest.mark.asyncio 102 | async def test_send_tx_async_mode_success(pyband_client): 103 | tx_response = await pyband_client.send_tx_async_mode(b"async_any_hash") 104 | mock_result = TxResponse( 105 | txhash="txhash", 106 | ) 107 | assert tx_response == mock_result 108 | 109 | 110 | @pytest.mark.asyncio 111 | async def test_send_tx_async_mode_invalid_input(pyband_client): 112 | with pytest.raises(TypeError): 113 | await pyband_client.send_tx_async_mode(1) 114 | 115 | 116 | # Sync mode: wait for checkTx execution response 117 | # Success if code = 0 118 | @pytest.mark.asyncio 119 | async def test_send_tx_sync_mode_success(pyband_client): 120 | tx_response = await pyband_client.send_tx_sync_mode(b"sync_success") 121 | mock_result = BroadcastTxResponse( 122 | tx_response=TxResponse( 123 | txhash="6E9A3A8145A0A6562AAE4A4066125006A392620A5656E3CCB145C22FF3CC8AA0", 124 | raw_log="[]", 125 | ) 126 | ) 127 | assert tx_response == mock_result.tx_response 128 | 129 | 130 | # Fail if code != 0, invalid bytes code = 2 131 | @pytest.mark.asyncio 132 | async def test_send_tx_sync_mode_invalid_bytes(pyband_client): 133 | tx_response = await pyband_client.send_tx_sync_mode(b"sync_fail_wrong_bytes") 134 | mock_result = BroadcastTxResponse( 135 | tx_response=TxResponse( 136 | txhash="C278EC5A69C34AACE42773E41B1163E6CE40C906F2A14F807D39D1B2A1C2DFF5", 137 | codespace="sdk", 138 | code=2, 139 | raw_log='errUnknownField "*tx.TxRaw": {TagNum: 13, WireType:"bytes"}: tx parse error', 140 | ) 141 | ) 142 | assert tx_response == mock_result.tx_response 143 | 144 | 145 | @pytest.mark.asyncio 146 | async def test_send_tx_sync_mode_invalid_input(pyband_client): 147 | with pytest.raises(TypeError): 148 | await pyband_client.send_tx_sync_mode(1) 149 | -------------------------------------------------------------------------------- /tests/utils_test.py: -------------------------------------------------------------------------------- 1 | import math 2 | import pytest 3 | 4 | from pyband.utils import is_bip44, bip44_to_list, get_bip32_byte, split_packet, NotBip44Error 5 | 6 | 7 | @pytest.fixture 8 | def valid_path(): 9 | return "m/44'/118'/0'/0/0" 10 | 11 | 12 | @pytest.fixture 13 | def invalid_paths(): 14 | return ["m/a'/b'/c'/d/e", "/44'/118'/0'/0/0"] 15 | 16 | 17 | def test_is_bip44_success(valid_path): 18 | assert is_bip44(valid_path) is True 19 | 20 | 21 | def test_is_bip44_failure(invalid_paths): 22 | assert [is_bip44(x) for x in invalid_paths] == [False] * len(invalid_paths) 23 | 24 | 25 | def test_bip44_to_list_success(valid_path): 26 | assert bip44_to_list(valid_path) == [44, 118, 0, 0, 0] 27 | 28 | 29 | def test_bip44_to_list_failure(invalid_paths): 30 | with pytest.raises(NotBip44Error): 31 | bip44_to_list(invalid_paths[0]) 32 | 33 | 34 | def test_get_bip32_byte(valid_path): 35 | path_list = bip44_to_list(valid_path) 36 | expected_val = b"\x2c\x00\x00\x80\x76\x00\x00\x80\x00\x00\x00\x80\x00\x00\x00\x80\x00\x00\x00\x80" 37 | assert get_bip32_byte(path_list, 5) == expected_val 38 | 39 | 40 | def test_split_packet(): 41 | test_msg_size = 1111 42 | expected_packet_size = 250 43 | test_msg = b"0" * test_msg_size 44 | 45 | expected_packets_count = math.ceil(test_msg_size / expected_packet_size) 46 | packets = split_packet(test_msg) 47 | 48 | assert len(packets) == expected_packets_count 49 | assert packets[0] == b"0" * expected_packet_size 50 | assert packets[-1] == b"0" * (test_msg_size % expected_packet_size) 51 | -------------------------------------------------------------------------------- /tests/wallet_test.py: -------------------------------------------------------------------------------- 1 | from pyband.wallet import PrivateKey, PublicKey, Address 2 | 3 | TEST_MNEMONIC = "coach pond canoe lake solution empty vacuum term pave toe burst top violin purpose umbrella color disease thrive diamond found track need filter wait" 4 | 5 | TEST_ACC_PUBKEY = "bandpub1addwnpepqdg7nrsmuztj2re07svgcz4vuzn3de56nykdwlualepkk05txs5q6mw8s9v" 6 | TEST_VAL_PUBKEY = "bandvaloperpub1addwnpepqdg7nrsmuztj2re07svgcz4vuzn3de56nykdwlualepkk05txs5q69gsm29" 7 | TEST_CONS_PUBKEY = "bandvalconspub1addwnpepqdg7nrsmuztj2re07svgcz4vuzn3de56nykdwlualepkk05txs5q6r8ytws" 8 | 9 | TEST_ACC_ADDRESS = "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c" 10 | TEST_VAL_ADDRESS = "bandvaloper13eznuehmqzd3r84fkxu8wklxl22r2qfm8f05zn" 11 | TEST_CONS_ADDRESS = "bandvalcons13eznuehmqzd3r84fkxu8wklxl22r2qfmn6ugwj" 12 | 13 | 14 | def test_private_key_from_mnemonic(): 15 | assert ( 16 | PrivateKey.from_mnemonic(TEST_MNEMONIC).to_hex() 17 | == "2159f40dda9e4c9d8ed9d6f8c353e247a2658993a9d53a94ff17410cd0ea471d" 18 | ) 19 | assert ( 20 | PrivateKey.from_mnemonic(TEST_MNEMONIC, "m/44'/494'/0'/0/1").to_hex() 21 | == "987af53f91a09926274e5a2ef86223356112056f61b35a57df345d7b14176bb3" 22 | ) 23 | 24 | 25 | def test_private_key_generate(): 26 | mnemonic, private_key = PrivateKey.generate("m/44'/494'/0'/0/5") 27 | 28 | assert PrivateKey.from_mnemonic(mnemonic, "m/44'/494'/0'/0/5").to_hex() == private_key.to_hex() 29 | 30 | 31 | def test_private_key_from_hex(): 32 | assert ( 33 | PrivateKey.from_hex("2159f40dda9e4c9d8ed9d6f8c353e247a2658993a9d53a94ff17410cd0ea471d").to_hex() 34 | == "2159f40dda9e4c9d8ed9d6f8c353e247a2658993a9d53a94ff17410cd0ea471d" 35 | ) 36 | 37 | 38 | def test_private_key_to_public_key(): 39 | public_key = PrivateKey.from_mnemonic(TEST_MNEMONIC).to_public_key() 40 | assert public_key.to_hex() == "0351e98e1be097250f2ff4188c0aace0a716e69a992cd77f9dfe436b3e8b34280d" 41 | 42 | 43 | def test_private_key_sign(): 44 | private_key = PrivateKey.from_mnemonic(TEST_MNEMONIC) 45 | sig = private_key.sign(b"test msg") 46 | 47 | assert ( 48 | sig.hex() 49 | == "42a1e41012155ae2daa9b9a2e038f76463da4662564b4989f236ecb4d97f592c1190d92319363e2d1eb78fb98f0dac30c5e2a850f45bb4c44f1f6203ebe6efbe" 50 | ) 51 | 52 | 53 | def test_public_key_from_bech32(): 54 | assert ( 55 | PublicKey.from_acc_bech32(TEST_ACC_PUBKEY).to_hex() 56 | == "0351e98e1be097250f2ff4188c0aace0a716e69a992cd77f9dfe436b3e8b34280d" 57 | ) 58 | assert ( 59 | PublicKey.from_val_bech32(TEST_VAL_PUBKEY).to_hex() 60 | == "0351e98e1be097250f2ff4188c0aace0a716e69a992cd77f9dfe436b3e8b34280d" 61 | ) 62 | assert ( 63 | PublicKey.from_cons_bech32(TEST_CONS_PUBKEY).to_hex() 64 | == "0351e98e1be097250f2ff4188c0aace0a716e69a992cd77f9dfe436b3e8b34280d" 65 | ) 66 | 67 | 68 | def test_public_key_to_bech32(): 69 | private_key = PrivateKey.from_mnemonic(TEST_MNEMONIC) 70 | 71 | assert private_key.to_public_key().to_acc_bech32() == TEST_ACC_PUBKEY 72 | assert private_key.to_public_key().to_val_bech32() == TEST_VAL_PUBKEY 73 | assert private_key.to_public_key().to_cons_bech32() == TEST_CONS_PUBKEY 74 | 75 | 76 | def test_public_key_verify(): 77 | private_key = PrivateKey.from_mnemonic(TEST_MNEMONIC) 78 | sig = private_key.sign(b"test msg") 79 | 80 | pub_key = private_key.to_public_key() 81 | assert pub_key.verify(b"test msg", sig) == True 82 | # Invalid message 83 | assert pub_key.verify(b"another msg", sig) == False 84 | # Invalid signature 85 | assert pub_key.verify(b"test msg", sig[1:]) == False 86 | 87 | 88 | def test_address_from_bech32(): 89 | assert Address.from_acc_bech32(TEST_ACC_ADDRESS).to_hex() == "8e453e66fb009b119ea9b1b8775be6fa9435013b" 90 | assert Address.from_val_bech32(TEST_VAL_ADDRESS).to_hex() == "8e453e66fb009b119ea9b1b8775be6fa9435013b" 91 | assert Address.from_cons_bech32(TEST_CONS_ADDRESS).to_hex() == "8e453e66fb009b119ea9b1b8775be6fa9435013b" 92 | 93 | 94 | def test_address_to_bech32(): 95 | addr = PrivateKey.from_mnemonic(TEST_MNEMONIC).to_public_key().to_address() 96 | 97 | assert addr.to_acc_bech32() == TEST_ACC_ADDRESS 98 | assert addr.to_val_bech32() == TEST_VAL_ADDRESS 99 | assert addr.to_cons_bech32() == TEST_CONS_ADDRESS 100 | --------------------------------------------------------------------------------