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 project
Interface projects are declared using a Polywrap Manifest.
To indicate that a project is an abstract interface, set the project language to
Interface projects do not have a module. Only a schema path is declared.
#Defining an interface
Defining 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 interface
As described in Wrapper Schema,
an interface can be imported and then implemented with the
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