Configure the Polywrap Client
The Polywrap Client accepts a ClientConfig
argument at construction.
While the default Client Config is sufficient for some use cases, you will likely want to customize it. The config you provide to the client will modify and add to the default configuration.
ClientConfig
object#
The The PolywrapClient
can be configured to redirect URIs, use different plugins,
register interface implementations, set environmental variables, and customize URI resolution.
ClientConfigBuilder
#
The You can use the ClientConfigBuilder
class present in @polywrap/client-config-builder-js
to easily build the ClientConfig
object:
Alternatively, default configs will be added to the start of our custom configuration if we just pass a built ClientConfig
to the client without specifying { noDefaults: true }
in the options:
caution
If you are using any kind of custom configuration, it is recommended that you use the ClientConfigBuilder
to build your configuration objects, as the Polywrap client and its configurations are undergoing a major change from version 0.9
to 0.10
. Doing so will ensure that you encounter as few breaking changes as possible - most likely none.
#
RedirectsURI Redirects can be used to redirect queries from one URI to another. This redirection occurs in all queries to the URI, even in cases where one wrapper calls another during its execution.
We can also use the ClientConfigBuilder
to add a URI Redirect to our config:
#
PluginsTo use a plugin wrapper, it has to be registered in the ClientConfig
.
Each item in the array of plugins contains the URI at which the plugin will be invoked and a PluginPackage
.
A PluginPackage
is a factory function the PolywrapClient
uses to create new
instances of the plugin.
Each plugin can have its own configuration.
We can also use the ClientConfigBuilder
to add a Plugin to our config:
#
InterfacesUsers can declare custom implementations for an interface by providing the interface URI and one or more URIs that resolve to implementations.
We can also use the ClientConfigBuilder
to add an Interface implementation to our config:
#
EnvsUsers can provide wrapper-specific environmental variables by providing the wrapper URI and an object with strings as keys. Wrapper developers use the Wrapper Schema to specify which methods accept or require environmental variables.
We can also use the ClientConfigBuilder
to add an Interface implementation to our config:
#
Uri ResolversBy default, the Client can resolve ENS, IPFS, and filesystem URIs. It is possible to use custom URI Resolvers as well. Documentation on how to do so is coming soon!