diff --git a/packages/orchestration/src/examples/stakeBld.contract.js b/packages/orchestration/src/examples/stakeBld.contract.js index 82952d356058..1651a3a58d4b 100644 --- a/packages/orchestration/src/examples/stakeBld.contract.js +++ b/packages/orchestration/src/examples/stakeBld.contract.js @@ -12,7 +12,7 @@ import { deeplyFulfilled } from '@endo/marshal'; import { M } from '@endo/patterns'; import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js'; import { makeChainHub } from '../exos/chain-hub.js'; -import { makeTimestampHelper } from '../exos/time.js'; +import { makeTimeHelper } from '../exos/time-helper.js'; /** * @import {NameHub} from '@agoric/vats'; @@ -50,7 +50,7 @@ export const start = async (zcf, privateArgs, baggage) => { privateArgs.timerService, vowTools, makeChainHub(privateArgs.agoricNames), - makeTimestampHelper(privateArgs.timerService), + makeTimeHelper(privateArgs.timerService), ); // ---------------- diff --git a/packages/orchestration/src/exos/local-orchestration-account.js b/packages/orchestration/src/exos/local-orchestration-account.js index 00a214c321a5..90bab091473e 100644 --- a/packages/orchestration/src/exos/local-orchestration-account.js +++ b/packages/orchestration/src/exos/local-orchestration-account.js @@ -26,7 +26,7 @@ import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js'; * @import {PromiseVow, VowTools} from '@agoric/vow'; * @import {TypedJson} from '@agoric/cosmic-proto'; * @import {ChainHub} from './chain-hub.js'; - * @import {TimestampHelper} from './time.js'; + * @import {TimeHelper} from './time-helper.js'; */ const trace = makeTracer('LOA'); @@ -66,7 +66,7 @@ const PUBLIC_TOPICS = { * @param {Remote} timerService * @param {VowTools} vowTools * @param {ChainHub} chainHub - * @param {TimestampHelper} timestampHelper + * @param {TimeHelper} timeHelper */ export const prepareLocalOrchestrationAccountKit = ( zone, @@ -75,7 +75,7 @@ export const prepareLocalOrchestrationAccountKit = ( timerService, { watch, when, allVows }, chainHub, - timestampHelper, + timeHelper, ) => /** Make an object wrapping an LCA with Zoe interfaces. */ zone.exoClassKit( @@ -403,7 +403,7 @@ export const prepareLocalOrchestrationAccountKit = ( // TODO #9324 what's a reasonable default? currently 5 minutes // FIXME: do not call `getTimeoutTimestampNS` if `opts.timeoutTimestamp` or `opts.timeoutHeight` is provided const timeoutTimestampV = watch( - timestampHelper.getTimeoutTimestampNS(), + timeHelper.getTimeoutTimestampNS(), this.facets.getTimeoutTimestampWatcher, { opts }, ); diff --git a/packages/orchestration/src/exos/time.js b/packages/orchestration/src/exos/time-helper.js similarity index 87% rename from packages/orchestration/src/exos/time.js rename to packages/orchestration/src/exos/time-helper.js index e5982d26219e..e2bb3694138c 100644 --- a/packages/orchestration/src/exos/time.js +++ b/packages/orchestration/src/exos/time-helper.js @@ -20,21 +20,22 @@ export const NANOSECONDS_PER_SECOND = 1_000_000_000n; * @param {Zone} [zone] */ -export const makeTimestampHelper = (timerService, zone = makeHeapZone()) => { +export const makeTimeHelper = (timerService, zone = makeHeapZone()) => { /** @type {TimerBrand | undefined} */ let brandCache; const getBrand = () => { if (brandCache) return brandCache; return watch(E(timerService).getTimerBrand(), { onFulfilled: timerBrand => { + brandCache = timerBrand; return timerBrand; }, }); }; return zone.exo( - 'Timestamp Helper', - M.interface('TimeStampHelperI', { + 'Time Helper', + M.interface('TimeHelperI', { getTimeoutTimestampNS: M.call() .optional(RelativeTimeRecordShape) .returns(VowShape), @@ -53,7 +54,7 @@ export const makeTimestampHelper = (timerService, zone = makeHeapZone()) => { return watch( allVows([E(timerService).getCurrentTimestamp(), getBrand()]), { - /** @param {[TimestampRecord, TimerBrand]} r */ + /** @param {[TimestampRecord, TimerBrand]} results */ onFulfilled([currentTime, timerBrand]) { const timeout = relativeTime || @@ -73,4 +74,4 @@ export const makeTimestampHelper = (timerService, zone = makeHeapZone()) => { ); }; -/** @typedef {Awaited>} TimestampHelper */ +/** @typedef {Awaited>} TimeHelper */ diff --git a/packages/orchestration/src/utils/start-helper.js b/packages/orchestration/src/utils/start-helper.js index bbc57260136a..5bf1c6a8e28a 100644 --- a/packages/orchestration/src/utils/start-helper.js +++ b/packages/orchestration/src/utils/start-helper.js @@ -8,7 +8,7 @@ import { makeChainHub } from '../exos/chain-hub.js'; import { prepareRemoteChainFacade } from '../exos/remote-chain-facade.js'; import { prepareCosmosOrchestrationAccount } from '../exos/cosmos-orchestration-account.js'; import { prepareLocalChainFacade } from '../exos/local-chain-facade.js'; -import { makeTimestampHelper } from '../exos/time.js'; +import { makeTimeHelper } from '../exos/time-helper.js'; /** * @import {PromiseKit} from '@endo/promise-kit' @@ -48,7 +48,7 @@ export const provideOrchestration = ( const zone = makeDurableZone(baggage); const chainHub = makeChainHub(remotePowers.agoricNames); - const timestampHelper = makeTimestampHelper(remotePowers.timerService); + const timeHelper = makeTimeHelper(remotePowers.timerService); const vowTools = prepareVowTools(zone.subZone('vows')); @@ -60,7 +60,7 @@ export const provideOrchestration = ( remotePowers.timerService, vowTools, chainHub, - timestampHelper, + timeHelper, ); const asyncFlowTools = prepareAsyncFlowTools(zone.subZone('asyncFlow'), { diff --git a/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts b/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts index 00dae4c6764f..09e75f88cfa8 100644 --- a/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts +++ b/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts @@ -9,9 +9,9 @@ import { prepareLocalOrchestrationAccountKit } from '../../src/exos/local-orches import { ChainAddress } from '../../src/orchestration-api.js'; import { makeChainHub } from '../../src/exos/chain-hub.js'; import { - makeTimestampHelper, + makeTimeHelper, NANOSECONDS_PER_SECOND, -} from '../../src/exos/time.js'; +} from '../../src/exos/time-helper.js'; import { commonSetup } from '../supports.js'; test('deposit, withdraw', async t => { @@ -37,7 +37,7 @@ test('deposit, withdraw', async t => { timer, vowTools, makeChainHub(bootstrap.agoricNames), - makeTimestampHelper(timer), + makeTimeHelper(timer), ); t.log('request account from vat-localchain'); @@ -109,7 +109,7 @@ test('delegate, undelegate', async t => { timer, vowTools, makeChainHub(bootstrap.agoricNames), - makeTimestampHelper(timer), + makeTimeHelper(timer), ); t.log('request account from vat-localchain'); @@ -162,7 +162,7 @@ test('transfer', async t => { timer, vowTools, makeChainHub(bootstrap.agoricNames), - makeTimestampHelper(timer), + makeTimeHelper(timer), ); t.log('request account from vat-localchain'); diff --git a/packages/orchestration/test/exos/time.test.ts b/packages/orchestration/test/exos/time-helper.test.ts similarity index 77% rename from packages/orchestration/test/exos/time.test.ts rename to packages/orchestration/test/exos/time-helper.test.ts index 768869e493f9..e761b5ce3edc 100644 --- a/packages/orchestration/test/exos/time.test.ts +++ b/packages/orchestration/test/exos/time-helper.test.ts @@ -4,26 +4,26 @@ import { V } from '@agoric/vow/vat.js'; import { buildZoeManualTimer } from '@agoric/zoe/tools/manualTimer.js'; import { TimeMath } from '@agoric/time'; import { - makeTimestampHelper, + makeTimeHelper, NANOSECONDS_PER_SECOND, SECONDS_PER_MINUTE, -} from '../../src/exos/time.js'; +} from '../../src/exos/time-helper.js'; -test('makeTimestampHelper - getCurrentTimestamp', async t => { +test('makeTimeHelper - getCurrentTimestamp', async t => { const timer = buildZoeManualTimer(t.log); const timerBrand = timer.getTimerBrand(); t.is(timer.getCurrentTimestamp().absValue, 0n, 'current time is 0n'); - const timestampHelper = makeTimestampHelper(timer); + const timeHelper = makeTimeHelper(timer); t.is( - await V.when(timestampHelper.getTimeoutTimestampNS()), + await V.when(timeHelper.getTimeoutTimestampNS()), 5n * SECONDS_PER_MINUTE * NANOSECONDS_PER_SECOND, 'default timestamp is 5 minutes from current time, in nanoseconds', ); t.is( await V.when( - timestampHelper.getTimeoutTimestampNS( + timeHelper.getTimeoutTimestampNS( TimeMath.coerceRelativeTimeRecord(1n, timerBrand), ), ), @@ -35,7 +35,7 @@ test('makeTimestampHelper - getCurrentTimestamp', async t => { await timer.tickN(3); t.is( await V.when( - timestampHelper.getTimeoutTimestampNS( + timeHelper.getTimeoutTimestampNS( TimeMath.coerceRelativeTimeRecord(1n, timerBrand), ), ),