Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FungibleTokenPacketData for sendIbcTokens #1413

Closed
Reecepbcups opened this issue Apr 11, 2023 · 8 comments
Closed

Add FungibleTokenPacketData for sendIbcTokens #1413

Reecepbcups opened this issue Apr 11, 2023 · 8 comments
Milestone

Comments

@Reecepbcups
Copy link
Member

Reecepbcups commented Apr 11, 2023

Can we get FungibleTokenPacketData memo so we can create Middleware UIs (packet forward middleware specifically)?
It requires JSON encoded values in this to properly work. This works for the CLI but not on cosmjs

Working CLI example

osmosisd tx ibc-transfer transfer transfer channel-0 cosmos10r39fueph9fq7a6lgswu4zdsg8t3gxlqvvvyvn 2uosmo --from reece --gas=250000 --gas-prices=0.003uosmo --node https://rpc.osmosis.zone:443 --chain-id=osmosis-1 --memo "{ \"forward\": { \"receiver\": \"juno10r39fueph9fq7a6lgswu4zdsg8t3gxlq670lt0\", \"port\": \"transfer\", \"channel\": \"channel-207\" }}"

Even though this is --memo, it's not the 'correct' memo for Keplr / cosmjs

https://github.com/cosmos/ibc-go/blob/v5.1.0/proto/ibc/applications/transfer/v2/packet.proto

@Reecepbcups Reecepbcups changed the title Add FungibleTokenPacketData memo for sendIbcTokens Add FungibleTokenPacketData for sendIbcTokens Apr 11, 2023
@webmaster128
Copy link
Member

Can you provide a dump of the unsigned transaction from the osmosisd tx ibc-transfer transfer transfer ... command? Is this the transaction memo or the MsgTransfer memo? The later is currently not supported but could be.

@Reecepbcups
Copy link
Member Author

Reecepbcups commented Apr 11, 2023

@webmaster128

{"body":{"messages":[{"@type":"/ibc.applications.transfer.v1.MsgTransfer","source_port":"transfer","source_channel":"channel-0","token":{"denom":"uosmo","amount":"2"},"sender":"osmo10r39fueph9fq7a6lgswu4zdsg8t3gxlqyhl56p","receiver":"cosmos10r39fueph9fq7a6lgswu4zdsg8t3gxlqvvvyvn","timeout_height":{"revision_number":"4","revision_height":"14849961"},"timeout_timestamp":"1681250180453486857","memo":"{ \"forward\": { \"receiver\": \"juno10r39fueph9fq7a6lgswu4zdsg8t3gxlq670lt0\", \"port\": \"transfer\", \"channel\": \"channel-207\" }}"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[{"denom":"uosmo","amount":"750"}],"gas_limit":"250000","payer":"","granter":""}},"signatures":[]}

Its for the MsgTransfer memo which is scoped to FungibleTokenPacketData from ibc-go. CLI scopes it to the correct one under the hood it seems

Definitely needed as Packet Forward Middleware & ibc-hooks both will use this packet data for transferring tokens

As you can see here: https://www.mintscan.io/osmosis/txs/06F9B34BFCEAA0A3EAE4ACA5F2074A149E127EFCCF380DFFEC48768E72E76141
a successful transfer will not show it in the memo (note) field in Mintscan

@webmaster128
Copy link
Member

Great, so all you need is that new memo field for MsgTransfer. Since you put your JSON in there, you don't even need FungibleTokenPacketData types.

That's cool because I want to build a re-designed API for sendIbcTokens anyways.

@duguorong009
Copy link

@webmaster128
Can you let me know when I can expect the ibcMsgTransfer with memo functionality?
Is this WIP? or just planned?

@webmaster128
Copy link
Member

You can already use it by creating the message yourself and use signAndBroadcast. This ticket here is a bit of API design challenge as we suddenly have two types of memo in the same method. Not sure how to do this nicely.

@duguorong009
Copy link

duguorong009 commented May 30, 2023

You can already use it by creating the message yourself and use signAndBroadcast. This ticket here is a bit of API design challenge as we suddenly have two types of memo in the same method. Not sure how to do this nicely.

Thanks!

One question, the fact that I can use the ibcMsgTranfer with memo field means that I can use the packet-forward-middleware & ibc-hook functionality with cosmjs.

Right?

@webmaster128
Copy link
Member

webmaster128 commented May 30, 2023

I don't know packet-forward-middleware & ibc-hook but I think yes.


You can do something like the current sendIbcTokens implementation in your app code. More or less this:

    const timeoutTimestampNanoseconds = timeoutTimestamp
      ? Long.fromNumber(timeoutTimestamp).multiply(1_000_000_000)
      : undefined;
    const transferMsg: MsgTransferEncodeObject = {
      typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
      value: MsgTransfer.fromPartial({
        sourcePort: sourcePort,
        sourceChannel: sourceChannel,
        sender: senderAddress,
        receiver: recipientAddress,
        token: transferAmount,
        timeoutHeight: timeoutHeight,
        timeoutTimestamp: timeoutTimestampNanoseconds,
        memo: "" /* your IBC memo goes here */,
      }),
    };

    client.signAndBroadcast(senderAddress, [transferMsg], fee, txLevelMemo);

@webmaster128
Copy link
Member

Please see #1493 for the current state of the MsgTransfer memo field. Closing here since sendIbcTokens won't be changed. Instead it will be fading out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants