Skip to content

Commit

Permalink
Merge pull request #332 from InjectiveLabs/feat/update_dependencies_c…
Browse files Browse the repository at this point in the history
…hain_v1_13

feat/update_dependencies_chain_v1_13
  • Loading branch information
aarmoa authored Jul 29, 2024
2 parents c8ac1b9 + b2c569c commit 572d3ad
Show file tree
Hide file tree
Showing 726 changed files with 42,367 additions and 17,442 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

All notable changes to this project will be documented in this file.

## [1.6.0] - 9999-99-99
## [1.6.0] - 2024-07-30
### Added
- Support for all queries in the chain "tendermint" module
- Support for all queries in the "IBC Transfer" module
- Support for all queries in the "IBC Channel" module
- Support for all queries in the "IBC Client" module
- Support for all queries in the "IBC Connection" module
- Support for all queries and messages in the chain "permissions" module
- Tokens initialization from the official tokens list in https://github.com/InjectiveLabs/injective-lists

### Changed
- Updated all proto definitions based on chain upgrade to v1.13
- Refactored cookies management logic to use all gRPC calls' responses to update the current cookies

## [1.5.4] - 2024-07-03
Expand Down
44 changes: 7 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ gen: gen-client

gen-client: clone-all copy-proto
mkdir -p ./pyinjective/proto
@for dir in $(shell find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do \
python3 -m grpc_tools.protoc \
--proto_path=./proto \
--python_out=./pyinjective/proto \
--grpc_python_out=./pyinjective/proto \
$$(find ./$${dir} -type f -name '*.proto'); \
done
buf generate --template buf.gen.yaml
rm -rf proto
$(call clean_repos)
touch pyinjective/proto/__init__.py
$(MAKE) fix-proto-imports
$(MAKE) fix-generated-proto-imports

PROTO_MODULES := cosmwasm exchange gogoproto cosmos_proto cosmos testpb ibc amino tendermint injective
fix-proto-imports:

fix-generated-proto-imports:
@touch pyinjective/proto/__init__.py
@for module in $(PROTO_MODULES); do \
find ./pyinjective/proto -type f -name "*.py" -exec sed -i "" -e "s/from $${module}/from pyinjective.proto.$${module}/g" {} \; ; \
done
Expand All @@ -35,39 +30,14 @@ endef
clean-all:
$(call clean_repos)

clone-injective-core:
git clone https://github.com/InjectiveLabs/injective-core.git -b v1.12.1 --depth 1 --single-branch

clone-injective-indexer:
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.12.79.1 --depth 1 --single-branch

clone-cometbft:
git clone https://github.com/InjectiveLabs/cometbft.git -b v0.37.2-inj --depth 1 --single-branch

clone-wasmd:
git clone https://github.com/InjectiveLabs/wasmd.git -b v0.45.0-inj --depth 1 --single-branch
git clone https://github.com/InjectiveLabs/injective-indexer.git -b v1.13.4 --depth 1 --single-branch

clone-cosmos-sdk:
git clone https://github.com/InjectiveLabs/cosmos-sdk.git -b v0.47.3-inj-9 --depth 1 --single-branch

clone-ibc-go:
git clone https://github.com/InjectiveLabs/ibc-go.git -b v7.2.0-inj --depth 1 --single-branch

clone-all: clone-cosmos-sdk clone-cometbft clone-ibc-go clone-wasmd clone-injective-core clone-injective-indexer
clone-all: clone-injective-indexer

copy-proto:
rm -rf pyinjective/proto
mkdir -p proto/exchange
buf export ./cosmos-sdk --output=third_party
buf export ./ibc-go --exclude-imports --output=third_party
buf export ./cometbft --exclude-imports --output=third_party
buf export ./wasmd --exclude-imports --output=third_party
buf export https://github.com/cosmos/ics23.git --exclude-imports --output=third_party
cp -r injective-core/proto/injective proto/
cp -r third_party/* proto/

rm -rf ./third_party

find ./injective-indexer/api/gen/grpc -type f -name "*.proto" -exec cp {} ./proto/exchange/ \;

tests:
Expand Down
29 changes: 29 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: v2
managed:
enabled: true
plugins:
- remote: buf.build/protocolbuffers/python
out: ./pyinjective/proto/
- remote: buf.build/grpc/python
out: ./pyinjective/proto/
inputs:
- module: buf.build/cosmos/cosmos-proto
- module: buf.build/cosmos/gogo-proto
- module: buf.build/googleapis/googleapis
- module: buf.build/cosmos/ics23
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
tag: v0.50.8-inj-0
- git_repo: https://github.com/InjectiveLabs/ibc-go
tag: v8.3.2-inj-0
- git_repo: https://github.com/InjectiveLabs/wasmd
tag: v0.51.0-inj-0
# - git_repo: https://github.com/InjectiveLabs/wasmd
# branch: v0.51.x-inj
# subdir: proto
- git_repo: https://github.com/InjectiveLabs/injective-core
tag: v1.13.0
subdir: proto
# - git_repo: https://github.com/InjectiveLabs/injective-core
# branch: master
# subdir: proto
- directory: proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import os
from decimal import Decimal

import dotenv

Expand Down Expand Up @@ -40,14 +41,15 @@ async def main() -> None:
oracle_provider="UFC",
oracle_type="Provider",
oracle_scale_factor=6,
maker_fee_rate=0.0005, # 0.05%
taker_fee_rate=0.0010, # 0.10%
maker_fee_rate=Decimal("0.0005"), # 0.05%
taker_fee_rate=Decimal("0.0010"), # 0.10%
expiration_timestamp=1680730982,
settlement_timestamp=1690730982,
admin=address.to_acc_bech32(),
quote_denom="peggy0xdAC17F958D2ee523a2206206994597C13D831ec7",
min_price_tick_size=0.01,
min_quantity_tick_size=0.01,
min_price_tick_size=Decimal("0.01"),
min_quantity_tick_size=Decimal("0.01"),
min_notional=Decimal("1"),
)

# broadcast the transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async def main() -> None:
quote_denom="USDC",
min_price_tick_size=Decimal("0.001"),
min_quantity_tick_size=Decimal("0.01"),
min_notional=Decimal("1"),
)

# broadcast the transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def main() -> None:
maintenance_margin_ratio=Decimal("0.095"),
min_price_tick_size=Decimal("0.001"),
min_quantity_tick_size=Decimal("0.01"),
min_notional=Decimal("1"),
)

# broadcast the transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def main() -> None:
maintenance_margin_ratio=Decimal("0.095"),
min_price_tick_size=Decimal("0.001"),
min_quantity_tick_size=Decimal("0.01"),
min_notional=Decimal("1"),
)

# broadcast the transaction
Expand Down
58 changes: 58 additions & 0 deletions examples/chain_client/permissions/1_MsgCreateNamespace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import asyncio
import os

import dotenv

from pyinjective.composer import Composer as ProtoMsgComposer
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
from pyinjective.core.network import Network
from pyinjective.wallet import PrivateKey


async def main() -> None:
dotenv.load_dotenv()
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")

# select network: local, testnet, mainnet
network = Network.devnet()
composer = ProtoMsgComposer(network=network.string())

message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
network=network,
private_key=private_key_in_hexa,
)

priv_key = PrivateKey.from_hex(private_key_in_hexa)
pub_key = priv_key.to_public_key()
address = pub_key.to_address()

blocked_address = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"
role1 = composer.permissions_role(
role=composer.DEFAULT_PERMISSIONS_EVERYONE_ROLE,
permissions=composer.MINT_ACTION_PERMISSION
| composer.RECEIVE_ACTION_PERMISSION
| composer.BURN_ACTION_PERMISSION,
)
role2 = composer.permissions_role(role="blacklisted", permissions=composer.UNDEFINED_ACTION_PERMISSION)
address_role1 = composer.permissions_address_roles(address=blocked_address, roles=["blacklisted"])

message = composer.msg_create_namespace(
sender=address.to_acc_bech32(),
denom=denom,
wasm_hook="",
mints_paused=False,
sends_paused=False,
burns_paused=False,
role_permissions=[role1, role2],
address_roles=[address_role1],
)

# broadcast the transaction
result = await message_broadcaster.broadcast([message])
print("---Transaction Response---")
print(result)


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
42 changes: 42 additions & 0 deletions examples/chain_client/permissions/2_MsgDeleteNamespace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import asyncio
import os

import dotenv

from pyinjective.composer import Composer as ProtoMsgComposer
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
from pyinjective.core.network import Network
from pyinjective.wallet import PrivateKey


async def main() -> None:
dotenv.load_dotenv()
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")

# select network: local, testnet, mainnet
network = Network.devnet()
composer = ProtoMsgComposer(network=network.string())

message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
network=network,
private_key=private_key_in_hexa,
)

priv_key = PrivateKey.from_hex(private_key_in_hexa)
pub_key = priv_key.to_public_key()
address = pub_key.to_address()

denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"
message = composer.msg_delete_namespace(
sender=address.to_acc_bech32(),
namespace_denom=denom,
)

# broadcast the transaction
result = await message_broadcaster.broadcast([message])
print("---Transaction Response---")
print(result)


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
47 changes: 47 additions & 0 deletions examples/chain_client/permissions/3_MsgUpdateNamespace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import asyncio
import os

import dotenv

from pyinjective.composer import Composer as ProtoMsgComposer
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
from pyinjective.core.network import Network
from pyinjective.wallet import PrivateKey


async def main() -> None:
dotenv.load_dotenv()
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")

# select network: local, testnet, mainnet
network = Network.devnet()
composer = ProtoMsgComposer(network=network.string())

message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
network=network,
private_key=private_key_in_hexa,
)

priv_key = PrivateKey.from_hex(private_key_in_hexa)
pub_key = priv_key.to_public_key()
address = pub_key.to_address()

denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"

message = composer.msg_update_namespace(
sender=address.to_acc_bech32(),
namespace_denom=denom,
wasm_hook="inj19ld6swyldyujcn72j7ugnu9twafhs9wxlyye5m",
mints_paused=True,
sends_paused=True,
burns_paused=True,
)

# broadcast the transaction
result = await message_broadcaster.broadcast([message])
print("---Transaction Response---")
print(result)


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
52 changes: 52 additions & 0 deletions examples/chain_client/permissions/4_MsgUpdateNamespaceRoles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import asyncio
import os

import dotenv

from pyinjective.composer import Composer as ProtoMsgComposer
from pyinjective.core.broadcaster import MsgBroadcasterWithPk
from pyinjective.core.network import Network
from pyinjective.wallet import PrivateKey


async def main() -> None:
dotenv.load_dotenv()
private_key_in_hexa = os.getenv("INJECTIVE_PRIVATE_KEY")

# select network: local, testnet, mainnet
network = Network.devnet()
composer = ProtoMsgComposer(network=network.string())

message_broadcaster = MsgBroadcasterWithPk.new_using_simulation(
network=network,
private_key=private_key_in_hexa,
)

priv_key = PrivateKey.from_hex(private_key_in_hexa)
pub_key = priv_key.to_public_key()
address = pub_key.to_address()

blocked_address = "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r"
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"
role1 = composer.permissions_role(
role=composer.DEFAULT_PERMISSIONS_EVERYONE_ROLE,
permissions=composer.RECEIVE_ACTION_PERMISSION,
)
role2 = composer.permissions_role(role="blacklisted", permissions=composer.UNDEFINED_ACTION_PERMISSION)
address_role1 = composer.permissions_address_roles(address=blocked_address, roles=["blacklisted"])

message = composer.msg_update_namespace_roles(
sender=address.to_acc_bech32(),
namespace_denom=denom,
role_permissions=[role1, role2],
address_roles=[address_role1],
)

# broadcast the transaction
result = await message_broadcaster.broadcast([message])
print("---Transaction Response---")
print(result)


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
Loading

0 comments on commit 572d3ad

Please sign in to comment.