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: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
with:
python-version: '>=3.9 <3.12'
- name: Install poetry
run: python -m pip install poetry
run: python -m pip install "poetry>=2.4,<3"
- name: Cache the virtualenv
id: cache-venv
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock', '**/pyproject.toml', '**/poetry.toml') }}
Comment on lines 20 to +24

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,120p' .github/workflows/pre-commit.yml | cat -n

Repository: InjectiveLabs/sdk-python

Length of output: 1314


🏁 Script executed:

cat -n .github/workflows/pre-commit.yml

Repository: InjectiveLabs/sdk-python

Length of output: 1314


🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/pre-commit.yml')
print(p.exists())
if p.exists():
    print(p.read_text())
PY

Repository: InjectiveLabs/sdk-python

Length of output: 1089


Include the resolved Python version in the .venv cache key. The current key is shared across all versions that satisfy >=3.9 <3.12, so a cache built under one interpreter can be restored under another. Add the resolved setup-python version to the key, or pin the workflow to an exact version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pre-commit.yml around lines 20 - 24, Update the cache key
in the cache-venv step to include the resolved Python version configured by
setup-python, ensuring virtual-environment caches are separated by interpreter
version while preserving the existing OS and dependency-file hash components.


- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Python
uses: actions/setup-python@v5
- name: Install poetry
run: python -m pip install poetry
run: python -m pip install "poetry>=2.4,<3"
Comment on lines 14 to +17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== release workflow excerpt ==="
sed -n '1,80p' .github/workflows/release.yml

echo
echo "=== python version declarations ==="
rg -n --hidden --glob '!**/.git/**' -e 'python-version|requires-python|tool\.poetry\.dependencies|Programming Language :: Python ::' pyproject.toml poetry.lock .github/workflows README* .python-version .tool-versions setup.cfg setup.py 2>/dev/null || true

echo
echo "=== candidate config files ==="
fd -H -a 'pyproject.toml|poetry.lock|.python-version|.tool-versions|setup.cfg|setup.py' .

Repository: InjectiveLabs/sdk-python

Length of output: 5335


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== pyproject.toml excerpt ==="
sed -n '1,120p' pyproject.toml

echo
echo "=== workflow files using setup-python ==="
rg -n "actions/setup-python@|python-version:" .github/workflows

Repository: InjectiveLabs/sdk-python

Length of output: 2904


🌐 Web query:

actions/setup-python v5 default python-version omitted behavior documentation

💡 Result:

In actions/setup-python v5, the python-version input is optional [1][2]. If this input is omitted, the action follows a specific fallback behavior to determine which Python version to use: 1. File-based resolution: The action first attempts to read the version from a.python-version file in the repository root [1][3]. 2. PATH fallback: If no.python-version file exists, the action will use the Python or PyPy version currently available in the PATH [1][4]. Because the default version present in the PATH can vary between different runner images and may change unexpectedly over time, the official documentation strongly recommends that you always explicitly specify a Python version using the python-version or python-version-file inputs to ensure build consistency [1][5].

Citations:


Pin the release Python version. .github/workflows/release.yml:14-17 falls back to the runner PATH here, and there’s no .python-version file in the repo, so release builds can drift with the hosted image. Set python-version explicitly to a supported release interpreter.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yml around lines 14 - 17, Set an explicit
supported interpreter in the “Install Python” setup-python step by adding the
python-version configuration; do not rely on the runner PATH or repository
defaults. Keep the existing Poetry installation step unchanged.

- name: Publish package
env:
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
run: echo "ARCHFLAGS=-arch arm64" >> $GITHUB_ENV

- name: Install poetry
run: python -m pip install poetry
run: python -m pip install "poetry>=2.4,<3"

- name: Cache the virtualenv
id: cache-venv
uses: actions/cache@v4
with:
path: ./.venv
key: ${{ runner.os }}-${{ matrix.python }}-venv-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-${{ matrix.python }}-venv-${{ hashFiles('**/poetry.lock', '**/pyproject.toml', '**/poetry.toml') }}

- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clean-all:
$(call clean_repos)

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

clone-all: clone-injective-indexer

Expand Down
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inputs:
- git_repo: https://github.com/InjectiveLabs/cosmos-sdk
tag: v0.50.14-inj.11
- git_repo: https://github.com/InjectiveLabs/injective-core
tag: v1.20.1
tag: v1.20.3
subdir: proto
# - git_repo: https://github.com/InjectiveLabs/injective-core
# branch: c-655/add_chainlink_data_streams_oracle
Expand Down
152 changes: 76 additions & 76 deletions pyinjective/proto/exchange/injective_derivative_exchange_rpc_pb2.py

Large diffs are not rendered by default.

