Apophis uses a fairly non-standard encoding subsystem, built on top of its middleware subsystem.
@apophis-sdk/core
package contains definitions for protobuf, and the @apophis-sdk/cosmos
package contains definitions for Amino, a Cosmos-specific encoding format. Cosmos messages generally
have to support both formats. To do so, the Messages concept was introduced. However, messages are
not a concrete class or interface. Instead, they hook into the encoding middleware.
Following is the definition of the Encoding Middleware:
implements
keyword gives no such assurance over the
actual class.
The ProtoBuf and Amino encodings use the registerDefaultProtobuf
and registerDefaultAmino
methods respectively. The signature of these methods ensures a class is actually compatible. These
methods use the following definitions:
@apophis-sdk/core
package only contains a rudimentary, generic
class with generalized public key types, and the @apophis-sdk/cosmos
package implements their
encodings as follows:
PublicKey
base class. Note that, of course, the
middleware has to be registered with mw.use
(though it is included in DefaultCosmosMiddlewares
).
As you can see, it also defines how these public keys are converted to addresses for specific
networks. A real use case for this is the Injective blockchain which uses a different elliptic
curve for its key pairs in order to be compatible with the EVM, and thus arrives at a different
address format.