Skip to main content

the toolset for cyber protocol and cosmos ecosystem

Project description

cyberutils

GitHub Python pip

PyPI Package · GitHub Repository

usage

execute bash query

get bash query result and error

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

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

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)

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

# 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',
    memo='the first transfer')

execute a graphql query

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

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

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cyberutils-0.0.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

cyberutils-0.0.4-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file cyberutils-0.0.4.tar.gz.

File metadata

  • Download URL: cyberutils-0.0.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for cyberutils-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d5f4447203d860f686e3aa0025a9b29ab1d12069add2a74517d8531a21375086
MD5 be9a6e055d41eab9e7496371327065c0
BLAKE2b-256 90250867edffe6e444c67661b65fc9aa763904ca4a983026688a7bdb800e9c22

See more details on using hashes here.

Provenance

File details

Details for the file cyberutils-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: cyberutils-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for cyberutils-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 196b650878efda2c6f7b986871b5dc968da2a4556a4966c6f0b05b0099d85156
MD5 fc0615c406fed8e414f01bc59f3de202
BLAKE2b-256 59c9c6c697999d523dc802fad4425521f0674465913051aa444e283a483a4f56

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page