118 changes: 67 additions & 51 deletions pyinjective/proto/exchange/injective_tc_derivatives_rpc_pb2.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def __init__(self, channel):
Args:
channel: A grpc.Channel.
"""
self.Markets = channel.unary_unary(
'/injective_tc_derivatives_rpc.InjectiveTCDerivativesRPC/Markets',
request_serializer=exchange_dot_injective__tc__derivatives__rpc__pb2.MarketsRequest.SerializeToString,
response_deserializer=exchange_dot_injective__tc__derivatives__rpc__pb2.MarketsResponse.FromString,
_registered_method=True)
self.OrdersHistory = channel.unary_unary(
'/injective_tc_derivatives_rpc.InjectiveTCDerivativesRPC/OrdersHistory',
request_serializer=exchange_dot_injective__tc__derivatives__rpc__pb2.OrdersHistoryRequest.SerializeToString,
Expand Down Expand Up @@ -66,6 +71,13 @@ class InjectiveTCDerivativesRPCServicer(object):
"""InjectiveTCDerivativesRPC defines gRPC API of the TC Derivatives API.
"""

def Markets(self, request, context):
"""Markets gets a list of TC derivative markets
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def OrdersHistory(self, request, context):
"""Get TC order history combining settlement requests with on-chain order data
"""
Expand Down Expand Up @@ -133,6 +145,11 @@ def FundingPayments(self, request, context):

