Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proto files moved to a separate proto module. #42

Merged
merged 33 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b34d393
Proto files moved to a separate proto module.
panasevychol Aug 12, 2021
2f7edce
Imports fixed.
panasevychol Aug 12, 2021
7d90930
Imports fixed with isort.
panasevychol Aug 12, 2021
14873f3
Manifest updated.
panasevychol Aug 12, 2021
5e510f9
Mypy ignored Proto module.
panasevychol Aug 12, 2021
c0925ed
Imports fixed.
panasevychol Aug 12, 2021
1795670
Proto imports fixed.
panasevychol Aug 12, 2021
124b483
Package docstring added.
panasevychol Aug 12, 2021
32de8dc
Makefile updated.
panasevychol Aug 12, 2021
0f91d72
chore: restructure and refactor
5A11 Aug 16, 2021
42565b9
fix: examples, manifest, setup.py
5A11 Aug 16, 2021
f040e98
fix: makefile
5A11 Aug 16, 2021
d919cc7
Makefile fi
MissingNO57 Aug 17, 2021
4a4d17e
tox.ini fix
MissingNO57 Aug 17, 2021
08c101d
fix
MissingNO57 Aug 17, 2021
515d8bd
import fixes
MissingNO57 Aug 17, 2021
348f53b
Import fixes
MissingNO57 Aug 17, 2021
5cac6b9
Fixes
MissingNO57 Aug 17, 2021
a66df5c
changes
MissingNO57 Aug 17, 2021
8a2384c
Copyright check
MissingNO57 Aug 17, 2021
52e49a5
copyright checks
MissingNO57 Aug 17, 2021
9d6682d
changes
MissingNO57 Aug 17, 2021
d35842c
Fixes
MissingNO57 Aug 17, 2021
5653d66
More fixes
MissingNO57 Aug 17, 2021
dd7e5ef
fix
MissingNO57 Aug 17, 2021
7878f3f
pylint fix
MissingNO57 Aug 17, 2021
45d0ab4
Copyright setup.py
MissingNO57 Aug 17, 2021
9af6624
comment
MissingNO57 Aug 17, 2021
fa3db0c
setup.py checks
MissingNO57 Aug 17, 2021
0405aee
setup.cfg
MissingNO57 Aug 17, 2021
9097585
module docstring
MissingNO57 Aug 17, 2021
48a57a9
pack fix
MissingNO57 Aug 17, 2021
c9f1237
Piplock update
MissingNO57 Aug 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ build/

# Tox files
.tox

.DS_Store
*/.DS_Store
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ recursive-include contracts *.wasm
recursive-include examples *.py
recursive-include scripts *.py
recursive-include scripts *.sh
recursive-include src *.py
recursive-include pycosm *.py
recursive-include tests *.py
recursive-include tests *.wasm
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ WASMD_VERSION := v0.16.0
COSMOS_PROTO_RELATIVE_DIRS := proto third_party/proto
WASMD_PROTO_RELATIVE_DIRS := proto
SOURCES_REGEX_TO_EXCLUDE := third_party/proto/google/.*
OUTPUT_FOLDER := src
PYCOSM_SRC_DIR := src/cosm
OUTPUT_FOLDER := pycosm/protos
PYCOSM_SRC_DIR := pycosm

PYCOSM_TESTS_DIR := tests
PYCOSM_EXAMPLES_DIR := examples

Expand Down Expand Up @@ -77,19 +78,19 @@ $(WASMD_DIR): Makefile

.PHONY: black-check
black-check:
black --check --verbose $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
black --check --verbose $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py

.PHONY: isort-check
isort-check:
isort --check-only --verbose $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
isort --check-only --verbose $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py

.PHONY: flake
flake:
flake8 $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
flake8 $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py

.PHONY: vulture
vulture:
vulture $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) --exclude "*_pb2.py"
vulture $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py --exclude '*_pb2.py,*_pb2_grpc.py'

####################
### Security & Safety
Expand All @@ -110,11 +111,11 @@ safety:

.PHONY: mypy
mypy:
mypy $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
mypy $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py --exclude 'vulture_whitelist.py|pycosm/protos'

.PHONY: pylint
pylint:
pylint $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
pylint $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py --ignore-paths "pycosm/protos/"

####################
### Tests
Expand Down Expand Up @@ -142,10 +143,10 @@ copyright-check:

.PHONY: lint
lint:
black $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
isort $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
flake8 $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR)
vulture $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) --exclude "*_pb2.py"
black $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py
isort $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py
flake8 $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py
vulture $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py --exclude '*_pb2.py,*_pb2_grpc.py'

.PHONY: check
check:
Expand Down
20 changes: 14 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions examples/atomic_swap_contract_grpc_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@

import inspect
import os
from pathlib import Path
from typing import Any, Dict

from grpc import insecure_channel

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.crypto.keypairs import PrivateKey
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.crypto.keypairs import PrivateKey

