-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core, apps): 'PacketDataProvider' interface added and implemented (
#4199) * refactor(core/exported): moved packet interfaces to packet.go * feat(core/exported): 'PacketDataProvider' interface added * feat(transfer): PacketDataProvider implemented * feat(ica): implemented PacketDataProvider * style(transfer_test, ica_test): improved test name * docs(core.adr8): updated godocs * style(ica_test): changed a variable name * docs(core.adr8): added missing '.' * imp(transfer): removed type assertion on jsonKey * fix(transfer_test): removed unused test case parameter * docs(transfer): updated godocs * imp(ica): removed type assertion from 'GetCustomPacketData' * imp(transfer_test): improved tests without type assertion * imp(ica_test): improved tests without type assertion * style(transfer_test): changed test case parameter name (cherry picked from commit a0a6526) # Conflicts: # modules/apps/27-interchain-accounts/types/packet.go # modules/apps/transfer/types/packet.go # modules/core/exported/channel.go
- Loading branch information
1 parent
001236b
commit 2d7e023
Showing
6 changed files
with
253 additions
and
0 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package exported | ||
|
||
// PacketI defines the standard interface for IBC packets | ||
type PacketI interface { | ||
GetSequence() uint64 | ||
GetTimeoutHeight() Height | ||
GetTimeoutTimestamp() uint64 | ||
GetSourcePort() string | ||
GetSourceChannel() string | ||
GetDestPort() string | ||
GetDestChannel() string | ||
GetData() []byte | ||
ValidateBasic() error | ||
} | ||
|
||
// Acknowledgement defines the interface used to return acknowledgements in the OnRecvPacket callback. | ||
// The Acknowledgement interface is used by core IBC to ensure partial state changes are not committed | ||
// when packet receives have not properly succeeded (typically resulting in an error acknowledgement being returned). | ||
// The interface also allows core IBC to obtain the acknowledgement bytes whose encoding is determined by each IBC application or middleware. | ||
// Each custom acknowledgement type must implement this interface. | ||
type Acknowledgement interface { | ||
// Success determines if the IBC application state should be persisted when handling `RecvPacket`. | ||
// During `OnRecvPacket` IBC application callback execution, all state changes are held in a cache store and committed if: | ||
// - the acknowledgement.Success() returns true | ||
// - a nil acknowledgement is returned (asynchronous acknowledgements) | ||
// | ||
// Note 1: IBC application callback events are always persisted so long as `RecvPacket` succeeds without error. | ||
// | ||
// Note 2: The return value should account for the success of the underlying IBC application or middleware. Thus the `acknowledgement.Success` is representative of the entire IBC stack's success when receiving a packet. The individual success of each acknowledgement associated with an IBC application or middleware must be determined by obtaining the actual acknowledgement type after decoding the acknowledgement bytes. | ||
// | ||
// See https://github.com/cosmos/ibc-go/blob/v7.0.0/docs/ibc/apps.md for further explanations. | ||
Success() bool | ||
Acknowledgement() []byte | ||
} | ||
|
||
// PacketDataProvider defines an optional interfaces for retrieving custom packet data stored on behalf of another application. | ||
// An existing problem in the IBC middleware design is the inability for a middleware to define its own packet data type and insert packet sender provided information. | ||
// A short term solution was introduced into several application's packet data to utilize a memo field to carry this information on behalf of another application. | ||
// This interfaces standardizes that behaviour. Upon realization of the ability for middleware's to define their own packet data types, this interface will be deprecated and removed with time. | ||
type PacketDataProvider interface { | ||
// GetCustomPacketData returns the packet data held on behalf of another application. | ||
// The name the information is stored under should be provided as the key. | ||
// If no custom packet data exists for the key, nil should be returned. | ||
GetCustomPacketData(key string) interface{} | ||
} |