forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: decouple from sdk/codec in amino codec usage (cosmos#20369)
- Loading branch information
1 parent
fbc61d2
commit 493d486
Showing
63 changed files
with
286 additions
and
195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package codec | ||
|
||
import ( | ||
"github.com/cosmos/gogoproto/proto" | ||
|
||
"cosmossdk.io/core/address" | ||
"cosmossdk.io/core/legacy" | ||
"cosmossdk.io/x/tx/signing" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
) | ||
|
||
func ProvideInterfaceRegistry( | ||
addressCodec address.Codec, | ||
validatorAddressCodec address.ValidatorAddressCodec, | ||
customGetSigners []signing.CustomGetSigner, | ||
) (types.InterfaceRegistry, error) { | ||
signingOptions := signing.Options{ | ||
AddressCodec: addressCodec, | ||
ValidatorAddressCodec: validatorAddressCodec, | ||
} | ||
for _, signer := range customGetSigners { | ||
signingOptions.DefineCustomGetSigners(signer.MsgType, signer.Fn) | ||
} | ||
|
||
interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ | ||
ProtoFiles: proto.HybridResolver, | ||
SigningOptions: signingOptions, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := interfaceRegistry.SigningContext().Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return interfaceRegistry, nil | ||
} | ||
|
||
func ProvideLegacyAmino() legacy.Amino { | ||
return NewLegacyAmino() | ||
} | ||
|
||
func ProvideProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec { | ||
return NewProtoCodec(interfaceRegistry) | ||
} |
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,14 @@ | ||
package legacy | ||
|
||
type Amino interface { | ||
// RegisterInterface registers an interface and its concrete type with the Amino codec. | ||
RegisterInterface(interfacePtr any, iopts *InterfaceOptions) | ||
|
||
// RegisterConcrete registers a concrete type with the Amino codec. | ||
RegisterConcrete(cdcType interface{}, name string) | ||
} | ||
|
||
type InterfaceOptions struct { | ||
Priority []string // Disamb priority. | ||
AlwaysDisambiguate bool // If true, include disamb for all types. | ||
} |
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
Oops, something went wrong.