-
Notifications
You must be signed in to change notification settings - Fork 657
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
imp: getMultiDenomFungibleTokenPacketData
to be used in packet unmarshalling/conversion
#6226
Merged
crodriguezvega
merged 52 commits into
feat/ics20-v2
from
charly/issue#5796-add-getfungibletokenpacketdatav2-and-replace-occurrences-of-fungibletokenpacketdata-with-it
Apr 29, 2024
Merged
Changes from 48 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
dbe408a
chore: adding proto files for ics20-v2
chatton 845b269
chore: add newline
chatton 69b2643
chore: modify MsgTransfer to accept coins instead of coin
chatton 8f4eaaa
Merge branch 'feat/ics20-v2' into cian/issue#5799-update-msg-transfer
chatton d8bfd45
chore: reverted unintentional comment changes
chatton e32a13d
chore: reverted unintentional comment changes
chatton e1b52c3
chore: adding test for conversion fn
chatton 0e0e478
chore: fix e2e linter
chatton 00e6c10
chore: adding docs
chatton 8b5eb77
chore: addressing PR feedback
chatton 62d76e9
chore: remove duplicate import
chatton 2cc1804
chore: addressing PR feedback
chatton 4b42e80
Merge branch 'cian/issue#5799-update-msg-transfer' into cian/issue#61…
chatton 3da8e01
chore: moved extration logic into internal package
chatton dee5a30
chore: commented out failing test
chatton f7e5792
chore: adding link to issue
chatton bd34b69
Merge branch 'feat/ics20-v2' into cian/issue#6114-add-conversion-func…
chatton 880b24d
chore: remove duplicate import
chatton 8cad136
chore: fix linting errors
chatton 5ebba40
FungibleTokenPacketData interface methods + tests
charleenfei 867746f
linter
charleenfei 24ed388
wip: token validation
charleenfei a666243
Merge branch 'cian/issue#6114-add-conversion-function' into charly/is…
charleenfei a85fa71
update trace identifier validation in Token + tests
charleenfei e10863e
rm Printf
charleenfei 81c4d50
update with pr review
charleenfei 2504c10
add CurrentVersion, EscrowVersion, update tests
charleenfei 3f9027b
pr review
charleenfei c417be5
fix e2e tests
charleenfei 15d949f
Merge branch 'feat/ics20-v2' into cian/issue#6114-add-conversion-func…
charleenfei 555d2f2
pr review
charleenfei 602237d
update e2e test version
charleenfei 3b421b3
linter
charleenfei 365b6a4
update hardcoded transfer channel version from interchaintest
charleenfei ab12fcb
update hardcoded transfer channel version from interchaintest
charleenfei a5cbcac
Merge branch 'charly/add_versions' into charly/msg_transfer
charleenfei 88d0b4f
Merge branch 'feat/ics20-v2' into charly/msg_transfer
charleenfei b6301a6
Merge branch 'cian/issue#6114-add-conversion-function' into charly/ms…
charleenfei a7b5a18
Merge branch 'charly/issue#5795-implement-required-fungibletokenpacke…
charleenfei 390f41f
wip packet unmarshaller
charleenfei f886b8b
Merge branch 'feat/ics20-v2' into charly/issue#5796-add-getfungibleto…
charleenfei 42077f2
wip
charleenfei 9302bed
wip testing
charleenfei c0db0de
update test
charleenfei 6ca22ce
linter
charleenfei c305a87
rm unnecessary version changes
charleenfei bc122a1
rm unnecessary artifacts
charleenfei 00f94ea
update callbacks test
charleenfei 72f670d
update comment
crodriguezvega af8ee7a
pr review
charleenfei 1982ed5
Merge branch 'charly/issue#5796-add-getfungibletokenpacketdatav2-and-…
charleenfei 3a8a670
rename getMultiDenomFungibleTokenPacketData to unmarshalPacketDataByt…
crodriguezvega File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,10 @@ import ( | |
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" | ||
convertinternal "github.com/cosmos/ibc-go/v8/modules/apps/transfer/internal/convert" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" | ||
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
multidenom "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types/v3" | ||
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" | ||
host "github.com/cosmos/ibc-go/v8/modules/core/24-host" | ||
|
@@ -170,6 +172,27 @@ func (IBCModule) OnChanCloseConfirm( | |
return nil | ||
} | ||
|
||
func (IBCModule) getMultiDenomFungibleTokenPacketData(bz []byte) (multidenom.FungibleTokenPacketData, error) { | ||
crodriguezvega marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TODO: remove support for this function parsing v1 packet data | ||
// TODO: explicit check for packet data type against app version | ||
|
||
var datav1 types.FungibleTokenPacketData | ||
if err := json.Unmarshal(bz, &datav1); err == nil { | ||
if len(datav1.Denom) != 0 { | ||
return convertinternal.PacketDataV1ToV3(datav1), nil | ||
} | ||
} | ||
|
||
var data multidenom.FungibleTokenPacketData | ||
if err := json.Unmarshal(bz, &data); err == nil { | ||
if len(data.Tokens) != 0 { | ||
return data, nil | ||
} | ||
} | ||
Comment on lines
+179
to
+191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we end up using protobuf for encoding the packet data in ICS20 v2, would that at least mitigate the problems of the brute force approach? Like if the packet data is protobuf-encoded, the json unmarshalling should fail, right? And also the other way around? |
||
|
||
return multidenom.FungibleTokenPacketData{}, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot unmarshal ICS-20 transfer packet data") | ||
} | ||
|
||
// OnRecvPacket implements the IBCModule interface. A successful acknowledgement | ||
// is returned if the packet data is successfully decoded and the receive application | ||
// logic returns without error. | ||
|
@@ -351,11 +374,11 @@ func (IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, pr | |
// UnmarshalPacketData attempts to unmarshal the provided packet data bytes | ||
// into a FungibleTokenPacketData. This function implements the optional | ||
// PacketDataUnmarshaler interface required for ADR 008 support. | ||
func (IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error) { | ||
var packetData types.FungibleTokenPacketData | ||
if err := json.Unmarshal(bz, &packetData); err != nil { | ||
func (im IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error) { | ||
ftpd, err := im.getMultiDenomFungibleTokenPacketData(bz) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return packetData, nil | ||
return ftpd, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (can be resolved later on when we do a walkthrough as well): I would probably alias the import with a different name (maybe
v3types
as you do in another file?), since ICS20 v2 will not only feature multi denom, but also path forwarding, etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i used multidenom for now, as i wasn't sure if we will change the v3 naming (referring to FungibleTokenDataPacket) for ics20v2