Skip to content

Commit

Permalink
Merge pull request #1794 from endojs/markm-symbol-insteadof-VatData
Browse files Browse the repository at this point in the history
feat(pass-style): Use endowed passStyleOf if at global symbol
  • Loading branch information
erights authored Sep 29, 2023
2 parents 1407148 + 53658ea commit 2a85f8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/pass-style/endow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PassStyleOfEndowmentSymbol } from './src/passStyleOf.js';
1 change: 1 addition & 0 deletions packages/pass-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"exports": {
".": "./index.js",
"./tools.js": "./tools.js",
"./endow.js": "./endow.js",
"./package.json": "./package.json"
},
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions packages/pass-style/src/passStyleOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ const makePassStyleOf = passStyleHelpers => {
return harden(passStyleOf);
};

export const PassStyleOfEndowmentSymbol = Symbol.for('@endo passStyleOf');

/**
* If there is already a `VataData` global containing a `passStyleOf`,
* then presumably it was endowed for us by liveslots, so we should use
* and export that one instead. Other software may have left it for us here,
* If there is already a PassStyleOfEndowmentSymbol property on the global,
* then presumably it was endowed for us by liveslots with a `passStyleOf`
* function, so we should use and export that one instead.
* Other software may have left it for us here,
* but it would require write access to our global, or the ability to
* provide endowments to our global, both of which seems adequate as a test of
* whether it is authorized to serve the same role as liveslots.
Expand All @@ -205,9 +208,7 @@ const makePassStyleOf = passStyleHelpers => {
* @type {PassStyleOf}
*/
export const passStyleOf =
// UNTIL https://github.com/endojs/endo/issues/1514
// Prefer: globalThis?.VatData?.passStyleOf ||
(globalThis && globalThis.VatData && globalThis.VatData.passStyleOf) ||
(globalThis && globalThis[PassStyleOfEndowmentSymbol]) ||
makePassStyleOf([
CopyArrayHelper,
CopyRecordHelper,
Expand Down

0 comments on commit 2a85f8a

Please sign in to comment.