github.com/cosmos/cosmos-proto@v1.0.0-beta.3/anyutil/doc.go (about)

     1  // Package any is a helper library to be used as a replacement for some of the
     2  // official "google.golang.org/protobuf/types/known/anypb"'s functions which
     3  // prepend the "type.googleapis.com" prefix in type URLs.
     4  //
     5  // In the Cosmos SDK, an Any's TypeURL starts with a `/` character, e.g.
     6  // "/cosmos.bank.v1beta1.MsgSend". However, if we pack this MsgSend into
     7  // an anypb.Any using the offical anypb package's helper functions, we get a
     8  // TypeURL which is "type.googleapis.com/cosmos.bank.v1beta1.MsgSend".
     9  //
    10  // Therefore, the following 3 functions/methods cannot be used within the
    11  // Cosmos context:
    12  // - anypb.New
    13  // - anypb.MarshalFrom
    14  // - anypb.Any#MarshalFrom
    15  // as all of them append the unwanted prefix.
    16  //
    17  // This package exposes the `New` and `MarshalFrom` helper functions, which do
    18  // not prepend any prefix to type URLs.
    19  package anyutil