Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## [1.9.0] - 9999-99-99
### Added
- Added support for all new queries and messages from the new Permissions module

Comment on lines +5 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Expand the changelog entry to cover all changes.

The changelog entry should document all significant changes mentioned in the PR objectives:

  1. Updates to Permissions module queries and messages (already covered)
  2. Unit test revisions for compatibility
  3. Fixes for failing tests due to new gRPC fields

Additionally, consider adding a note that this version depends on the final proto definitions.

Apply this diff to expand the changelog entry:

 ## [1.9.0] - 9999-99-99
 ### Added
 - Added support for all new queries and messages from the new Permissions module
+- Updated unit tests for compatibility with the new Permissions module
+
+### Fixed
+- Fixed failing tests affected by new fields in gRPC queries and messages
+
+### Notes
+- This version requires the final version of proto definitions
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## [1.9.0] - 9999-99-99
### Added
- Added support for all new queries and messages from the new Permissions module
## [1.9.0] - 9999-99-99
### Added
- Added support for all new queries and messages from the new Permissions module
- Updated unit tests for compatibility with the new Permissions module
### Fixed
- Fixed failing tests affected by new fields in gRPC queries and messages
### Notes
- This version requires the final version of proto definitions
🧰 Tools
🪛 LanguageTool

[duplication] ~6-~6: Possible typo: you repeated a word.
Context: ...this file. ## [1.9.0] - 9999-99-99 ### Added - Added support for all new queries and message...

(ENGLISH_WORD_REPEAT_RULE)

## [1.8.2] - 2024-12-13
### Changed
- Updated `protobuf` dependency version to make it more flexible
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ clean-all:
$(call clean_repos)

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

clone-all: clone-injective-indexer

Expand Down
12 changes: 6 additions & 6 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ inputs:
- module: buf.build/googleapis/googleapis
- module: buf.build/cosmos/ics23
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
tag: v0.50.8-inj-0
tag: v0.50.9-inj-2
- 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
tag: v0.53.2-inj-1
# - 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
# tag: v1.13.0
# subdir: proto
- git_repo: https://github.com/InjectiveLabs/injective-core
branch: testnet
subdir: proto
- directory: proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async def main() -> None:
min_price_tick_size=Decimal("0.001"),
min_quantity_tick_size=Decimal("0.01"),
min_notional=Decimal("1"),
base_decimals=18,
quote_decimals=6,
)

# broadcast the transaction
Expand Down
21 changes: 21 additions & 0 deletions examples/chain_client/exchange/query/56_L3DerivativeOrderBook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import asyncio

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


async def main() -> None:
# select network: local, testnet, mainnet
network = Network.testnet()

# initialize grpc client
client = AsyncClient(network)

orderbook = await client.fetch_l3_derivative_orderbook(
market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6",
)
print(orderbook)
Comment on lines +7 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add docstring and improve error handling.

The example would benefit from:

  1. A docstring explaining the purpose and expected output
  2. Documentation for the market ID parameter
  3. Error handling for potential API failures
 async def main() -> None:
+    """
+    Example demonstrating how to fetch Level 3 derivative orderbook data.
+    
+    The market ID represents a specific derivative market on the Injective exchange.
+    Example market ID used here is for BTC/USDT perpetual futures on testnet.
+    """
     # select network: local, testnet, mainnet
     network = Network.testnet()
 
     # initialize grpc client
     client = AsyncClient(network)
 
-    orderbook = await client.fetch_l3_derivative_orderbook(
-        market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6",
-    )
-    print(orderbook)
+    try:
+        orderbook = await client.fetch_l3_derivative_orderbook(
+            market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6",
+        )
+        print(orderbook)
+    except Exception as e:
+        print(f"Error fetching orderbook: {e}")
+    finally:
+        await client.close()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async def main() -> None:
# select network: local, testnet, mainnet
network = Network.testnet()
# initialize grpc client
client = AsyncClient(network)
orderbook = await client.fetch_l3_derivative_orderbook(
market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6",
)
print(orderbook)
async def main() -> None:
"""
Example demonstrating how to fetch Level 3 derivative orderbook data.
The market ID represents a specific derivative market on the Injective exchange.
Example market ID used here is for BTC/USDT perpetual futures on testnet.
"""
# select network: local, testnet, mainnet
network = Network.testnet()
# initialize grpc client
client = AsyncClient(network)
try:
orderbook = await client.fetch_l3_derivative_orderbook(
market_id="0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6",
)
print(orderbook)
except Exception as e:
print(f"Error fetching orderbook: {e}")
finally:
await client.close()



if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
21 changes: 21 additions & 0 deletions examples/chain_client/exchange/query/57_L3SpotOrderBook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import asyncio

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


async def main() -> None:
# select network: local, testnet, mainnet
network = Network.testnet()

# initialize grpc client
client = AsyncClient(network)

