Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small revisions and fixes For Wasm templates #1924

Open
wants to merge 8 commits into
base: origin-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/templates/wasm/assemblyscript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 0 additions & 8 deletions packages/templates/wasm/assemblyscript/polywrap.build.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions packages/templates/wasm/assemblyscript/polywrap.deploy.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions packages/templates/wasm/assemblyscript/polywrap.test.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions packages/templates/wasm/assemblyscript/polywrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ project:
source:
module: ./src/index.ts
schema: ./polywrap.graphql
extensions:
build: ./polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
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 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<App.Template_SampleResult>({
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);
});
});
11 changes: 0 additions & 11 deletions packages/templates/wasm/assemblyscript/workflows/validator.cue

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
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 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<App.Template_SampleResult>({
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);
});
});
6 changes: 2 additions & 4 deletions packages/templates/wasm/golang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 0 additions & 11 deletions packages/templates/wasm/golang/polywrap.test.cue

This file was deleted.

10 changes: 0 additions & 10 deletions packages/templates/wasm/golang/polywrap.test.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion packages/templates/wasm/golang/polywrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ project:
type: wasm/golang
source:
schema: ./polywrap.graphql
module: ./go.mod
module: ./go.mod
7 changes: 0 additions & 7 deletions packages/templates/wasm/interface/polywrap.deploy.yaml

This file was deleted.

6 changes: 2 additions & 4 deletions packages/templates/wasm/rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions packages/templates/wasm/rust/polywrap.build.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions packages/templates/wasm/rust/polywrap.deploy.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions packages/templates/wasm/rust/polywrap.test.cue

This file was deleted.

10 changes: 0 additions & 10 deletions packages/templates/wasm/rust/polywrap.test.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions packages/templates/wasm/rust/polywrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ project:
type: wasm/rust
source:
module: ./Cargo.toml
schema: ./polywrap.graphql
extensions:
build: ./polywrap.build.yaml
schema: ./polywrap.graphql
10 changes: 5 additions & 5 deletions packages/templates/wasm/rust/tests/it/module.rs
Original file line number Diff line number Diff line change
@@ -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");
}
9 changes: 5 additions & 4 deletions packages/templates/wasm/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions packages/templates/wasm/typescript/polywrap.build.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion packages/templates/wasm/typescript/polywrap.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
type Module {
foo(bar: String!): String!
sampleMethod(arg: String!): SampleResult!
}

type SampleResult {
result: String!
}
Original file line number Diff line number Diff line change
@@ -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);
});
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#import * into Template from "wrap://ens/sample.eth"
8 changes: 5 additions & 3 deletions packages/templates/wasm/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}
}