diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 0000000..c470b68
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1 @@
+* @dOrgJelli
diff --git a/.github/workflows/javascript-client.yaml b/.github/workflows/javascript-client.yaml
new file mode 100644
index 0000000..d62f517
--- /dev/null
+++ b/.github/workflows/javascript-client.yaml
@@ -0,0 +1,30 @@
+name: JavaScript-Client
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+jobs:
+ Client-Readiness:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Read .nvmrc
+ run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
+ id: nvm
+ working-directory: ./verify
+
+ - name: Setup Node.js
+ uses: actions/setup-node@master
+ with:
+ node-version: '${{ steps.nvm.outputs.NVMRC }}'
+
+ - name: Install
+ run: ./install.sh
+
+ - name: Run
+ run: ./run.sh js
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5148416
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+stdout
+stderr
+wraps/*
+!wraps/install.sh
+!wraps/public
diff --git a/README.md b/README.md
index 4ff1b2f..a633d5e 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,47 @@
# Client Readiness Checklist
A place to define a "readiness checklist" for all Polywrap clients to adhere to.
-## Checklist (WRAP 0.1)
+## Checklist
-| Feature :heavy_check_mark: | Description :thought_balloon: | Required :question: | Spec :clipboard: |
-|-|-|-|-|
-| URI | Create & sanitize a `wrap://` URI | Yes | [uri.yaml](./feature-specs/uri.yaml) |
-| Resolve URI | Resolve a `wrap://` URI to a wrap or URI | Yes | ... |
-| Load Wrap | Resolve a `wrap://` URI to a wrap | Yes | ... |
-| Invoke | Invoke a wrap's function | Yes | ... |
+| Feature :heavy_check_mark: | Scenario :thought_balloon: | Required :question: | Spec :clipboard: | JS :scroll: |
+|-|-|-|-|-|
+| **`wrap://` URIs** | | | | |
+| | Create & sanitize a `wrap://` URI | Yes | [:mag:](./specs/uri.yaml) | [:heavy_check_mark:](./clients/js/src/features/uri.ts) |
+| **Client Configuration** | | | | |
+| | Add a wrap package | Yes | [:mag:](./specs/config_embed_wrap_package.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_embed_wrap_package.ts) |
+| | Add a plugin package | Yes | [:mag:](./specs/config_plugin_package.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_plugin_package.ts) |
+| | Add a plugin instance | Yes | [:mag:](./specs/config_plugin_instance.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_plugin_instance.ts) |
+| | Add a URI redirect | Yes | [:mag:](./specs/config_uri_redirect.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_uri_redirect.ts) |
+| | Add env variables | Yes | [:mag:](./specs/config_env_variables.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_env_variables.ts) |
+| | Add interface implementations | Yes | [:mag:](./specs/config_interface_implementations.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_interface_implementations.ts) |
+| | Add resolver | Yes | [:mag:](./specs/config_resolver.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_resolver.ts) |
+| | Add resolver ext | Yes | [:mag:](./specs/config_resolver_ext.yaml) | [:heavy_check_mark:](./clients/js/src/features/config_resolver_ext.ts) |
+| **Invocation** | | | | |
+| | Invoke a wrap function
(Wasm Runtime v0.1) | Yes | [:mag:](./specs/invoke_wrap_wasm_v0_1.yaml) | [:heavy_check_mark:](./clients/js/src/features/invoke_wrap_wasm_v0_1.ts) |
+| | Invoke a plugin function | Yes | [:mag:](./specs/invoke_plugin.yaml) | [:heavy_check_mark:](./clients/js/src/features/invoke_plugin.ts) |
+| | Subinvoke: `wrap -> wrap` | Yes | [:mag:](./specs/subinvoke_wrap_wrap.yaml) | [:heavy_check_mark:](./clients/js/src/features/subinvoke_wrap_wrap.ts) |
+| | Subinvoke: `wrap -> plugin` | Yes | [:mag:](./specs/subinvoke_wrap_plugin.yaml) | [:heavy_check_mark:](./clients/js/src/features/subinvoke_wrap_plugin.ts) |
+| | Subinvoke: `plugin -> wrap` | Yes | [:mag:](./specs/subinvoke_plugin_wrap.yaml) | [:heavy_check_mark:](./clients/js/src/features/subinvoke_plugin_wrap.ts) |
+| **`wrap://` Resolution** | | | | |
+| | Resolve a wrap package | Yes | [:mag:](./specs/resolve_package.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_package.ts) |
+| | Resolve a wrap instance | Yes | [:mag:](./specs/resolve_instance.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_instance.ts) |
+| | Resolve a redirect | Yes | [:mag:](./specs/resolve_redirect.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_redirect.ts) |
+| | Resolve `wrap://http/` &
`wrap://https/` | Yes | [:mag:](./specs/resolve_http.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_http.ts) |
+| | Resolve `wrap://file/` &
`wrap://fs/` | Yes | [:mag:](./specs/resolve_file.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_file.ts) |
+| | Resolve `wrap://ipfs/` | Yes | [:mag:](./specs/resolve_ipfs.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_ipfs.ts) |
+| | Resolve `wrap://ens/` contenthash | No | [:mag:](./specs/resolve_ens_contenthash.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_ens_contenthash.ts) |
+| | Resolve `wrap://ens/` text-records | No | [:mag:](./specs/resolve_ens_text_record.yaml) | [:heavy_check_mark:](./clients/js/src/features/resolve_ens_text_record.ts) |
+| **[WRAP Features](https://github.com/polywrap/wrap-test-harness/tree/master/cases)** | | | | |
+| | Wrap `Env` Variables | Yes | [:mag:](./specs/wrap_feature_env_vars.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_feature_env_vars.ts) |
+| | Wrap Interface Invocations | Yes | [:mag:](./specs/wrap_feature_interface_invoke.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_feature_interface_invoke.ts) |
+| **[WRAP ABI Type Support](https://github.com/polywrap/wrap-test-harness/tree/master/cases)** | | | | |
+| | `(U)Int(8\|16\|32)` | Yes | [:mag:](./specs/wrap_type_ints.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_ints.ts) |
+| | `String` | Yes | TODO | TODO |
+| | `Bytes` | Yes | [:mag:](./specs/wrap_type_bytes.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_bytes.ts) |
+| | `Object` | Yes | [:mag:](./specs/wrap_type_object.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_object.ts) |
+| | `Enum` | Yes | [:mag:](./specs/wrap_type_enum.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_enum.ts) |
+| | `BigInt` | Yes | [:mag:](./specs/wrap_type_bigint.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_bigint.ts) |
+| | `BigNumber` | Yes | [:mag:](./specs/wrap_type_bignumber.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_bignumber.ts) |
+| | `JSON` | Yes | [:mag:](./specs/wrap_type_json.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_json.ts) |
+| | `Array` | Yes | TODO | TODO |
+| | `Map` | Yes | [:mag:](./specs/wrap_type_map.yaml) | [:heavy_check_mark:](./clients/js/src/features/wrap_type_map.ts) |
diff --git a/clients/js/.gitignore b/clients/js/.gitignore
new file mode 100644
index 0000000..4d29575
--- /dev/null
+++ b/clients/js/.gitignore
@@ -0,0 +1,23 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
diff --git a/clients/js/.nvmrc b/clients/js/.nvmrc
new file mode 100644
index 0000000..5015706
--- /dev/null
+++ b/clients/js/.nvmrc
@@ -0,0 +1 @@
+v17.9.1
\ No newline at end of file
diff --git a/clients/js/install.sh b/clients/js/install.sh
new file mode 100755
index 0000000..bd5d27b
--- /dev/null
+++ b/clients/js/install.sh
@@ -0,0 +1,2 @@
+nvm install && nvm use
+yarn
\ No newline at end of file
diff --git a/clients/js/package.json b/clients/js/package.json
new file mode 100644
index 0000000..df62c54
--- /dev/null
+++ b/clients/js/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "templates-app-typescript",
+ "description": "Polywrap App TypeScript Template",
+ "private": true,
+ "version": "0.10.1",
+ "scripts": {
+ "start": "ts-node ./src/index.ts"
+ },
+ "dependencies": {
+ "@polywrap/client-js": "0.10.1",
+ "bignumber.js": "9.1.1",
+ "yaml": "2.2.1"
+ },
+ "devDependencies": {
+ "@types/node": "^18.14.6",
+ "ts-node": "10.9.1",
+ "typescript": "4.9.5"
+ }
+}
diff --git a/clients/js/run.sh b/clients/js/run.sh
new file mode 100755
index 0000000..42cf284
--- /dev/null
+++ b/clients/js/run.sh
@@ -0,0 +1 @@
+yarn start -- $1 2> stderr | tee stdout
\ No newline at end of file
diff --git a/clients/js/src/features/config_embed_wrap_package.ts b/clients/js/src/features/config_embed_wrap_package.ts
new file mode 100644
index 0000000..daa4b95
--- /dev/null
+++ b/clients/js/src/features/config_embed_wrap_package.ts
@@ -0,0 +1,61 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { WasmPackage } from "@polywrap/wasm-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ directory: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+
+ const wrapDir = Input.expectRootDir(
+ inputObj.directory,
+ path.join(__dirname, "../../../../")
+ );
+
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ console.log(`Reading wrap.info & wrap.wasm from ${inputObj.directory}`);
+
+ const manifest = fs.readFileSync(
+ path.join(wrapDir, "wrap.info")
+ );
+ const wasmModule = fs.readFileSync(
+ path.join(wrapDir, "wrap.wasm")
+ );
+
+ console.log("Creating WrapPackage from raw wrap.info & wrap.wasm bytes");
+
+ const wrapPackage = WasmPackage.from(
+ manifest,
+ wasmModule
+ );
+
+ console.log("Adding WrapPackage to ClientConfig");
+
+ const config = new ClientConfigBuilder()
+ .addPackage("embed/foo", wrapPackage)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Invoking WrapPackage");
+
+ const result = await client.invoke({
+ uri: "embed/foo",
+ method,
+ args
+ });
+
+ if (result.ok) {
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/config_env_variables.ts b/clients/js/src/features/config_env_variables.ts
new file mode 100644
index 0000000..fe9e853
--- /dev/null
+++ b/clients/js/src/features/config_env_variables.ts
@@ -0,0 +1,33 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ uri: unknown;
+ env: unknown;
+ }>(input);
+ const uri = Input.expectUri(inputObj.uri).uri;
+ const env = Input.expectObject>(
+ inputObj.env
+ );
+
+ console.log("Adding Env to ClientConfig");
+
+ const config = new ClientConfigBuilder()
+ .addEnv(uri, env)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Fetching Env");
+
+ const result = client.getEnvByUri(uri);
+
+ if (result) {
+ for (const key of Object.keys(result)) {
+ console.log(`env.${key} = ${result[key]}`);
+ }
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/config_interface_implementations.ts b/clients/js/src/features/config_interface_implementations.ts
new file mode 100644
index 0000000..a008e77
--- /dev/null
+++ b/clients/js/src/features/config_interface_implementations.ts
@@ -0,0 +1,32 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ interfaceUri: unknown;
+ implementations: unknown;
+ }>(input);
+ const interfaceUri = Input.expectUri(inputObj.interfaceUri).uri;
+ const implementations = Input.expectArray(inputObj.implementations);
+
+ console.log("Adding Interface Implementations to ClientConfig");
+
+ const config = new ClientConfigBuilder()
+ .addInterfaceImplementations(
+ interfaceUri,
+ implementations
+ )
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Getting Implementations");
+
+ const result = await client.getImplementations(interfaceUri);
+
+ if (result.ok && result.value.length > 0) {
+ console.log(`Found ${result.value.length} Implementations`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/config_plugin_instance.ts b/clients/js/src/features/config_plugin_instance.ts
new file mode 100644
index 0000000..cbefe0e
--- /dev/null
+++ b/clients/js/src/features/config_plugin_instance.ts
@@ -0,0 +1,53 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { PluginWrapper, PluginModule } from "@polywrap/plugin-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ uri: unknown;
+ method: unknown;
+ }>(input);
+ const uri = Input.expectUri(inputObj.uri).uri;
+ const method = Input.expectString(inputObj.method);
+
+ console.log("Creating Plugin Instance");
+
+ class Plugin extends PluginModule<{}, {}> {
+ counter: number = 0;
+
+ increment() {
+ ++this.counter;
+ }
+ }
+
+ const plugin = new Plugin({});
+
+ console.log("Adding Plugin Instance to ClientConfig");
+
+ const pluginWrapper = new PluginWrapper(
+ { version: "0.1", type: "plugin", name: "counter", abi: {} },
+ plugin
+ );
+
+ const config = new ClientConfigBuilder()
+ .addWrapper(uri, pluginWrapper)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ for (let i = 0; i < 2; ++i) {
+ console.log("Invoking Plugin Instance");
+
+ const result = await client.invoke({
+ uri,
+ method
+ });
+
+ if (result.ok) {
+ console.log(`counter = ${plugin.counter}`);
+ }
+ }
+
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/config_plugin_package.ts b/clients/js/src/features/config_plugin_package.ts
new file mode 100644
index 0000000..bc4ea03
--- /dev/null
+++ b/clients/js/src/features/config_plugin_package.ts
@@ -0,0 +1,45 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { PluginPackage } from "@polywrap/plugin-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ uri: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const uri = Input.expectUri(inputObj.uri).uri;
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ console.log("Creating PluginPackage");
+
+ const pluginPackage = PluginPackage.from(() => ({
+ add: (args: { a: number, b: number }) => {
+ return args.a + args.b;
+ }
+ }));
+
+ console.log("Adding PluginPackage to ClientConfig");
+
+ const config = new ClientConfigBuilder()
+ .addPackage(uri, pluginPackage)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Invoking PluginPackage");
+
+ const result = await client.invoke({
+ uri,
+ method,
+ args
+ });
+
+ if (result.ok) {
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/config_resolver.ts b/clients/js/src/features/config_resolver.ts
new file mode 100644
index 0000000..09a7f2d
--- /dev/null
+++ b/clients/js/src/features/config_resolver.ts
@@ -0,0 +1,54 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient,
+ IUriResolver,
+ Uri
+} from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ authority: unknown;
+ result: unknown;
+ }>(input);
+ const authority = Input.expectString(inputObj.authority);
+ const result = Input.expectString(inputObj.result);
+
+ console.log("Adding Resolver to ClientConfig");
+
+ const resolver: IUriResolver = {
+ tryResolveUri: async (uri: Uri) => {
+ const response = uri.authority === authority
+ ? Uri.from(result)
+ : uri;
+
+ return {
+ ok: true,
+ value: {
+ type: "uri",
+ uri: response
+ }
+ };
+ }
+ }
+
+ const config = new ClientConfigBuilder()
+ .addResolver(resolver)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving a wrap://${authority} URI`);
+
+ const res = await client.tryResolveUri({
+ uri: Uri.from(`wrap://${authority}/foo`)
+ });
+
+ console.log(res)
+
+ if (res.ok && res.value.type === "uri") {
+ console.log(`Received URI '${res.value.uri}'`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/config_resolver_ext.ts b/clients/js/src/features/config_resolver_ext.ts
new file mode 100644
index 0000000..8e5b87b
--- /dev/null
+++ b/clients/js/src/features/config_resolver_ext.ts
@@ -0,0 +1,66 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient,
+ Uri,
+ ExtendableUriResolver
+} from "@polywrap/client-js";
+import {
+ PluginPackage
+} from "@polywrap/plugin-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ authority: unknown;
+ result: unknown;
+ }>(input);
+ const authority = Input.expectString(inputObj.authority);
+ const result = Input.expectString(inputObj.result);
+
+ console.log("Creating CustomResolverExt Plugin");
+
+ const customResolverExt = {
+ uri: "wrap://plugin/custom-resolver",
+ plugin: PluginPackage.from(() => ({
+ tryResolveUri: async (args: { authority: string }) => {
+
+ if (args.authority === authority) {
+ return {
+ manifest: null,
+ uri: Uri.from(result).uri
+ };
+ }
+
+ return null;
+ }
+ }))
+ };
+
+ console.log("Adding CustomResolverExt & ExtendableUriResolver to ClientConfig");
+
+ const config = new ClientConfigBuilder()
+ .addPackage(
+ customResolverExt.uri,
+ customResolverExt.plugin
+ )
+ .addInterfaceImplementation(
+ ExtendableUriResolver.defaultExtInterfaceUris[0].uri,
+ customResolverExt.uri
+ )
+ .addResolver(new ExtendableUriResolver())
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving a wrap://${authority} URI`);
+
+ const res = await client.tryResolveUri({
+ uri: Uri.from(`wrap://${authority}/foo`)
+ });
+
+ if (res.ok && res.value.type === "uri") {
+ console.log(`Received URI '${res.value.uri}'`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/config_uri_redirect.ts b/clients/js/src/features/config_uri_redirect.ts
new file mode 100644
index 0000000..693e913
--- /dev/null
+++ b/clients/js/src/features/config_uri_redirect.ts
@@ -0,0 +1,29 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ from: unknown;
+ to: unknown;
+ }>(input);
+ const from = Input.expectUri(inputObj.from).uri;
+ const to = Input.expectUri(inputObj.to).uri;
+
+ console.log("Adding URI Redirect to ClientConfig");
+
+ const config = new ClientConfigBuilder()
+ .addRedirect(from, to)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Resolving Redirect");
+
+ const result = await client.tryResolveUri({ uri: from });
+
+ if (result.ok && result.value.type === "uri") {
+ console.log(`Received URI '${result.value.uri}'`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/invoke_plugin.ts b/clients/js/src/features/invoke_plugin.ts
new file mode 100644
index 0000000..b083f3e
--- /dev/null
+++ b/clients/js/src/features/invoke_plugin.ts
@@ -0,0 +1,42 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { PluginPackage } from "@polywrap/plugin-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ uri: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const uri = Input.expectUri(inputObj.uri).uri;
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const pluginPackage = PluginPackage.from(() => ({
+ add: (args: { a: number, b: number }) => {
+ return args.a + args.b;
+ }
+ }));
+
+ const config = new ClientConfigBuilder()
+ .addPackage(uri, pluginPackage)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ const result = await client.invoke({
+ uri,
+ method,
+ args
+ });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/invoke_wrap_wasm_v0_1.ts b/clients/js/src/features/invoke_wrap_wasm_v0_1.ts
new file mode 100644
index 0000000..f5ec729
--- /dev/null
+++ b/clients/js/src/features/invoke_wrap_wasm_v0_1.ts
@@ -0,0 +1,54 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { WasmPackage } from "@polywrap/wasm-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ directory: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const wrapDir = Input.expectRootDir(
+ inputObj.directory,
+ path.join(__dirname, "../../../../")
+ );
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const manifest = fs.readFileSync(
+ path.join(wrapDir, "wrap.info")
+ );
+ const wasmModule = fs.readFileSync(
+ path.join(wrapDir, "wrap.wasm")
+ );
+
+ const wrapPackage = WasmPackage.from(
+ manifest,
+ wasmModule
+ );
+
+ const config = new ClientConfigBuilder()
+ .addPackage("embed/foo", wrapPackage)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ const result = await client.invoke({
+ uri: "embed/foo",
+ method,
+ args
+ });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_ens_contenthash.ts b/clients/js/src/features/resolve_ens_contenthash.ts
new file mode 100644
index 0000000..f2a659b
--- /dev/null
+++ b/clients/js/src/features/resolve_ens_contenthash.ts
@@ -0,0 +1,27 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient
+} from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const uri = Input.expectUri(input);
+
+ console.log(`URI Authority: ${uri.authority}`);
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving: ${uri}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_ens_text_record.ts b/clients/js/src/features/resolve_ens_text_record.ts
new file mode 100644
index 0000000..f2a659b
--- /dev/null
+++ b/clients/js/src/features/resolve_ens_text_record.ts
@@ -0,0 +1,27 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient
+} from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const uri = Input.expectUri(input);
+
+ console.log(`URI Authority: ${uri.authority}`);
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving: ${uri}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_file.ts b/clients/js/src/features/resolve_file.ts
new file mode 100644
index 0000000..f726ba1
--- /dev/null
+++ b/clients/js/src/features/resolve_file.ts
@@ -0,0 +1,36 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient,
+ Uri
+} from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputUri = Input.expectUri(input);
+ const uri = Uri.from(
+ inputUri.authority + "/" +
+ Input.expectRootDir(
+ inputUri.path,
+ path.join(__dirname, "../../../../")
+ )
+ );
+
+ console.log(`URI Authority: ${uri.authority}`);
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving: ${input}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_http.ts b/clients/js/src/features/resolve_http.ts
new file mode 100644
index 0000000..f2a659b
--- /dev/null
+++ b/clients/js/src/features/resolve_http.ts
@@ -0,0 +1,27 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient
+} from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const uri = Input.expectUri(input);
+
+ console.log(`URI Authority: ${uri.authority}`);
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving: ${uri}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_instance.ts b/clients/js/src/features/resolve_instance.ts
new file mode 100644
index 0000000..ebef7c8
--- /dev/null
+++ b/clients/js/src/features/resolve_instance.ts
@@ -0,0 +1,45 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { WasmWrapper } from "@polywrap/wasm-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ directory: unknown;
+ uri: unknown;
+ }>(input);
+ const wrapDir = Input.expectRootDir(
+ inputObj.directory,
+ path.join(__dirname, "../../../../")
+ );
+ const uri = Input.expectUri(inputObj.uri).uri;
+
+ const manifest = fs.readFileSync(
+ path.join(wrapDir, "wrap.info")
+ );
+ const wasmModule = fs.readFileSync(
+ path.join(wrapDir, "wrap.wasm")
+ );
+ const wrapInstance = await WasmWrapper.from(
+ manifest,
+ wasmModule
+ );
+
+ const config = new ClientConfigBuilder()
+ .addWrapper(uri, wrapInstance)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving URI: ${uri}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_ipfs.ts b/clients/js/src/features/resolve_ipfs.ts
new file mode 100644
index 0000000..f2a659b
--- /dev/null
+++ b/clients/js/src/features/resolve_ipfs.ts
@@ -0,0 +1,27 @@
+import { Input } from "../input";
+
+import {
+ ClientConfigBuilder,
+ PolywrapClient
+} from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const uri = Input.expectUri(input);
+
+ console.log(`URI Authority: ${uri.authority}`);
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving: ${uri}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_package.ts b/clients/js/src/features/resolve_package.ts
new file mode 100644
index 0000000..9bf77f2
--- /dev/null
+++ b/clients/js/src/features/resolve_package.ts
@@ -0,0 +1,45 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { WasmPackage } from "@polywrap/wasm-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ directory: unknown;
+ uri: unknown;
+ }>(input);
+ const wrapDir = Input.expectRootDir(
+ inputObj.directory,
+ path.join(__dirname, "../../../../")
+ )
+ const uri = Input.expectUri(inputObj.uri).uri;
+
+ const manifest = fs.readFileSync(
+ path.join(wrapDir, "wrap.info")
+ );
+ const wasmModule = fs.readFileSync(
+ path.join(wrapDir, "wrap.wasm")
+ );
+ const wrapPackage = WasmPackage.from(
+ manifest,
+ wasmModule
+ );
+
+ const config = new ClientConfigBuilder()
+ .addPackage(uri, wrapPackage)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Resolving URI: ${uri}`);
+
+ const result = await client.tryResolveUri({ uri });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value.type}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/resolve_redirect.ts b/clients/js/src/features/resolve_redirect.ts
new file mode 100644
index 0000000..b515cc9
--- /dev/null
+++ b/clients/js/src/features/resolve_redirect.ts
@@ -0,0 +1,27 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ from: unknown;
+ to: unknown;
+ }>(input);
+ const from = Input.expectUri(inputObj.from).uri;
+ const to = Input.expectUri(inputObj.to).uri;
+
+ const config = new ClientConfigBuilder()
+ .addRedirect(from, to)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Resolving Redirect");
+
+ const result = await client.tryResolveUri({ uri: from });
+
+ if (result.ok && result.value.type === "uri") {
+ console.log(`Received URI '${result.value.uri}'`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/subinvoke_plugin_wrap.ts b/clients/js/src/features/subinvoke_plugin_wrap.ts
new file mode 100644
index 0000000..ba74437
--- /dev/null
+++ b/clients/js/src/features/subinvoke_plugin_wrap.ts
@@ -0,0 +1,76 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient, Uri } from "@polywrap/client-js";
+import { WasmPackage } from "@polywrap/wasm-js";
+import { PluginPackage } from "@polywrap/plugin-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ directory: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const wrapDir = Input.expectRootDir(
+ inputObj.directory,
+ path.join(__dirname, "../../../../")
+ );
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const manifest = fs.readFileSync(
+ path.join(wrapDir, "wrap.info")
+ );
+ const wasmModule = fs.readFileSync(
+ path.join(wrapDir, "wrap.wasm")
+ );
+
+ const wrap = {
+ package: WasmPackage.from(manifest, wasmModule),
+ uri: Uri.from("embed/foo")
+ };
+
+ const plugin = {
+ package: PluginPackage.from(() => ({
+ performSubinvoke: async (_, client) => {
+ console.log(`Subinvoking ${method}`);
+ const res = await client.invoke({
+ uri: wrap.uri,
+ method,
+ args
+ });
+ if (res.ok) {
+ console.log(`Received: ${res.value}`);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ })),
+ uri: Uri.from("plugin/bar")
+ };
+
+ const config = new ClientConfigBuilder()
+ .addPackages({
+ [wrap.uri.uri]: wrap.package,
+ [plugin.uri.uri]: plugin.package
+ })
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking Plugin`);
+
+ const result = await client.invoke({
+ uri: plugin.uri,
+ method: "performSubinvoke"
+ });
+
+ if (result.ok && result.value) {
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/subinvoke_wrap_plugin.ts b/clients/js/src/features/subinvoke_wrap_plugin.ts
new file mode 100644
index 0000000..ba91100
--- /dev/null
+++ b/clients/js/src/features/subinvoke_wrap_plugin.ts
@@ -0,0 +1,66 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import { WasmPackage } from "@polywrap/wasm-js";
+import { PluginPackage } from "@polywrap/plugin-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ rootWrap: unknown;
+ subWrapUri: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const subWrapUri = Input.expectUri(inputObj.subWrapUri);
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const rootWrapObj = Input.expectObject<{
+ directory: unknown;
+ uri: unknown;
+ }>(inputObj.rootWrap);
+
+ const rootWrapDirectory = Input.expectRootDir(
+ rootWrapObj.directory,
+ path.join(__dirname, "../../../../")
+ );
+
+ const rootWrapUri = Input.expectUri(rootWrapObj.uri);
+ const rootWrapPackage = WasmPackage.from(
+ fs.readFileSync(path.join(rootWrapDirectory, "wrap.info")),
+ fs.readFileSync(path.join(rootWrapDirectory, "wrap.wasm"))
+ );
+
+ const subWrapPackage = PluginPackage.from(() => ({
+ add: (args: { a: number, b: number }) => {
+ return args.a + args.b;
+ }
+ }));
+
+ const config = new ClientConfigBuilder()
+ .addPackages({
+ [rootWrapUri.uri]: rootWrapPackage,
+ [subWrapUri.uri]: subWrapPackage
+ })
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ const result = await client.invoke({
+ uri: rootWrapUri,
+ method,
+ args
+ });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/subinvoke_wrap_wrap.ts b/clients/js/src/features/subinvoke_wrap_wrap.ts
new file mode 100644
index 0000000..dda95d2
--- /dev/null
+++ b/clients/js/src/features/subinvoke_wrap_wrap.ts
@@ -0,0 +1,78 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient, Uri } from "@polywrap/client-js";
+import { WasmPackage } from "@polywrap/wasm-js";
+
+import path from "path";
+import fs from "fs";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ rootWrap: unknown;
+ subWrap: unknown;
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const verifyWrap = (wrap: unknown, name: string): {
+ directory: string;
+ uri: Uri;
+ } => {
+ const wrapObj = Input.expectObject<{
+ directory: unknown;
+ uri: unknown;
+ }>(wrap);
+
+ const directory = Input.expectRootDir(
+ wrapObj.directory,
+ path.join(__dirname, "../../../../")
+ );
+ const uri = Input.expectUri(wrapObj.uri);
+
+ return {
+ directory,
+ uri
+ };
+ }
+
+ const rootInput = verifyWrap(inputObj.rootWrap, "rootWrap");
+ const subInput = verifyWrap(inputObj.subWrap, "subWrap");
+
+ const loadWasmPackage = (wrapDir: string): WasmPackage =>
+ WasmPackage.from(
+ fs.readFileSync(path.join(wrapDir, "wrap.info")),
+ fs.readFileSync(path.join(wrapDir, "wrap.wasm"))
+ );
+
+ const rootWrapUri = rootInput.uri;
+ const rootWrapPackage = loadWasmPackage(rootInput.directory);
+
+ const subWrapUri = subInput.uri;
+ const subWrapPackage = loadWasmPackage(subInput.directory);
+
+ const config = new ClientConfigBuilder()
+ .addPackages({
+ [rootWrapUri.uri]: rootWrapPackage,
+ [subWrapUri.uri]: subWrapPackage
+ })
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ const result = await client.invoke({
+ uri: rootWrapUri,
+ method,
+ args
+ });
+
+ if (result.ok) {
+ console.log(`Received: ${result.value}`);
+ console.log("Success!");
+ }
+}
diff --git a/clients/js/src/features/uri.ts b/clients/js/src/features/uri.ts
new file mode 100644
index 0000000..4c9e59d
--- /dev/null
+++ b/clients/js/src/features/uri.ts
@@ -0,0 +1,14 @@
+import { Input } from "../input";
+
+import { Uri } from "@polywrap/client-js";
+
+export function runTestCase(input: unknown): void {
+ const str = Input.expectString(input);
+
+ const uri = new Uri(str);
+
+ console.log("WRAP URI successfully created.");
+ console.log(`uri - ${uri}`);
+ console.log(`uri.authority - ${uri.authority}`);
+ console.log(`uri.path - ${uri.path}`);
+}
diff --git a/clients/js/src/features/wrap_feature_env_vars.ts b/clients/js/src/features/wrap_feature_env_vars.ts
new file mode 100644
index 0000000..54deb4a
--- /dev/null
+++ b/clients/js/src/features/wrap_feature_env_vars.ts
@@ -0,0 +1,77 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient, Uri } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ mainEnv: unknown;
+ extEnv: unknown;
+ }>(input);
+
+ const mainEnv = Input.expectObject>(
+ inputObj.mainEnv
+ );
+ const extEnv = Input.expectObject>(
+ inputObj.extEnv
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const externalWrapperPath = path.join(root, "/env-type/00-external/implementations/as");
+ const { uri: externalWrapperUri } = Uri.from(
+ `file/${externalWrapperPath}`
+ );
+
+ const wrapperPath = path.join(root, "/env-type/01-main/implementations/as");
+ const { uri: wrapperUri } = Uri.from(`file/${wrapperPath}`);
+
+ const envs = {
+ [wrapperUri]: mainEnv,
+ [externalWrapperUri]: extEnv,
+ };
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .addEnvs(envs)
+ .addRedirect("ens/external-env.polywrap.eth", externalWrapperUri)
+ .build();
+
+ const client = new PolywrapClient(config);
+
+ console.log("Invoking methodRequireEnv");
+
+ const methodRequireEnvResult = await client.invoke({
+ uri: wrapperUri,
+ method: "methodRequireEnv",
+ args: {
+ arg: "string",
+ },
+ });
+
+ if (!methodRequireEnvResult.ok) throw methodRequireEnvResult.error;
+
+ console.log("Success!");
+
+ console.log("Invoking subinvokeEnvMethod");
+
+ const subinvokeEnvMethodResult = await client.invoke<{
+ local: unknown,
+ external: unknown
+ }>({
+ uri: wrapperUri,
+ method: "subinvokeEnvMethod",
+ args: {
+ arg: "string",
+ },
+ });
+
+ if (!subinvokeEnvMethodResult.ok) throw subinvokeEnvMethodResult.error;
+
+ console.log(
+ "response.local exists:", !!subinvokeEnvMethodResult.value.local
+ );
+ console.log(
+ "response.external exists:", !!subinvokeEnvMethodResult.value.external
+ );
+ console.log("Success!")
+}
diff --git a/clients/js/src/features/wrap_feature_interface_invoke.ts b/clients/js/src/features/wrap_feature_interface_invoke.ts
new file mode 100644
index 0000000..2f8633b
--- /dev/null
+++ b/clients/js/src/features/wrap_feature_interface_invoke.ts
@@ -0,0 +1,35 @@
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(_: unknown): Promise {
+ const root = path.join(__dirname, "../../../../wraps");
+ const interfaceUri = "wrap://ens/interface.eth";
+ const implementationPath = path.join(root, "/interface-invoke/01-implementation/implementations/as");
+ const implementationUri = `fs/${implementationPath}`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .addInterfaceImplementation(interfaceUri, implementationUri);
+
+ const client = new PolywrapClient(config.build());
+
+ const wrapperPath = path.join(root, "/interface-invoke/02-wrapper/implementations/as");
+ const wrapperUri = `fs/${wrapperPath}`;
+
+ console.log("Invoking moduleMethod");
+
+ const result = await client.invoke({
+ uri: wrapperUri,
+ method: "moduleMethod",
+ args: {
+ arg: {
+ uint8: 1,
+ str: "Test String 1",
+ },
+ },
+ });
+
+ if (!result.ok) throw result.error;
+
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_bigint.ts b/clients/js/src/features/wrap_type_bigint.ts
new file mode 100644
index 0000000..58ff640
--- /dev/null
+++ b/clients/js/src/features/wrap_type_bigint.ts
@@ -0,0 +1,36 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ args: unknown;
+ }>(input);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/bigint-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ console.log("Invoking method");
+
+ let response = await client.invoke({
+ uri,
+ method: "method",
+ args: args,
+ });
+
+ if (!response.ok) throw response.error;
+
+ const bigint = BigInt(response.value);
+
+ console.log("Result:", bigint.toString());
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_bignumber.ts b/clients/js/src/features/wrap_type_bignumber.ts
new file mode 100644
index 0000000..06ff5a3
--- /dev/null
+++ b/clients/js/src/features/wrap_type_bignumber.ts
@@ -0,0 +1,37 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import BigNumber from "bignumber.js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ args: unknown;
+ }>(input);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/bignumber-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ console.log("Invoking method");
+
+ let response = await client.invoke({
+ uri,
+ method: "method",
+ args: args,
+ });
+
+ if (!response.ok) throw response.error;
+
+ const bignumber = new BigNumber(response.value);
+
+ console.log("Result:", bignumber.toString());
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_bytes.ts b/clients/js/src/features/wrap_type_bytes.ts
new file mode 100644
index 0000000..5d8d3d4
--- /dev/null
+++ b/clients/js/src/features/wrap_type_bytes.ts
@@ -0,0 +1,36 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/bytes-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ let response = await client.invoke({
+ uri,
+ method,
+ args: args,
+ });
+
+ if (!response.ok) throw response.error;
+
+ console.log("Result:", JSON.stringify(Array.apply([], response.value)));
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_enum.ts b/clients/js/src/features/wrap_type_enum.ts
new file mode 100644
index 0000000..21b7fb9
--- /dev/null
+++ b/clients/js/src/features/wrap_type_enum.ts
@@ -0,0 +1,36 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/enum-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ let response = await client.invoke({
+ uri,
+ method,
+ args: args,
+ });
+
+ if (!response.ok) throw response.error;
+
+ console.log("Result:", response.value);
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_ints.ts b/clients/js/src/features/wrap_type_ints.ts
new file mode 100644
index 0000000..eb6ca1a
--- /dev/null
+++ b/clients/js/src/features/wrap_type_ints.ts
@@ -0,0 +1,36 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/numbers-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ let response = await client.invoke({
+ uri,
+ method,
+ args: args,
+ });
+
+ if (!response.ok) throw response.error;
+
+ console.log("Result:", response.value);
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_json.ts b/clients/js/src/features/wrap_type_json.ts
new file mode 100644
index 0000000..0eedca6
--- /dev/null
+++ b/clients/js/src/features/wrap_type_json.ts
@@ -0,0 +1,36 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ method: unknown;
+ args: unknown;
+ }>(input);
+ const method = Input.expectString(inputObj.method);
+ const args = Input.expectObject>(
+ inputObj.args
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/json-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ console.log(`Invoking ${method}`);
+
+ let response = await client.invoke({
+ uri,
+ method,
+ args: args,
+ });
+
+ if (!response.ok) throw response.error;
+
+ console.log("Result:", response.value);
+ console.log("Success!");
+}
diff --git a/clients/js/src/features/wrap_type_map.ts b/clients/js/src/features/wrap_type_map.ts
new file mode 100644
index 0000000..0fd5eb6
--- /dev/null
+++ b/clients/js/src/features/wrap_type_map.ts
@@ -0,0 +1,47 @@
+import { Input } from "../input";
+
+import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js";
+import path from "path";
+
+export async function runTestCase(input: unknown): Promise {
+ const inputObj = Input.expectObject<{
+ map: unknown;
+ }>(input);
+ const map = Input.expectObject>(
+ inputObj.map
+ );
+
+ const root = path.join(__dirname, "../../../../wraps");
+ const uri = `fs/${root}/map-type/implementations/as`;
+
+ const config = new ClientConfigBuilder()
+ .addDefaults()
+ .build();
+ const client = new PolywrapClient(config);
+
+ const mapClass = new Map();
+
+ for (const entry of Object.entries(map)) {
+ mapClass.set(entry[0], entry[1] as number);
+ }
+
+ console.log("Invoking returnMap");
+
+ const returnMapResponse1 = await client.invoke