Skip to content

Commit 964fd64

Browse files
authored
Merge pull request #1568 from polywrap/origin-0.9-dev
Prep 0.9.6 | /workflows/release-pr
2 parents f27bea8 + b3efd99 commit 964fd64

23 files changed

Lines changed: 410 additions & 100 deletions

File tree

.github/workflows/release-pr.yaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
if: ${{env.IS_PUBLISHER == 'false'}}
3232
uses: actions/github-script@0.8.0
3333
with:
34-
github-token: ${{secrets.POLYWRAP_BUILD_BOT_PAT}}
34+
github-token: ${{secrets.GITHUB_TOKEN}}
3535
script: |
3636
github.issues.createComment({
3737
issue_number: context.issue.number,
@@ -62,7 +62,7 @@ jobs:
6262
if: ${{env.TAG_EXISTS == 'true'}}
6363
uses: actions/github-script@0.8.0
6464
with:
65-
github-token: ${{secrets.POLYWRAP_BUILD_BOT_PAT}}
65+
github-token: ${{secrets.GITHUB_TOKEN}}
6666
script: |
6767
github.issues.createComment({
6868
issue_number: context.issue.number,
@@ -86,16 +86,19 @@ jobs:
8686
with:
8787
ref: ${{github.event.pull_request.base.ref}}
8888

89-
- name: Set env.BOT to Build Bot's Username
90-
run: echo BOT=polywrap-build-bot >> $GITHUB_ENV
89+
- name: set env.RELEASE_FORKS to Release Forks' Organization
90+
run: echo RELEASE_FORKS=polywrap-release-forks >> $GITHUB_ENV
91+
92+
- name: Set env.BUILD_BOT to Build Bot's Username
93+
run: echo BUILD_BOT=polywrap-build-bot >> $GITHUB_ENV
9194

9295
- name: Read VERSION into env.RELEASE_VERSION
9396
run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
9497

9598
- name: Building Release PR...
9699
uses: actions/github-script@0.8.0
97100
with:
98-
github-token: ${{secrets.POLYWRAP_BUILD_BOT_PAT}}
101+
github-token: ${{secrets.GITHUB_TOKEN}}
99102
script: |
100103
github.issues.createComment({
101104
issue_number: context.issue.number,
@@ -120,8 +123,8 @@ jobs:
120123

121124
- name: Set Git Identity
122125
run: |
123-
git config --global user.name '${{env.BOT}}'
124-
git config --global user.email '${{env.BOT}}@users.noreply.github.com'
126+
git config --global user.name '${{env.BUILD_BOT}}'
127+
git config --global user.email '${{env.BUILD_BOT}}@users.noreply.github.com'
125128
env:
126129
GITHUB_TOKEN: ${{ secrets.POLYWRAP_BUILD_BOT_PAT }}
127130

@@ -141,11 +144,11 @@ jobs:
141144
uses: peter-evans/create-pull-request@v3
142145
with:
143146
token: ${{ secrets.POLYWRAP_BUILD_BOT_PAT }}
144-
push-to-fork: ${{env.BOT}}/${{github.event.pull_request.base.repo.name}}
147+
push-to-fork: ${{env.RELEASE_FORKS}}/${{github.event.pull_request.base.repo.name}}
145148
branch: release/origin-${{env.RELEASE_VERSION}}
146149
base: ${{github.event.pull_request.base.ref}}
147150
committer: GitHub <noreply@github.com>
148-
author: ${{env.BOT}} <${{env.BOT}}@users.noreply.github.com>
151+
author: ${{env.BUILD_BOT}} <${{env.BUILD_BOT}}@users.noreply.github.com>
149152
commit-message: "${{env.RELEASE_VERSION}}"
150153
title: 'Polywrap Origin (${{env.RELEASE_VERSION}})'
151154
body: |
@@ -168,7 +171,7 @@ jobs:
168171
- name: Release PR Created...
169172
uses: actions/github-script@0.8.0
170173
with:
171-
github-token: ${{secrets.POLYWRAP_BUILD_BOT_PAT}}
174+
github-token: ${{secrets.GITHUB_TOKEN}}
172175
script: |
173176
github.issues.createComment({
174177
issue_number: context.issue.number,

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Polywrap Origin (0.9.6)
2+
## Bugs
3+
* [PR-1558](https://github.com/polywrap/toolchain/pull/1558) `@polywrap/core-js` WrapError now correctly parsing Rust unwrap errors.
4+
* [PR-1559](https://github.com/polywrap/toolchain/pull/1559) `@polywrap/client-config-builder-js`, `@polywrap/ipfs-resolver-plugin-js`: Add the concept of configurable retries to the IPFS resolver.
5+
16
# Polywrap Origin (0.9.5)
27
## Bugs
38
* [PR-1541](https://github.com/polywrap/toolchain/pull/1541) `polywrap` CLI: Update build images to use the latest multi-platform versions.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.5
1+
0.9.6

packages/js/client-config-builder/src/bundles/default-client-config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export const getDefaultClientConfig = (
4040
fallbackProviders: defaultIpfsProviders.slice(1),
4141
},
4242
},
43+
{
44+
uri: new Uri("wrap://ens/ipfs-resolver.polywrap.eth"),
45+
env: {
46+
retries: { tryResolveUri: 1, getFile: 1 },
47+
},
48+
},
4349
],
4450
redirects: [
4551
{

packages/js/client/src/__tests__/core/error-structure.spec.ts

Lines changed: 177 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,44 @@ const incompatibleWrapperPath = `${GetPathToTestWrappers()}/wasm-as/simple-depre
2222
const incompatibleWrapperUri = new Uri(`fs/${incompatibleWrapperPath}`);
2323

2424
// RS
25-
const invalidTypesWrapperPath = `${GetPathToTestWrappers()}/wasm-rs/invalid-types`;
26-
const invalidTypesWrapperUri = new Uri(`fs/${invalidTypesWrapperPath}/build`);
25+
const invalidTypesWrapperRSPath = `${GetPathToTestWrappers()}/wasm-rs/invalid-types`;
26+
const invalidTypesWrapperRSUri = new Uri(`fs/${invalidTypesWrapperRSPath}/build`);
2727

28-
describe("Error structure", () => {
28+
const subinvokeErrorWrapperRSPath = `${GetPathToTestWrappers()}/wasm-rs/subinvoke-error/invoke`;
29+
const subinvokeErrorWrapperRSUri = new Uri(`fs/${subinvokeErrorWrapperRSPath}/build`);
2930

30-
let client: PolywrapClient;
31+
const badMathWrapperRSPath = `${GetPathToTestWrappers()}/wasm-rs/subinvoke-error/0-subinvoke`;
32+
const badMathWrapperRSUri = new Uri(`fs/${badMathWrapperRSPath}/build`);
3133

32-
beforeAll(async () => {
33-
await buildWrapper(simpleWrapperPath);
34-
await buildWrapper(badUtilWrapperPath);
35-
await buildWrapper(badMathWrapperPath);
36-
await buildWrapper(subinvokeErrorWrapperPath);
37-
await buildWrapper(invalidTypesWrapperPath);
34+
const badUtilWrapperRSPath = `${GetPathToTestWrappers()}/wasm-rs/subinvoke-error/1-subinvoke`;
35+
const badUtilWrapperRSUri = new Uri(`fs/${badUtilWrapperRSPath}/build`);
3836

39-
client = new PolywrapClient({
40-
redirects: [
41-
{
42-
from: "ens/bad-math.eth",
43-
to: badMathWrapperUri,
44-
},
45-
{
46-
from: "ens/bad-util.eth",
47-
to: badUtilWrapperUri,
48-
}
49-
]
50-
})
51-
});
5237

53-
describe("URI resolution", () => {
38+
describe("Error structure", () => {
39+
40+
describe("Wasm wrapper - AS", () => {
41+
let client: PolywrapClient;
42+
43+
beforeAll(async () => {
44+
await buildWrapper(simpleWrapperPath);
45+
await buildWrapper(badUtilWrapperPath);
46+
await buildWrapper(badMathWrapperPath);
47+
await buildWrapper(subinvokeErrorWrapperPath);
48+
49+
client = new PolywrapClient({
50+
redirects: [
51+
{
52+
from: Uri.from("ens/bad-math.eth"),
53+
to: badMathWrapperUri,
54+
},
55+
{
56+
from: Uri.from("ens/bad-util.eth"),
57+
to: badUtilWrapperUri,
58+
}
59+
]
60+
})
61+
});
62+
5463
test("Invoke a wrapper that is not found", async () => {
5564
const result = await client.invoke<string>({
5665
uri: simpleWrapperUri.uri + "-not-found",
@@ -99,10 +108,8 @@ describe("Error structure", () => {
99108
expect(prev.uri).toEqual("wrap://ens/not-found.eth");
100109
expect(prev.resolutionStack).toBeTruthy();
101110
});
102-
});
103111

104-
describe("Wasm wrapper", () => {
105-
test("Invoke a wrapper with malformed arguments - as", async () => {
112+
test("Invoke a wrapper with malformed arguments", async () => {
106113
const result = await client.invoke<string>({
107114
uri: simpleWrapperUri.uri,
108115
method: "simpleMethod",
@@ -123,27 +130,6 @@ describe("Error structure", () => {
123130
expect(result.error?.source).toEqual({ file: "~lib/@polywrap/wasm-as/msgpack/ReadDecoder.ts", row: 167, col: 5 });
124131
});
125132

126-
test("Invoke a wrapper with malformed arguments - rs", async () => {
127-
const result = await client.invoke<string>({
128-
uri: invalidTypesWrapperUri.uri,
129-
method: "boolMethod",
130-
args: {
131-
arg: 3,
132-
},
133-
});
134-
135-
expect(result.ok).toBeFalsy();
136-
if (result.ok) throw Error("should never happen");
137-
138-
expect(result.error?.name).toEqual("WrapError");
139-
expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED);
140-
expect(result.error?.reason.startsWith("__wrap_abort:")).toBeTruthy();
141-
expect(result.error?.uri.endsWith("packages/test-cases/cases/wrappers/wasm-rs/invalid-types/build")).toBeTruthy();
142-
expect(result.error?.method).toEqual("boolMethod");
143-
expect(result.error?.args).toEqual("{\n \"arg\": 3\n}");
144-
expect(result.error?.source).toEqual({ file: "src/wrap/module/wrapped.rs", row: 38, col: 13 });
145-
});
146-
147133
test("Invoke a wrapper method that doesn't exist", async () => {
148134
const result = await client.invoke<string>({
149135
uri: simpleWrapperUri.uri,
@@ -230,7 +216,150 @@ describe("Error structure", () => {
230216
});
231217
});
232218

219+
describe("Wasm wrapper - RS", () => {
220+
let client: PolywrapClient;
221+
222+
beforeAll(async () => {
223+
await buildWrapper(invalidTypesWrapperRSPath);
224+
await buildWrapper(badUtilWrapperRSPath);
225+
await buildWrapper(badMathWrapperRSPath);
226+
await buildWrapper(subinvokeErrorWrapperRSPath);
227+
228+
client = new PolywrapClient({
229+
redirects: [
230+
{
231+
from: Uri.from("ens/bad-math.eth"),
232+
to: badMathWrapperRSUri,
233+
},
234+
{
235+
from: Uri.from("ens/bad-util.eth"),
236+
to: badUtilWrapperRSUri,
237+
}
238+
]
239+
})
240+
});
241+
242+
test("Subinvoke a wrapper that is not found", async () => {
243+
const result = await client.invoke<number>({
244+
uri: subinvokeErrorWrapperRSUri.uri,
245+
method: "subWrapperNotFound",
246+
args: {
247+
a: 1,
248+
b: 1,
249+
},
250+
});
251+
252+
expect(result.ok).toBeFalsy();
253+
if (result.ok) throw Error("should never happen");
254+
255+
expect(result.error?.name).toEqual("WrapError");
256+
expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED);
257+
expect(result.error?.reason.startsWith("SubInvocation exception encountered")).toBeTruthy();
258+
expect(result.error?.uri.endsWith("packages/test-cases/cases/wrappers/wasm-rs/subinvoke-error/invoke/build")).toBeTruthy();
259+
expect(result.error?.method).toEqual("subWrapperNotFound");
260+
expect(result.error?.args).toEqual("{\n \"a\": 1,\n \"b\": 1\n}");
261+
expect(result.error?.source).toEqual({ file: "src/lib.rs", row: 17, col: 57 });
262+
263+
expect(result.error?.innerError instanceof WrapError).toBeTruthy();
264+
const prev = result.error?.innerError as WrapError;
265+
expect(prev.name).toEqual("WrapError");
266+
expect(prev.code).toEqual(WrapErrorCode.URI_NOT_FOUND);
267+
expect(prev.reason).toEqual("Unable to find URI wrap://ens/not-found.eth.");
268+
expect(prev.uri).toEqual("wrap://ens/not-found.eth");
269+
expect(prev.resolutionStack).toBeTruthy();
270+
});
271+
272+
test("Invoke a wrapper with malformed arguments", async () => {
273+
const result = await client.invoke<string>({
274+
uri: invalidTypesWrapperRSUri.uri,
275+
method: "boolMethod",
276+
args: {
277+
arg: 3,
278+
},
279+
});
280+
281+
expect(result.ok).toBeFalsy();
282+
if (result.ok) throw Error("should never happen");
283+
284+
expect(result.error?.name).toEqual("WrapError");
285+
expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED);
286+
expect(result.error?.reason.startsWith("__wrap_abort:")).toBeTruthy();
287+
expect(result.error?.uri.endsWith("packages/test-cases/cases/wrappers/wasm-rs/invalid-types/build")).toBeTruthy();
288+
expect(result.error?.method).toEqual("boolMethod");
289+
expect(result.error?.args).toEqual("{\n \"arg\": 3\n}");
290+
expect(result.error?.source).toEqual({ file: "src/wrap/module/wrapped.rs", row: 38, col: 13 });
291+
});
292+
293+
test("Invoke a wrapper method that doesn't exist", async () => {
294+
const result = await client.invoke<string>({
295+
uri: invalidTypesWrapperRSUri.uri,
296+
method: "complexMethod",
297+
args: {
298+
arg: "test",
299+
},
300+
});
301+
302+
expect(result.ok).toBeFalsy();
303+
if (result.ok) throw Error("should never happen");
304+
305+
expect(result.error?.name).toEqual("WrapError");
306+
expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_FAIL);
307+
expect(result.error?.reason.startsWith("Could not find invoke function")).toBeTruthy();
308+
expect(result.error?.uri.endsWith("packages/test-cases/cases/wrappers/wasm-rs/invalid-types/build")).toBeTruthy();
309+
expect(result.error?.method).toEqual("complexMethod");
310+
expect(result.error?.args).toEqual("{\n \"arg\": \"test\"\n}");
311+
expect(result.error?.toString().split(
312+
WrapErrorCode.WRAPPER_INVOKE_FAIL.valueOf().toString()
313+
).length).toEqual(2);
314+
expect(result.error?.innerError).toBeUndefined();
315+
});
316+
317+
test("Subinvoke error two layers deep", async () => {
318+
const result = await client.invoke<number>({
319+
uri: subinvokeErrorWrapperRSUri.uri,
320+
method: "throwsInTwoSubinvokeLayers",
321+
args: {
322+
a: 1,
323+
b: 1,
324+
},
325+
});
326+
327+
expect(result.ok).toBeFalsy();
328+
if (result.ok) throw Error("should never happen");
329+
330+
expect(result.error?.name).toEqual("WrapError");
331+
expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED);
332+
expect(result.error?.reason.startsWith("SubInvocation exception encountered")).toBeTruthy();
333+
expect(result.error?.uri.endsWith("packages/test-cases/cases/wrappers/wasm-rs/subinvoke-error/invoke/build")).toBeTruthy();
334+
expect(result.error?.method).toEqual("throwsInTwoSubinvokeLayers");
335+
expect(result.error?.args).toEqual("{\n \"a\": 1,\n \"b\": 1\n}");
336+
expect(result.error?.source).toEqual({ file: "src/lib.rs", row: 9, col: 56 });
337+
338+
expect(result.error?.innerError instanceof WrapError).toBeTruthy();
339+
const prev = result.error?.innerError as WrapError;
340+
expect(prev.name).toEqual("WrapError");
341+
expect(prev.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED);
342+
expect(prev.reason.startsWith("SubInvocation exception encountered")).toBeTruthy();
343+
expect(prev.uri).toEqual("wrap://ens/bad-math.eth");
344+
expect(prev.method).toEqual("subInvokeWillThrow");
345+
expect(prev.args).toEqual("{\n \"0\": 130,\n \"1\": 161,\n \"2\": 97,\n \"3\": 1,\n \"4\": 161,\n \"5\": 98,\n \"6\": 1\n}");
346+
expect(prev.source).toEqual({ file: "src/lib.rs", row: 5, col: 75 });
347+
348+
expect(prev.innerError instanceof WrapError).toBeTruthy();
349+
const prevOfPrev = prev.innerError as WrapError;
350+
expect(prevOfPrev.name).toEqual("WrapError");
351+
expect(prevOfPrev.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED);
352+
expect(prevOfPrev.reason).toEqual("__wrap_abort: I threw an error!");
353+
expect(prevOfPrev.uri.endsWith("wrap://ens/bad-util.eth")).toBeTruthy();
354+
expect(prevOfPrev.method).toEqual("iThrow");
355+
expect(prevOfPrev.args).toEqual("{\n \"0\": 129,\n \"1\": 161,\n \"2\": 97,\n \"3\": 0\n}");
356+
expect(prevOfPrev.source).toEqual({ file: "src/lib.rs", row: 6, col: 5 });
357+
});
358+
});
359+
233360
describe("Plugin wrapper", () => {
361+
let client: PolywrapClient = new PolywrapClient();
362+
234363
test("Invoke a plugin wrapper with malformed args", async () => {
235364
const result = await client.invoke<Uint8Array>({
236365
uri: "wrap://ens/fs.polywrap.eth",

0 commit comments

Comments
 (0)