From 8844ecc54d521b5087dc9458b985a990185c3e21 Mon Sep 17 00:00:00 2001 From: Cesar Date: Tue, 8 Aug 2023 22:04:29 +0200 Subject: [PATCH 01/12] chore(examples): init examples --- examples/README.md | 1 + examples/package.json | 21 +++++++++++++ examples/src/filesystem.ts | 61 +++++++++++++++++++++++++++++++++++++ examples/src/hello-world.ts | 26 ++++++++++++++++ examples/src/http.ts | 51 +++++++++++++++++++++++++++++++ examples/tsconfig.json | 30 ++++++++++++++++++ 6 files changed, 190 insertions(+) create mode 100644 examples/README.md create mode 100644 examples/package.json create mode 100644 examples/src/filesystem.ts create mode 100644 examples/src/hello-world.ts create mode 100644 examples/src/http.ts create mode 100644 examples/tsconfig.json diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..38f42043e --- /dev/null +++ b/examples/README.md @@ -0,0 +1 @@ +# Polywrap JS Client Examples \ No newline at end of file diff --git a/examples/package.json b/examples/package.json new file mode 100644 index 000000000..4418757cd --- /dev/null +++ b/examples/package.json @@ -0,0 +1,21 @@ +{ + "name": "polywrap-js-examples", + "description": "Polywrap Client JS examples", + "license": "MIT", + "scripts": { + "run:fs": "ts-node src/filesystem.ts", + "run:http": "ts-node src/http.ts", + "run:hello-world": "ts-node src/hello-world.ts" + }, + "devDependencies": { + "@polywrap/client-js": "../packages/client", + "@polywrap/file-system-plugin-js": "0.12.0-pre.0", + "@polywrap/http-plugin-js": "0.12.0-pre.0", + "@polywrap/logger-plugin-js": "0.12.0-pre.0", + "ts-node": "10.9.1", + "typescript": "4.9.5" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/examples/src/filesystem.ts b/examples/src/filesystem.ts new file mode 100644 index 000000000..f1589459f --- /dev/null +++ b/examples/src/filesystem.ts @@ -0,0 +1,61 @@ +import { PolywrapClient, PolywrapClientConfigBuilder } from "@polywrap/client-js"; +import { httpPlugin } from "@polywrap/http-plugin-js" +import { Uri } from "@polywrap/core-js"; + +const main = async () => { + const { uri } = Uri.from("plugin/http") + const builder = new PolywrapClientConfigBuilder() + builder.setPackage(uri, httpPlugin({})) + const client = new PolywrapClient(builder.build()) + + const filePath = "./fs-example.txt" + const data = "Hello world!" + + const writeFile = await client.invoke({ + uri: uri, + method: "writeFile", + args: { + path: filePath, + data: new TextEncoder().encode(data) + } + }) + + if (!writeFile.ok) { + throw Error("Error writing file: " + writeFile.error) + } + + console.log("File created!") + + const readFile = await client.invoke({ + uri, + method: "readFile", + args: { + path: filePath + } + }) + + if (!readFile.ok) { + throw Error("Error read file: " + readFile.error) + } + + const decodedContent = new TextDecoder().decode(readFile.value) + console.log("Content from file: " + decodedContent) + + const removeFile = await client.invoke({ + uri, + method: "rm", + args: { + path: filePath + } + }) + + if (!removeFile.ok) { + throw Error("Error removing file file: " + removeFile.error) + } + + console.log("File removed!") +} + +main().then().catch(e => { + console.error("Error in file system example: ", e) +}) \ No newline at end of file diff --git a/examples/src/hello-world.ts b/examples/src/hello-world.ts new file mode 100644 index 000000000..31a95d9cb --- /dev/null +++ b/examples/src/hello-world.ts @@ -0,0 +1,26 @@ +import { PolywrapClient, PolywrapClientConfigBuilder } from "@polywrap/client-js"; +import { loggerPlugin } from "@polywrap/logger-plugin-js" +import { Uri } from "@polywrap/core-js"; +const main = async () => { + const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0") + const { uri: wrapUri } = Uri.from("http/https://wraps.wrapscan.io/r/polywrap/logging@1.0.0") + const builder = new PolywrapClientConfigBuilder() + builder.setPackage(pluginPackageUri, loggerPlugin({})).addBundle("sys") + const client = new PolywrapClient(builder.build()) + + const result = await client.invoke({ + uri: wrapUri, + method: "info", + args: { + message: "Hello from hello world wrap!" + } + }) + + if (!result.ok) { + throw Error("Log message error: " + result.error) + } +} + +main().then().catch(e => { + console.error("Error in HTTP example: ", e) +}) \ No newline at end of file diff --git a/examples/src/http.ts b/examples/src/http.ts new file mode 100644 index 000000000..af0dea789 --- /dev/null +++ b/examples/src/http.ts @@ -0,0 +1,51 @@ +import { PolywrapClient, PolywrapClientConfigBuilder } from "@polywrap/client-js"; +import { httpPlugin } from "@polywrap/http-plugin-js" +import { Uri } from "@polywrap/core-js"; + +interface Response { + status: Number + statusText: String + headers: Map | undefined + body: String | undefined +} + +const main = async () => { + const { uri } = Uri.from("plugin/http") + const builder = new PolywrapClientConfigBuilder() + builder.setPackage(uri, httpPlugin({})) + const client = new PolywrapClient(builder.build()) + + const getResult = await client.invoke({ + uri, + method: "get", + args: { + url: "https://httpbin.org/get" + } + }) + + if (!getResult.ok) { + throw Error("Get method error: " + getResult.error) + } + console.log("Get method response: ", getResult.value) + + const postResult = await client.invoke({ + uri, + method: "post", + args: { + url: "https://httpbin.org/post", + request: { + body: JSON.stringify({ item: "Hello world!" }), + responseType: "TEXT" + } + } + }) + + if (!postResult.ok) { + throw Error("Post method error: " + postResult.error) + } + console.log("Post method response: ", postResult.value) +} + +main().then().catch(e => { + console.error("Error in HTTP example: ", e) +}) \ No newline at end of file diff --git a/examples/tsconfig.json b/examples/tsconfig.json new file mode 100644 index 000000000..2e01ca5c2 --- /dev/null +++ b/examples/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "lib": [ + "es2015", + "es5", + "dom" + ], + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "declaration": true, + "preserveSymlinks": true, + "preserveWatchOutput": true, + "pretty": false, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "module": "commonjs", + "sourceMap": true, + "target": "es5", + "resolveJsonModule": true, + "strictNullChecks": true + }, + "include": [ + "./src/**/*" + ], +} From 03f3e80c0ac7d17a96d232ab95adf40f819ffcaf Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 11:13:52 +0200 Subject: [PATCH 02/12] chore(examples): ens, etherem & ipfs --- examples/package.json | 6 +- examples/src/ens.ts | 66 ++++++++++++++++++ examples/src/ethereum.ts | 134 ++++++++++++++++++++++++++++++++++++ examples/src/filesystem.ts | 61 ++++++++-------- examples/src/hello-world.ts | 36 ++++++---- examples/src/http.ts | 55 ++++++++------- examples/src/ipfs.ts | 53 ++++++++++++++ 7 files changed, 342 insertions(+), 69 deletions(-) create mode 100644 examples/src/ens.ts create mode 100644 examples/src/ethereum.ts create mode 100644 examples/src/ipfs.ts diff --git a/examples/package.json b/examples/package.json index 4418757cd..dad72aaa9 100644 --- a/examples/package.json +++ b/examples/package.json @@ -5,13 +5,17 @@ "scripts": { "run:fs": "ts-node src/filesystem.ts", "run:http": "ts-node src/http.ts", - "run:hello-world": "ts-node src/hello-world.ts" + "run:hello-world": "ts-node src/hello-world.ts", + "run:ipfs": "ts-node src/ipfs.ts", + "run:ethereum": "ts-node src/ethereum.ts", + "run:ens": "ts-node src/ens.ts" }, "devDependencies": { "@polywrap/client-js": "../packages/client", "@polywrap/file-system-plugin-js": "0.12.0-pre.0", "@polywrap/http-plugin-js": "0.12.0-pre.0", "@polywrap/logger-plugin-js": "0.12.0-pre.0", + "@polywrap/ethereum-wallet-js": "0.1.0", "ts-node": "10.9.1", "typescript": "4.9.5" }, diff --git a/examples/src/ens.ts b/examples/src/ens.ts new file mode 100644 index 000000000..dd67e04e6 --- /dev/null +++ b/examples/src/ens.ts @@ -0,0 +1,66 @@ +import { + PolywrapClient, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { Uri } from "@polywrap/core-js"; +import { + ethereumWalletPlugin, + Connection, + Connections, +} from "@polywrap/ethereum-wallet-js"; + +const main = async () => { + const { uri: ethereumPluginUri } = Uri.from( + "wrapscan.io/polywrap/ethereum-wallet@1.0" + ); + const builder = new PolywrapClientConfigBuilder(); + builder.addBundle("sys"); + const ethereumPlugin = ethereumWalletPlugin({ + connections: new Connections({ + networks: { + mainnet: new Connection({ + provider: + "https://mainnet.infura.io/v3/f1f688077be642c190ac9b28769daecf", + }), + }, + }), + }); + builder.setPackage(ethereumPluginUri, ethereumPlugin); + const client = new PolywrapClient(builder.build()); + + const resolverAddress = await client.invoke({ + uri: "wrapscan.io/polywrap/ens@1.0.0", + method: "getResolver", + args: { + registryAddress: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", + domain: "vitalik.eth", + }, + }); + + if (!resolverAddress.ok) { + throw Error("Error getting resolver: " + resolverAddress.error); + } + + console.log("Resolver address: " + resolverAddress.value); + + const contentHash = await client.invoke({ + uri: "wrapscan.io/polywrap/ens@1.0.0", + method: "getContentHash", + args: { + resolverAddress: resolverAddress.value, + domain: "vitalik.eth", + }, + }); + + if (!contentHash.ok) { + throw Error("Error getting resolver: " + contentHash.error); + } + + console.log("Content hash of vitalik.eth: " + contentHash.value); +}; + +main() + .then() + .catch((e) => { + console.error("Error in Ethereum example: ", e); + }); diff --git a/examples/src/ethereum.ts b/examples/src/ethereum.ts new file mode 100644 index 000000000..9da7c04aa --- /dev/null +++ b/examples/src/ethereum.ts @@ -0,0 +1,134 @@ +import { + PolywrapClient, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { Uri } from "@polywrap/core-js"; +import { + ethereumWalletPlugin, + Connection, + Connections, +} from "@polywrap/ethereum-wallet-js"; +import { Wallet } from "ethers"; + +const main = async () => { + const { uri: ethereumPluginUri } = Uri.from( + "wrapscan.io/polywrap/ethereum-wallet@1.0" + ); + const builder = new PolywrapClientConfigBuilder(); + builder.addBundle("sys"); + const ethereumPlugin = ethereumWalletPlugin({ + connections: new Connections({ + networks: { + mainnet: new Connection({ + provider: + "https://mainnet.infura.io/v3/f1f688077be642c190ac9b28769daecf", + signer: new Wallet( + "4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d" + ), + }), + }, + }), + }); + builder.setPackage(ethereumPluginUri, ethereumPlugin); + const client = new PolywrapClient(builder.build()); + + const balance = await client.invoke({ + uri: "wrapscan.io/polywrap/ethers@1.0.0", + method: "getBalance", + args: { + address: "0x00000000219ab540356cbb839cbe05303d7705fa", + }, + }); + + if (!balance.ok) { + throw Error("Error getting balance: " + balance.error); + } + + console.log("Balance in Wei: " + balance.value); + + const balanceInEth = await client.invoke({ + uri: "wrapscan.io/polywrap/ethers-utils@1.0.0", + method: "toEth", + args: { + wei: balance.value, + }, + }); + + if (!balanceInEth.ok) { + throw Error("Error converting balance to ETH: " + balanceInEth.error); + } + + console.log("Balance in Eth: " + balanceInEth.value); + + const domain = { + name: "Ether Mail", + version: "1", + chainId: 1, + verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC", + }; + + // The named list of all type definitions + const types = { + EIP712Domain: [ + { + type: "string", + name: "name", + }, + { + type: "string", + name: "version", + }, + { + type: "uint256", + name: "chainId", + }, + { + type: "address", + name: "verifyingContract", + }, + ], + Person: [ + { name: "name", type: "string" }, + { name: "wallet", type: "address" }, + ], + Mail: [ + { name: "from", type: "Person" }, + { name: "to", type: "Person" }, + { name: "contents", type: "string" }, + ], + }; + + // The data to sign + const message = { + from: { + name: "Cow", + wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", + }, + to: { + name: "Bob", + wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB", + }, + contents: "Hello, Bob!", + }; + + console.log("Signing typed data..."); + const signedData = await client.invoke({ + uri: "wrapscan.io/polywrap/ethers@1.0.0", + method: "signTypedData", + args: { + payload: JSON.stringify({ domain, primaryType: "Mail", types, message }), + }, + }); + + if (!signedData.ok) { + throw Error("Error signing data: " + signedData.error); + } + + console.log("Signed data: " + signedData.value); +}; + +main() + .then() + .catch((e) => { + console.error("Error in Ethereum example: ", e); + }); diff --git a/examples/src/filesystem.ts b/examples/src/filesystem.ts index f1589459f..b4eb4ab41 100644 --- a/examples/src/filesystem.ts +++ b/examples/src/filesystem.ts @@ -1,61 +1,66 @@ -import { PolywrapClient, PolywrapClientConfigBuilder } from "@polywrap/client-js"; -import { httpPlugin } from "@polywrap/http-plugin-js" +import { + PolywrapClient, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { httpPlugin } from "@polywrap/http-plugin-js"; import { Uri } from "@polywrap/core-js"; const main = async () => { - const { uri } = Uri.from("plugin/http") - const builder = new PolywrapClientConfigBuilder() - builder.setPackage(uri, httpPlugin({})) - const client = new PolywrapClient(builder.build()) + const { uri } = Uri.from("plugin/http"); + const builder = new PolywrapClientConfigBuilder(); + builder.setPackage(uri, httpPlugin({})); + const client = new PolywrapClient(builder.build()); - const filePath = "./fs-example.txt" - const data = "Hello world!" + const filePath = "./fs-example.txt"; + const data = "Hello world!"; const writeFile = await client.invoke({ uri: uri, method: "writeFile", args: { path: filePath, - data: new TextEncoder().encode(data) - } - }) + data: new TextEncoder().encode(data), + }, + }); if (!writeFile.ok) { - throw Error("Error writing file: " + writeFile.error) + throw Error("Error writing file: " + writeFile.error); } - console.log("File created!") + console.log("File created!"); const readFile = await client.invoke({ uri, method: "readFile", args: { - path: filePath - } - }) + path: filePath, + }, + }); if (!readFile.ok) { - throw Error("Error read file: " + readFile.error) + throw Error("Error read file: " + readFile.error); } - const decodedContent = new TextDecoder().decode(readFile.value) - console.log("Content from file: " + decodedContent) + const decodedContent = new TextDecoder().decode(readFile.value); + console.log("Content from file: " + decodedContent); const removeFile = await client.invoke({ uri, method: "rm", args: { - path: filePath - } - }) + path: filePath, + }, + }); if (!removeFile.ok) { - throw Error("Error removing file file: " + removeFile.error) + throw Error("Error removing file file: " + removeFile.error); } - console.log("File removed!") -} + console.log("File removed!"); +}; -main().then().catch(e => { - console.error("Error in file system example: ", e) -}) \ No newline at end of file +main() + .then() + .catch((e) => { + console.error("Error in file system example: ", e); + }); diff --git a/examples/src/hello-world.ts b/examples/src/hello-world.ts index 31a95d9cb..dc2b60307 100644 --- a/examples/src/hello-world.ts +++ b/examples/src/hello-world.ts @@ -1,26 +1,32 @@ -import { PolywrapClient, PolywrapClientConfigBuilder } from "@polywrap/client-js"; -import { loggerPlugin } from "@polywrap/logger-plugin-js" +import { + PolywrapClient, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { loggerPlugin } from "@polywrap/logger-plugin-js"; import { Uri } from "@polywrap/core-js"; + const main = async () => { - const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0") - const { uri: wrapUri } = Uri.from("http/https://wraps.wrapscan.io/r/polywrap/logging@1.0.0") - const builder = new PolywrapClientConfigBuilder() - builder.setPackage(pluginPackageUri, loggerPlugin({})).addBundle("sys") - const client = new PolywrapClient(builder.build()) + const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0"); + const { uri: wrapUri } = Uri.from("wrapscan.io/polywrap/logging@1.0.0"); + const builder = new PolywrapClientConfigBuilder(); + builder.setPackage(pluginPackageUri, loggerPlugin({})).addBundle("sys"); + const client = new PolywrapClient(builder.build()); const result = await client.invoke({ uri: wrapUri, method: "info", args: { - message: "Hello from hello world wrap!" - } - }) + message: "Hello from hello world wrap!", + }, + }); if (!result.ok) { - throw Error("Log message error: " + result.error) + throw Error("Log message error: " + result.error); } -} +}; -main().then().catch(e => { - console.error("Error in HTTP example: ", e) -}) \ No newline at end of file +main() + .then() + .catch((e) => { + console.error("Error in Hello World example: ", e); + }); diff --git a/examples/src/http.ts b/examples/src/http.ts index af0dea789..5418e0834 100644 --- a/examples/src/http.ts +++ b/examples/src/http.ts @@ -1,32 +1,35 @@ -import { PolywrapClient, PolywrapClientConfigBuilder } from "@polywrap/client-js"; -import { httpPlugin } from "@polywrap/http-plugin-js" +import { + PolywrapClient, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { httpPlugin } from "@polywrap/http-plugin-js"; import { Uri } from "@polywrap/core-js"; interface Response { - status: Number - statusText: String - headers: Map | undefined - body: String | undefined + status: Number; + statusText: String; + headers: Map | undefined; + body: String | undefined; } const main = async () => { - const { uri } = Uri.from("plugin/http") - const builder = new PolywrapClientConfigBuilder() - builder.setPackage(uri, httpPlugin({})) - const client = new PolywrapClient(builder.build()) + const { uri } = Uri.from("plugin/http"); + const builder = new PolywrapClientConfigBuilder(); + builder.setPackage(uri, httpPlugin({})); + const client = new PolywrapClient(builder.build()); const getResult = await client.invoke({ uri, method: "get", args: { - url: "https://httpbin.org/get" - } - }) + url: "https://httpbin.org/get", + }, + }); if (!getResult.ok) { - throw Error("Get method error: " + getResult.error) + throw Error("Get method error: " + getResult.error); } - console.log("Get method response: ", getResult.value) + console.log("Get method response: ", getResult.value); const postResult = await client.invoke({ uri, @@ -35,17 +38,19 @@ const main = async () => { url: "https://httpbin.org/post", request: { body: JSON.stringify({ item: "Hello world!" }), - responseType: "TEXT" - } - } - }) + responseType: "TEXT", + }, + }, + }); if (!postResult.ok) { - throw Error("Post method error: " + postResult.error) + throw Error("Post method error: " + postResult.error); } - console.log("Post method response: ", postResult.value) -} + console.log("Post method response: ", postResult.value); +}; -main().then().catch(e => { - console.error("Error in HTTP example: ", e) -}) \ No newline at end of file +main() + .then() + .catch((e) => { + console.error("Error in HTTP example: ", e); + }); diff --git a/examples/src/ipfs.ts b/examples/src/ipfs.ts new file mode 100644 index 000000000..eb1e520e4 --- /dev/null +++ b/examples/src/ipfs.ts @@ -0,0 +1,53 @@ +import { + PolywrapClient, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { Uri } from "@polywrap/core-js"; + +const main = async () => { + const { uri } = Uri.from("wrapscan.io/polywrap/ipfs-http-client@1.0"); + const ipfsProvider = "http://localhost:5001"; + const builder = new PolywrapClientConfigBuilder(); + builder.addBundle("sys"); + const client = new PolywrapClient(builder.build()); + + const fileName = "hello-world.txt"; + const fileData = "Hello world!!!"; + const addFileResult = await client.invoke<{ hash: String }>({ + uri, + method: "addFile", + args: { + data: { + name: fileName, + data: new TextEncoder().encode(fileData), + }, + ipfsProvider, + }, + }); + + if (!addFileResult.ok) { + throw Error("Add file method error: " + addFileResult.error); + } + console.log("File added!"); + console.log("Fetching from IPFS provider..."); + const catResult = await client.invoke({ + uri, + method: "cat", + args: { + cid: addFileResult.value.hash, + ipfsProvider, + }, + }); + + if (!catResult.ok) { + throw Error("Cat method error: " + catResult.error); + } + + console.log("Cat result: " + new TextDecoder().decode(catResult.value)); +}; + +main() + .then() + .catch((e) => { + console.error("Error in IPFS example: ", e); + }); From b220aa89f80b3a783f125741d0d7f543ef3462fb Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 12:15:28 +0200 Subject: [PATCH 03/12] chore: update readme --- CONTRIBUTING.md | 30 ++++++++++++ DEV_GUIDELINES.md | 55 ---------------------- README.md | 92 +++++++++++++------------------------ examples/README.md | 46 ++++++++++++++++++- examples/src/hello-world.ts | 6 +-- 5 files changed, 111 insertions(+), 118 deletions(-) create mode 100644 CONTRIBUTING.md delete mode 100644 DEV_GUIDELINES.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..297fc8451 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# Contributing + +Thank you for considering contributing to the Polywrap Javascript Client! We welcome contributions from the community to help improve and enhance the project. Look through this repository's [issues](https://github.com/polywrap/javascript-client/issues) to see what we're focused on solving. + + +## Pre-Requisites +To be able to fully build and test all functionality within the JS Client, you'll need the following programs installed: + +`nvm` +`yarn` + +## Installation + +From the root directory, run `nvm install && nvm use` to install the correct version of Node.JS. Next, run `yarn` to install all dependencies for all packages. + +## Build + +Running `yarn build` from the root directory will build all packages. After this, if you'd like to rebuild an individual package you're making changes to, simply run `yarn build` within the specific `./packages/...` folder you're working in. + + +## Test + +Run `yarn test` from the root to test everything, and `yarn test` within a specific package folder to test just that package. + + +## Feedback and Discussions + +For questions, suggestions, or discussions, open an issue or create a discussion within the [Polywrap Discord](https://discord.polywrap.io). + +Happy coding! diff --git a/DEV_GUIDELINES.md b/DEV_GUIDELINES.md deleted file mode 100644 index bd48e2c4b..000000000 --- a/DEV_GUIDELINES.md +++ /dev/null @@ -1,55 +0,0 @@ -# Toolchain Development Guidelines - -Guidelines for polywrap toolchain contributors. Have questions? https://discord.polywrap.io - -## GitHub Issues - -All planned features, bugs, and enhancements are represented as [GitHub issues](https://github.com/polywrap/toolchain/issues). Once created, issues can be brought into the ["Polywarp Release Roadmap"](https://github.com/orgs/polywrap/projects/6), where we track all in-progress roadmaps. [Milestones in GitHub repositories](https://github.com/polywrap/toolchain/milestones) are used to organize issues into [individual roadmaps](https://github.com/orgs/polywrap/projects/6/views/13). - -## Testing - -Tests for toolchain packages can be found in the can be found in the individual packages. Additionally there are various reusable integration test cases defined in the [test-cases directory](https://github.com/polywrap/toolchain/tree/origin/packages/test-cases). - -### Dependencies - -Some tests rely on additional system-wide dependencies being installed. These include: -- [`docker buildx`](https://docs.docker.com/engine/reference/commandline/buildx/) -- [`cue`](https://cuelang.org) - -### WRAP Integration Testing -In the test-cases directory, you can find the `wrappers` folder, which is auto generated from the releases of the [WRAP Test Harness](https://github.com/polywrap/wrap-test-harness). The WRAP Test Harness is used to ensure the toolchain is compliant with the various WRAP versions it is supposed to support. - -If your changes within the toolchain repo include breaking changes to the wrap developer experience, please modify the WRAP Test Harness accordingly by [following the development guidelines written here](https://github.com/polywrap/wrap-test-harness#build--contribute). - -## Branches - -The toolchain repo organizes branches in the following ways: -* **Release** - * 1 or more [publishers](./.github/PUBLISHERS) must approve - * ex: `origin`, `origin-0.9`, etc -* **Dev** - * 2 or more developers working on the project must approve - * ex: `origin-dev`, `origin-0.9-dev`, etc - -## Changelog - -For each new release, a new entry in the [CHANGELOG.md](CHANGELOG) file should be added manually listing the changes done like new features or bug fixing. - -## Releases - -The toolchain's releases can be found on [NPM](https://www.npmjs.com/org/polywrap) and [Github](https://github.com/polywrap/monorepo/releases). - -Only the people listed in the [.github/PUBLISHERS](./github/PUBLISHERS) file can initiate releases. To make a new release, a publisher should: - -1. Update the [VERSION](VERSION) and [CHANGELOG](CHANGELOG) files. -2. Make a pull request from the ${release}-dev branch into the ${release} branch, appending to the PR's title `/workflows/release-pr` -3. The [`polywrap-build-bot`](https://github.com/polywrap-build-bot) will prepare a new release pull request for the ${release} branch, and comment a link to it on the pull request it was initiated from. -4. In this new release pull request, copy & paste the changelog into the pull request's description section. This is what will be used for the Github release notes. -5. Add the "Polywrap-Release" Github tag to the pull request. -6. If this new pull request is merged, the release workflow will be run, publishing a new git tag, git release, and all packages. - -## Code Owners - -The [CODEOWNERS](./.github/CODEOWNERS) file is used to define individuals or teams that are responsible for code in the repository. Code owners are automatically requested for review when someone opens a pull request. - -Code owners can be defined using a certain [syntax](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax) for a project globally or for a certain part of the code (directory) so only people that have worked on certain parts are really the defined code owners. diff --git a/README.md b/README.md index fb0460f0d..a04712acf 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,56 @@ -![Public Release Announcement](https://user-images.githubusercontent.com/5522128/177473887-2689cf25-7937-4620-8ca5-17620729a65d.png) +![polywrap-banner](https://raw.githubusercontent.com/polywrap/branding/master/assets/banner.png) -[**Polywrap**](https://polywrap.io/) is a developer tool that enables easy integration of Web3 protocols into any application. It makes it possible for applications on any platform, written in any language, to read and write data to Web3 protocols. +# Javascript Client -# Getting Started - -Have questions or want to get involved? Join our community [Discord](https://discord.polywrap.io) or [open an issue](https://github.com/polywrap/javascript-client/issues) on Github. - -For detailed information about Polywrap and the WRAP standard, visit our [developer documentation](https://docs.polywrap.io/). - -# Contributing - -The Polywrap project is completely open-source and we welcome contributors of all levels. - -Come visit our [Github issues](https://github.com/polywrap/javascript-client/issues) to see the problems we're focused on solving. Here are some of our tags for issues and what they mean: - -- `good first issue` - These are good first issues for newcomers to learn about how our project works - -- `pri-0`, `pri-1` and `pri-2` - These are our priority issues, with `pri-0` being our highest priority and `pri-2` being lower. - -- `alpha-blocker` - We're in pre-alpha right now and to get to alpha, we need to resolve all alpha blocker issues - -- `beta-blocker` - After our alpha release, we'll start working towards releasing our beta! These are the blockers for us in reaching that milestone. - -Below are a series of steps to get started with our monorepo after you've cloned it into your local repository. - -Before contributing to this repository, please read the [developer guidelines](DEV_GUIDELINES.md). - -## Pre-reqs - -You'll need the following installed before building your wrapper: - -`nvm` - -`yarn` - -`docker` - -`docker-compose` +Implementation of the Polywrap client in JavaScript. ## Installation +Switching to Node.js version 18 is required. Execute nvm use, if you have Node Version Manager. -To ensure all of your project's dependencies are installed, from inside your project's directory, simply run: +Then, in your project, run: ``` -nvm install && nvm use -yarn +npm install @polywrap/client +# or +yarn add @polywrap/client ``` -## Build +## Getting Started -Run the following to compile the monorepo: +Create a new Polywrap client config builder instance, add the bundles you want to use, and then create a new Polywrap client instance with the config. -`yarn build` +```typescript +import { + PolywrapClient, + PolywrapClientConfigBuilder +} from "@polywrap/client"; -## Test +const builder = new PolywrapClientConfigBuilder(); +builder.addBundle("sys"); +const client = new PolywrapClient(builder.build()); -Run the following to test if the build worked: +const result = await client.invoke({ + uri: "wrapscan.io/polywrap/logging@1.0.0", + method: "info", + args: { + message: "Hello from hello world wrap!", + } +}); -``` -yarn test +if (!result.ok) { + throw Error("Log message error: " + result.error); +} ``` -## Lint +# Getting Started -To lint your project directory, run the following: +Have questions or want to get involved? Join our community [Discord](https://discord.polywrap.io) or [open an issue](https://github.com/polywrap/javascript-client/issues) on Github. -``` -yarn lint -``` +For detailed information about Polywrap and the WRAP standard, visit our [developer documentation](https://docs.polywrap.io/). -To auto-fix lint errors: -``` -yarn lint:fix -``` # Resources -- [Website](https://polywrap.io/) -- [Documentation](https://docs.polywrap.io/) -- [Forum](https://forum.polywrap.io/) +- [Examples](./examples/) +- [Features supported](https://github.com/polywrap/client-readiness/tree/main/clients/js/src/features) diff --git a/examples/README.md b/examples/README.md index 38f42043e..0f3524e99 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1 +1,45 @@ -# Polywrap JS Client Examples \ No newline at end of file +# Polywrap JS Client Examples + +## Hello World + +Invokes the logger wrap, which interacts with the logger plugin. It shows a console.log message from WASM world +``` +$ yarn run:hello-world +``` +## File System + +Invokes the File System plugin; which creates, reads and deletes a file +``` +$ yarn run:fs +``` + +## Http + +Invokes the HTTP plugin, doing GET and POST requests +``` +$ yarn run:http +``` + +## Ipfs + +Invoke the IPFS Client wrap; adds file to a local IPFS node, and then retrieves it +``` +$ yarn run:ipfs +``` + +## Ethereum + +Invoke the Ethers core & util wraps, and uses the Ethereum Wallet plugin. It gets the balance of the Staking contract and then parses it from Wei to Eth. Also, it executes the sign typed data method + +``` +$ yarn run:ethereum +``` + +## ENS + +Invoke the ENS wrap, it gets the resolver & content hash of vitalik.eth +``` +$ yarn run:ens +``` + + diff --git a/examples/src/hello-world.ts b/examples/src/hello-world.ts index dc2b60307..f2167ce88 100644 --- a/examples/src/hello-world.ts +++ b/examples/src/hello-world.ts @@ -2,14 +2,14 @@ import { PolywrapClient, PolywrapClientConfigBuilder, } from "@polywrap/client-js"; -import { loggerPlugin } from "@polywrap/logger-plugin-js"; +// import { loggerPlugin } from "@polywrap/logger-plugin-js"; import { Uri } from "@polywrap/core-js"; const main = async () => { - const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0"); + // const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0"); const { uri: wrapUri } = Uri.from("wrapscan.io/polywrap/logging@1.0.0"); const builder = new PolywrapClientConfigBuilder(); - builder.setPackage(pluginPackageUri, loggerPlugin({})).addBundle("sys"); + builder.addBundle("sys"); const client = new PolywrapClient(builder.build()); const result = await client.invoke({ From d3c9448483bd485db0ee98a5bd98646f0d2d7ed0 Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 12:45:43 +0200 Subject: [PATCH 04/12] chore(ci): add examples --- .github/workflows/ci-javascript.yaml | 46 +++++++++++++++++++++++++++- README.md | 4 --- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-javascript.yaml b/.github/workflows/ci-javascript.yaml index b9734fa7a..040608645 100644 --- a/.github/workflows/ci-javascript.yaml +++ b/.github/workflows/ci-javascript.yaml @@ -83,7 +83,6 @@ jobs: Test: runs-on: ubuntu-latest timeout-minutes: 60 - if: ${{ always() }} steps: - name: Checkout repository uses: actions/checkout@v2 @@ -116,3 +115,48 @@ jobs: - name: Test run: yarn test + + Examples: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Read .nvmrc + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + id: nvm + + - name: Setup Node.js + uses: actions/setup-node@master + with: + node-version: '${{ steps.nvm.outputs.NVMRC }}' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: (yarn install --nonInteractive --frozen-lockfile --prefer-offline || yarn install --nonInteractive --frozen-lockfile --prefer-offline) + + - name: Build + run: yarn build + + - name: Instantiate IPFS node + run: npx polywrap infra up --modules=eth-ens-ipfs + + - name: Examples + run: | + yarn run:hello-world + yarn run:fs + yarn run:http + yarn run:ipfs + yarn run:ethereum + yarn run:ens diff --git a/README.md b/README.md index a04712acf..f9518e541 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,6 @@ Implementation of the Polywrap client in JavaScript. ## Installation -Switching to Node.js version 18 is required. Execute nvm use, if you have Node Version Manager. - -Then, in your project, run: - ``` npm install @polywrap/client # or From 3093fcab70f164db728e269b2cbcee95538f1b20 Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 12:53:36 +0200 Subject: [PATCH 05/12] chore(examples): use constant for uris --- examples/src/ethereum.ts | 15 +++++++++------ examples/src/filesystem.ts | 7 ++++--- examples/src/hello-world.ts | 6 +++--- examples/src/http.ts | 3 ++- examples/src/ipfs.ts | 5 +++-- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/examples/src/ethereum.ts b/examples/src/ethereum.ts index 9da7c04aa..7070b885e 100644 --- a/examples/src/ethereum.ts +++ b/examples/src/ethereum.ts @@ -10,13 +10,16 @@ import { } from "@polywrap/ethereum-wallet-js"; import { Wallet } from "ethers"; +const ETHEREUM_CORE_URI = "wrapscan.io/polywrap/ethers@1.0.0"; +const ETHEREUM_UTIL_URI = "wrapscan.io/polywrap/ethers-utils@1.0.0"; + const main = async () => { - const { uri: ethereumPluginUri } = Uri.from( + const { uri: ethereumWalletUri } = Uri.from( "wrapscan.io/polywrap/ethereum-wallet@1.0" ); const builder = new PolywrapClientConfigBuilder(); builder.addBundle("sys"); - const ethereumPlugin = ethereumWalletPlugin({ + const ethereumWalletPackage = ethereumWalletPlugin({ connections: new Connections({ networks: { mainnet: new Connection({ @@ -29,11 +32,11 @@ const main = async () => { }, }), }); - builder.setPackage(ethereumPluginUri, ethereumPlugin); + builder.setPackage(ethereumWalletUri, ethereumWalletPackage); const client = new PolywrapClient(builder.build()); const balance = await client.invoke({ - uri: "wrapscan.io/polywrap/ethers@1.0.0", + uri: ETHEREUM_CORE_URI, method: "getBalance", args: { address: "0x00000000219ab540356cbb839cbe05303d7705fa", @@ -47,7 +50,7 @@ const main = async () => { console.log("Balance in Wei: " + balance.value); const balanceInEth = await client.invoke({ - uri: "wrapscan.io/polywrap/ethers-utils@1.0.0", + uri: ETHEREUM_UTIL_URI, method: "toEth", args: { wei: balance.value, @@ -113,7 +116,7 @@ const main = async () => { console.log("Signing typed data..."); const signedData = await client.invoke({ - uri: "wrapscan.io/polywrap/ethers@1.0.0", + uri: ETHEREUM_CORE_URI, method: "signTypedData", args: { payload: JSON.stringify({ domain, primaryType: "Mail", types, message }), diff --git a/examples/src/filesystem.ts b/examples/src/filesystem.ts index b4eb4ab41..17e39b88c 100644 --- a/examples/src/filesystem.ts +++ b/examples/src/filesystem.ts @@ -2,13 +2,14 @@ import { PolywrapClient, PolywrapClientConfigBuilder, } from "@polywrap/client-js"; -import { httpPlugin } from "@polywrap/http-plugin-js"; +import { fileSystemPlugin } from "@polywrap/file-system-plugin-js"; import { Uri } from "@polywrap/core-js"; +const { uri } = Uri.from("wrapscan.io/polywrap/file-system@1.0"); + const main = async () => { - const { uri } = Uri.from("plugin/http"); const builder = new PolywrapClientConfigBuilder(); - builder.setPackage(uri, httpPlugin({})); + builder.setPackage(uri, fileSystemPlugin({})); const client = new PolywrapClient(builder.build()); const filePath = "./fs-example.txt"; diff --git a/examples/src/hello-world.ts b/examples/src/hello-world.ts index f2167ce88..dc2b60307 100644 --- a/examples/src/hello-world.ts +++ b/examples/src/hello-world.ts @@ -2,14 +2,14 @@ import { PolywrapClient, PolywrapClientConfigBuilder, } from "@polywrap/client-js"; -// import { loggerPlugin } from "@polywrap/logger-plugin-js"; +import { loggerPlugin } from "@polywrap/logger-plugin-js"; import { Uri } from "@polywrap/core-js"; const main = async () => { - // const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0"); + const { uri: pluginPackageUri } = Uri.from("wrapscan.io/polywrap/logger@1.0"); const { uri: wrapUri } = Uri.from("wrapscan.io/polywrap/logging@1.0.0"); const builder = new PolywrapClientConfigBuilder(); - builder.addBundle("sys"); + builder.setPackage(pluginPackageUri, loggerPlugin({})).addBundle("sys"); const client = new PolywrapClient(builder.build()); const result = await client.invoke({ diff --git a/examples/src/http.ts b/examples/src/http.ts index 5418e0834..4457ad370 100644 --- a/examples/src/http.ts +++ b/examples/src/http.ts @@ -12,8 +12,9 @@ interface Response { body: String | undefined; } +const { uri } = Uri.from("wrapscan.io/polywrap/http@1.0"); + const main = async () => { - const { uri } = Uri.from("plugin/http"); const builder = new PolywrapClientConfigBuilder(); builder.setPackage(uri, httpPlugin({})); const client = new PolywrapClient(builder.build()); diff --git a/examples/src/ipfs.ts b/examples/src/ipfs.ts index eb1e520e4..601710155 100644 --- a/examples/src/ipfs.ts +++ b/examples/src/ipfs.ts @@ -4,9 +4,10 @@ import { } from "@polywrap/client-js"; import { Uri } from "@polywrap/core-js"; +const { uri } = Uri.from("wrapscan.io/polywrap/ipfs-http-client@1.0"); +const ipfsProvider = "http://localhost:5001"; + const main = async () => { - const { uri } = Uri.from("wrapscan.io/polywrap/ipfs-http-client@1.0"); - const ipfsProvider = "http://localhost:5001"; const builder = new PolywrapClientConfigBuilder(); builder.addBundle("sys"); const client = new PolywrapClient(builder.build()); From 5649146325031df7f0b6ca0402147316a75f2e6e Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 12:57:41 +0200 Subject: [PATCH 06/12] chore(examples/ens): ethereumPluginUri -> ethereumWalletUri --- examples/src/ens.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/src/ens.ts b/examples/src/ens.ts index dd67e04e6..05c919419 100644 --- a/examples/src/ens.ts +++ b/examples/src/ens.ts @@ -10,12 +10,12 @@ import { } from "@polywrap/ethereum-wallet-js"; const main = async () => { - const { uri: ethereumPluginUri } = Uri.from( + const { uri: ethereumWalletUri } = Uri.from( "wrapscan.io/polywrap/ethereum-wallet@1.0" ); const builder = new PolywrapClientConfigBuilder(); builder.addBundle("sys"); - const ethereumPlugin = ethereumWalletPlugin({ + const ethereumWalletPackage = ethereumWalletPlugin({ connections: new Connections({ networks: { mainnet: new Connection({ @@ -25,7 +25,7 @@ const main = async () => { }, }), }); - builder.setPackage(ethereumPluginUri, ethereumPlugin); + builder.setPackage(ethereumWalletUri, ethereumWalletPackage); const client = new PolywrapClient(builder.build()); const resolverAddress = await client.invoke({ From 4224576dc5abf5912fc58cfdde360590b33fd920 Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 13:01:03 +0200 Subject: [PATCH 07/12] chore(ci): fix example script --- .github/workflows/ci-javascript.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-javascript.yaml b/.github/workflows/ci-javascript.yaml index 040608645..5a7abc72c 100644 --- a/.github/workflows/ci-javascript.yaml +++ b/.github/workflows/ci-javascript.yaml @@ -154,6 +154,7 @@ jobs: - name: Examples run: | + cd examples yarn run:hello-world yarn run:fs yarn run:http From e743867f6669a32b6311f4b3804962b0756006f5 Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 13:13:13 +0200 Subject: [PATCH 08/12] chore(ci/examples): add yarn install step --- .github/workflows/ci-javascript.yaml | 1 + .gitignore | 3 ++- examples/README.md | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-javascript.yaml b/.github/workflows/ci-javascript.yaml index 5a7abc72c..7ac90200b 100644 --- a/.github/workflows/ci-javascript.yaml +++ b/.github/workflows/ci-javascript.yaml @@ -155,6 +155,7 @@ jobs: - name: Examples run: | cd examples + yarn yarn run:hello-world yarn run:fs yarn run:http diff --git a/.gitignore b/.gitignore index 6a1e7a230..117f2ddd8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ polywrap.deployment.txt **/.pytest_cache/ **/__pycache__/ **/dist/ -poetry.lock \ No newline at end of file +poetry.lock +examples/yarn.lock \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index 0f3524e99..1a726e363 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,5 +1,7 @@ # Polywrap JS Client Examples +Before running any example you must run `yarn` in the `examples` folder + ## Hello World Invokes the logger wrap, which interacts with the logger plugin. It shows a console.log message from WASM world From ffb41be59f03304aae3392e32fbf44d1ef9e9bd2 Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 13:35:00 +0200 Subject: [PATCH 09/12] chore(examples): add instruction to spin up local ipfs node --- examples/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index 1a726e363..f47c7ea5f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -24,7 +24,10 @@ $ yarn run:http ## Ipfs -Invoke the IPFS Client wrap; adds file to a local IPFS node, and then retrieves it +Invoke the IPFS Client wrap; adds file to a local IPFS node, and then retrieves it. +Before running this example, you must instantiate a local IPFS node by running the following command: +``` +npx polywrap infra up --modules=eth-ens-ipfs ``` $ yarn run:ipfs ``` From ac33cae1d64544d3468681b8c1d83fac5b9fe09b Mon Sep 17 00:00:00 2001 From: Cesar Date: Wed, 9 Aug 2023 15:57:45 +0200 Subject: [PATCH 10/12] chore: fix readmes --- README.md | 14 +++++--------- examples/README.md | 4 +++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f9518e541..deb54847f 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,12 @@ if (!result.ok) { throw Error("Log message error: " + result.error); } ``` - -# Getting Started - -Have questions or want to get involved? Join our community [Discord](https://discord.polywrap.io) or [open an issue](https://github.com/polywrap/javascript-client/issues) on Github. - -For detailed information about Polywrap and the WRAP standard, visit our [developer documentation](https://docs.polywrap.io/). - - - # Resources +- [Documentation](https://docs.polywrap.io/) - [Examples](./examples/) - [Features supported](https://github.com/polywrap/client-readiness/tree/main/clients/js/src/features) + +# Support + +For any questions or problems, please visit our [Discord](https://discord.polywrap.io). \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index f47c7ea5f..318d9531c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -27,7 +27,9 @@ $ yarn run:http Invoke the IPFS Client wrap; adds file to a local IPFS node, and then retrieves it. Before running this example, you must instantiate a local IPFS node by running the following command: ``` -npx polywrap infra up --modules=eth-ens-ipfs +$ npx polywrap infra up --modules=eth-ens-ipfs +``` +And now you can run the example: ``` $ yarn run:ipfs ``` From 0daaf7d450863fcb9cc0e78ad2f2ab1c4986f130 Mon Sep 17 00:00:00 2001 From: Cesar Date: Thu, 17 Aug 2023 16:13:13 +0200 Subject: [PATCH 11/12] chore(example): add note of docker needed in ipfs example --- examples/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/README.md b/examples/README.md index 318d9531c..0940687d4 100644 --- a/examples/README.md +++ b/examples/README.md @@ -26,6 +26,8 @@ $ yarn run:http Invoke the IPFS Client wrap; adds file to a local IPFS node, and then retrieves it. Before running this example, you must instantiate a local IPFS node by running the following command: + +_NOTE: This command requires Docker to be installed on your machine._ ``` $ npx polywrap infra up --modules=eth-ens-ipfs ``` From 29296dc0476aa1988be53f3f963f8b5438880a8b Mon Sep 17 00:00:00 2001 From: Cesar Date: Thu, 17 Aug 2023 18:48:01 +0200 Subject: [PATCH 12/12] chore(examples): rename hello world to logger --- .github/workflows/ci-javascript.yaml | 2 +- examples/README.md | 13 +++++++------ examples/package.json | 2 +- examples/src/{hello-world.ts => logger.ts} | 0 4 files changed, 9 insertions(+), 8 deletions(-) rename examples/src/{hello-world.ts => logger.ts} (100%) diff --git a/.github/workflows/ci-javascript.yaml b/.github/workflows/ci-javascript.yaml index 7ac90200b..6e6c3678c 100644 --- a/.github/workflows/ci-javascript.yaml +++ b/.github/workflows/ci-javascript.yaml @@ -156,7 +156,7 @@ jobs: run: | cd examples yarn - yarn run:hello-world + yarn run:logger yarn run:fs yarn run:http yarn run:ipfs diff --git a/examples/README.md b/examples/README.md index 0940687d4..96a9db45d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,12 +2,6 @@ Before running any example you must run `yarn` in the `examples` folder -## Hello World - -Invokes the logger wrap, which interacts with the logger plugin. It shows a console.log message from WASM world -``` -$ yarn run:hello-world -``` ## File System Invokes the File System plugin; which creates, reads and deletes a file @@ -36,6 +30,13 @@ And now you can run the example: $ yarn run:ipfs ``` +## Logger + +Invokes the logger wrap, which interacts with the logger plugin. It shows a console.log message from WASM world +``` +$ yarn run:logger +``` + ## Ethereum Invoke the Ethers core & util wraps, and uses the Ethereum Wallet plugin. It gets the balance of the Staking contract and then parses it from Wei to Eth. Also, it executes the sign typed data method diff --git a/examples/package.json b/examples/package.json index dad72aaa9..08a5f04dd 100644 --- a/examples/package.json +++ b/examples/package.json @@ -5,7 +5,7 @@ "scripts": { "run:fs": "ts-node src/filesystem.ts", "run:http": "ts-node src/http.ts", - "run:hello-world": "ts-node src/hello-world.ts", + "run:logger": "ts-node src/logger.ts", "run:ipfs": "ts-node src/ipfs.ts", "run:ethereum": "ts-node src/ethereum.ts", "run:ens": "ts-node src/ens.ts" diff --git a/examples/src/hello-world.ts b/examples/src/logger.ts similarity index 100% rename from examples/src/hello-world.ts rename to examples/src/logger.ts