Define and implement interfaces
A special type of Polywrap project can be used to define an abstract interface without providing a concrete implementation. Like other wrappers, the interface is defined using a Wrapper Schema. Once an interface is written and deployed, other projects can import and implement it.
For example, the URI Resolver interface is used to standardize the interface of URI resolvers. It is implemented by multiple plugin wrappers to help the Polywrap client query different types of URIs.
#
Declaring an interface projectInterface projects are declared using a Polywrap Manifest.
To indicate that a project is an abstract interface, set the project language to interface
.
Interface projects do not have a module. Only a schema path is declared.
#
Defining an interfaceDefining an interface is as simple as writing the Wrapper Schema. Once the schema is complete, you are ready to deploy the interface wrapper.
#
Implementing an interfaceAs described in Wrapper Schema,
an interface can be imported and then implemented with the implements
keyword.
When a module implements
an interface module, it inherits all of its method declarations.
The ENS Resolver plugin implements the URI Resolver interface and inherits its methods.
- ENS Resolver Schema
- URI Resolver Schema