diff --git a/packages/templates/wasm/assemblyscript/package.json b/packages/templates/wasm/assemblyscript/package.json index 5655b15996..8511c141c3 100644 --- a/packages/templates/wasm/assemblyscript/package.json +++ b/packages/templates/wasm/assemblyscript/package.json @@ -6,13 +6,9 @@ "scripts": { "codegen": "npx polywrap codegen", "build": "npx polywrap build", - "test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs", - "test:env:down": "npx polywrap infra down --modules=eth-ens-ipfs", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", - "test:e2e:codegen": "npx polywrap codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap", - "test:workflow": "npx polywrap test -o ./workflows/output.json" + "test": "yarn test:codegen && jest --passWithNoTests --runInBand --verbose", + "test:codegen": "npx polywrap codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap" }, "devDependencies": { "@types/jest": "26.0.8", diff --git a/packages/templates/wasm/assemblyscript/polywrap.build.yaml b/packages/templates/wasm/assemblyscript/polywrap.build.yaml deleted file mode 100644 index 7a6e7fac0e..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.build.yaml +++ /dev/null @@ -1,8 +0,0 @@ -format: 0.3.0 -strategies: - image: - name: wrap-wasm-as-build-image - node_version: 16.13.0 - include: - - ./package.json - - ./src diff --git a/packages/templates/wasm/assemblyscript/polywrap.deploy.yaml b/packages/templates/wasm/assemblyscript/polywrap.deploy.yaml deleted file mode 100644 index f0444053fc..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.deploy.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: "0.1" -stages: - ipfs_deploy: - package: ipfs - uri: fs/./build - config: - gatewayUri: "https://ipfs.wrappers.io" \ No newline at end of file diff --git a/packages/templates/wasm/assemblyscript/polywrap.test.yaml b/packages/templates/wasm/assemblyscript/polywrap.test.yaml deleted file mode 100644 index 1cb06da5f4..0000000000 --- a/packages/templates/wasm/assemblyscript/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-rs -format: 0.1.0 -validation: "./workflows/validator.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/assemblyscript/polywrap.yaml b/packages/templates/wasm/assemblyscript/polywrap.yaml index 0474ff70bd..950f086093 100644 --- a/packages/templates/wasm/assemblyscript/polywrap.yaml +++ b/packages/templates/wasm/assemblyscript/polywrap.yaml @@ -5,5 +5,3 @@ project: source: module: ./src/index.ts schema: ./polywrap.graphql -extensions: - build: ./polywrap.build.yaml diff --git a/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/assemblyscript/src/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); diff --git a/packages/templates/wasm/assemblyscript/workflows/validator.cue b/packages/templates/wasm/assemblyscript/workflows/validator.cue deleted file mode 100644 index a71f50ace0..0000000000 --- a/packages/templates/wasm/assemblyscript/workflows/validator.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts index 55913c174a..68c84d6ee1 100644 --- a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts +++ b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts @@ -1,4 +1,3 @@ -import { PolywrapClient } from "@polywrap/client-js"; import * as App from "../types/wrap"; import path from "path"; @@ -6,26 +5,21 @@ jest.setTimeout(60000); describe("Template Wrapper End to End Tests", () => { - const client: PolywrapClient = new PolywrapClient(); + let template: App.Template; let wrapperUri: string; beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) }) it("calls sampleMethod", async () => { const expected: string = "polywrap"; - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); + const result = await template.sampleMethod({ arg: expected }) - expect(result.ok).toBeTruthy(); - if (!result.ok) return; + if (!result.ok) throw result.error; expect(result.value.result).toEqual(expected); }); }); diff --git a/packages/templates/wasm/golang/package.json b/packages/templates/wasm/golang/package.json index aa9a03750f..7d4a4e525f 100644 --- a/packages/templates/wasm/golang/package.json +++ b/packages/templates/wasm/golang/package.json @@ -7,10 +7,8 @@ "codegen": "npx polywrap codegen", "build": "npx polywrap build", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", - "test:e2e:codegen": "npx polywrap codegen -m ./module/__tests__/types/polywrap.app.yaml -g ./module/__tests__/types/wrap", - "test:workflow": "npx polywrap test" + "test": "yarn test:codegen && jest --passWithNoTests --runInBand --verbose", + "test:codegen": "npx polywrap codegen -m ./module/__tests__/types/polywrap.app.yaml -g ./module/__tests__/types/wrap" }, "devDependencies": { "@types/jest": "26.0.8", diff --git a/packages/templates/wasm/golang/polywrap.test.cue b/packages/templates/wasm/golang/polywrap.test.cue deleted file mode 100644 index a71f50ace0..0000000000 --- a/packages/templates/wasm/golang/polywrap.test.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/golang/polywrap.test.yaml b/packages/templates/wasm/golang/polywrap.test.yaml deleted file mode 100644 index 2603e2d03f..0000000000 --- a/packages/templates/wasm/golang/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-go -format: 0.1.0 -validation: "./polywrap.test.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/golang/polywrap.yaml b/packages/templates/wasm/golang/polywrap.yaml index 0b1f3f35d6..d9b2de8b3a 100644 --- a/packages/templates/wasm/golang/polywrap.yaml +++ b/packages/templates/wasm/golang/polywrap.yaml @@ -4,4 +4,4 @@ project: type: wasm/golang source: schema: ./polywrap.graphql - module: ./go.mod + module: ./go.mod \ No newline at end of file diff --git a/packages/templates/wasm/interface/polywrap.deploy.yaml b/packages/templates/wasm/interface/polywrap.deploy.yaml deleted file mode 100644 index f0444053fc..0000000000 --- a/packages/templates/wasm/interface/polywrap.deploy.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: "0.1" -stages: - ipfs_deploy: - package: ipfs - uri: fs/./build - config: - gatewayUri: "https://ipfs.wrappers.io" \ No newline at end of file diff --git a/packages/templates/wasm/rust/package.json b/packages/templates/wasm/rust/package.json index 8aec722df6..5bf7bbd1e8 100644 --- a/packages/templates/wasm/rust/package.json +++ b/packages/templates/wasm/rust/package.json @@ -7,10 +7,8 @@ "codegen": "npx polywrap codegen", "build": "npx polywrap build", "deploy": "npx polywrap deploy", - "test": "yarn test:e2e && yarn test:workflow", - "test:e2e": "yarn test:e2e:codegen && cargo test --release", - "test:e2e:codegen": "npx polywrap codegen -m ./tests/types/polywrap.app.yaml -g ./tests/types/wrap", - "test:workflow": "npx polywrap test" + "test": "yarn test:codegen && cargo test --release", + "test:codegen": "npx polywrap codegen -m ./tests/types/polywrap.app.yaml -g ./tests/types/wrap" }, "devDependencies": { "polywrap": "0.12.1" diff --git a/packages/templates/wasm/rust/polywrap.build.yaml b/packages/templates/wasm/rust/polywrap.build.yaml deleted file mode 100644 index 875939c725..0000000000 --- a/packages/templates/wasm/rust/polywrap.build.yaml +++ /dev/null @@ -1,4 +0,0 @@ -format: 0.2.0 -strategies: - image: - name: template-wasm-rs \ No newline at end of file diff --git a/packages/templates/wasm/rust/polywrap.deploy.yaml b/packages/templates/wasm/rust/polywrap.deploy.yaml deleted file mode 100644 index 2b9ab565ce..0000000000 --- a/packages/templates/wasm/rust/polywrap.deploy.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: 0.1.0 -stages: - ipfs_deploy: - package: ipfs - uri: fs/./build - config: - gatewayUri: "https://ipfs.wrappers.io" \ No newline at end of file diff --git a/packages/templates/wasm/rust/polywrap.test.cue b/packages/templates/wasm/rust/polywrap.test.cue deleted file mode 100644 index 72c37000a6..0000000000 --- a/packages/templates/wasm/rust/polywrap.test.cue +++ /dev/null @@ -1,11 +0,0 @@ -package e2e - -sampleMethod: { - $0: { - data: { - value: "polywrap from sample_method" - }, - error?: _|_, - } -} - diff --git a/packages/templates/wasm/rust/polywrap.test.yaml b/packages/templates/wasm/rust/polywrap.test.yaml deleted file mode 100644 index c622bccd27..0000000000 --- a/packages/templates/wasm/rust/polywrap.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: template-wasm-rs -format: 0.1.0 -validation: "./polywrap.test.cue" -jobs: - sampleMethod: - steps: - - uri: fs/build - method: sampleMethod - args: - arg: "polywrap" diff --git a/packages/templates/wasm/rust/polywrap.yaml b/packages/templates/wasm/rust/polywrap.yaml index a87ff9b728..11220fee06 100644 --- a/packages/templates/wasm/rust/polywrap.yaml +++ b/packages/templates/wasm/rust/polywrap.yaml @@ -4,6 +4,4 @@ project: type: wasm/rust source: module: ./Cargo.toml - schema: ./polywrap.graphql -extensions: - build: ./polywrap.build.yaml + schema: ./polywrap.graphql \ No newline at end of file diff --git a/packages/templates/wasm/rust/tests/it/module.rs b/packages/templates/wasm/rust/tests/it/module.rs index a738738bbc..33e83bc530 100644 --- a/packages/templates/wasm/rust/tests/it/module.rs +++ b/packages/templates/wasm/rust/tests/it/module.rs @@ -1,14 +1,14 @@ use crate::types::wrap::types::{ - TemplateModule, - TemplateModuleArgsSampleMethod + Template, + TemplateArgsSampleMethod }; #[test] fn sample_method() { - let args = TemplateModuleArgsSampleMethod { + let args = TemplateArgsSampleMethod { arg: "input data".to_string(), }; - let template: TemplateModule = TemplateModule::new(None, None, None); - let response = template.sample_method(&args, None, None, None).unwrap(); + let template: Template = Template::new(None); + let response = template.sample_method(&args, None).unwrap(); assert_eq!(response.result, "input data from sample_method"); } diff --git a/packages/templates/wasm/typescript/package.json b/packages/templates/wasm/typescript/package.json index 41a85158d2..983f859756 100644 --- a/packages/templates/wasm/typescript/package.json +++ b/packages/templates/wasm/typescript/package.json @@ -6,10 +6,11 @@ "main": "build/index.js", "scripts": { "bundle": "rollup -c", - "codegen": "polywrap codegen --verbose", - "build": "yarn bundle && npx polywrap build --no-codegen", - "test": "jest --passWithNoTests --runInBand --verbose", - "deploy": "polywrap deploy" + "codegen": "npx polywrap codegen", + "build": "yarn codegen && yarn bundle && npx polywrap build --no-codegen", + "deploy": "npx polywrap deploy", + "test": "yarn test:codegen && jest --passWithNoTests --runInBand --verbose", + "test:codegen": "npx polywrap codegen -m ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap" }, "dependencies": { "tslib": "^2.6.2" diff --git a/packages/templates/wasm/typescript/polywrap.build.yaml b/packages/templates/wasm/typescript/polywrap.build.yaml deleted file mode 100644 index 4bdc6dc166..0000000000 --- a/packages/templates/wasm/typescript/polywrap.build.yaml +++ /dev/null @@ -1,3 +0,0 @@ -format: 0.3.0 -config: - scriptFile: ./bundled/wrap.js \ No newline at end of file diff --git a/packages/templates/wasm/typescript/polywrap.graphql b/packages/templates/wasm/typescript/polywrap.graphql index a527c058c2..5b34469c7e 100644 --- a/packages/templates/wasm/typescript/polywrap.graphql +++ b/packages/templates/wasm/typescript/polywrap.graphql @@ -1,3 +1,7 @@ type Module { - foo(bar: String!): String! + sampleMethod(arg: String!): SampleResult! +} + +type SampleResult { + result: String! } diff --git a/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts new file mode 100644 index 0000000000..68c84d6ee1 --- /dev/null +++ b/packages/templates/wasm/typescript/src/__tests__/e2e/integration.spec.ts @@ -0,0 +1,25 @@ +import * as App from "../types/wrap"; +import path from "path"; + +jest.setTimeout(60000); + +describe("Template Wrapper End to End Tests", () => { + + let template: App.Template; + let wrapperUri: string; + + beforeAll(() => { + const wrapperPath: string = path.join(__dirname, "..", "..", ".."); + wrapperUri = `fs/${wrapperPath}/build`; + template = new App.Template(undefined, undefined, wrapperUri) + }) + + it("calls sampleMethod", async () => { + const expected: string = "polywrap"; + + const result = await template.sampleMethod({ arg: expected }) + + if (!result.ok) throw result.error; + expect(result.value.result).toEqual(expected); + }); +}); diff --git a/packages/templates/wasm/typescript/src/__tests__/integration.spec.ts b/packages/templates/wasm/typescript/src/__tests__/integration.spec.ts deleted file mode 100644 index 5793310246..0000000000 --- a/packages/templates/wasm/typescript/src/__tests__/integration.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { PolywrapClient } from "@polywrap/client-js"; -import path from "path"; - -jest.setTimeout(60000); - -describe("Template Wrapper End to End Tests", () => { - - const client: PolywrapClient = new PolywrapClient(); - let wrapUri = `file://${path.join(__dirname, "../../build")}`; - - it("invoke foo", async () => { - const result = await client.invoke({ - uri: wrapUri, - method: "foo", - args: { bar: "bar" } - }); - - expect(result.ok).toBeFalsy(); - if (result.ok) return; - expect(result.error?.toString()).toContain("Not implemented"); - }); -}); diff --git a/packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml b/packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml new file mode 100644 index 0000000000..c084aed0f0 --- /dev/null +++ b/packages/templates/wasm/typescript/src/__tests__/types/polywrap.app.yaml @@ -0,0 +1,9 @@ +format: 0.3.0 +project: + name: sample-typescript-type-generation + type: app/typescript +source: + schema: ./schema.graphql + import_abis: + - uri: "wrap://ens/sample.eth" + abi: "../../../build/wrap.info" diff --git a/packages/templates/wasm/typescript/src/__tests__/types/schema.graphql b/packages/templates/wasm/typescript/src/__tests__/types/schema.graphql new file mode 100644 index 0000000000..6d75bfc9bc --- /dev/null +++ b/packages/templates/wasm/typescript/src/__tests__/types/schema.graphql @@ -0,0 +1 @@ +#import * into Template from "wrap://ens/sample.eth" diff --git a/packages/templates/wasm/typescript/src/index.ts b/packages/templates/wasm/typescript/src/index.ts index fb25fe8ea7..135f6e6ba1 100644 --- a/packages/templates/wasm/typescript/src/index.ts +++ b/packages/templates/wasm/typescript/src/index.ts @@ -1,7 +1,9 @@ -import { Args_foo, ModuleBase } from "./wrap"; +import { Args_sampleMethod, SampleResult, ModuleBase } from "./wrap"; export class Module extends ModuleBase { - foo(args: Args_foo): string { - throw new Error("Not implemented"); + sampleMethod(args: Args_sampleMethod): SampleResult { + return { + result: args.arg, + }; } }