Skip to content

Commit

Permalink
fix: review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Sep 17, 2022
1 parent 9d55a2a commit 0a5739f
Show file tree
Hide file tree
Showing 12 changed files with 414 additions and 273 deletions.
11 changes: 6 additions & 5 deletions packages/captp/src/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export const makeCapTP = (
// TODO Temporary hack.
// See https://github.com/Agoric/agoric-sdk/issues/2780
errorIdNum: 20000,
// TODO: fix captp to be compatible with smallcaps
serializeBodyFormat: 'capdata',
},
);

Expand Down Expand Up @@ -611,10 +613,11 @@ export const makeCapTP = (
assert.fail(X`Trap(${target}) target cannot be a promise`);

const slot = valToSlot.get(target);
(slot && slot[1] === '-') ||
assert.fail(X`Trap(${target}) target was not imported`);
// @ts-expect-error TS apparently confused about `||` control flow
// TypeScript confused about `||` control flow so use `if` instead
// https://github.com/microsoft/TypeScript/issues/50739
if (!(slot && slot[1] === '-')) {
assert.fail(X`Trap(${target}) target was not imported`);
}
slot[0] === 't' ||
assert.fail(
X`Trap(${target}) imported target was not created with makeTrapHandler`,
Expand Down Expand Up @@ -651,8 +654,6 @@ export const makeCapTP = (
// messages over the current CapTP data channel.
const [isException, serialized] = trapGuest({
trapMethod: implMethod,
// @ts-expect-error TS apparently confused about `||` control flow
// https://github.com/microsoft/TypeScript/issues/50739
slot,
trapArgs: implArgs,
startTrap: () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/marshal/src/dot-membrane.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const makeConverter = (mirrorConverter = undefined) => {
break;
}
default: {
assert.fail(X`unrecognized passStyle ${passStyle}`);
assert.fail(X`internal: Unrecognized passStyle ${passStyle}`);
}
}
mineToYours.set(mine, yours);
Expand Down
9 changes: 6 additions & 3 deletions packages/marshal/src/encodeToCapData.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ export const makeEncodeToCapData = ({
return encodePromiseToCapData(passable);
}
default: {
assert.fail(X`unrecognized passStyle ${q(passStyle)}`, TypeError);
assert.fail(
X`internal: Unrecognized passStyle ${q(passStyle)}`,
TypeError,
);
}
}
};
Expand Down Expand Up @@ -393,9 +396,9 @@ export const makeDecodeFromCapData = ({
// @ts-expect-error This is the error case we're testing for
case 'ibid': {
assert.fail(
X`The capData protocol no longer supports [${q(QCLASS)}]: ${q(
X`The capData protocol no longer supports ${q(QCLASS)} ${q(
qclass,
)} encoding: ${jsonEncoded}.`,
)}`,
);
}
default: {
Expand Down
Loading

0 comments on commit 0a5739f

Please sign in to comment.