Skip to content

Commit

Permalink
Merge pull request #347 from InjectiveLabs/release/v_1_7_0
Browse files Browse the repository at this point in the history
Release/v1.7.0
  • Loading branch information
aarmoa authored Sep 18, 2024
2 parents 5541211 + 0592ef2 commit ffd2151
Show file tree
Hide file tree
Showing 11 changed files with 3,982 additions and 1,391 deletions.
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.7.0] - 2024-09-18
### Added
- Added OFAC restricted addresses validations

## [1.6.3]
### Fixed
- Updated reference gas cost for messages in the gas limit estimator after chain upgrade v1.13
Expand Down
1,618 changes: 837 additions & 781 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pyinjective/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pyinjective.constant import ADDITIONAL_CHAIN_FORMAT_DECIMALS, INJ_DECIMALS, INJ_DENOM
from pyinjective.core.market import BinaryOptionMarket, DerivativeMarket, SpotMarket
from pyinjective.core.token import Token
from pyinjective.ofac import OfacChecker
from pyinjective.proto.cosmos.authz.v1beta1 import authz_pb2 as cosmos_authz_pb, tx_pb2 as cosmos_authz_tx_pb
from pyinjective.proto.cosmos.bank.v1beta1 import bank_pb2 as bank_pb, tx_pb2 as cosmos_bank_tx_pb
from pyinjective.proto.cosmos.base.v1beta1 import coin_pb2 as base_coin_pb
Expand Down Expand Up @@ -147,6 +148,7 @@ def __init__(
self.derivative_markets = derivative_markets
self.binary_option_markets = binary_option_markets
self.tokens = tokens
self._ofac_checker = OfacChecker()

def Coin(self, amount: int, denom: str):
"""
Expand Down Expand Up @@ -471,6 +473,8 @@ def MsgBid(self, sender: str, bid_amount: float, round: float):

# region Authz module
def MsgGrantGeneric(self, granter: str, grantee: str, msg_type: str, expire_in: int):
if self._ofac_checker.is_blacklisted(granter):
raise Exception(f"Address {granter} is in the OFAC list")
auth = cosmos_authz_pb.GenericAuthorization(msg=msg_type)
any_auth = any_pb2.Any()
any_auth.Pack(auth, type_url_prefix="")
Expand Down Expand Up @@ -2125,6 +2129,9 @@ def MsgGrantTyped(
subaccount_id: str,
**kwargs,
):
if self._ofac_checker.is_blacklisted(granter):
raise Exception(f"Address {granter} is in the OFAC list")

auth = None
if msg_type == "CreateSpotLimitOrderAuthz":
auth = injective_authz_pb.CreateSpotLimitOrderAuthz(
Expand Down
5 changes: 5 additions & 0 deletions pyinjective/core/broadcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pyinjective.constant import GAS_PRICE
from pyinjective.core.gas_limit_estimator import GasLimitEstimator
from pyinjective.core.network import Network
from pyinjective.ofac import OfacChecker


class BroadcasterAccountConfig(ABC):
Expand Down Expand Up @@ -62,6 +63,10 @@ def __init__(
self._client = client
self._composer = composer
self._fee_calculator = fee_calculator
self._ofac_checker = OfacChecker()

if self._ofac_checker.is_blacklisted(address=self._account_config.trading_injective_address):
raise Exception(f"Address {self._account_config.trading_injective_address} is in the OFAC list")

@classmethod
def new_using_simulation(
Expand Down
Loading

0 comments on commit ffd2151

Please sign in to comment.