From 4c07b00f2c5bf7d4cb8e7145c3fba4d2e97f8723 Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Mon, 27 Jun 2022 10:06:44 -0700 Subject: [PATCH 1/6] finish renaming --- package.json | 4 +- packages/cli/src/__tests__/e2e/deploy.spec.ts | 2 +- .../lib/defaults/deploy-modules/ens/index.ts | 6 +- .../deploy-modules/local-dev-ens/index.ts | 10 +- .../src/__tests__/core/plugin-wrapper.spec.ts | 6 +- .../src/__tests__/core/wasm-wrapper.spec.ts | 6 +- .../js/client/src/__tests__/e2e/test-cases.ts | 16 +- .../src/__tests__/e2e/workflow-test-cases.ts | 12 +- .../js/client/src/plugin/PluginWrapper.ts | 24 +- packages/js/client/src/wasm/WasmWrapper.ts | 10 +- packages/js/client/src/wasm/imports.ts | 18 +- packages/js/client/src/wasm/types.ts | 8 +- packages/js/core/src/__tests__/Plugin.spec.ts | 4 +- .../js/core/src/__tests__/parse-query.spec.ts | 10 +- .../js/core/src/__tests__/resolveUri.spec.ts | 16 +- .../js/core/src/algorithms/parse-query.ts | 12 +- .../js/core/src/interfaces/uri-resolver.ts | 4 +- packages/js/core/src/types/Invoke.ts | 4 +- packages/js/core/src/types/Plugin.ts | 22 +- packages/js/core/src/types/Workflow.ts | 2 +- packages/js/core/src/workflow/JobRunner.ts | 12 +- packages/js/plugins/ens/src/index.ts | 12 +- .../ethereum/src/__tests__/e2e.spec.ts | 8 +- .../src/__tests__/integration/src/index.ts | 250 +++++++++--------- packages/js/plugins/ethereum/src/index.ts | 244 ++++++++--------- packages/js/plugins/file-system/src/index.ts | 50 ++-- packages/js/plugins/graph-node/src/index.ts | 7 +- .../__tests__/e2e/integration/src/index.ts | 16 +- packages/js/plugins/http/src/index.ts | 18 +- packages/js/plugins/ipfs/src/index.ts | 42 +-- packages/js/plugins/logger/src/index.ts | 18 +- packages/js/plugins/sha3/src/index.ts | 72 ++--- .../src/__tests__/e2e.spec.ts | 2 +- .../file-system-resolver/src/index.ts | 15 +- packages/js/plugins/uts46/src/index.ts | 18 +- .../src/__tests__/usePolywrapInvoke.spec.tsx | 20 +- packages/js/react/src/invoke.tsx | 10 +- packages/js/test-env/src/index.ts | 6 +- packages/js/tracing/src/index.ts | 4 +- .../imported/module-type/index-ts.mustache | 10 +- .../module-type/serialization-ts.mustache | 26 +- .../wasm-as/templates/index-ts.mustache | 4 +- .../templates/module-type/index-ts.mustache | 4 +- .../module-type/serialization-ts.mustache | 4 +- .../imported/module-type/mod-rs.mustache | 6 +- .../module-type/serialization-rs.mustache | 24 +- .../imported/object-type/mod-rs.mustache | 12 +- .../object-type/serialization-rs.mustache | 26 +- .../rust/wasm-rs/templates/mod-rs.mustache | 2 +- .../templates/module-type/mod-rs.mustache | 2 +- .../module-type/serialization-rs.mustache | 8 +- .../templates/module-type/wrapped-rs.mustache | 8 +- .../templates/object-type/mod-rs.mustache | 12 +- .../object-type/serialization-rs.mustache | 26 +- .../app-ts/templates/types-ts.mustache | 6 +- .../plugin-ts/templates/module-ts.mustache | 4 +- .../plugin-ts/templates/types-ts.mustache | 10 +- .../typescript/src/__tests__/e2e.spec.ts | 2 +- .../templates/plugin/typescript/src/index.ts | 6 +- .../wasm/assemblyscript/src/index.ts | 24 +- .../wasm/assemblyscript/workflows/e2e.yaml | 6 +- .../cases/bind/sanity/output/app-ts/types.ts | 12 +- .../bind/sanity/output/plugin-ts/module.ts | 8 +- .../bind/sanity/output/plugin-ts/types.ts | 12 +- .../sanity/output/wasm-as/Module/index.ts | 8 +- .../output/wasm-as/Module/serialization.ts | 8 +- .../imported/TestImport_Module/index.ts | 12 +- .../TestImport_Module/serialization.ts | 50 ++-- .../cases/bind/sanity/output/wasm-as/index.ts | 8 +- .../sanity/output/wasm-rs/another_type/mod.rs | 12 +- .../wasm-rs/another_type/serialization.rs | 18 +- .../sanity/output/wasm-rs/custom_type/mod.rs | 12 +- .../wasm-rs/custom_type/serialization.rs | 86 +++--- .../test_import_another_object/mod.rs | 12 +- .../serialization.rs | 12 +- .../imported/test_import_module/mod.rs | 12 +- .../test_import_module/serialization.rs | 46 ++-- .../imported/test_import_object/mod.rs | 12 +- .../test_import_object/serialization.rs | 28 +- .../cases/bind/sanity/output/wasm-rs/mod.rs | 4 +- .../bind/sanity/output/wasm-rs/module/mod.rs | 4 +- .../output/wasm-rs/module/serialization.rs | 16 +- .../sanity/output/wasm-rs/module/wrapped.rs | 16 +- .../001-sanity/expected/src/wrap/module.ts | 8 +- .../001-sanity/expected/src/wrap/types.ts | 162 ++++++------ .../expected/src/wrap/module.ts | 4 +- .../expected/src/wrap/types.ts | 162 ++++++------ .../003-env/expected/src/wrap/module.ts | 4 +- .../expected/src/wrap/module.ts | 8 +- .../wasm/build-cmd/001-sanity/src/index.ts | 6 +- .../build-cmd/004-default-build/src/index.ts | 6 +- .../005-default-dockerfile/src/index.ts | 6 +- .../006-custom-dockerfile/src/index.ts | 6 +- .../007-linked-packages/src/index.ts | 6 +- .../wasm/build-cmd/008-metadata/src/index.ts | 6 +- .../build-cmd/009-docker-buildx/src/index.ts | 6 +- .../cli/wasm/codegen/001-sanity/src/index.ts | 6 +- .../002-invalid-codegen-script/src/index.ts | 6 +- .../codegen/003-codegen-script/src/index.ts | 6 +- .../cli/wasm/deploy/001-sanity/src/index.ts | 4 +- .../cli/wasm/deploy/002-no-ext/src/index.ts | 4 +- .../deploy/003-invalid-config/src/index.ts | 4 +- .../wasm/deploy/004-fail-between/src/index.ts | 4 +- .../005-non-loaded-env-var/src/index.ts | 4 +- .../cases/cli/wasm/run/client-async-config.js | 4 +- .../cases/cli/wasm/run/client-async-config.ts | 4 +- .../cases/cli/wasm/run/client-config.js | 4 +- .../cases/cli/wasm/run/client-config.ts | 4 +- .../cases/cli/wasm/run/src/index.ts | 26 +- .../cases/cli/wasm/run/workflows/e2e.json | 6 +- .../cases/cli/wasm/run/workflows/e2e.yaml | 6 +- .../wrappers/wasm-as/asyncify/src/index.ts | 94 +++---- .../wasm-as/bigint-type/schema.graphql | 4 +- .../wrappers/wasm-as/bigint-type/src/index.ts | 14 +- .../wasm-as/bignumber-type/schema.graphql | 4 +- .../wasm-as/bignumber-type/src/index.ts | 14 +- .../wrappers/wasm-as/bytes-type/src/index.ts | 6 +- .../wrappers/wasm-as/enum-types/src/index.ts | 12 +- .../wasm-as/env-client-types/src/index.ts | 12 +- .../wrappers/wasm-as/env-types/src/index.ts | 4 +- .../test-use-getImpl/src/index.ts | 10 +- .../implementations/test-wrapper/src/index.ts | 10 +- .../test-implementation/src/index.ts | 10 +- .../test-wrapper/src/index.ts | 8 +- .../wasm-as/invalid-types/src/index.ts | 30 +-- .../wrappers/wasm-as/json-type/src/index.ts | 32 +-- .../wrappers/wasm-as/large-types/src/index.ts | 6 +- .../wrappers/wasm-as/map-type/src/index.ts | 12 +- .../wasm-as/number-types/src/index.ts | 48 ++-- .../wasm-as/object-types/src/index.ts | 36 +-- .../wasm-as/reserved-words/src/index.ts | 6 +- .../wasm-as/simple-env-types/src/index.ts | 4 +- .../wasm-as/simple-storage/src/index.ts | 40 +-- .../wrappers/wasm-rs/asyncify/src/lib.rs | 96 +++---- .../wasm-rs/bigint-type/schema.graphql | 4 +- .../wrappers/wasm-rs/bigint-type/src/lib.rs | 12 +- .../wasm-rs/bignumber-type/schema.graphql | 4 +- .../wasm-rs/bignumber-type/src/lib.rs | 12 +- .../wrappers/wasm-rs/bytes-type/src/lib.rs | 4 +- .../wrappers/wasm-rs/enum-types/src/lib.rs | 8 +- .../test-use-getImpl/src/lib.rs | 8 +- .../implementations/test-wrapper/src/lib.rs | 8 +- .../wrappers/wasm-rs/invalid-types/src/lib.rs | 20 +- .../wrappers/wasm-rs/json-type/src/lib.rs | 20 +- .../wrappers/wasm-rs/large-types/src/lib.rs | 4 +- .../wrappers/wasm-rs/map-type/src/lib.rs | 8 +- .../wrappers/wasm-rs/number-types/src/lib.rs | 24 +- .../wrappers/wasm-rs/object-types/src/lib.rs | 28 +- .../wasm-rs/simple-storage/src/lib.rs | 40 +-- .../as/assembly/implementation-subinvoke.ts | 6 +- packages/wasm/as/assembly/subinvoke.ts | 6 +- packages/wasm/rs/src/subinvoke.rs | 10 +- yarn.lock | 129 ++++----- 153 files changed, 1509 insertions(+), 1500 deletions(-) diff --git a/package.json b/package.json index cf8fd49faf..5a851e4c03 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "reset": "yarn clean && yarn && yarn build", "clean": "npx rimraf ./**/node_modules ./**/yarn.lock ./**/build ./**/coverage ./**/.polywrap", "dependencies:install": "cd dependencies && yarn", - "dependencies:link": "cd packages/schema/bind && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-bind", + "dependencies:link": "yarn link:schema:parse && yarn link:schema:bind", + "link:schema:parse": "cd packages/schema/parse && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-parse && cd ../", + "link:schema:bind": "cd packages/schema/bind && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-bind && cd ../", "preinstall": "yarn dependencies:install", "build": "yarn build:core && yarn dependencies:link && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli", "build:core": "lerna run build --no-private --ignore @polywrap/*-plugin-js --ignore polywrap --ignore @polywrap/client-js --ignore @polywrap/react --ignore @polywrap/test-env-js", diff --git a/packages/cli/src/__tests__/e2e/deploy.spec.ts b/packages/cli/src/__tests__/e2e/deploy.spec.ts index f9b7638d60..86a752935f 100644 --- a/packages/cli/src/__tests__/e2e/deploy.spec.ts +++ b/packages/cli/src/__tests__/e2e/deploy.spec.ts @@ -79,7 +79,7 @@ const setup = async (domainNames: string[]) => { const result = await client.invoke({ uri: ensWrapperUri, method: "registerDomainAndSubdomainsRecursively", - input: { + args: { domain: domainName, owner: signer.address, registrarAddress, diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts b/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts index ca332885d9..56fe4454a9 100644 --- a/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts +++ b/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts @@ -68,7 +68,7 @@ class ENSPublisher implements Deployer { const { data: resolver } = await client.invoke({ method: "getResolver", uri: ensWrapperUri, - input: { + args: { registryAddress: config.ensRegistryAddress, domain: config.domainName, connection: { @@ -90,7 +90,7 @@ class ENSPublisher implements Deployer { const { data: setContenthashData } = await client.invoke<{ hash: string }>({ method: "setContentHash", uri: ensWrapperUri, - input: { + args: { domain: config.domainName, cid: hash, resolverAddress: resolver, @@ -107,7 +107,7 @@ class ENSPublisher implements Deployer { await client.invoke({ method: "awaitTransaction", uri: ethereumPluginUri, - input: { + args: { txHash: setContenthashData.hash, confirmations: 1, timeout: 15000, diff --git a/packages/cli/src/lib/defaults/deploy-modules/local-dev-ens/index.ts b/packages/cli/src/lib/defaults/deploy-modules/local-dev-ens/index.ts index de86cf6747..b95f2ae297 100644 --- a/packages/cli/src/lib/defaults/deploy-modules/local-dev-ens/index.ts +++ b/packages/cli/src/lib/defaults/deploy-modules/local-dev-ens/index.ts @@ -49,7 +49,7 @@ class LocalDevENSPublisher implements Deployer { const { data: signer } = await client.invoke({ method: "getSignerAddress", uri: ethereumPluginUri, - input: { + args: { connection: { networkNameOrChainId: "testnet", }, @@ -70,7 +70,7 @@ class LocalDevENSPublisher implements Deployer { { method: "registerDomainAndSubdomainsRecursively", uri: ensWrapperUri, - input: { + args: { domain: config.domainName, owner: signer, resolverAddress: ensAddresses.resolverAddress, @@ -94,7 +94,7 @@ class LocalDevENSPublisher implements Deployer { await client.invoke({ method: "awaitTransaction", uri: ethereumPluginUri, - input: { + args: { txHash: registerData.hash, confirmations: 1, timeout: 15000, @@ -109,7 +109,7 @@ class LocalDevENSPublisher implements Deployer { const { data: setContenthashData } = await client.invoke<{ hash: string }>({ method: "setContentHash", uri: ensWrapperUri, - input: { + args: { domain: config.domainName, cid: hash, resolverAddress: ensAddresses.resolverAddress, @@ -126,7 +126,7 @@ class LocalDevENSPublisher implements Deployer { await client.invoke({ method: "awaitTransaction", uri: ethereumPluginUri, - input: { + args: { txHash: setContenthashData.hash, confirmations: 1, timeout: 15000, diff --git a/packages/js/client/src/__tests__/core/plugin-wrapper.spec.ts b/packages/js/client/src/__tests__/core/plugin-wrapper.spec.ts index 079bb8d3fd..eeda31926a 100644 --- a/packages/js/client/src/__tests__/core/plugin-wrapper.spec.ts +++ b/packages/js/client/src/__tests__/core/plugin-wrapper.spec.ts @@ -38,11 +38,11 @@ describe("plugin-wrapper", () => { return this.config.map; } - updateMap(input: { map: Map }): Map { - for (const key of input.map.keys()) { + updateMap(args: { map: Map }): Map { + for (const key of args.map.keys()) { this.config.map.set( key, - (this.config.map.get(key) || 0) + (input.map.get(key) || 0) + (this.config.map.get(key) || 0) + (args.map.get(key) || 0) ); } return this.config.map; diff --git a/packages/js/client/src/__tests__/core/wasm-wrapper.spec.ts b/packages/js/client/src/__tests__/core/wasm-wrapper.spec.ts index ad1719bfdc..f58ce78a34 100644 --- a/packages/js/client/src/__tests__/core/wasm-wrapper.spec.ts +++ b/packages/js/client/src/__tests__/core/wasm-wrapper.spec.ts @@ -90,7 +90,7 @@ describe("wasm-wrapper", () => { const result = await client.invoke({ uri: wrapperUri, method: "deployContract", - input: { + args: { connection: { networkNameOrChainId: "testnet", }, @@ -108,7 +108,7 @@ describe("wasm-wrapper", () => { const result = await client.invoke({ uri: wrapperUri, method: "deployContract", - input: { + args: { connection: { networkNameOrChainId: "testnet", }, @@ -142,7 +142,7 @@ describe("wasm-wrapper", () => { const result = await client.invoke({ uri: wrapperUri, method: "deployContract", - input: {}, + args: {}, config: { redirects, }, diff --git a/packages/js/client/src/__tests__/e2e/test-cases.ts b/packages/js/client/src/__tests__/e2e/test-cases.ts index 39493c523a..ddbf37950f 100644 --- a/packages/js/client/src/__tests__/e2e/test-cases.ts +++ b/packages/js/client/src/__tests__/e2e/test-cases.ts @@ -637,7 +637,7 @@ export const runJsonTypeTest = async ( const parseResponse = await client.invoke<{ parse: Json }>({ uri, method: "parse", - input: { + args: { value } }) @@ -652,7 +652,7 @@ export const runJsonTypeTest = async ( const stringifyResponse = await client.invoke<{ stringify: Json}>({ uri, method: "stringify", - input: { + args: { values } }) @@ -669,7 +669,7 @@ export const runJsonTypeTest = async ( }>({ uri, method: "stringifyObject", - input: { + args: { object, }, }); @@ -689,7 +689,7 @@ export const runJsonTypeTest = async ( }>({ uri, method: "methodJSON", - input: json + args: json }); const methodJSONResult = JSON.stringify(json); @@ -1126,7 +1126,7 @@ export const runMapTypeTest = async ( const returnMapResponse1 = await client.invoke>({ uri, method: "returnMap", - input: { + args: { map: mapClass, }, }); @@ -1136,7 +1136,7 @@ export const runMapTypeTest = async ( const returnMapResponse2 = await client.invoke>({ uri, method: "returnMap", - input: { + args: { map: mapRecord, }, }); @@ -1146,7 +1146,7 @@ export const runMapTypeTest = async ( const getKeyResponse1 = await client.invoke({ uri, method: "getKey", - input: { + args: { map: mapClass, key: "Hello", }, @@ -1157,7 +1157,7 @@ export const runMapTypeTest = async ( const getKeyResponse2 = await client.invoke({ uri, method: "getKey", - input: { + args: { map: mapRecord, key: "Heyo", }, diff --git a/packages/js/client/src/__tests__/e2e/workflow-test-cases.ts b/packages/js/client/src/__tests__/e2e/workflow-test-cases.ts index 50605b33db..a5f9227368 100644 --- a/packages/js/client/src/__tests__/e2e/workflow-test-cases.ts +++ b/packages/js/client/src/__tests__/e2e/workflow-test-cases.ts @@ -8,7 +8,7 @@ export const sanityWorkflow: Workflow = { { uri: "ens/testnet/simple-storage.eth", method: "deployContract", - input: { + args: { connection: null, }, }, @@ -19,7 +19,7 @@ export const sanityWorkflow: Workflow = { { uri: "ens/testnet/simple-storage.eth", method: "setData", - input: { + args: { address: "0xA57B8a5584442B467b4689F1144D269d096A3daF", value: 100, connection: null, @@ -28,7 +28,7 @@ export const sanityWorkflow: Workflow = { { uri: "ens/testnet/simple-storage.eth", method: "getData", - input: { + args: { address: "0xA57B8a5584442B467b4689F1144D269d096A3daF", connection: null, }, @@ -48,7 +48,7 @@ export const outPropWorkflow: Workflow = { { uri: "ens/testnet/simple-storage.eth", method: "deployContract", - input: { + args: { connection: null, }, }, @@ -59,7 +59,7 @@ export const outPropWorkflow: Workflow = { { uri: "ens/testnet/simple-storage.eth", method: "setData", - input: { + args: { address: "$cases.0.data", value: 100, connection: null, @@ -68,7 +68,7 @@ export const outPropWorkflow: Workflow = { { uri: "ens/testnet/simple-storage.eth", method: "getData", - input: { + args: { address: "$cases.0.data", connection: null, }, diff --git a/packages/js/client/src/plugin/PluginWrapper.ts b/packages/js/client/src/plugin/PluginWrapper.ts index b65d0fd690..acd84e01cc 100644 --- a/packages/js/client/src/plugin/PluginWrapper.ts +++ b/packages/js/client/src/plugin/PluginWrapper.ts @@ -30,7 +30,7 @@ export class PluginWrapper extends Wrapper { super(); Tracer.startSpan("PluginWrapper: constructor"); - Tracer.setAttribute("input", { + Tracer.setAttribute("args", { uri: this._uri, plugin: this._plugin, clientEnv: this._clientEnv, @@ -63,7 +63,7 @@ export class PluginWrapper extends Wrapper { ): Promise> { try { const { method, resultFilter } = options; - const input = options.input || {}; + const args = options.args || {}; const module = this._getInstance(); if (!module) { @@ -77,30 +77,30 @@ export class PluginWrapper extends Wrapper { // Sanitize & load the module's environment await this._sanitizeAndLoadEnv(client, module); - let jsInput: Record; + let jsArgs: Record; - // If the input is a msgpack buffer, deserialize it - if (input instanceof ArrayBuffer) { - const result = msgpackDecode(input); + // If the args are a msgpack buffer, deserialize it + if (args instanceof ArrayBuffer) { + const result = msgpackDecode(args); Tracer.addEvent("msgpack-decoded", result); if (typeof result !== "object") { throw new Error( - `PluginWrapper: decoded MsgPack input did not result in an object.\nResult: ${result}` + `PluginWrapper: decoded MsgPack args did not result in an object.\nResult: ${result}` ); } - jsInput = result as Record; + jsArgs = result as Record; } else { - jsInput = input; + jsArgs = args; } // Invoke the function try { const result = (await module._wrap_invoke( method, - jsInput, + jsArgs, client )) as TData; @@ -119,7 +119,7 @@ export class PluginWrapper extends Wrapper { `TEST_PLUGIN msgpack encode failure.` + `uri: ${this._uri.uri}\nmodule: ${module}\n` + `method: ${method}\n` + - `input: ${JSON.stringify(jsInput, null, 2)}\n` + + `args: ${JSON.stringify(jsArgs, null, 2)}\n` + `result: ${JSON.stringify(data, null, 2)}\n` + `exception: ${e}` ); @@ -143,7 +143,7 @@ export class PluginWrapper extends Wrapper { `PluginWrapper: invocation exception encountered.\n` + `uri: ${this._uri.uri}\nmodule: ${module}\n` + `method: ${method}\nresultFilter: ${resultFilter}\n` + - `input: ${JSON.stringify(jsInput, null, 2)}\n` + + `args: ${JSON.stringify(jsArgs, null, 2)}\n` + `exception: ${e.message}` ); } diff --git a/packages/js/client/src/wasm/WasmWrapper.ts b/packages/js/client/src/wasm/WasmWrapper.ts index 88899f1da5..56e82b8d80 100644 --- a/packages/js/client/src/wasm/WasmWrapper.ts +++ b/packages/js/client/src/wasm/WasmWrapper.ts @@ -79,7 +79,7 @@ export class WasmWrapper extends Wrapper { super(); Tracer.startSpan("WasmWrapper: constructor"); - Tracer.setAttribute("input", { + Tracer.setAttribute("args", { uri: this._uri, manifest: this._manifest, clientEnv: this._clientEnv, @@ -179,7 +179,7 @@ export class WasmWrapper extends Wrapper { ): Promise> { try { const { method, noDecode } = options; - const input = options.input || {}; + const args = options.args || {}; const wasm = await this._getWasmModule(client); const state: State = { @@ -193,14 +193,14 @@ export class WasmWrapper extends Wrapper { invokeResult: {} as InvokeResult, method, sanitizeEnv: {}, - args: input instanceof ArrayBuffer ? input : msgpackEncode(input), + args: args instanceof ArrayBuffer ? args : msgpackEncode(args), }; const abort = (message: string) => { throw new Error( `WasmWrapper: Wasm module aborted execution.\nURI: ${this._uri.uri}\n` + `Method: ${method}\n` + - `Input: ${JSON.stringify(input, null, 2)}\nMessage: ${message}.\n` + `Args: ${JSON.stringify(args, null, 2)}\nMessage: ${message}.\n` ); }; @@ -233,7 +233,7 @@ export class WasmWrapper extends Wrapper { `WasmWrapper: invocation exception encountered.\n` + `uri: ${this._uri.uri}\n` + `method: ${method}\n` + - `input: ${JSON.stringify(input, null, 2)}\n` + + `args: ${JSON.stringify(args, null, 2)}\n` + `exception: ${invokeResult.invokeError}` ); } diff --git a/packages/js/client/src/wasm/imports.ts b/packages/js/client/src/wasm/imports.ts index aa7de8db29..e717edf191 100644 --- a/packages/js/client/src/wasm/imports.ts +++ b/packages/js/client/src/wasm/imports.ts @@ -22,8 +22,8 @@ export const createImports = (config: { uriLen: u32, methodPtr: u32, methodLen: u32, - inputPtr: u32, - inputLen: u32 + argsPtr: u32, + argsLen: u32 ): Promise => { // Reset our state state.subinvoke.result = undefined; @@ -31,12 +31,12 @@ export const createImports = (config: { const uri = readString(memory.buffer, uriPtr, uriLen); const method = readString(memory.buffer, methodPtr, methodLen); - const input = readBytes(memory.buffer, inputPtr, inputLen); + const args = readBytes(memory.buffer, argsPtr, argsLen); const { data, error } = await client.invoke({ uri: uri, method: method, - input: input, + args: args, noDecode: true, }); @@ -94,22 +94,22 @@ export const createImports = (config: { implUriLen: u32, methodPtr: u32, methodLen: u32, - inputPtr: u32, - inputLen: u32 + argsPtr: u32, + argsLen: u32 ): Promise => { state.subinvokeImplementation.result = undefined; state.subinvokeImplementation.error = undefined; const implUri = readString(memory.buffer, implUriPtr, implUriLen); const method = readString(memory.buffer, methodPtr, methodLen); - const input = readBytes(memory.buffer, inputPtr, inputLen); + const args = readBytes(memory.buffer, argsPtr, argsLen); - state.subinvokeImplementation.args = [implUri, method, input]; + state.subinvokeImplementation.args = [implUri, method, args]; const { data, error } = await client.invoke({ uri: implUri, method: method, - input: input, + args: args, noDecode: true, }); diff --git a/packages/js/client/src/wasm/types.ts b/packages/js/client/src/wasm/types.ts index ad86c9c91f..0bff4033bd 100644 --- a/packages/js/client/src/wasm/types.ts +++ b/packages/js/client/src/wasm/types.ts @@ -16,8 +16,8 @@ export interface WrapImports extends WebAssembly.Imports { uriLen: u32, methodPtr: u32, methodLen: u32, - inputPtr: u32, - inputLen: u32 + argsPtr: u32, + argsLen: u32 ) => Promise; __wrap_subinvoke_result_len: () => u32; __wrap_subinvoke_result: (ptr: u32) => void; @@ -30,8 +30,8 @@ export interface WrapImports extends WebAssembly.Imports { implUriLen: u32, methodPtr: u32, methodLen: u32, - inputPtr: u32, - inputLen: u32 + argsPtr: u32, + argsLen: u32 ) => Promise; __wrap_subinvokeImplementation_result_len: () => u32; __wrap_subinvokeImplementation_result: (ptr: u32) => void; diff --git a/packages/js/core/src/__tests__/Plugin.spec.ts b/packages/js/core/src/__tests__/Plugin.spec.ts index 21ba125462..4274313cf8 100644 --- a/packages/js/core/src/__tests__/Plugin.spec.ts +++ b/packages/js/core/src/__tests__/Plugin.spec.ts @@ -16,10 +16,10 @@ const testPluginManifest: PluginPackageManifest = { }; class TestPluginModule extends PluginModule<{}> { - testQuery(_input: unknown, _client: Client): number { + testQuery(_args: unknown, _client: Client): number { return 5; } - testMutation(_input: unknown, _client: Client): Promise { + testMutation(_args: unknown, _client: Client): Promise { return Promise.resolve(true); } } diff --git a/packages/js/core/src/__tests__/parse-query.spec.ts b/packages/js/core/src/__tests__/parse-query.spec.ts index a789f1543f..f6debec582 100644 --- a/packages/js/core/src/__tests__/parse-query.spec.ts +++ b/packages/js/core/src/__tests__/parse-query.spec.ts @@ -40,7 +40,7 @@ describe("parseQuery", () => { someMethod: { uri: dummy, method: "someMethod", - input: { + args: { arg1: "hey", arg2: 4, arg3: true, @@ -145,7 +145,7 @@ describe("parseQuery", () => { someMethod: { uri: dummy, method: "someMethod", - input: { + args: { arg1: 4, arg2: ["hey", "there", [5.5]], arg3: { @@ -169,7 +169,7 @@ describe("parseQuery", () => { anotherMethod: { uri: dummy, method: "anotherMethod", - input: { + args: { arg: "hey", var: "var 1", }, @@ -285,7 +285,7 @@ describe("parseQuery", () => { ).not.toThrowError(/Missing variable/); }); - it("fails when duplicate input arguments are provided", () => { + it("fails when duplicate args arguments are provided", () => { const doc = createQueryDocument(` mutation { someMethod( @@ -296,7 +296,7 @@ describe("parseQuery", () => { `); expect(() => parseQuery(dummy, doc)).toThrowError( - /Duplicate input argument found/ + /Duplicate arguments found/ ); }); diff --git a/packages/js/core/src/__tests__/resolveUri.spec.ts b/packages/js/core/src/__tests__/resolveUri.spec.ts index 199c0fce2a..910a604a22 100644 --- a/packages/js/core/src/__tests__/resolveUri.spec.ts +++ b/packages/js/core/src/__tests__/resolveUri.spec.ts @@ -63,7 +63,7 @@ describe("resolveUri", () => { return Promise.resolve({ // @ts-ignore data: wrappers[uri]?.[options.method]( - options.input as Record, + options.args as Record, {} as Client ) as TData }); @@ -166,23 +166,23 @@ describe("resolveUri", () => { const ensWrapper = { tryResolveUri: ( - input: { authority: string; path: string }, + args: { authority: string; path: string }, _client: Client ) => { return { - uri: input.authority === "ens" ? "ipfs/QmHash" : undefined, + uri: args.authority === "ens" ? "ipfs/QmHash" : undefined, }; }, }; const ipfsWrapper = { tryResolveUri: ( - input: { authority: string; path: string }, + args: { authority: string; path: string }, _client: Client ) => { return { manifest: - input.authority === "ipfs" + args.authority === "ipfs" ? "format: 0.0.1-prealpha.9\ndog: cat" : undefined, }; @@ -191,12 +191,12 @@ describe("resolveUri", () => { const pluginWrapper = { tryResolveUri: ( - input: { authority: string; path: string }, + args: { authority: string; path: string }, _client: Client ) => { return { manifest: - input.authority === "my" ? "format: 0.0.1-prealpha.9" : undefined, + args.authority === "my" ? "format: 0.0.1-prealpha.9" : undefined, }; }, }; @@ -443,7 +443,7 @@ describe("resolveUri", () => { it("returns URI when it does not resolve to an Wrapper", async () => { const faultyIpfsWrapper = { tryResolveUri: ( - input: { authority: string; path: string }, + args: { authority: string; path: string }, _client: Client ) => { return { diff --git a/packages/js/core/src/algorithms/parse-query.ts b/packages/js/core/src/algorithms/parse-query.ts index 99c4de4000..9475403a6b 100644 --- a/packages/js/core/src/algorithms/parse-query.ts +++ b/packages/js/core/src/algorithms/parse-query.ts @@ -51,19 +51,19 @@ export const parseQuery = Tracer.traceFunc( ); } - // Get all input arguments + // Get al arguments const selectionArgs = selection.arguments; - const input: Record = {}; + const args: Record = {}; if (selectionArgs) { for (const arg of selectionArgs) { const name = arg.name.value; - if (input[name]) { - throw Error(`Duplicate input argument found: ${name}`); + if (args[name]) { + throw Error(`Duplicate arguments found: ${name}`); } - input[name] = extractValue(arg.value, variables); + args[name] = extractValue(arg.value, variables); } } @@ -78,7 +78,7 @@ export const parseQuery = Tracer.traceFunc( queryInvocations[invocationName] = { uri, method, - input, + args, resultFilter, }; } diff --git a/packages/js/core/src/interfaces/uri-resolver.ts b/packages/js/core/src/interfaces/uri-resolver.ts index 1473298488..46e30c52a6 100644 --- a/packages/js/core/src/interfaces/uri-resolver.ts +++ b/packages/js/core/src/interfaces/uri-resolver.ts @@ -20,7 +20,7 @@ export const Query = { return invoke({ uri: wrapper.uri, method: `tryResolveUri`, - input: { + args: { authority: uri.authority, path: uri.path, }, @@ -37,7 +37,7 @@ export const Query = { return invoke({ uri: wrapper.uri, method: "getFile", - input: { + args: { path, }, }); diff --git a/packages/js/core/src/types/Invoke.ts b/packages/js/core/src/types/Invoke.ts index 3e48582c8b..367eb5a09a 100644 --- a/packages/js/core/src/types/Invoke.ts +++ b/packages/js/core/src/types/Invoke.ts @@ -12,10 +12,10 @@ export interface InvokeOptions< method: string; /** - * Input arguments for the method, structured as a map, + * Arguments for the method, structured as a map, * removing the chance of incorrectly ordering arguments. */ - input?: Record | ArrayBuffer; + args?: Record | ArrayBuffer; /** * Filters the [[InvokeResult]] data properties. The key diff --git a/packages/js/core/src/types/Plugin.ts b/packages/js/core/src/types/Plugin.ts index 696798f879..2533e078eb 100644 --- a/packages/js/core/src/types/Plugin.ts +++ b/packages/js/core/src/types/Plugin.ts @@ -4,15 +4,15 @@ import { Uri, Client, MaybeAsync, executeMaybeAsyncFunction } from "."; /** * Invocable plugin method. * - * @param input Input arguments for the method, structured as + * @param args Arguments for the method, structured as * a map, removing the chance of incorrectly ordering arguments. * @param client The client instance requesting this invocation. * This client will be used for any sub-invokes that occur. */ export type PluginMethod< - TInput extends Record = Record, + TArgs extends Record = Record, TResult = unknown -> = (input: TInput, client: Client) => MaybeAsync; +> = (args: TArgs, client: Client) => MaybeAsync; export abstract class PluginModule< TConfig, @@ -54,10 +54,10 @@ export abstract class PluginModule< } public async _wrap_invoke< - TInput extends Record = Record, + TArgs extends Record = Record, TResult = unknown - >(method: string, input: TInput, client: Client): Promise { - const fn = this.getMethod(method); + >(method: string, args: TArgs, client: Client): Promise { + const fn = this.getMethod(method); if (!fn) { throw Error(`Plugin missing method "${method}"`); @@ -68,19 +68,19 @@ export abstract class PluginModule< } return await executeMaybeAsyncFunction( - fn.bind(this, input, client) + fn.bind(this, args, client) ); } public getMethod< - TInput extends Record = Record, + TArgs extends Record = Record, TResult = unknown - >(method: string): PluginMethod | undefined { + >(method: string): PluginMethod | undefined { const fn: - | PluginMethod + | PluginMethod | undefined = ((this as unknown) as Record< string, - PluginMethod + PluginMethod >)[method]; return fn; diff --git a/packages/js/core/src/types/Workflow.ts b/packages/js/core/src/types/Workflow.ts index d2668b3e22..f1c0b8df86 100644 --- a/packages/js/core/src/types/Workflow.ts +++ b/packages/js/core/src/types/Workflow.ts @@ -5,7 +5,7 @@ import { MaybeAsync } from "./MaybeAsync"; export type Step = { uri: TUri; method: string; - input: Record; + args: Record; config?: Partial; }; diff --git a/packages/js/core/src/workflow/JobRunner.ts b/packages/js/core/src/workflow/JobRunner.ts index d8ac17be06..9cfec9e880 100644 --- a/packages/js/core/src/workflow/JobRunner.ts +++ b/packages/js/core/src/workflow/JobRunner.ts @@ -49,12 +49,12 @@ export class JobRunner< const absoluteId = parentId ? `${parentId}.${jobId}.${i}` : `${jobId}.${i}`; - const input = this.resolveInput(absoluteId, step.input); + const args = this.resolveArgs(absoluteId, step.args); const result = await this.client.invoke({ uri: step.uri, method: step.method, config: step.config, - input: input, + args: args, }); this.jobOutput.set(absoluteId, result); @@ -92,9 +92,9 @@ export class JobRunner< } } - resolveInput( + resolveArgs( absCurStepId: string, - input: Record + args: Record ): Record { const index = absCurStepId.lastIndexOf("."); const curStepId = +absCurStepId.substring(index + 1); @@ -130,7 +130,7 @@ export class JobRunner< } throw new Error( - `Could not resolve input for step with stepId: ${absCurJobId}.${curStepId}` + `Could not resolve arguments for step with stepId: ${absCurJobId}.${curStepId}` ); } else if (Array.isArray(value)) return value.map(resolveValue); else if (typeof value === "object" && value !== null) { @@ -141,6 +141,6 @@ export class JobRunner< } else return value; } - return resolveValue(input) as Record; + return resolveValue(args) as Record; } } diff --git a/packages/js/plugins/ens/src/index.ts b/packages/js/plugins/ens/src/index.ts index 889676ea6e..df5263f469 100644 --- a/packages/js/plugins/ens/src/index.ts +++ b/packages/js/plugins/ens/src/index.ts @@ -1,8 +1,8 @@ import { Client, Module, - Input_tryResolveUri, - Input_getFile, + Args_tryResolveUri, + Args_getFile, UriResolver_MaybeUriOrManifest, Bytes, Ethereum_Module, @@ -37,15 +37,15 @@ export class EnsPlugin extends Module { } async tryResolveUri( - input: Input_tryResolveUri, + args: Args_tryResolveUri, client: Client ): Promise { - if (input.authority !== "ens") { + if (args.authority !== "ens") { return null; } try { - const cid = await this.ensToCID(input.path, client); + const cid = await this.ensToCID(args.path, client); if (!cid) { return null; @@ -63,7 +63,7 @@ export class EnsPlugin extends Module { return { uri: null, manifest: null }; } - getFile(_input: Input_getFile, _client: Client): Bytes | null { + getFile(_args: Args_getFile, _client: Client): Bytes | null { return null; } diff --git a/packages/js/plugins/ethereum/src/__tests__/e2e.spec.ts b/packages/js/plugins/ethereum/src/__tests__/e2e.spec.ts index 056eb7bf15..304fc03c92 100644 --- a/packages/js/plugins/ethereum/src/__tests__/e2e.spec.ts +++ b/packages/js/plugins/ethereum/src/__tests__/e2e.spec.ts @@ -180,7 +180,7 @@ describe("Ethereum Plugin", () => { const response = await client.invoke({ uri, method: "getBalance", - input: { + args: { address: signerAddressQuery.data, }, }); @@ -286,7 +286,7 @@ describe("Ethereum Plugin", () => { const result = await client.invoke({ uri: uri, method: "solidityPack", - input: { + args: { types, values, }, @@ -317,7 +317,7 @@ describe("Ethereum Plugin", () => { const result = await client.invoke({ uri: uri, method: "solidityKeccak256", - input: { + args: { types, values, }, @@ -348,7 +348,7 @@ describe("Ethereum Plugin", () => { const result = await client.invoke({ uri: uri, method: "soliditySha256", - input: { + args: { types, values, }, diff --git a/packages/js/plugins/ethereum/src/__tests__/integration/src/index.ts b/packages/js/plugins/ethereum/src/__tests__/integration/src/index.ts index dfdf2d05c2..996b86aaed 100644 --- a/packages/js/plugins/ethereum/src/__tests__/integration/src/index.ts +++ b/packages/js/plugins/ethereum/src/__tests__/integration/src/index.ts @@ -4,293 +4,293 @@ import { Ethereum_StaticTxResult, Ethereum_TxReceipt, Ethereum_Network, - Input_callContractView, - Input_callContractStatic, - Input_encodeParams, - Input_encodeFunction, - Input_solidityPack, - Input_solidityKeccak256, - Input_soliditySha256, - Input_getSignerAddress, - Input_getSignerBalance, - Input_getSignerTransactionCount, - Input_getGasPrice, - Input_estimateTransactionGas, - Input_estimateContractCallGas, - Input_checkAddress, - Input_toWei, - Input_toEth, - Input_awaitTransaction, - Input_waitForEvent, - Input_getNetwork, - Input_getBalance, + Args_callContractView, + Args_callContractStatic, + Args_encodeParams, + Args_encodeFunction, + Args_solidityPack, + Args_solidityKeccak256, + Args_soliditySha256, + Args_getSignerAddress, + Args_getSignerBalance, + Args_getSignerTransactionCount, + Args_getGasPrice, + Args_estimateTransactionGas, + Args_estimateContractCallGas, + Args_checkAddress, + Args_toWei, + Args_toEth, + Args_awaitTransaction, + Args_waitForEvent, + Args_getNetwork, + Args_getBalance, Ethereum_TxResponse, - Input_callContractMethod, - Input_callContractMethodAndWait, - Input_deployContract, - Input_sendRPC, - Input_sendTransaction, - Input_sendTransactionAndWait, - Input_signMessage + Args_callContractMethod, + Args_callContractMethodAndWait, + Args_deployContract, + Args_sendRPC, + Args_sendTransaction, + Args_sendTransactionAndWait, + Args_signMessage } from "./wrap"; import { BigInt } from "@polywrap/wasm-as"; export function callContractView( - input: Input_callContractView + args: Args_callContractView ): string { return Ethereum_Module.callContractView({ - address: input.address, - method: input.method, - args: input.args, - connection: input.connection + address: args.address, + method: args.method, + args: args.args, + connection: args.connection }).unwrap(); } export function callContractStatic( - input: Input_callContractStatic + args: Args_callContractStatic ): Ethereum_StaticTxResult { return Ethereum_Module.callContractStatic({ - address: input.address, - method: input.method, - args: input.args, - connection: input.connection, - txOverrides: input.txOverrides + address: args.address, + method: args.method, + args: args.args, + connection: args.connection, + txOverrides: args.txOverrides }).unwrap(); } export function getBalance( - input: Input_getBalance + args: Args_getBalance ): BigInt { return Ethereum_Module.getBalance({ - address: input.address, - blockTag: input.blockTag, - connection: input.connection + address: args.address, + blockTag: args.blockTag, + connection: args.connection }).unwrap(); } export function encodeParams( - input: Input_encodeParams + args: Args_encodeParams ): string { return Ethereum_Module.encodeParams({ - types: input.types, - values: input.values + types: args.types, + values: args.values }).unwrap(); } export function encodeFunction( - input: Input_encodeFunction + args: Args_encodeFunction ): string { return Ethereum_Module.encodeFunction({ - method: input.method, - args: input.args + method: args.method, + args: args.args }).unwrap(); } export function solidityPack( - input: Input_solidityPack + args: Args_solidityPack ): string { return Ethereum_Module.solidityPack({ - types: input.types, - values: input.values + types: args.types, + values: args.values }).unwrap(); } export function solidityKeccak256( - input: Input_solidityKeccak256 + args: Args_solidityKeccak256 ): string { return Ethereum_Module.solidityKeccak256({ - types: input.types, - values: input.values + types: args.types, + values: args.values }).unwrap(); } export function soliditySha256( - input: Input_soliditySha256 + args: Args_soliditySha256 ): string { return Ethereum_Module.soliditySha256({ - types: input.types, - values: input.values + types: args.types, + values: args.values }).unwrap(); } export function getSignerAddress( - input: Input_getSignerAddress + args: Args_getSignerAddress ): string { return Ethereum_Module.getSignerAddress({ - connection: input.connection + connection: args.connection }).unwrap(); } export function getSignerBalance( - input: Input_getSignerBalance + args: Args_getSignerBalance ): BigInt { return Ethereum_Module.getSignerBalance({ - blockTag: input.blockTag, - connection: input.connection + blockTag: args.blockTag, + connection: args.connection }).unwrap(); } export function getSignerTransactionCount( - input: Input_getSignerTransactionCount + args: Args_getSignerTransactionCount ): BigInt { return Ethereum_Module.getSignerTransactionCount({ - blockTag: input.blockTag, - connection: input.connection + blockTag: args.blockTag, + connection: args.connection }).unwrap(); } export function getGasPrice( - input: Input_getGasPrice + args: Args_getGasPrice ): BigInt { return Ethereum_Module.getGasPrice({ - connection: input.connection + connection: args.connection }).unwrap(); } export function estimateTransactionGas( - input: Input_estimateTransactionGas + args: Args_estimateTransactionGas ): BigInt { return Ethereum_Module.estimateTransactionGas({ - tx: input.tx, - connection: input.connection + tx: args.tx, + connection: args.connection }).unwrap(); } export function estimateContractCallGas( - input: Input_estimateContractCallGas + args: Args_estimateContractCallGas ): BigInt { return Ethereum_Module.estimateContractCallGas({ - address: input.address, - method: input.method, - args: input.args, - connection: input.connection, - txOverrides: input.txOverrides + address: args.address, + method: args.method, + args: args.args, + connection: args.connection, + txOverrides: args.txOverrides }).unwrap(); } export function checkAddress( - input: Input_checkAddress + args: Args_checkAddress ): bool { return Ethereum_Module.checkAddress({ - address: input.address + address: args.address }).unwrap(); } export function toWei( - input: Input_toWei + args: Args_toWei ): BigInt { return Ethereum_Module.toWei({ - eth: input.eth + eth: args.eth }).unwrap(); } export function toEth( - input: Input_toEth + args: Args_toEth ): String { return Ethereum_Module.toEth({ - wei: input.wei + wei: args.wei }).unwrap(); } export function awaitTransaction( - input: Input_awaitTransaction + args: Args_awaitTransaction ): Ethereum_TxReceipt { return Ethereum_Module.awaitTransaction({ - txHash: input.txHash, - confirmations: input.confirmations, - timeout: input.timeout, - connection: input.connection + txHash: args.txHash, + confirmations: args.confirmations, + timeout: args.timeout, + connection: args.connection }).unwrap(); } export function waitForEvent( - input: Input_waitForEvent + args: Args_waitForEvent ): Ethereum_EventNotification { return Ethereum_Module.waitForEvent({ - address: input.address, - event: input.event, - args: input.args, - timeout: input.timeout, - connection: input.connection + address: args.address, + event: args.event, + args: args.args, + timeout: args.timeout, + connection: args.connection }).unwrap(); } export function getNetwork( - input: Input_getNetwork + args: Args_getNetwork ): Ethereum_Network { return Ethereum_Module.getNetwork({ - connection: input.connection + connection: args.connection }).unwrap(); } export function callContractMethod( - input: Input_callContractMethod + args: Args_callContractMethod ): Ethereum_TxResponse { return Ethereum_Module.callContractMethod({ - address: input.address, - method: input.method, - args: input.args, - connection: input.connection, - txOverrides: input.txOverrides + address: args.address, + method: args.method, + args: args.args, + connection: args.connection, + txOverrides: args.txOverrides }).unwrap(); } export function callContractMethodAndWait( - input: Input_callContractMethodAndWait + args: Args_callContractMethodAndWait ): Ethereum_TxReceipt { return Ethereum_Module.callContractMethodAndWait({ - address: input.address, - method: input.method, - args: input.args, - connection: input.connection, - txOverrides: input.txOverrides + address: args.address, + method: args.method, + args: args.args, + connection: args.connection, + txOverrides: args.txOverrides }).unwrap(); } export function sendTransaction( - input: Input_sendTransaction + args: Args_sendTransaction ): Ethereum_TxResponse { return Ethereum_Module.sendTransaction({ - tx: input.tx, - connection: input.connection + tx: args.tx, + connection: args.connection }).unwrap(); } export function sendTransactionAndWait( - input: Input_sendTransactionAndWait + args: Args_sendTransactionAndWait ): Ethereum_TxReceipt { return Ethereum_Module.sendTransactionAndWait({ - tx: input.tx, - connection: input.connection + tx: args.tx, + connection: args.connection }).unwrap(); } export function deployContract( - input: Input_deployContract + args: Args_deployContract ): string { return Ethereum_Module.deployContract({ - abi: input.abi, - bytecode: input.bytecode, - args: input.args, - connection: input.connection + abi: args.abi, + bytecode: args.bytecode, + args: args.args, + connection: args.connection }).unwrap(); } export function signMessage( - input: Input_signMessage + args: Args_signMessage ): string { return Ethereum_Module.signMessage({ - message: input.message, - connection: input.connection + message: args.message, + connection: args.connection }).unwrap(); } export function sendRPC( - input: Input_sendRPC + args: Args_sendRPC ): string | null { return Ethereum_Module.sendRPC({ - method: input.method, - params: input.params, - connection: input.connection + method: args.method, + params: args.params, + connection: args.connection }).unwrap(); } diff --git a/packages/js/plugins/ethereum/src/index.ts b/packages/js/plugins/ethereum/src/index.ts index 9077be5239..485adf64f6 100644 --- a/packages/js/plugins/ethereum/src/index.ts +++ b/packages/js/plugins/ethereum/src/index.ts @@ -1,33 +1,33 @@ import { Client, Module, - Input_callContractView, - Input_callContractStatic, - Input_getBalance, - Input_encodeParams, - Input_encodeFunction, - Input_solidityPack, - Input_solidityKeccak256, - Input_soliditySha256, - Input_getSignerAddress, - Input_getSignerBalance, - Input_getSignerTransactionCount, - Input_getGasPrice, - Input_estimateTransactionGas, - Input_estimateContractCallGas, - Input_checkAddress, - Input_toWei, - Input_toEth, - Input_waitForEvent, - Input_awaitTransaction, - Input_getNetwork, - Input_callContractMethod, - Input_callContractMethodAndWait, - Input_deployContract, - Input_sendRPC, - Input_sendTransaction, - Input_sendTransactionAndWait, - Input_signMessage, + Args_callContractView, + Args_callContractStatic, + Args_getBalance, + Args_encodeParams, + Args_encodeFunction, + Args_solidityPack, + Args_solidityKeccak256, + Args_soliditySha256, + Args_getSignerAddress, + Args_getSignerBalance, + Args_getSignerTransactionCount, + Args_getGasPrice, + Args_estimateTransactionGas, + Args_estimateContractCallGas, + Args_checkAddress, + Args_toWei, + Args_toEth, + Args_waitForEvent, + Args_awaitTransaction, + Args_getNetwork, + Args_callContractMethod, + Args_callContractMethodAndWait, + Args_deployContract, + Args_sendRPC, + Args_sendTransaction, + Args_sendTransactionAndWait, + Args_signMessage, TxResponse, BigInt, StaticTxResult, @@ -79,39 +79,39 @@ export class EthereumPlugin extends Module { } async callContractView( - input: Input_callContractView, + args: Args_callContractView, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); const contract = connection.getContract( - input.address, - [input.method], + args.address, + [args.method], false ); const funcs = Object.keys(contract.interface.functions); - const res = await contract[funcs[0]](...parseArgs(input.args)); + const res = await contract[funcs[0]](...parseArgs(args.args)); return res.toString(); } async callContractStatic( - input: Input_callContractStatic, + args: Args_callContractStatic, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); - const contract = connection.getContract(input.address, [input.method]); + const connection = await this._getConnection(args.connection); + const contract = connection.getContract(args.address, [args.method]); const funcs = Object.keys(contract.interface.functions); try { const res = await contract.callStatic[funcs[0]]( - ...parseArgs(input.args), + ...parseArgs(args.args), { - gasPrice: input.gasPrice - ? ethers.BigNumber.from(input.gasPrice) + gasPrice: args.gasPrice + ? ethers.BigNumber.from(args.gasPrice) : undefined, - gasLimit: input.gasLimit - ? ethers.BigNumber.from(input.gasLimit) + gasLimit: args.gasLimit + ? ethers.BigNumber.from(args.gasLimit) : undefined, - value: input.value ? ethers.BigNumber.from(input.value) : undefined, + value: args.value ? ethers.BigNumber.from(args.value) : undefined, } ); return { @@ -126,115 +126,115 @@ export class EthereumPlugin extends Module { } } - async getBalance(input: Input_getBalance, _client: Client): Promise { - const connection = await this._getConnection(input.connection); + async getBalance(args: Args_getBalance, _client: Client): Promise { + const connection = await this._getConnection(args.connection); return ( await connection .getProvider() - .getBalance(input.address, input.blockTag || undefined) + .getBalance(args.address, args.blockTag || undefined) ).toString(); } async encodeParams( - input: Input_encodeParams, + args: Args_encodeParams, _client: Client ): Promise { - return defaultAbiCoder.encode(input.types, parseArgs(input.values)); + return defaultAbiCoder.encode(args.types, parseArgs(args.values)); } async encodeFunction( - input: Input_encodeFunction, + args: Args_encodeFunction, _client: Client ): Promise { - const functionInterface = ethers.Contract.getInterface([input.method]); + const functionInterface = ethers.Contract.getInterface([args.method]); return functionInterface.encodeFunctionData( functionInterface.functions[Object.keys(functionInterface.functions)[0]], - parseArgs(input.args) + parseArgs(args.args) ); } async solidityPack( - input: Input_solidityPack, + args: Args_solidityPack, _client: Client ): Promise { - return ethers.utils.solidityPack(input.types, parseArgs(input.values)); + return ethers.utils.solidityPack(args.types, parseArgs(args.values)); } async solidityKeccak256( - input: Input_solidityKeccak256, + args: Args_solidityKeccak256, _client: Client ): Promise { - return ethers.utils.solidityKeccak256(input.types, parseArgs(input.values)); + return ethers.utils.solidityKeccak256(args.types, parseArgs(args.values)); } async soliditySha256( - input: Input_soliditySha256, + args: Args_soliditySha256, _client: Client ): Promise { - return ethers.utils.soliditySha256(input.types, parseArgs(input.values)); + return ethers.utils.soliditySha256(args.types, parseArgs(args.values)); } async getSignerAddress( - input: Input_getSignerAddress, + args: Args_getSignerAddress, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); return await connection.getSigner().getAddress(); } async getSignerBalance( - input: Input_getSignerBalance, + args: Args_getSignerBalance, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); return ( - await connection.getSigner().getBalance(input.blockTag || undefined) + await connection.getSigner().getBalance(args.blockTag || undefined) ).toString(); } async getSignerTransactionCount( - input: Input_getSignerTransactionCount, + args: Args_getSignerTransactionCount, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); return ( await connection .getSigner() - .getTransactionCount(input.blockTag || undefined) + .getTransactionCount(args.blockTag || undefined) ).toString(); } async getGasPrice( - input: Input_getGasPrice, + args: Args_getGasPrice, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); return (await connection.getSigner().getGasPrice()).toString(); } async estimateTransactionGas( - input: Input_estimateTransactionGas, + args: Args_estimateTransactionGas, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); return ( - await connection.getSigner().estimateGas(Mapping.fromTxRequest(input.tx)) + await connection.getSigner().estimateGas(Mapping.fromTxRequest(args.tx)) ).toString(); } async estimateContractCallGas( - input: Input_estimateContractCallGas, + args: Args_estimateContractCallGas, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); - const contract = connection.getContract(input.address, [input.method]); + const connection = await this._getConnection(args.connection); + const contract = connection.getContract(args.address, [args.method]); const funcs = Object.keys(contract.interface.functions); - const gasPrice: string | null | undefined = input.txOverrides?.gasPrice; - const gasLimit: string | null | undefined = input.txOverrides?.gasLimit; - const value: string | null | undefined = input.txOverrides?.value; + const gasPrice: string | null | undefined = args.txOverrides?.gasPrice; + const gasLimit: string | null | undefined = args.txOverrides?.gasLimit; + const value: string | null | undefined = args.txOverrides?.value; - const gas = await contract.estimateGas[funcs[0]](...parseArgs(input.args), { + const gas = await contract.estimateGas[funcs[0]](...parseArgs(args.args), { gasPrice: gasPrice ? ethers.BigNumber.from(gasPrice) : undefined, gasLimit: gasLimit ? ethers.BigNumber.from(gasLimit) : undefined, value: value ? ethers.BigNumber.from(value) : undefined, @@ -244,10 +244,10 @@ export class EthereumPlugin extends Module { } async checkAddress( - input: Input_checkAddress, + args: Args_checkAddress, _client: Client ): Promise { - let address = input.address; + let address = args.address; try { // If the address is all upper-case, convert to lower case @@ -266,24 +266,24 @@ export class EthereumPlugin extends Module { } } - async toWei(input: Input_toWei, _client: Client): Promise { - const weiAmount = ethers.utils.parseEther(input.eth); + async toWei(args: Args_toWei, _client: Client): Promise { + const weiAmount = ethers.utils.parseEther(args.eth); return weiAmount.toString(); } - async toEth(input: Input_toEth, _client: Client): Promise { - const etherAmount = ethers.utils.formatEther(input.wei); + async toEth(args: Args_toEth, _client: Client): Promise { + const etherAmount = ethers.utils.formatEther(args.wei); return etherAmount.toString(); } async waitForEvent( - input: Input_waitForEvent, + args: Args_waitForEvent, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); - const contract = connection.getContract(input.address, [input.event]); + const connection = await this._getConnection(args.connection); + const contract = connection.getContract(args.address, [args.event]); const events = Object.keys(contract.interface.events); - const filter = contract.filters[events[0]](...parseArgs(input.args)); + const filter = contract.filters[events[0]](...parseArgs(args.args)); return Promise.race([ new Promise((resolve) => { @@ -301,31 +301,31 @@ export class EthereumPlugin extends Module { new Promise((_, reject) => { setTimeout(function () { reject( - `Waiting for event "${input.event}" on contract "${input.address}" timed out` + `Waiting for event "${args.event}" on contract "${args.address}" timed out` ); - }, input.timeout || 60000); + }, args.timeout || 60000); }), ]); } async awaitTransaction( - input: Input_awaitTransaction, + args: Args_awaitTransaction, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); const provider = connection.getProvider(); const res = await provider.waitForTransaction( - input.txHash, - input.confirmations, - input.timeout + args.txHash, + args.confirmations, + args.timeout ); return Mapping.toTxReceipt(res); } - async getNetwork(input: Input_getNetwork, _client: Client): Promise { - const connection = await this._getConnection(input.connection); + async getNetwork(args: Args_getNetwork, _client: Client): Promise { + const connection = await this._getConnection(args.connection); const provider = connection.getProvider(); const network = await provider.getNetwork(); return { @@ -336,89 +336,89 @@ export class EthereumPlugin extends Module { } public async callContractMethod( - input: Input_callContractMethod, + args: Args_callContractMethod, _client: Client ): Promise { - const res = await this._callContractMethod(input); + const res = await this._callContractMethod(args); return Mapping.toTxResponse(res); } public async callContractMethodAndWait( - input: Input_callContractMethodAndWait, + args: Args_callContractMethodAndWait, _client: Client ): Promise { - const response = await this._callContractMethod(input); + const response = await this._callContractMethod(args); const res = await response.wait(); return Mapping.toTxReceipt(res); } public async sendTransaction( - input: Input_sendTransaction, + args: Args_sendTransaction, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); const signer = connection.getSigner(); - const res = await signer.sendTransaction(Mapping.fromTxRequest(input.tx)); + const res = await signer.sendTransaction(Mapping.fromTxRequest(args.tx)); return Mapping.toTxResponse(res); } public async sendTransactionAndWait( - input: Input_sendTransactionAndWait, + args: Args_sendTransactionAndWait, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); const signer = connection.getSigner(); const response = await signer.sendTransaction( - Mapping.fromTxRequest(input.tx) + Mapping.fromTxRequest(args.tx) ); const receipt = await response.wait(); return Mapping.toTxReceipt(receipt); } public async deployContract( - input: Input_deployContract, + args: Args_deployContract, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); + const connection = await this._getConnection(args.connection); const signer = connection.getSigner(); const factory = new ethers.ContractFactory( - input.abi, - input.bytecode, + args.abi, + args.bytecode, signer ); - const contract = await factory.deploy(...parseArgs(input.args)); + const contract = await factory.deploy(...parseArgs(args.args)); await contract.deployTransaction.wait(); return contract.address; } public async signMessage( - input: Input_signMessage, + args: Args_signMessage, _client: Client ): Promise { - const connection = await this._getConnection(input.connection); - return await connection.getSigner().signMessage(input.message); + const connection = await this._getConnection(args.connection); + return await connection.getSigner().signMessage(args.message); } - public async sendRPC(input: Input_sendRPC, _client: Client): Promise { - const connection = await this._getConnection(input.connection); + public async sendRPC(args: Args_sendRPC, _client: Client): Promise { + const connection = await this._getConnection(args.connection); const provider = connection.getProvider(); - const response = await provider.send(input.method, input.params); + const response = await provider.send(args.method, args.params); return response.toString(); } private async _callContractMethod( - input: Input_callContractMethod + args: Args_callContractMethod ): Promise { - const connection = await this._getConnection(input.connection); - const contract = connection.getContract(input.address, [input.method]); + const connection = await this._getConnection(args.connection); + const contract = connection.getContract(args.address, [args.method]); const funcs = Object.keys(contract.interface.functions); - const gasPrice: string | null | undefined = input.txOverrides?.gasPrice; - const gasLimit: string | null | undefined = input.txOverrides?.gasLimit; - const value: string | null | undefined = input.txOverrides?.value; + const gasPrice: string | null | undefined = args.txOverrides?.gasPrice; + const gasLimit: string | null | undefined = args.txOverrides?.gasLimit; + const value: string | null | undefined = args.txOverrides?.value; - return await contract[funcs[0]](...parseArgs(input.args), { + return await contract[funcs[0]](...parseArgs(args.args), { gasPrice: gasPrice ? ethers.BigNumber.from(gasPrice) : undefined, gasLimit: gasLimit ? ethers.BigNumber.from(gasLimit) : undefined, value: value ? ethers.BigNumber.from(value) : undefined, diff --git a/packages/js/plugins/file-system/src/index.ts b/packages/js/plugins/file-system/src/index.ts index e2ecd5ff49..96bb84ad92 100644 --- a/packages/js/plugins/file-system/src/index.ts +++ b/packages/js/plugins/file-system/src/index.ts @@ -2,13 +2,13 @@ import { Client, Module, manifest, - Input_readFile, - Input_readFileAsString, - Input_exists, - Input_writeFile, - Input_mkdir, - Input_rm, - Input_rmdir, + Args_readFile, + Args_readFileAsString, + Args_exists, + Args_writeFile, + Args_mkdir, + Args_rm, + Args_rmdir, } from "./wrap"; import fileSystemEncodingToBufferEncoding from "./utils/fileSystemEncodingToBufferEncoding"; @@ -18,51 +18,51 @@ import { PluginFactory } from "@polywrap/core-js"; type NoConfig = Record; export class FileSystemPlugin extends Module { - async readFile(input: Input_readFile, _client: Client): Promise { - return fs.promises.readFile(input.path); + async readFile(args: Args_readFile, _client: Client): Promise { + return fs.promises.readFile(args.path); } async readFileAsString( - input: Input_readFileAsString, + args: Args_readFileAsString, _client: Client ): Promise { - return fs.promises.readFile(input.path, { - encoding: fileSystemEncodingToBufferEncoding(input.encoding), + return fs.promises.readFile(args.path, { + encoding: fileSystemEncodingToBufferEncoding(args.encoding), }); } - async exists(input: Input_exists, _client: Client): Promise { - return fs.existsSync(input.path); + async exists(args: Args_exists, _client: Client): Promise { + return fs.existsSync(args.path); } async writeFile( - input: Input_writeFile, + args: Args_writeFile, _client: Client ): Promise { - await fs.promises.writeFile(input.path, Buffer.from(input.data)); + await fs.promises.writeFile(args.path, Buffer.from(args.data)); return true; } - async mkdir(input: Input_mkdir, _client: Client): Promise { - await fs.promises.mkdir(input.path, { - recursive: input.recursive ?? false, + async mkdir(args: Args_mkdir, _client: Client): Promise { + await fs.promises.mkdir(args.path, { + recursive: args.recursive ?? false, }); return true; } - async rm(input: Input_rm, _client: Client): Promise { - await fs.promises.rm(input.path, { - recursive: input.recursive ?? false, - force: input.force ?? false, + async rm(args: Args_rm, _client: Client): Promise { + await fs.promises.rm(args.path, { + recursive: args.recursive ?? false, + force: args.force ?? false, }); return true; } - async rmdir(input: Input_rmdir, _client: Client): Promise { - await fs.promises.rmdir(input.path); + async rmdir(args: Args_rmdir, _client: Client): Promise { + await fs.promises.rmdir(args.path); return true; } diff --git a/packages/js/plugins/graph-node/src/index.ts b/packages/js/plugins/graph-node/src/index.ts index 1979fecda4..97fb020fb6 100644 --- a/packages/js/plugins/graph-node/src/index.ts +++ b/packages/js/plugins/graph-node/src/index.ts @@ -1,7 +1,7 @@ import { Client, Module, - Input_querySubgraph, + Args_querySubgraph, HTTP_Module, manifest, } from "./wrap"; @@ -27,11 +27,12 @@ export class GraphNodePlugin extends Module { constructor(config: GraphNodePluginConfig) { super(config); } + public async querySubgraph( - input: Input_querySubgraph, + args: Args_querySubgraph, client: Client ): Promise { - const { subgraphAuthor, subgraphName, query } = input; + const { subgraphAuthor, subgraphName, query } = args; const { data, error } = await HTTP_Module.post( { url: `${this.config.provider}/subgraphs/name/${subgraphAuthor}/${subgraphName}`, diff --git a/packages/js/plugins/http/src/__tests__/e2e/integration/src/index.ts b/packages/js/plugins/http/src/__tests__/e2e/integration/src/index.ts index 335bdf66dd..66afe9e78e 100644 --- a/packages/js/plugins/http/src/__tests__/e2e/integration/src/index.ts +++ b/packages/js/plugins/http/src/__tests__/e2e/integration/src/index.ts @@ -1,20 +1,20 @@ import { HTTP_Module, HTTP_Response, - Input_get, - Input_post, + Args_get, + Args_post, } from "./wrap"; -export function get(input: Input_get): HTTP_Response | null { +export function get(args: Args_get): HTTP_Response | null { return HTTP_Module.get({ - url: input.url, - request: input.request + url: args.url, + request: args.request }).unwrap(); } -export function post(input: Input_post): HTTP_Response | null { +export function post(args: Args_post): HTTP_Response | null { return HTTP_Module.post({ - url: input.url, - request: input.request + url: args.url, + request: args.request }).unwrap(); } diff --git a/packages/js/plugins/http/src/index.ts b/packages/js/plugins/http/src/index.ts index 813cac8980..e8b3879ac0 100644 --- a/packages/js/plugins/http/src/index.ts +++ b/packages/js/plugins/http/src/index.ts @@ -1,8 +1,8 @@ import { Client, Module, - Input_get, - Input_post, + Args_get, + Args_post, Response, manifest, } from "./wrap"; @@ -15,24 +15,24 @@ type NoConfig = Record; export class HttpPlugin extends Module { public async get( - input: Input_get, + args: Args_get, _client: Client ): Promise { const response = await axios.get( - input.url, - input.request ? toAxiosRequestConfig(input.request) : undefined + args.url, + args.request ? toAxiosRequestConfig(args.request) : undefined ); return fromAxiosResponse(response); } public async post( - input: Input_post, + args: Args_post, _client: Client ): Promise { const response = await axios.post( - input.url, - input.request ? input.request.body : undefined, - input.request ? toAxiosRequestConfig(input.request) : undefined + args.url, + args.request ? args.request.body : undefined, + args.request ? toAxiosRequestConfig(args.request) : undefined ); return fromAxiosResponse(response); } diff --git a/packages/js/plugins/ipfs/src/index.ts b/packages/js/plugins/ipfs/src/index.ts index 972445f9eb..933709ac77 100644 --- a/packages/js/plugins/ipfs/src/index.ts +++ b/packages/js/plugins/ipfs/src/index.ts @@ -1,10 +1,10 @@ import { Module, - Input_catFile, - Input_resolve, - Input_tryResolveUri, - Input_getFile, - Input_addFile, + Args_catFile, + Args_resolve, + Args_tryResolveUri, + Args_getFile, + Args_addFile, Bytes, Options, ResolveResult, @@ -22,8 +22,8 @@ const isIPFS = require("is-ipfs"); // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, @typescript-eslint/naming-convention const createIpfsClient = require("@dorgjelli-test/ipfs-http-client-lite"); -const getOptions = (input: Options | undefined | null, env: Env): Options => { - const options = input || {}; +const getOptions = (args: Options | undefined | null, env: Env): Options => { + const options = args || {}; if ( options.disableParallelRequests === undefined || @@ -69,17 +69,17 @@ export class IpfsPlugin extends Module { return buffer.toString("utf-8"); } - public async catFile(input: Input_catFile): Promise { - const options = getOptions(input.options, this.env); - return await this.cat(input.cid, options); + public async catFile(args: Args_catFile): Promise { + const options = getOptions(args.options, this.env); + return await this.cat(args.cid, options); } - public async resolve(input: Input_resolve): Promise { - const options = getOptions(input.options, this.env); + public async resolve(args: Args_resolve): Promise { + const options = getOptions(args.options, this.env); return await this._execWithOptions( "resolve", async (ipfs: IpfsClient, provider: string, options: unknown) => { - const { path } = await ipfs.resolve(input.cid, options); + const { path } = await ipfs.resolve(args.cid, options); return { cid: path, provider, @@ -91,13 +91,13 @@ export class IpfsPlugin extends Module { // uri-resolver.core.polywrap.eth public async tryResolveUri( - input: Input_tryResolveUri + args: Args_tryResolveUri ): Promise { - if (input.authority !== "ipfs") { + if (args.authority !== "ipfs") { return null; } - if (!IpfsPlugin.isCID(input.path)) { + if (!IpfsPlugin.isCID(args.path)) { // Not a valid CID return { manifest: null, uri: null }; } @@ -113,7 +113,7 @@ export class IpfsPlugin extends Module { for (const manifestSearchPattern of manifestSearchPatterns) { try { manifest = await this.catToString( - `${input.path}/${manifestSearchPattern}`, + `${args.path}/${manifestSearchPattern}`, { timeout: 5000, disableParallelRequests: this.env.disableParallelRequests, @@ -133,10 +133,10 @@ export class IpfsPlugin extends Module { } } - public async getFile(input: Input_getFile): Promise { + public async getFile(args: Args_getFile): Promise { try { const result = await this.resolve({ - cid: input.path, + cid: args.path, options: { timeout: 5000, disableParallelRequests: this.env.disableParallelRequests, @@ -157,8 +157,8 @@ export class IpfsPlugin extends Module { } } - public async addFile(input: Input_addFile): Promise { - const result = await this._ipfs.add(new Uint8Array(input.data)); + public async addFile(args: Args_addFile): Promise { + const result = await this._ipfs.add(new Uint8Array(args.data)); if (result.length === 0) { throw Error( diff --git a/packages/js/plugins/logger/src/index.ts b/packages/js/plugins/logger/src/index.ts index 23edb37277..b40ea2dac4 100644 --- a/packages/js/plugins/logger/src/index.ts +++ b/packages/js/plugins/logger/src/index.ts @@ -1,6 +1,6 @@ import { Module, - Input_log, + Args_log, Logger_LogLevel, Logger_LogLevelEnum, manifest, @@ -15,30 +15,30 @@ export interface LoggerPluginConfig { } export class LoggerPlugin extends Module { - public log(input: Input_log): boolean { + public log(args: Args_log): boolean { if (this.config.logFunc) { - return this.config.logFunc(input.level, input.message); + return this.config.logFunc(args.level, args.message); } - switch (input.level) { + switch (args.level) { case "DEBUG": case Logger_LogLevelEnum.DEBUG: - console.debug(input.message); + console.debug(args.message); break; case "WARN": case Logger_LogLevelEnum.WARN: - console.warn(input.message); + console.warn(args.message); break; case "ERROR": case Logger_LogLevelEnum.ERROR: - console.error(input.message); + console.error(args.message); break; case "INFO": case Logger_LogLevelEnum.INFO: - console.log(input.message); + console.log(args.message); break; default: - console.log(input.message); + console.log(args.message); } return true; diff --git a/packages/js/plugins/sha3/src/index.ts b/packages/js/plugins/sha3/src/index.ts index 806df172dc..508686dcd5 100644 --- a/packages/js/plugins/sha3/src/index.ts +++ b/packages/js/plugins/sha3/src/index.ts @@ -3,18 +3,18 @@ import { Module, - Input_sha3_512, - Input_sha3_384, - Input_sha3_256, - Input_sha3_224, - Input_keccak_512, - Input_keccak_384, - Input_keccak_256, - Input_keccak_224, - Input_hex_keccak_256, - Input_buffer_keccak_256, - Input_shake_128, - Input_shake_256, + Args_sha3_512, + Args_sha3_384, + Args_sha3_256, + Args_sha3_224, + Args_keccak_512, + Args_keccak_384, + Args_keccak_256, + Args_keccak_224, + Args_hex_keccak_256, + Args_buffer_keccak_256, + Args_shake_128, + Args_shake_256, manifest, } from "./wrap"; @@ -35,37 +35,37 @@ import { PluginFactory } from "@polywrap/core-js"; type NoConfig = Record; export class Sha3Plugin extends Module { - public sha3_512(input: Input_sha3_512): string { - return sha3_512(input.message); + public sha3_512(args: Args_sha3_512): string { + return sha3_512(args.message); } - public sha3_384(input: Input_sha3_384): string { - return sha3_384(input.message); + public sha3_384(args: Args_sha3_384): string { + return sha3_384(args.message); } - public sha3_256(input: Input_sha3_256): string { - return sha3_256(input.message); + public sha3_256(args: Args_sha3_256): string { + return sha3_256(args.message); } - public sha3_224(input: Input_sha3_224): string { - return sha3_224(input.message); + public sha3_224(args: Args_sha3_224): string { + return sha3_224(args.message); } - public keccak_512(input: Input_keccak_512): string { - return keccak_512(input.message); + public keccak_512(args: Args_keccak_512): string { + return keccak_512(args.message); } - public keccak_384(input: Input_keccak_384): string { - return keccak_384(input.message); + public keccak_384(args: Args_keccak_384): string { + return keccak_384(args.message); } - public keccak_256(input: Input_keccak_256): string { - return keccak_256(input.message); + public keccak_256(args: Args_keccak_256): string { + return keccak_256(args.message); } - public hex_keccak_256(input: Input_hex_keccak_256): string { + public hex_keccak_256(args: Args_hex_keccak_256): string { // remove the leading 0x - const hexString = input.message.replace(/^0x/, ""); + const hexString = args.message.replace(/^0x/, ""); // ensure even number of characters if (hexString.length % 2 != 0) { @@ -95,20 +95,20 @@ export class Sha3Plugin extends Module { return keccak_256(new Uint8Array(integers)); } - public buffer_keccak_256(input: Input_buffer_keccak_256): string { - return keccak_256(input.message); + public buffer_keccak_256(args: Args_buffer_keccak_256): string { + return keccak_256(args.message); } - public keccak_224(input: Input_keccak_224): string { - return keccak_224(input.message); + public keccak_224(args: Args_keccak_224): string { + return keccak_224(args.message); } - public shake_128(input: Input_shake_128): string { - return shake_128(input.message, input.outputBits); + public shake_128(args: Args_shake_128): string { + return shake_128(args.message, args.outputBits); } - public shake_256(input: Input_shake_256): string { - return shake_256(input.message, input.outputBits); + public shake_256(args: Args_shake_256): string { + return shake_256(args.message, args.outputBits); } } diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts b/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts index 26ae557386..3b5fa84a9a 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts @@ -80,7 +80,7 @@ describe("Filesystem plugin", () => { const deploy = await client.invoke({ uri: fsUri, method: "deployContract", - input: { + args: { connection: { networkNameOrChainId: "testnet" } diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/src/index.ts b/packages/js/plugins/uri-resolvers/file-system-resolver/src/index.ts index 33a60daf34..b290b104ec 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/src/index.ts +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/src/index.ts @@ -3,8 +3,8 @@ import { Client, FileSystem_EncodingEnum, FileSystem_Module, - Input_getFile, - Input_tryResolveUri, + Args_getFile, + Args_tryResolveUri, Module, UriResolver_MaybeUriOrManifest, manifest, @@ -17,10 +17,10 @@ type NoConfig = Record; export class FileSystemResolverPlugin extends Module { async tryResolveUri( - input: Input_tryResolveUri, + args: Args_tryResolveUri, _client: Client ): Promise { - if (input.authority !== "fs" && input.authority !== "file") { + if (args.authority !== "fs" && args.authority !== "file") { return null; } @@ -29,7 +29,7 @@ export class FileSystemResolverPlugin extends Module { let manifest: string | undefined; for (const manifestSearchPattern of manifestSearchPatterns) { - const manifestPath = path.resolve(input.path, manifestSearchPattern); + const manifestPath = path.resolve(args.path, manifestSearchPattern); const manifestExistsResult = await FileSystem_Module.exists( { path: manifestPath }, _client @@ -59,10 +59,10 @@ export class FileSystemResolverPlugin extends Module { } } - async getFile(input: Input_getFile, _client: Client): Promise { + async getFile(args: Args_getFile, _client: Client): Promise { try { const fileResult = await FileSystem_Module.readFile( - { path: input.path }, + { path: args.path }, _client ); @@ -76,6 +76,7 @@ export class FileSystemResolverPlugin extends Module { } } } + export const fileSystemResolverPlugin: PluginFactory = () => { return { factory: () => new FileSystemResolverPlugin({}), diff --git a/packages/js/plugins/uts46/src/index.ts b/packages/js/plugins/uts46/src/index.ts index 42f4b26ea2..bd751e4a66 100644 --- a/packages/js/plugins/uts46/src/index.ts +++ b/packages/js/plugins/uts46/src/index.ts @@ -1,8 +1,8 @@ import { Module, - Input_toAscii, - Input_toUnicode, - Input_convert, + Args_toAscii, + Args_toUnicode, + Args_convert, ConvertResult, manifest, } from "./wrap"; @@ -15,16 +15,16 @@ const uts46 = require("idna-uts46-hx/uts46bundle.js"); type NoConfig = Record; export class Uts46Plugin extends Module { - public toAscii(input: Input_toAscii): string { - return uts46.toAscii(input.value); + public toAscii(args: Args_toAscii): string { + return uts46.toAscii(args.value); } - public toUnicode(input: Input_toUnicode): string { - return uts46.toUnicode(input.value); + public toUnicode(args: Args_toUnicode): string { + return uts46.toUnicode(args.value); } - public convert(input: Input_convert): ConvertResult { - return uts46.convert(input.value); + public convert(args: Args_convert): ConvertResult { + return uts46.convert(args.value); } } diff --git a/packages/js/react/src/__tests__/usePolywrapInvoke.spec.tsx b/packages/js/react/src/__tests__/usePolywrapInvoke.spec.tsx index 347c8659d5..2f2783fa7e 100644 --- a/packages/js/react/src/__tests__/usePolywrapInvoke.spec.tsx +++ b/packages/js/react/src/__tests__/usePolywrapInvoke.spec.tsx @@ -89,7 +89,7 @@ describe("usePolywrapInvoke hook", () => { const { result: hookResult } = renderHook(hook, WrapperProvider); await act(async () => { - await hookResult.current.execute(options.input); + await hookResult.current.execute(options.args); }); const result = hookResult.current; @@ -101,7 +101,7 @@ describe("usePolywrapInvoke hook", () => { const deployQuery: UsePolywrapInvokeProps = { uri: envUri, method: "getEnv", - input: { + args: { arg: "Alice" }, config: { @@ -129,7 +129,7 @@ describe("usePolywrapInvoke hook", () => { const deployInvoke: UsePolywrapInvokeProps = { uri, method: "deployContract", - input: { + args: { connection: { networkNameOrChainId: "testnet", }, @@ -141,7 +141,7 @@ describe("usePolywrapInvoke hook", () => { const setStorageInvocation: UsePolywrapInvokeProps = { uri, method: "setData", - input: { + args: { address: address, value: 5, connection: { @@ -157,7 +157,7 @@ describe("usePolywrapInvoke hook", () => { const getStorageDataInvocation: UsePolywrapInvokeProps = { uri, method: "getData", - input: { + args: { address: address, connection: { networkNameOrChainId: "testnet", @@ -174,7 +174,7 @@ describe("usePolywrapInvoke hook", () => { provider: "Non existent Polywrap Provider", uri, method: "getData", - input: { + args: { address: "foo", }, }; @@ -194,7 +194,7 @@ describe("usePolywrapInvoke hook", () => { provider: "other", uri, method: "getData", - input: { + args: { address: "foo", }, }; @@ -211,7 +211,7 @@ describe("usePolywrapInvoke hook", () => { const deployInvoke: UsePolywrapInvokeProps = { uri, method: "deployContract", - input: { + args: { connection: { networkNameOrChainId: "testnet", }, @@ -223,7 +223,7 @@ describe("usePolywrapInvoke hook", () => { const setStorageInvocation: UsePolywrapInvokeProps = { uri, method: "setData", - input: { + args: { address: address, value: 3, connection: { @@ -239,7 +239,7 @@ describe("usePolywrapInvoke hook", () => { const getStorageDataInvocation: UsePolywrapInvokeProps = { uri, method: "getData", - input: { + args: { address: address, connection: { networkNameOrChainId: "testnet", diff --git a/packages/js/react/src/invoke.tsx b/packages/js/react/src/invoke.tsx index 3b40ec645d..d01b2f4c00 100644 --- a/packages/js/react/src/invoke.tsx +++ b/packages/js/react/src/invoke.tsx @@ -27,7 +27,7 @@ export interface UsePolywrapInvoke< TData = unknown > extends UsePolywrapInvokeState { execute: ( - input?: Record | ArrayBuffer + args?: Record | ArrayBuffer ) => Promise>; } @@ -42,13 +42,13 @@ export function usePolywrapInvoke< INITIAL_QUERY_STATE as UsePolywrapInvokeState ); - const execute = async (input?: Record | ArrayBuffer) => { + const execute = async (args?: Record | ArrayBuffer) => { dispatch({ loading: true }); const { data, error } = await client.invoke({ ...props, - input: input instanceof ArrayBuffer ? input : { - ...props.input, - ...input, + args: args instanceof ArrayBuffer ? args : { + ...props.args, + ...args, }, }); dispatch({ data, error, loading: false }); diff --git a/packages/js/test-env/src/index.ts b/packages/js/test-env/src/index.ts index d73341954b..80e8b16491 100644 --- a/packages/js/test-env/src/index.ts +++ b/packages/js/test-env/src/index.ts @@ -268,7 +268,7 @@ export async function buildAndDeployWrapper({ const { data: signerAddress } = await client.invoke({ method: "getSignerAddress", uri: ethereumPluginUri, - input: { + args: { connection: { networkNameOrChainId: "testnet", }, @@ -282,7 +282,7 @@ export async function buildAndDeployWrapper({ const { data: registerData, error } = await client.invoke<{ hash: string }>({ method: "registerDomainAndSubdomainsRecursively", uri: ensWrapperUri, - input: { + args: { domain: wrapperEns, owner: signerAddress, resolverAddress: ensAddresses.resolverAddress, @@ -305,7 +305,7 @@ export async function buildAndDeployWrapper({ await client.invoke({ method: "awaitTransaction", uri: ethereumPluginUri, - input: { + args: { txHash: registerData.hash, confirmations: 1, timeout: 15000, diff --git a/packages/js/tracing/src/index.ts b/packages/js/tracing/src/index.ts index 0d3bac92c7..9235f78467 100644 --- a/packages/js/tracing/src/index.ts +++ b/packages/js/tracing/src/index.ts @@ -112,7 +112,7 @@ export class Tracer { ): TReturn { try { Tracer.startSpan(span); - Tracer.setAttribute("input", { ...args }); + Tracer.setAttribute("args", { ...args }); const result = original.apply(this, args); @@ -145,7 +145,7 @@ export class Tracer { return (...args: TArgs): TReturn => { try { this.startSpan(span); - this.setAttribute("input", { ...args }); + this.setAttribute("args", { ...args }); const result = func(...args); diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache index af1dfb53fa..9b4216de10 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache @@ -12,7 +12,7 @@ import { {{#methods}} serialize{{name}}Args, deserialize{{name}}Result, - Input_{{name}}{{^last}},{{/last}} + Args_{{name}}{{^last}},{{/last}} {{/methods}} } from "./serialization"; {{/methods.length}} @@ -25,9 +25,9 @@ export class {{type}} { {{#methods}} public static {{name}}( - input: Input_{{name}} + args: Args_{{name}} ): Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string> { - const args = serialize{{name}}Args(input); + const args = serialize{{name}}Args(args); const result = wrap_subinvoke( "{{uri}}", "{{name}}", @@ -63,9 +63,9 @@ export class {{type}} { {{#methods}} public {{name}}( - input: Input_{{name}} + args: Args_{{name}} ): Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string> { - const args = serialize{{name}}Args(input); + const args = serialize{{name}}Args(args); const result = wrap_subinvokeImplementation( "{{uri}}", this.uri, diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache index 842613e064..afeb22c55d 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/serialization-ts.mustache @@ -3,41 +3,41 @@ import * as Types from "../.."; {{#methods}} -export class Input_{{name}} { +export class Args_{{name}} { {{#arguments}} {{#handleKeywords}}{{name}}{{/handleKeywords}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; {{/arguments}} } -export function serialize{{name}}Args(input: Input_{{name}}): ArrayBuffer { +export function serialize{{name}}Args(args: Args_{{name}}): ArrayBuffer { const sizerContext: Context = new Context("Serializing (sizing) imported module-type: {{name}}"); const sizer = new WriteSizer(sizerContext); - write{{name}}Args(sizer, input); + write{{name}}Args(sizer, args); const buffer = new ArrayBuffer(sizer.length); const encoderContext: Context = new Context("Serializing (encoding) imported module-type: {{name}}"); const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{name}}Args(encoder, input); + write{{name}}Args(encoder, args); return buffer; } export function write{{name}}Args( writer: Write, - input: Input_{{name}} + args: Args_{{name}} ): void { writer.writeMapLength({{arguments.length}}); {{#arguments}} writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); writer.writeString("{{name}}"); {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/scalar}} {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { + writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#handleKeywords}}{{name}}{{/handleKeywords}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { {{> serialize_array}} }); {{/array}} {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { + writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#handleKeywords}}{{name}}{{/handleKeywords}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { {{#value}} @@ -47,19 +47,19 @@ export function write{{name}}Args( {{/map}} {{#enum}} {{#required}} - writer.writeInt32(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + writer.writeInt32(args.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{^required}} - writer.writeNullableInt32(input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + writer.writeNullableInt32(args.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{/enum}} {{#object}} {{#required}} - Types.{{type}}.write(writer, input.{{#handleKeywords}}{{name}}{{/handleKeywords}}); + Types.{{type}}.write(writer, args.{{#handleKeywords}}{{name}}{{/handleKeywords}}); {{/required}} {{^required}} - if (input.{{#handleKeywords}}{{name}}{{/handleKeywords}}) { - Types.{{type}}.write(writer, input.{{#handleKeywords}}{{name}}{{/handleKeywords}} as Types.{{type}}); + if (args.{{#handleKeywords}}{{name}}{{/handleKeywords}}) { + Types.{{type}}.write(writer, args.{{#handleKeywords}}{{name}}{{/handleKeywords}} as Types.{{type}}); } else { writer.writeNil(); } diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/index-ts.mustache index 71d6d2fee9..9ef53bed90 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/index-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/index-ts.mustache @@ -2,7 +2,7 @@ {{#methods.length}} import { {{#methods}} - Input_{{name}}{{^last}},{{/last}} + Args_{{name}}{{^last}},{{/last}} {{/methods}} } from "./{{type}}"; {{/methods.length}} @@ -11,7 +11,7 @@ import { {{#methods.length}} export { {{#methods}} - Input_{{name}}{{^last}},{{/last}} + Args_{{name}}{{^last}},{{/last}} {{/methods}} }; {{/methods.length}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/index-ts.mustache index 5c7b7380a7..2ce26b1ab7 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/index-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/index-ts.mustache @@ -1,13 +1,13 @@ {{#methods.length}} import { {{#methods}} - Input_{{name}}{{^last}},{{/last}} + Args_{{name}}{{^last}},{{/last}} {{/methods}} } from "./serialization"; export { {{#methods}} - Input_{{name}}{{^last}},{{/last}} + Args_{{name}}{{^last}},{{/last}} {{/methods}} }; {{/methods.length}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache index f4a4b0c88e..da675fb095 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/module-type/serialization-ts.mustache @@ -2,13 +2,13 @@ import * as Types from ".."; {{#methods}} -export class Input_{{name}} { +export class Args_{{name}} { {{#arguments}} {{#handleKeywords}}{{name}}{{/handleKeywords}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; {{/arguments}} } -export function deserialize{{name}}Args(argsBuf: ArrayBuffer): Input_{{name}} { +export function deserialize{{name}}Args(argsBuf: ArrayBuffer): Args_{{name}} { const context: Context = new Context("Deserializing module-type: {{name}}"); {{#arguments.length}} const reader = new ReadDecoder(argsBuf, context); diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/mod-rs.mustache index 80ee0b0b9d..efe4318278 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/mod-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/mod-rs.mustache @@ -14,7 +14,7 @@ pub use serialization::{ {{#methods}} deserialize_{{#toLower}}{{name}}{{/toLower}}_result, serialize_{{#toLower}}{{name}}{{/toLower}}_args, - Input{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} + Args{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} {{/methods}} }; {{/methods.length}} @@ -36,9 +36,9 @@ impl {{#toUpper}}{{type}}{{/toUpper}} { } {{#methods}} - pub fn {{#toLower}}{{name}}{{/toLower}}(input: &Input{{#toUpper}}{{name}}{{/toUpper}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, String> { + pub fn {{#toLower}}{{name}}{{/toLower}}(args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, String> { let uri = {{#parent}}{{#toUpper}}{{type}}{{/toUpper}}{{/parent}}::URI; - let args = serialize_{{#toLower}}{{name}}{{/toLower}}_args(input).map_err(|e| e.to_string())?; + let args = serialize_{{#toLower}}{{name}}{{/toLower}}_args(args).map_err(|e| e.to_string())?; let result = subinvoke::wrap_subinvoke( uri, "{{name}}", diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache index 36712389f3..f5e583ff2a 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/module-type/serialization-rs.mustache @@ -31,35 +31,35 @@ use crate::{ {{#methods}} #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Input{{#toUpper}}{{name}}{{/toUpper}} { +pub struct Args{{#toUpper}}{{name}}{{/toUpper}} { {{#arguments}} pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, {{/arguments}} } -pub fn serialize_{{#toLower}}{{name}}{{/toLower}}_args(input: &Input{{#toUpper}}{{name}}{{/toUpper}}) -> Result, EncodeError> { +pub fn serialize_{{#toLower}}{{name}}{{/toLower}}_args(args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) imported module-type: {{#toLower}}{{name}}{{/toLower}}".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{name}}{{/toLower}}_args(input, &mut encoder)?; + write_{{#toLower}}{{name}}{{/toLower}}_args(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_{{#toLower}}{{name}}{{/toLower}}_args(input: &Input{{#toUpper}}{{name}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_{{#toLower}}{{name}}{{/toLower}}_args(args: &Args{{#toUpper}}{{name}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&{{arguments.length}})?; {{#arguments}} writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); writer.write_string("{{name}}")?; {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; {{/scalar}} {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { {{> serialize_array}} })?; {{/array}} {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) }, |writer, value| { {{#value}} @@ -69,19 +69,19 @@ pub fn write_{{#toLower}}{{name}}{{/toLower}}_args(input: &Input{{#toU {{/map}} {{#enum}} {{#required}} - writer.write_i32(&(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; + writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; + writer.write_nullable_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; {{/required}} {{/enum}} {{#object}} {{#required}} - {{#toUpper}}{{type}}{{/toUpper}}::write(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; + {{#toUpper}}{{type}}{{/toUpper}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; {{/required}} {{^required}} - if input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#toUpper}}{{type}}{{/toUpper}}::write(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; + if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { + {{#toUpper}}{{type}}{{/toUpper}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/mod-rs.mustache index c9577cb271..b58e2faac0 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/mod-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/mod-rs.mustache @@ -41,16 +41,16 @@ impl {{#toUpper}}{{type}}{{/toUpper}} { } } - pub fn to_buffer(input: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { - serialize_{{#toLower}}{{type}}{{/toLower}}(input).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn to_buffer(args: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { + serialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } - pub fn from_buffer(input: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { - deserialize_{{#toLower}}{{type}}{{/toLower}}(input).map_err(|e| DecodeError::TypeReadError(e.to_string())) + pub fn from_buffer(args: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { + deserialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) } - pub fn write(input: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { - write_{{#toLower}}{{type}}{{/toLower}}(input, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn write(args: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { + write_{{#toLower}}{{type}}{{/toLower}}(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } pub fn read(reader: &mut R) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache index ac73008645..387d5c6536 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/imported/object-type/serialization-rs.mustache @@ -28,29 +28,29 @@ use crate::{ {{/isEnum}} {{/propertyDeps}} -pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { +pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(args: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) imported object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{type}}{{/toLower}}(input, &mut encoder)?; + write_{{#toLower}}{{type}}{{/toLower}}(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_{{#toLower}}{{type}}{{/toLower}}(args: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&{{properties.length}})?; {{#properties}} writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); writer.write_string("{{name}}")?; {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; {{/scalar}} {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { {{> serialize_array}} })?; {{/array}} {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) }, |writer, value| { {{#value}} @@ -60,11 +60,11 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty {{/map}} {{#object}} {{#required}} - {{#toUpper}}{{type}}{{/toUpper}}::write(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; + {{#toUpper}}{{type}}{{/toUpper}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; {{/required}} {{^required}} - if input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#toUpper}}{{type}}{{/toUpper}}::write(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; + if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { + {{#toUpper}}{{type}}{{/toUpper}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } @@ -72,10 +72,10 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty {{/object}} {{#enum}} {{#required}} - writer.write_i32(&(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; + writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; + writer.write_nullable_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; {{/required}} {{/enum}} writer.context().pop(); @@ -83,10 +83,10 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty Ok(()) } -pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(input: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { +pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(args: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { let mut context = Context::new(); context.description = "Deserializing imported object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); read_{{#toLower}}{{type}}{{/toLower}}(&mut reader) } diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/mod-rs.mustache index cf3208365c..55339e620f 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/mod-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/mod-rs.mustache @@ -40,7 +40,7 @@ pub use {{#toLower}}{{type}}{{/toLower}}::{ deserialize_{{#toLower}}{{name}}{{/toLower}}_args, serialize_{{#toLower}}{{name}}{{/toLower}}_result, {{#toLower}}{{name}}{{/toLower}}_wrapped, - Input{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} + Args{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} {{/methods}} }; {{/moduleType}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/mod-rs.mustache index 74b43c6b5f..fcf5a9b236 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/mod-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/mod-rs.mustache @@ -10,7 +10,7 @@ pub use serialization::{ {{#methods}} deserialize_{{#toLower}}{{name}}{{/toLower}}_args, serialize_{{#toLower}}{{name}}{{/toLower}}_result, - Input{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} + Args{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} {{/methods}} }; {{/methods.length}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache index 0c0105b777..2c5f77c2dd 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/serialization-rs.mustache @@ -31,18 +31,18 @@ use crate::{ {{#methods}} #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Input{{#toUpper}}{{name}}{{/toUpper}} { +pub struct Args{{#toUpper}}{{name}}{{/toUpper}} { {{#arguments}} pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, {{/arguments}} } -pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_args(input: &[u8]) -> Result { +pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_args(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing module-type: {{#toLower}}{{name}}{{/toLower}}".to_string(); {{#arguments.length}} - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); let mut num_of_fields = reader.read_map_length()?; {{#arguments}} @@ -113,7 +113,7 @@ pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_args(input: &[u8]) -> Result {{/arguments}} {{/arguments.length}} - Ok(Input{{#toUpper}}{{name}}{{/toUpper}} { + Ok(Args{{#toUpper}}{{name}}{{/toUpper}} { {{#arguments}} {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, {{/arguments}} diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/wrapped-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/wrapped-rs.mustache index a8bcf74f98..e6a9dbe427 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/wrapped-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/module-type/wrapped-rs.mustache @@ -2,7 +2,7 @@ use crate::{ {{#methods}} {{#toLower}}{{name}}{{/toLower}}, - Input{{#toUpper}}{{name}}{{/toUpper}}, + Args{{#toUpper}}{{name}}{{/toUpper}}, deserialize_{{#toLower}}{{name}}{{/toLower}}_args, serialize_{{#toLower}}{{name}}{{/toLower}}_result{{^last}},{{/last}} {{/methods}} @@ -10,12 +10,12 @@ use crate::{ {{/methods.length}} {{#methods}} -pub fn {{#toLower}}{{name}}{{/toLower}}_wrapped(input: &[u8]) -> Vec { +pub fn {{#toLower}}{{name}}{{/toLower}}_wrapped(args: &[u8]) -> Vec { {{#arguments.length}} - match deserialize_{{#toLower}}{{name}}{{/toLower}}_args(input) { + match deserialize_{{#toLower}}{{name}}{{/toLower}}_args(args) { Ok(args) => { {{/arguments.length}} - let result = {{#toLower}}{{name}}{{/toLower}}({{#arguments.length}}Input{{#toUpper}}{{name}}{{/toUpper}} { + let result = {{#toLower}}{{name}}{{/toLower}}({{#arguments.length}}Args{{#toUpper}}{{name}}{{/toUpper}} { {{#arguments}} {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: args.{{#toLower}}{{name}}{{/toLower}}, {{/arguments}} diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/mod-rs.mustache index b158fa626a..9018a7f19f 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/mod-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/mod-rs.mustache @@ -37,16 +37,16 @@ impl {{#toUpper}}{{type}}{{/toUpper}} { } } - pub fn to_buffer(input: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { - serialize_{{#toLower}}{{type}}{{/toLower}}(input).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn to_buffer(args: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { + serialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } - pub fn from_buffer(input: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { - deserialize_{{#toLower}}{{type}}{{/toLower}}(input).map_err(|e| DecodeError::TypeReadError(e.to_string())) + pub fn from_buffer(args: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { + deserialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) } - pub fn write(input: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { - write_{{#toLower}}{{type}}{{/toLower}}(input, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn write(args: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { + write_{{#toLower}}{{type}}{{/toLower}}(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } pub fn read(reader: &mut R) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { diff --git a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache index 106e788b9e..0c346826e0 100644 --- a/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache +++ b/packages/schema/bind/src/bindings/rust/wasm-rs/templates/object-type/serialization-rs.mustache @@ -28,29 +28,29 @@ use crate::{ {{/isEnum}} {{/propertyDeps}} -pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { +pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(args: &{{#toUpper}}{{type}}{{/toUpper}}) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{type}}{{/toLower}}(input, &mut encoder)?; + write_{{#toLower}}{{type}}{{/toLower}}(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_{{#toLower}}{{type}}{{/toLower}}(args: &{{#toUpper}}{{type}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&{{properties.length}})?; {{#properties}} writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); writer.write_string("{{name}}")?; {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; {{/scalar}} {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { {{> serialize_array}} })?; {{/array}} {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { + writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) }, |writer, value| { {{#value}} @@ -60,11 +60,11 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty {{/map}} {{#object}} {{#required}} - {{#toUpper}}{{type}}{{/toUpper}}::write(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; + {{#toUpper}}{{type}}{{/toUpper}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; {{/required}} {{^required}} - if input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#toUpper}}{{type}}{{/toUpper}}::write(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; + if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { + {{#toUpper}}{{type}}{{/toUpper}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } @@ -72,10 +72,10 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty {{/object}} {{#enum}} {{#required}} - writer.write_i32(&(input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; + writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; {{/required}} {{^required}} - writer.write_nullable_i32(&input.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; + writer.write_nullable_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; {{/required}} {{/enum}} writer.context().pop(); @@ -83,10 +83,10 @@ pub fn write_{{#toLower}}{{type}}{{/toLower}}(input: &{{#toUpper}}{{ty Ok(()) } -pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(input: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { +pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(args: &[u8]) -> Result<{{#toUpper}}{{type}}{{/toUpper}}, DecodeError> { let mut context = Context::new(); context.description = "Deserializing object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); read_{{#toLower}}{{type}}{{/toLower}}(&mut reader) } diff --git a/packages/schema/bind/src/bindings/typescript/app-ts/templates/types-ts.mustache b/packages/schema/bind/src/bindings/typescript/app-ts/templates/types-ts.mustache index c31bd634af..78a23f1067 100644 --- a/packages/schema/bind/src/bindings/typescript/app-ts/templates/types-ts.mustache +++ b/packages/schema/bind/src/bindings/typescript/app-ts/templates/types-ts.mustache @@ -88,7 +88,7 @@ export type {{type}} = {{type}}Enum | {{type}}String; {{#methods}} /* URI: "{{parent.uri}}" */ -interface {{parent.type}}_Input_{{name}} extends Record { +interface {{parent.type}}_Args_{{name}} extends Record { {{#arguments}} {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; {{/arguments}} @@ -99,14 +99,14 @@ interface {{parent.type}}_Input_{{name}} extends Record { export const {{type}} = { {{#methods}} {{name}}: async ( - input: {{parent.type}}_Input_{{name}}, + args: {{parent.type}}_Args_{{name}}, client: Client, uri: string = "{{parent.uri}}" ): Promise> => { return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({ uri, method: "{{name}}", - input + args }); }{{^last}},{{/last}} {{^last}} diff --git a/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/module-ts.mustache b/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/module-ts.mustache index 6bad811990..7c3460b9a7 100644 --- a/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/module-ts.mustache +++ b/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/module-ts.mustache @@ -11,7 +11,7 @@ import { {{#moduleType}} {{#methods}} -export interface Input_{{name}} extends Record { +export interface Args_{{name}} extends Record { {{#arguments}} {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; {{/arguments}} @@ -30,7 +30,7 @@ export abstract class Module< {{#methods}} abstract {{name}}( - input: Input_{{name}}, + args: Args_{{name}}, client: Client ): MaybeAsync<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>; {{/methods}} diff --git a/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/types-ts.mustache b/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/types-ts.mustache index 116c7a4034..771baaab3c 100644 --- a/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/types-ts.mustache +++ b/packages/schema/bind/src/bindings/typescript/plugin-ts/templates/types-ts.mustache @@ -107,7 +107,7 @@ export type {{type}} = {{type}}Enum | {{type}}String; {{#importedModuleTypes}} {{#methods}} /* URI: "{{parent.uri}}" */ -interface {{parent.type}}_Input_{{name}} extends Record { +interface {{parent.type}}_Args_{{name}} extends Record { {{#arguments}} {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; {{/arguments}} @@ -119,13 +119,13 @@ interface {{parent.type}}_Input_{{name}} extends Record { export const {{type}} = { {{#methods}} {{name}}: async ( - input: {{parent.type}}_Input_{{name}}, + args: {{parent.type}}_Args_{{name}}, client: Client ): Promise> => { return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({ uri: "{{parent.uri}}", method: "{{name}}", - input + args }); }{{^last}},{{/last}} {{^last}} @@ -144,13 +144,13 @@ export class {{type}} { {{#methods}} public async {{name}} ( - input: {{parent.type}}_Input_{{name}}, + args: {{parent.type}}_Args_{{name}}, client: Client ): Promise> { return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({ uri: this.uri, method: "{{name}}", - input + args }); } {{^last}} diff --git a/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts b/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts index 746339efc9..0934a8691f 100644 --- a/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts +++ b/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts @@ -24,7 +24,7 @@ describe("e2e", () => { const result = await client.invoke({ uri, method: "sampleMethod", - input: { + args: { data: "fuz baz " }, }); diff --git a/packages/templates/plugin/typescript/src/index.ts b/packages/templates/plugin/typescript/src/index.ts index bd8753fe25..4601141f95 100644 --- a/packages/templates/plugin/typescript/src/index.ts +++ b/packages/templates/plugin/typescript/src/index.ts @@ -1,4 +1,4 @@ -import { Module, Input_sampleMethod, manifest } from "./wrap"; +import { Module, Args_sampleMethod, manifest } from "./wrap"; import { PluginFactory } from "@polywrap/core-js"; @@ -10,8 +10,8 @@ export class SamplePlugin extends Module { constructor(config: SamplePluginConfig) { super(config); } - public sampleMethod(input: Input_sampleMethod): string { - return input.data + this.config.defaultValue; + public sampleMethod(args: Args_sampleMethod): string { + return args.data + this.config.defaultValue; } } diff --git a/packages/templates/wasm/assemblyscript/src/index.ts b/packages/templates/wasm/assemblyscript/src/index.ts index e8821b96f7..a4134a153e 100644 --- a/packages/templates/wasm/assemblyscript/src/index.ts +++ b/packages/templates/wasm/assemblyscript/src/index.ts @@ -1,39 +1,39 @@ import { Ethereum_Module, - Input_deployContract, - Input_setData, - Input_getData, + Args_deployContract, + Args_setData, + Args_getData, } from "./wrap"; import { abi, bytecode } from "./contracts/SimpleStorage"; -export function getData(input: Input_getData): u32 { +export function getData(args: Args_getData): u32 { const res = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function get() view returns (uint256)", args: null, - connection: input.connection, + connection: args.connection, }).unwrap(); return U32.parseInt(res); } -export function setData(input: Input_setData): string { +export function setData(args: Args_setData): string { const res = Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", - args: [input.value.toString()], - connection: input.connection, + args: [args.value.toString()], + connection: args.connection, txOverrides: null, }).unwrap(); return res.hash; } -export function deployContract(input: Input_deployContract): string { +export function deployContract(args: Args_deployContract): string { return Ethereum_Module.deployContract({ abi, bytecode, args: null, - connection: input.connection, + connection: args.connection, }).unwrap(); } diff --git a/packages/templates/wasm/assemblyscript/workflows/e2e.yaml b/packages/templates/wasm/assemblyscript/workflows/e2e.yaml index 5ed90fa0db..24ffeb3c1e 100644 --- a/packages/templates/wasm/assemblyscript/workflows/e2e.yaml +++ b/packages/templates/wasm/assemblyscript/workflows/e2e.yaml @@ -4,7 +4,7 @@ jobs: steps: - uri: fs/build method: deployContract - input: + args: connection: networkNameOrChainId: testnet jobs: @@ -12,14 +12,14 @@ jobs: steps: - uri: fs/build method: setData - input: + args: address: "$cases.0.data" value: 100 connection: networkNameOrChainId: testnet - uri: fs/build method: getData - input: + args: address: "$cases.0.data" connection: networkNameOrChainId: testnet diff --git a/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts b/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts index b325904177..71e9a4a833 100644 --- a/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts +++ b/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts @@ -119,7 +119,7 @@ export type TestImport_Enum = TestImport_EnumEnum | TestImport_EnumString; /// Imported Modules START /// /* URI: "testimport.uri.eth" */ -interface TestImport_Module_Input_importedMethod extends Record { +interface TestImport_Module_Args_importedMethod extends Record { str: Types.String; optStr?: Types.String | null; u: Types.UInt; @@ -136,33 +136,33 @@ interface TestImport_Module_Input_importedMethod extends Record } /* URI: "testimport.uri.eth" */ -interface TestImport_Module_Input_anotherMethod extends Record { +interface TestImport_Module_Args_anotherMethod extends Record { arg: Array; } /* URI: "testimport.uri.eth" */ export const TestImport_Module = { importedMethod: async ( - input: TestImport_Module_Input_importedMethod, + args: TestImport_Module_Args_importedMethod, client: Client, uri: string = "testimport.uri.eth" ): Promise> => { return client.invoke({ uri, method: "importedMethod", - input + args }); }, anotherMethod: async ( - input: TestImport_Module_Input_anotherMethod, + args: TestImport_Module_Args_anotherMethod, client: Client, uri: string = "testimport.uri.eth" ): Promise> => { return client.invoke({ uri, method: "anotherMethod", - input + args }); } } diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts index 1b95aa652e..0f6a4088a5 100644 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts +++ b/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts @@ -9,7 +9,7 @@ import { MaybeAsync } from "@polywrap/core-js"; -export interface Input_moduleMethod extends Record { +export interface Args_moduleMethod extends Record { str: Types.String; optStr?: Types.String | null; en: Types.CustomEnum; @@ -19,7 +19,7 @@ export interface Input_moduleMethod extends Record { map: Map; } -export interface Input_objectMethod extends Record { +export interface Args_objectMethod extends Record { object: Types.AnotherType; optObject?: Types.AnotherType | null; objectArray: Array; @@ -34,12 +34,12 @@ export abstract class Module< > { abstract moduleMethod( - input: Input_moduleMethod, + args: Args_moduleMethod, client: Client ): MaybeAsync; abstract objectMethod( - input: Input_objectMethod, + args: Args_objectMethod, client: Client ): MaybeAsync; } diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts index 004fd2aaa9..8aed41456a 100644 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts +++ b/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts @@ -132,7 +132,7 @@ export type TestImport_Enum = TestImport_EnumEnum | TestImport_EnumString; /// Imported Modules START /// /* URI: "testimport.uri.eth" */ -interface TestImport_Module_Input_importedMethod extends Record { +interface TestImport_Module_Args_importedMethod extends Record { str: Types.String; optStr?: Types.String | null; u: Types.UInt; @@ -149,7 +149,7 @@ interface TestImport_Module_Input_importedMethod extends Record } /* URI: "testimport.uri.eth" */ -interface TestImport_Module_Input_anotherMethod extends Record { +interface TestImport_Module_Args_anotherMethod extends Record { arg: Array; } @@ -161,24 +161,24 @@ export class TestImport_Module { } public async importedMethod ( - input: TestImport_Module_Input_importedMethod, + args: TestImport_Module_Args_importedMethod, client: Client ): Promise> { return client.invoke({ uri: this.uri, method: "importedMethod", - input + args }); } public async anotherMethod ( - input: TestImport_Module_Input_anotherMethod, + args: TestImport_Module_Args_anotherMethod, client: Client ): Promise> { return client.invoke({ uri: this.uri, method: "anotherMethod", - input + args }); } } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts index 469f9f5f8b..6576b65fdf 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts @@ -1,9 +1,9 @@ import { - Input_moduleMethod, - Input_objectMethod + Args_moduleMethod, + Args_objectMethod } from "./serialization"; export { - Input_moduleMethod, - Input_objectMethod + Args_moduleMethod, + Args_objectMethod }; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts index f214d2abae..9aaf0ec015 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts @@ -12,7 +12,7 @@ import { } from "@polywrap/wasm-as"; import * as Types from ".."; -export class Input_moduleMethod { +export class Args_moduleMethod { str: string; optStr: string | null; en: Types.CustomEnum; @@ -22,7 +22,7 @@ export class Input_moduleMethod { map: Map; } -export function deserializemoduleMethodArgs(argsBuf: ArrayBuffer): Input_moduleMethod { +export function deserializemoduleMethodArgs(argsBuf: ArrayBuffer): Args_moduleMethod { const context: Context = new Context("Deserializing module-type: moduleMethod"); const reader = new ReadDecoder(argsBuf, context); let numFields = reader.readMapLength(); @@ -179,14 +179,14 @@ export function writemoduleMethodResult(writer: Write, result: i32): void { writer.context().pop(); } -export class Input_objectMethod { +export class Args_objectMethod { object: Types.AnotherType; optObject: Types.AnotherType | null; objectArray: Array; optObjectArray: Array | null; } -export function deserializeobjectMethodArgs(argsBuf: ArrayBuffer): Input_objectMethod { +export function deserializeobjectMethodArgs(argsBuf: ArrayBuffer): Args_objectMethod { const context: Context = new Context("Deserializing module-type: objectMethod"); const reader = new ReadDecoder(argsBuf, context); let numFields = reader.readMapLength(); diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts index 859818f55b..6587cada4c 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts @@ -10,10 +10,10 @@ import { import { serializeimportedMethodArgs, deserializeimportedMethodResult, - Input_importedMethod, + Args_importedMethod, serializeanotherMethodArgs, deserializeanotherMethodResult, - Input_anotherMethod + Args_anotherMethod } from "./serialization"; import * as Types from "../.."; @@ -28,9 +28,9 @@ export class TestImport_Module { } public importedMethod( - input: Input_importedMethod + args: Args_importedMethod ): Result { - const args = serializeimportedMethodArgs(input); + const args = serializeimportedMethodArgs(args); const result = wrap_subinvokeImplementation( "testimport.uri.eth", this.uri, @@ -50,9 +50,9 @@ export class TestImport_Module { } public anotherMethod( - input: Input_anotherMethod + args: Args_anotherMethod ): Result { - const args = serializeanotherMethodArgs(input); + const args = serializeanotherMethodArgs(args); const result = wrap_subinvokeImplementation( "testimport.uri.eth", this.uri, diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts index d1bb72d7e5..1fcb254884 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts @@ -12,7 +12,7 @@ import { } from "@polywrap/wasm-as"; import * as Types from "../.."; -export class Input_importedMethod { +export class Args_importedMethod { str: string; optStr: string | null; u: u32; @@ -28,41 +28,41 @@ export class Input_importedMethod { optEnumArray: Array> | null; } -export function serializeimportedMethodArgs(input: Input_importedMethod): ArrayBuffer { +export function serializeimportedMethodArgs(args: Args_importedMethod): ArrayBuffer { const sizerContext: Context = new Context("Serializing (sizing) imported module-type: importedMethod"); const sizer = new WriteSizer(sizerContext); - writeimportedMethodArgs(sizer, input); + writeimportedMethodArgs(sizer, args); const buffer = new ArrayBuffer(sizer.length); const encoderContext: Context = new Context("Serializing (encoding) imported module-type: importedMethod"); const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeimportedMethodArgs(encoder, input); + writeimportedMethodArgs(encoder, args); return buffer; } export function writeimportedMethodArgs( writer: Write, - input: Input_importedMethod + args: Args_importedMethod ): void { writer.writeMapLength(13); writer.context().push("str", "string", "writing property"); writer.writeString("str"); - writer.writeString(input.str); + writer.writeString(args.str); writer.context().pop(); writer.context().push("optStr", "string | null", "writing property"); writer.writeString("optStr"); - writer.writeNullableString(input.optStr); + writer.writeNullableString(args.optStr); writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.writeString("u"); - writer.writeUInt32(input.u); + writer.writeUInt32(args.u); writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.writeString("optU"); - writer.writeNullableUInt32(input.optU); + writer.writeNullableUInt32(args.optU); writer.context().pop(); writer.context().push("uArrayArray", "Array> | null>", "writing property"); writer.writeString("uArrayArray"); - writer.writeArray(input.uArrayArray, (writer: Write, item: Array> | null): void => { + writer.writeArray(args.uArrayArray, (writer: Write, item: Array> | null): void => { writer.writeNullableArray(item, (writer: Write, item: Option): void => { writer.writeNullableUInt32(item); }); @@ -70,25 +70,25 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("object", "Types.TestImport_Object", "writing property"); writer.writeString("object"); - Types.TestImport_Object.write(writer, input.object); + Types.TestImport_Object.write(writer, args.object); writer.context().pop(); writer.context().push("optObject", "Types.TestImport_Object | null", "writing property"); writer.writeString("optObject"); - if (input.optObject) { - Types.TestImport_Object.write(writer, input.optObject as Types.TestImport_Object); + if (args.optObject) { + Types.TestImport_Object.write(writer, args.optObject as Types.TestImport_Object); } else { writer.writeNil(); } writer.context().pop(); writer.context().push("objectArray", "Array", "writing property"); writer.writeString("objectArray"); - writer.writeArray(input.objectArray, (writer: Write, item: Types.TestImport_Object): void => { + writer.writeArray(args.objectArray, (writer: Write, item: Types.TestImport_Object): void => { Types.TestImport_Object.write(writer, item); }); writer.context().pop(); writer.context().push("optObjectArray", "Array | null", "writing property"); writer.writeString("optObjectArray"); - writer.writeNullableArray(input.optObjectArray, (writer: Write, item: Types.TestImport_Object | null): void => { + writer.writeNullableArray(args.optObjectArray, (writer: Write, item: Types.TestImport_Object | null): void => { if (item) { Types.TestImport_Object.write(writer, item as Types.TestImport_Object); } else { @@ -98,21 +98,21 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("en", "Types.TestImport_Enum", "writing property"); writer.writeString("en"); - writer.writeInt32(input.en); + writer.writeInt32(args.en); writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.writeString("optEnum"); - writer.writeNullableInt32(input.optEnum); + writer.writeNullableInt32(args.optEnum); writer.context().pop(); writer.context().push("enumArray", "Array", "writing property"); writer.writeString("enumArray"); - writer.writeArray(input.enumArray, (writer: Write, item: Types.TestImport_Enum): void => { + writer.writeArray(args.enumArray, (writer: Write, item: Types.TestImport_Enum): void => { writer.writeInt32(item); }); writer.context().pop(); writer.context().push("optEnumArray", "Array> | null", "writing property"); writer.writeString("optEnumArray"); - writer.writeNullableArray(input.optEnumArray, (writer: Write, item: Option): void => { + writer.writeNullableArray(args.optEnumArray, (writer: Write, item: Option): void => { writer.writeNullableInt32(item); }); writer.context().pop(); @@ -133,29 +133,29 @@ export function deserializeimportedMethodResult(buffer: ArrayBuffer): Types.Test return res; } -export class Input_anotherMethod { +export class Args_anotherMethod { arg: Array; } -export function serializeanotherMethodArgs(input: Input_anotherMethod): ArrayBuffer { +export function serializeanotherMethodArgs(args: Args_anotherMethod): ArrayBuffer { const sizerContext: Context = new Context("Serializing (sizing) imported module-type: anotherMethod"); const sizer = new WriteSizer(sizerContext); - writeanotherMethodArgs(sizer, input); + writeanotherMethodArgs(sizer, args); const buffer = new ArrayBuffer(sizer.length); const encoderContext: Context = new Context("Serializing (encoding) imported module-type: anotherMethod"); const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeanotherMethodArgs(encoder, input); + writeanotherMethodArgs(encoder, args); return buffer; } export function writeanotherMethodArgs( writer: Write, - input: Input_anotherMethod + args: Args_anotherMethod ): void { writer.writeMapLength(1); writer.context().push("arg", "Array", "writing property"); writer.writeString("arg"); - writer.writeArray(input.arg, (writer: Write, item: string): void => { + writer.writeArray(args.arg, (writer: Write, item: string): void => { writer.writeString(item); }); writer.context().pop(); diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts index 771e446703..849ecfa59a 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts @@ -1,10 +1,10 @@ import { - Input_moduleMethod, - Input_objectMethod + Args_moduleMethod, + Args_objectMethod } from "./Module"; export { - Input_moduleMethod, - Input_objectMethod + Args_moduleMethod, + Args_objectMethod }; export { CustomType } from "./CustomType"; export { AnotherType } from "./AnotherType"; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs index 8106b127e5..4cee40baf2 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs @@ -35,16 +35,16 @@ impl AnotherType { } } - pub fn to_buffer(input: &AnotherType) -> Result, EncodeError> { - serialize_another_type(input).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn to_buffer(args: &AnotherType) -> Result, EncodeError> { + serialize_another_type(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } - pub fn from_buffer(input: &[u8]) -> Result { - deserialize_another_type(input).map_err(|e| DecodeError::TypeReadError(e.to_string())) + pub fn from_buffer(args: &[u8]) -> Result { + deserialize_another_type(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) } - pub fn write(input: &AnotherType, writer: &mut W) -> Result<(), EncodeError> { - write_another_type(input, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn write(args: &AnotherType, writer: &mut W) -> Result<(), EncodeError> { + write_another_type(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } pub fn read(reader: &mut R) -> Result { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs index 9f93c92f32..1cc38fab91 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs @@ -16,39 +16,39 @@ use crate::AnotherType; use crate::CustomType; -pub fn serialize_another_type(input: &AnotherType) -> Result, EncodeError> { +pub fn serialize_another_type(args: &AnotherType) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) object-type: AnotherType".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_another_type(input, &mut encoder)?; + write_another_type(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_another_type(input: &AnotherType, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_another_type(args: &AnotherType, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&3)?; writer.context().push("prop", "Option", "writing property"); writer.write_string("prop")?; - writer.write_nullable_string(&input.prop)?; + writer.write_nullable_string(&args.prop)?; writer.context().pop(); writer.context().push("circular", "Option", "writing property"); writer.write_string("circular")?; - if input.circular.is_some() { - CustomType::write(input.circular.as_ref().as_ref().unwrap(), writer)?; + if args.circular.is_some() { + CustomType::write(args.circular.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } writer.context().pop(); writer.context().push("const", "Option", "writing property"); writer.write_string("const")?; - writer.write_nullable_string(&input.m_const)?; + writer.write_nullable_string(&args.m_const)?; writer.context().pop(); Ok(()) } -pub fn deserialize_another_type(input: &[u8]) -> Result { +pub fn deserialize_another_type(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing object-type: AnotherType".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); read_another_type(&mut reader) } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs index ed36d1900d..29a3d033e8 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs @@ -104,16 +104,16 @@ impl CustomType { } } - pub fn to_buffer(input: &CustomType) -> Result, EncodeError> { - serialize_custom_type(input).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn to_buffer(args: &CustomType) -> Result, EncodeError> { + serialize_custom_type(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } - pub fn from_buffer(input: &[u8]) -> Result { - deserialize_custom_type(input).map_err(|e| DecodeError::TypeReadError(e.to_string())) + pub fn from_buffer(args: &[u8]) -> Result { + deserialize_custom_type(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) } - pub fn write(input: &CustomType, writer: &mut W) -> Result<(), EncodeError> { - write_custom_type(input, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn write(args: &CustomType, writer: &mut W) -> Result<(), EncodeError> { + write_custom_type(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } pub fn read(reader: &mut R) -> Result { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs index fd55943a66..c27c13d17b 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs @@ -21,127 +21,127 @@ use crate::{ sanitize_custom_enum_value }; -pub fn serialize_custom_type(input: &CustomType) -> Result, EncodeError> { +pub fn serialize_custom_type(args: &CustomType) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) object-type: CustomType".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_custom_type(input, &mut encoder)?; + write_custom_type(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_custom_type(args: &CustomType, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&37)?; writer.context().push("str", "String", "writing property"); writer.write_string("str")?; - writer.write_string(&input.str)?; + writer.write_string(&args.str)?; writer.context().pop(); writer.context().push("optStr", "Option", "writing property"); writer.write_string("optStr")?; - writer.write_nullable_string(&input.opt_str)?; + writer.write_nullable_string(&args.opt_str)?; writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.write_string("u")?; - writer.write_u32(&input.u)?; + writer.write_u32(&args.u)?; writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.write_string("optU")?; - writer.write_nullable_u32(&input.opt_u)?; + writer.write_nullable_u32(&args.opt_u)?; writer.context().pop(); writer.context().push("u8", "u8", "writing property"); writer.write_string("u8")?; - writer.write_u8(&input.u8)?; + writer.write_u8(&args.u8)?; writer.context().pop(); writer.context().push("u16", "u16", "writing property"); writer.write_string("u16")?; - writer.write_u16(&input.u16)?; + writer.write_u16(&args.u16)?; writer.context().pop(); writer.context().push("u32", "u32", "writing property"); writer.write_string("u32")?; - writer.write_u32(&input.u32)?; + writer.write_u32(&args.u32)?; writer.context().pop(); writer.context().push("i", "i32", "writing property"); writer.write_string("i")?; - writer.write_i32(&input.i)?; + writer.write_i32(&args.i)?; writer.context().pop(); writer.context().push("i8", "i8", "writing property"); writer.write_string("i8")?; - writer.write_i8(&input.i8)?; + writer.write_i8(&args.i8)?; writer.context().pop(); writer.context().push("i16", "i16", "writing property"); writer.write_string("i16")?; - writer.write_i16(&input.i16)?; + writer.write_i16(&args.i16)?; writer.context().pop(); writer.context().push("i32", "i32", "writing property"); writer.write_string("i32")?; - writer.write_i32(&input.i32)?; + writer.write_i32(&args.i32)?; writer.context().pop(); writer.context().push("bigint", "BigInt", "writing property"); writer.write_string("bigint")?; - writer.write_bigint(&input.bigint)?; + writer.write_bigint(&args.bigint)?; writer.context().pop(); writer.context().push("optBigint", "Option", "writing property"); writer.write_string("optBigint")?; - writer.write_nullable_bigint(&input.opt_bigint)?; + writer.write_nullable_bigint(&args.opt_bigint)?; writer.context().pop(); writer.context().push("bignumber", "BigNumber", "writing property"); writer.write_string("bignumber")?; - writer.write_bignumber(&input.bignumber)?; + writer.write_bignumber(&args.bignumber)?; writer.context().pop(); writer.context().push("optBignumber", "Option", "writing property"); writer.write_string("optBignumber")?; - writer.write_nullable_bignumber(&input.opt_bignumber)?; + writer.write_nullable_bignumber(&args.opt_bignumber)?; writer.context().pop(); writer.context().push("json", "JSON::Value", "writing property"); writer.write_string("json")?; - writer.write_json(&input.json)?; + writer.write_json(&args.json)?; writer.context().pop(); writer.context().push("optJson", "Option", "writing property"); writer.write_string("optJson")?; - writer.write_nullable_json(&input.opt_json)?; + writer.write_nullable_json(&args.opt_json)?; writer.context().pop(); writer.context().push("bytes", "Vec", "writing property"); writer.write_string("bytes")?; - writer.write_bytes(&input.bytes)?; + writer.write_bytes(&args.bytes)?; writer.context().pop(); writer.context().push("optBytes", "Option>", "writing property"); writer.write_string("optBytes")?; - writer.write_nullable_bytes(&input.opt_bytes)?; + writer.write_nullable_bytes(&args.opt_bytes)?; writer.context().pop(); writer.context().push("boolean", "bool", "writing property"); writer.write_string("boolean")?; - writer.write_bool(&input.boolean)?; + writer.write_bool(&args.boolean)?; writer.context().pop(); writer.context().push("optBoolean", "Option", "writing property"); writer.write_string("optBoolean")?; - writer.write_nullable_bool(&input.opt_boolean)?; + writer.write_nullable_bool(&args.opt_boolean)?; writer.context().pop(); writer.context().push("uArray", "Vec", "writing property"); writer.write_string("uArray")?; - writer.write_array(&input.u_array, |writer, item| { + writer.write_array(&args.u_array, |writer, item| { writer.write_u32(item) })?; writer.context().pop(); writer.context().push("uOptArray", "Option>", "writing property"); writer.write_string("uOptArray")?; - writer.write_nullable_array(&input.u_opt_array, |writer, item| { + writer.write_nullable_array(&args.u_opt_array, |writer, item| { writer.write_u32(item) })?; writer.context().pop(); writer.context().push("optUOptArray", "Option>>", "writing property"); writer.write_string("optUOptArray")?; - writer.write_nullable_array(&input.opt_u_opt_array, |writer, item| { + writer.write_nullable_array(&args.opt_u_opt_array, |writer, item| { writer.write_nullable_u32(item) })?; writer.context().pop(); writer.context().push("optStrOptArray", "Option>>", "writing property"); writer.write_string("optStrOptArray")?; - writer.write_nullable_array(&input.opt_str_opt_array, |writer, item| { + writer.write_nullable_array(&args.opt_str_opt_array, |writer, item| { writer.write_nullable_string(item) })?; writer.context().pop(); writer.context().push("uArrayArray", "Vec>", "writing property"); writer.write_string("uArrayArray")?; - writer.write_array(&input.u_array_array, |writer, item| { + writer.write_array(&args.u_array_array, |writer, item| { writer.write_array(item, |writer, item| { writer.write_u32(item) }) @@ -149,7 +149,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("uOptArrayOptArray", "Vec>>>", "writing property"); writer.write_string("uOptArrayOptArray")?; - writer.write_array(&input.u_opt_array_opt_array, |writer, item| { + writer.write_array(&args.u_opt_array_opt_array, |writer, item| { writer.write_nullable_array(item, |writer, item| { writer.write_nullable_u32(item) }) @@ -157,7 +157,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("uArrayOptArrayArray", "Vec>>>", "writing property"); writer.write_string("uArrayOptArrayArray")?; - writer.write_array(&input.u_array_opt_array_array, |writer, item| { + writer.write_array(&args.u_array_opt_array_array, |writer, item| { writer.write_nullable_array(item, |writer, item| { writer.write_array(item, |writer, item| { writer.write_u32(item) @@ -167,7 +167,7 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("crazyArray", "Option>>>>>>", "writing property"); writer.write_string("crazyArray")?; - writer.write_nullable_array(&input.crazy_array, |writer, item| { + writer.write_nullable_array(&args.crazy_array, |writer, item| { writer.write_nullable_array(item, |writer, item| { writer.write_array(item, |writer, item| { writer.write_nullable_array(item, |writer, item| { @@ -179,25 +179,25 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("object", "AnotherType", "writing property"); writer.write_string("object")?; - AnotherType::write(&input.object, writer)?; + AnotherType::write(&args.object, writer)?; writer.context().pop(); writer.context().push("optObject", "Option", "writing property"); writer.write_string("optObject")?; - if input.opt_object.is_some() { - AnotherType::write(input.opt_object.as_ref().as_ref().unwrap(), writer)?; + if args.opt_object.is_some() { + AnotherType::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } writer.context().pop(); writer.context().push("objectArray", "Vec", "writing property"); writer.write_string("objectArray")?; - writer.write_array(&input.object_array, |writer, item| { + writer.write_array(&args.object_array, |writer, item| { AnotherType::write(item, writer) })?; writer.context().pop(); writer.context().push("optObjectArray", "Option>>", "writing property"); writer.write_string("optObjectArray")?; - writer.write_nullable_array(&input.opt_object_array, |writer, item| { + writer.write_nullable_array(&args.opt_object_array, |writer, item| { if item.is_some() { AnotherType::write(item.as_ref().as_ref().unwrap(), writer) } else { @@ -207,31 +207,31 @@ pub fn write_custom_type(input: &CustomType, writer: &mut W) -> Result writer.context().pop(); writer.context().push("en", "CustomEnum", "writing property"); writer.write_string("en")?; - writer.write_i32(&(input.en as i32))?; + writer.write_i32(&(args.en as i32))?; writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.write_string("optEnum")?; - writer.write_nullable_i32(&input.opt_enum.map(|f| f as i32))?; + writer.write_nullable_i32(&args.opt_enum.map(|f| f as i32))?; writer.context().pop(); writer.context().push("enumArray", "Vec", "writing property"); writer.write_string("enumArray")?; - writer.write_array(&input.enum_array, |writer, item| { + writer.write_array(&args.enum_array, |writer, item| { writer.write_i32(&(*item as i32)) })?; writer.context().pop(); writer.context().push("optEnumArray", "Option>>", "writing property"); writer.write_string("optEnumArray")?; - writer.write_nullable_array(&input.opt_enum_array, |writer, item| { + writer.write_nullable_array(&args.opt_enum_array, |writer, item| { writer.write_nullable_i32(&item.map(|f| f as i32)) })?; writer.context().pop(); Ok(()) } -pub fn deserialize_custom_type(input: &[u8]) -> Result { +pub fn deserialize_custom_type(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing object-type: CustomType".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); read_custom_type(&mut reader) } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs index 6f5c741152..838d59b797 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs @@ -31,16 +31,16 @@ impl TestImportAnotherObject { } } - pub fn to_buffer(input: &TestImportAnotherObject) -> Result, EncodeError> { - serialize_test_import_another_object(input).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn to_buffer(args: &TestImportAnotherObject) -> Result, EncodeError> { + serialize_test_import_another_object(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } - pub fn from_buffer(input: &[u8]) -> Result { - deserialize_test_import_another_object(input).map_err(|e| DecodeError::TypeReadError(e.to_string())) + pub fn from_buffer(args: &[u8]) -> Result { + deserialize_test_import_another_object(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) } - pub fn write(input: &TestImportAnotherObject, writer: &mut W) -> Result<(), EncodeError> { - write_test_import_another_object(input, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn write(args: &TestImportAnotherObject, writer: &mut W) -> Result<(), EncodeError> { + write_test_import_another_object(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } pub fn read(reader: &mut R) -> Result { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs index cc02f6e701..43d97eb245 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs @@ -14,27 +14,27 @@ use polywrap_wasm_rs::{ }; use crate::TestImportAnotherObject; -pub fn serialize_test_import_another_object(input: &TestImportAnotherObject) -> Result, EncodeError> { +pub fn serialize_test_import_another_object(args: &TestImportAnotherObject) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) imported object-type: TestImportAnotherObject".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_test_import_another_object(input, &mut encoder)?; + write_test_import_another_object(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_test_import_another_object(input: &TestImportAnotherObject, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_test_import_another_object(args: &TestImportAnotherObject, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&1)?; writer.context().push("prop", "String", "writing property"); writer.write_string("prop")?; - writer.write_string(&input.prop)?; + writer.write_string(&args.prop)?; writer.context().pop(); Ok(()) } -pub fn deserialize_test_import_another_object(input: &[u8]) -> Result { +pub fn deserialize_test_import_another_object(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing imported object-type: TestImportAnotherObject".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); read_test_import_another_object(&mut reader) } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs index a3229dfb3f..d2d26cb8f2 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs @@ -12,10 +12,10 @@ pub mod serialization; pub use serialization::{ deserialize_imported_method_result, serialize_imported_method_args, - InputImportedMethod, + ArgsImportedMethod, deserialize_another_method_result, serialize_another_method_args, - InputAnotherMethod + ArgsAnotherMethod }; use crate::TestImportObject; @@ -31,9 +31,9 @@ impl TestImportModule { TestImportModule {} } - pub fn imported_method(input: &InputImportedMethod) -> Result, String> { + pub fn imported_method(args: &ArgsImportedMethod) -> Result, String> { let uri = TestImportModule::URI; - let args = serialize_imported_method_args(input).map_err(|e| e.to_string())?; + let args = serialize_imported_method_args(args).map_err(|e| e.to_string())?; let result = subinvoke::wrap_subinvoke( uri, "importedMethod", @@ -42,9 +42,9 @@ impl TestImportModule { deserialize_imported_method_result(result.as_slice()).map_err(|e| e.to_string()) } - pub fn another_method(input: &InputAnotherMethod) -> Result { + pub fn another_method(args: &ArgsAnotherMethod) -> Result { let uri = TestImportModule::URI; - let args = serialize_another_method_args(input).map_err(|e| e.to_string())?; + let args = serialize_another_method_args(args).map_err(|e| e.to_string())?; let result = subinvoke::wrap_subinvoke( uri, "anotherMethod", diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs index 32a9e5a23b..755b648166 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs @@ -21,7 +21,7 @@ use crate::{ }; #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct InputImportedMethod { +pub struct ArgsImportedMethod { pub str: String, pub opt_str: Option, pub u: u32, @@ -37,35 +37,35 @@ pub struct InputImportedMethod { pub opt_enum_array: Option>>, } -pub fn serialize_imported_method_args(input: &InputImportedMethod) -> Result, EncodeError> { +pub fn serialize_imported_method_args(args: &ArgsImportedMethod) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) imported module-type: imported_method".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_imported_method_args(input, &mut encoder)?; + write_imported_method_args(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_imported_method_args(input: &InputImportedMethod, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_imported_method_args(args: &ArgsImportedMethod, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&13)?; writer.context().push("str", "String", "writing property"); writer.write_string("str")?; - writer.write_string(&input.str)?; + writer.write_string(&args.str)?; writer.context().pop(); writer.context().push("optStr", "Option", "writing property"); writer.write_string("optStr")?; - writer.write_nullable_string(&input.opt_str)?; + writer.write_nullable_string(&args.opt_str)?; writer.context().pop(); writer.context().push("u", "u32", "writing property"); writer.write_string("u")?; - writer.write_u32(&input.u)?; + writer.write_u32(&args.u)?; writer.context().pop(); writer.context().push("optU", "Option", "writing property"); writer.write_string("optU")?; - writer.write_nullable_u32(&input.opt_u)?; + writer.write_nullable_u32(&args.opt_u)?; writer.context().pop(); writer.context().push("uArrayArray", "Vec>>>", "writing property"); writer.write_string("uArrayArray")?; - writer.write_array(&input.u_array_array, |writer, item| { + writer.write_array(&args.u_array_array, |writer, item| { writer.write_nullable_array(item, |writer, item| { writer.write_nullable_u32(item) }) @@ -73,25 +73,25 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("object", "TestImportObject", "writing property"); writer.write_string("object")?; - TestImportObject::write(&input.object, writer)?; + TestImportObject::write(&args.object, writer)?; writer.context().pop(); writer.context().push("optObject", "Option", "writing property"); writer.write_string("optObject")?; - if input.opt_object.is_some() { - TestImportObject::write(input.opt_object.as_ref().as_ref().unwrap(), writer)?; + if args.opt_object.is_some() { + TestImportObject::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } writer.context().pop(); writer.context().push("objectArray", "Vec", "writing property"); writer.write_string("objectArray")?; - writer.write_array(&input.object_array, |writer, item| { + writer.write_array(&args.object_array, |writer, item| { TestImportObject::write(item, writer) })?; writer.context().pop(); writer.context().push("optObjectArray", "Option>>", "writing property"); writer.write_string("optObjectArray")?; - writer.write_nullable_array(&input.opt_object_array, |writer, item| { + writer.write_nullable_array(&args.opt_object_array, |writer, item| { if item.is_some() { TestImportObject::write(item.as_ref().as_ref().unwrap(), writer) } else { @@ -101,21 +101,21 @@ pub fn write_imported_method_args(input: &InputImportedMethod, writer: writer.context().pop(); writer.context().push("en", "TestImportEnum", "writing property"); writer.write_string("en")?; - writer.write_i32(&(input.en as i32))?; + writer.write_i32(&(args.en as i32))?; writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.write_string("optEnum")?; - writer.write_nullable_i32(&input.opt_enum.map(|f| f as i32))?; + writer.write_nullable_i32(&args.opt_enum.map(|f| f as i32))?; writer.context().pop(); writer.context().push("enumArray", "Vec", "writing property"); writer.write_string("enumArray")?; - writer.write_array(&input.enum_array, |writer, item| { + writer.write_array(&args.enum_array, |writer, item| { writer.write_i32(&(*item as i32)) })?; writer.context().pop(); writer.context().push("optEnumArray", "Option>>", "writing property"); writer.write_string("optEnumArray")?; - writer.write_nullable_array(&input.opt_enum_array, |writer, item| { + writer.write_nullable_array(&args.opt_enum_array, |writer, item| { writer.write_nullable_i32(&item.map(|f| f as i32)) })?; writer.context().pop(); @@ -140,23 +140,23 @@ pub fn deserialize_imported_method_result(result: &[u8]) -> Result, } -pub fn serialize_another_method_args(input: &InputAnotherMethod) -> Result, EncodeError> { +pub fn serialize_another_method_args(args: &ArgsAnotherMethod) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) imported module-type: another_method".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_another_method_args(input, &mut encoder)?; + write_another_method_args(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_another_method_args(input: &InputAnotherMethod, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_another_method_args(args: &ArgsAnotherMethod, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&1)?; writer.context().push("arg", "Vec", "writing property"); writer.write_string("arg")?; - writer.write_array(&input.arg, |writer, item| { + writer.write_array(&args.arg, |writer, item| { writer.write_string(item) })?; writer.context().pop(); diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs index 9da9ab7a82..ab9c3cf3c4 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs @@ -48,16 +48,16 @@ impl TestImportObject { } } - pub fn to_buffer(input: &TestImportObject) -> Result, EncodeError> { - serialize_test_import_object(input).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn to_buffer(args: &TestImportObject) -> Result, EncodeError> { + serialize_test_import_object(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } - pub fn from_buffer(input: &[u8]) -> Result { - deserialize_test_import_object(input).map_err(|e| DecodeError::TypeReadError(e.to_string())) + pub fn from_buffer(args: &[u8]) -> Result { + deserialize_test_import_object(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) } - pub fn write(input: &TestImportObject, writer: &mut W) -> Result<(), EncodeError> { - write_test_import_object(input, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) + pub fn write(args: &TestImportObject, writer: &mut W) -> Result<(), EncodeError> { + write_test_import_object(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) } pub fn read(reader: &mut R) -> Result { diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs index da0947cce0..1901842a55 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs @@ -21,37 +21,37 @@ use crate::{ sanitize_test_import_enum_value }; -pub fn serialize_test_import_object(input: &TestImportObject) -> Result, EncodeError> { +pub fn serialize_test_import_object(args: &TestImportObject) -> Result, EncodeError> { let mut encoder_context = Context::new(); encoder_context.description = "Serializing (encoding) imported object-type: TestImportObject".to_string(); let mut encoder = WriteEncoder::new(&[], encoder_context); - write_test_import_object(input, &mut encoder)?; + write_test_import_object(args, &mut encoder)?; Ok(encoder.get_buffer()) } -pub fn write_test_import_object(input: &TestImportObject, writer: &mut W) -> Result<(), EncodeError> { +pub fn write_test_import_object(args: &TestImportObject, writer: &mut W) -> Result<(), EncodeError> { writer.write_map_length(&8)?; writer.context().push("object", "TestImportAnotherObject", "writing property"); writer.write_string("object")?; - TestImportAnotherObject::write(&input.object, writer)?; + TestImportAnotherObject::write(&args.object, writer)?; writer.context().pop(); writer.context().push("optObject", "Option", "writing property"); writer.write_string("optObject")?; - if input.opt_object.is_some() { - TestImportAnotherObject::write(input.opt_object.as_ref().as_ref().unwrap(), writer)?; + if args.opt_object.is_some() { + TestImportAnotherObject::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; } else { writer.write_nil()?; } writer.context().pop(); writer.context().push("objectArray", "Vec", "writing property"); writer.write_string("objectArray")?; - writer.write_array(&input.object_array, |writer, item| { + writer.write_array(&args.object_array, |writer, item| { TestImportAnotherObject::write(item, writer) })?; writer.context().pop(); writer.context().push("optObjectArray", "Option>>", "writing property"); writer.write_string("optObjectArray")?; - writer.write_nullable_array(&input.opt_object_array, |writer, item| { + writer.write_nullable_array(&args.opt_object_array, |writer, item| { if item.is_some() { TestImportAnotherObject::write(item.as_ref().as_ref().unwrap(), writer) } else { @@ -61,31 +61,31 @@ pub fn write_test_import_object(input: &TestImportObject, writer: &mut writer.context().pop(); writer.context().push("en", "TestImportEnum", "writing property"); writer.write_string("en")?; - writer.write_i32(&(input.en as i32))?; + writer.write_i32(&(args.en as i32))?; writer.context().pop(); writer.context().push("optEnum", "Option", "writing property"); writer.write_string("optEnum")?; - writer.write_nullable_i32(&input.opt_enum.map(|f| f as i32))?; + writer.write_nullable_i32(&args.opt_enum.map(|f| f as i32))?; writer.context().pop(); writer.context().push("enumArray", "Vec", "writing property"); writer.write_string("enumArray")?; - writer.write_array(&input.enum_array, |writer, item| { + writer.write_array(&args.enum_array, |writer, item| { writer.write_i32(&(*item as i32)) })?; writer.context().pop(); writer.context().push("optEnumArray", "Option>>", "writing property"); writer.write_string("optEnumArray")?; - writer.write_nullable_array(&input.opt_enum_array, |writer, item| { + writer.write_nullable_array(&args.opt_enum_array, |writer, item| { writer.write_nullable_i32(&item.map(|f| f as i32)) })?; writer.context().pop(); Ok(()) } -pub fn deserialize_test_import_object(input: &[u8]) -> Result { +pub fn deserialize_test_import_object(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing imported object-type: TestImportObject".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); read_test_import_object(&mut reader) } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs index 8110f0d6f5..5a9b352cde 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs @@ -27,9 +27,9 @@ pub use module::{ deserialize_module_method_args, serialize_module_method_result, module_method_wrapped, - InputModuleMethod, + ArgsModuleMethod, deserialize_object_method_args, serialize_object_method_result, object_method_wrapped, - InputObjectMethod + ArgsObjectMethod }; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs index 3e69228c04..41672cf9f8 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs @@ -7,8 +7,8 @@ pub mod serialization; pub use serialization::{ deserialize_module_method_args, serialize_module_method_result, - InputModuleMethod, + ArgsModuleMethod, deserialize_object_method_args, serialize_object_method_result, - InputObjectMethod + ArgsObjectMethod }; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs index 4aac4eaf93..9b16d025e4 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs +++ b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs @@ -22,7 +22,7 @@ use crate::{ use crate::AnotherType; #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct InputModuleMethod { +pub struct ArgsModuleMethod { pub str: String, pub opt_str: Option, pub en: CustomEnum, @@ -32,11 +32,11 @@ pub struct InputModuleMethod { pub map: Map, } -pub fn deserialize_module_method_args(input: &[u8]) -> Result { +pub fn deserialize_module_method_args(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing module-type: module_method".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); let mut num_of_fields = reader.read_map_length()?; let mut _str: String = String::new(); @@ -155,7 +155,7 @@ pub fn deserialize_module_method_args(input: &[u8]) -> Result.".to_string())); } - Ok(InputModuleMethod { + Ok(ArgsModuleMethod { str: _str, opt_str: _opt_str, en: _en, @@ -182,18 +182,18 @@ pub fn write_module_method_result(result: &i32, writer: &mut W) -> Res } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct InputObjectMethod { +pub struct ArgsObjectMethod { pub object: AnotherType, pub opt_object: Option, pub object_array: Vec, pub opt_object_array: Option>>, } -pub fn deserialize_object_method_args(input: &[u8]) -> Result { +pub fn deserialize_object_method_args(args: &[u8]) -> Result { let mut context = Context::new(); context.description = "Deserializing module-type: object_method".to_string(); - let mut reader = ReadDecoder::new(input, context); + let mut reader = ReadDecoder::new(args, context); let mut num_of_fields = reader.read_map_length()?; let mut _object: AnotherType = AnotherType::new(); @@ -258,7 +258,7 @@ pub fn deserialize_object_method_args(input: &[u8]) -> Result Vec { - match deserialize_module_method_args(input) { +pub fn module_method_wrapped(args: &[u8]) -> Vec { + match deserialize_module_method_args(args) { Ok(args) => { - let result = module_method(InputModuleMethod { + let result = module_method(ArgsModuleMethod { str: args.str, opt_str: args.opt_str, en: args.en, @@ -29,10 +29,10 @@ pub fn module_method_wrapped(input: &[u8]) -> Vec { } } -pub fn object_method_wrapped(input: &[u8]) -> Vec { - match deserialize_object_method_args(input) { +pub fn object_method_wrapped(args: &[u8]) -> Vec { + match deserialize_object_method_args(args) { Ok(args) => { - let result = object_method(InputObjectMethod { + let result = object_method(ArgsObjectMethod { object: args.object, opt_object: args.opt_object, object_array: args.object_array, diff --git a/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/module.ts b/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/module.ts index db2ed36b6c..5d68d6b00e 100644 --- a/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/module.ts +++ b/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/module.ts @@ -9,12 +9,12 @@ import { MaybeAsync } from "@polywrap/core-js"; -export interface Input_methodOne extends Record { +export interface Args_methodOne extends Record { str: Types.String; optStr?: Types.String | null; } -export interface Input_methodTwo extends Record { +export interface Args_methodTwo extends Record { arg: Types.UInt32; } @@ -26,12 +26,12 @@ export abstract class Module< > { abstract methodOne( - input: Input_methodOne, + args: Args_methodOne, client: Client ): MaybeAsync; abstract methodTwo( - input: Input_methodTwo, + args: Args_methodTwo, client: Client ): MaybeAsync; } diff --git a/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/types.ts b/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/types.ts index 40d910d1b7..796131ef49 100644 --- a/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/types.ts +++ b/packages/test-cases/cases/cli/plugin/codegen/001-sanity/expected/src/wrap/types.ts @@ -159,7 +159,7 @@ export interface Ethereum_Access { /// Imported Modules START /// /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_callContractView extends Record { +interface Ethereum_Module_Args_callContractView extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -167,7 +167,7 @@ interface Ethereum_Module_Input_callContractView extends Record } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_callContractStatic extends Record { +interface Ethereum_Module_Args_callContractStatic extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -176,72 +176,72 @@ interface Ethereum_Module_Input_callContractStatic extends Record { +interface Ethereum_Module_Args_getBalance extends Record { address: Types.String; blockTag?: Types.BigInt | null; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_encodeParams extends Record { +interface Ethereum_Module_Args_encodeParams extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_encodeFunction extends Record { +interface Ethereum_Module_Args_encodeFunction extends Record { method: Types.String; args?: Array | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_solidityPack extends Record { +interface Ethereum_Module_Args_solidityPack extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_solidityKeccak256 extends Record { +interface Ethereum_Module_Args_solidityKeccak256 extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_soliditySha256 extends Record { +interface Ethereum_Module_Args_soliditySha256 extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getSignerAddress extends Record { +interface Ethereum_Module_Args_getSignerAddress extends Record { connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getSignerBalance extends Record { +interface Ethereum_Module_Args_getSignerBalance extends Record { blockTag?: Types.BigInt | null; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getSignerTransactionCount extends Record { +interface Ethereum_Module_Args_getSignerTransactionCount extends Record { blockTag?: Types.BigInt | null; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getGasPrice extends Record { +interface Ethereum_Module_Args_getGasPrice extends Record { connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_estimateTransactionGas extends Record { +interface Ethereum_Module_Args_estimateTransactionGas extends Record { tx: Types.Ethereum_TxRequest; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_estimateContractCallGas extends Record { +interface Ethereum_Module_Args_estimateContractCallGas extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -250,22 +250,22 @@ interface Ethereum_Module_Input_estimateContractCallGas extends Record { +interface Ethereum_Module_Args_checkAddress extends Record { address: Types.String; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_toWei extends Record { +interface Ethereum_Module_Args_toWei extends Record { eth: Types.String; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_toEth extends Record { +interface Ethereum_Module_Args_toEth extends Record { wei: Types.BigInt; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_awaitTransaction extends Record { +interface Ethereum_Module_Args_awaitTransaction extends Record { txHash: Types.String; confirmations: Types.UInt32; timeout: Types.UInt32; @@ -273,7 +273,7 @@ interface Ethereum_Module_Input_awaitTransaction extends Record } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_waitForEvent extends Record { +interface Ethereum_Module_Args_waitForEvent extends Record { address: Types.String; event: Types.String; args?: Array | null; @@ -282,12 +282,12 @@ interface Ethereum_Module_Input_waitForEvent extends Record { } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getNetwork extends Record { +interface Ethereum_Module_Args_getNetwork extends Record { connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_callContractMethod extends Record { +interface Ethereum_Module_Args_callContractMethod extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -296,7 +296,7 @@ interface Ethereum_Module_Input_callContractMethod extends Record { +interface Ethereum_Module_Args_callContractMethodAndWait extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -305,19 +305,19 @@ interface Ethereum_Module_Input_callContractMethodAndWait extends Record { +interface Ethereum_Module_Args_sendTransaction extends Record { tx: Types.Ethereum_TxRequest; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_sendTransactionAndWait extends Record { +interface Ethereum_Module_Args_sendTransactionAndWait extends Record { tx: Types.Ethereum_TxRequest; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_deployContract extends Record { +interface Ethereum_Module_Args_deployContract extends Record { abi: Types.String; bytecode: Types.String; args?: Array | null; @@ -325,13 +325,13 @@ interface Ethereum_Module_Input_deployContract extends Record { } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_signMessage extends Record { +interface Ethereum_Module_Args_signMessage extends Record { message: Types.String; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_sendRPC extends Record { +interface Ethereum_Module_Args_sendRPC extends Record { method: Types.String; params: Array; connection?: Types.Ethereum_Connection | null; @@ -340,299 +340,299 @@ interface Ethereum_Module_Input_sendRPC extends Record { /* URI: "ens/ethereum.polywrap.eth" */ export const Ethereum_Module = { callContractView: async ( - input: Ethereum_Module_Input_callContractView, + args: Ethereum_Module_Args_callContractView, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractView", - input + args }); }, callContractStatic: async ( - input: Ethereum_Module_Input_callContractStatic, + args: Ethereum_Module_Args_callContractStatic, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractStatic", - input + args }); }, getBalance: async ( - input: Ethereum_Module_Input_getBalance, + args: Ethereum_Module_Args_getBalance, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getBalance", - input + args }); }, encodeParams: async ( - input: Ethereum_Module_Input_encodeParams, + args: Ethereum_Module_Args_encodeParams, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "encodeParams", - input + args }); }, encodeFunction: async ( - input: Ethereum_Module_Input_encodeFunction, + args: Ethereum_Module_Args_encodeFunction, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "encodeFunction", - input + args }); }, solidityPack: async ( - input: Ethereum_Module_Input_solidityPack, + args: Ethereum_Module_Args_solidityPack, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "solidityPack", - input + args }); }, solidityKeccak256: async ( - input: Ethereum_Module_Input_solidityKeccak256, + args: Ethereum_Module_Args_solidityKeccak256, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "solidityKeccak256", - input + args }); }, soliditySha256: async ( - input: Ethereum_Module_Input_soliditySha256, + args: Ethereum_Module_Args_soliditySha256, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "soliditySha256", - input + args }); }, getSignerAddress: async ( - input: Ethereum_Module_Input_getSignerAddress, + args: Ethereum_Module_Args_getSignerAddress, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getSignerAddress", - input + args }); }, getSignerBalance: async ( - input: Ethereum_Module_Input_getSignerBalance, + args: Ethereum_Module_Args_getSignerBalance, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getSignerBalance", - input + args }); }, getSignerTransactionCount: async ( - input: Ethereum_Module_Input_getSignerTransactionCount, + args: Ethereum_Module_Args_getSignerTransactionCount, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getSignerTransactionCount", - input + args }); }, getGasPrice: async ( - input: Ethereum_Module_Input_getGasPrice, + args: Ethereum_Module_Args_getGasPrice, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getGasPrice", - input + args }); }, estimateTransactionGas: async ( - input: Ethereum_Module_Input_estimateTransactionGas, + args: Ethereum_Module_Args_estimateTransactionGas, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "estimateTransactionGas", - input + args }); }, estimateContractCallGas: async ( - input: Ethereum_Module_Input_estimateContractCallGas, + args: Ethereum_Module_Args_estimateContractCallGas, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "estimateContractCallGas", - input + args }); }, checkAddress: async ( - input: Ethereum_Module_Input_checkAddress, + args: Ethereum_Module_Args_checkAddress, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "checkAddress", - input + args }); }, toWei: async ( - input: Ethereum_Module_Input_toWei, + args: Ethereum_Module_Args_toWei, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "toWei", - input + args }); }, toEth: async ( - input: Ethereum_Module_Input_toEth, + args: Ethereum_Module_Args_toEth, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "toEth", - input + args }); }, awaitTransaction: async ( - input: Ethereum_Module_Input_awaitTransaction, + args: Ethereum_Module_Args_awaitTransaction, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "awaitTransaction", - input + args }); }, waitForEvent: async ( - input: Ethereum_Module_Input_waitForEvent, + args: Ethereum_Module_Args_waitForEvent, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "waitForEvent", - input + args }); }, getNetwork: async ( - input: Ethereum_Module_Input_getNetwork, + args: Ethereum_Module_Args_getNetwork, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getNetwork", - input + args }); }, callContractMethod: async ( - input: Ethereum_Module_Input_callContractMethod, + args: Ethereum_Module_Args_callContractMethod, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractMethod", - input + args }); }, callContractMethodAndWait: async ( - input: Ethereum_Module_Input_callContractMethodAndWait, + args: Ethereum_Module_Args_callContractMethodAndWait, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractMethodAndWait", - input + args }); }, sendTransaction: async ( - input: Ethereum_Module_Input_sendTransaction, + args: Ethereum_Module_Args_sendTransaction, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "sendTransaction", - input + args }); }, sendTransactionAndWait: async ( - input: Ethereum_Module_Input_sendTransactionAndWait, + args: Ethereum_Module_Args_sendTransactionAndWait, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "sendTransactionAndWait", - input + args }); }, deployContract: async ( - input: Ethereum_Module_Input_deployContract, + args: Ethereum_Module_Args_deployContract, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "deployContract", - input + args }); }, signMessage: async ( - input: Ethereum_Module_Input_signMessage, + args: Ethereum_Module_Args_signMessage, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "signMessage", - input + args }); }, sendRPC: async ( - input: Ethereum_Module_Input_sendRPC, + args: Ethereum_Module_Args_sendRPC, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "sendRPC", - input + args }); } } diff --git a/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/module.ts b/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/module.ts index ddf61a521c..cc9669e5be 100644 --- a/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/module.ts +++ b/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/module.ts @@ -9,7 +9,7 @@ import { MaybeAsync } from "@polywrap/core-js"; -export interface Input_method extends Record { +export interface Args_method extends Record { str: Types.String; optStr?: Types.String | null; } @@ -22,7 +22,7 @@ export abstract class Module< > { abstract method( - input: Input_method, + args: Args_method, client: Client ): MaybeAsync; } diff --git a/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/types.ts b/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/types.ts index 40d910d1b7..796131ef49 100644 --- a/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/types.ts +++ b/packages/test-cases/cases/cli/plugin/codegen/002-single-module/expected/src/wrap/types.ts @@ -159,7 +159,7 @@ export interface Ethereum_Access { /// Imported Modules START /// /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_callContractView extends Record { +interface Ethereum_Module_Args_callContractView extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -167,7 +167,7 @@ interface Ethereum_Module_Input_callContractView extends Record } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_callContractStatic extends Record { +interface Ethereum_Module_Args_callContractStatic extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -176,72 +176,72 @@ interface Ethereum_Module_Input_callContractStatic extends Record { +interface Ethereum_Module_Args_getBalance extends Record { address: Types.String; blockTag?: Types.BigInt | null; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_encodeParams extends Record { +interface Ethereum_Module_Args_encodeParams extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_encodeFunction extends Record { +interface Ethereum_Module_Args_encodeFunction extends Record { method: Types.String; args?: Array | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_solidityPack extends Record { +interface Ethereum_Module_Args_solidityPack extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_solidityKeccak256 extends Record { +interface Ethereum_Module_Args_solidityKeccak256 extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_soliditySha256 extends Record { +interface Ethereum_Module_Args_soliditySha256 extends Record { types: Array; values: Array; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getSignerAddress extends Record { +interface Ethereum_Module_Args_getSignerAddress extends Record { connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getSignerBalance extends Record { +interface Ethereum_Module_Args_getSignerBalance extends Record { blockTag?: Types.BigInt | null; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getSignerTransactionCount extends Record { +interface Ethereum_Module_Args_getSignerTransactionCount extends Record { blockTag?: Types.BigInt | null; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getGasPrice extends Record { +interface Ethereum_Module_Args_getGasPrice extends Record { connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_estimateTransactionGas extends Record { +interface Ethereum_Module_Args_estimateTransactionGas extends Record { tx: Types.Ethereum_TxRequest; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_estimateContractCallGas extends Record { +interface Ethereum_Module_Args_estimateContractCallGas extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -250,22 +250,22 @@ interface Ethereum_Module_Input_estimateContractCallGas extends Record { +interface Ethereum_Module_Args_checkAddress extends Record { address: Types.String; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_toWei extends Record { +interface Ethereum_Module_Args_toWei extends Record { eth: Types.String; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_toEth extends Record { +interface Ethereum_Module_Args_toEth extends Record { wei: Types.BigInt; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_awaitTransaction extends Record { +interface Ethereum_Module_Args_awaitTransaction extends Record { txHash: Types.String; confirmations: Types.UInt32; timeout: Types.UInt32; @@ -273,7 +273,7 @@ interface Ethereum_Module_Input_awaitTransaction extends Record } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_waitForEvent extends Record { +interface Ethereum_Module_Args_waitForEvent extends Record { address: Types.String; event: Types.String; args?: Array | null; @@ -282,12 +282,12 @@ interface Ethereum_Module_Input_waitForEvent extends Record { } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_getNetwork extends Record { +interface Ethereum_Module_Args_getNetwork extends Record { connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_callContractMethod extends Record { +interface Ethereum_Module_Args_callContractMethod extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -296,7 +296,7 @@ interface Ethereum_Module_Input_callContractMethod extends Record { +interface Ethereum_Module_Args_callContractMethodAndWait extends Record { address: Types.String; method: Types.String; args?: Array | null; @@ -305,19 +305,19 @@ interface Ethereum_Module_Input_callContractMethodAndWait extends Record { +interface Ethereum_Module_Args_sendTransaction extends Record { tx: Types.Ethereum_TxRequest; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_sendTransactionAndWait extends Record { +interface Ethereum_Module_Args_sendTransactionAndWait extends Record { tx: Types.Ethereum_TxRequest; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_deployContract extends Record { +interface Ethereum_Module_Args_deployContract extends Record { abi: Types.String; bytecode: Types.String; args?: Array | null; @@ -325,13 +325,13 @@ interface Ethereum_Module_Input_deployContract extends Record { } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_signMessage extends Record { +interface Ethereum_Module_Args_signMessage extends Record { message: Types.String; connection?: Types.Ethereum_Connection | null; } /* URI: "ens/ethereum.polywrap.eth" */ -interface Ethereum_Module_Input_sendRPC extends Record { +interface Ethereum_Module_Args_sendRPC extends Record { method: Types.String; params: Array; connection?: Types.Ethereum_Connection | null; @@ -340,299 +340,299 @@ interface Ethereum_Module_Input_sendRPC extends Record { /* URI: "ens/ethereum.polywrap.eth" */ export const Ethereum_Module = { callContractView: async ( - input: Ethereum_Module_Input_callContractView, + args: Ethereum_Module_Args_callContractView, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractView", - input + args }); }, callContractStatic: async ( - input: Ethereum_Module_Input_callContractStatic, + args: Ethereum_Module_Args_callContractStatic, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractStatic", - input + args }); }, getBalance: async ( - input: Ethereum_Module_Input_getBalance, + args: Ethereum_Module_Args_getBalance, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getBalance", - input + args }); }, encodeParams: async ( - input: Ethereum_Module_Input_encodeParams, + args: Ethereum_Module_Args_encodeParams, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "encodeParams", - input + args }); }, encodeFunction: async ( - input: Ethereum_Module_Input_encodeFunction, + args: Ethereum_Module_Args_encodeFunction, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "encodeFunction", - input + args }); }, solidityPack: async ( - input: Ethereum_Module_Input_solidityPack, + args: Ethereum_Module_Args_solidityPack, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "solidityPack", - input + args }); }, solidityKeccak256: async ( - input: Ethereum_Module_Input_solidityKeccak256, + args: Ethereum_Module_Args_solidityKeccak256, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "solidityKeccak256", - input + args }); }, soliditySha256: async ( - input: Ethereum_Module_Input_soliditySha256, + args: Ethereum_Module_Args_soliditySha256, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "soliditySha256", - input + args }); }, getSignerAddress: async ( - input: Ethereum_Module_Input_getSignerAddress, + args: Ethereum_Module_Args_getSignerAddress, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getSignerAddress", - input + args }); }, getSignerBalance: async ( - input: Ethereum_Module_Input_getSignerBalance, + args: Ethereum_Module_Args_getSignerBalance, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getSignerBalance", - input + args }); }, getSignerTransactionCount: async ( - input: Ethereum_Module_Input_getSignerTransactionCount, + args: Ethereum_Module_Args_getSignerTransactionCount, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getSignerTransactionCount", - input + args }); }, getGasPrice: async ( - input: Ethereum_Module_Input_getGasPrice, + args: Ethereum_Module_Args_getGasPrice, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getGasPrice", - input + args }); }, estimateTransactionGas: async ( - input: Ethereum_Module_Input_estimateTransactionGas, + args: Ethereum_Module_Args_estimateTransactionGas, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "estimateTransactionGas", - input + args }); }, estimateContractCallGas: async ( - input: Ethereum_Module_Input_estimateContractCallGas, + args: Ethereum_Module_Args_estimateContractCallGas, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "estimateContractCallGas", - input + args }); }, checkAddress: async ( - input: Ethereum_Module_Input_checkAddress, + args: Ethereum_Module_Args_checkAddress, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "checkAddress", - input + args }); }, toWei: async ( - input: Ethereum_Module_Input_toWei, + args: Ethereum_Module_Args_toWei, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "toWei", - input + args }); }, toEth: async ( - input: Ethereum_Module_Input_toEth, + args: Ethereum_Module_Args_toEth, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "toEth", - input + args }); }, awaitTransaction: async ( - input: Ethereum_Module_Input_awaitTransaction, + args: Ethereum_Module_Args_awaitTransaction, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "awaitTransaction", - input + args }); }, waitForEvent: async ( - input: Ethereum_Module_Input_waitForEvent, + args: Ethereum_Module_Args_waitForEvent, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "waitForEvent", - input + args }); }, getNetwork: async ( - input: Ethereum_Module_Input_getNetwork, + args: Ethereum_Module_Args_getNetwork, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "getNetwork", - input + args }); }, callContractMethod: async ( - input: Ethereum_Module_Input_callContractMethod, + args: Ethereum_Module_Args_callContractMethod, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractMethod", - input + args }); }, callContractMethodAndWait: async ( - input: Ethereum_Module_Input_callContractMethodAndWait, + args: Ethereum_Module_Args_callContractMethodAndWait, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "callContractMethodAndWait", - input + args }); }, sendTransaction: async ( - input: Ethereum_Module_Input_sendTransaction, + args: Ethereum_Module_Args_sendTransaction, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "sendTransaction", - input + args }); }, sendTransactionAndWait: async ( - input: Ethereum_Module_Input_sendTransactionAndWait, + args: Ethereum_Module_Args_sendTransactionAndWait, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "sendTransactionAndWait", - input + args }); }, deployContract: async ( - input: Ethereum_Module_Input_deployContract, + args: Ethereum_Module_Args_deployContract, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "deployContract", - input + args }); }, signMessage: async ( - input: Ethereum_Module_Input_signMessage, + args: Ethereum_Module_Args_signMessage, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "signMessage", - input + args }); }, sendRPC: async ( - input: Ethereum_Module_Input_sendRPC, + args: Ethereum_Module_Args_sendRPC, client: Client ): Promise> => { return client.invoke({ uri: "ens/ethereum.polywrap.eth", method: "sendRPC", - input + args }); } } diff --git a/packages/test-cases/cases/cli/plugin/codegen/003-env/expected/src/wrap/module.ts b/packages/test-cases/cases/cli/plugin/codegen/003-env/expected/src/wrap/module.ts index bee6b1bad0..adb37990bf 100644 --- a/packages/test-cases/cases/cli/plugin/codegen/003-env/expected/src/wrap/module.ts +++ b/packages/test-cases/cases/cli/plugin/codegen/003-env/expected/src/wrap/module.ts @@ -9,7 +9,7 @@ import { MaybeAsync } from "@polywrap/core-js"; -export interface Input_method extends Record { +export interface Args_method extends Record { str: Types.String; } @@ -21,7 +21,7 @@ export abstract class Module< > { abstract method( - input: Input_method, + args: Args_method, client: Client ): MaybeAsync; } diff --git a/packages/test-cases/cases/cli/plugin/codegen/004-env-sanitization/expected/src/wrap/module.ts b/packages/test-cases/cases/cli/plugin/codegen/004-env-sanitization/expected/src/wrap/module.ts index 96ad7a7660..7a9c6f4ba7 100644 --- a/packages/test-cases/cases/cli/plugin/codegen/004-env-sanitization/expected/src/wrap/module.ts +++ b/packages/test-cases/cases/cli/plugin/codegen/004-env-sanitization/expected/src/wrap/module.ts @@ -9,11 +9,11 @@ import { MaybeAsync } from "@polywrap/core-js"; -export interface Input_sanitizeEnv extends Record { +export interface Args_sanitizeEnv extends Record { env: Types.ClientEnv; } -export interface Input_method extends Record { +export interface Args_method extends Record { str: Types.String; } @@ -26,12 +26,12 @@ export abstract class Module< > { abstract sanitizeEnv( - input: Input_sanitizeEnv, + args: Args_sanitizeEnv, client: Client ): MaybeAsync; abstract method( - input: Input_method, + args: Args_method, client: Client ): MaybeAsync; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/001-sanity/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/001-sanity/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/001-sanity/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/001-sanity/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/004-default-build/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/004-default-build/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/004-default-build/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/004-default-build/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/005-default-dockerfile/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/005-default-dockerfile/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/005-default-dockerfile/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/005-default-dockerfile/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/006-custom-dockerfile/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/006-custom-dockerfile/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/006-custom-dockerfile/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/006-custom-dockerfile/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/007-linked-packages/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/007-linked-packages/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/007-linked-packages/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/007-linked-packages/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/008-metadata/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/008-metadata/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/008-metadata/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/008-metadata/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/build-cmd/009-docker-buildx/src/index.ts b/packages/test-cases/cases/cli/wasm/build-cmd/009-docker-buildx/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/build-cmd/009-docker-buildx/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/build-cmd/009-docker-buildx/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/codegen/001-sanity/src/index.ts b/packages/test-cases/cases/cli/wasm/codegen/001-sanity/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/codegen/001-sanity/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/codegen/001-sanity/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/codegen/002-invalid-codegen-script/src/index.ts b/packages/test-cases/cases/cli/wasm/codegen/002-invalid-codegen-script/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/codegen/002-invalid-codegen-script/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/codegen/002-invalid-codegen-script/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/codegen/003-codegen-script/src/index.ts b/packages/test-cases/cases/cli/wasm/codegen/003-codegen-script/src/index.ts index c044ed3188..862d4cb226 100644 --- a/packages/test-cases/cases/cli/wasm/codegen/003-codegen-script/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/codegen/003-codegen-script/src/index.ts @@ -1,5 +1,5 @@ -import { Input_method } from "./wrap"; +import { Args_method } from "./wrap"; -export function method(input: Input_method): string { - return input.arg; +export function method(args: Args_method): string { + return args.arg; } diff --git a/packages/test-cases/cases/cli/wasm/deploy/001-sanity/src/index.ts b/packages/test-cases/cases/cli/wasm/deploy/001-sanity/src/index.ts index 1b02cda239..bc65c781df 100644 --- a/packages/test-cases/cases/cli/wasm/deploy/001-sanity/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/deploy/001-sanity/src/index.ts @@ -1,5 +1,5 @@ -import { Input_get } from "./wrap"; +import { Args_get } from "./wrap"; -export function get(input: Input_get): string { +export function get(args: Args_get): string { return "foo"; } diff --git a/packages/test-cases/cases/cli/wasm/deploy/002-no-ext/src/index.ts b/packages/test-cases/cases/cli/wasm/deploy/002-no-ext/src/index.ts index 1b02cda239..bc65c781df 100644 --- a/packages/test-cases/cases/cli/wasm/deploy/002-no-ext/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/deploy/002-no-ext/src/index.ts @@ -1,5 +1,5 @@ -import { Input_get } from "./wrap"; +import { Args_get } from "./wrap"; -export function get(input: Input_get): string { +export function get(args: Args_get): string { return "foo"; } diff --git a/packages/test-cases/cases/cli/wasm/deploy/003-invalid-config/src/index.ts b/packages/test-cases/cases/cli/wasm/deploy/003-invalid-config/src/index.ts index 1b02cda239..bc65c781df 100644 --- a/packages/test-cases/cases/cli/wasm/deploy/003-invalid-config/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/deploy/003-invalid-config/src/index.ts @@ -1,5 +1,5 @@ -import { Input_get } from "./wrap"; +import { Args_get } from "./wrap"; -export function get(input: Input_get): string { +export function get(args: Args_get): string { return "foo"; } diff --git a/packages/test-cases/cases/cli/wasm/deploy/004-fail-between/src/index.ts b/packages/test-cases/cases/cli/wasm/deploy/004-fail-between/src/index.ts index 1b02cda239..bc65c781df 100644 --- a/packages/test-cases/cases/cli/wasm/deploy/004-fail-between/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/deploy/004-fail-between/src/index.ts @@ -1,5 +1,5 @@ -import { Input_get } from "./wrap"; +import { Args_get } from "./wrap"; -export function get(input: Input_get): string { +export function get(args: Args_get): string { return "foo"; } diff --git a/packages/test-cases/cases/cli/wasm/deploy/005-non-loaded-env-var/src/index.ts b/packages/test-cases/cases/cli/wasm/deploy/005-non-loaded-env-var/src/index.ts index 1b02cda239..bc65c781df 100644 --- a/packages/test-cases/cases/cli/wasm/deploy/005-non-loaded-env-var/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/deploy/005-non-loaded-env-var/src/index.ts @@ -1,5 +1,5 @@ -import { Input_get } from "./wrap"; +import { Args_get } from "./wrap"; -export function get(input: Input_get): string { +export function get(args: Args_get): string { return "foo"; } diff --git a/packages/test-cases/cases/cli/wasm/run/client-async-config.js b/packages/test-cases/cases/cli/wasm/run/client-async-config.js index cafb9c8356..ce70b6d1e1 100644 --- a/packages/test-cases/cases/cli/wasm/run/client-async-config.js +++ b/packages/test-cases/cases/cli/wasm/run/client-async-config.js @@ -5,8 +5,8 @@ const mockPlugin = () => { class MockPlugin extends PluginModule { getData() { return this.config.val; } - setData(input) { - this.config.val = +input.options.value; + setData(args) { + this.config.val = +args.options.value; return { txReceipt: "0xdone", value: this.config.val }; } diff --git a/packages/test-cases/cases/cli/wasm/run/client-async-config.ts b/packages/test-cases/cases/cli/wasm/run/client-async-config.ts index 6399fb916f..e0e08021cc 100644 --- a/packages/test-cases/cases/cli/wasm/run/client-async-config.ts +++ b/packages/test-cases/cases/cli/wasm/run/client-async-config.ts @@ -8,8 +8,8 @@ interface Config extends Record { class MockPlugin extends PluginModule { getData(_: unknown): number { return this.config.val; } - setData(input: { options: { value: number } }) { - this.config.val = +input.options.value; + setData(args: { options: { value: number } }) { + this.config.val = +args.options.value; return { txReceipt: "0xdone", value: this.config.val }; } diff --git a/packages/test-cases/cases/cli/wasm/run/client-config.js b/packages/test-cases/cases/cli/wasm/run/client-config.js index 711b490b7c..38240a8db3 100644 --- a/packages/test-cases/cases/cli/wasm/run/client-config.js +++ b/packages/test-cases/cases/cli/wasm/run/client-config.js @@ -6,8 +6,8 @@ const mockPlugin = () => { getData() { return this.config.val; } - setData(input) { - this.config.val = +input.options.value; + setData(args) { + this.config.val = +args.options.value; return { txReceipt: "0xdone", value: this.config.val }; } diff --git a/packages/test-cases/cases/cli/wasm/run/client-config.ts b/packages/test-cases/cases/cli/wasm/run/client-config.ts index c465ed930b..297db8741e 100644 --- a/packages/test-cases/cases/cli/wasm/run/client-config.ts +++ b/packages/test-cases/cases/cli/wasm/run/client-config.ts @@ -9,8 +9,8 @@ class MockPlugin extends PluginModule { getData(_: unknown): number { return this.config.val; } - setData(input: { options: { value: number } }) { - this.config.val = +input.options.value; + setData(args: { options: { value: number } }) { + this.config.val = +args.options.value; return { txReceipt: "0xdone", value: this.config.val }; } diff --git a/packages/test-cases/cases/cli/wasm/run/src/index.ts b/packages/test-cases/cases/cli/wasm/run/src/index.ts index 3abf40fd1d..6b5e84959e 100644 --- a/packages/test-cases/cases/cli/wasm/run/src/index.ts +++ b/packages/test-cases/cases/cli/wasm/run/src/index.ts @@ -1,43 +1,43 @@ import { Ethereum_Module } from "./wrap/imported"; import { - Input_getData, - Input_setData, - Input_deployContract, + Args_getData, + Args_setData, + Args_deployContract, SetDataResult } from "./wrap"; -export function getData(input: Input_getData): u32 { +export function getData(args: Args_getData): u32 { const res = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function get() view returns (uint256)", args: null, - connection: input.connection + connection: args.connection }).unwrap(); return U32.parseInt(res); } -export function setData(input: Input_setData): SetDataResult { +export function setData(args: Args_setData): SetDataResult { const receipt = Ethereum_Module.callContractMethodAndWait({ - address: input.options.address, + address: args.options.address, method: "function set(uint256 value)", - args: [input.options.value.toString()], - connection: input.connection, + args: [args.options.value.toString()], + connection: args.connection, txOverrides: null }).unwrap(); return { txReceipt: receipt.transactionHash, - value: input.options.value + value: args.options.value }; } -export function deployContract(input: Input_deployContract): string { +export function deployContract(args: Args_deployContract): string { return Ethereum_Module.deployContract({ abi: `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]`, bytecode: "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033", args: null, - connection: input.connection + connection: args.connection }).unwrap(); } diff --git a/packages/test-cases/cases/cli/wasm/run/workflows/e2e.json b/packages/test-cases/cases/cli/wasm/run/workflows/e2e.json index 7193a1c6ce..0f6da03b44 100644 --- a/packages/test-cases/cases/cli/wasm/run/workflows/e2e.json +++ b/packages/test-cases/cases/cli/wasm/run/workflows/e2e.json @@ -6,7 +6,7 @@ { "uri": "fs/build", "method": "deployContract", - "input": { "connection": null } + "args": { "connection": null } } ], "jobs": { @@ -15,7 +15,7 @@ { "uri": "fs/build", "method": "setData", - "input": { + "args": { "options": { "address": "$cases.0.data", "value": 100 @@ -26,7 +26,7 @@ { "uri": "fs/build", "method": "getData", - "input": { "address": "$cases.0.data", "connection": null } + "args": { "address": "$cases.0.data", "connection": null } } ] } diff --git a/packages/test-cases/cases/cli/wasm/run/workflows/e2e.yaml b/packages/test-cases/cases/cli/wasm/run/workflows/e2e.yaml index 450829495e..d023d44941 100644 --- a/packages/test-cases/cases/cli/wasm/run/workflows/e2e.yaml +++ b/packages/test-cases/cases/cli/wasm/run/workflows/e2e.yaml @@ -4,20 +4,20 @@ jobs: steps: - uri: fs/build method: deployContract - input: + args: connection: null jobs: case1: steps: - uri: fs/build method: setData - input: + args: options: address: "$cases.0.data" value: 100 connection: null - uri: fs/build method: getData - input: + args: address: "$cases.0.data" connection: null diff --git a/packages/test-cases/cases/wrappers/wasm-as/asyncify/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/asyncify/src/index.ts index 14339e377a..2c37be55e7 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/asyncify/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/asyncify/src/index.ts @@ -1,21 +1,21 @@ import { - Input_getData, - Input_setDataWithLargeArgs, - Input_deployContract, - Input_localVarMethod, - Input_globalVarMethod, - Input_subsequentInvokes, - Input_setDataWithManyArgs, - Input_setDataWithManyStructuredArgs, + Args_getData, + Args_setDataWithLargeArgs, + Args_deployContract, + Args_localVarMethod, + Args_globalVarMethod, + Args_subsequentInvokes, + Args_setDataWithManyArgs, + Args_setDataWithManyStructuredArgs, Ethereum_Module, } from "./wrap"; -export function getData(input: Input_getData): u32 { +export function getData(args: Args_getData): u32 { const res = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function get() view returns (uint256)", args: null, - connection: input.connection + connection: args.connection }).unwrap(); return U32.parseInt(res); @@ -26,78 +26,78 @@ export function returnTrue(): boolean { } export function setDataWithLargeArgs( - input: Input_setDataWithLargeArgs + args: Args_setDataWithLargeArgs ): string { - const largeString = input.value; + const largeString = args.value; Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", args: ["66"], - connection: input.connection, + connection: args.connection, }).unwrap(); return largeString; } -export function setDataWithManyArgs(input: Input_setDataWithManyArgs): string { - const argsA = input.valueA; - const argsB = input.valueB; - const argsC = input.valueC; - const argsD = input.valueD; - const argsE = input.valueE; - const argsF = input.valueF; - const argsG = input.valueG; - const argsH = input.valueH; - const argsI = input.valueI; - const argsJ = input.valueJ; - const argsK = input.valueK; - const argsL = input.valueL; +export function setDataWithManyArgs(args: Args_setDataWithManyArgs): string { + const argsA = args.valueA; + const argsB = args.valueB; + const argsC = args.valueC; + const argsD = args.valueD; + const argsE = args.valueE; + const argsF = args.valueF; + const argsG = args.valueG; + const argsH = args.valueH; + const argsI = args.valueI; + const argsJ = args.valueJ; + const argsK = args.valueK; + const argsL = args.valueL; Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", args: ["55"], - connection: input.connection, + connection: args.connection, }).unwrap(); return argsA + argsB + argsC + argsD + argsE + argsF + argsG + argsH + argsI + argsJ + argsK + argsL; } export function setDataWithManyStructuredArgs( - input: Input_setDataWithManyStructuredArgs + args: Args_setDataWithManyStructuredArgs ): boolean { Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", args: ["44"], - connection: input.connection, + connection: args.connection, }).unwrap(); return true; } -export function deployContract(input: Input_deployContract): string { +export function deployContract(args: Args_deployContract): string { return Ethereum_Module.deployContract({ abi: `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]`, bytecode: "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033", args: null, - connection: input.connection, + connection: args.connection, }).unwrap(); } -export function localVarMethod(input: Input_localVarMethod): boolean { +export function localVarMethod(args: Args_localVarMethod): boolean { let functionArg = false; functionArg = returnTrue(); Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", args: ["88"], - connection: input.connection, + connection: args.connection, }).unwrap(); return functionArg; @@ -105,35 +105,35 @@ export function localVarMethod(input: Input_localVarMethod): boolean { let globalValue = false; -export function globalVarMethod(input: Input_globalVarMethod): boolean { +export function globalVarMethod(args: Args_globalVarMethod): boolean { globalValue = true; Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", args: ["77"], - connection: input.connection, + connection: args.connection, }).unwrap(); return globalValue; } -export function subsequentInvokes(input: Input_subsequentInvokes): string[] { +export function subsequentInvokes(args: Args_subsequentInvokes): string[] { const result: string[] = []; - for (let i = 0; i < input.numberOfTimes; i++) { + for (let i = 0; i < args.numberOfTimes; i++) { Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", args: [i.toString()], - connection: input.connection, + connection: args.connection, }).unwrap(); result[i] = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function get() view returns (uint256)", args: null, - connection: input.connection, + connection: args.connection, }).unwrap(); } diff --git a/packages/test-cases/cases/wrappers/wasm-as/bigint-type/schema.graphql b/packages/test-cases/cases/wrappers/wasm-as/bigint-type/schema.graphql index 13292e028e..7696ac2202 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/bigint-type/schema.graphql +++ b/packages/test-cases/cases/wrappers/wasm-as/bigint-type/schema.graphql @@ -2,11 +2,11 @@ type Module { method( arg1: BigInt! arg2: BigInt - obj: BigIntInput! + obj: BigIntArg! ): BigInt! } -type BigIntInput { +type BigIntArg { prop1: BigInt! prop2: BigInt } diff --git a/packages/test-cases/cases/wrappers/wasm-as/bigint-type/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/bigint-type/src/index.ts index d98e6eb91c..496f54f6cc 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/bigint-type/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/bigint-type/src/index.ts @@ -1,16 +1,16 @@ import { - Input_method + Args_method } from "./wrap"; import { BigInt } from "@polywrap/wasm-as"; -export function method(input: Input_method): BigInt { - let result = input.arg1.mul(input.obj.prop1); +export function method(args: Args_method): BigInt { + let result = args.arg1.mul(args.obj.prop1); - if (input.arg2) { - result = result.mul(input.arg2 as BigInt); + if (args.arg2) { + result = result.mul(args.arg2 as BigInt); } - if (input.obj.prop2) { - result = result.mul(input.obj.prop2 as BigInt); + if (args.obj.prop2) { + result = result.mul(args.obj.prop2 as BigInt); } return result; diff --git a/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/schema.graphql b/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/schema.graphql index bc4fff129c..ffe506dec2 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/schema.graphql +++ b/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/schema.graphql @@ -2,11 +2,11 @@ type Module { method( arg1: BigNumber! arg2: BigNumber - obj: BigNumberInput! + obj: BigNumberArg! ): BigNumber! } -type BigNumberInput { +type BigNumberArg { prop1: BigNumber! prop2: BigNumber } diff --git a/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/src/index.ts index 36f4dedecc..84bdb6face 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/bignumber-type/src/index.ts @@ -1,16 +1,16 @@ import { - Input_method + Args_method } from "./wrap"; import { BigNumber } from "@polywrap/wasm-as"; -export function method(input: Input_method): BigNumber { - let result = input.arg1.mul(input.obj.prop1); +export function method(args: Args_method): BigNumber { + let result = args.arg1.mul(args.obj.prop1); - if (input.arg2) { - result = result.mul(input.arg2 as BigNumber); + if (args.arg2) { + result = result.mul(args.arg2 as BigNumber); } - if (input.obj.prop2) { - result = result.mul(input.obj.prop2 as BigNumber); + if (args.obj.prop2) { + result = result.mul(args.obj.prop2 as BigNumber); } return result; diff --git a/packages/test-cases/cases/wrappers/wasm-as/bytes-type/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/bytes-type/src/index.ts index 1603d66a36..9a73d639c9 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/bytes-type/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/bytes-type/src/index.ts @@ -1,9 +1,9 @@ import { - Input_bytesMethod + Args_bytesMethod } from "./wrap"; -export function bytesMethod(input: Input_bytesMethod): ArrayBuffer { - const argStr = String.UTF8.decode(input.arg.prop); +export function bytesMethod(args: Args_bytesMethod): ArrayBuffer { + const argStr = String.UTF8.decode(args.arg.prop); const sanityStr = argStr + " Sanity!"; const sanityBuffer = String.UTF8.encode(sanityStr); return sanityBuffer; diff --git a/packages/test-cases/cases/wrappers/wasm-as/enum-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/enum-types/src/index.ts index d028211676..9a381f8de4 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/enum-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/enum-types/src/index.ts @@ -1,13 +1,13 @@ import { SanityEnum, - Input_method1, - Input_method2, + Args_method1, + Args_method2, } from "./wrap"; -export function method1(input: Input_method1): SanityEnum { - return input.en; +export function method1(args: Args_method1): SanityEnum { + return args.en; } -export function method2(input: Input_method2): SanityEnum[] { - return input.enumArray; +export function method2(args: Args_method2): SanityEnum[] { + return args.enumArray; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/env-client-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/env-client-types/src/index.ts index ad3d771ddc..9cf9c52371 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/env-client-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/env-client-types/src/index.ts @@ -1,18 +1,18 @@ import { env, - Input_environment, - Input_sanitizeEnv, + Args_environment, + Args_sanitizeEnv, Env } from "./wrap"; -export function environment(input: Input_environment): Env { +export function environment(args: Args_environment): Env { return env as Env; } -export function sanitizeEnv(input: Input_sanitizeEnv): Env { +export function sanitizeEnv(args: Args_sanitizeEnv): Env { return { - str: input.env.str, - optStr: input.env.optStr, + str: args.env.str, + optStr: args.env.optStr, defStr: "default string", } } diff --git a/packages/test-cases/cases/wrappers/wasm-as/env-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/env-types/src/index.ts index f2f9afa52b..d3f80428d6 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/env-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/env-types/src/index.ts @@ -1,9 +1,9 @@ import { env, Env, - Input_moduleEnv, + Args_moduleEnv, } from "./wrap"; -export function moduleEnv(input: Input_moduleEnv): Env { +export function moduleEnv(args: Args_moduleEnv): Env { return env as Env; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/implementations/test-use-getImpl/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/implementations/test-use-getImpl/src/index.ts index b8edf54f4d..418bc885c9 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/implementations/test-use-getImpl/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/implementations/test-use-getImpl/src/index.ts @@ -1,13 +1,13 @@ -import { Input_moduleMethod, Input_abstractModuleMethod, ImplementationType, Interface } from "./wrap"; +import { Args_moduleMethod, Args_abstractModuleMethod, ImplementationType, Interface } from "./wrap"; export function moduleImplementations(): string[] { return Interface.getImplementations(); } -export function moduleMethod(input: Input_moduleMethod): ImplementationType { - return input.arg; +export function moduleMethod(args: Args_moduleMethod): ImplementationType { + return args.arg; } -export function abstractModuleMethod(input: Input_abstractModuleMethod): String { - return input.arg.str; +export function abstractModuleMethod(args: Args_abstractModuleMethod): String { + return args.arg.str; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/implementations/test-wrapper/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/implementations/test-wrapper/src/index.ts index 54b76b9e6f..0266157968 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/implementations/test-wrapper/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/implementations/test-wrapper/src/index.ts @@ -1,9 +1,9 @@ -import { Input_moduleMethod, Input_abstractModuleMethod, ImplementationType } from "./wrap"; +import { Args_moduleMethod, Args_abstractModuleMethod, ImplementationType } from "./wrap"; -export function moduleMethod(input: Input_moduleMethod): ImplementationType { - return input.arg; +export function moduleMethod(args: Args_moduleMethod): ImplementationType { + return args.arg; } -export function abstractModuleMethod(input: Input_abstractModuleMethod): String { - return input.arg.str; +export function abstractModuleMethod(args: Args_abstractModuleMethod): String { + return args.arg.str; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-implementation/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-implementation/src/index.ts index 54b76b9e6f..0266157968 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-implementation/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-implementation/src/index.ts @@ -1,9 +1,9 @@ -import { Input_moduleMethod, Input_abstractModuleMethod, ImplementationType } from "./wrap"; +import { Args_moduleMethod, Args_abstractModuleMethod, ImplementationType } from "./wrap"; -export function moduleMethod(input: Input_moduleMethod): ImplementationType { - return input.arg; +export function moduleMethod(args: Args_moduleMethod): ImplementationType { + return args.arg; } -export function abstractModuleMethod(input: Input_abstractModuleMethod): String { - return input.arg.str; +export function abstractModuleMethod(args: Args_abstractModuleMethod): String { + return args.arg.str; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-wrapper/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-wrapper/src/index.ts index 9a0fc61d84..5eb613e9de 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-wrapper/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/interface-invoke/test-wrapper/src/index.ts @@ -1,19 +1,19 @@ import { Interface, Interface_Module, - Input_moduleMethod, + Args_moduleMethod, ImplementationType } from "./wrap"; -export function moduleMethod(input: Input_moduleMethod): ImplementationType { +export function moduleMethod(args: Args_moduleMethod): ImplementationType { const uris = Interface.getImplementations(); const result = new Interface_Module(uris[0]).abstractModuleMethod({ arg: { - str: input.arg.str + str: args.arg.str } }).unwrap(); return { str: result, - uint8: input.arg.uint8, + uint8: args.arg.uint8, }; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/invalid-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/invalid-types/src/index.ts index 6acff069d3..7eca7dac3e 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/invalid-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/invalid-types/src/index.ts @@ -1,27 +1,27 @@ import { - Input_boolMethod, - Input_bytesMethod, - Input_arrayMethod, - Input_intMethod, - Input_uIntMethod + Args_boolMethod, + Args_bytesMethod, + Args_arrayMethod, + Args_intMethod, + Args_uIntMethod } from "./wrap"; -export function boolMethod(input: Input_boolMethod): bool { - return input.arg; +export function boolMethod(args: Args_boolMethod): bool { + return args.arg; } -export function intMethod(input: Input_intMethod): i32 { - return input.arg; +export function intMethod(args: Args_intMethod): i32 { + return args.arg; } -export function uIntMethod(input: Input_uIntMethod): u32 { - return input.arg; +export function uIntMethod(args: Args_uIntMethod): u32 { + return args.arg; } -export function bytesMethod(input: Input_bytesMethod): ArrayBuffer { - return input.arg; +export function bytesMethod(args: Args_bytesMethod): ArrayBuffer { + return args.arg; } -export function arrayMethod(input: Input_arrayMethod): string[] { - return input.arg; +export function arrayMethod(args: Args_arrayMethod): string[] { + return args.arg; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/json-type/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/json-type/src/index.ts index 553f2b5b52..9594cef7b0 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/json-type/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/json-type/src/index.ts @@ -1,36 +1,36 @@ import { - Input_parse, - Input_stringify, - Input_stringifyObject, - Input_methodJSON + Args_parse, + Args_stringify, + Args_stringifyObject, + Args_methodJSON } from "./wrap"; import { JSON } from "@polywrap/wasm-as"; -export function parse(input: Input_parse): JSON.Value { - return JSON.parse(input.value); +export function parse(args: Args_parse): JSON.Value { + return JSON.parse(args.value); } -export function stringify(input: Input_stringify): string { +export function stringify(args: Args_stringify): string { let str = ""; - for (let i = 0; i < input.values.length; ++i) { - const value = input.values[i]; + for (let i = 0; i < args.values.length; ++i) { + const value = args.values[i]; str += value.stringify(); } return str; } -export function stringifyObject(input: Input_stringifyObject): string { +export function stringifyObject(args: Args_stringifyObject): string { let str = ""; - str += input.object.jsonA.stringify(); - str += input.object.jsonB.stringify(); + str += args.object.jsonA.stringify(); + str += args.object.jsonB.stringify(); return str; } -export function methodJSON(input: Input_methodJSON): JSON.Value { +export function methodJSON(args: Args_methodJSON): JSON.Value { const result = JSON.Value.Object(); - result.set("valueA", JSON.from(input.valueA)); - result.set("valueB", JSON.from(input.valueB)); - result.set("valueC", JSON.from(input.valueC)); + result.set("valueA", JSON.from(args.valueA)); + result.set("valueB", JSON.from(args.valueB)); + result.set("valueC", JSON.from(args.valueC)); return result; } \ No newline at end of file diff --git a/packages/test-cases/cases/wrappers/wasm-as/large-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/large-types/src/index.ts index 32cd45c661..6aeab7c262 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/large-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/large-types/src/index.ts @@ -1,8 +1,8 @@ import { - Input_method, + Args_method, LargeCollection, } from "./wrap"; -export function method(input: Input_method): LargeCollection { - return input.largeCollection; +export function method(args: Args_method): LargeCollection { + return args.largeCollection; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/map-type/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/map-type/src/index.ts index 5f0bb05693..33a7920d0b 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/map-type/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/map-type/src/index.ts @@ -1,13 +1,13 @@ import { - Input_getKey, - Input_returnMap + Args_getKey, + Args_returnMap } from "./wrap"; -export function getKey(input: Input_getKey): i32 { - let result = input.map.get(input.key); +export function getKey(args: Args_getKey): i32 { + let result = args.map.get(args.key); return result; } -export function returnMap(input: Input_returnMap): Map { - return input.map; +export function returnMap(args: Args_returnMap): Map { + return args.map; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/number-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/number-types/src/index.ts index b328a25eec..bf15a590b3 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/number-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/number-types/src/index.ts @@ -1,44 +1,44 @@ import { - Input_i8Method, - Input_u8Method, - Input_i16Method, - Input_u16Method, - Input_i32Method, - Input_u32Method, + Args_i8Method, + Args_u8Method, + Args_i16Method, + Args_u16Method, + Args_i32Method, + Args_u32Method, } from "./wrap"; -export function i8Method(input: Input_i8Method): i8 { - const firstInt = input.first; - const secondInt = input.second; +export function i8Method(args: Args_i8Method): i8 { + const firstInt = args.first; + const secondInt = args.second; return firstInt + secondInt; } -export function u8Method(input: Input_u8Method): u8 { - const firstInt = input.first; - const secondInt = input.second; +export function u8Method(args: Args_u8Method): u8 { + const firstInt = args.first; + const secondInt = args.second; return firstInt + secondInt; } -export function i16Method(input: Input_i16Method): i16 { - const firstInt = input.first; - const secondInt = input.second; +export function i16Method(args: Args_i16Method): i16 { + const firstInt = args.first; + const secondInt = args.second; return firstInt + secondInt; } -export function u16Method(input: Input_u16Method): u16 { - const firstInt = input.first; - const secondInt = input.second; +export function u16Method(args: Args_u16Method): u16 { + const firstInt = args.first; + const secondInt = args.second; return firstInt + secondInt; } -export function i32Method(input: Input_i32Method): i32 { - const firstInt = input.first; - const secondInt = input.second; +export function i32Method(args: Args_i32Method): i32 { + const firstInt = args.first; + const secondInt = args.second; return firstInt + secondInt; } -export function u32Method(input: Input_u32Method): u32 { - const firstInt = input.first; - const secondInt = input.second; +export function u32Method(args: Args_u32Method): u32 { + const firstInt = args.first; + const secondInt = args.second; return firstInt + secondInt; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/object-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/object-types/src/index.ts index e3e2c10291..e552004a8f 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/object-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/object-types/src/index.ts @@ -1,57 +1,57 @@ import { - Input_method1, - Input_method2, - Input_method3, - Input_method5, + Args_method1, + Args_method2, + Args_method3, + Args_method5, Output, Arg2 } from "./wrap"; -export function method1(input: Input_method1): Output[] { +export function method1(args: Args_method1): Output[] { return [ { - prop: input.arg1.prop, + prop: args.arg1.prop, nested: { - prop: input.arg1.nested.prop + prop: args.arg1.nested.prop } }, { - prop: input.arg2 ? (input.arg2 as Arg2).prop : "", + prop: args.arg2 ? (args.arg2 as Arg2).prop : "", nested: { - prop: input.arg2 ? (input.arg2 as Arg2).circular.prop : "" + prop: args.arg2 ? (args.arg2 as Arg2).circular.prop : "" } } ]; } -export function method2(input: Input_method2): Output | null { - if (input.arg.prop == "null") { +export function method2(args: Args_method2): Output | null { + if (args.arg.prop == "null") { return null; } return { - prop: input.arg.prop, + prop: args.arg.prop, nested: { - prop: input.arg.nested.prop + prop: args.arg.nested.prop } }; } -export function method3(input: Input_method3): (Output | null)[] { +export function method3(args: Args_method3): (Output | null)[] { return [ null, { - prop: input.arg.prop, + prop: args.arg.prop, nested: { - prop: input.arg.nested.prop + prop: args.arg.nested.prop } } ] } -export function method5(input: Input_method5): Output { +export function method5(args: Args_method5): Output { return { - prop: String.UTF8.decode(input.arg.prop), + prop: String.UTF8.decode(args.arg.prop), nested: { prop: "nested prop" } diff --git a/packages/test-cases/cases/wrappers/wasm-as/reserved-words/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/reserved-words/src/index.ts index c804a2e4d0..2823d1db01 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/reserved-words/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/reserved-words/src/index.ts @@ -1,10 +1,10 @@ import { - Input_method1, + Args_method1, Result, } from "./wrap"; -export function method1(input: Input_method1): Result { +export function method1(args: Args_method1): Result { return { - m_const: "result: " + input.m_const.m_const, + m_const: "result: " + args.m_const.m_const, }; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/simple-env-types/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/simple-env-types/src/index.ts index 2481e52ed0..9b67892734 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/simple-env-types/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/simple-env-types/src/index.ts @@ -1,5 +1,5 @@ -import { env, Env, Input_getEnv } from "./wrap"; +import { env, Env, Args_getEnv } from "./wrap"; -export function getEnv(input: Input_getEnv): Env { +export function getEnv(args: Args_getEnv): Env { return env as Env; } diff --git a/packages/test-cases/cases/wrappers/wasm-as/simple-storage/src/index.ts b/packages/test-cases/cases/wrappers/wasm-as/simple-storage/src/index.ts index 98ca74a11a..b7e6e845bd 100644 --- a/packages/test-cases/cases/wrappers/wasm-as/simple-storage/src/index.ts +++ b/packages/test-cases/cases/wrappers/wasm-as/simple-storage/src/index.ts @@ -1,62 +1,62 @@ import { Ethereum_Module } from "./wrap/imported"; import { - Input_getData, - Input_tryGetData, - Input_throwGetData, - Input_setData, - Input_deployContract + Args_getData, + Args_tryGetData, + Args_throwGetData, + Args_setData, + Args_deployContract } from "./wrap"; -export function getData(input: Input_getData): u32 { +export function getData(args: Args_getData): u32 { const res = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function get() view returns (uint256)", args: null, - connection: input.connection + connection: args.connection }).unwrap(); return U32.parseInt(res); } -export function tryGetData(input: Input_tryGetData): string { +export function tryGetData(args: Args_tryGetData): string { const res = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function badFunctionCall() view returns (uint256)", args: null, - connection: input.connection + connection: args.connection }); return res.unwrapErr(); } -export function throwGetData(input: Input_throwGetData): string { +export function throwGetData(args: Args_throwGetData): string { const res = Ethereum_Module.callContractView({ - address: input.address, + address: args.address, method: "function badFunctionCall() view returns (uint256)", args: null, - connection: input.connection + connection: args.connection }).unwrap(); return res; } -export function setData(input: Input_setData): string { +export function setData(args: Args_setData): string { const res = Ethereum_Module.callContractMethod({ - address: input.address, + address: args.address, method: "function set(uint256 value)", - args: [input.value.toString()], - connection: input.connection + args: [args.value.toString()], + connection: args.connection }).unwrap(); return res.hash; } -export function deployContract(input: Input_deployContract): string { +export function deployContract(args: Args_deployContract): string { return Ethereum_Module.deployContract({ abi: `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]`, bytecode: "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033", args: null, - connection: input.connection + connection: args.connection }).unwrap(); } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/asyncify/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/asyncify/src/lib.rs index 6f3b7975f8..51fb559d39 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/asyncify/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/asyncify/src/lib.rs @@ -4,13 +4,13 @@ use polywrap_wasm_rs::JSON; use wrap::imported::ethereum_module; use wrap::module; -pub fn get_data(input: module::InputGetData) -> u32 { +pub fn get_data(args: module::ArgsGetData) -> u32 { match EthereumModule::call_contract_view( - ðereum_module::InputCallContractView { - address: input.address, + ðereum_module::ArgsCallContractView { + address: args.address, method: "function get() view returns (uint256)".to_string(), args: None, - connection: input.connection, + connection: args.connection, }, ) { Ok(v) => v.parse::().unwrap(), @@ -22,13 +22,13 @@ pub fn return_true() -> bool { true } -pub fn set_data_with_large_args(input: module::InputSetDataWithLargeArgs) -> String { - let large_string = input.value; - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address, +pub fn set_data_with_large_args(args: module::ArgsSetDataWithLargeArgs) -> String { + let large_string = args.value; + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address, method: "function set(uint256 value)".to_string(), args: Some(vec!["66".to_string()]), - connection: input.connection, + connection: args.connection, tx_overrides: None, }) { Ok(_v) => large_string, @@ -36,7 +36,7 @@ pub fn set_data_with_large_args(input: module::InputSetDataWithLargeArgs) -> Str } } -pub fn set_data_with_many_args(input: module::InputSetDataWithManyArgs) -> String { +pub fn set_data_with_many_args(args: module::ArgsSetDataWithManyArgs) -> String { let ( args_a, args_b, @@ -51,24 +51,24 @@ pub fn set_data_with_many_args(input: module::InputSetDataWithManyArgs) -> Strin args_k, args_l, ) = ( - input.value_a, - input.value_b, - input.value_c, - input.value_d, - input.value_e, - input.value_f, - input.value_g, - input.value_h, - input.value_i, - input.value_j, - input.value_k, - input.value_l, + args.value_a, + args.value_b, + args.value_c, + args.value_d, + args.value_e, + args.value_f, + args.value_g, + args.value_h, + args.value_i, + args.value_j, + args.value_k, + args.value_l, ); - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address, + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address, method: "function set(uint256 value)".to_string(), args: Some(vec!["55".to_string()]), - connection: input.connection, + connection: args.connection, tx_overrides: None, }) { Ok(_v) => [ @@ -81,13 +81,13 @@ pub fn set_data_with_many_args(input: module::InputSetDataWithManyArgs) -> Strin } pub fn set_data_with_many_structured_args( - input: module::InputSetDataWithManyStructuredArgs, + args: module::ArgsSetDataWithManyStructuredArgs, ) -> bool { - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address, + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address, method: "function set(uint256 value)".to_string(), args: Some(vec!["44".to_string()]), - connection: input.connection, + connection: args.connection, tx_overrides: None, }) { Ok(_v) => return_true(), @@ -95,27 +95,27 @@ pub fn set_data_with_many_structured_args( } } -pub fn deploy_contract(input: module::InputDeployContract) -> String { +pub fn deploy_contract(args: module::ArgsDeployContract) -> String { let abi = JSON::json!([{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]).to_string(); let bytecode = "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033".to_string(); - match EthereumModule::deploy_contract(ðereum_module::InputDeployContract { + match EthereumModule::deploy_contract(ðereum_module::ArgsDeployContract { abi, bytecode, args: None, - connection: input.connection, + connection: args.connection, }) { Ok(v) => v, Err(e) => panic!("{}", e), } } -pub fn local_var_method(input: module::InputLocalVarMethod) -> bool { - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address, +pub fn local_var_method(args: module::ArgsLocalVarMethod) -> bool { + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address, method: "function set(uint256 value)".to_string(), args: Some(vec!["88".to_string()]), - connection: input.connection, + connection: args.connection, tx_overrides: None, }) { Ok(_v) => true, @@ -123,12 +123,12 @@ pub fn local_var_method(input: module::InputLocalVarMethod) -> bool { } } -pub fn global_var_method(input: module::InputGlobalVarMethod) -> bool { - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address, +pub fn global_var_method(args: module::ArgsGlobalVarMethod) -> bool { + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address, method: "function set(uint256 value)".to_string(), args: Some(vec!["77".to_string()]), - connection: input.connection, + connection: args.connection, tx_overrides: None, }) { Ok(_v) => true, @@ -136,23 +136,23 @@ pub fn global_var_method(input: module::InputGlobalVarMethod) -> bool { } } -pub fn subsequent_invokes(input: module::InputSubsequentInvokes) -> Vec { +pub fn subsequent_invokes(args: module::ArgsSubsequentInvokes) -> Vec { let mut result: Vec = vec![]; - for i in 0..input.number_of_times { - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address.clone(), + for i in 0..args.number_of_times { + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address.clone(), method: "function set(uint256 value)".to_string(), args: Some(vec![i.to_string()]), - connection: input.connection.clone(), + connection: args.connection.clone(), tx_overrides: None, }) { Ok(_v) => { - match EthereumModule::call_contract_view(ðereum_module::InputCallContractView{ - address: input.address.clone(), + match EthereumModule::call_contract_view(ðereum_module::ArgsCallContractView{ + address: args.address.clone(), method: "function get() view returns (uint256)".to_string(), args: None, - connection: input.connection.clone(), + connection: args.connection.clone(), }) { Ok(v) => result.push(v), Err(e) => panic!("{}", e), diff --git a/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/schema.graphql b/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/schema.graphql index 213e87d28e..5be8cdf1d4 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/schema.graphql +++ b/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/schema.graphql @@ -2,11 +2,11 @@ type Module { method( arg1: BigInt! arg2: BigInt - obj: BigIntInput! + obj: BigIntArg! ): BigInt! } -type BigIntInput { +type BigIntArg { prop1: BigInt! prop2: BigInt } \ No newline at end of file diff --git a/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/src/lib.rs index 8b85ad8f7f..7d648a4f14 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/bigint-type/src/lib.rs @@ -4,14 +4,14 @@ use polywrap_wasm_rs::BigInt; pub mod wrap; pub use wrap::*; -pub fn method(input: InputMethod) -> BigInt { - let mut result = input.arg1.mul(input.obj.prop1); +pub fn method(args: ArgsMethod) -> BigInt { + let mut result = args.arg1.mul(args.obj.prop1); - if input.arg2.is_some() { - result = result.mul(input.arg2.unwrap()); + if args.arg2.is_some() { + result = result.mul(args.arg2.unwrap()); } - if input.obj.prop2.is_some() { - result = result.mul(input.obj.prop2.unwrap()); + if args.obj.prop2.is_some() { + result = result.mul(args.obj.prop2.unwrap()); } result diff --git a/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/schema.graphql b/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/schema.graphql index bc4fff129c..ffe506dec2 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/schema.graphql +++ b/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/schema.graphql @@ -2,11 +2,11 @@ type Module { method( arg1: BigNumber! arg2: BigNumber - obj: BigNumberInput! + obj: BigNumberArg! ): BigNumber! } -type BigNumberInput { +type BigNumberArg { prop1: BigNumber! prop2: BigNumber } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/src/lib.rs index a9015a4d6f..5e5b5ae13c 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/bignumber-type/src/lib.rs @@ -4,14 +4,14 @@ use polywrap_wasm_rs::BigNumber; pub mod wrap; pub use wrap::*; -pub fn method(input: InputMethod) -> BigNumber { - let mut result = input.arg1.mul(input.obj.prop1); +pub fn method(args: ArgsMethod) -> BigNumber { + let mut result = args.arg1.mul(args.obj.prop1); - if input.arg2.is_some() { - result = result.mul(input.arg2.unwrap()); + if args.arg2.is_some() { + result = result.mul(args.arg2.unwrap()); } - if input.obj.prop2.is_some() { - result = result.mul(input.obj.prop2.unwrap()); + if args.obj.prop2.is_some() { + result = result.mul(args.obj.prop2.unwrap()); } result diff --git a/packages/test-cases/cases/wrappers/wasm-rs/bytes-type/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/bytes-type/src/lib.rs index b272be08bb..261f90ae23 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/bytes-type/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/bytes-type/src/lib.rs @@ -1,8 +1,8 @@ pub mod wrap; pub use wrap::*; -pub fn bytes_method(input: InputBytesMethod) -> Vec { - let arg_str = match String::from_utf8(input.arg.prop) { +pub fn bytes_method(args: ArgsBytesMethod) -> Vec { + let arg_str = match String::from_utf8(args.arg.prop) { Ok(s) => s, Err(_e) => panic!("Parsing error"), }; diff --git a/packages/test-cases/cases/wrappers/wasm-rs/enum-types/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/enum-types/src/lib.rs index 32962d3686..5f3fcef1e3 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/enum-types/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/enum-types/src/lib.rs @@ -1,10 +1,10 @@ pub mod wrap; pub use wrap::*; -pub fn method1(input: InputMethod1) -> SanityEnum { - input.en +pub fn method1(args: ArgsMethod1) -> SanityEnum { + args.en } -pub fn method2(input: InputMethod2) -> Vec { - input.enum_array +pub fn method2(args: ArgsMethod2) -> Vec { + args.enum_array } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-use-getImpl/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-use-getImpl/src/lib.rs index 823aa9f87a..7a44ca80a3 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-use-getImpl/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-use-getImpl/src/lib.rs @@ -5,10 +5,10 @@ pub fn module_implementations() -> Vec { Interface::get_implementations() } -pub fn module_method(input: InputModuleMethod) -> ImplementationType { - input.arg +pub fn module_method(args: ArgsModuleMethod) -> ImplementationType { + args.arg } -pub fn abstract_module_method(input: InputAbstractModuleMethod) -> String { - input.arg.str +pub fn abstract_module_method(args: ArgsAbstractModuleMethod) -> String { + args.arg.str } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-wrapper/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-wrapper/src/lib.rs index a001016170..488c42970c 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-wrapper/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/implementations/test-wrapper/src/lib.rs @@ -1,10 +1,10 @@ pub mod wrap; pub use wrap::*; -pub fn module_method(input: InputModuleMethod) -> ImplementationType { - input.arg +pub fn module_method(args: ArgsModuleMethod) -> ImplementationType { + args.arg } -pub fn abstract_module_method(input: InputAbstractModuleMethod) -> String { - input.arg.str +pub fn abstract_module_method(args: ArgsAbstractModuleMethod) -> String { + args.arg.str } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/invalid-types/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/invalid-types/src/lib.rs index c3cb9d7260..ec35bcbfad 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/invalid-types/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/invalid-types/src/lib.rs @@ -1,22 +1,22 @@ pub mod wrap; pub use wrap::*; -pub fn bool_method(input: InputBoolMethod) -> bool { - input.arg +pub fn bool_method(args: ArgsBoolMethod) -> bool { + args.arg } -pub fn int_method(input: InputIntMethod) -> i32 { - input.arg +pub fn int_method(args: ArgsIntMethod) -> i32 { + args.arg } -pub fn u_int_method(input: InputUIntMethod) -> u32 { - input.arg +pub fn u_int_method(args: ArgsUIntMethod) -> u32 { + args.arg } -pub fn bytes_method(input: InputBytesMethod) -> Vec { - input.arg +pub fn bytes_method(args: ArgsBytesMethod) -> Vec { + args.arg } -pub fn array_method(input: InputArrayMethod) -> Option> { - Some(input.arg) +pub fn array_method(args: ArgsArrayMethod) -> Option> { + Some(args.arg) } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/json-type/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/json-type/src/lib.rs index 771fd3f151..b3317a0ac9 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/json-type/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/json-type/src/lib.rs @@ -3,26 +3,26 @@ pub use wrap::*; use polywrap_wasm_rs::JSON; use serde_json::*; -pub fn stringify(input: InputStringify) -> String { +pub fn stringify(args: ArgsStringify) -> String { let mut new_string = String::from(""); - for object in &input.values { + for object in &args.values { new_string.push_str(&object.to_string()); } new_string } -pub fn parse(input: InputParse) -> JSON::Value { JSON::from_str(&input.value).unwrap() } +pub fn parse(args: ArgsParse) -> JSON::Value { JSON::from_str(&args.value).unwrap() } -pub fn stringify_object(input: InputStringifyObject) -> String { - let mut new_string = String::from(&input.object.json_a.to_string()); - new_string.push_str(&input.object.json_b.to_string()); +pub fn stringify_object(args: ArgsStringifyObject) -> String { + let mut new_string = String::from(&args.object.json_a.to_string()); + new_string.push_str(&args.object.json_b.to_string()); new_string } -pub fn method_j_s_o_n(input: InputMethodJSON) -> JSON::Value { +pub fn method_j_s_o_n(args: ArgsMethodJSON) -> JSON::Value { json!({ - "valueA": input.value_a, - "valueB": input.value_b, - "valueC": input.value_c + "valueA": args.value_a, + "valueB": args.value_b, + "valueC": args.value_c }) } \ No newline at end of file diff --git a/packages/test-cases/cases/wrappers/wasm-rs/large-types/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/large-types/src/lib.rs index 1bd56401d3..d443f2331c 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/large-types/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/large-types/src/lib.rs @@ -1,6 +1,6 @@ pub mod wrap; pub use wrap::*; -pub fn method(input: InputMethod) -> LargeCollection { - input.large_collection +pub fn method(args: ArgsMethod) -> LargeCollection { + args.large_collection } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/map-type/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/map-type/src/lib.rs index 48f97e4a87..845d02a97e 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/map-type/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/map-type/src/lib.rs @@ -2,10 +2,10 @@ pub mod wrap; pub use wrap::*; use polywrap_wasm_rs::Map; -pub fn get_key(input: InputGetKey) -> i32 { - *input.map.get(&input.key).unwrap() +pub fn get_key(args: ArgsGetKey) -> i32 { + *args.map.get(&args.key).unwrap() } -pub fn return_map(input: InputReturnMap) -> Map { - input.map +pub fn return_map(args: ArgsReturnMap) -> Map { + args.map } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/number-types/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/number-types/src/lib.rs index 6480fce0a6..7eedae9e0f 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/number-types/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/number-types/src/lib.rs @@ -1,26 +1,26 @@ pub mod wrap; pub use wrap::*; -pub fn i8_method(input: InputI8Method) -> i8 { - input.first + input.second +pub fn i8_method(args: ArgsI8Method) -> i8 { + args.first + args.second } -pub fn u8_method(input: InputU8Method) -> u8 { - input.first + input.second +pub fn u8_method(args: ArgsU8Method) -> u8 { + args.first + args.second } -pub fn i16_method(input: InputI16Method) -> i16 { - input.first + input.second +pub fn i16_method(args: ArgsI16Method) -> i16 { + args.first + args.second } -pub fn u16_method(input: InputU16Method) -> u16 { - input.first + input.second +pub fn u16_method(args: ArgsU16Method) -> u16 { + args.first + args.second } -pub fn i32_method(input: InputI32Method) -> i32 { - input.first + input.second +pub fn i32_method(args: ArgsI32Method) -> i32 { + args.first + args.second } -pub fn u32_method(input: InputU32Method) -> u32 { - input.first + input.second +pub fn u32_method(args: ArgsU32Method) -> u32 { + args.first + args.second } diff --git a/packages/test-cases/cases/wrappers/wasm-rs/object-types/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/object-types/src/lib.rs index 11a3d6916b..4ad102571c 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/object-types/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/object-types/src/lib.rs @@ -1,21 +1,21 @@ pub mod wrap; pub use wrap::*; -pub fn method1(input: InputMethod1) -> Vec { +pub fn method1(args: ArgsMethod1) -> Vec { vec![ Output { - prop: input.arg1.prop, + prop: args.arg1.prop, nested: Nested { - prop: input.arg1.nested.prop, + prop: args.arg1.nested.prop, }, }, Output { - prop: match input.arg2 { + prop: match args.arg2 { Some(ref v) => v.prop.clone(), None => "".to_string(), }, nested: Nested { - prop: match input.arg2 { + prop: match args.arg2 { Some(ref v) => v.circular.prop.clone(), None => "".to_string(), } @@ -24,33 +24,33 @@ pub fn method1(input: InputMethod1) -> Vec { ] } -pub fn method2(input: InputMethod2) -> Option { - if input.arg.prop == "null".to_string() { +pub fn method2(args: ArgsMethod2) -> Option { + if args.arg.prop == "null".to_string() { return None; } Some(Output { - prop: input.arg.prop, + prop: args.arg.prop, nested: Nested { - prop: input.arg.nested.prop, + prop: args.arg.nested.prop, }, }) } -pub fn method3(input: InputMethod3) -> Vec> { +pub fn method3(args: ArgsMethod3) -> Vec> { vec![ None, Some(Output { - prop: input.arg.prop, + prop: args.arg.prop, nested: Nested { - prop: input.arg.nested.prop, + prop: args.arg.nested.prop, }, }), ] } -pub fn method5(input: InputMethod5) -> Output { +pub fn method5(args: ArgsMethod5) -> Output { Output { - prop: match String::from_utf8(input.arg.prop) { + prop: match String::from_utf8(args.arg.prop) { Ok(v) => v, Err(e) => panic!("{}", e), }, diff --git a/packages/test-cases/cases/wrappers/wasm-rs/simple-storage/src/lib.rs b/packages/test-cases/cases/wrappers/wasm-rs/simple-storage/src/lib.rs index 90b0674af8..be731b757d 100644 --- a/packages/test-cases/cases/wrappers/wasm-rs/simple-storage/src/lib.rs +++ b/packages/test-cases/cases/wrappers/wasm-rs/simple-storage/src/lib.rs @@ -3,44 +3,44 @@ use polywrap_wasm_rs::JSON; use wrap::imported::ethereum_module; pub use wrap::*; -pub fn get_data(input: InputGetData) -> i32 { - match EthereumModule::call_contract_view(ðereum_module::InputCallContractView { - address: input.address, +pub fn get_data(args: ArgsGetData) -> i32 { + match EthereumModule::call_contract_view(ðereum_module::ArgsCallContractView { + address: args.address, method: "function get() view returns (uint256)".to_string(), args: None, - connection: input.connection, + connection: args.connection, }) { Ok(v) => v.parse::().unwrap(), Err(e) => panic!("{}", e), } } -pub fn try_get_data(input: InputTryGetData) -> String { - let res = EthereumModule::call_contract_view(ðereum_module::InputCallContractView { - address: input.address, +pub fn try_get_data(args: ArgsTryGetData) -> String { + let res = EthereumModule::call_contract_view(ðereum_module::ArgsCallContractView { + address: args.address, method: "function badFunctionCall() view returns (uint256)".to_string(), args: None, - connection: input.connection, + connection: args.connection, }); res.unwrap_err() } -pub fn throw_get_data(input: InputThrowGetData) -> String { - EthereumModule::call_contract_view(ðereum_module::InputCallContractView { - address: input.address, +pub fn throw_get_data(args: ArgsThrowGetData) -> String { + EthereumModule::call_contract_view(ðereum_module::ArgsCallContractView { + address: args.address, method: "function badFunctionCall() view returns (uint256)".to_string(), args: None, - connection: input.connection, + connection: args.connection, }).unwrap() } -pub fn set_data(input: InputSetData) -> String { - match EthereumModule::call_contract_method(ðereum_module::InputCallContractMethod { - address: input.address, +pub fn set_data(args: ArgsSetData) -> String { + match EthereumModule::call_contract_method(ðereum_module::ArgsCallContractMethod { + address: args.address, method: "function set(uint256 value)".to_string(), - args: Some(vec![input.value.to_string()]), - connection: input.connection, + args: Some(vec![args.value.to_string()]), + connection: args.connection, tx_overrides: None, }) { Ok(res) => res.hash, @@ -48,14 +48,14 @@ pub fn set_data(input: InputSetData) -> String { } } -pub fn deploy_contract(input: InputDeployContract) -> String { +pub fn deploy_contract(args: ArgsDeployContract) -> String { let abi = JSON::json!([{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"DataSet","type":"event"},{"inputs":[],"name":"get","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"}]).to_string(); let bytecode = "0x608060405234801561001057600080fd5b5061012a806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780636d4ce63c146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b606860eb565b6040518082815260200191505060405180910390f35b806000819055507f3d38713ec8fb49acced894a52df2f06a371a15960550da9ba0f017cb7d07a8ec33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000805490509056fea2646970667358221220f312fe8d32f77c74cc4eb4a1f5c805d8bb124755ca4e8a1db2cce10cbb133dc564736f6c63430006060033".to_string(); - EthereumModule::deploy_contract(ðereum_module::InputDeployContract { + EthereumModule::deploy_contract(ðereum_module::ArgsDeployContract { abi, bytecode, args: None, - connection: input.connection, + connection: args.connection, }) .unwrap() } diff --git a/packages/wasm/as/assembly/implementation-subinvoke.ts b/packages/wasm/as/assembly/implementation-subinvoke.ts index 561a530720..053c93a459 100644 --- a/packages/wasm/as/assembly/implementation-subinvoke.ts +++ b/packages/wasm/as/assembly/implementation-subinvoke.ts @@ -8,7 +8,7 @@ export declare function __wrap_subinvokeImplementation( interface_uri_ptr: u32, interface_uri_len: u32, impl_uri_ptr: u32, impl_uri_len: u32, method_ptr: u32, method_len: u32, - input_ptr: u32, input_len: u32 + args_ptr: u32, args_len: u32 ): bool; // Implementation Subinvoke Result @@ -28,7 +28,7 @@ export function wrap_subinvokeImplementation( interfaceUri: string, implUri: string, method: string, - input: ArrayBuffer + args: ArrayBuffer ): Result { const interfaceUriBuf = String.UTF8.encode(interfaceUri); const implUriBuf = String.UTF8.encode(implUri); @@ -38,7 +38,7 @@ export function wrap_subinvokeImplementation( changetype(interfaceUriBuf), interfaceUriBuf.byteLength, changetype(implUriBuf), implUriBuf.byteLength, changetype(methodBuf), methodBuf.byteLength, - changetype(input), input.byteLength + changetype(args), args.byteLength ); if (!success) { diff --git a/packages/wasm/as/assembly/subinvoke.ts b/packages/wasm/as/assembly/subinvoke.ts index 9a963c6d89..b263407238 100644 --- a/packages/wasm/as/assembly/subinvoke.ts +++ b/packages/wasm/as/assembly/subinvoke.ts @@ -7,7 +7,7 @@ import { Result } from "./containers"; export declare function __wrap_subinvoke( uri_ptr: u32, uri_len: u32, method_ptr: u32, method_len: u32, - input_ptr: u32, input_len: u32 + args_ptr: u32, args_len: u32 ): bool; // Subinvoke Result @@ -26,7 +26,7 @@ export declare function __wrap_subinvoke_error(ptr: u32): void; export function wrap_subinvoke( uri: string, method: string, - input: ArrayBuffer + args: ArrayBuffer ): Result { const uriBuf = String.UTF8.encode(uri); const methodBuf = String.UTF8.encode(method); @@ -34,7 +34,7 @@ export function wrap_subinvoke( const success = __wrap_subinvoke( changetype(uriBuf), uriBuf.byteLength, changetype(methodBuf), methodBuf.byteLength, - changetype(input), input.byteLength + changetype(args), args.byteLength ); if (!success) { diff --git a/packages/wasm/rs/src/subinvoke.rs b/packages/wasm/rs/src/subinvoke.rs index 485470031b..f32db4471c 100644 --- a/packages/wasm/rs/src/subinvoke.rs +++ b/packages/wasm/rs/src/subinvoke.rs @@ -9,8 +9,8 @@ extern "C" { uri_len: u32, method_ptr: u32, method_len: u32, - input_ptr: u32, - input_len: u32, + args_ptr: u32, + args_len: u32, ) -> bool; /// Subinvoke Result @@ -32,7 +32,7 @@ extern "C" { pub fn wrap_subinvoke( uri: &str, method: &str, - input: Vec, + args: Vec, ) -> Result, String> { let uri_buf = uri.as_bytes(); let method_buf = method.as_bytes(); @@ -43,8 +43,8 @@ pub fn wrap_subinvoke( uri_buf.len() as u32, method_buf.as_ptr() as u32, method_buf.len() as u32, - input.as_ptr() as u32, - input.len() as u32, + args.as_ptr() as u32, + args.len() as u32, ) }; if !success { diff --git a/yarn.lock b/yarn.lock index f021076ac2..920e3d85d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2227,33 +2227,33 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/gen-mapping@^0.3.0": - version "0.3.1" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.1.tgz#cf92a983c83466b8c0ce9124fadeaf09f7c66ea9" - integrity sha512-GcHwniMlA2z+WFPWuY8lp3fsza0I8xPFMWL5+n8LYyP6PSvPrXf4+n8stDHZY2DM0zy9sVkRDy1jDI4XGzYVqg== + version "0.3.2" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" + integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== dependencies: - "@jridgewell/set-array" "^1.0.0" + "@jridgewell/set-array" "^1.0.1" "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping" "^0.3.9" "@jridgewell/resolve-uri@^3.0.3": - version "3.0.7" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz#30cd49820a962aff48c8fffc5cd760151fca61fe" - integrity sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA== + version "3.0.8" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.8.tgz#687cc2bbf243f4e9a868ecf2262318e2658873a1" + integrity sha512-YK5G9LaddzGbcucK4c8h5tWFmMPBvRZ/uyWmN1/SbBdIvqGUdWGkJ5BAaccgs6XbzVLsqbPJrBSFwKv3kT9i7w== -"@jridgewell/set-array@^1.0.0": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea" - integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== +"@jridgewell/set-array@^1.0.0", "@jridgewell/set-array@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" + integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== "@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.13" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c" - integrity sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w== + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== "@jridgewell/trace-mapping@^0.3.9": - version "0.3.13" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea" - integrity sha512-o1xbKhp9qnIAoHJSWd6KlCZfqslL4valSF81H8ImioOAxluWYWOpWkpyktY2vnt4tbrX9XYaxovq6cgowaJp2w== + version "0.3.14" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" + integrity sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ== dependencies: "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" @@ -3143,9 +3143,9 @@ "@octokit/plugin-rest-endpoint-methods" "^5.12.0" "@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.36.0": - version "6.37.0" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.37.0.tgz#32eb78edb34cf5cea4ba5753ab8db75b776d617a" - integrity sha512-BXWQhFKRkjX4dVW5L2oYa0hzWOAqsEsujXsQLSdepPoDZfYdubrD1KDGpyNldGXtR8QM/WezDcxcIN1UKJMGPA== + version "6.37.1" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.37.1.tgz#600a9c9643f696ba68f229c8d71abbc1040ad6a6" + integrity sha512-Q1hXSP2YumHkDdD+V4wFKr7vJ9+8tjocixrTSb75JzJ4GpjSyu5B4kpgrXxO6GOs4nOmVyRwRgS4/RO/Lf9oEA== dependencies: "@octokit/openapi-types" "^12.4.0" @@ -3538,9 +3538,9 @@ "@types/json-schema" "*" "@types/estree@*": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== + version "0.0.52" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.52.tgz#7f1f57ad5b741f3d5b210d3b1f145640d89bf8fe" + integrity sha512-BZWrtCU0bMVAIliIV+HJO1f1PR41M7NKjfxrFJwwhKI1KwhwOxYw1SXg9ao+CIMt774nFuGiG6eU+udtbEI9oQ== "@types/fs-extra@9.0.12": version "9.0.12" @@ -5327,7 +5327,7 @@ browserslist@4.10.0: node-releases "^1.1.52" pkg-up "^3.1.0" -browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.20.2, browserslist@^4.20.4, browserslist@^4.6.2, browserslist@^4.6.4, browserslist@^4.9.1: +browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.20.2, browserslist@^4.21.0, browserslist@^4.6.2, browserslist@^4.6.4, browserslist@^4.9.1: version "4.21.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.0.tgz#7ab19572361a140ecd1e023e2c1ed95edda0cefe" integrity sha512-UQxE0DIhRB5z/zDz9iA03BOfxaN2+GQdBYH/2WrSIWEUrnpzTPJbhqt+umq6r3acaPRTW1FNTkrcp0PXgtFkvA== @@ -5605,9 +5605,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001358: - version "1.0.30001358" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001358.tgz#473d35dabf5e448b463095cab7924e96ccfb8c00" - integrity sha512-hvp8PSRymk85R20bsDra7ZTCpSVGN/PAz9pSAjPSjKC+rNmnUk5vCRgJwiTT/O4feQ/yu/drvZYpKxxhbFuChw== + version "1.0.30001359" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001359.tgz#a1c1cbe1c2da9e689638813618b4219acbd4925e" + integrity sha512-Xln/BAsPzEuiVLgJ2/45IaqD9jShtk3Y33anKb4+yLwQzws3+v6odKfpgES/cDEaZMLzSChpIGdbOYtH9MyuHw== capture-exit@^2.0.0: version "2.0.0" @@ -6335,17 +6335,17 @@ copyfiles@2.4.1: yargs "^16.1.0" core-js-compat@^3.21.0, core-js-compat@^3.22.1, core-js-compat@^3.6.2: - version "3.23.2" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.23.2.tgz#5cbf8a9c8812d665392845b85ae91b5bcc7b615c" - integrity sha512-lrgZvxFwbQp9v7E8mX0rJ+JX7Bvh4eGULZXA1IAyjlsnWvCdw6TF8Tg6xtaSUSJMrSrMaLdpmk+V54LM1dvfOA== + version "3.23.3" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.23.3.tgz#7d8503185be76bb6d8d592c291a4457a8e440aa9" + integrity sha512-WSzUs2h2vvmKsacLHNTdpyOC9k43AEhcGoFlVgCY4L7aw98oSBKtPL6vD0/TqZjRWRQYdDSLkzZIni4Crbbiqw== dependencies: - browserslist "^4.20.4" + browserslist "^4.21.0" semver "7.0.0" core-js-pure@^3.20.2: - version "3.23.2" - resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.23.2.tgz#efe5e486469c5ed2d088d76e973eb12e74a930e7" - integrity sha512-t6u7H4Ff/yZNk+zqTr74UjCcZ3k8ApBryeLLV4rYQd9aF3gqmjjGjjR44ENfeBMH8VVvSynIjAJ0mUuFhzQtrA== + version "3.23.3" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.23.3.tgz#bcd02d3d8ec68ad871ef50d5ccbb248ddb54f401" + integrity sha512-XpoouuqIj4P+GWtdyV8ZO3/u4KftkeDVMfvp+308eGMhCrA3lVDSmAxO0c6GGOcmgVlaKDrgWVMo49h2ab/TDA== core-js@^2.4.0: version "2.6.12" @@ -6353,9 +6353,9 @@ core-js@^2.4.0: integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== core-js@^3.5.0: - version "3.23.2" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.23.2.tgz#e07a60ca8b14dd129cabdc3d2551baf5a01c76f0" - integrity sha512-ELJOWxNrJfOH/WK4VJ3Qd+fOqZuOuDNDJz0xG6Bt4mGg2eO/UT9CljCrbqDGovjLKUrGajEEBcoTOc0w+yBYeQ== + version "3.23.3" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.23.3.tgz#3b977612b15da6da0c9cc4aec487e8d24f371112" + integrity sha512-oAKwkj9xcWNBAvGbT//WiCdOMpb9XQG92/Fe3ABFM/R16BsHgePG00mFOgKf7IsCtfj8tA1kHtf/VwErhriz5Q== core-util-is@1.0.2: version "1.0.2" @@ -7285,9 +7285,9 @@ electron-fetch@^1.7.2: encoding "^0.1.13" electron-to-chromium@^1.3.378, electron-to-chromium@^1.4.164: - version "1.4.168" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.168.tgz#8f6bda320a434ac963850d18e41d83220973cbdd" - integrity sha512-yz247hclRBaP8ABB1hf9kL7AMfa+yC2hB9F3XF8Y87VWMnYgq4QYvV6acRACcDkTDxfGQ4GYK/aZPQiuFMGbaA== + version "1.4.170" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.170.tgz#0415fc489402e09bfbe1f0c99bbf4d73f31d48d4" + integrity sha512-rZ8PZLhK4ORPjFqLp9aqC4/S1j4qWFsPPz13xmWdrbBkU/LlxMcok+f+6f8YnQ57MiZwKtOaW15biZZsY5Igvw== elliptic@6.5.4, elliptic@^6.5.3: version "6.5.4" @@ -8422,9 +8422,9 @@ flatted@^2.0.0: integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== flatted@^3.1.0: - version "3.2.5" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" - integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== + version "3.2.6" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.6.tgz#022e9218c637f9f3fc9c35ab9c9193f05add60b2" + integrity sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ== flatten@^1.0.2: version "1.0.3" @@ -9311,9 +9311,9 @@ http-errors@~1.6.2: statuses ">= 1.4.0 < 2" http-parser-js@>=0.5.1: - version "0.5.7" - resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.7.tgz#39bde369fb8a57235121bb69d05f079fa1b598f4" - integrity sha512-8gQM8ZcewlONQLnik2AKzS13euQhaZcu4rK5QBSYOszW0T1upLW9VA2MdWvTvMmRo42HjXp7igFmdROoBCCrfg== + version "0.5.8" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" + integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== http-proxy-agent@^4.0.1: version "4.0.1" @@ -10196,11 +10196,11 @@ is-shared-array-buffer@^1.0.2: call-bind "^1.0.2" is-ssh@^1.3.0: - version "1.3.3" - resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.3.3.tgz#7f133285ccd7f2c2c7fc897b771b53d95a2b2c7e" - integrity sha512-NKzJmQzJfEEma3w5cJNcUMxoXfDjz0Zj0eyCalHn2E6VOwlzjZo0yuO2fcBSf8zhFuVCL/82/r5gRcoi6aEPVQ== + version "1.4.0" + resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.4.0.tgz#4f8220601d2839d8fa624b3106f8e8884f01b8b2" + integrity sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ== dependencies: - protocols "^1.1.0" + protocols "^2.0.1" is-stream@^1.1.0: version "1.1.0" @@ -13265,9 +13265,9 @@ number-is-nan@^1.0.0: integrity sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ== nwsapi@^2.0.7, nwsapi@^2.1.3, nwsapi@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" - integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ== + version "2.2.1" + resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.1.tgz#10a9f268fbf4c461249ebcfe38e359aa36e2577c" + integrity sha512-JYOWTeFoS0Z93587vRJgASD5Ut11fYl5NyihP3KrYBvMe1FRRs6RN7m20SA/16GM4P6hTnZjT+UmDOt38UeXNg== oauth-sign@~0.9.0: version "0.9.0" @@ -13781,7 +13781,7 @@ parse-json@^5.0.0: json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" -parse-path@^4.0.0: +parse-path@^4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/parse-path/-/parse-path-4.0.4.tgz#4bf424e6b743fb080831f03b536af9fc43f0ffea" integrity sha512-Z2lWUis7jlmXC1jeOG9giRO2+FsuyNipeQ43HAjqAZjwSe3SEf+q/84FGPHoso3kyntbxa4c4i77t3m6fGf8cw== @@ -13792,13 +13792,13 @@ parse-path@^4.0.0: query-string "^6.13.8" parse-url@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-6.0.0.tgz#f5dd262a7de9ec00914939220410b66cff09107d" - integrity sha512-cYyojeX7yIIwuJzledIHeLUBVJ6COVLeT4eF+2P6aKVzwvgKQPndCBv3+yQ7pcWjqToYwaligxzSYNNmGoMAvw== + version "6.0.2" + resolved "https://registry.yarnpkg.com/parse-url/-/parse-url-6.0.2.tgz#4a30b057bfc452af64512dfb1a7755c103db3ea1" + integrity sha512-uCSjOvD3T+6B/sPWhR+QowAZcU/o4bjPrVBQBGFxcDF6J6FraCGIaDBsdoQawiaaAVdHvtqBe3w3vKlfBKySOQ== dependencies: is-ssh "^1.3.0" normalize-url "^6.1.0" - parse-path "^4.0.0" + parse-path "^4.0.4" protocols "^1.4.0" parse5@4.0.0: @@ -14862,11 +14862,16 @@ protocol-buffers-schema@^3.3.1: resolved "https://registry.yarnpkg.com/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz#77bc75a48b2ff142c1ad5b5b90c94cd0fa2efd03" integrity sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw== -protocols@^1.1.0, protocols@^1.4.0: +protocols@^1.4.0: version "1.4.8" resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8" integrity sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg== +protocols@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/protocols/-/protocols-2.0.1.tgz#8f155da3fc0f32644e83c5782c8e8212ccf70a86" + integrity sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q== + protons@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/protons/-/protons-2.0.3.tgz#94f45484d04b66dfedc43ad3abff1e8907994bb2" @@ -14977,9 +14982,9 @@ qs@6.10.3: side-channel "^1.0.4" qs@^6.9.4: - version "6.10.5" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4" - integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ== + version "6.11.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== dependencies: side-channel "^1.0.4" From 295c40e5bce19c535fd9e1690a3f2dcd3e6aac2f Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Mon, 27 Jun 2022 10:12:07 -0700 Subject: [PATCH 2/6] linter fix --- packages/js/plugins/ethereum/src/index.ts | 38 +++++++---------------- packages/js/plugins/http/src/index.ts | 5 +-- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/packages/js/plugins/ethereum/src/index.ts b/packages/js/plugins/ethereum/src/index.ts index 485adf64f6..d30fcf8f26 100644 --- a/packages/js/plugins/ethereum/src/index.ts +++ b/packages/js/plugins/ethereum/src/index.ts @@ -83,11 +83,7 @@ export class EthereumPlugin extends Module { _client: Client ): Promise { const connection = await this._getConnection(args.connection); - const contract = connection.getContract( - args.address, - [args.method], - false - ); + const contract = connection.getContract(args.address, [args.method], false); const funcs = Object.keys(contract.interface.functions); const res = await contract[funcs[0]](...parseArgs(args.args)); return res.toString(); @@ -102,18 +98,15 @@ export class EthereumPlugin extends Module { const funcs = Object.keys(contract.interface.functions); try { - const res = await contract.callStatic[funcs[0]]( - ...parseArgs(args.args), - { - gasPrice: args.gasPrice - ? ethers.BigNumber.from(args.gasPrice) - : undefined, - gasLimit: args.gasLimit - ? ethers.BigNumber.from(args.gasLimit) - : undefined, - value: args.value ? ethers.BigNumber.from(args.value) : undefined, - } - ); + const res = await contract.callStatic[funcs[0]](...parseArgs(args.args), { + gasPrice: args.gasPrice + ? ethers.BigNumber.from(args.gasPrice) + : undefined, + gasLimit: args.gasLimit + ? ethers.BigNumber.from(args.gasLimit) + : undefined, + value: args.value ? ethers.BigNumber.from(args.value) : undefined, + }); return { result: res.toString(), error: false, @@ -204,10 +197,7 @@ export class EthereumPlugin extends Module { ).toString(); } - async getGasPrice( - args: Args_getGasPrice, - _client: Client - ): Promise { + async getGasPrice(args: Args_getGasPrice, _client: Client): Promise { const connection = await this._getConnection(args.connection); return (await connection.getSigner().getGasPrice()).toString(); } @@ -381,11 +371,7 @@ export class EthereumPlugin extends Module { ): Promise { const connection = await this._getConnection(args.connection); const signer = connection.getSigner(); - const factory = new ethers.ContractFactory( - args.abi, - args.bytecode, - signer - ); + const factory = new ethers.ContractFactory(args.abi, args.bytecode, signer); const contract = await factory.deploy(...parseArgs(args.args)); await contract.deployTransaction.wait(); diff --git a/packages/js/plugins/http/src/index.ts b/packages/js/plugins/http/src/index.ts index e8b3879ac0..ef692214fd 100644 --- a/packages/js/plugins/http/src/index.ts +++ b/packages/js/plugins/http/src/index.ts @@ -14,10 +14,7 @@ import { PluginFactory } from "@polywrap/core-js"; type NoConfig = Record; export class HttpPlugin extends Module { - public async get( - args: Args_get, - _client: Client - ): Promise { + public async get(args: Args_get, _client: Client): Promise { const response = await axios.get( args.url, args.request ? toAxiosRequestConfig(args.request) : undefined From 1430526e27f1ba9b282071d130f20789dc3f57c7 Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Mon, 27 Jun 2022 10:38:34 -0700 Subject: [PATCH 3/6] fix codegen --- .../templates/imported/module-type/index-ts.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache index 9b4216de10..ebcf75368c 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache +++ b/packages/schema/bind/src/bindings/assemblyscript/wasm-as/templates/imported/module-type/index-ts.mustache @@ -27,11 +27,11 @@ export class {{type}} { public static {{name}}( args: Args_{{name}} ): Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string> { - const args = serialize{{name}}Args(args); + const argsBuf = serialize{{name}}Args(args); const result = wrap_subinvoke( "{{uri}}", "{{name}}", - args + argsBuf ); if (result.isErr) { @@ -65,12 +65,12 @@ export class {{type}} { public {{name}}( args: Args_{{name}} ): Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string> { - const args = serialize{{name}}Args(args); + const argsBuf = serialize{{name}}Args(args); const result = wrap_subinvokeImplementation( "{{uri}}", this.uri, "{{name}}", - args + argsBuf ); if (result.isErr) { From 94c0c670ca28b93c842068a6ae42b4fc50d4d999 Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Mon, 27 Jun 2022 10:45:38 -0700 Subject: [PATCH 4/6] fix typo --- packages/js/core/src/algorithms/parse-query.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/core/src/algorithms/parse-query.ts b/packages/js/core/src/algorithms/parse-query.ts index 9475403a6b..7fc3049182 100644 --- a/packages/js/core/src/algorithms/parse-query.ts +++ b/packages/js/core/src/algorithms/parse-query.ts @@ -51,7 +51,7 @@ export const parseQuery = Tracer.traceFunc( ); } - // Get al arguments + // Get all arguments const selectionArgs = selection.arguments; const args: Record = {}; From 55c6ee74a9d3b49375fce19ddea02c496d836960 Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Mon, 27 Jun 2022 10:49:02 -0700 Subject: [PATCH 5/6] fix bind test --- .../output/wasm-as/imported/TestImport_Module/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts index 6587cada4c..1f5887a141 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts @@ -30,12 +30,12 @@ export class TestImport_Module { public importedMethod( args: Args_importedMethod ): Result { - const args = serializeimportedMethodArgs(args); + const argsBuf = serializeimportedMethodArgs(args); const result = wrap_subinvokeImplementation( "testimport.uri.eth", this.uri, "importedMethod", - args + argsBuf ); if (result.isErr) { @@ -52,12 +52,12 @@ export class TestImport_Module { public anotherMethod( args: Args_anotherMethod ): Result { - const args = serializeanotherMethodArgs(args); + const argsBuf = serializeanotherMethodArgs(args); const result = wrap_subinvokeImplementation( "testimport.uri.eth", this.uri, "anotherMethod", - args + argsBuf ); if (result.isErr) { From 2d94065bcbaf9e125872673f7313d6d68d6802ba Mon Sep 17 00:00:00 2001 From: dOrgJelli Date: Mon, 27 Jun 2022 11:51:19 -0700 Subject: [PATCH 6/6] fix bind tests --- .../output/wasm-as/imported/TestImport_Module/serialization.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts index 46dffdc603..c6b5c83eaa 100644 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts +++ b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts @@ -112,8 +112,6 @@ export function writeimportedMethodArgs( writer.context().pop(); writer.context().push("optEnumArray", "Array> | null", "writing property"); writer.writeString("optEnumArray"); - writer.writeOptionalArray(args.optEnumArray, (writer: Write, item: Option): void => { - writer.writeOptionalInt32(item); writer.writeOptionalArray(args.optEnumArray, (writer: Write, item: Option): void => { writer.writeOptionalInt32(item); });