# ID and amount of tokens to be minted in contract
TOKEN_ID_1 = "1234"
Expand All @@ -35,7 +37,7 @@

# Path to smart contract
CUR_PATH = os.path.dirname(inspect.getfile(inspect.currentframe())) # type: ignore
CONTRACT_FILENAME = os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm")
CONTRACT_FILENAME = Path(os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm"))

# Node config
GRPC_ENDPOINT_ADDRESS = "localhost:9090"
Expand All @@ -61,7 +63,8 @@
print(f"Contract stored, code ID: {code_id}")

# Init contract
contract_address = validator_client.instantiate_contract(code_id, {})
init_msg: Dict[str, Any] = {}
contract_address = validator_client.instantiate_contract(code_id, init_msg)
print(f"Contract address: {contract_address}")

# Create 2 tokens in one batch message
Expand Down
13 changes: 8 additions & 5 deletions examples/atomic_swap_contract_rest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

import inspect
import os
from pathlib import Path
from typing import Any, Dict

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.common.rest_client import RestClient
from cosm.crypto.keypairs import PrivateKey
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.common.rest_client import RestClient
from pycosm.crypto.keypairs import PrivateKey

# ID and amount of tokens to be minted in contract
TOKEN_ID_1 = "1234"
Expand All @@ -34,7 +36,7 @@

# Path to smart contract
CUR_PATH = os.path.dirname(inspect.getfile(inspect.currentframe())) # type: ignore
CONTRACT_FILENAME = os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm")
CONTRACT_FILENAME = Path(os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm"))

# Node config
REST_ENDPOINT_ADDRESS = "http:https://localhost:1317"
Expand All @@ -60,7 +62,8 @@
print(f"Contract stored, code ID: {code_id}")

# Init contract
contract_address = validator_client.instantiate_contract(code_id, {})
init_msg: Dict[str, Any] = {}
contract_address = validator_client.instantiate_contract(code_id, init_msg)
print(f"Contract address: {contract_address}")

# Create 2 tokens in one batch message
Expand Down
11 changes: 7 additions & 4 deletions examples/contract_interaction_grpc_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@

import inspect
import os
from pathlib import Path
from typing import Any, Dict

from grpc import insecure_channel

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.crypto.keypairs import PrivateKey
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.crypto.keypairs import PrivateKey

# ID and amount of tokens to be minted in contract
TOKEN_ID = "1234"
AMOUNT = "1"

# Path to smart contract
CUR_PATH = os.path.dirname(inspect.getfile(inspect.currentframe())) # type: ignore
CONTRACT_FILENAME = os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm")
CONTRACT_FILENAME = Path(os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm"))

# Node config
GRPC_ENDPOINT_ADDRESS = "localhost:9090"
Expand All @@ -53,7 +55,8 @@
print(f"Contract stored, code ID: {code_id}")

# Init contract
contract_address = client.instantiate_contract(code_id, {})
init_msg: Dict[str, Any] = {}
contract_address = client.instantiate_contract(code_id, init_msg)
print(f"Contract address: {contract_address}")

# Create token with ID TOKEN_ID
Expand Down
13 changes: 8 additions & 5 deletions examples/contract_interaction_rest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@

import inspect
import os
from pathlib import Path
from typing import Any, Dict

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.common.rest_client import RestClient
from cosm.crypto.keypairs import PrivateKey
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.common.rest_client import RestClient
from pycosm.crypto.keypairs import PrivateKey

# ID and amount of tokens to be minted in contract
TOKEN_ID = "1234"
AMOUNT = "1"

# Path to smart contract
CUR_PATH = os.path.dirname(inspect.getfile(inspect.currentframe())) # type: ignore
CONTRACT_FILENAME = os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm")
CONTRACT_FILENAME = Path(os.path.join(CUR_PATH, "..", "contracts", "cw_erc1155.wasm"))

# Node config
REST_ENDPOINT_ADDRESS = "http:https://localhost:1317"
Expand All @@ -52,7 +54,8 @@
print(f"Contract stored, code ID: {code_id}")

# Init contract
contract_address = client.instantiate_contract(code_id, {})
init_msg: Dict[str, Any] = {}
contract_address = client.instantiate_contract(code_id, init_msg)
print(f"Contract address: {contract_address}")

# Create token with ID TOKEN_ID
Expand Down
4 changes: 2 additions & 2 deletions examples/query_balance_rest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

"""REST example of query balance."""

from cosm.bank.rest_client import BankRestClient, QueryBalanceRequest
from cosm.common.rest_client import RestClient
from pycosm.bank.rest_client import BankRestClient, QueryBalanceRequest
from pycosm.common.rest_client import RestClient

REST_URL = "http:https://127.0.0.1:1317"
ADDRESS = "fetch1mrf5yyjnnlpy0egvpk2pvjdk9667j2gtu8kpfy"
Expand Down
6 changes: 3 additions & 3 deletions examples/tx_native_tokens_atomic_swap_grpc_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

from grpc import insecure_channel

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.crypto.keypairs import PrivateKey
from cosmos.base.v1beta1.coin_pb2 import Coin
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.crypto.keypairs import PrivateKey
from pycosm.protos.cosmos.base.v1beta1.coin_pb2 import Coin

# Denomination and amount of transferred tokens
DENOM_1 = "stake"
Expand Down
8 changes: 4 additions & 4 deletions examples/tx_native_tokens_atomic_swap_rest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

""" REST example of native tokens atomic swap """

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.common.rest_client import RestClient
from cosm.crypto.keypairs import PrivateKey
from cosmos.base.v1beta1.coin_pb2 import Coin
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.common.rest_client import RestClient
from pycosm.crypto.keypairs import PrivateKey
from pycosm.protos.cosmos.base.v1beta1.coin_pb2 import Coin

# Denomination and amount of transferred tokens
DENOM_1 = "stake"
Expand Down
9 changes: 5 additions & 4 deletions examples/tx_send_grpc_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

from grpc import insecure_channel

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.crypto.keypairs import PrivateKey
from cosmos.base.v1beta1.coin_pb2 import Coin
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.crypto.address import Address
from pycosm.crypto.keypairs import PrivateKey
from pycosm.protos.cosmos.base.v1beta1.coin_pb2 import Coin

# Denomination and amount of transferred tokens
DENOM = "stake"
Expand All @@ -42,7 +43,7 @@
client = SigningCosmWasmClient(FROM_PK, channel, CHAIN_ID)

# Address of recipient account
TO_ADDRESS = "fetch128r83uvcxns82535d3da5wmfvhc2e5mut922dw"
TO_ADDRESS = Address("fetch128r83uvcxns82535d3da5wmfvhc2e5mut922dw")

# Print balance before transfer
print("Before transaction")
Expand Down
11 changes: 6 additions & 5 deletions examples/tx_send_rest_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

""" REST example of sending and querying funds """

from cosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from cosm.common.rest_client import RestClient
from cosm.crypto.keypairs import PrivateKey
from cosmos.base.v1beta1.coin_pb2 import Coin
from pycosm.clients.signing_cosmwasm_client import SigningCosmWasmClient
from pycosm.common.rest_client import RestClient
from pycosm.crypto.address import Address
from pycosm.crypto.keypairs import PrivateKey
from pycosm.protos.cosmos.base.v1beta1.coin_pb2 import Coin

# Denomination and amount of transferred tokens
DENOM = "stake"
Expand All @@ -41,7 +42,7 @@
client = SigningCosmWasmClient(FROM_PK, channel, CHAIN_ID)

# Address of recipient account
TO_ADDRESS = "fetch128r83uvcxns82535d3da5wmfvhc2e5mut922dw"
TO_ADDRESS = Address("fetch128r83uvcxns82535d3da5wmfvhc2e5mut922dw")

# Print balance before transfer
print("Before transaction")
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cosm/auth/interface.py → pycosm/auth/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from abc import ABC, abstractmethod

from cosmos.auth.v1beta1.query_pb2 import (
from pycosm.protos.cosmos.auth.v1beta1.query_pb2 import (
QueryAccountRequest,
QueryAccountResponse,
QueryParamsRequest,
Expand Down
6 changes: 3 additions & 3 deletions src/cosm/auth/rest_client.py → pycosm/auth/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

from google.protobuf.json_format import Parse

from cosm.auth.interface import Auth
from cosm.common.rest_client import RestClient
from cosmos.auth.v1beta1.query_pb2 import (
from pycosm.auth.interface import Auth
from pycosm.common.rest_client import RestClient
from pycosm.protos.cosmos.auth.v1beta1.query_pb2 import (
QueryAccountRequest,
QueryAccountResponse,
QueryParamsRequest,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cosm/bank/interface.py → pycosm/bank/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from abc import ABC, abstractmethod

from cosmos.bank.v1beta1.query_pb2 import (
from pycosm.protos.cosmos.bank.v1beta1.query_pb2 import (
QueryAllBalancesRequest,
QueryAllBalancesResponse,
QueryBalanceRequest,
Expand Down
6 changes: 3 additions & 3 deletions src/cosm/bank/rest_client.py → pycosm/bank/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

from google.protobuf.json_format import Parse

from cosm.bank.interface import Bank
from cosm.common.rest_client import RestClient
from cosmos.bank.v1beta1.query_pb2 import (
from pycosm.bank.interface import Bank
from pycosm.common.rest_client import RestClient
from pycosm.protos.cosmos.bank.v1beta1.query_pb2 import (
QueryAllBalancesRequest,
QueryAllBalancesResponse,
QueryBalanceRequest,
Expand Down
File renamed without changes.
Loading