Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(board)!: migrate to smallCaps for boardMarshaller, vstorage, smartWallet #7013

Closed
wants to merge 3 commits into from
Closed
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 packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ export default async function main(progname, args, { env, homedir, agcc }) {
STORAGE_PATH.BUNDLES,
{ sequence: true },
);
const marshaller = makeMarshal();
const marshaller = makeMarshal({
serializeBodyFormat: 'smallcaps',
});
const { publisher, subscriber } = makePublishKit();
pipeTopicToStorage(subscriber, installationStorageNode, marshaller);
return publisher;
Expand Down
1 change: 1 addition & 0 deletions packages/notifier/src/storesub.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const makeStoredSubscription = (
storageNode,
marshaller = makeMarshal(undefined, undefined, {
marshalSaveError: () => {},
serializeBodyFormat: 'smallcaps',
}),
) => {
/** @type {Unserializer} */
Expand Down
9 changes: 7 additions & 2 deletions packages/vats/src/lib-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ const makeSlotToVal = state => {
return slotToVal;
};

/** @type {import('@endo/marshal').MakeMarshalOptions} */
const useSmallCaps = harden({
serializeBodyFormat: 'smallcaps',
});

Comment on lines +202 to +206
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer that you not factor this out, but rather repeat the object literal inline in both call sites. The reason is that this is an options bag, and each call site could in theory want to add their own options over time. Think of the options like serializeBodyFormat as approximating name-based parameters as opposed to positional parameters.

// TODO make Marshaller type generic on slot
/**
* @param {BoardState} state
Expand All @@ -216,7 +221,7 @@ const makeReadonlyMarshaller = state => {
// Published value.
return valToId.get(val);
};
return makeMarshal(valToSlot, slotToVal);
return makeMarshal(valToSlot, slotToVal, useSmallCaps);
};

/**
Expand All @@ -227,7 +232,7 @@ const makePublishingMarshaller = state => {
const slotToVal = makeSlotToVal(state);
// Always put the value in the board.
const valToSlot = val => getId(val, state);
return makeMarshal(valToSlot, slotToVal);
return makeMarshal(valToSlot, slotToVal, useSmallCaps);
};
// #endregion

Expand Down
10 changes: 5 additions & 5 deletions packages/vats/test/test-lib-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ const testBoardMarshaller = async (t, board, marshaller, publishing) => {
unpublished2: unpublished,
}),
);
const pub1ser = `{"@qclass":"slot","iface":"Alleged: published","index":0}`;
const pub2ser = `{"@qclass":"slot","index":0}`;
const unpub1ser = `{"@qclass":"slot","iface":"Alleged: unpublished","index":1}`;
const unpub2ser = `{"@qclass":"slot","index":1}`;
const pub1ser = '"$0.Alleged: published"';
const pub2ser = '"$0"';
const unpub1ser = '"$1.Alleged: unpublished"';
const unpub2ser = `"$1"`;
t.is(
ser.body,
`{"published1":${pub1ser},"published2":${pub2ser},"unpublished1":${unpub1ser},"unpublished2":${unpub2ser}}`,
`#{"published1":${pub1ser},"published2":${pub2ser},"unpublished1":${unpub1ser},"unpublished2":${unpub2ser}}`,
);
t.is(ser.slots.length, 2);
t.is(ser.slots[0], published1id);
Expand Down