Skip to content

Commit

Permalink
fix(types): board values
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed May 7, 2024
1 parent 09c12d6 commit 23e8302
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/smart-wallet/src/marshal-contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DEFAULT_PREFIX } from '@agoric/vats/src/lib-board.js';
const { Fail, quote: q } = assert;

/**
* @import {PassableCap} from '@endo/marshal';
* @import {PassableCap, RemotableObject} from '@endo/marshal';
* @import {Key} from '@endo/patterns';
* @import {BoardId} from '@agoric/vats/src/lib-board.js';
*/
Expand Down Expand Up @@ -212,14 +212,14 @@ export const makeExportContext = () => {
purseEntries: walletObjects.purse.bySlot.entries,
/**
* @param {BoardId} id
* @param {PassableCap} val
* @param {RemotableObject} val
*/
initBoardId: (id, val) => {
initSlotVal(boardObjects, id, val);
},
/**
* @param {BoardId} id
* @param {PassableCap} val
* @param {RemotableObject} val
*/
ensureBoardId: (id, val) => {
if (boardObjects.byVal.has(val)) {
Expand Down
1 change: 0 additions & 1 deletion packages/smart-wallet/test/test-marshal-contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const makeOnChainWallet = board => {
getCurrentAmount: () => harden({ brand, value: 100 }),
});
// only for private brands
// context.initBrandId(boardId, brand);
context.initBoardId(boardId, brand);
// @ts-expect-error mock purse
context.initPurseId(name, purse); // TODO: strong id rather than name?
Expand Down
16 changes: 8 additions & 8 deletions packages/vats/src/lib-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { makeMarshal } from '@endo/marshal';
import { crc6 } from './crc.js';

/**
* @import {PassableCap} from '@endo/marshal';
* @import {Key} from '@endo/patterns';
* @import {PassableCap, RemotableObject} from '@endo/marshal';
* @import {ScalarKey} from '@endo/patterns';
*/

export const DEFAULT_CRC_DIGITS = 2;
Expand Down Expand Up @@ -102,13 +102,13 @@ const initDurableBoardState = (
const immutable = { prefix, crcDigits };

const lastSequence = BigInt(initSequence);
/** @type {MapStore<BoardId, PassableCap>} */
/** @type {MapStore<BoardId, RemotableObject>} */
const idToVal = makeScalarBigMapStore('idToVal', {
durable: true,
keyShape: IdShape,
valueShape: ValShape,
});
/** @type {MapStore<PassableCap, BoardId>} */
/** @type {MapStore<RemotableObject, BoardId>} */
const valToId = makeScalarBigMapStore('valToId', {
durable: true,
keyShape: ValShape,
Expand All @@ -130,7 +130,7 @@ const initDurableBoardState = (
// transient marshallers that get GCed when the function completes.

/**
* @param {PassableCap} value
* @param {RemotableObject} value
* @param {BoardState} state
*/
const getId = (value, state) => {
Expand Down Expand Up @@ -267,8 +267,8 @@ export const prepareBoardKit = baggage => {
* `value` for its entire lifetime. For a well-known board, this is
* essentially forever.
*
* @param {PassableCap} value
* @throws if `value` is not a Key in the @agoric/store sense
* @param {RemotableObject} value
* @throws if `value` is not a ScalarKey in the @agoric/store sense
*/
getId(value) {
return getId(value, this.state);
Expand Down Expand Up @@ -305,7 +305,7 @@ export const prepareBoardKit = baggage => {
}
return E(firstValue).lookup(...rest);
},
/** @param {PassableCap} val */
/** @param {RemotableObject} val */
has(val) {
const { state } = this;
return state.valToId.has(val);
Expand Down

0 comments on commit 23e8302

Please sign in to comment.