From b52714ee1327c62814b33e2f74fe68e9034c011c Mon Sep 17 00:00:00 2001 From: Phuc Ta Date: Thu, 14 Sep 2023 10:49:57 +0700 Subject: [PATCH 1/3] feat: add MsgPrivilegedExecuteContract, MsgInstantiateContract composer --- pyinjective/composer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyinjective/composer.py b/pyinjective/composer.py index 41140aea..c995cda6 100644 --- a/pyinjective/composer.py +++ b/pyinjective/composer.py @@ -900,6 +900,24 @@ def MsgVote( return cosmos_gov_tx_pb.MsgVote( proposal_id=proposal_id, voter=voter, option=option ) + + def MsgPrivilegedExecuteContract(self, sender: str, contract: str, msg: str, **kwargs): + return injective_exchange_tx_pb.MsgPrivilegedExecuteContract( + sender=sender, + contract_address=contract, + data=msg, + funds=kwargs.get('funds') # funds is a list of cosmos_dot_base_dot_v1beta1_dot_coin__pb2.Coin. The coins in the list must be sorted in alphabetical order by denoms. + ) + + def MsgInstantiateContract(self, sender, admin: str, code_id: int, label: str, message: bytes, **kwargs): + return wasm_tx_pb.MsgInstantiateContract( + sender=sender, + admin=admin, + code_id=code_id, + label=label, + msg=message, + funds=kwargs.get('funds'), + ) # data field format: [request-msg-header][raw-byte-msg-response] # you need to figure out this magic prefix number to trim request-msg-header off the data From b5586334ccab2d24480d165415559001c3518d73 Mon Sep 17 00:00:00 2001 From: Phuc Ta Date: Thu, 14 Sep 2023 10:52:02 +0700 Subject: [PATCH 2/3] chore: update command --- pyinjective/composer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyinjective/composer.py b/pyinjective/composer.py index c995cda6..b2253f32 100644 --- a/pyinjective/composer.py +++ b/pyinjective/composer.py @@ -906,7 +906,7 @@ def MsgPrivilegedExecuteContract(self, sender: str, contract: str, msg: str, **k sender=sender, contract_address=contract, data=msg, - funds=kwargs.get('funds') # funds is a list of cosmos_dot_base_dot_v1beta1_dot_coin__pb2.Coin. The coins in the list must be sorted in alphabetical order by denoms. + funds=kwargs.get('funds') # funds is a string of Coin strings, comma separated, e.g 100000inj,20000000000usdt ) def MsgInstantiateContract(self, sender, admin: str, code_id: int, label: str, message: bytes, **kwargs): @@ -916,7 +916,7 @@ def MsgInstantiateContract(self, sender, admin: str, code_id: int, label: str, m code_id=code_id, label=label, msg=message, - funds=kwargs.get('funds'), + funds=kwargs.get('funds'), # funds is a list of cosmos_dot_base_dot_v1beta1_dot_coin__pb2.Coin. The coins in the list must be sorted in alphabetical order by denoms. ) # data field format: [request-msg-header][raw-byte-msg-response] From 0dcc8a601c33356aca9569cef9bd3ce6906b39d9 Mon Sep 17 00:00:00 2001 From: Phuc Ta Date: Thu, 14 Sep 2023 19:37:33 +0700 Subject: [PATCH 3/3] chore: add misisng typehints --- pyinjective/composer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyinjective/composer.py b/pyinjective/composer.py index b2253f32..000efcf6 100644 --- a/pyinjective/composer.py +++ b/pyinjective/composer.py @@ -901,7 +901,7 @@ def MsgVote( proposal_id=proposal_id, voter=voter, option=option ) - def MsgPrivilegedExecuteContract(self, sender: str, contract: str, msg: str, **kwargs): + def MsgPrivilegedExecuteContract(self, sender: str, contract: str, msg: str, **kwargs) -> injective_exchange_tx_pb.MsgPrivilegedExecuteContract: return injective_exchange_tx_pb.MsgPrivilegedExecuteContract( sender=sender, contract_address=contract, @@ -909,7 +909,7 @@ def MsgPrivilegedExecuteContract(self, sender: str, contract: str, msg: str, **k funds=kwargs.get('funds') # funds is a string of Coin strings, comma separated, e.g 100000inj,20000000000usdt ) - def MsgInstantiateContract(self, sender, admin: str, code_id: int, label: str, message: bytes, **kwargs): + def MsgInstantiateContract(self, sender: str, admin: str, code_id: int, label: str, message: bytes, **kwargs) -> wasm_tx_pb.MsgInstantiateContract: return wasm_tx_pb.MsgInstantiateContract( sender=sender, admin=admin,