Skip to content

Commit

Permalink
Merge pull request #8481 from Agoric/recorder-kit-storage-type
Browse files Browse the repository at this point in the history
Update RecorderKit to use Awaited<FarAway<StorageNode>>
  • Loading branch information
mergify[bot] authored Nov 6, 2023
2 parents 0e22bfa + 30c3d60 commit 97f26d4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/zoe/src/contractSupport/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { E } from '@endo/eventual-send';

/**
* @template T
* @typedef {{ getStorageNode(): StorageNode, getStoragePath(): Promise<string>, write(value: T): Promise<void>, writeFinal(value: T): Promise<void> }} Recorder
* @typedef {{ getStorageNode(): Awaited<import('@endo/far').FarRef<StorageNode>>, getStoragePath(): Promise<string>, write(value: T): Promise<void>, writeFinal(value: T): Promise<void> }} Recorder
*/

/**
Expand Down Expand Up @@ -55,7 +55,7 @@ export const prepareRecorder = (baggage, marshaller) => {
/**
* @template T
* @param {PublishKit<T>['publisher']} publisher
* @param {StorageNode} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {TypedMatcher<T>} [valueShape]
*/
(
Expand Down Expand Up @@ -144,13 +144,19 @@ harden(prepareRecorder);
export const defineRecorderKit = ({ makeRecorder, makeDurablePublishKit }) => {
/**
* @template T
* @param {StorageNode} storageNode
* @param {StorageNode | Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {TypedMatcher<T>} [valueShape]
* @returns {RecorderKit<T>}
*/
const makeRecorderKit = (storageNode, valueShape) => {
const { subscriber, publisher } = makeDurablePublishKit();
const recorder = makeRecorder(publisher, storageNode, valueShape);
const recorder = makeRecorder(
publisher,
/** @type { Awaited<import('@endo/far').FarRef<StorageNode>> } */ (
storageNode
),
valueShape,
);
return harden({ subscriber, recorder });
};
return makeRecorderKit;
Expand All @@ -174,7 +180,12 @@ export const defineERecorderKit = ({ makeRecorder, makeDurablePublishKit }) => {
const makeERecorderKit = (storageNodeP, valueShape) => {
const { publisher, subscriber } = makeDurablePublishKit();
const recorderP = E.when(storageNodeP, storageNode =>
makeRecorder(publisher, storageNode, valueShape),
makeRecorder(
publisher,
// @ts-expect-error Casting because it's remote
/** @type { import('@endo/far').FarRef<StorageNode> } */ (storageNode),
valueShape,
),
);
return { subscriber, recorderP };
};
Expand Down

0 comments on commit 97f26d4

Please sign in to comment.