|
1 | 1 | import { assert, details, q } from '@agoric/assert';
|
2 |
| -import { pureCopy, passStyleOf, REMOTE_STYLE } from '@agoric/marshal'; |
| 2 | +import { |
| 3 | + pureCopy, |
| 4 | + passStyleOf, |
| 5 | + REMOTE_STYLE, |
| 6 | + getInterfaceOf, |
| 7 | +} from '@agoric/marshal'; |
3 | 8 |
|
4 | 9 | // TODO: assertSubset and assertKeysAllowed are copied from Zoe. Move
|
5 | 10 | // this code to a location where it can be used by ERTP and Zoe
|
@@ -44,6 +49,18 @@ export const assertDisplayInfo = allegedDisplayInfo => {
|
44 | 49 |
|
45 | 50 | export const coerceDisplayInfo = allegedDisplayInfo => {
|
46 | 51 | if (passStyleOf(allegedDisplayInfo) === REMOTE_STYLE) {
|
| 52 | + // These condition together try to ensure that `allegedDisplayInfo` |
| 53 | + // is a plain empty object. It will accept all plain empty objects |
| 54 | + // that it should. It will reject most things we want to reject including |
| 55 | + // remotables that are explicitly declared `Remotable`. But a normal |
| 56 | + // HandledPromise presence not explicitly declared `Remotable` will |
| 57 | + // be mistaken for a plain empty object. Even in this case, the copy |
| 58 | + // has a new identity, so the only danger is that we didn't reject |
| 59 | + // with a diagnostic, potentially masking a programmer error. |
| 60 | + assert(Object.isFrozen(allegedDisplayInfo)); |
| 61 | + assert.equal(Reflect.ownKeys(allegedDisplayInfo).length, 0); |
| 62 | + assert.equal(Object.getPrototypeOf(allegedDisplayInfo), Object.prototype); |
| 63 | + assert.equal(getInterfaceOf(allegedDisplayInfo), undefined); |
47 | 64 | return harden({});
|
48 | 65 | }
|
49 | 66 | allegedDisplayInfo = pureCopy(allegedDisplayInfo);
|
|
0 commit comments