diff --git a/fxsdk/client/crosschain.py b/fxsdk/client/crosschain.py index f9cfcff..6c02d48 100644 --- a/fxsdk/client/crosschain.py +++ b/fxsdk/client/crosschain.py @@ -85,3 +85,10 @@ def ibc_transfer(self, tx_builder: TxBuilder, to_address: str, amount: Coin, cha return self.build_tx(tx_builder=tx_builder, msgs=[msg]) else: return self.build_and_broadcast_tx(tx_builder=tx_builder, msgs=[msg], mode=mode) + + def ibc_transfer_mx2mx(self, tx_builder: TxBuilder, amount: Coin, from_channel: str, to_channel: str, + mode: Optional[BroadcastMode] = BROADCAST_MODE_UNSPECIFIED): + address = tx_builder.from_address() + to_address = "{}|transfer/{}:{}".format(address.to_string("fx"), to_channel, address.to_string()) + self.ibc_transfer(tx_builder=tx_builder, to_address=to_address, amount=amount, channel=from_channel, + target=CrossChainTarget.MarginX, mode=mode) diff --git a/tests/test_tx.py b/tests/test_tx.py index 39b0911..19d6aca 100644 --- a/tests/test_tx.py +++ b/tests/test_tx.py @@ -52,6 +52,20 @@ def test_ibc_transfer_mx2eth(self): print(tx_response) self.assertEqual(tx_response.code, 0) + def test_ibc_transfer_mx2mx(self): + grpc_cli = CrossChainClient(grpc_url) + channels = grpc_cli.query_channels() + if len(channels) == 0: + print("no channel found") + return + from_channel = channels[0].channel_id + to_channel = "channel-6" + amount = Coin(denom='FX', amount='100') + tx_response = grpc_cli.ibc_transfer_mx2mx(tx_builder=tx_builder, amount=amount, from_channel=from_channel, + to_channel=to_channel, mode=BROADCAST_MODE_SYNC) + print(tx_response) + self.assertEqual(tx_response.code, 0) + if __name__ == '__main__': unittest.main()