@agoric/smart-wallet 0.5.4-u15.0 → 0.5.4-u16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,11 @@ import { DEFAULT_PREFIX } from '@agoric/vats/src/lib-board.js';
6
6
 
7
7
  const { Fail, quote: q } = assert;
8
8
 
9
- /** @typedef {import('@agoric/vats/src/lib-board.js').BoardId} BoardId */
9
+ /**
10
+ * @import {PassableCap, RemotableObject} from '@endo/marshal';
11
+ * @import {Key} from '@endo/patterns';
12
+ * @import {BoardId} from '@agoric/vats/src/lib-board.js';
13
+ */
10
14
 
11
15
  /**
12
16
  * ID from a board made with { prefix: DEFAULT_PREFIX }
@@ -19,11 +23,10 @@ const isDefaultBoardId = specimen => {
19
23
  };
20
24
 
21
25
  /**
22
- * When marshaling a purse, payment, etc. we partition the slots
23
- * using prefixes.
26
+ * When marshaling a purse, payment, etc. we partition the slots using prefixes.
24
27
  *
25
- * @template {Record<string, IdTable<*,*>>} T
26
- * @typedef {`${string & keyof T}:${Digits}`} WalletSlot<T>
28
+ * @template {Record<string, IdTable<any, any>>} T
29
+ * @typedef {`${string & keyof T}:${Digits}`} WalletSlot
27
30
  */
28
31
  /**
29
32
  * @template {string} K
@@ -31,7 +34,7 @@ const isDefaultBoardId = specimen => {
31
34
  */
32
35
 
33
36
  /**
34
- * @template {Record<string, IdTable<*,*>>} T
37
+ * @template {Record<string, IdTable<any, any>>} T
35
38
  * @param {T} _tables
36
39
  * @param {string & keyof T} kind
37
40
  * @param {number} id
@@ -43,10 +46,10 @@ const makeWalletSlot = (_tables, kind, id) => {
43
46
  };
44
47
 
45
48
  /**
46
- * @template {Record<string, IdTable<*,*>>} T
49
+ * @template {Record<string, IdTable<any, any>>} T
47
50
  * @param {T} record
48
51
  * @param {(value: string, index: number, obj: string[]) => boolean} predicate
49
- * @returns {string & keyof T | undefined}
52
+ * @returns {(string & keyof T) | undefined}
50
53
  */
