Skip to content

Commit

Permalink
refactor: resolvePathname for sync resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 12, 2025
1 parent 4d316b4 commit 9660aa6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { faV1BundleName } from './bootstrap-fluxAggregator-service-upgrade.js';

// so paths can be expresssed relative to this file and made absolute
const bfile = name => new URL(name, import.meta.url).pathname;
const resolvePathname = spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;

test('fluxAggregator service upgrade', async t => {
/** @type {SwingSetConfig} */
Expand All @@ -21,36 +23,25 @@ test('fluxAggregator service upgrade', async t => {
sourceSpec: bfile('bootstrap-fluxAggregator-service-upgrade.js'),
},
zoe: {
sourceSpec: importMetaResolve(
'@agoric/vats/src/vat-zoe.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/vats/src/vat-zoe.js'),
},
},
bundles: {
zcf: {
sourceSpec: importMetaResolve(
'@agoric/zoe/src/contractFacet/vatRoot.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/zoe/src/contractFacet/vatRoot.js'),
},
committee: {
sourceSpec: importMetaResolve(
'@agoric/governance/src/committee.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/governance/src/committee.js'),
},
puppetContractGovernor: {
sourceSpec: importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/governance/tools/puppetContractGovernor.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
[faV1BundleName]: {
sourceSpec: importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/inter-protocol/src/price/fluxAggregatorContract.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { psmV1BundleName } from './bootstrap-psm-upgrade.js';

// so paths can be expresssed relative to this file and made absolute
const bfile = name => new URL(name, import.meta.url).pathname;
const resolvePathname = spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;

test('PSM service upgrade', async t => {
/** @type {SwingSetConfig} */
Expand All @@ -21,36 +23,23 @@ test('PSM service upgrade', async t => {
sourceSpec: bfile('bootstrap-psm-upgrade.js'),
},
zoe: {
sourceSpec: importMetaResolve(
'@agoric/vats/src/vat-zoe.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/vats/src/vat-zoe.js'),
},
},
bundles: {
zcf: {
sourceSpec: importMetaResolve(
'@agoric/zoe/src/contractFacet/vatRoot.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/zoe/src/contractFacet/vatRoot.js'),
},
committee: {
sourceSpec: importMetaResolve(
'@agoric/governance/src/committee.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/governance/src/committee.js'),
},
puppetContractGovernor: {
sourceSpec: importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/governance/tools/puppetContractGovernor.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
[psmV1BundleName]: {
sourceSpec: importMetaResolve(
'@agoric/inter-protocol/src/psm/psm.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/inter-protocol/src/psm/psm.js'),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { arV1BundleName } from './bootstrap-assetReserve-upgrade.js';

// so paths can be expresssed relative to this file and made absolute
const bfile = name => new URL(name, import.meta.url).pathname;
const resolvePathname = spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;

test('assetReserve service upgrade', async t => {
/** @type {SwingSetConfig} */
Expand All @@ -21,36 +23,25 @@ test('assetReserve service upgrade', async t => {
sourceSpec: bfile('bootstrap-assetReserve-upgrade.js'),
},
zoe: {
sourceSpec: importMetaResolve(
'@agoric/vats/src/vat-zoe.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/vats/src/vat-zoe.js'),
},
},
bundles: {
zcf: {
sourceSpec: importMetaResolve(
'@agoric/zoe/src/contractFacet/vatRoot.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/zoe/src/contractFacet/vatRoot.js'),
},
committee: {
sourceSpec: importMetaResolve(
'@agoric/governance/src/committee.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/governance/src/committee.js'),
},
puppetContractGovernor: {
sourceSpec: importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/governance/tools/puppetContractGovernor.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
[arV1BundleName]: {
sourceSpec: importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/inter-protocol/src/reserve/assetReserve.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
},
};
Expand Down

0 comments on commit 9660aa6

Please sign in to comment.