Some checks failed
Build SimApp / build (amd64) (push) Waiting to run
Build SimApp / build (arm64) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Build & Push / build (push) Waiting to run
Run Gosec / Gosec (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Checks dependencies and mocks generation / Check go mod tidy (push) Waiting to run
Checks dependencies and mocks generation / Check up to date mocks (push) Waiting to run
System Tests / setup (push) Waiting to run
System Tests / test-system (push) Blocked by required conditions
System Tests / test-system-legacy (push) Blocked by required conditions
Tests / Code Coverage / split-test-files (push) Waiting to run
Tests / Code Coverage / tests (00) (push) Blocked by required conditions
Tests / Code Coverage / tests (01) (push) Blocked by required conditions
Tests / Code Coverage / tests (02) (push) Blocked by required conditions
Tests / Code Coverage / tests (03) (push) Blocked by required conditions
Tests / Code Coverage / test-integration (push) Waiting to run
Tests / Code Coverage / test-e2e (push) Waiting to run
Tests / Code Coverage / repo-analysis (push) Blocked by required conditions
Tests / Code Coverage / test-sim-nondeterminism (push) Waiting to run
Tests / Code Coverage / test-clientv2 (push) Waiting to run
Tests / Code Coverage / test-core (push) Waiting to run
Tests / Code Coverage / test-depinject (push) Waiting to run
Tests / Code Coverage / test-errors (push) Waiting to run
Tests / Code Coverage / test-math (push) Waiting to run
Tests / Code Coverage / test-schema (push) Waiting to run
Tests / Code Coverage / test-collections (push) Waiting to run
Tests / Code Coverage / test-cosmovisor (push) Waiting to run
Tests / Code Coverage / test-confix (push) Waiting to run
Tests / Code Coverage / test-store (push) Waiting to run
Tests / Code Coverage / test-log (push) Waiting to run
Tests / Code Coverage / test-x-tx (push) Waiting to run
Tests / Code Coverage / test-x-nft (push) Waiting to run
Tests / Code Coverage / test-x-circuit (push) Waiting to run
Tests / Code Coverage / test-x-feegrant (push) Waiting to run
Tests / Code Coverage / test-x-evidence (push) Waiting to run
Tests / Code Coverage / test-x-upgrade (push) Waiting to run
Tests / Code Coverage / test-tools-benchmark (push) Waiting to run
Build & Push SDK Proto Builder / build (push) Has been cancelled
131 lines
4.5 KiB
Go
131 lines
4.5 KiB
Go
package codec
|
|
|
|
import (
|
|
"github.com/cosmos/gogoproto/proto"
|
|
)
|
|
|
|
// Deprecated: AminoCodec defines a codec that utilizes Codec for both binary and JSON
|
|
// encoding. Any usage of amino should be done using the LegacyAmino type directly.
|
|
// Usage of amino with the Codec type is not well-supported and may be removed in the future.
|
|
type AminoCodec struct {
|
|
*LegacyAmino
|
|
}
|
|
|
|
var (
|
|
_ BinaryCodec = &AminoCodec{}
|
|
_ JSONCodec = &AminoCodec{}
|
|
)
|
|
|
|
// Deprecated: NewAminoCodec returns a reference to a new AminoCodec.
|
|
// Use NewLegacyAmino instead.
|
|
func NewAminoCodec(codec *LegacyAmino) *AminoCodec {
|
|
return &AminoCodec{LegacyAmino: codec}
|
|
}
|
|
|
|
// Marshal implements BinaryMarshaler.Marshal method.
|
|
func (ac *AminoCodec) Marshal(o proto.Message) ([]byte, error) {
|
|
return ac.LegacyAmino.Marshal(o)
|
|
}
|
|
|
|
// MustMarshal implements BinaryMarshaler.MustMarshal method.
|
|
func (ac *AminoCodec) MustMarshal(o proto.Message) []byte {
|
|
return ac.LegacyAmino.MustMarshal(o)
|
|
}
|
|
|
|
// MarshalLengthPrefixed implements BinaryMarshaler.MarshalLengthPrefixed method.
|
|
func (ac *AminoCodec) MarshalLengthPrefixed(o proto.Message) ([]byte, error) {
|
|
return ac.LegacyAmino.MarshalLengthPrefixed(o)
|
|
}
|
|
|
|
// MustMarshalLengthPrefixed implements BinaryMarshaler.MustMarshalLengthPrefixed method.
|
|
func (ac *AminoCodec) MustMarshalLengthPrefixed(o proto.Message) []byte {
|
|
return ac.LegacyAmino.MustMarshalLengthPrefixed(o)
|
|
}
|
|
|
|
// Unmarshal implements BinaryMarshaler.Unmarshal method.
|
|
func (ac *AminoCodec) Unmarshal(bz []byte, ptr proto.Message) error {
|
|
return ac.LegacyAmino.Unmarshal(bz, ptr)
|
|
}
|
|
|
|
// MustUnmarshal implements BinaryMarshaler.MustUnmarshal method.
|
|
func (ac *AminoCodec) MustUnmarshal(bz []byte, ptr proto.Message) {
|
|
ac.LegacyAmino.MustUnmarshal(bz, ptr)
|
|
}
|
|
|
|
// UnmarshalLengthPrefixed implements BinaryMarshaler.UnmarshalLengthPrefixed method.
|
|
func (ac *AminoCodec) UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error {
|
|
return ac.LegacyAmino.UnmarshalLengthPrefixed(bz, ptr)
|
|
}
|
|
|
|
// MustUnmarshalLengthPrefixed implements BinaryMarshaler.MustUnmarshalLengthPrefixed method.
|
|
func (ac *AminoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr proto.Message) {
|
|
ac.LegacyAmino.MustUnmarshalLengthPrefixed(bz, ptr)
|
|
}
|
|
|
|
// MarshalJSON implements JSONCodec.MarshalJSON method,
|
|
// it marshals to JSON using legacy amino codec.
|
|
func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error) {
|
|
return ac.LegacyAmino.MarshalJSON(o)
|
|
}
|
|
|
|
// MustMarshalJSON implements JSONCodec.MustMarshalJSON method,
|
|
// it executes MarshalJSON except it panics upon failure.
|
|
func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte {
|
|
return ac.LegacyAmino.MustMarshalJSON(o)
|
|
}
|
|
|
|
// UnmarshalJSON implements JSONCodec.UnmarshalJSON method,
|
|
// it unmarshals from JSON using legacy amino codec.
|
|
func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error {
|
|
return ac.LegacyAmino.UnmarshalJSON(bz, ptr)
|
|
}
|
|
|
|
// MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method,
|
|
// it executes UnmarshalJSON except it panics upon failure.
|
|
func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message) {
|
|
ac.LegacyAmino.MustUnmarshalJSON(bz, ptr)
|
|
}
|
|
|
|
// MarshalInterface is a convenience function for amino marshaling interfaces.
|
|
// The `i` must be an interface.
|
|
// NOTE: to marshal a concrete type, you should use Marshal instead
|
|
func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error) {
|
|
if err := assertNotNil(i); err != nil {
|
|
return nil, err
|
|
}
|
|
return ac.LegacyAmino.Marshal(i)
|
|
}
|
|
|
|
// UnmarshalInterface is a convenience function for amino unmarshaling interfaces.
|
|
// `ptr` must be a pointer to an interface.
|
|
// NOTE: to unmarshal a concrete type, you should use Unmarshal instead
|
|
//
|
|
// Example:
|
|
//
|
|
// var x MyInterface
|
|
// err := cdc.UnmarshalInterface(bz, &x)
|
|
func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr any) error {
|
|
return ac.LegacyAmino.Unmarshal(bz, ptr)
|
|
}
|
|
|
|
// MarshalInterfaceJSON is a convenience function for amino marshaling interfaces.
|
|
// The `i` must be an interface.
|
|
// NOTE: to marshal a concrete type, you should use MarshalJSON instead
|
|
func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
|
|
if err := assertNotNil(i); err != nil {
|
|
return nil, err
|
|
}
|
|
return ac.LegacyAmino.MarshalJSON(i)
|
|
}
|
|
|
|
// UnmarshalInterfaceJSON is a convenience function for amino unmarshaling interfaces.
|
|
// `ptr` must be a pointer to an interface.
|
|
// NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
|
|
//
|
|
// Example:
|
|
//
|
|
// var x MyInterface
|
|
// err := cdc.UnmarshalInterfaceJSON(bz, &x)
|
|
func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr any) error {
|
|
return ac.LegacyAmino.UnmarshalJSON(bz, ptr)
|
|
}
|