cyberutils


Namecyberutils JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/Snedashkovsky/cyberutils
Summarythe toolset for cyber protocol and cosmos ecosystem
upload_time2024-04-25 01:33:55
maintainerNone
docs_urlNone
authorSnedashkovsky,
requires_python<4.0,>=3.9
licenseMIT
keywords bostrom cyber knowledge-graph dex swap defi crypto blockchain
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cyberutils

<p>
    <img alt="GitHub" src="https://img.shields.io/github/license/Snedashkovsky/cyberutils">
    <img alt="Python" src="https://img.shields.io/pypi/pyversions/cyberutils">
    <img alt="pip" src="https://img.shields.io/pypi/v/cyberutils">
</p>
<p>
    <a href="https://pypi.org/project/cyberutils/">PyPI Package</a>
    ยท
    <a href="https://github.com/Snedashkovsky/cyberutils">GitHub Repository</a>
</p>

## usage

### execute bash query
get bash query result and error
```python
from cyberutils.bash import execute_bash

execute_bash(
    bash_command='cyber status --node https://rpc.bostrom.cybernode.ai:443')
```
get json from bash query result
```python
from cyberutils.bash import get_json_from_bash_query

get_json_from_bash_query(
    bash_command='cyber status --node https://rpc.bostrom.cybernode.ai:443')
```

### execute a cosmwasm contract

```python
import requests

from cyber_sdk.client.lcd import LCDClient
from cyber_sdk.key.mnemonic import MnemonicKey

from cyberutils.contract import execute_contract

WALLET_SEED = 'rack canyon puzzle grow afford faint heavy kick furnace economy change loop debate tip acquire render rib truth bachelor monster page range wine measure'
CONTRACT_ADDRESS = 'bostrom1nwm9pjmfgmxgc4euyfps05p9pfde8vd4sm8pavy93eu9xquz27dsgyxtml'

# initiate lcd client and wallet
mk = MnemonicKey(mnemonic=WALLET_SEED)
lcd_client = LCDClient(
    url='https://lcd.bostrom.cybernode.ai/',
    chain_id='bostrom',
    prefix='bostrom'
)
wallet = lcd_client.wallet(mk)

# an execution message in a contract must match its schema
execute_msg = {
    "transfer" :  {
        "recipient": "bostrom1xszmhkfjs3s00z2nvtn7evqxw3dtus6yr8e4pw",
        "amount": "1000000"
    }
}

# load a contract schema for an execute message validation
contract_schema_json = \
    requests.get(
        url='https://raw.githubusercontent.com/Snedashkovsky/cw-plus/main/contracts/cw20-base/schema/cw20-base.json'
    ).json()

# execution of a contract
execute_contract(
    execute_msgs=[execute_msg],
    wallet=wallet,
    contract_address=CONTRACT_ADDRESS,
    lcd_client=lcd_client,
    gas=500_000,
    fee_amount=0,
    fee_denom='boot',
    contract_execute_schema=contract_schema_json['execute'],
    memo='the first transfer')
```

### query a cosmwasm contract

```python
from cyberutils.contract import query_contract

query_contract(
    query={
        'get_asset': {
            'chain_name': 'osmosis',
            'base': 'ibc/FE2CD1E6828EC0FAB8AF39BAC45BC25B965BA67CCBC50C13A14BD610B0D1E2C4'
        }
    },
    contract_address='bostrom1w33tanvadg6fw04suylew9akcagcwngmkvns476wwu40fpq36pms92re6u',
    node_lcd_url='https://lcd.bostrom.cybernode.ai'
)
```

### execute a graphql query

