-
Notifications
You must be signed in to change notification settings - Fork 72
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
Inconsistency between Remotable rules and InterfaceGuard pattern language #1728
Labels
bug
Something isn't working
Comments
This was referenced Aug 22, 2023
Closed
Anticipated fix foundation: update export const assertInterfaceGuard = specimen => {
mustMatch(specimen, InterfaceGuardShape, 'interfaceGuard');
};
harden(assertInterfaceGuard);
+
+const { comparator: passableComparator } = makeComparatorKit();
/**
* @param {string} interfaceName
* @param {Record<string, MethodGuard>} methodGuards
* @param {{sloppy?: boolean}} [options]
* @returns {InterfaceGuard}
*/
const makeInterfaceGuard = (interfaceName, methodGuards, options = {}) => {
const { sloppy = false } = options;
+ const stringMethodGuards = {};
+ const symbolMethodGuardsEntries = [];
+ for (const key of ownKeys(methodGuards)) {
+ const value = methodGuards[key];
+ if (typeof key === 'symbol') {
+ symbolMethodGuardsEntries.push([key, value]);
+ } else {
+ stringMethodGuards[key] = value;
+ }
+ }
+ // Ensure a consistent order.
+ symbolMethodGuardsEntries.sort(([k1], [k2]) => passableComparator(k1, k2));
/** @type {InterfaceGuard} */
const result = harden({
klass: 'Interface',
interfaceName,
- methodGuards,
+ methodGuards: stringMethodGuards,
+ symbolMethodGuards: symbolMethodGuardsEntries,
sloppy,
});
assertInterfaceGuard(result);
return result;
}; |
gibson042
added a commit
that referenced
this issue
Aug 26, 2023
gibson042
added a commit
that referenced
this issue
Aug 27, 2023
gibson042
added a commit
that referenced
this issue
Aug 27, 2023
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Originally reported at Agoric/agoric-sdk#8231 )
https://github.com/Agoric/agoric-sdk/blob/61b6c39a7c8cedf7c7b11a5f5352d82f351e5657/packages/notifier/src/publish-kit.js#L48-L53
Remotables are allowed to have symbol-named methods. (The particular case that is already important for us is
Symbol.asyncIterator
as we see here.)InterfaceGuards are supposed to be Passable descriptions of the API of an exo, including the guards and methods used do the first level of input validation of the exo's methods. The InterfaceGuard uses a CopyRecord of method guards, where each property name of that CopyRecord is supposed to be the name of the method being described/guarded.
However, a CopyRecord can only have string-named properties. Therefore, there is currently no way for an InterfaceGuard to provide a MethodGuard for describing/guarding a symbol-named method.
The text was updated successfully, but these errors were encountered: