Skip to content

Commit

Permalink
fixup! change storagenode type to FarAway
Browse files Browse the repository at this point in the history
  • Loading branch information
iomekam committed Oct 30, 2023
1 parent 32c0df5 commit 502a38c
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 66 deletions.
4 changes: 2 additions & 2 deletions packages/cache/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const makeScalarStoreCoordinator = (
*
* @param {MapStore<string, import('./state').State>} stateStore
* @param {ERef<Marshaller>} marshaller
* @param {ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @returns {<T>(storedValue: T) => Promise<T>}
*/
const makeLastWinsUpdater = (stateStore, marshaller, storageNode) => {
Expand Down Expand Up @@ -199,7 +199,7 @@ const makeLastWinsUpdater = (stateStore, marshaller, storageNode) => {
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
* currently enforce any cache eviction, but that would be a useful feature.
*
* @param {ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {ERef<Marshaller>} marshaller
*/
export const makeChainStorageCoordinator = (storageNode, marshaller) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ harden(meta);
* committeeName: string,
* committeeSize: number,
* }>} zcf
* @param {{ storageNode: ERef<StorageNode>, marshaller: ERef<Marshaller>}} privateArgs
* @param {{ storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>, marshaller: ERef<Marshaller>}} privateArgs
* @param {import('@agoric/vat-data').Baggage} baggage
* @returns {{creatorFacet: CommitteeElectorateCreatorFacet, publicFacet: CommitteeElectoratePublic}}
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/src/contractHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const facetHelpers = (zcf, paramManager) => {
* @param {ZCF<GovernanceTerms<M>>} zcf
* @param {Invitation} initialPoserInvitation
* @param {M} paramTypesMap
* @param {ERef<StorageNode>} [storageNode]
* @param {Awaited<import('@endo/eventual-send').FarRef<StorageNode>>} [storageNode]
* @param {ERef<Marshaller>} [marshaller]
*/
const handleParamGovernance = (
Expand Down
5 changes: 4 additions & 1 deletion packages/inter-protocol/src/auction/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ export const makeAuctioneerParamManager = (publisherKit, zcf, initial) => {
harden(makeAuctioneerParamManager);

/**
* @param {{ storageNode: ERef<StorageNode>; marshaller: ERef<Marshaller> }} caps
* @param {{
* storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>;
* marshaller: ERef<Marshaller>;
* }} caps
* @param {ERef<Timer>} timer
* @param {ERef<PriceAuthority>} priceAuthority
* @param {ERef<AssetReservePublicFacet>} reservePublicFacet
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/src/provisionPoolKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export const prepareProvisionPoolKit = (
*
* @param {object} opts
* @param {Brand} opts.poolBrand
* @param {ERef<StorageNode>} opts.storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} opts.storageNode
*/
const makeProvisionPoolKit = async ({ poolBrand, storageNode }) => {
/** @type {Purse<'nat'>} */
Expand Down
5 changes: 2 additions & 3 deletions packages/inter-protocol/src/reserve/assetReserve.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ harden(meta);
* feeMintAccess: FeeMintAccess;
* initialPoserInvitation: Invitation;
* marshaller: ERef<Marshaller>;
* storageNode: ERef<StorageNode>;
* storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>;
* }} privateArgs
* @param {Baggage} baggage
*/
Expand Down Expand Up @@ -72,11 +72,10 @@ export const start = async (zcf, privateArgs, baggage) => {
};
trace('awaiting takeFeeMint');
const feeMint = await takeFeeMint();
const storageNode = await privateArgs.storageNode;
const makeAssetReserveKit = await prepareAssetReserveKit(baggage, {
feeMint,
makeRecorderKit,
storageNode,
storageNode: privateArgs.storageNode,
zcf,
});

Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/src/reserve/assetReserveKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const trace = makeTracer('ReserveKit', true);
* @param {{
* feeMint: ZCFMint<'nat'>;
* makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit;
* storageNode: StorageNode;
* storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>;
* zcf: ZCF;
* }} powers
*/
Expand Down Expand Up @@ -90,7 +90,7 @@ export const prepareAssetReserveKit = async (
keywordForBrand,
metricsKit: makeRecorderKit(
metricsNode,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */(
M.any()
),
),
Expand Down
7 changes: 5 additions & 2 deletions packages/inter-protocol/src/vaultFactory/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
/**
* @type {MapStore<
* Brand,
* { storageNode: StorageNode; initialParamValues: VaultManagerParamValues }
* {
* storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>;
* initialParamValues: VaultManagerParamValues;
* }
* >}
*/
const managerArgs = provideDurableMapStore(
Expand All @@ -206,7 +209,7 @@ export const provideVaultParamManagers = (baggage, marshaller) => {
return {
/**
* @param {Brand} brand
* @param {StorageNode} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {VaultManagerParamValues} initialParamValues
*/
addParamManager(brand, storageNode, initialParamValues) {
Expand Down
4 changes: 2 additions & 2 deletions packages/inter-protocol/src/vaultFactory/vaultDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const shortfallInvitationKey = 'shortfallInvitation';
* @param {ZCFMint<'nat'>} debtMint
* @param {ERef<import('@agoric/time/src/types').TimerService>} timer
* @param {ERef<import('../auction/auctioneer.js').AuctioneerPublicFacet>} auctioneer
* @param {ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {ERef<Marshaller>} marshaller
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit} makeRecorderKit
* @param {import('@agoric/zoe/src/contractSupport/recorder.js').MakeERecorderKit} makeERecorderKit
Expand Down Expand Up @@ -123,7 +123,7 @@ const prepareVaultDirector = (

const metricsKit = makeERecorderKit(
metricsNode,
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */ (
/** @type {import('@agoric/zoe/src/contractSupport/recorder.js').TypedMatcher<MetricsNotification>} */(
M.any()
),
);
Expand Down
18 changes: 10 additions & 8 deletions packages/inter-protocol/src/vaultFactory/vaultManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const trace = makeTracer('VM');
* collateralUnit: Amount<'nat'>;
* descriptionScope: string;
* startTimeStamp: Timestamp;
* storageNode: StorageNode;
* storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>;
* }>} HeldParams
*/

Expand Down Expand Up @@ -174,7 +174,7 @@ const trace = makeTracer('VM');
* }}
*/
// any b/c will be filled after start()
const collateralEphemera = makeEphemeraProvider(() => /** @type {any} */ ({}));
const collateralEphemera = makeEphemeraProvider(() => /** @type {any} */({}));

/**
* @param {import('@agoric/ertp').Baggage} baggage
Expand All @@ -195,7 +195,9 @@ export const prepareVaultManagerKit = (
const makeVault = prepareVault(baggage, makeRecorderKit, zcf);

/**
* @param {HeldParams & { metricsStorageNode: StorageNode }} params
* @param {HeldParams & {
* metricsStorageNode: Awaited<import('@endo/far').FarRef<StorageNode>>;
* }} params
* @returns {HeldParams & ImmutableState & MutableState}
*/
const initState = params => {
Expand Down Expand Up @@ -699,11 +701,11 @@ export const prepareVaultManagerKit = (
if (plan.transfersToVault.length > 0) {
const transfers = plan.transfersToVault.map(
([vaultIndex, amounts]) =>
/** @type {TransferPart} */ ([
liqSeat,
vaultsInPlan[vaultIndex].getVaultSeat(),
amounts,
]),
/** @type {TransferPart} */([
liqSeat,
vaultsInPlan[vaultIndex].getVaultSeat(),
amounts,
]),
);
atomicRearrange(zcf, harden(transfers));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/psm/gov-replace-committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ harden(invitePSMCommitteeMembers);
* falling back to an inert object with the correct interface (but incomplete
* behavior) when that is unavailable.
*
* @param {ERef<StorageNode>} storageNodeRef
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNodeRef
* @param {string} childName
* @returns {Promise<StorageNode>}
*/
Expand Down
18 changes: 9 additions & 9 deletions packages/internal/src/lib-chainStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const { Fail } = assert;
* @property {(data: string) => Promise<void>} setValue publishes some data
* @property {() => string} getPath the chain storage path at which the node was constructed
* @property {() => Promise<VStorageKey>} getStoreKey DEPRECATED use getPath
* @property {(subPath: string, options?: {sequence?: boolean}) => StorageNode} makeChildNode
* @property {(subPath: string, options?: {sequence?: boolean}) => Awaited<import('@endo/far').FarRef<StorageNode>>} makeChildNode
*/

const ChainStorageNodeI = M.interface('StorageNode', {
Expand Down Expand Up @@ -139,7 +139,7 @@ export const prepareChainStorageNode = zone => {
* so the backing implementation employs a wrapping structure that
* preserves each value set within a single block.
* Child nodes default to inheriting this option from their parent.
* @returns {StorageNode}
* @returns {Awaited<import('@endo/far').FarRef<StorageNode>>}
*/
const makeChainStorageNode = zone.exoClass(
'ChainStorageNode',
Expand Down Expand Up @@ -170,7 +170,7 @@ export const prepareChainStorageNode = zone => {
args: [path],
});
},
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => StorageNode} */
/** @type {(name: string, childNodeOptions?: {sequence?: boolean}) => Awaited<import('@endo/far').FarRef<StorageNode>>} */
makeChildNode(name, childNodeOptions = {}) {
const { sequence, path, messenger } = this.state;
assertPathSegment(name);
Expand Down Expand Up @@ -236,7 +236,7 @@ export function makeChainStorageRoot(
}

/**
* @returns {StorageNode} an object that confirms to StorageNode API but does not store anywhere.
* @returns {Awaited<import('@endo/far').FarRef<StorageNode>>} an object that confirms to StorageNode API but does not store anywhere.
*/
const makeNullStorageNode = () => {
// XXX re-use "ChainStorage" methods above which don't actually depend on chains
Expand All @@ -248,20 +248,20 @@ const makeNullStorageNode = () => {
* falling back to an inert object with the correct interface (but incomplete
* behavior) when that is unavailable.
*
* @param {import('@endo/far').ERef<StorageNode?>} storageNodeRef
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNodeRef
* @param {string} childName
* @returns {Promise<StorageNode>}
* @returns {Awaited<import('@endo/far').FarRef<StorageNode>>}
*/
export async function makeStorageNodeChild(storageNodeRef, childName) {
const existingStorageNode = await storageNodeRef;
export function makeStorageNodeChild(storageNodeRef, childName) {
const existingStorageNode = E(storageNodeRef);
const storageNode = existingStorageNode || makeNullStorageNode();
return E(storageNode).makeChildNode(childName);
}
harden(makeStorageNodeChild);

// TODO find a better module for this
/**
* @param {import('@endo/far').ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {import('@endo/far').ERef<Marshaller>} marshaller
* @returns {(value: unknown) => Promise<void>}
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/notifier/src/stored-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { observeNotifier } from './asyncIterableAdaptor.js';
*
* @template T
* @param {ERef<Notifier<T>>} notifier
* @param {ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {ERef<Marshaller>} marshaller
* @returns {StoredNotifier<T>}
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/notifier/src/storesub.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const forEachPublicationRecord = async (subscriber, consumeValue) => {
*
* @template T
* @param {Subscriber<T>} subscriber
* @param {ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {ERef<ReturnType<typeof makeMarshal>>} marshaller
* @returns {StoredSubscriber<T>}
*/
Expand Down Expand Up @@ -84,15 +84,15 @@ export const makeStoredSubscriber = (subscriber, storageNode, marshaller) => {
*
* @template T
* @param {Subscription<T>} subscription
* @param {ERef<StorageNode>} [storageNode]
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} [storageNode]
* @param {ERef<ReturnType<typeof makeMarshal>>} [marshaller]
* @returns {StoredSubscription<T>}
*/
export const makeStoredSubscription = (
subscription,
storageNode,
marshaller = makeMarshal(undefined, undefined, {
marshalSaveError: () => {},
marshalSaveError: () => { },

Check warning on line 95 in packages/notifier/src/storesub.js

View workflow job for this annotation

GitHub Actions / lint-rest

Delete `·`
serializeBodyFormat: 'smallcaps',
}),
) => {
Expand Down Expand Up @@ -170,7 +170,7 @@ harden(makeStoredSubscription);
* @deprecated incompatible with durability; instead handle vstorage ephemerally on a durable PublishKit
*
* @template [T=unknown]
* @param {ERef<StorageNode>} [storageNode]
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} [storageNode]
* @param {ERef<Marshaller>} [marshaller]
* @param {string} [childPath]
* @returns {StoredPublisherKit<T>}
Expand Down Expand Up @@ -205,7 +205,7 @@ export const makeStoredPublisherKit = (storageNode, marshaller, childPath) => {
* What's different is `subscriber` tees records, writing out to storageNode.
*
* @template [T=unknown]
* @param {ERef<StorageNode>} storageNode
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} storageNode
* @param {ERef<Marshaller>} marshaller
* @returns {StoredPublishKit<T>}
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/notifier/src/types-ambient.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
* @property {(data: string) => Promise<void>} setValue publishes some data (append to the node)
* @property {() => string} getPath the chain storage path at which the node was constructed
* @property {() => Promise<VStorageKey>} getStoreKey DEPRECATED use getPath
* @property {(subPath: string, options?: {sequence?: boolean}) => StorageNode} makeChildNode
* @property {(subPath: string, options?: {sequence?: boolean}) => Awaited<import('@endo/far').FarRef<StorageNode>>} makeChildNode
*/

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/smart-wallet/src/smartWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ const trace = makeTracer('SmrtWlt');
* @typedef {{
* address: string,
* bank: ERef<import('@agoric/vats/src/vat-bank').Bank>,
* currentStorageNode: StorageNode,
* currentStorageNode: Awaited<import('@endo/far').FarRef<StorageNode>>,
* invitationPurse: Purse<'set'>,
* walletStorageNode: StorageNode,
* walletStorageNode: Awaited<import('@endo/far').FarRef<StorageNode>>,
* }} UniqueParams
*
* @typedef {Pick<MapStore<Brand, BrandDescriptor>, 'has' | 'get' | 'values'>} BrandDescriptorRegistry
Expand Down Expand Up @@ -752,7 +752,7 @@ export const prepareSmartWallet = (baggage, shared) => {
);

/**
* @param {Omit<UniqueParams, 'currentStorageNode' | 'walletStorageNode'> & {walletStorageNode: ERef<StorageNode>}} uniqueWithoutChildNodes
* @param {Omit<UniqueParams, 'currentStorageNode' | 'walletStorageNode'> & {walletStorageNode: Awaited<import('@endo/far').FarRef<StorageNode>>}} uniqueWithoutChildNodes
*/
const makeSmartWallet = async uniqueWithoutChildNodes => {
const [walletStorageNode, currentStorageNode] = await Promise.all([
Expand Down
10 changes: 5 additions & 5 deletions packages/smart-wallet/src/walletFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const makeAssetRegistry = assetPublisher => {
/**
* @param {ZCF<SmartWalletContractTerms>} zcf
* @param {{
* storageNode: ERef<StorageNode>,
* storageNode: Awaited<import('@endo/far').FarRef<StorageNode>>,
* walletBridgeManager?: ERef<import('@agoric/vats').ScopedBridgeManager>,
* walletReviver?: ERef<WalletReviver>,
* }} privateArgs
Expand Down Expand Up @@ -192,7 +192,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
const walletP =
!walletsByAddress.has(address) && walletReviver
? // this will call provideSmartWallet which will update `walletsByAddress` for next time
E(walletReviver).reviveWallet(address)
E(walletReviver).reviveWallet(address)
: walletsByAddress.get(address); // or throw
const wallet = await walletP;

Expand Down Expand Up @@ -276,9 +276,9 @@ export const prepare = async (zcf, privateArgs, baggage) => {

const finisher = walletReviver
? async (_address, _wallet) => {
const isRevive = await E(walletReviver).ackWallet(address);
isNew = !isRevive;
}
const isRevive = await E(walletReviver).ackWallet(address);
isNew = !isRevive;
}
: undefined;

return provider
Expand Down
2 changes: 1 addition & 1 deletion packages/smart-wallet/test/start-game1-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const CENT = IST_UNIT / 100n;
/**
* Make a storage node for auxilliary data for a value on the board.
*
* @param {ERef<StorageNode>} chainStorage
* @param {Awaited<import('@endo/far').FarRef<StorageNode>>} chainStorage
* @param {string} boardId
*/
const makeBoardAuxNode = async (chainStorage, boardId) => {
Expand Down
Loading

0 comments on commit 502a38c

Please sign in to comment.