Skip to content

Commit

Permalink
add bank_send to grpc BaseClient
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code committed Oct 9, 2023
1 parent c4fe1e4 commit 619ebd4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fxsdk/client/grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from fxsdk.x.cosmos.auth.v1beta1.query_pb2 import QueryAccountRequest
from fxsdk.x.cosmos.auth.v1beta1.query_pb2_grpc import QueryStub as AuthQuery
from fxsdk.x.cosmos.bank.v1beta1.bank_pb2 import Supply
from fxsdk.x.cosmos.bank.v1beta1.tx_pb2 import MsgSend
from fxsdk.x.cosmos.bank.v1beta1.query_pb2 import QueryBalanceRequest, QueryAllBalancesRequest, QueryTotalSupplyRequest
from fxsdk.x.cosmos.bank.v1beta1.query_pb2_grpc import QueryStub as BankQuery
from fxsdk.x.cosmos.base.abci.v1beta1.abci_pb2 import GasInfo, TxResponse
Expand All @@ -20,7 +21,8 @@
from fxsdk.x.cosmos.staking.v1beta1.query_pb2 import QueryValidatorsRequest
from fxsdk.x.cosmos.staking.v1beta1.query_pb2_grpc import QueryStub as StakingClient
from fxsdk.x.cosmos.staking.v1beta1.staking_pb2 import Validator
from fxsdk.x.cosmos.tx.v1beta1.service_pb2 import BROADCAST_MODE_BLOCK, BroadcastMode, BroadcastTxRequest, SimulateRequest, \
from fxsdk.x.cosmos.tx.v1beta1.service_pb2 import BROADCAST_MODE_BLOCK, BroadcastMode, BroadcastTxRequest, \
SimulateRequest, \
GetTxRequest, GetTxResponse
from fxsdk.x.cosmos.tx.v1beta1.service_pb2_grpc import ServiceStub as TxClient
from fxsdk.x.cosmos.tx.v1beta1.tx_pb2 import Fee, Tx, TxRaw
Expand Down Expand Up @@ -109,6 +111,14 @@ def query_tx(self, tx_hash: str) -> GetTxResponse:

return TxClient(self.channel).GetTx(GetTxRequest(hash=tx_hash))

def bank_send(self, tx_builder: TxBuilder, to: str, amount: [Coin],
mode: BroadcastMode = BROADCAST_MODE_BLOCK) -> TxResponse:

send_msg = MsgSend(from_address=tx_builder.address(), to_address=to, amount=amount)
send_msg_any = Any(type_url='/cosmos.bank.v1beta1.MsgSend', value=send_msg.SerializeToString())
tx = self.build_tx(tx_builder, [send_msg_any])
return self.broadcast_tx(tx, mode)

def build_tx(self, tx_builder: TxBuilder, msg: [Any], account_number: int = -1,
sequence: int = -1, gas_limit: int = 0) -> Tx:

Expand Down

0 comments on commit 619ebd4

Please sign in to comment.