Skip to content

Commit

Permalink
Merge pull request #438 from polywrap/prealpha-dev
Browse files Browse the repository at this point in the history
Prep 0.0.1-prealpha.32
  • Loading branch information
dOrgJelli authored Aug 19, 2021
2 parents 6d0d2cc + bcedf27 commit 087bf9e
Show file tree
Hide file tree
Showing 154 changed files with 4,782 additions and 1,099 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Web3API 0.0.1-prealpha.32
## Features
* Improved the plugin developer experience by creating a new `w3 plugin codegen` command, which generated types based on the plugin's schema. For an example of how this works, see the updated plugin template project by running `w3 create plugin typescript my-plugin`.
* `@web3api/cli`: Refactored the `w3 codegen` command, making its default behavior the generation of types for Web3APIs. It's "old" behavior of loading a custom generation script is now usable through the `--custom` option.

## Bugs
* `@web3api/cli`: Properly validate all required Wasm exports when compiling Web3APIs.

# Web3API 0.0.1-prealpha.31
## Features
* Use Binaryen's Asyncify to support async Wasm import calls. Deprecate the Wasm threading model we were using previously. This now means that the client now supports all browsers, as it no longer requires `SharedArrayBuffer` & the `atomics` library.
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.31
0.0.1-prealpha.32
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"clean": "npx rimraf ./**/node_modules ./**/build ./**/coverage ./**/.w3",
"build": "lerna run build --no-private --ignore @web3api/cli* --ignore @web3api/react && lerna run build --scope @web3api/client-js --scope @web3api/react && lerna run build --scope @web3api/cli",
"lint": "lerna run lint --ignore @web3api/uts46-plugin-js",
"lint:fix": "lerna run lint -- --fix",
"lint:fix": "lerna run lint --ignore @web3api/uts46-plugin-js -- --fix",
"lint:ci": "yarn lint",
"test": "lerna run test --no-private --ignore @web3api/client-js && lerna run test --scope @web3api/client-js",
"test:ci": "lerna run test:ci --no-private --ignore @web3api/client-js && lerna run test:ci --scope @web3api/client-js",
Expand Down
1 change: 0 additions & 1 deletion packages/apis/uniswapv2/src/query/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import { Query, StaticTxResult } into Ethereum from "w3://ens/ethereum.web3api.eth"
#import { Query } into SHA3 from "w3://ens/sha3.web3api.eth"
#import { ChainId, TradeType, Rounding, Currency, Token, TokenAmount, TradeOptions, Pair, Route, Trade, BestTradeOptions, SwapParameters, TxOverrides } from "../common/schema.graphql"
#import { Query, LogLevel } into Logger from "w3://w3/logger"

