0.9.7 • Published 1 year ago
@polywrap/ens-resolver-plugin-js v0.9.7
@polywrap/ens-resolver-plugin-js
ENS Resolver Plugin allows the Polywrap JS Client to resolve URIs from the Ethereum Name Service.
Usage
import {
initTestEnvironment,
providers,
ensAddresses,
stopTestEnvironment,
buildAndDeployWrapper,
} from "@polywrap/test-env-js";
import { ethereumPlugin, Connections, Connection } from "@polywrap/ethereum-plugin-js";
import { ipfsPlugin } from "@polywrap/ipfs-plugin-js";
import { ensPlugin } from "@polywrap/ens-plugin-js";
// query a wrapper with an ENS path
export async function foo({
// spin up docker containers with Ganache and IPFS.
await initTestEnvironment();
// initialize Ethereum Connections store
const connections: Connections = new Connections({
networks: {
testnet: new Connection({
provider: providers.ethereum,
}),
},
defaultNetwork: "testnet",
});
// initialize the client with eth, ipfs, ens plugins
client = new PolywrapClient({
plugins: [
{
uri: "wrap://ens/ethereum.polywrap.eth",
plugin: ethereumPlugin({ connections }),
},
{
uri: "wrap://ens/ipfs.polywrap.eth",
plugin: ipfsPlugin({
provider: providers.ipfs,
fallbackProviders: defaultIpfsProviders,
}),
},
{
uri: "wrap://ens/ens.polywrap.eth",
plugin: ensPlugin({
addresses: {
testnet: ensAddresses.ensAddress,
},
}),
},
],
});
// get filesystem path
const wrapperAbsPath = `/path/to/simple-storage`;
// deploy a wrapper to IPFS
let { ensDomain } = await buildAndDeployWrapper({
wrapperAbsPath: wrapperAbsPath,
ipfsProvider: providers.ipfs,
ethereumProvider: providers.ethereum,
ensName: "simple-storage.eth",
});
// get ENS URI
const wrapperUriENS = `ens/testnet/${wrapperEnsDomain}`;
// query the wrapper
const schemaENS = await client.getManifest(wrapperUriENS)
// we can also resolve an ENS URI in two steps
// get IPFS URI
const resolveUriResult = await client.resolveUri(wrapperUriEns);
const wrapperUriIpfs = resolveUriResult.uri
// query the wrapper
const schemaIPFS = await resolveUriResult.wrapperIPFS?.getManifest(client);
await stopTestEnvironment();
});
For more usage examples see src/__tests__
.
API
ENS Resolver Plugin conforms to a generic UriResolver interface that provides a tryResolveUri method to the Polywrap client and adds ENS resolution capability to every client method, e.g. getSchema, getManifest, resolveUri.
0.9.7
1 year ago
0.10.0-pre.10
1 year ago
0.9.6
1 year ago
0.9.5
1 year ago
0.10.0-pre.8
1 year ago
0.10.0-pre.7
1 year ago
0.10.0-pre.6
1 year ago
0.10.0-pre.3
1 year ago
0.10.0-pre.4
1 year ago
0.10.0-pre.1
1 year ago
0.10.0-pre.5
1 year ago
0.9.4
2 years ago
0.9.3
2 years ago
0.9.0
2 years ago
0.9.2
2 years ago
0.9.1
2 years ago
0.10.0-pre.0
2 years ago
0.8.0
2 years ago
0.5.0
2 years ago
0.4.1
2 years ago
0.7.0
2 years ago
0.6.0
2 years ago
0.4.0
2 years ago
0.3.0
2 years ago
0.2.0
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.1-prealpha.93
2 years ago
0.0.1-prealpha.92
2 years ago
0.0.1-prealpha.91
2 years ago
0.0.1-prealpha.90
2 years ago