Skip to content

Commit

Permalink
Merge pull request #719 from polywrap/prealpha-dev
Browse files Browse the repository at this point in the history
Prep 0.0.1-prealpha.66
  • Loading branch information
dOrgJelli authored Mar 4, 2022
2 parents 5bd8ac1 + d96ed53 commit 97d1d51
Show file tree
Hide file tree
Showing 18 changed files with 354 additions and 62 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Web3API 0.0.1-prealpha.66
## Features
* [PR-718](https://github.com/polywrap/monorepo/pull/718) `@web3api/cli`: `w3 plugin codegen` now outputs the plugin manifest to the build directory.
* [PR-695](https://github.com/polywrap/monorepo/pull/695) `@web3api/ethereum-plugin-js`: Added Query methods: `solidityPack`, `solidityKeccak256`, `soliditySha256`.

## Breaking Changes
* [PR-718](https://github.com/polywrap/monorepo/pull/718) `@web3api/cli`: `w3 plugin codegen` option `-s, --output-schema-path` changed to `-p, --publish-dir`.
* [PR-718](https://github.com/polywrap/monorepo/pull/718) `@web3api/cli`: `w3 plugin codegen` option `-t, --output-types-dir` changed to `-c, --codegen-dir`.

# Web3API 0.0.1-prealpha.65
## Bugs
* [PR-690](https://github.com/polywrap/monorepo/pull/690) `@web3api/http-plugin-js`: Better axios response header handling for lists.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1-prealpha.65
0.0.1-prealpha.66
9 changes: 4 additions & 5 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@
"commands_plugin_description": "Build/generate types for the plugin",
"commands_plugin_error_domain": "domain",
"commands_plugin_error_noCommand": "Please provide a command",
"commands_plugin_error_outputDirMissingPath": "{option} option missing {argument} argument",
"commands_plugin_options_build": "Build the plugin",
"commands_plugin_options_codegen": "Generate code for the plugin",
"commands_plugin_error_optionMissingArgument": "{option} option missing {argument} argument",
"commands_plugin_commands_codegen": "Generate code for the plugin",
"commands_plugin_options_command": "command",
"commands_plugin_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_plugin_options_e_address": "address",
Expand All @@ -80,8 +79,8 @@
"commands_plugin_options_langs": "langs",
"commands_plugin_options_m": "Path to the Web3API manifest file (default: {default})",
"commands_plugin_options_path": "path",
"commands_plugins_options_schema": "Output path for the built schema (default: {default})",
"commands_plugins_options_types": "Output directory for the generated types (default: {default})",
"commands_plugin_options_publish": "Output path for the built schema and manifest (default: {default})",
"commands_plugin_options_codegen": "Output directory for the generated types (default: {default})",
"commands_query_options_configPath": "config-path",
"commands_query_options_config": "Add custom configuration to the Web3ApiClient",
"commands_query_error_clientConfigMissingPath": "{option} option missing {argument} argument",
Expand Down
9 changes: 4 additions & 5 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@
"commands_plugin_description": "Build/generate types for the plugin",
"commands_plugin_error_domain": "domain",
"commands_plugin_error_noCommand": "Please provide a command",
"commands_plugin_error_outputDirMissingPath": "{option} option missing {argument} argument",
"commands_plugin_options_build": "Build the plugin",
"commands_plugin_options_codegen": "Generate code for the plugin",
"commands_plugin_error_optionMissingArgument": "{option} option missing {argument} argument",
"commands_plugin_commands_codegen": "Generate code for the plugin",
"commands_plugin_options_command": "command",
"commands_plugin_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_plugin_options_e_address": "address",
Expand All @@ -80,8 +79,8 @@
"commands_plugin_options_langs": "langs",
"commands_plugin_options_m": "Path to the Web3API manifest file (default: {default})",
"commands_plugin_options_path": "path",
"commands_plugins_options_schema": "Output path for the built schema (default: {default})",
"commands_plugins_options_types": "Output directory for the generated types (default: {default})",
"commands_plugin_options_publish": "Output path for the built schema and manifest (default: {default})",
"commands_plugin_options_codegen": "Output directory for the generated types (default: {default})",
"commands_query_options_configPath": "config-path",
"commands_query_options_config": "Add custom configuration to the Web3ApiClient",
"commands_query_error_clientConfigMissingPath": "{option} option missing {argument} argument",
Expand Down
32 changes: 17 additions & 15 deletions packages/cli/src/__tests__/e2e/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Options:
-m, --manifest-path <path> Path to the Web3API manifest file (default: ${defaultManifest.join(
" | "
)})
-s, --output-schema-path <path> Output path for the built schema (default: ./build/schema.graphql)
-t, --output-types-dir <path> Output directory for the generated types (default: ./src/w3)
-p, --publish-dir <path> Output path for the built schema and manifest (default: ./build)
-c, --codegen-dir <path> Output directory for the generated types (default: ./src/w3)
-i, --ipfs [<node>] IPFS node to load external schemas (default: dev-server's node)
-e, --ens [<address>] ENS address to lookup external schemas (default: 0x0000...2e1e)
Expand All @@ -42,7 +42,7 @@ describe("e2e tests for plugin command", () => {
test("Should throw error for invalid params - no command", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["plugin", "--output-dir"],
args: ["plugin", "--publish-dir"],
cwd: projectRoot,
}
);
Expand All @@ -53,33 +53,33 @@ describe("e2e tests for plugin command", () => {
${HELP}`);
});

test("Should throw error for invalid params - output-schema-path", async () => {
test("Should throw error for invalid params - publish-dir", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["plugin", "codegen", "--output-schema-path"],
args: ["plugin", "codegen", "--publish-dir"],
cwd: projectRoot,
}
);

expect(code).toEqual(0);
expect(error).toBe("");
expect(clearStyle(output))
.toEqual(`--output-schema-path option missing <path> argument
.toEqual(`--publish-dir option missing <path> argument
${HELP}`);
});

test("Should throw error for invalid params - output-types-dir", async () => {
test("Should throw error for invalid params - codegen-dir", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI(
{
args: ["plugin", "codegen", "--output-types-dir"],
args: ["plugin", "codegen", "--codegen-dir"],
cwd: projectRoot,
}
);

expect(code).toEqual(0);
expect(error).toBe("");
expect(clearStyle(output))
.toEqual(`--output-types-dir option missing <path> argument
.toEqual(`--codegen-dir option missing <path> argument
${HELP}`);
});

Expand All @@ -106,12 +106,14 @@ ${HELP}`);
}
);

expect(code).toEqual(0);
expect(error).toBe("");
expect(clearStyle(output)).toEqual(`- Generate types
- Manifest loaded from ./web3api.plugin.yaml
expect(code).toEqual(0);
expect(clearStyle(output)).toEqual(`- Manifest loaded from ./web3api.plugin.yaml
✔ Manifest loaded from ./web3api.plugin.yaml
- Generate types
✔ Generate types
- Manifest written to ./build/web3api.plugin.json
✔ Manifest written to ./build/web3api.plugin.json
`);

const expectedTypesResult = compareSync(
Expand All @@ -122,12 +124,12 @@ ${HELP}`);

expect(expectedTypesResult.differences).toBe(0);

const expectedSchemaResult = compareSync(
const expectedBuildResult = compareSync(
`${projectRoot}/build`,
`${projectRoot}/expected-schema`,
`${projectRoot}/expected-build`,
{ compareContent: true }
);

expect(expectedSchemaResult.differences).toBe(0);
expect(expectedBuildResult.differences).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ type Ethereum_Query @imported(
args: [String!]
): String!

solidityPack(
types: [String!]!
values: [String!]!
): String!

solidityKeccak256(
types: [String!]!
values: [String!]!
): String!

soliditySha256(
types: [String!]!
values: [String!]!
): String!

getSignerAddress(
connection: Ethereum_Connection
): String!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"format":"0.0.1-prealpha.1","language":"plugin/typescript","schema":"./schema.graphql"}
15 changes: 15 additions & 0 deletions packages/cli/src/__tests__/plugin/expected-types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ type Ethereum_Query @imported(
args: [String!]
): String!
solidityPack(
types: [String!]!
values: [String!]!
): String!
solidityKeccak256(
types: [String!]!
values: [String!]!
): String!
soliditySha256(
types: [String!]!
values: [String!]!
): String!
getSignerAddress(
connection: Ethereum_Connection
): String!
Expand Down
54 changes: 54 additions & 0 deletions packages/cli/src/__tests__/plugin/expected-types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ interface Ethereum_Query_Input_encodeFunction extends Record<string, unknown> {
args?: Array<String> | null;
}

/* URI: "ens/ethereum.web3api.eth" */
interface Ethereum_Query_Input_solidityPack extends Record<string, unknown> {
types: Array<String>;
values: Array<String>;
}

/* URI: "ens/ethereum.web3api.eth" */
interface Ethereum_Query_Input_solidityKeccak256 extends Record<string, unknown> {
types: Array<String>;
values: Array<String>;
}

/* URI: "ens/ethereum.web3api.eth" */
interface Ethereum_Query_Input_soliditySha256 extends Record<string, unknown> {
types: Array<String>;
values: Array<String>;
}

/* URI: "ens/ethereum.web3api.eth" */
interface Ethereum_Query_Input_getSignerAddress extends Record<string, unknown> {
connection?: Types.Ethereum_Connection | null;
Expand Down Expand Up @@ -294,6 +312,42 @@ export const Ethereum_Query = {
});
},

solidityPack: async (
input: Ethereum_Query_Input_solidityPack,
client: Client
): Promise<InvokeApiResult<String>> => {
return client.invoke<String>({
uri: "ens/ethereum.web3api.eth",
module: "query",
method: "solidityPack",
input
});
},

solidityKeccak256: async (
input: Ethereum_Query_Input_solidityKeccak256,
client: Client
): Promise<InvokeApiResult<String>> => {
return client.invoke<String>({
uri: "ens/ethereum.web3api.eth",
module: "query",
method: "solidityKeccak256",
input
});
},

soliditySha256: async (
input: Ethereum_Query_Input_soliditySha256,
client: Client
): Promise<InvokeApiResult<String>> => {
return client.invoke<String>({
uri: "ens/ethereum.web3api.eth",
module: "query",
method: "soliditySha256",
input
});
},

getSignerAddress: async (
input: Ethereum_Query_Input_getSignerAddress,
client: Client
Expand Down
30 changes: 30 additions & 0 deletions packages/cli/src/__tests__/project/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ type Ethereum_Query @imported(
args: [String!]
): String!
solidityPack(
types: [String!]!
values: [String!]!
): String!
solidityKeccak256(
types: [String!]!
values: [String!]!
): String!
soliditySha256(
types: [String!]!
values: [String!]!
): String!
getSignerAddress(
connection: Ethereum_Connection
): String!
Expand Down Expand Up @@ -605,6 +620,21 @@ type Ethereum_Query @imported(
args: [String!]
): String!
solidityPack(
types: [String!]!
values: [String!]!
): String!
solidityKeccak256(
types: [String!]!
values: [String!]!
): String!
soliditySha256(
types: [String!]!
values: [String!]!
): String!
getSignerAddress(
connection: Ethereum_Connection
): String!
Expand Down
Loading

0 comments on commit 97d1d51

Please sign in to comment.