type Query {

Expand Down
2 changes: 1 addition & 1 deletion packages/apis/uniswapv2/web3api.build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
format: 0.0.1-prealpha.2
format: 0.0.1-prealpha.1
config:
node_version: "14.16.0"
include:
Expand Down
37 changes: 33 additions & 4 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
"commands_build_uriViewers": "URI Viewers",
"commands_codegen_description": "Auto-generate API Types",
"commands_codegen_error_domain": "domain",
"commands_codegen_error_customScriptMissingPath": "{option} option missing {argument} argument",
"commands_codegen_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_codegen_options_e_address": "address",
"commands_codegen_options_genFile": "Generation file",
"commands_codegen_options_genFilePath": "Path to the generation file (default",
"commands_codegen_options_h": "Show usage information",
"commands_codegen_options_i": "IPFS node to load external schemas (default: dev-server's node)",
"commands_codegen_options_c": "Path to a custom generation script (JavaScript | TypeScript)",
"commands_codegen_options_i": "IPFS node to load external schemas (default: ipfs.io & localhost)",
"commands_codegen_options_i_node": "node",
"commands_codegen_options_m": "Path to the Web3API manifest file (default",
"commands_build_options_manifest": "manifest",
"commands_codegen_options_o": "Output directory for generated types (default: types/)",
"commands_codegen_options_o": "Output directory for custom generated types (default: 'types/')",
"commands_codegen_options_o_path": "path",
"commands_options_options": "options",
"commands_codegen_success": "Types were generated successfully",
Expand Down Expand Up @@ -64,6 +64,24 @@
"commands_create_readyPlugin": "You are ready to build a plugin into a Web3API",
"commands_create_readyProtocol": "You are ready to turn your protocol into a Web3API",
"commands_create_settingUp": "Setting everything up...",
"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_options_command": "command",
"commands_plugin_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_plugin_options_e_address": "address",
"commands_plugin_options_h": "Show usage information",
"commands_plugin_options_i": "IPFS node to load external schemas (default: dev-server's node)",
"commands_plugin_options_i_node": "node",
"commands_plugin_options_lang": "lang",
"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_query_description": "Query Web3APIs using recipe scripts",
"commands_query_error_missingScript": "Required argument {script} is missing",
"commands_query_error_noApi": "API needs to be initialized",
Expand Down Expand Up @@ -92,9 +110,16 @@
"lib_codeGenerator_templateNoModify": "NOTE: This is generated by 'w3 codegen', DO NOT MODIFY",
"lib_codeGenerator_noRunMethod": "The generation file provided doesn't have the 'run' method.",
"lib_codeGenerator_noComposedSchema": "The schema does not exist, please define one.",
"lib_codeGenerator_typeInfoMissing": "The TypeInfo is missing from the composer output.",
"lib_compiler_compileError": "Failed to compile Web3API",
"lib_compiler_compileText": "Compile Web3API",
"lib_compiler_compileWarning": "Warnings while compiling Web3API",
"lib_compiler_codegenError": "Failed to generate Web3API schema bindings",
"lib_compiler_codegenText": "Codegen Web3API schema bindings",
"lib_compiler_codegenWarning": "Warnings while generating Web3API schema bindings",
"lib_compiler_compileWasmModulesError": "Failed to compile Wasm modules",
"lib_compiler_compileWasmModulesText": "Compile Wasm modules",
"lib_compiler_compileWasmModulesWarning": "Warnings while compiling Wasm modules",
"lib_compiler_failedSchemaReturn": "Schema composer failed to return a combined schema.",
"lib_compiler_noModulesToBuild": "No modules to build declared.",
"lib_compiler_missingSchema": "Missing schema definition for the module {name}",
Expand All @@ -106,6 +131,7 @@
"lib_compiler_noInvoke": "WASM module is missing the _w3_invoke export. This should never happen...",
"lib_compiler_dup_code_folder": "Duplicate code generation folder found `{directory}`. Please ensure each module file is located in a unique directory.",
"lib_compiler_missing_export": "{missingExport} is not exported from the WASM module `{moduleName}`",
"lib_compiler_cannotBuildInterfaceModules": "Cannot build modules for an Interface Web3API",
"lib_generators_projectGenerator_fallback": "Falling back to the local Yarn cache.",
"lib_generators_projectGenerator_offline": "You appear to be offline.",
"lib_helpers_manifest_loadError": "Failed to load manifest from {path}",
Expand All @@ -125,9 +151,12 @@
"lib_helpers_docker_projectFolderMissing": "Build image `{image}` missing /project folder",
"lib_helpers_docker_projectBuildFolderMissing": "Build image `{image}` missing build artifact `{artifact}` in folder /project/build",
"lib_helpers_parameters_unexpectedValue": "Unexpected value provided for one or more of {options}. See --help for more information.",
"lib_language_unsupportedManifestLanguage": "The manifest's language {language} is not supported.",
"lib_publishers_ipfsPublisher_urlMalformed": "IPFS URL Malformed",
"lib_project_invalid_build_language": "Unrecognized build language {language}. No default manifest found at {defaultPath}",
"lib_project_language_not_found": "Build language not found. Please include the `language` property in the manifest file.",
"lib_typescript_notInstalled": "Your project uses typescript, but it's not installed",
"lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed",
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",
"lib_docker_invalidImageId": "Invalid docker image ID returned: {imageId}"
}
37 changes: 33 additions & 4 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
"commands_build_uriViewers": "URI Viewers",
"commands_codegen_description": "Auto-generate API Types",
"commands_codegen_error_domain": "domain",
"commands_codegen_error_customScriptMissingPath": "{option} option missing {argument} argument",
"commands_codegen_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_codegen_options_e_address": "address",
"commands_codegen_options_genFile": "Generation file",
"commands_codegen_options_genFilePath": "Path to the generation file (default",
"commands_codegen_options_h": "Show usage information",
"commands_codegen_options_i": "IPFS node to load external schemas (default: dev-server's node)",
"commands_codegen_options_c": "Path to a custom generation script (JavaScript | TypeScript)",
"commands_codegen_options_i": "IPFS node to load external schemas (default: ipfs.io & localhost)",
"commands_codegen_options_i_node": "node",
"commands_codegen_options_m": "Path to the Web3API manifest file (default",
"commands_build_options_manifest": "manifest",
"commands_codegen_options_o": "Output directory for generated types (default: types/)",
"commands_codegen_options_o": "Output directory for custom generated types (default: 'types/')",
"commands_codegen_options_o_path": "path",
"commands_options_options": "options",
"commands_codegen_success": "Types were generated successfully",
Expand Down Expand Up @@ -64,6 +64,24 @@
"commands_create_readyPlugin": "You are ready to build a plugin into a Web3API",
"commands_create_readyProtocol": "You are ready to turn your protocol into a Web3API",
"commands_create_settingUp": "Setting everything up...",
"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_options_command": "command",
"commands_plugin_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_plugin_options_e_address": "address",
"commands_plugin_options_h": "Show usage information",
"commands_plugin_options_i": "IPFS node to load external schemas (default: dev-server's node)",
"commands_plugin_options_i_node": "node",
"commands_plugin_options_lang": "lang",
"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_query_description": "Query Web3APIs using recipe scripts",
"commands_query_error_missingScript": "Required argument {script} is missing",
"commands_query_error_noApi": "API needs to be initialized",
Expand Down Expand Up @@ -92,9 +110,16 @@
"lib_codeGenerator_templateNoModify": "NOTE: This is generated by 'w3 codegen', DO NOT MODIFY",
"lib_codeGenerator_noRunMethod": "The generation file provided doesn't have the 'run' method.",
"lib_codeGenerator_noComposedSchema": "The schema does not exist, please define one.",
"lib_codeGenerator_typeInfoMissing": "The TypeInfo is missing from the composer output.",
"lib_compiler_compileError": "Failed to compile Web3API",
"lib_compiler_compileText": "Compile Web3API",
"lib_compiler_compileWarning": "Warnings while compiling Web3API",
"lib_compiler_codegenError": "Failed to generate Web3API schema bindings",
"lib_compiler_codegenText": "Codegen Web3API schema bindings",
"lib_compiler_codegenWarning": "Warnings while generating Web3API schema bindings",
"lib_compiler_compileWasmModulesError": "Failed to compile Wasm modules",
"lib_compiler_compileWasmModulesText": "Compile Wasm modules",
"lib_compiler_compileWasmModulesWarning": "Warnings while compiling Wasm modules",
"lib_compiler_failedSchemaReturn": "Schema composer failed to return a combined schema.",
"lib_compiler_noModulesToBuild": "No modules to build declared.",
"lib_compiler_missingSchema": "Missing schema definition for the module {name}",
Expand All @@ -106,6 +131,7 @@
"lib_compiler_noInvoke": "WASM module is missing the _w3_invoke export. This should never happen...",
"lib_compiler_dup_code_folder": "Duplicate code generation folder found `{directory}`. Please ensure each module file is located in a unique directory.",
"lib_compiler_missing_export": "{missingExport} is not exported from the WASM module `{moduleName}`",
"lib_compiler_cannotBuildInterfaceModules": "Cannot build modules for an Interface Web3API",
"lib_generators_projectGenerator_fallback": "Falling back to the local Yarn cache.",
"lib_generators_projectGenerator_offline": "You appear to be offline.",
"lib_helpers_manifest_loadError": "Failed to load manifest from {path}",
Expand All @@ -125,9 +151,12 @@
"lib_helpers_docker_projectFolderMissing": "Build image `{image}` missing /project folder",
"lib_helpers_docker_projectBuildFolderMissing": "Build image `{image}` missing build artifact `{artifact}` in folder /project/build",
"lib_helpers_parameters_unexpectedValue": "Unexpected value provided for one or more of {options}. See --help for more information.",
"lib_language_unsupportedManifestLanguage": "The manifest's language {language} is not supported.",
"lib_publishers_ipfsPublisher_urlMalformed": "IPFS URL Malformed",
"lib_project_invalid_build_language": "Unrecognized build language {language}. No default manifest found at {defaultPath}",
"lib_project_language_not_found": "Build language not found. Please include the `language` property in the manifest file.",
"lib_typescript_notInstalled": "Your project uses typescript, but it's not installed",
"lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed",
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",
"lib_docker_invalidImageId": "Invalid docker image ID returned: {imageId}"
}
11 changes: 7 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
"build:envs": "copyfiles ./src/lib/build-envs/**/**/* ./build/lib/build-envs/ -u 3",
"prebuild": "ts-node ./scripts/generateIntlTypes.ts",
"lint": "eslint --color --ext .ts src/",
"test": "jest --passWithNoTests --runInBand --verbose",
"test:ci": "jest --passWithNoTests --runInBand --verbose",
"test:watch": "jest --watch --passWithNoTests --verbose"
"test": "cross-env TEST=true jest --passWithNoTests --runInBand --verbose",
"test:ci": "cross-env TEST=true jest --passWithNoTests --runInBand --verbose",
"test:watch": "cross-env TEST=true jest --watch --passWithNoTests --verbose"
},
"dependencies": {
"@formatjs/intl": "1.8.2",
"@web3api/asyncify-js": "0.0.1-prealpha.31",
"@web3api/client-js": "0.0.1-prealpha.31",
"@web3api/client-test-env": "0.0.1-prealpha.31",
"@web3api/core-js": "0.0.1-prealpha.31",
Expand Down Expand Up @@ -59,6 +60,8 @@
"@types/node": "12.7.11",
"@types/rimraf": "3.0.0",
"@web3api/test-env-js": "0.0.1-prealpha.31",
"cross-env": "7.0.3",
"dir-compare": "3.3.0",
"eslint-plugin-formatjs": "2.12.7",
"jest": "26.6.3",
"ts-jest": "26.5.4",
Expand All @@ -70,4 +73,4 @@
"publishConfig": {
"access": "public"
}
}
}
16 changes: 7 additions & 9 deletions packages/cli/src/__tests__/e2e/codegen.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import path from "path";
import { defaultGenerationFile, defaultManifest } from "../../commands/codegen";
import { defaultManifest } from "../../commands/codegen";
import { clearStyle, w3Cli } from "./utils";

