Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.7.0 #347

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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.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
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
Loading