Skip to content

Commit

Permalink
refactor(smart-wallet): re-use MapStore for has/get/values
Browse files Browse the repository at this point in the history
After changing [...values()] to just values(), I went to find
consumers who would now need to construct the array, but it
looks like registry.values() is no longer used.

While looking, I discovered that the return type of
t.context.simpleProvideWallet() defaulted to any.
  • Loading branch information
dckc committed Feb 9, 2023
1 parent 6621acc commit ef986b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
9 changes: 3 additions & 6 deletions packages/smart-wallet/src/smartWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,10 @@ const mapToRecord = map => Object.fromEntries(map.entries());
* walletStorageNode: StorageNode,
* }} UniqueParams
*
* @typedef {Pick<MapStore<Brand, BrandDescriptor>, 'has' | 'get' | 'values'>} ReadOnlyMapStore
* @typedef {{
* agoricNames: ERef<import('@agoric/vats').NameHub>,
* registry: {
* has: (b: Brand) => boolean,
* get: (b: Brand) => BrandDescriptor,
* values: () => BrandDescriptor[],
* },
* registry: ReadOnlyMapStore,
* invitationIssuer: Issuer<'set'>,
* invitationBrand: Brand<'set'>,
* invitationDisplayInfo: DisplayInfo,
Expand Down Expand Up @@ -144,7 +141,7 @@ export const prepareSmartWallet = (baggage, shared) => {
invitationDisplayInfo: DisplayInfoShape,
publicMarshaller: M.remotable('Marshaller'),
zoe: M.eref(M.remotable('ZoeService')),
registry: M.remotable('AssetRegistry'),
registry: M.remotable('AssetRegistry'), // XXX too strict
}),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/smart-wallet/src/walletFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const makeAssetRegistry = assetPublisher => {
has: brand => brandDescriptors.has(brand),
/** @param {Brand} brand */
get: brand => brandDescriptors.get(brand),
values: () => [...brandDescriptors.values()],
values: () => brandDescriptors.values(),
});
return registry;
};
Expand Down
1 change: 1 addition & 0 deletions packages/smart-wallet/test/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const makeDefaultTestContext = async (t, makeSpace) => {
// copied from makeClientBanks()
const bank = E(consume.bankManager).getBankForAddress(address);

/** @type {[ReturnType<ReturnType<import('../src/smartWallet').prepareSmartWallet>>, boolean]} */
const [wallet, _isNew] = await E(
walletFactory.creatorFacet,
).provideSmartWallet(address, bank, consume.namesByAddressAdmin);
Expand Down

0 comments on commit ef986b1

Please sign in to comment.