orderbook = await client.fetch_l3_spot_orderbook(
market_id="0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe",
)
print(orderbook)


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
31 changes: 31 additions & 0 deletions examples/chain_client/exchange/query/58_MarketBalance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import asyncio

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


async def main() -> None:
"""
Demonstrate fetching market balance using AsyncClient.
"""
# Select network: choose between Network.mainnet(), Network.testnet(), or Network.devnet()
network = Network.testnet()

# Initialize the Async Client
client = AsyncClient(network)

try:
# Example market ID (replace with an actual market ID from the network)
market_id = "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"

# Fetch market balance
market_balance = await client.fetch_market_balance(market_id=market_id)
print("Market Balance:")
print(market_balance)

except Exception as ex:
print(f"Error occurred: {ex}")


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
28 changes: 28 additions & 0 deletions examples/chain_client/exchange/query/59_MarketBalances.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import asyncio

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


async def main() -> None:
"""
Demonstrate fetching market balances using AsyncClient.
"""
# Select network: choose between Network.mainnet(), Network.testnet(), or Network.devnet()
network = Network.testnet()

# Initialize the Async Client
client = AsyncClient(network)

try:
# Fetch market balances
market_balances = await client.fetch_market_balances()
print("Market Balances:")
print(market_balances)

except Exception as ex:
print(f"Error occurred: {ex}")


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
31 changes: 31 additions & 0 deletions examples/chain_client/exchange/query/60_DenomMinNotional.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import asyncio

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


async def main() -> None:
"""
Demonstrate fetching denom min notional using AsyncClient.
"""
# Select network: choose between Network.mainnet(), Network.testnet(), or Network.devnet()
network = Network.testnet()

# Initialize the Async Client
client = AsyncClient(network)

try:
# Example denom
denom = "factory/inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r/inj_test"

# Fetch market balance
min_notional = await client.fetch_denom_min_notional(denom=denom)
print("Min Notional:")
print(min_notional)

except Exception as ex:
print(f"Error occurred: {ex}")


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
28 changes: 28 additions & 0 deletions examples/chain_client/exchange/query/61_DenomMinNotionals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import asyncio

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


async def main() -> None:
"""
Demonstrate fetching denom min notionals using AsyncClient.
"""
# Select network: choose between Network.mainnet(), Network.testnet(), or Network.devnet()
network = Network.testnet()

# Initialize the Async Client
client = AsyncClient(network)

try:
# Fetch market balance
min_notionals = await client.fetch_denom_min_notionals()
print("Min Notionals:")
print(min_notionals)

except Exception as ex:
print(f"Error occurred: {ex}")


if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
68 changes: 55 additions & 13 deletions examples/chain_client/permissions/1_MsgCreateNamespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,68 @@ async def main() -> None:
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,
name="EVERYONE",
role_id=0,
permissions=composer.PERMISSIONS_ACTION["RECEIVE"] | composer.PERMISSIONS_ACTION["SEND"],
)
role2 = composer.permissions_role(
name="admin",
role_id=1,
permissions=composer.PERMISSIONS_ACTION["MODIFY_ROLE_PERMISSIONS"]
| composer.PERMISSIONS_ACTION["MODIFY_ADDRESS_ROLES"],
)
role3 = composer.permissions_role(
name="user",
role_id=2,
permissions=composer.PERMISSIONS_ACTION["MINT"]
| composer.PERMISSIONS_ACTION["RECEIVE"]
| composer.PERMISSIONS_ACTION["BURN"]
| composer.PERMISSIONS_ACTION["SEND"],
)

actor_role1 = composer.permissions_actor_roles(
actor="inj1specificactoraddress",
roles=["admin"],
)
actor_role2 = composer.permissions_actor_roles(
actor="inj1anotheractoraddress",
roles=["user"],
)

role_manager = composer.permissions_role_manager(
manager="inj1manageraddress",
roles=["admin"],
)

policy_status1 = composer.permissions_policy_status(
action=composer.PERMISSIONS_ACTION["MINT"],
is_disabled=False,
is_sealed=False,
)
policy_status2 = composer.permissions_policy_status(
action=composer.PERMISSIONS_ACTION["BURN"],
is_disabled=False,
is_sealed=False,
)

policy_manager_capability = composer.permissions_policy_manager_capability(
manager="inj1policymanageraddress",
action=composer.PERMISSIONS_ACTION["MODIFY_CONTRACT_HOOK"],
can_disable=True,
can_seal=False,
)
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],
contract_hook="",
role_permissions=[role1, role2, role3],
actor_roles=[actor_role1, actor_role2],
role_managers=[role_manager],
policy_statuses=[policy_status1, policy_status2],
policy_manager_capabilities=[policy_manager_capability],
)

# broadcast the transaction
Expand Down
42 changes: 0 additions & 42 deletions examples/chain_client/permissions/2_MsgDeleteNamespace.py

This file was deleted.

Loading
Loading