Skip to content

Commit

Permalink
Merge pull request #337 from InjectiveLabs/dev
Browse files Browse the repository at this point in the history
Release v1.6.0
  • Loading branch information
aarmoa authored Jul 30, 2024
2 parents 6a9c390 + ea5c929 commit 7f39b06
Show file tree
Hide file tree
Showing 673 changed files with 61,535 additions and 16,155 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5

- name: Install poetry
run: python -m pip install poetry
- name: Cache the virtualenv
id: cache-venv
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
- name: Install poetry
run: python -m pip install poetry
- name: Publish package
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,38 @@

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

## [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
### Changed
- Fixed all import statements in pyinjective.proto modules to make them explicit

## [1.4.4] - 2024-07-03
### Changed
- Fixed all import statements in pyinjective.proto modules to make them explicit

## [1.5.3] - 2024-06-12
### Changed
- Changed parameter `key` from the PaginationOption class.
- Fixed an error when using the next page key in PaginationOption, causing incorrect pagination responses.

## [1.4.3] - 2024-06-06
### Changed
- Fixed `protobuf` dependency version to "<5" to for the v1.4 branch, because newer versions require a code refactoring (done in v1.5)
- Fixed `protobuf` dependency version to "<5" for the v1.4 branch because newer versions require a code refactoring (done in v1.5)

## [1.5.2] - 2024-05-10
### Changed
- Updated `protobuf` dependency version to ">=5.26.1"
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sudo dnf install python3-devel autoconf automake gcc gcc-c++ libffi-devel libtoo
**macOS**

```bash
brew install autoconf automake libtool
brew install autoconf automake libtool bufbuild/buf/buf
```

### Quick Start
Expand Down Expand Up @@ -67,7 +67,7 @@ Upgrade `pip` to the latest version, if you see these warnings:

3. Fetch latest denom config
```
poetry run python pyinjective/fetch_metadata.py
poetry run python pyinjective/utils/fetch_metadata.py
```

Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/master/pyinjective/client.py) has been deprecated as of April 18, 2022. If you are using the sync client please make sure to transition to the [async client](https://github.com/InjectiveLabs/sdk-python/blob/master/pyinjective/async_client.py), for more information read [here](https://github.com/InjectiveLabs/sdk-python/issues/101)
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import asyncio

from google.protobuf import symbol_database

from pyinjective.async_client import AsyncClient
from pyinjective.client.model.pagination import PaginationOption
from pyinjective.core.network import Network


async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)

port_id = "transfer"
channel_id = "channel-126"
sequences = [1, 2]
pagination = PaginationOption(skip=2, limit=4)

acknowledgements = await client.fetch_ibc_packet_acknowledgements(
port_id=port_id,
channel_id=channel_id,
packet_commitment_sequences=sequences,
pagination=pagination,
)
print(acknowledgements)


if __name__ == "__main__":
symbol_db = symbol_database.Default()
asyncio.get_event_loop().run_until_complete(main())
25 changes: 25 additions & 0 deletions examples/chain_client/ibc/channel/query/11_UnreceivedPackets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import asyncio

from google.protobuf import symbol_database

from pyinjective.async_client import AsyncClient
from pyinjective.core.network import Network


async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)

port_id = "transfer"
channel_id = "channel-126"
sequences = [1, 2]

packets = await client.fetch_ibc_unreceived_packets(
port_id=port_id, channel_id=channel_id, packet_commitment_sequences=sequences
)
print(packets)


if __name__ == "__main__":
symbol_db = symbol_database.Default()
asyncio.get_event_loop().run_until_complete(main())
25 changes: 25 additions & 0 deletions examples/chain_client/ibc/channel/query/12_UnreceivedAcks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import asyncio

from google.protobuf import symbol_database

from pyinjective.async_client import AsyncClient
from pyinjective.core.network import Network


async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)

port_id = "transfer"
channel_id = "channel-126"

acks = await client.fetch_ibc_unreceived_acks(
port_id=port_id,
channel_id=channel_id,
)
print(acks)


if __name__ == "__main__":
symbol_db = symbol_database.Default()
asyncio.get_event_loop().run_until_complete(main())
25 changes: 25 additions & 0 deletions examples/chain_client/ibc/channel/query/13_NextSequenceReceive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import asyncio

from google.protobuf import symbol_database

from pyinjective.async_client import AsyncClient
from pyinjective.core.network import Network


async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)

port_id = "transfer"
channel_id = "channel-126"

sequence = await client.fetch_next_sequence_receive(
port_id=port_id,
channel_id=channel_id,
)
print(sequence)


if __name__ == "__main__":
symbol_db = symbol_database.Default()
asyncio.get_event_loop().run_until_complete(main())
22 changes: 22 additions & 0 deletions examples/chain_client/ibc/channel/query/1_Channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import asyncio

from google.protobuf import symbol_database

from pyinjective.async_client import AsyncClient
from pyinjective.core.network import Network


async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)

port_id = "transfer"
channel_id = "channel-126"

channel = await client.fetch_ibc_channel(port_id=port_id, channel_id=channel_id)
print(channel)


if __name__ == "__main__":
symbol_db = symbol_database.Default()
asyncio.get_event_loop().run_until_complete(main())
22 changes: 22 additions & 0 deletions examples/chain_client/ibc/channel/query/2_Channels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import asyncio

from google.protobuf import symbol_database

from pyinjective.async_client import AsyncClient
from pyinjective.client.model.pagination import PaginationOption
from pyinjective.core.network import Network


async def main() -> None:
network = Network.testnet()
client = AsyncClient(network)

pagination = PaginationOption(skip=2, limit=4)

channels = await client.fetch_ibc_channels(pagination=pagination)
print(channels)


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

0 comments on commit 7f39b06

Please sign in to comment.