51
54
  const findKey = (record, predicate) => {
52
55
  const key = Object.keys(record).find(predicate);
@@ -54,10 +57,10 @@ const findKey = (record, predicate) => {
54
57
  };
55
58
 
56
59
  /**
57
- * @template {Record<string, IdTable<*,*>>} T
60
+ * @template {Record<string, IdTable<any, any>>} T
58
61
  * @param {T} tables
59
62
  * @param {string} slot
60
- * @returns {{ kind: undefined | string & keyof T, id: number }}
63
+ * @returns {{ kind: undefined | (string & keyof T); id: number }}
61
64
  */
62
65
  const parseWalletSlot = (tables, slot) => {
63
66
  const kind = findKey(tables, k => slot.startsWith(`${k}:`));
@@ -66,32 +69,30 @@ const parseWalletSlot = (tables, slot) => {
66
69
  };
67
70
 
68
71
  /**
69
- * Since KindSlots always include a colon and BoardIds never do,
70
- * we an mix them without confusion.
72
+ * Since KindSlots always include a colon and BoardIds never do, we an mix them
73
+ * without confusion.
71
74
  *
72
- * @template {Record<string, IdTable<*,*>>} T
73
- * @typedef {WalletSlot<T> | BoardId} MixedSlot<T>
75
+ * @template {Record<string, IdTable<any, any>>} T
76
+ * @typedef {WalletSlot<T> | BoardId} MixedSlot
74
77
  */
75
78
  /**
76
- * @typedef {`1` | `12` | `123`} Digits - 1 or more digits.
77
- * NOTE: the typescript definition here is more restrictive than
78
- * actual usage.
79
+ * @typedef {`1` | `12` | `123`} Digits - 1 or more digits. NOTE: the typescript
80
+ * definition here is more restrictive than actual usage.
79
81
  */
80
82
 
81
83
  /**
82
- * @template Slot
83
- * @template Val
84
- *
84
+ * @template {Key} Slot
85
+ * @template {PassableCap} Val
85
86
  * @typedef {{
86
- * bySlot: MapStore<Slot, Val>,
87
- * byVal: MapStore<Val, Slot>,
87
+ * bySlot: MapStore<Slot, Val>;
88
+ * byVal: MapStore<Val, Slot>;
88
89
  * }} IdTable<Value>
89
90
  */
90
91
 
91
92
  /**
92
- * @template Slot
93
- * @template Val
94
- * @param {IdTable<Slot, Val>} table
93
+ * @template {Key} Slot
94
+ * @template {PassableCap} Val
95
+ * @param {IdTable<Slot, PassableCap>} table
95
96
  * @param {Slot} slot
96
97
  * @param {Val} val
97
98
  */
@@ -101,17 +102,20 @@ const initSlotVal = (table, slot, val) => {
101
102
  };
102
103
 
103
104
  /**
104
- * Make context for exporting wallet data where brands etc. can be recognized by boardId.
105
- * Export for use outside the smart wallet.
105
+ * Make context for exporting wallet data where brands etc. can be recognized by
106
+ * boardId. Export for use outside the smart wallet.
106
107
  *
107
108
  * When serializing wallet state for, there's a tension between
108
109
  *
109
- * - keeping purses etc. closely held
110
- * - recognizing identity of brands also referenced in the state of contracts such as the AMM
110
+ * - keeping purses etc. closely held
111
+ * - recognizing identity of brands also referenced in the state of contracts such
112
+ * as the AMM
111
113
  *
112
- * `makeMarshal()` is parameterized by the type of slots. Here we use a disjoint union of
113
- * - board ids for widely shared objects
114
- * - kind:seq ids for closely held objects; for example purse:123
114
+ * `makeMarshal()` is parameterized by the type of slots. Here we use a disjoint
115
+ * union of
116
+ *
117
+ * - board ids for widely shared objects
118
+ * - kind:seq ids for closely held objects; for example purse:123
115
119
  */
116
120
  export const makeExportContext = () => {
117
121
  const walletObjects = {
@@ -126,27 +130,26 @@ export const makeExportContext = () => {
126
130
  byVal: makeScalarMapStore(),
127
131
  },
128
132
  // TODO: offer, contact, dapp
129
- /** @type {IdTable<number, unknown>} */
133
+ /** @type {IdTable<number, PassableCap>} */
130
134
  unknown: {
131
135
  bySlot: makeScalarMapStore(),
132
136
  byVal: makeScalarMapStore(),
133
137
  },
134
138
  };
135
- /** @type {IdTable<BoardId, unknown>} */
139
+ /** @type {IdTable<BoardId, PassableCap>} */
136
140
  const boardObjects = {
137
141
  bySlot: makeScalarMapStore(),
138
142
  byVal: makeScalarMapStore(),
139
143
  };
140
144
 
141
145
  /**
142
- * Look up the slot in mappings from published data
143
- * else try walletObjects that we have seen.
144
- *
145
- * @throws if not found (a slotToVal function typically
146
- * conjures a new identity)
146
+ * Look up the slot in mappings from published data else try walletObjects
147
+ * that we have seen.
147
148
  *
148
149
  * @param {MixedSlot<typeof walletObjects>} slot
149
150
  * @param {string} _iface
151
+ * @throws if not found (a slotToVal function typically conjures a new
152
+ * identity)
150
153
  */
151
154
  const slotToVal = (slot, _iface) => {
152
155
  if (isDefaultBoardId(slot) && boardObjects.bySlot.has(slot)) {
@@ -161,7 +164,7 @@ export const makeExportContext = () => {
161
164
  let unknownNonce = 0;
162
165
 
163
166
  /**
164
- * @param {unknown} val
167
+ * @param {PassableCap} val
165
168
  * @returns {MixedSlot<typeof walletObjects>}
166
169
  */
167
170
  const valToSlot = val => {
@@ -181,7 +184,7 @@ export const makeExportContext = () => {
181
184
  };
182
185
 
183
186
  /**
184
- * @template V
187
+ * @template {PassableCap} V
185
188
  * @param {string & keyof typeof walletObjects} kind
186
189
  * @param {IdTable<number, V>} table
187
190
  */
@@ -208,14 +211,14 @@ export const makeExportContext = () => {
208
211
  purseEntries: walletObjects.purse.bySlot.entries,
209
212
  /**
210
213
  * @param {BoardId} id
211
- * @param {unknown} val
214
+ * @param {RemotableObject} val
212
215
  */
213
216
  initBoardId: (id, val) => {
214
217
  initSlotVal(boardObjects, id, val);
215
218
  },
216
219
  /**
217
220
  * @param {BoardId} id
218
- * @param {unknown} val
221
+ * @param {RemotableObject} val
219
222
  */
220
223
  ensureBoardId: (id, val) => {
221
224
  if (boardObjects.byVal.has(val)) {
@@ -235,38 +238,38 @@ const defaultMakePresence = iface => {
235
238
  };
236
239
 
237
240
  /**
238
- * Make context for marshalling wallet or board data.
239
- * To be imported into the client, which never exports objects.
241
+ * Make context for marshalling wallet or board data. To be imported into the
242
+ * client, which never exports objects.
240
243
  *
241
- * @param {(iface: string) => unknown} [makePresence]
244
+ * @param {(iface: string) => PassableCap} [makePresence]
242
245
  */
243
246
  export const makeImportContext = (makePresence = defaultMakePresence) => {
244
247
  const walletObjects = {
245
- /** @type {IdTable<number, unknown>} */
248
+ /** @type {IdTable<number, PassableCap>} */
246
249
  purse: {
247
250
  bySlot: makeScalarMapStore(),
248
251
  byVal: makeScalarMapStore(),
249
252
  },
250
- /** @type {IdTable<number, unknown>} */
253
+ /** @type {IdTable<number, PassableCap>} */
251
254
  payment: {
252
255
  bySlot: makeScalarMapStore(),
253
256
  byVal: makeScalarMapStore(),
254
257
  },
255
- /** @type {IdTable<number, unknown>} */
258
+ /** @type {IdTable<number, PassableCap>} */
256
259
  unknown: {
257
260
  bySlot: makeScalarMapStore(),
258
261
  byVal: makeScalarMapStore(),
259
262
  },
260
263
  };
261
- /** @type {IdTable<BoardId, unknown>} */
264
+ /** @type {IdTable<BoardId, PassableCap>} */
262
265
  const boardObjects = {
263
266
  bySlot: makeScalarMapStore(),
264
267
  byVal: makeScalarMapStore(),
265
268
  };
266
269
 
267
270
  /**
268
- * @template Slot
269
- * @template Val
271
+ * @template {Key} Slot
272
+ * @template {PassableCap} Val
270
273
  * @param {IdTable<Slot, Val>} table
271
274
  * @param {Slot} slot
272
275
  * @param {string} iface
@@ -308,7 +311,7 @@ export const makeImportContext = (makePresence = defaultMakePresence) => {
308
311
 
309
312
  const valToSlot = {
310
313
  fromBoard: val => boardObjects.byVal.get(val),
311
- /** @param {unknown} val */
314
+ /** @param {PassableCap} val */
312
315
  fromMyWallet: val => {
313
316
  const kind = findKey(walletObjects, k => walletObjects[k].byVal.has(val));
314
317
  if (kind === undefined) {
@@ -334,14 +337,14 @@ export const makeImportContext = (makePresence = defaultMakePresence) => {
334
337
  return harden({
335
338
  /**
336
339
  * @param {BoardId} id
337
- * @param {unknown} val
340
+ * @param {PassableCap} val
338
341
  */
339
342
  initBoardId: (id, val) => {
340
343
  initSlotVal(boardObjects, id, val);
341
344
  },
342
345
  /**
343
346
  * @param {BoardId} id
344
- * @param {unknown} val
347
+ * @param {PassableCap} val
345
348
  */
346
349
  ensureBoardId: (id, val) => {
347
350
  if (boardObjects.byVal.has(val)) {
@@ -359,13 +362,17 @@ export const makeImportContext = (makePresence = defaultMakePresence) => {
359
362
  /**
360
363
  * @param {string} iface
361
364
  * @param {{
362
- * applyMethod: (target: unknown, method: string | symbol, args: unknown[]) => void,
363
- * applyFunction: (target: unknown, args: unknown[]) => void,
365
+ * applyMethod: (
366
+ * target: unknown,
367
+ * method: string | symbol,
368
+ * args: unknown[],
369
+ * ) => void;
370
+ * applyFunction: (target: unknown, args: unknown[]) => void;
364
371
  * }} handler
365
372
  */
366
373
  const makePresence = (iface, handler) => {
367
374
  let obj;
368
- // eslint-disable-next-line no-new
375
+
369
376
  void new HandledPromise((resolve, reject, resolveWithPresence) => {
370
377
  obj = resolveWithPresence(handler);
371
378
  });
@@ -1,66 +1,48 @@
1
1
  export function watchOfferOutcomes(watchers: OutcomeWatchers, seat: UserSeat): Promise<[unknown, 0 | 1, PaymentPKeywordRecord]>;
2
- export function prepareOfferWatcher(baggage: MapStore<string, unknown>): (walletHelper: any, deposit: any, offerSpec: import("./offers.js").OfferSpec, address: string, invitationAmount: Amount<"set">, seatRef: UserSeat<unknown>) => {
2
+ export function prepareOfferWatcher(baggage: import("@agoric/vat-data").Baggage): (walletHelper: any, deposit: any, offerSpec: OfferSpec, address: string, invitationAmount: import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key>, seatRef: UserSeat<unknown>) => import("@endo/exo").GuardedKit<{
3
3
  helper: {
4
4
  /**
5
5
  * @param {Record<string, unknown>} offerStatusUpdates
6
6
  */
7
7
  updateStatus(offerStatusUpdates: Record<string, unknown>): void;
8
- onNewContinuingOffer(offerId: any, invitationAmount: any, invitationMakers: any, publicSubscribers: any): void;
9
- publishResult(result: any): void;
10
8
  /**
11
- * Called when the offer result promise rejects. The other two watchers
12
- * are waiting for particular values out of Zoe but they settle at the same time
13
- * and don't need their own error handling.
14
- * @param {Error} err
15
- */
16
- handleError(err: Error): void;
17
- };
18
- /** @type {OutcomeWatchers['paymentWatcher']} */
19
- paymentWatcher: OutcomeWatchers['paymentWatcher'];
20
- /** @type {OutcomeWatchers['resultWatcher']} */
21
- resultWatcher: OutcomeWatchers['resultWatcher'];
22
- /** @type {OutcomeWatchers['numWantsWatcher']} */
23
- numWantsWatcher: OutcomeWatchers['numWantsWatcher'];
24
- } & import("@endo/eventual-send").RemotableBrand<{}, {
25
- helper: {
26
- /**
27
- * @param {Record<string, unknown>} offerStatusUpdates
9
+ * @param {string} offerId
10
+ * @param {Amount<'set'>} invitationAmount
11
+ * @param {import('./types.js').InvitationMakers} invitationMakers
12
+ * @param {import('./types.js').PublicSubscribers} publicSubscribers
28
13
  */
29
- updateStatus(offerStatusUpdates: Record<string, unknown>): void;
30
- onNewContinuingOffer(offerId: any, invitationAmount: any, invitationMakers: any, publicSubscribers: any): void;
31
- publishResult(result: any): void;
14
+ onNewContinuingOffer(offerId: string, invitationAmount: Amount<"set">, invitationMakers: import("./types.js").InvitationMakers, publicSubscribers: import("./types.js").PublicSubscribers): void;
15
+ /** @param {Passable | ContinuingOfferResult} result */
16
+ publishResult(result: Passable | ContinuingOfferResult): void;
32
17
  /**
33
18
  * Called when the offer result promise rejects. The other two watchers
34
- * are waiting for particular values out of Zoe but they settle at the same time
35
- * and don't need their own error handling.
19
+ * are waiting for particular values out of Zoe but they settle at the
20
+ * same time and don't need their own error handling.
21
+ *
36
22
  * @param {Error} err
37
23
  */
38
24
  handleError(err: Error): void;
39
25
  };
40
26
  /** @type {OutcomeWatchers['paymentWatcher']} */
41
- paymentWatcher: OutcomeWatchers['paymentWatcher'];
27
+ paymentWatcher: OutcomeWatchers["paymentWatcher"];
42
28
  /** @type {OutcomeWatchers['resultWatcher']} */
43
- resultWatcher: OutcomeWatchers['resultWatcher'];
29
+ resultWatcher: OutcomeWatchers["resultWatcher"];
44
30
  /** @type {OutcomeWatchers['numWantsWatcher']} */
45
- numWantsWatcher: OutcomeWatchers['numWantsWatcher'];
31
+ numWantsWatcher: OutcomeWatchers["numWantsWatcher"];
46
32
  }>;
47
- export type OfferStatus = import('./offers.js').OfferSpec & {
48
- error?: string;
49
- numWantsSatisfied?: number;
50
- result?: unknown | typeof import('./offers.js').UNPUBLISHED_RESULT;
51
- payouts?: AmountKeywordRecord;
52
- };
53
33
  /**
54
34
  * <T, [UserSeat]
55
35
  */
56
- export type OfferPromiseWatcher<T extends unknown> = {
57
- onFulfilled: (any: any) => any;
58
- onRejected: (err: Error, seat: any) => void;
59
- };
36
+ export type OfferPromiseWatcher<T extends unknown> = PromiseWatcher<T, [UserSeat]>;
60
37
  export type OutcomeWatchers = {
61
- resultWatcher: OfferPromiseWatcher<unknown>;
38
+ resultWatcher: OfferPromiseWatcher<Passable>;
62
39
  numWantsWatcher: OfferPromiseWatcher<number>;
63
40
  paymentWatcher: OfferPromiseWatcher<PaymentPKeywordRecord>;
64
41
  };
65
42
  export type MakeOfferWatcher = ReturnType<typeof prepareOfferWatcher>;
43
+ export type OfferWatcher = ReturnType<MakeOfferWatcher>;
44
+ import type { OfferSpec } from "./offers.js";
45
+ import type { Passable } from '@endo/pass-style';
46
+ import type { ContinuingOfferResult } from "./types.js";
47
+ import type { PromiseWatcher } from '@agoric/swingset-liveslots';
66
48
  //# sourceMappingURL=offerWatcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"offerWatcher.d.ts","sourceRoot":"","sources":["offerWatcher.js"],"names":[],"mappings":"AAyEO,6CAHI,eAAe,QACf,QAAQ,oDAQlB;AAkCM;;QAwBC;;WAEG;yCADQ,OAAO,MAAM,EAAE,OAAO,CAAC;;;QAyDlC;;;;;WAKG;yBADQ,KAAK;;IAclB,gDAAgD;oBAArC,eAAe,CAAC,gBAAgB,CAAC;IA6B5C,+CAA+C;mBAApC,eAAe,CAAC,eAAe,CAAC;IAsB3C,iDAAiD;qBAAtC,eAAe,CAAC,iBAAiB,CAAC;;;QA/H3C;;WAEG;yCADQ,OAAO,MAAM,EAAE,OAAO,CAAC;;;QAyDlC;;;;;WAKG;yBADQ,KAAK;;IAclB,gDAAgD;oBAArC,eAAe,CAAC,gBAAgB,CAAC;IA6B5C,+CAA+C;mBAApC,eAAe,CAAC,eAAe,CAAC;IAsB3C,iDAAiD;qBAAtC,eAAe,CAAC,iBAAiB,CAAC;GA0BlD;0BAnRY,OAAO,aAAa,EAAE,SAAS,GAAG;IAC9C,KAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,MAAU,CAAC,EAAE,OAAO,GAAG,cAAc,aAAa,EAAE,kBAAkB,CAAC;IACvE,OAAW,CAAC,EAAE,mBAAmB,CAAC;CAC/B;;;;;+BAKiC,GAAG;sBAAoB,KAAK,QAAQ,GAAG,KAAK,IAAI;;8BAIxE;IACZ,aAAe,EAAE,oBAAoB,OAAO,CAAC,CAAC;IAC9C,eAAiB,EAAE,oBAAoB,MAAM,CAAC,CAAC;IAC/C,cAAgB,EAAE,oBAAoB,qBAAqB,CAAC,CAAC;CAC1D;+BAoQU,WAAW,0BAA0B,CAAC"}
1
+ {"version":3,"file":"offerWatcher.d.ts","sourceRoot":"","sources":["offerWatcher.js"],"names":[],"mappings":"AAoEO,6CAHI,eAAe,QACf,QAAQ,oDAQlB;AAkCM,6CAFI,OAAO,kBAAkB,EAAE,OAAO,iNAyHnC,WAAS;;QAhGX;;WAEG;yCADQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;QAQlC;;;;;WAKG;sCAJQ,MAAM,oBACN,MAAM,CAAC,KAAK,CAAC,oBACb,OAAO,YAAY,EAAE,gBAAgB,qBACrC,OAAO,YAAY,EAAE,iBAAiB;QAkBjD,uDAAuD;8BAA3C,QAAQ,GAAG,qBAAqB;QAoC5C;;;;;;WAMG;yBADQ,KAAK;;IAclB,gDAAgD;oBAArC,eAAe,CAAC,gBAAgB,CAAC;IA+B5C,+CAA+C;mBAApC,eAAe,CAAC,eAAe,CAAC;IAwB3C,iDAAiD;qBAAtC,eAAe,CAAC,iBAAiB,CAAC;GA2BlD;;;;gCArRkB,CAAC,oBACP,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;8BAI7B;IACZ,aAAiB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACjD,eAAmB,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACjD,cAAkB,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;CAC5D;+BA+QU,UAAU,CAAC,OAAO,mBAAmB,CAAC;2BACtC,UAAU,CAAC,gBAAgB,CAAC;+BAhSd,aAAa;8BAEd,kBAAkB;2CADL,YAAY;oCAEnB,4BAA4B"}
@@ -13,24 +13,22 @@ import { deeplyFulfilledObject, objectMap } from '@agoric/internal';
13
13
  import { UNPUBLISHED_RESULT } from './offers.js';
14
14
 
15
15
  /**
16
- * @typedef {import('./offers.js').OfferSpec & {
17
- * error?: string,
18
- * numWantsSatisfied?: number
19
- * result?: unknown | typeof import('./offers.js').UNPUBLISHED_RESULT,
20
- * payouts?: AmountKeywordRecord,
21
- * }} OfferStatus
16
+ * @import {OfferSpec} from "./offers.js";
17
+ * @import {ContinuingOfferResult} from "./types.js";
18
+ * @import {Passable} from '@endo/pass-style';
19
+ * @import {PromiseWatcher} from '@agoric/swingset-liveslots';
22
20
  */
23
21
 
24
22
  /**
25
23
  * @template {any} T
26
- * @typedef {{ onFulfilled: (any) => any, onRejected: (err: Error, seat: any) => void }} OfferPromiseWatcher<T, [UserSeat]
24
+ * @typedef {PromiseWatcher<T, [UserSeat]>} OfferPromiseWatcher<T, [UserSeat]
27
25
  */
28
26
 
29
27
  /**
30
28
  * @typedef {{
31
- * resultWatcher: OfferPromiseWatcher<unknown>,
32
- * numWantsWatcher: OfferPromiseWatcher<number>,
33
- * paymentWatcher: OfferPromiseWatcher<PaymentPKeywordRecord>,
29
+ * resultWatcher: OfferPromiseWatcher<Passable>;
30
+ * numWantsWatcher: OfferPromiseWatcher<number>;
31
+ * paymentWatcher: OfferPromiseWatcher<PaymentPKeywordRecord>;
34
32
  * }} OutcomeWatchers
35
33
  */
36
34
 
@@ -40,7 +38,6 @@ import { UNPUBLISHED_RESULT } from './offers.js';
40
38
  */
41
39
  const watchForOfferResult = ({ resultWatcher }, seat) => {
42
40
  const p = E(seat).getOfferResult();
43
- // @ts-expect-error missing declarations?
44
41
  watchPromise(p, resultWatcher, seat);
45
42
  return p;
46
43
  };
@@ -51,7 +48,6 @@ const watchForOfferResult = ({ resultWatcher }, seat) => {
51
48
  */
52
49
  const watchForNumWants = ({ numWantsWatcher }, seat) => {
53
50
  const p = E(seat).numWantsSatisfied();
54
- // @ts-expect-error missing declarations?
55
51
  watchPromise(p, numWantsWatcher, seat);
56
52
  return p;
57
53
  };
@@ -62,7 +58,6 @@ const watchForNumWants = ({ numWantsWatcher }, seat) => {
62
58
  */
63
59
  const watchForPayout = ({ paymentWatcher }, seat) => {
64
60
  const p = E(seat).getPayouts();
65
- // @ts-expect-error missing declarations?
66
61
  watchPromise(p, paymentWatcher, seat);
67
62
  return p;
68
63
  };
@@ -117,10 +112,9 @@ export const prepareOfferWatcher = baggage => {
117
112
  'OfferWatcher',
118
113
  offerWatcherGuard,
119
114
  /**
120
- *
121
- * @param {*} walletHelper
122
- * @param {*} deposit
123
- * @param {import('./offers.js').OfferSpec} offerSpec
115
+ * @param {any} walletHelper
116
+ * @param {any} deposit
117
+ * @param {OfferSpec} offerSpec
124
118
  * @param {string} address
125
119
  * @param {Amount<'set'>} invitationAmount
126
120
  * @param {UserSeat} seatRef
@@ -144,6 +138,12 @@ export const prepareOfferWatcher = baggage => {
144
138
 
145
139
  state.walletHelper.updateStatus(state.status);
146
140
  },
141
+ /**
142
+ * @param {string} offerId
143
+ * @param {Amount<'set'>} invitationAmount
144
+ * @param {import('./types.js').InvitationMakers} invitationMakers
145
+ * @param {import('./types.js').PublicSubscribers} publicSubscribers
146
+ */
147
147
  onNewContinuingOffer(
148
148
  offerId,
149
149
  invitationAmount,
@@ -160,6 +160,7 @@ export const prepareOfferWatcher = baggage => {
160
160
  );
161
161
  },
162
162
 
163
+ /** @param {Passable | ContinuingOfferResult} result */
163
164
  publishResult(result) {
164
165
  const { state, facets } = this;
165
166
 
@@ -176,12 +177,14 @@ export const prepareOfferWatcher = baggage => {
176
177
  facets.helper.updateStatus({ result });
177
178
  break;
178
179
  case 'copyRecord':
180
+ // @ts-expect-error narrowed by passStyle
179
181
  if ('invitationMakers' in result) {
180
182
  // save for continuing invitation offer
181
183
 
182
184
  void facets.helper.onNewContinuingOffer(
183
185
  String(state.status.id),
184
186
  state.invitationAmount,
187
+ // @ts-expect-error narrowed by passStyle
185
188
  result.invitationMakers,
186
189
  result.publicSubscribers,
187
190
  );
@@ -195,8 +198,9 @@ export const prepareOfferWatcher = baggage => {
195
198
  },
196
199
  /**
197
200
  * Called when the offer result promise rejects. The other two watchers
198
- * are waiting for particular values out of Zoe but they settle at the same time
199
- * and don't need their own error handling.
201
+ * are waiting for particular values out of Zoe but they settle at the
202
+ * same time and don't need their own error handling.
203
+ *
200
204
  * @param {Error} err
201
205
  */
202
206
  handleError(err) {
@@ -225,9 +229,11 @@ export const prepareOfferWatcher = baggage => {
225
229
  facets.helper.updateStatus({ payouts: amounts });
226
230
  },
227
231
  /**
228
- * If promise disconnected, watch again. Or if there's an Error, handle it.
232
+ * If promise disconnected, watch again. Or if there's an Error, handle
233
+ * it.
229
234
  *
230
- * @param {Error | import('@agoric/internal/src/upgrade-api.js').DisconnectionObject} reason
235
+ * @param {Error
236
+ * | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
231
237
  * @param {UserSeat} seat
232
238
  */
233
239
  onRejected(reason, seat) {
@@ -247,9 +253,11 @@ export const prepareOfferWatcher = baggage => {
247
253
  facets.helper.publishResult(result);
248
254
  },
249
255
  /**
250
- * If promise disconnected, watch again. Or if there's an Error, handle it.
256
+ * If promise disconnected, watch again. Or if there's an Error, handle
257
+ * it.
251
258
  *
252
- * @param {Error | import('@agoric/internal/src/upgrade-api.js').DisconnectionObject} reason
259
+ * @param {Error
260
+ * | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
253
261
  * @param {UserSeat} seat
254
262
  */
255
263
  onRejected(reason, seat) {
@@ -276,7 +284,8 @@ export const prepareOfferWatcher = baggage => {
276
284
  * and getPayouts() settle the same (they await the same promise and
277
285
  * then synchronously return a local value).
278
286
  *
279
- * @param {Error | import('@agoric/internal/src/upgrade-api.js').DisconnectionObject} reason
287
+ * @param {Error
288
+ * | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
280
289
  * @param {UserSeat} seat
281
290
  */
282
291
  onRejected(reason, seat) {
@@ -292,3 +301,4 @@ export const prepareOfferWatcher = baggage => {
292
301
  harden(prepareOfferWatcher);
293
302
 
294
303
  /** @typedef {ReturnType<typeof prepareOfferWatcher>} MakeOfferWatcher */
304
+ /** @typedef {ReturnType<MakeOfferWatcher>} OfferWatcher */
package/src/offers.d.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  */
4
4
  /**
5
5
  * @typedef {{
6
- * id: OfferId,
7
- * invitationSpec: import('./invitations').InvitationSpec,
8
- * proposal: Proposal,
9
- * offerArgs?: unknown
6
+ * id: OfferId;
7
+ * invitationSpec: import('./invitations.js').InvitationSpec;
8
+ * proposal: Proposal;
9
+ * offerArgs?: any;
10
10
  * }} OfferSpec
11
11
  */
12
12
  /** Value for "result" field when the result can't be published */
@@ -14,11 +14,11 @@ export const UNPUBLISHED_RESULT: "UNPUBLISHED";
14
14
  export type OfferId = number | string;
15
15
  export type OfferSpec = {
16
16
  id: OfferId;
17
- invitationSpec: import('./invitations').InvitationSpec;
17
+ invitationSpec: import("./invitations.js").InvitationSpec;
18
18
  proposal: Proposal;
19
- offerArgs?: unknown;
19
+ offerArgs?: any;
20
20
  };
21
- export type OfferStatus = import('./offers.js').OfferSpec & {
21
+ export type OfferStatus = OfferSpec & {
22
22
  error?: string;
23
23
  numWantsSatisfied?: number;
24
24
  result?: unknown | typeof UNPUBLISHED_RESULT;
@@ -1 +1 @@
1
- {"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["offers.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AAEH,kEAAkE;AAClE,+CAAgD;sBAbnC,MAAM,GAAG,MAAM;wBAIf;IACZ,EAAM,EAAE,OAAO,CAAC;IAChB,cAAkB,EAAE,OAAO,eAAe,EAAE,cAAc,CAAC;IAC3D,QAAY,EAAE,QAAQ,CAAC;IACvB,SAAa,CAAC,EAAE,OAAO,CAAA;CACpB;0BAOS,OAAO,aAAa,EAAE,SAAS,GAAG;IAC9C,KAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,MAAQ,CAAC,EAAE,OAAO,GAAG,yBAAyB,CAAC;IAC/C,OAAS,CAAC,EAAE,mBAAmB,CAAC;CAC7B"}
1
+ {"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["offers.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AAEH,kEAAkE;AAClE,+CAAgD;sBAbnC,MAAM,GAAG,MAAM;wBAIf;IACZ,EAAM,EAAE,OAAO,CAAC;IAChB,cAAkB,EAAE,OAAO,kBAAkB,EAAE,cAAc,CAAC;IAC9D,QAAY,EAAE,QAAQ,CAAC;IACvB,SAAa,CAAC,EAAE,GAAG,CAAC;CACjB;0BAOS,SAAS,GAAG;IACxB,KAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAU,CAAC,EAAE,OAAO,GAAG,OAAO,kBAAkB,CAAC;IACjD,OAAW,CAAC,EAAE,mBAAmB,CAAC;CAC/B"}
package/src/offers.js CHANGED
@@ -4,10 +4,10 @@
4
4
 
5
5
  /**
6
6
  * @typedef {{
7
- * id: OfferId,
8
- * invitationSpec: import('./invitations').InvitationSpec,
9
- * proposal: Proposal,
10
- * offerArgs?: unknown
7
+ * id: OfferId;
8
+ * invitationSpec: import('./invitations.js').InvitationSpec;
9
+ * proposal: Proposal;
10
+ * offerArgs?: any;
11
11
  * }} OfferSpec
12
12
  */
13
13
 
@@ -15,10 +15,10 @@
15
15
  export const UNPUBLISHED_RESULT = 'UNPUBLISHED';
16
16
 
17
17
  /**
18
- * @typedef {import('./offers.js').OfferSpec & {
19
- * error?: string,
20
- * numWantsSatisfied?: number
21
- * result?: unknown | typeof UNPUBLISHED_RESULT,
22
- * payouts?: AmountKeywordRecord,
18
+ * @typedef {OfferSpec & {
19
+ * error?: string;
20
+ * numWantsSatisfied?: number;
21
+ * result?: unknown | typeof UNPUBLISHED_RESULT;
22
+ * payouts?: AmountKeywordRecord;
23
23
  * }} OfferStatus
24
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-wallet-factory2-proposal.d.ts","sourceRoot":"","sources":["upgrade-wallet-factory2-proposal.js"],"names":[],"mappings":"AASO,qKAJI,eAAe,GAAG,mBAAmB;;mBAExB,YAAY;;kBAqCnC;AAEM;;;;;;;;;;;;;;;;EAYL"}
1
+ {"version":3,"file":"upgrade-wallet-factory2-proposal.d.ts","sourceRoot":"","sources":["upgrade-wallet-factory2-proposal.js"],"names":[],"mappings":"AAWO,qKAJI,eAAe,GAAG,mBAAmB,WAE7C;IAA6C,OAAO,EAA5C;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE;CACrC,iBAmCA;AAEM;;;;;;;;;;;;;;;;EAYL"}
@@ -1,4 +1,6 @@
1
1
  // @ts-check
2
+ /// <reference types="@agoric/vats/src/core/types-ambient" />
3
+
2
4
  import { E } from '@endo/far';
3
5
  import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
4
6
 
@@ -27,7 +29,6 @@ export const upgradeWalletFactory = async (
27
29
  makeStorageNodeChild(chainStorage, WALLET_STORAGE_PATH_SEGMENT),
28
30
  provisionPoolStartResult,
29
31
  ]);
30
- // @ts-expect-error missing type declaration?
31
32
  const walletReviver = await E(ppFacets.creatorFacet).getWalletReviver();
32
33
 
33
34
  const privateArgs = {
@@ -1,4 +1,4 @@
1
- export function upgradeWalletFactory({ consume: { contractKits: kitsP, instancePrivateArgs: argsP }, instance: { consume: { walletFactory: wfInstanceP }, }, }: BootstrapPowers, config: {
1
+ export function upgradeWalletFactory({ consume: { contractKits, governedContractKits, chainStorage, walletBridgeManager: walletBridgeManagerP, }, instance: { consume: { walletFactory: wfInstanceP, provisionPool: ppInstanceP }, }, }: BootstrapPowers, config: {
2
2
  options: {
3
3
  walletFactoryRef: VatSourceRef & {
4
4
  bundleID: string;
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-walletFactory-proposal.d.ts","sourceRoot":"","sources":["upgrade-walletFactory-proposal.js"],"names":[],"mappings":"AAoBO,gKALK,eAAe;;0BAGI,YAAY,GAAG;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE;;kBA6BjE;AAMM,mGAFK,eAAe,iBAwB1B;AAsBM;;;;;;;EAKN"}
1
+ {"version":3,"file":"upgrade-walletFactory-proposal.d.ts","sourceRoot":"","sources":["upgrade-walletFactory-proposal.js"],"names":[],"mappings":"AAoBO,yOAJI,eAAe,UAEvB;IAA0E,OAAO,EAAzE;QAAE,gBAAgB,EAAE,YAAY,GAAG;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;CACnE,iBAiDA;AAMM,mGAFI,eAAe,iBAwBzB;AAyBM;;;;;;;EAKN"}