Skip to content

Commit ffd2151

Browse files
authored
Merge pull request #347 from InjectiveLabs/release/v_1_7_0
Release/v1.7.0
2 parents 5541211 + 0592ef2 commit ffd2151

File tree

11 files changed

+3982
-1391
lines changed

11 files changed

+3982
-1391
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
## [1.7.0] - 2024-09-18
6+
### Added
7+
- Added OFAC restricted addresses validations
8+
59
## [1.6.3]
610
### Fixed
711
- Updated reference gas cost for messages in the gas limit estimator after chain upgrade v1.13

poetry.lock

Lines changed: 837 additions & 781 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyinjective/composer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pyinjective.constant import ADDITIONAL_CHAIN_FORMAT_DECIMALS, INJ_DECIMALS, INJ_DENOM
1212
from pyinjective.core.market import BinaryOptionMarket, DerivativeMarket, SpotMarket
1313
from pyinjective.core.token import Token
14+
from pyinjective.ofac import OfacChecker
1415
from pyinjective.proto.cosmos.authz.v1beta1 import authz_pb2 as cosmos_authz_pb, tx_pb2 as cosmos_authz_tx_pb
1516
from pyinjective.proto.cosmos.bank.v1beta1 import bank_pb2 as bank_pb, tx_pb2 as cosmos_bank_tx_pb
1617
from pyinjective.proto.cosmos.base.v1beta1 import coin_pb2 as base_coin_pb
@@ -147,6 +148,7 @@ def __init__(
147148
self.derivative_markets = derivative_markets
148149
self.binary_option_markets = binary_option_markets
149150
self.tokens = tokens
151+
self._ofac_checker = OfacChecker()
150152

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

472474
# region Authz module
473475
def MsgGrantGeneric(self, granter: str, grantee: str, msg_type: str, expire_in: int):
476+
if self._ofac_checker.is_blacklisted(granter):
477+
raise Exception(f"Address {granter} is in the OFAC list")
474478
auth = cosmos_authz_pb.GenericAuthorization(msg=msg_type)
475479
any_auth = any_pb2.Any()
476480
any_auth.Pack(auth, type_url_prefix="")
@@ -2125,6 +2129,9 @@ def MsgGrantTyped(
21252129
subaccount_id: str,
21262130
**kwargs,
21272131
):
2132+
if self._ofac_checker.is_blacklisted(granter):
2133+
raise Exception(f"Address {granter} is in the OFAC list")
2134+
21282135
auth = None
21292136
if msg_type == "CreateSpotLimitOrderAuthz":
21302137
auth = injective_authz_pb.CreateSpotLimitOrderAuthz(

pyinjective/core/broadcaster.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pyinjective.constant import GAS_PRICE
1313
from pyinjective.core.gas_limit_estimator import GasLimitEstimator
1414
from pyinjective.core.network import Network
15+
from pyinjective.ofac import OfacChecker
1516

1617

1718
class BroadcasterAccountConfig(ABC):
@@ -62,6 +63,10 @@ def __init__(
6263
self._client = client
6364
self._composer = composer
6465
self._fee_calculator = fee_calculator
66+
self._ofac_checker = OfacChecker()
67+
68+
if self._ofac_checker.is_blacklisted(address=self._account_config.trading_injective_address):
69+
raise Exception(f"Address {self._account_config.trading_injective_address} is in the OFAC list")
6570

6671
@classmethod
6772
def new_using_simulation(

0 commit comments

Comments
 (0)