import { runCLI } from "@web3api/test-env-js";
import rimraf from "rimraf";

const HELP = `
w3 codegen [<generation-file>] [options]
Generation file:
Path to the generation file (default: ${defaultGenerationFile})
w3 codegen [options]
Options:
-h, --help Show usage information
-m, --manifest-path <path> Path to the Web3API manifest file (default: ${defaultManifest.join(
" | "
)})
-i, --ipfs [<node>] IPFS node to load external schemas (default: dev-server's node)
-o, --output-dir <path> Output directory for generated types (default: types/)
-c, --custom <path> Path to a custom generation script (JavaScript | TypeScript)
-o, --output-dir <path> Output directory for custom generated types (default: 'types/')
-i, --ipfs [<node>] IPFS node to load external schemas (default: ipfs.io & localhost)
-e, --ens [<address>] ENS address to lookup external schemas (default: 0x0000...2e1e)
`;
Expand Down Expand Up @@ -64,7 +62,7 @@ ${HELP}`);

test("Should throw error for invalid generation file - wrong file", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["codegen", `web3api-invalid.gen.js`],
args: ["codegen", "--custom", `web3api-invalid.gen.js`],
cwd: projectRoot
}, w3Cli);

Expand All @@ -77,7 +75,7 @@ ${HELP}`);

test("Should throw error for invalid generation file - no run() method", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["codegen", `web3api-norun.gen.js`],
args: ["codegen", "--custom", `web3api-norun.gen.js`],
cwd: projectRoot
}, w3Cli);

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/__tests__/e2e/help.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ const HELP = `
help (h) -
test-env (t) Manage a test environment for Web3API
query (q) Query Web3APIs using recipe scripts
plugin (p) Build/generate types for the plugin
create (c) Create a new project with w3 CLI
codegen (g) Auto-generate API Types
build (b) Builds a Web3API and (optionally) uploads it to IPFS
`;

describe("e2e tests for no help", () => {
const projectRoot = path.resolve(__dirname, "../project/");

test("Should display the help content", async () => {
const { exitCode: code, stdout: output, stderr: error } = await runCLI({
args: ["help"],
Expand Down
Loading

0 comments on commit 087bf9e

Please sign in to comment.