-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jim/only-keep-resps
- Loading branch information
Showing
3 changed files
with
91 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package types | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
) | ||
|
||
// UnmarshalJSON implements the Unmarshaller interface for FungibleTokenPacketDataV2. | ||
func (ftpd *FungibleTokenPacketDataV2) UnmarshalJSON(bz []byte) error { | ||
// Recursion protection. We cannot unmarshal into FungibleTokenPacketData directly | ||
// else UnmarshalJSON is going to get invoked again, ad infinum. Create an alias | ||
// and unmarshal into that, instead. | ||
type ftpdAlias FungibleTokenPacketDataV2 | ||
|
||
d := json.NewDecoder(bytes.NewReader(bz)) | ||
// Raise errors during decoding if unknown fields are encountered. | ||
d.DisallowUnknownFields() | ||
|
||
var alias ftpdAlias | ||
if err := d.Decode(&alias); err != nil { | ||
return err | ||
} | ||
|
||
*ftpd = FungibleTokenPacketDataV2(alias) | ||
return nil | ||
} | ||
|
||
// UnmarshalJSON implements the Unmarshaller interface for FungibleTokenPacketData. | ||
func (ftpd *FungibleTokenPacketData) UnmarshalJSON(bz []byte) error { | ||
// Recursion protection. We cannot unmarshal into FungibleTokenPacketData directly | ||
// else UnmarshalJSON is going to get invoked again, ad infinum. Create an alias | ||
// and unmarshal into that, instead. | ||
type ftpdAlias FungibleTokenPacketData | ||
|
||
d := json.NewDecoder(bytes.NewReader(bz)) | ||
// Raise errors during decoding if unknown fields are encountered. | ||
d.DisallowUnknownFields() | ||
|
||
var alias ftpdAlias | ||
if err := d.Decode(&alias); err != nil { | ||
return err | ||
} | ||
|
||
*ftpd = FungibleTokenPacketData(alias) | ||
return 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