diff --git a/packages/cli/src/lib/project/manifests/app/languages.ts b/packages/cli/src/lib/project/manifests/app/languages.ts index fe2c9be239..9fa02320f8 100644 --- a/packages/cli/src/lib/project/manifests/app/languages.ts +++ b/packages/cli/src/lib/project/manifests/app/languages.ts @@ -6,6 +6,8 @@ export const appManifestLanguages = { "app/typescript": "app/typescript", "app/python": "app/python", "app/rust": "app/rust", + "app/kotlin": "app/kotlin", + "app/swift": "app/swift", }; export type AppManifestLanguages = typeof appManifestLanguages; @@ -28,6 +30,10 @@ export function appManifestLanguageToBindLanguage( return "app-py"; case "app/rust": return "app-rs"; + case "app/kotlin": + return "app-kt"; + case "app/swift": + return "app-swift"; default: throw Error( intlMsg.lib_language_unsupportedManifestLanguage({ diff --git a/packages/templates/wasm/rust/Cargo.toml b/packages/templates/wasm/rust/Cargo.toml index b5e4af31ea..457be6b146 100644 --- a/packages/templates/wasm/rust/Cargo.toml +++ b/packages/templates/wasm/rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "template-wasm-rs" +name = "template_wasm_rs" version = "0.1.0" description = "A Polywrap Wasm wrapper template written in Rust" authors = ["Polywrap"] @@ -7,11 +7,16 @@ repository = "https://github.com/polywrap/monorepo" license = "MIT" edition = "2021" +include = ["src"] + [dependencies] -polywrap-wasm-rs = { version = "~0.11.0-pre.4" } -polywrap_msgpack_serde = "~0.0.2-beta.5" +polywrap-wasm-rs = { version = "~0.11.2" } +polywrap_msgpack_serde = "0.0.2-beta.7" serde = { version = "1.0", features = ["derive"] } +[dev-dependencies] +polywrap = { version = "0.1.9-beta.2" } + [lib] crate-type = ["cdylib"] diff --git a/packages/templates/wasm/rust/jest.config.js b/packages/templates/wasm/rust/jest.config.js deleted file mode 100644 index 4a4c022f7b..0000000000 --- a/packages/templates/wasm/rust/jest.config.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - collectCoverage: false, - preset: "ts-jest", - testEnvironment: "node", - testMatch: ["**/__tests__/**/?(*.)+(spec|test).[jt]s?(x)"], - globals: { - "ts-jest": { - tsconfig: "tsconfig.json", - diagnostics: false, - }, - }, - testPathIgnorePatterns: [ - "/.polywrap/" - ], -}; diff --git a/packages/templates/wasm/rust/package.json b/packages/templates/wasm/rust/package.json index 767f33589e..5bb56df739 100644 --- a/packages/templates/wasm/rust/package.json +++ b/packages/templates/wasm/rust/package.json @@ -8,15 +8,11 @@ "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 ./src/__tests__/types/polywrap.app.yaml -g ./src/__tests__/types/wrap", + "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" }, "devDependencies": { - "@types/jest": "26.0.8", - "jest": "26.6.3", - "polywrap": "0.11.2", - "ts-jest": "26.5.4", - "typescript": "4.9.5" + "polywrap": "0.11.2" } } diff --git a/packages/templates/wasm/rust/polywrap.test.cue b/packages/templates/wasm/rust/polywrap.test.cue index a71f50ace0..72c37000a6 100644 --- a/packages/templates/wasm/rust/polywrap.test.cue +++ b/packages/templates/wasm/rust/polywrap.test.cue @@ -3,7 +3,7 @@ package e2e sampleMethod: { $0: { data: { - value: "polywrap" + value: "polywrap from sample_method" }, error?: _|_, } diff --git a/packages/templates/wasm/rust/src/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/rust/src/__tests__/e2e/integration.spec.ts deleted file mode 100644 index 55913c174a..0000000000 --- a/packages/templates/wasm/rust/src/__tests__/e2e/integration.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { PolywrapClient } from "@polywrap/client-js"; -import * as App from "../types/wrap"; -import path from "path"; - -jest.setTimeout(60000); - -describe("Template Wrapper End to End Tests", () => { - - const client: PolywrapClient = new PolywrapClient(); - let wrapperUri: string; - - beforeAll(() => { - const dirname: string = path.resolve(__dirname); - const wrapperPath: string = path.join(dirname, "..", "..", ".."); - wrapperUri = `fs/${wrapperPath}/build`; - }) - - it("calls sampleMethod", async () => { - const expected: string = "polywrap"; - - const result = await client.invoke({ - uri: wrapperUri, - method: "sampleMethod", - args: { arg: expected } - }); - - expect(result.ok).toBeTruthy(); - if (!result.ok) return; - expect(result.value.result).toEqual(expected); - }); -}); diff --git a/packages/templates/wasm/rust/src/__tests__/types/polywrap.app.yaml b/packages/templates/wasm/rust/src/__tests__/types/polywrap.app.yaml deleted file mode 100644 index c084aed0f0..0000000000 --- a/packages/templates/wasm/rust/src/__tests__/types/polywrap.app.yaml +++ /dev/null @@ -1,9 +0,0 @@ -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/rust/src/__tests__/types/schema.graphql b/packages/templates/wasm/rust/src/__tests__/types/schema.graphql deleted file mode 100644 index 6d75bfc9bc..0000000000 --- a/packages/templates/wasm/rust/src/__tests__/types/schema.graphql +++ /dev/null @@ -1 +0,0 @@ -#import * into Template from "wrap://ens/sample.eth" diff --git a/packages/templates/wasm/rust/src/lib.rs b/packages/templates/wasm/rust/src/lib.rs index 6503dc136b..5141adeb94 100644 --- a/packages/templates/wasm/rust/src/lib.rs +++ b/packages/templates/wasm/rust/src/lib.rs @@ -4,7 +4,7 @@ pub use wrap::*; impl ModuleTrait for Module { fn sample_method(args: ArgsSampleMethod) -> Result { return Ok(SampleResult { - result: args.arg + result: format!("{} from sample_method", args.arg), }); } } diff --git a/packages/templates/wasm/rust/tests/it/mod.rs b/packages/templates/wasm/rust/tests/it/mod.rs new file mode 100644 index 0000000000..a94a2104e7 --- /dev/null +++ b/packages/templates/wasm/rust/tests/it/mod.rs @@ -0,0 +1 @@ +pub mod module; \ 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 new file mode 100644 index 0000000000..a738738bbc --- /dev/null +++ b/packages/templates/wasm/rust/tests/it/module.rs @@ -0,0 +1,14 @@ +use crate::types::wrap::types::{ + TemplateModule, + TemplateModuleArgsSampleMethod +}; + +#[test] +fn sample_method() { + let args = TemplateModuleArgsSampleMethod { + arg: "input data".to_string(), + }; + let template: TemplateModule = TemplateModule::new(None, None, None); + let response = template.sample_method(&args, None, None, None).unwrap(); + assert_eq!(response.result, "input data from sample_method"); +} diff --git a/packages/templates/wasm/rust/tests/mod.rs b/packages/templates/wasm/rust/tests/mod.rs new file mode 100644 index 0000000000..e727a250b9 --- /dev/null +++ b/packages/templates/wasm/rust/tests/mod.rs @@ -0,0 +1,2 @@ +mod it; +mod types; \ No newline at end of file diff --git a/packages/templates/wasm/rust/tests/types/mod.rs b/packages/templates/wasm/rust/tests/types/mod.rs new file mode 100644 index 0000000000..9fd51ef761 --- /dev/null +++ b/packages/templates/wasm/rust/tests/types/mod.rs @@ -0,0 +1 @@ +pub mod wrap; \ No newline at end of file diff --git a/packages/templates/wasm/rust/tests/types/polywrap.app.graphql b/packages/templates/wasm/rust/tests/types/polywrap.app.graphql new file mode 100644 index 0000000000..f3741e82c8 --- /dev/null +++ b/packages/templates/wasm/rust/tests/types/polywrap.app.graphql @@ -0,0 +1 @@ +#import * into Template from "fs/build" \ No newline at end of file diff --git a/packages/templates/wasm/rust/tests/types/polywrap.app.yaml b/packages/templates/wasm/rust/tests/types/polywrap.app.yaml new file mode 100644 index 0000000000..5f9fbba0da --- /dev/null +++ b/packages/templates/wasm/rust/tests/types/polywrap.app.yaml @@ -0,0 +1,6 @@ +format: 0.3.0 +project: + name: template-wasm-rs-app-types + type: app/rust +source: + schema: ./polywrap.app.graphql diff --git a/packages/templates/wasm/rust/tsconfig.json b/packages/templates/wasm/rust/tsconfig.json deleted file mode 100644 index 75bfa86f2e..0000000000 --- a/packages/templates/wasm/rust/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compilerOptions": { - "lib": [ - "es2015", - "es5", - "dom" - ], - "esModuleInterop": true, - "outDir": "build", - "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, - "experimentalDecorators": true - }, - "typeAcquisition": { "include": ["jest"] } -} \ No newline at end of file