```python
import pandas as pd

from cyberutils.graphql import execute_graphql

res = await execute_graphql(
    request="""
        query AllContracts {
          contracts(order_by: {tx: desc_nulls_last}) {
            address
            admin
            code_id
            creation_time
            creator
            fees
            gas
            height
            label
            tx
          }
        }
        """,
    graphql_url='https://index.bostrom.cybernode.ai/v1/graphql')

pd.DataFrame(res['contracts'])
```
a query with variable values
```python
import pandas as pd

from cyberutils.graphql import execute_graphql

res = await execute_graphql(
    request="""
        query ContractsCodeID($code_id: bigint) {
            contracts(order_by: {tx: desc_nulls_last}, where: {code_id: {_eq: $code_id}}) {
                address
                admin
                creation_time
                creator
                fees
                gas
                height
                label
                tx
                code_id
            }
        }
        """,
    variable_values={"code_id": "3"},
    graphql_url='https://index.bostrom.cybernode.ai/v1/graphql')

pd.DataFrame(res['contracts'])
```
get messages with a given address and type
```python
import pandas as pd

from cyberutils.graphql import get_messages_by_address_and_type


res = await get_messages_by_address_and_type(
    address='bostrom1xszmhkfjs3s00z2nvtn7evqxw3dtus6yr8e4pw',
    msg_type='cosmos.bank.v1beta1.MsgSend',
    graphql_url='https://index.bostrom.cybernode.ai/v1/graphql')

pd.DataFrame(res)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Snedashkovsky/cyberutils",
    "name": "cyberutils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "bostrom, cyber, knowledge-graph, dex, swap, defi, crypto, blockchain",
    "author": "Snedashkovsky,",
    "author_email": "sn@cyberdrop.ai",
    "download_url": "https://files.pythonhosted.org/packages/dd/05/41d2543cde70ca609dbd4125c2bbbfc3dd8725fd8832a71c63ff763e3f1b/cyberutils-0.0.6.tar.gz",
    "platform": null,
    "description": "# cyberutils\n\n<p>\n    <img alt=\"GitHub\" src=\"https://img.shields.io/github/license/Snedashkovsky/cyberutils\">\n    <img alt=\"Python\" src=\"https://img.shields.io/pypi/pyversions/cyberutils\">\n    <img alt=\"pip\" src=\"https://img.shields.io/pypi/v/cyberutils\">\n</p>\n<p>\n    <a href=\"https://pypi.org/project/cyberutils/\">PyPI Package</a>\n    \u00b7\n    <a href=\"https://github.com/Snedashkovsky/cyberutils\">GitHub Repository</a>\n</p>\n\n## usage\n\n### execute bash query\nget bash query result and error\n```python\nfrom cyberutils.bash import execute_bash\n\nexecute_bash(\n    bash_command='cyber status --node https://rpc.bostrom.cybernode.ai:443')\n```\nget json from bash query result\n```python\nfrom cyberutils.bash import get_json_from_bash_query\n\nget_json_from_bash_query(\n    bash_command='cyber status --node https://rpc.bostrom.cybernode.ai:443')\n```\n\n### execute a cosmwasm contract\n\n```python\nimport requests\n\nfrom cyber_sdk.client.lcd import LCDClient\nfrom cyber_sdk.key.mnemonic import MnemonicKey\n\nfrom cyberutils.contract import execute_contract\n\nWALLET_SEED = 'rack canyon puzzle grow afford faint heavy kick furnace economy change loop debate tip acquire render rib truth bachelor monster page range wine measure'\nCONTRACT_ADDRESS = 'bostrom1nwm9pjmfgmxgc4euyfps05p9pfde8vd4sm8pavy93eu9xquz27dsgyxtml'\n\n# initiate lcd client and wallet\nmk = MnemonicKey(mnemonic=WALLET_SEED)\nlcd_client = LCDClient(\n    url='https://lcd.bostrom.cybernode.ai/',\n    chain_id='bostrom',\n    prefix='bostrom'\n)\nwallet = lcd_client.wallet(mk)\n\n# an execution message in a contract must match its schema\nexecute_msg = {\n    \"transfer\" :  {\n        \"recipient\": \"bostrom1xszmhkfjs3s00z2nvtn7evqxw3dtus6yr8e4pw\",\n        \"amount\": \"1000000\"\n    }\n}\n\n# load a contract schema for an execute message validation\ncontract_schema_json = \\\n    requests.get(\n        url='https://raw.githubusercontent.com/Snedashkovsky/cw-plus/main/contracts/cw20-base/schema/cw20-base.json'\n    ).json()\n\n# execution of a contract\nexecute_contract(\n    execute_msgs=[execute_msg],\n    wallet=wallet,\n    contract_address=CONTRACT_ADDRESS,\n    lcd_client=lcd_client,\n    gas=500_000,\n    fee_amount=0,\n    fee_denom='boot',\n    contract_execute_schema=contract_schema_json['execute'],\n    memo='the first transfer')\n```\n\n### query a cosmwasm contract\n\n```python\nfrom cyberutils.contract import query_contract\n\nquery_contract(\n    query={\n        'get_asset': {\n            'chain_name': 'osmosis',\n            'base': 'ibc/FE2CD1E6828EC0FAB8AF39BAC45BC25B965BA67CCBC50C13A14BD610B0D1E2C4'\n        }\n    },\n    contract_address='bostrom1w33tanvadg6fw04suylew9akcagcwngmkvns476wwu40fpq36pms92re6u',\n    node_lcd_url='https://lcd.bostrom.cybernode.ai'\n)\n```\n\n### execute a graphql query\n\n```python\nimport pandas as pd\n\nfrom cyberutils.graphql import execute_graphql\n\nres = await execute_graphql(\n    request=\"\"\"\n        query AllContracts {\n          contracts(order_by: {tx: desc_nulls_last}) {\n            address\n            admin\n            code_id\n            creation_time\n            creator\n            fees\n            gas\n            height\n            label\n            tx\n          }\n        }\n        \"\"\",\n    graphql_url='https://index.bostrom.cybernode.ai/v1/graphql')\n\npd.DataFrame(res['contracts'])\n```\na query with variable values\n```python\nimport pandas as pd\n\nfrom cyberutils.graphql import execute_graphql\n\nres = await execute_graphql(\n    request=\"\"\"\n        query ContractsCodeID($code_id: bigint) {\n            contracts(order_by: {tx: desc_nulls_last}, where: {code_id: {_eq: $code_id}}) {\n                address\n                admin\n                creation_time\n                creator\n                fees\n                gas\n                height\n                label\n                tx\n                code_id\n            }\n        }\n        \"\"\",\n    variable_values={\"code_id\": \"3\"},\n    graphql_url='https://index.bostrom.cybernode.ai/v1/graphql')\n\npd.DataFrame(res['contracts'])\n```\nget messages with a given address and type\n```python\nimport pandas as pd\n\nfrom cyberutils.graphql import get_messages_by_address_and_type\n\n\nres = await get_messages_by_address_and_type(\n    address='bostrom1xszmhkfjs3s00z2nvtn7evqxw3dtus6yr8e4pw',\n    msg_type='cosmos.bank.v1beta1.MsgSend',\n    graphql_url='https://index.bostrom.cybernode.ai/v1/graphql')\n\npd.DataFrame(res)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "the toolset for cyber protocol and cosmos ecosystem",
    "version": "0.0.6",
    "project_urls": {
        "Documentation": "https://github.com/Snedashkovsky/cyberutils",
        "Homepage": "https://github.com/Snedashkovsky/cyberutils",
        "Repository": "https://github.com/Snedashkovsky/cyberutils.git"
    },
    "split_keywords": [
        "bostrom",
        " cyber",
        " knowledge-graph",
        " dex",
        " swap",
        " defi",
        " crypto",
        " blockchain"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1cc3ec22fe74e5a7f5d6d7d395e9ae5d696f9ce3a6a42f3eab3099f15b148a79",
                "md5": "044badcb9b8435960dabc9aaf114d85d",
                "sha256": "f48c6f0dd2a124e916816578af0f6cfca5e06bc6294d58dae8f8808ba333b9c9"
            },
            "downloads": -1,
            "filename": "cyberutils-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "044badcb9b8435960dabc9aaf114d85d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 10175,
            "upload_time": "2024-04-25T01:33:53",
            "upload_time_iso_8601": "2024-04-25T01:33:53.776162Z",
            "url": "https://files.pythonhosted.org/packages/1c/c3/ec22fe74e5a7f5d6d7d395e9ae5d696f9ce3a6a42f3eab3099f15b148a79/cyberutils-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd0541d2543cde70ca609dbd4125c2bbbfc3dd8725fd8832a71c63ff763e3f1b",
                "md5": "f5824646e358ec4610951873088d11f3",
                "sha256": "71eb369a5f559fb2118c4fb975231c8e9e2e384e21b414d2da59a6bf11a8a960"
            },
            "downloads": -1,
            "filename": "cyberutils-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f5824646e358ec4610951873088d11f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 8699,
            "upload_time": "2024-04-25T01:33:55",
            "upload_time_iso_8601": "2024-04-25T01:33:55.487210Z",
            "url": "https://files.pythonhosted.org/packages/dd/05/41d2543cde70ca609dbd4125c2bbbfc3dd8725fd8832a71c63ff763e3f1b/cyberutils-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 01:33:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Snedashkovsky",
    "github_project": "cyberutils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cyberutils"
}
        
Elapsed time: 0.23020s