Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/e2e/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/lib/defaults/deploy-modules/ens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ENSPublisher implements Deployer {
const { data: resolver } = await client.invoke<string>({
method: "getResolver",
uri: ensWrapperUri,
input: {
args: {
registryAddress: config.ensRegistryAddress,
domain: config.domainName,
connection: {
Expand All @@ -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,
Expand All @@ -107,7 +107,7 @@ class ENSPublisher implements Deployer {
await client.invoke({
method: "awaitTransaction",
uri: ethereumPluginUri,
input: {
args: {
txHash: setContenthashData.hash,
confirmations: 1,
timeout: 15000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LocalDevENSPublisher implements Deployer {
const { data: signer } = await client.invoke<string>({
method: "getSignerAddress",
uri: ethereumPluginUri,
input: {
args: {
connection: {
networkNameOrChainId: "testnet",
},
Expand All @@ -70,7 +70,7 @@ class LocalDevENSPublisher implements Deployer {
{
method: "registerDomainAndSubdomainsRecursively",
uri: ensWrapperUri,
input: {
args: {
domain: config.domainName,
owner: signer,
resolverAddress: ensAddresses.resolverAddress,
Expand All @@ -94,7 +94,7 @@ class LocalDevENSPublisher implements Deployer {
await client.invoke({
method: "awaitTransaction",
uri: ethereumPluginUri,
input: {
args: {
txHash: registerData.hash,
confirmations: 1,
timeout: 15000,
Expand All @@ -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,
Expand All @@ -126,7 +126,7 @@ class LocalDevENSPublisher implements Deployer {
await client.invoke({
method: "awaitTransaction",
uri: ethereumPluginUri,
input: {
args: {
txHash: setContenthashData.hash,
confirmations: 1,
timeout: 15000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ describe("plugin-wrapper", () => {
return this.config.map;
}

updateMap(input: { map: Map<string, number> }): Map<string, number> {
for (const key of input.map.keys()) {
updateMap(args: { map: Map<string, number> }): Map<string, number> {
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;
Expand Down
6 changes: 3 additions & 3 deletions packages/js/client/src/__tests__/core/wasm-wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("wasm-wrapper", () => {
const result = await client.invoke<string>({
uri: wrapperUri,
method: "deployContract",
input: {
args: {
connection: {
networkNameOrChainId: "testnet",
},
Expand All @@ -108,7 +108,7 @@ describe("wasm-wrapper", () => {
const result = await client.invoke({
uri: wrapperUri,
method: "deployContract",
input: {
args: {
connection: {
networkNameOrChainId: "testnet",
},
Expand Down Expand Up @@ -142,7 +142,7 @@ describe("wasm-wrapper", () => {
const result = await client.invoke({
uri: wrapperUri,
method: "deployContract",
input: {},
args: {},
config: {
redirects,
},
Expand Down
16 changes: 8 additions & 8 deletions packages/js/client/src/__tests__/e2e/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ export const runJsonTypeTest = async (
const parseResponse = await client.invoke<{ parse: Json }>({
uri,
method: "parse",
input: {
args: {
value
}
})
Expand All @@ -652,7 +652,7 @@ export const runJsonTypeTest = async (
const stringifyResponse = await client.invoke<{ stringify: Json}>({
uri,
method: "stringify",
input: {
args: {
values
}
})
Expand All @@ -669,7 +669,7 @@ export const runJsonTypeTest = async (
}>({
uri,
method: "stringifyObject",
input: {
args: {
object,
},
});
Expand All @@ -689,7 +689,7 @@ export const runJsonTypeTest = async (
}>({
uri,
method: "methodJSON",
input: json
args: json
});

const methodJSONResult = JSON.stringify(json);
Expand Down Expand Up @@ -1126,7 +1126,7 @@ export const runMapTypeTest = async (
const returnMapResponse1 = await client.invoke<Map<string, number>>({
uri,
method: "returnMap",
input: {
args: {
map: mapClass,
},
});
Expand All @@ -1136,7 +1136,7 @@ export const runMapTypeTest = async (
const returnMapResponse2 = await client.invoke<Map<string, number>>({
uri,
method: "returnMap",
input: {
args: {
map: mapRecord,
},
});
Expand All @@ -1146,7 +1146,7 @@ export const runMapTypeTest = async (
const getKeyResponse1 = await client.invoke<number>({
uri,
method: "getKey",
input: {
args: {
map: mapClass,
key: "Hello",
},
Expand All @@ -1157,7 +1157,7 @@ export const runMapTypeTest = async (
const getKeyResponse2 = await client.invoke<number>({
uri,
method: "getKey",
input: {
args: {
map: mapRecord,
key: "Heyo",
},
Expand Down
12 changes: 6 additions & 6 deletions packages/js/client/src/__tests__/e2e/workflow-test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const sanityWorkflow: Workflow = {
{
uri: "ens/testnet/simple-storage.eth",
method: "deployContract",
input: {
args: {
connection: null,
},
},
Expand All @@ -19,7 +19,7 @@ export const sanityWorkflow: Workflow = {
{
uri: "ens/testnet/simple-storage.eth",
method: "setData",
input: {
args: {
address: "0xA57B8a5584442B467b4689F1144D269d096A3daF",
value: 100,
connection: null,
Expand All @@ -28,7 +28,7 @@ export const sanityWorkflow: Workflow = {
{
uri: "ens/testnet/simple-storage.eth",
method: "getData",
input: {
args: {
address: "0xA57B8a5584442B467b4689F1144D269d096A3daF",
connection: null,
},
Expand All @@ -48,7 +48,7 @@ export const outPropWorkflow: Workflow = {
{
uri: "ens/testnet/simple-storage.eth",
method: "deployContract",
input: {
args: {
connection: null,
},
},
Expand All @@ -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,
Expand All @@ -68,7 +68,7 @@ export const outPropWorkflow: Workflow = {
{
uri: "ens/testnet/simple-storage.eth",
method: "getData",
input: {
args: {
address: "$cases.0.data",
connection: null,
},
Expand Down
24 changes: 12 additions & 12 deletions packages/js/client/src/plugin/PluginWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -63,7 +63,7 @@ export class PluginWrapper extends Wrapper {
): Promise<InvokeResult<TData>> {
try {
const { method, resultFilter } = options;
const input = options.input || {};
const args = options.args || {};
const module = this._getInstance();

if (!module) {
Expand All @@ -77,30 +77,30 @@ export class PluginWrapper extends Wrapper {
// Sanitize & load the module's environment
await this._sanitizeAndLoadEnv(client, module);

let jsInput: Record<string, unknown>;
let jsArgs: Record<string, unknown>;

// 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<string, unknown>;
jsArgs = result as Record<string, unknown>;
} else {
jsInput = input;
jsArgs = args;
}

// Invoke the function
try {
const result = (await module._wrap_invoke(
method,
jsInput,
jsArgs,
client
)) as TData;

Expand All @@ -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}`
);
Expand All @@ -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}`
);
}
Expand Down
10 changes: 5 additions & 5 deletions packages/js/client/src/wasm/WasmWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -179,7 +179,7 @@ export class WasmWrapper extends Wrapper {
): Promise<InvokeResult<unknown | ArrayBuffer>> {
try {
const { method, noDecode } = options;
const input = options.input || {};
const args = options.args || {};
const wasm = await this._getWasmModule(client);

const state: State = {
Expand All @@ -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`
);
};

Expand Down Expand Up @@ -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}`
);
}
Expand Down
Loading