def add_InjectiveTCDerivativesRPCServicer_to_server(servicer, server):
rpc_method_handlers = {
'Markets': grpc.unary_unary_rpc_method_handler(
servicer.Markets,
request_deserializer=exchange_dot_injective__tc__derivatives__rpc__pb2.MarketsRequest.FromString,
response_serializer=exchange_dot_injective__tc__derivatives__rpc__pb2.MarketsResponse.SerializeToString,
),
'OrdersHistory': grpc.unary_unary_rpc_method_handler(
servicer.OrdersHistory,
request_deserializer=exchange_dot_injective__tc__derivatives__rpc__pb2.OrdersHistoryRequest.FromString,
Expand Down Expand Up @@ -190,6 +207,33 @@ class InjectiveTCDerivativesRPC(object):
"""InjectiveTCDerivativesRPC defines gRPC API of the TC Derivatives API.
"""

@staticmethod
def Markets(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/injective_tc_derivatives_rpc.InjectiveTCDerivativesRPC/Markets',
exchange_dot_injective__tc__derivatives__rpc__pb2.MarketsRequest.SerializeToString,
exchange_dot_injective__tc__derivatives__rpc__pb2.MarketsResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)

@staticmethod
def OrdersHistory(request,
target,
Expand Down
130 changes: 66 additions & 64 deletions pyinjective/proto/injective/exchange/v1beta1/exchange_pb2.py

Large diffs are not rendered by default.

226 changes: 114 additions & 112 deletions pyinjective/proto/injective/exchange/v1beta1/tx_pb2.py

Large diffs are not rendered by default.

118 changes: 60 additions & 58 deletions pyinjective/proto/injective/exchange/v2/exchange_pb2.py

Large diffs are not rendered by default.

406 changes: 203 additions & 203 deletions pyinjective/proto/injective/exchange/v2/tx_pb2.py

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions pyinjective/proto/injective/exchange/v2/tx_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ def __init__(self, channel):
request_serializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgAtomicMarketOrderFeeMultiplierSchedule.SerializeToString,
response_deserializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgAtomicMarketOrderFeeMultiplierScheduleResponse.FromString,
_registered_method=True)
self.SetDelegationTransferReceivers = channel.unary_unary(
'/injective.exchange.v2.Msg/SetDelegationTransferReceivers',
request_serializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgSetDelegationTransferReceivers.SerializeToString,
response_deserializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgSetDelegationTransferReceiversResponse.FromString,
_registered_method=True)
self.CancelPostOnlyMode = channel.unary_unary(
'/injective.exchange.v2.Msg/CancelPostOnlyMode',
request_serializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgCancelPostOnlyMode.SerializeToString,
Expand Down Expand Up @@ -680,6 +685,13 @@ def UpdateAtomicMarketOrderFeeMultiplierSchedule(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def SetDelegationTransferReceivers(self, request, context):
"""SetDelegationTransferReceivers adds delegation transfer receivers.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def CancelPostOnlyMode(self, request, context):
"""MsgCancelPostOnlyMode defines a message to turn off the post-only mode
"""
Expand Down Expand Up @@ -980,6 +992,11 @@ def add_MsgServicer_to_server(servicer, server):
request_deserializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgAtomicMarketOrderFeeMultiplierSchedule.FromString,
response_serializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgAtomicMarketOrderFeeMultiplierScheduleResponse.SerializeToString,
),
'SetDelegationTransferReceivers': grpc.unary_unary_rpc_method_handler(
servicer.SetDelegationTransferReceivers,
request_deserializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgSetDelegationTransferReceivers.FromString,
response_serializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgSetDelegationTransferReceiversResponse.SerializeToString,
),
'CancelPostOnlyMode': grpc.unary_unary_rpc_method_handler(
servicer.CancelPostOnlyMode,
request_deserializer=injective_dot_exchange_dot_v2_dot_tx__pb2.MsgCancelPostOnlyMode.FromString,
Expand Down Expand Up @@ -2443,6 +2460,33 @@ def UpdateAtomicMarketOrderFeeMultiplierSchedule(request,
metadata,
_registered_method=True)

@staticmethod
def SetDelegationTransferReceivers(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(
request,
target,
'/injective.exchange.v2.Msg/SetDelegationTransferReceivers',
injective_dot_exchange_dot_v2_dot_tx__pb2.MsgSetDelegationTransferReceivers.SerializeToString,
injective_dot_exchange_dot_v2_dot_tx__pb2.MsgSetDelegationTransferReceiversResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True)

@staticmethod
def CancelPostOnlyMode(request,
target,
Expand Down
46 changes: 24 additions & 22 deletions pyinjective/proto/injective/stream/v1beta1/query_pb2.py

Large diffs are not rendered by default.

62 changes: 32 additions & 30 deletions pyinjective/proto/injective/stream/v2/query_pb2.py

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "injective-py"
version = "1.16.0"
version = "1.16.1"
description = "Injective Python SDK, with Exchange API Client"
authors = ["Injective Labs <contact@injectivelabs.org>"]
license = "Apache-2.0"
Expand All @@ -20,6 +20,9 @@ include = [
{ path = "*.ini" },
]

[tool.poetry.build-constraints]
coincurve = { scikit-build-core = ">=0.9,<0.10" }

[tool.poetry.dependencies]
python = ">=3.10,<3.15"
aiohttp = "^3.9.4" # Version dependency due to https://github.com/InjectiveLabs/sdk-python/security/dependabot/18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ async def test_stream(
"feeRecipientAddress": spot_trade.fee_recipient_address,
"cid": spot_trade.cid,
"tradeId": spot_trade.trade_id,
"notional": spot_trade.notional,
},
],
"derivativeTrades": [
Expand Down Expand Up @@ -670,6 +671,7 @@ async def test_stream_v2(
"feeRecipientAddress": spot_trade.fee_recipient_address,
"cid": spot_trade.cid,
"tradeId": spot_trade.trade_id,
"notional": spot_trade.notional,
},
],
"derivativeTrades": [
Expand Down
4 changes: 4 additions & 0 deletions tests/client/indexer/grpc/test_indexer_grpc_derivative_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,10 @@ async def test_fetch_positions_v2(
"cumulativeFundingEntry": position.cumulative_funding_entry,
"effectiveCumulativeFundingEntry": position.effective_cumulative_funding_entry,
"upnl": position.upnl,
"initialLeverage": position.initial_leverage,
"initialMargin": position.initial_margin,
"initialEntryPrice": position.initial_entry_price,
"initialQuantity": position.initial_quantity,
Comment on lines +768 to +771

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Use non-default values for the new position fields.

Both tests currently assert protobuf defaults, so they do not reliably detect incorrect propagation or serialization.

  • tests/client/indexer/grpc/test_indexer_grpc_derivative_api.py#L768-L771: initialize all four initial_* fields with distinct values.
  • tests/client/indexer/stream_grpc/test_indexer_grpc_derivative_stream.py#L876-L879: initialize the same four fields in the stream fixture.
📍 Affects 2 files
  • tests/client/indexer/grpc/test_indexer_grpc_derivative_api.py#L768-L771 (this comment)
  • tests/client/indexer/stream_grpc/test_indexer_grpc_derivative_stream.py#L876-L879
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/client/indexer/grpc/test_indexer_grpc_derivative_api.py` around lines
768 - 771, Update the position fixtures in
tests/client/indexer/grpc/test_indexer_grpc_derivative_api.py:768-771 and
tests/client/indexer/stream_grpc/test_indexer_grpc_derivative_stream.py:876-879
to assign distinct non-default values to initialLeverage, initialMargin,
initialEntryPrice, and initialQuantity, ensuring both derivative API and stream
tests validate propagation and serialization.

},
],
"paging": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,10 @@ async def test_stream_positions_v2(
"cumulativeFundingEntry": position.cumulative_funding_entry,
"effectiveCumulativeFundingEntry": position.effective_cumulative_funding_entry,
"upnl": position.upnl,
"initialLeverage": position.initial_leverage,
"initialMargin": position.initial_margin,
"initialEntryPrice": position.initial_entry_price,
"initialQuantity": position.initial_quantity,
},
"timestamp": str(timestamp),
"operationType": "",
Expand Down
Loading