Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0b8fbc7
removed ethereum plugin folder and updated default client config in c…
krisbitney Dec 14, 2022
378c607
replaced usages of ethereum plugin with ethereum wrapper in various p…
krisbitney Dec 15, 2022
3a0709b
changed ens uri used for ethereum wrapper and provider interface
krisbitney Dec 15, 2022
1d76047
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Dec 16, 2022
08fd6ab
moved ens text record resolver ipfs uri to defaultWrappers object for…
krisbitney Dec 19, 2022
9df2cc5
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Dec 19, 2022
a243def
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Dec 30, 2022
c74738e
using ipfs uri instead of ens text record uri for ethereum wrapper
krisbitney Dec 30, 2022
bc0aecb
updated eth wrapper URIs, updated eth provider plugin, moved invokeWi…
krisbitney Dec 30, 2022
b3ebe30
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 4, 2023
7078403
fix merge conflicts
krisbitney Jan 4, 2023
2ec4f68
updated ens wrappers in test-env-js to use ethereum wrapper
krisbitney Jan 4, 2023
da87773
fixed some tests for use with ethereum wrapper and missed merge confl…
krisbitney Jan 4, 2023
53250e1
fixes to default config and client sanity test
krisbitney Jan 5, 2023
cb08ede
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 5, 2023
8ff7a6f
updated ethereum wrapper ipfs uri to new version
krisbitney Jan 5, 2023
2421071
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 6, 2023
ac753f7
updated ganache version in default test env to @latest
krisbitney Jan 6, 2023
6045da6
fixed typo in updated ganache command in docker-compose
krisbitney Jan 6, 2023
ccdd538
correctly providing txHash to awaitTransaction call in ens-recursive-…
krisbitney Jan 6, 2023
eb4c8f9
moved timeout clearing logic in invokeWithTimeout
krisbitney Jan 6, 2023
db2d4d3
updated ens text record resolver ipfs uri to use version that depends…
krisbitney Jan 6, 2023
8f09ca6
updated ens resolver test to throw result error on failure (helps wit…
krisbitney Jan 6, 2023
97ac3d9
adjusted some codegen tests for ethereum wrapper
krisbitney Jan 6, 2023
d1ea738
adjusted docgen test for ethereum wrapper (output is malformed due to…
krisbitney Jan 6, 2023
099c1cf
fixed client sanity test for change in default config bundle
krisbitney Jan 6, 2023
f00bb72
updated ens text record resolver ipfs URI in uri resolution tests; up…
krisbitney Jan 9, 2023
2e817dd
added defaultIpfsProviders to client config in client tests
krisbitney Jan 10, 2023
77b311a
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 11, 2023
4e4d866
update yarn lock
krisbitney Jan 11, 2023
cc74ee1
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 15, 2023
29329ec
fixed version of plugin-js in client package.json
krisbitney Jan 16, 2023
0a0fbff
replaced invokeWithTimeout in ens deployer modules with tested version
krisbitney Jan 16, 2023
d74ee38
added RetryResolver to ens deployers; fixed null pointer exception wh…
krisbitney Jan 16, 2023
90a3c2c
removed redundant items from getTestEnvClientConfig in CLI
krisbitney Jan 17, 2023
272ac51
adjusted config in ens resolver test client
krisbitney Jan 17, 2023
951c547
moved file reader null check from WasmWRapper and WasmPackage to UriR…
krisbitney Jan 17, 2023
de9e973
added RetryResolver to additional test client configs
krisbitney Jan 17, 2023
b88d99a
added retry options to ipfs resolver plugin; removed RetryResolver
krisbitney Jan 18, 2023
87bdeb6
lint
krisbitney Jan 18, 2023
4d114d2
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 18, 2023
3f35dda
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 19, 2023
a0109b4
lint
krisbitney Jan 19, 2023
881776e
fixed issue where deployment would fail when uri was already register…
krisbitney Jan 19, 2023
68fea02
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Jan 19, 2023
7f715de
updated eth provider uri; simplified client config in ens deployer mo…
krisbitney Jan 25, 2023
445c2ba
improved UInt8Array validity check in ipfs resolver plugin
krisbitney Jan 25, 2023
63a8856
added copies of invokeWithTimeout.ts to each of the defult ens deploy…
krisbitney Jan 27, 2023
99aa1a9
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Feb 13, 2023
94681a6
fix merge conflicts
krisbitney Feb 13, 2023
1be734a
added ens wrapper uri and updated ens text record uri
krisbitney Feb 13, 2023
590ac88
partial transition to ens/wraps:ethereum
krisbitney Feb 14, 2023
753d633
updated to all URIS to ens/wraps.eth
krisbitney Feb 15, 2023
ef4c3cf
updated ethereum uris
krisbitney Feb 15, 2023
0b9e0df
added fallback ipfs providers to test configs
krisbitney Feb 15, 2023
4e481eb
added ens text record resolver to config in client tests; updated eth…
krisbitney Feb 15, 2023
0f2d709
fixed uri in app codegen test case 002
krisbitney Feb 15, 2023
04fe7b3
fixed uris some plugin codegen test cases
krisbitney Feb 15, 2023
b8fb20c
increased ipfs retry value
krisbitney Feb 15, 2023
4850e07
updated version of ethereum-provider-js and replaced ethereum/ens ipf…
krisbitney Feb 16, 2023
469e757
replaced old ens text record resolver ipfs uri with updated version i…
krisbitney Feb 16, 2023
d4a80e9
Merge remote-tracking branch 'origin/origin-dev' into ethereum-plugin…
krisbitney Feb 16, 2023
63fb182
update yarn lock
krisbitney Feb 16, 2023
982c1be
updated uri resolution tests
krisbitney Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@polywrap/client-js": "0.10.0-pre.8",
"@polywrap/core-js": "0.10.0-pre.8",
"@polywrap/ens-resolver-plugin-js": "0.10.0-pre.8",
"@polywrap/ethereum-plugin-js": "0.10.0-pre.8",
"ethereum-provider-js": "0.1.7",
"@polywrap/ipfs-plugin-js": "~0.10.0-pre",
"@polywrap/logging-js": "0.10.0-pre.8",
"@polywrap/os-js": "0.10.0-pre.8",
Expand All @@ -58,6 +58,9 @@
"@polywrap/test-env-js": "0.10.0-pre.8",
"@polywrap/wasm-js": "0.10.0-pre.8",
"@polywrap/wrap-manifest-types-js": "0.10.0-pre.8",
"@polywrap/result": "0.10.0-pre.7",
"@polywrap/uri-resolvers-js": "0.10.0-pre.7",
"@polywrap/uri-resolver-extensions-js": "0.10.0-pre.7",
"axios": "0.21.2",
"chalk": "4.1.0",
"chokidar": "3.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parseWrapperEnvsOption } from "../../../lib";
describe("unit tests for option-parsers", () => {
describe("wrapper-envs", () => {
const sampleFileEnvs = {
"ens/ethereum.polywrap.eth": {
"ens/wraps.eth:ethereum@1.0.0": {
connection: {
networkNameOrChainId: "mainnet",
node: "https://mainnet.infura.io/v3/some_api_key",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ens/hello-world.polywrap.eth": {
"foo": "bar"
},
"ens/ethereum.polywrap.eth": {
"ens/wraps.eth:ethereum@1.0.0": {
"connection": {
"node": "https://mainnet.infura.io/v3/some_api_key",
"networkNameOrChainId": "mainnet"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ens/hello-world.polywrap.eth:
foo: bar
ens/ethereum.polywrap.eth:
ens/wraps.eth:ethereum@1.0.0:
connection:
node: https://mainnet.infura.io/v3/some_api_key
networkNameOrChainId: mainnet
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-var-requires */
import { DeployModule } from "../../../deploy";
import { invokeWithTimeout } from "./invokeWithTimeout";

import { Wallet } from "@ethersproject/wallet";
import { JsonRpcProvider } from "@ethersproject/providers";
import { Uri } from "@polywrap/core-js";
import {
ethereumPlugin,
Connections,
Connection,
} from "@polywrap/ethereum-plugin-js";
import { embeddedWrappers } from "@polywrap/test-env-js";
ethereumProviderPlugin,
} from "ethereum-provider-js";
import { PolywrapClient } from "@polywrap/client-js";
import {
defaultIpfsProviders,
defaultPackages,
defaultInterfaces,
defaultWrappers,
} from "@polywrap/client-config-builder-js";

class ENSRecursiveNameRegisterPublisher implements DeployModule {
Expand Down Expand Up @@ -52,34 +52,11 @@ class ENSRecursiveNameRegisterPublisher implements DeployModule {
? new Wallet(config.privateKey).connect(connectionProvider)
: undefined;

const ethereumPluginUri = "wrap://ens/ethereum.polywrap.eth";
const ensWrapperUri = embeddedWrappers.ens;

const client = new PolywrapClient({
envs: [
{
uri: defaultPackages.ipfsResolver,
env: {
provider: defaultIpfsProviders[0],
fallbackProviders: defaultIpfsProviders.slice(1),
retries: { tryResolveUri: 2, getFile: 2 },
},
},
],
redirects: [
{
from: "wrap://ens/uts46.polywrap.eth",
to: embeddedWrappers.uts46,
},
{
from: "wrap://ens/sha3.polywrap.eth",
to: embeddedWrappers.sha3,
},
],
packages: [
{
uri: ethereumPluginUri,
package: ethereumPlugin({
uri: defaultInterfaces.ethereumProvider,
package: ethereumProviderPlugin({
connections: new Connections({
networks: {
[network]: new Connection({
Expand All @@ -96,7 +73,7 @@ class ENSRecursiveNameRegisterPublisher implements DeployModule {

const signerAddress = await client.invoke<string>({
method: "getSignerAddress",
uri: ethereumPluginUri,
uri: defaultWrappers.ethereum,
args: {
connection: {
networkNameOrChainId: network,
Expand All @@ -108,9 +85,11 @@ class ENSRecursiveNameRegisterPublisher implements DeployModule {
throw new Error("Could not get signer");
}

const registerData = await client.invoke<{ hash: string }>({
const registerData = await client.invoke<
{ tx: { hash: string }; didRegister: boolean }[]
>({
method: "registerDomainAndSubdomainsRecursively",
uri: ensWrapperUri,
uri: defaultWrappers.ens,
args: {
domain: ensDomain,
owner: signerAddress.value,
Expand All @@ -131,18 +110,23 @@ class ENSRecursiveNameRegisterPublisher implements DeployModule {
);
}

await client.invoke({
method: "awaitTransaction",
uri: ethereumPluginUri,
args: {
txHash: registerData.value.hash,
confirmations: 1,
timeout: 15000,
connection: {
networkNameOrChainId: network,
// didRegister can be false if the ens domain is already registered, in which case there is no transaction
if (registerData.value[0].didRegister) {
await invokeWithTimeout(
client,
{
method: "awaitTransaction",
uri: Uri.from(defaultWrappers.ethereum),
args: {
txHash: registerData.value[0].tx.hash,
connection: {
networkNameOrChainId: network,
},
},
},
},
});
15000
);
}

return new Uri(`ens/${network}/${ensDomain}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
Invoker,
InvokeResult,
InvokerOptions,
WrapError,
WrapErrorCode,
} from "@polywrap/core-js";
import { ResultErr } from "@polywrap/result";

/**
* Invoke a wrapper; abort the invocation if a timeout expires.
*
* @param client - a Polywrap Invoker (e.g. CoreClient)
* @param options - invocation options
* @param timeout - a timeout period (in ms)
* */
export async function invokeWithTimeout<TResult>(
client: Invoker,
options: InvokerOptions,
timeout: number
): Promise<InvokeResult<TResult>> {
const controller = new AbortController();

const timer = setTimeout(() => {
controller.abort();
}, timeout);

return await new Promise<InvokeResult<TResult>>((resolve, reject) => {
controller.signal.addEventListener("abort", () => {
const wrapError = new WrapError("Timeout has been reached", {
code: WrapErrorCode.WRAPPER_INVOKE_ABORTED,
uri: options.uri.uri,
method: options.method,
args: JSON.stringify(options.args, null, 2),
});
reject(wrapError);
});
client
.invoke<TResult>(options)
.then((result) => resolve(result))
.catch((error) => {
// the client threw an error (this should never happen)
const wrapError = new WrapError(error.message, {
code: WrapErrorCode.WRAPPER_INVOKE_FAIL,
uri: options.uri.uri,
method: options.method,
args: JSON.stringify(options.args, null, 2),
});
resolve(ResultErr(wrapError));
});
})
.catch((error) => {
return ResultErr<WrapError>(error as WrapError);
})
.finally(() => timer && clearTimeout(timer));
}
63 changes: 21 additions & 42 deletions packages/cli/src/lib/defaults/deploy-modules/ens/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-var-requires */
import { DeployModule } from "../../../deploy";
import { invokeWithTimeout } from "./invokeWithTimeout";

import { Wallet } from "@ethersproject/wallet";
import { JsonRpcProvider } from "@ethersproject/providers";
import { Uri } from "@polywrap/core-js";
import {
Connections,
Connection,
ethereumPlugin,
} from "@polywrap/ethereum-plugin-js";
import { embeddedWrappers } from "@polywrap/test-env-js";
ethereumProviderPlugin,
} from "ethereum-provider-js";
import { PolywrapClient } from "@polywrap/client-js";
import {
defaultIpfsProviders,
defaultPackages,
defaultInterfaces,
defaultWrappers,
} from "@polywrap/client-config-builder-js";

const contentHash = require("content-hash");
Expand Down Expand Up @@ -49,34 +49,11 @@ class ENSPublisher implements DeployModule {
? new Wallet(config.privateKey).connect(connectionProvider)
: undefined;

const ethereumPluginUri = "wrap://ens/ethereum.polywrap.eth";
const ensWrapperUri = embeddedWrappers.ens;

const client = new PolywrapClient({
envs: [
{
uri: defaultPackages.ipfsResolver,
env: {
provider: defaultIpfsProviders[0],
fallbackProviders: defaultIpfsProviders.slice(1),
retries: { tryResolveUri: 2, getFile: 2 },
},
},
],
redirects: [
{
from: "wrap://ens/uts46.polywrap.eth",
to: embeddedWrappers.uts46,
},
{
from: "wrap://ens/sha3.polywrap.eth",
to: embeddedWrappers.sha3,
},
],
packages: [
{
uri: ethereumPluginUri,
package: ethereumPlugin({
uri: defaultInterfaces.ethereumProvider,
package: ethereumProviderPlugin({
connections: new Connections({
networks: {
[network]: new Connection({
Expand All @@ -93,7 +70,7 @@ class ENSPublisher implements DeployModule {

const resolver = await client.invoke<string>({
method: "getResolver",
uri: ensWrapperUri,
uri: defaultWrappers.ens,
args: {
registryAddress: config.ensRegistryAddress,
domain: config.domainName,
Expand All @@ -115,7 +92,7 @@ class ENSPublisher implements DeployModule {

const setContenthashData = await client.invoke<{ hash: string }>({
method: "setContentHash",
uri: ensWrapperUri,
uri: defaultWrappers.ens,
args: {
domain: config.domainName,
cid: hash,
Expand All @@ -130,18 +107,20 @@ class ENSPublisher implements DeployModule {
throw new Error(`Could not set contentHash for '${config.domainName}'`);
}

await client.invoke({
method: "awaitTransaction",
uri: ethereumPluginUri,
args: {
txHash: setContenthashData.value.hash,
confirmations: 1,
timeout: 15000,
connection: {
networkNameOrChainId: network,
await invokeWithTimeout(
client,
{
method: "awaitTransaction",
uri: Uri.from(defaultWrappers.ethereum),
args: {
txHash: setContenthashData.value.hash,
connection: {
networkNameOrChainId: network,
},
},
},
});
15000
);

return new Uri(`ens/${network}/${config.domainName}`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
Comment thread
Niraj-Kamdar marked this conversation as resolved.
Invoker,
InvokeResult,
InvokerOptions,
WrapError,
WrapErrorCode,
} from "@polywrap/core-js";
import { ResultErr } from "@polywrap/result";

/**
* Invoke a wrapper; abort the invocation if a timeout expires.
*
* @param client - a Polywrap Invoker (e.g. CoreClient)
* @param options - invocation options
* @param timeout - a timeout period (in ms)
* */
export async function invokeWithTimeout<TResult>(
client: Invoker,
options: InvokerOptions,
timeout: number
): Promise<InvokeResult<TResult>> {
const controller = new AbortController();

const timer = setTimeout(() => {
controller.abort();
}, timeout);

return await new Promise<InvokeResult<TResult>>((resolve, reject) => {
controller.signal.addEventListener("abort", () => {
const wrapError = new WrapError("Timeout has been reached", {
code: WrapErrorCode.WRAPPER_INVOKE_ABORTED,
uri: options.uri.uri,
method: options.method,
args: JSON.stringify(options.args, null, 2),
});
reject(wrapError);
});
client
.invoke<TResult>(options)
.then((result) => resolve(result))
.catch((error) => {
// the client threw an error (this should never happen)
const wrapError = new WrapError(error.message, {
code: WrapErrorCode.WRAPPER_INVOKE_FAIL,
uri: options.uri.uri,
method: options.method,
args: JSON.stringify(options.args, null, 2),
});
resolve(ResultErr(wrapError));
});
})
.catch((error) => {
return ResultErr<WrapError>(error as WrapError);
})
.finally(() => timer && clearTimeout(timer));
}
Loading