|
2 | 2 | import json |
3 | 3 | import logging |
4 | 4 |
|
5 | | -from google.protobuf import any_pb2, message, timestamp_pb2 |
| 5 | +from google.protobuf import any_pb2, timestamp_pb2, json_format |
6 | 6 |
|
7 | 7 | from .proto.cosmos.authz.v1beta1 import authz_pb2 as cosmos_authz_pb |
8 | 8 | from .proto.cosmos.authz.v1beta1 import tx_pb2 as cosmos_authz_tx_pb |
|
13 | 13 |
|
14 | 14 | from .proto.injective.exchange.v1beta1 import tx_pb2 as injective_exchange_tx_pb |
15 | 15 | from pyinjective.proto.injective.exchange.v1beta1 import exchange_pb2 as injective_dot_exchange_dot_v1beta1_dot_exchange__pb2 |
16 | | -from .proto.injective.types.v1beta1 import tx_response_pb2 as tx_response_pb |
17 | 16 |
|
18 | 17 | from .proto.injective.auction.v1beta1 import tx_pb2 as injective_auction_tx_pb |
19 | 18 |
|
@@ -969,3 +968,45 @@ def UnpackMsgExecResponse(msg_type, data): |
969 | 968 |
|
970 | 969 | responses = [header_map[msg_type].FromString(result) for result in data.results] |
971 | 970 | return responses |
| 971 | + |
| 972 | + @staticmethod |
| 973 | + def UnpackTransactionMessages(transaction): |
| 974 | + meta_messages = json.loads(transaction.messages.decode()) |
| 975 | + |
| 976 | + header_map = { |
| 977 | + "/injective.exchange.v1beta1.MsgCreateSpotLimitOrder": injective_exchange_tx_pb.MsgCreateSpotLimitOrderResponse, |
| 978 | + "/injective.exchange.v1beta1.MsgCreateSpotMarketOrder": injective_exchange_tx_pb.MsgCreateSpotMarketOrderResponse, |
| 979 | + "/injective.exchange.v1beta1.MsgCreateDerivativeLimitOrder": injective_exchange_tx_pb.MsgCreateDerivativeLimitOrderResponse, |
| 980 | + "/injective.exchange.v1beta1.MsgCreateDerivativeMarketOrder": injective_exchange_tx_pb.MsgCreateDerivativeMarketOrderResponse, |
| 981 | + "/injective.exchange.v1beta1.MsgCancelSpotOrder": injective_exchange_tx_pb.MsgCancelSpotOrderResponse, |
| 982 | + "/injective.exchange.v1beta1.MsgCancelDerivativeOrder": injective_exchange_tx_pb.MsgCancelDerivativeOrderResponse, |
| 983 | + "/injective.exchange.v1beta1.MsgBatchCancelSpotOrders": injective_exchange_tx_pb.MsgBatchCancelSpotOrdersResponse, |
| 984 | + "/injective.exchange.v1beta1.MsgBatchCancelDerivativeOrders": injective_exchange_tx_pb.MsgBatchCancelDerivativeOrdersResponse, |
| 985 | + "/injective.exchange.v1beta1.MsgBatchCreateSpotLimitOrders": injective_exchange_tx_pb.MsgBatchCreateSpotLimitOrders, |
| 986 | + "/injective.exchange.v1beta1.MsgBatchCreateDerivativeLimitOrders": injective_exchange_tx_pb.MsgBatchCreateDerivativeLimitOrders, |
| 987 | + "/injective.exchange.v1beta1.MsgBatchUpdateOrders": injective_exchange_tx_pb.MsgBatchUpdateOrders, |
| 988 | + "/injective.exchange.v1beta1.MsgDeposit": injective_exchange_tx_pb.MsgDeposit, |
| 989 | + "/injective.exchange.v1beta1.MsgWithdraw": injective_exchange_tx_pb.MsgWithdraw, |
| 990 | + "/injective.exchange.v1beta1.MsgSubaccountTransfer": injective_exchange_tx_pb.MsgSubaccountTransfer, |
| 991 | + "/injective.exchange.v1beta1.MsgLiquidatePosition": injective_exchange_tx_pb.MsgLiquidatePosition, |
| 992 | + "/injective.exchange.v1beta1.MsgIncreasePositionMargin": injective_exchange_tx_pb.MsgIncreasePositionMargin, |
| 993 | + "/injective.auction.v1beta1.MsgBid": injective_auction_tx_pb.MsgBid, |
| 994 | + "/injective.exchange.v1beta1.MsgCreateBinaryOptionsLimitOrder": injective_exchange_tx_pb.MsgCreateBinaryOptionsLimitOrder, |
| 995 | + "/injective.exchange.v1beta1.MsgCreateBinaryOptionsMarketOrder": injective_exchange_tx_pb.MsgCreateBinaryOptionsMarketOrder, |
| 996 | + "/injective.exchange.v1beta1.MsgCancelBinaryOptionsOrder": injective_exchange_tx_pb.MsgCancelBinaryOptionsOrder, |
| 997 | + "/injective.exchange.v1beta1.MsgAdminUpdateBinaryOptionsMarket": injective_exchange_tx_pb.MsgAdminUpdateBinaryOptionsMarket, |
| 998 | + "/injective.exchange.v1beta1.MsgInstantBinaryOptionsMarketLaunch": injective_exchange_tx_pb.MsgInstantBinaryOptionsMarketLaunch, |
| 999 | + "/cosmos.bank.v1beta1.MsgSend": cosmos_bank_tx_pb.MsgSend, |
| 1000 | + "/cosmos.authz.v1beta1.MsgGrant": cosmos_authz_tx_pb.MsgGrant, |
| 1001 | + "/cosmos.authz.v1beta1.MsgExec": cosmos_authz_tx_pb.MsgExec, |
| 1002 | + "/cosmos.authz.v1beta1.MsgRevoke": cosmos_authz_tx_pb.MsgRevoke, |
| 1003 | + "/injective.oracle.v1beta1.MsgRelayPriceFeedPrice": injective_oracle_tx_pb.MsgRelayPriceFeedPrice, |
| 1004 | + "/injective.oracle.v1beta1.MsgRelayProviderPrices": injective_oracle_tx_pb.MsgRelayProviderPrices, |
| 1005 | + } |
| 1006 | + |
| 1007 | + msgs = [] |
| 1008 | + for msg in meta_messages: |
| 1009 | + msg_as_string_dict = json.dumps(msg["value"]) |
| 1010 | + msgs.append(json_format.Parse(msg_as_string_dict, header_map[msg["type"]]())) |
| 1011 | + |
| 1012 | + return msgs |
0 commit comments