@agoric/smart-wallet 0.5.4-upgrade-16-fi-dev-8879538.0 → 0.5.4-upgrade-16-dev-f908f89.0

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.
@@ -3,9 +3,11 @@ export function prepareSmartWallet(baggage: import("@agoric/vat-data").Baggage,
3
3
  walletStorageNode: ERef<StorageNode>;
4
4
  }) => Promise<import("@endo/exo").Guarded<{
5
5
  /**
6
- * Umarshals the actionCapData and delegates to the appropriate action handler.
6
+ * Umarshals the actionCapData and delegates to the appropriate action
7
+ * handler.
7
8
  *
8
- * @param {import('@endo/marshal').CapData<string | null>} actionCapData of type BridgeAction
9
+ * @param {import('@endo/marshal').CapData<string | null>} actionCapData
10
+ * of type BridgeAction
9
11
  * @param {boolean} [canSpend]
10
12
  * @returns {Promise<void>}
11
13
  */
@@ -18,17 +20,21 @@ export function prepareSmartWallet(baggage: import("@agoric/vat-data").Baggage,
18
20
  *
19
21
  * @param {Payment} payment
20
22
  * @returns {Promise<Amount>}
21
- * @throws if there's not yet a purse, though the payment is held to try again when there is
23
+ * @throws if there's not yet a purse, though the payment is held to try
24
+ * again when there is
22
25
  */
23
26
  receive(payment: Payment): Promise<Amount>;
24
27
  }>;
25
28
  getOffersFacet(): import("@endo/exo").Guarded<{
26
29
  /**
27
- * Take an offer description provided in capData, augment it with payments and call zoe.offer()
30
+ * Take an offer description provided in capData, augment it with
31
+ * payments and call zoe.offer()
28
32
  *
29
33
  * @param {OfferSpec} offerSpec
30
- * @returns {Promise<void>} after the offer has been both seated and exited by Zoe.
31
- * @throws if any parts of the offer can be determined synchronously to be invalid
34
+ * @returns {Promise<void>} after the offer has been both seated and
35
+ * exited by Zoe.
36
+ * @throws if any parts of the offer can be determined synchronously to
37
+ * be invalid
32
38
  */
33
39
  executeOffer(offerSpec: OfferSpec): Promise<void>;
34
40
  /**
@@ -88,47 +94,55 @@ export type TryExitOfferAction = {
88
94
  };
89
95
  export type BridgeAction = ExecuteOfferAction | TryExitOfferAction;
90
96
  /**
91
- * Purses is an array to support a future requirement of multiple purses per brand.
97
+ * Purses is an array to support a future requirement of multiple purses per
98
+ * brand.
92
99
  *
93
- * Each map is encoded as an array of entries because a Map doesn't serialize directly.
94
- * We also considered having a vstorage key for each offer but for now are sticking with this design.
100
+ * Each map is encoded as an array of entries because a Map doesn't serialize
101
+ * directly. We also considered having a vstorage key for each offer but for now
102
+ * are sticking with this design.
95
103
  *
96
104
  * Cons
97
- * - Reserializes previously written results when a new result is added
98
- * - Optimizes reads though writes are on-chain (~100 machines) and reads are off-chain (to 1 machine)
105
+ *
106
+ * - Reserializes previously written results when a new result is added
107
+ * - Optimizes reads though writes are on-chain (~100 machines) and reads are
108
+ * off-chain (to 1 machine)
99
109
  *
100
110
  * Pros
101
- * - Reading all offer results happens much more (>100) often than storing a new offer result
102
- * - Reserialization and writes are paid in execution gas, whereas reads are not
103
111
  *
104
- * This design should be revisited if ever batch querying across vstorage keys become cheaper or reads be paid.
112
+ * - Reading all offer results happens much more (>100) often than storing a new
113
+ * offer result
114
+ * - Reserialization and writes are paid in execution gas, whereas reads are not
115
+ *
116
+ * This design should be revisited if ever batch querying across vstorage keys
117
+ * become cheaper or reads be paid.
105
118
  */
106
119
  export type CurrentWalletRecord = {
107
- purses: Array<{
120
+ purses: {
108
121
  brand: Brand;
109
122
  balance: Amount;
110
- }>;
111
- offerToUsedInvitation: Array<[offerId: string, usedInvitation: Amount]>;
112
- offerToPublicSubscriberPaths: Array<[offerId: string, publicTopics: {
123
+ }[];
124
+ offerToUsedInvitation: [offerId: string, usedInvitation: Amount][];
125
+ offerToPublicSubscriberPaths: [offerId: string, publicTopics: {
113
126
  [subscriberName: string]: string;
114
- }]>;
115
- liveOffers: Array<[OfferId, import("./offers.js").OfferStatus]>;
127
+ }][];
128
+ liveOffers: [OfferId, OfferStatus][];
116
129
  };
117
130
  /**
118
131
  * Record of an update to the state of this wallet.
119
132
  *
120
- * Client is responsible for coalescing updates into a current state. See `coalesceUpdates` utility.
133
+ * Client is responsible for coalescing updates into a current state. See
134
+ * `coalesceUpdates` utility.
121
135
  *
122
- * The reason for this burden on the client is that publishing
123
- * the full history of offers with each change is untenable.
136
+ * The reason for this burden on the client is that publishing the full history
137
+ * of offers with each change is untenable.
124
138
  *
125
139
  * `balance` update supports forward-compatibility for more than one purse per
126
- * brand. An additional key will be needed to disambiguate. For now the brand in
127
- * the amount suffices.
140
+ * brand. An additional key will be needed to disambiguate. For now the brand
141
+ * in the amount suffices.
128
142
  */
129
143
  export type UpdateRecord = {
130
144
  updated: "offerStatus";
131
- status: import("./offers.js").OfferStatus;
145
+ status: OfferStatus;
132
146
  } | {
133
147
  updated: "balance";
134
148
  currentAmount: Amount;
@@ -139,7 +153,8 @@ export type UpdateRecord = {
139
153
  };
140
154
  };
141
155
  /**
142
- * For use by clients to describe brands to users. Includes `displayInfo` to save a remote call.
156
+ * For use by clients to describe brands to users. Includes `displayInfo` to
157
+ * save a remote call.
143
158
  */
144
159
  export type BrandDescriptor = {
145
160
  brand: Brand;
@@ -166,27 +181,37 @@ export type SharedParams = {
166
181
  secretWalletFactoryKey: any;
167
182
  };
168
183
  /**
169
- * - `brandPurses` is precious and closely held. defined as late as possible to reduce its scope.
184
+ * - `brandPurses` is precious
185
+ * and closely held. defined as late as possible to reduce its scope.
186
+ *
170
187
  * - `offerToInvitationMakers` is precious and closely held.
171
188
  * - `offerToPublicSubscriberPaths` is precious and closely held.
172
- * - `purseBalances` is a cache of what we've received from purses. Held so we can publish all balances on change.
189
+ * - `purseBalances` is a cache of what we've received from purses. Held so we can
190
+ * publish all balances on change.
173
191
  */
174
192
  export type State = ImmutableState & MutableState;
175
- export type ImmutableState = Readonly<UniqueParams & {
176
- paymentQueues: MapStore<Brand, Array<Payment>>;
177
- offerToInvitationMakers: MapStore<string, import("./types.js").InvitationMakers>;
178
- offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
179
- offerToUsedInvitation: MapStore<string, Amount<"set">>;
180
- purseBalances: MapStore<Purse, Amount>;
181
- updateRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").RecorderKit<UpdateRecord>;
182
- currentRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").RecorderKit<CurrentWalletRecord>;
183
- liveOffers: MapStore<OfferId, import("./offers.js").OfferStatus>;
184
- liveOfferSeats: MapStore<OfferId, UserSeat<unknown>>;
185
- liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>>;
186
- }>;
193
+ export type ImmutableState = {
194
+ readonly address: string;
195
+ readonly bank: globalThis.ERef<import("@agoric/vats/src/vat-bank.js").Bank>;
196
+ readonly currentStorageNode: globalThis.StorageNode;
197
+ readonly invitationPurse: globalThis.Purse<"set", InvitationDetails>;
198
+ readonly walletStorageNode: globalThis.StorageNode;
199
+ readonly paymentQueues: MapStore<Brand, Payment[]>;
200
+ readonly offerToInvitationMakers: MapStore<string, import("./types.js").InvitationMakers>;
201
+ readonly offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
202
+ readonly offerToUsedInvitation: MapStore<string, Amount<"set">>;
203
+ readonly purseBalances: MapStore<Purse, Amount>;
204
+ readonly updateRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").RecorderKit<UpdateRecord>;
205
+ readonly currentRecorderKit: import("@agoric/zoe/src/contractSupport/recorder.js").RecorderKit<CurrentWalletRecord>;
206
+ readonly liveOffers: globalThis.MapStore<OfferId, OfferStatus>;
207
+ readonly liveOfferSeats: globalThis.MapStore<OfferId, UserSeat<unknown>>;
208
+ readonly liveOfferPayments: globalThis.MapStore<OfferId, globalThis.MapStore<globalThis.Brand, globalThis.Payment>>;
209
+ };
187
210
  export type PurseRecord = BrandDescriptor & {
188
211
  purse: Purse;
189
212
  };
190
213
  export type MutableState = {};
191
214
  export type SmartWallet = Awaited<ReturnType<ReturnType<typeof prepareSmartWallet>>>;
215
+ import type { OfferId } from './offers.js';
216
+ import type { OfferStatus } from './offers.js';
192
217
  //# sourceMappingURL=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C;IACtD,QAAY,EAAE,uBAAuB,CAAC;IACtC,gBAAoB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,eAAmB,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,qBAAyB,EAAE,WAAW,CAAC;IACvC,gBAAoB,EAAE,UAAU,CAAC;IACjC,GAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1B,sBAA0B,EAAE,GAAG,CAAC;CAC7B;;;;;;;;;;oBAGS,cAAc,GAAG,YAAY;;;;;;;4BAWpB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;sCAChB,QAAQ,CACvC,MAAc,EACd,OAAe,YAAY,EAAE,gBAAgB,CACtC;2CAC6B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oCAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;4BACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gCACnB,OAAO,6CAA6C,EAAE,WAAW,CAAC,YAAY,CAAC;iCAC9E,OAAO,6CAA6C,EAAE,WAAW,CAAC,mBAAmB,CAAC;;;;;0BAQpG,eAAe,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE;2BAElC,EAAE;0BAwhCD,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC;6BAjsChC,aAAa;iCAAb,aAAa"}
@@ -42,149 +42,176 @@ import { shape } from './typeGuards.js';
42
42
  import { objectMapStoragePath } from './utils.js';
43
43
  import { prepareOfferWatcher, watchOfferOutcomes } from './offerWatcher.js';
44
44
 
45
+ /** @import {OfferId, OfferStatus} from './offers.js'; */
46
+
45
47
  const { Fail, quote: q } = assert;
46
48
 
47
49
  const trace = makeTracer('SmrtWlt');
48
50
 
49
51
  /**
50
52
  * @file Smart wallet module
51
- *
52
- * @see {@link ../README.md}}
53
+ * @see {@link ../README.md} }
53
54
  */
54
55
 
55
56
  /** @typedef {number | string} OfferId */
56
57
 
57
58
  /**
58
59
  * @typedef {{
59
- * id: OfferId,
60
- * invitationSpec: import('./invitations').InvitationSpec,
61
- * proposal: Proposal,
62
- * offerArgs?: any
60
+ * id: OfferId;
61
+ * invitationSpec: import('./invitations').InvitationSpec;
62
+ * proposal: Proposal;
63
+ * offerArgs?: any;
63
64
  * }} OfferSpec
64
65
  */
65
66
 
66
67
  /**
67
68
  * @typedef {{
68
- * logger: {info: (...args: any[]) => void, error: (...args: any[]) => void},
69
- * makeOfferWatcher: import('./offerWatcher.js').MakeOfferWatcher,
70
- * invitationFromSpec: ERef<Invitation>,
69
+ * logger: {
70
+ * info: (...args: any[]) => void;
71
+ * error: (...args: any[]) => void;
72
+ * };
73
+ * makeOfferWatcher: import('./offerWatcher.js').MakeOfferWatcher;
74
+ * invitationFromSpec: ERef<Invitation>;
71
75
  * }} ExecutorPowers
72
76
  */
73
77
 
74
78
  /**
75
79
  * @typedef {{
76
- * method: 'executeOffer'
77
- * offer: OfferSpec,
80
+ * method: 'executeOffer';
81
+ * offer: OfferSpec;
78
82
  * }} ExecuteOfferAction
79
83
  */
80
84
 
81
85
  /**
82
86
  * @typedef {{
83
- * method: 'tryExitOffer'
84
- * offerId: OfferId,
87
+ * method: 'tryExitOffer';
88
+ * offerId: OfferId;
85
89
  * }} TryExitOfferAction
86
90
  */
87
91
 
88
92
  // Discriminated union. Possible future messages types:
89
93
  // maybe suggestIssuer for https://github.com/Agoric/agoric-sdk/issues/6132
90
94
  // setting petnames and adding brands for https://github.com/Agoric/agoric-sdk/issues/6126
91
- /**
92
- * @typedef { ExecuteOfferAction | TryExitOfferAction } BridgeAction
93
- */
95
+ /** @typedef {ExecuteOfferAction | TryExitOfferAction} BridgeAction */
94
96
 
95
97
  /**
96
- * Purses is an array to support a future requirement of multiple purses per brand.
98
+ * Purses is an array to support a future requirement of multiple purses per
99
+ * brand.
97
100
  *
98
- * Each map is encoded as an array of entries because a Map doesn't serialize directly.
99
- * We also considered having a vstorage key for each offer but for now are sticking with this design.
101
+ * Each map is encoded as an array of entries because a Map doesn't serialize
102
+ * directly. We also considered having a vstorage key for each offer but for now
103
+ * are sticking with this design.
100
104
  *
101
105
  * Cons
102
- * - Reserializes previously written results when a new result is added
103
- * - Optimizes reads though writes are on-chain (~100 machines) and reads are off-chain (to 1 machine)
106
+ *
107
+ * - Reserializes previously written results when a new result is added
108
+ * - Optimizes reads though writes are on-chain (~100 machines) and reads are
109
+ * off-chain (to 1 machine)
104
110
  *
105
111
  * Pros
106
- * - Reading all offer results happens much more (>100) often than storing a new offer result
107
- * - Reserialization and writes are paid in execution gas, whereas reads are not
108
112
  *
109
- * This design should be revisited if ever batch querying across vstorage keys become cheaper or reads be paid.
113
+ * - Reading all offer results happens much more (>100) often than storing a new
114
+ * offer result
115
+ * - Reserialization and writes are paid in execution gas, whereas reads are not
116
+ *
117
+ * This design should be revisited if ever batch querying across vstorage keys
118
+ * become cheaper or reads be paid.
110
119
  *
111
120
  * @typedef {{
112
- * purses: Array<{brand: Brand, balance: Amount}>,
113
- * offerToUsedInvitation: Array<[ offerId: string, usedInvitation: Amount ]>,
114
- * offerToPublicSubscriberPaths: Array<[ offerId: string, publicTopics: { [subscriberName: string]: string } ]>,
115
- * liveOffers: Array<[OfferId, import('./offers.js').OfferStatus]>,
121
+ * purses: { brand: Brand; balance: Amount }[];
122
+ * offerToUsedInvitation: [offerId: string, usedInvitation: Amount][];
123
+ * offerToPublicSubscriberPaths: [
124
+ * offerId: string,
125
+ * publicTopics: { [subscriberName: string]: string },
126
+ * ][];
127
+ * liveOffers: [OfferId, OfferStatus][];
116
128
  * }} CurrentWalletRecord
117
129
  */
118
130
 
119
131
  /**
120
- * @typedef {{ updated: 'offerStatus', status: import('./offers.js').OfferStatus }
132
+ * @typedef {{ updated: 'offerStatus'; status: OfferStatus }
121
133
  * | { updated: 'balance'; currentAmount: Amount }
122
- * | { updated: 'walletAction'; status: { error: string } }
123
- * } UpdateRecord Record of an update to the state of this wallet.
134
+ * | { updated: 'walletAction'; status: { error: string } }} UpdateRecord
135
+ * Record of an update to the state of this wallet.
124
136
  *
125
- * Client is responsible for coalescing updates into a current state. See `coalesceUpdates` utility.
137
+ * Client is responsible for coalescing updates into a current state. See
138
+ * `coalesceUpdates` utility.
126
139
  *
127
- * The reason for this burden on the client is that publishing
128
- * the full history of offers with each change is untenable.
140
+ * The reason for this burden on the client is that publishing the full history
141
+ * of offers with each change is untenable.
129
142
  *
130
- * `balance` update supports forward-compatibility for more than one purse per
131
- * brand. An additional key will be needed to disambiguate. For now the brand in
132
- * the amount suffices.
143
+ * `balance` update supports forward-compatibility for more than one purse per
144
+ * brand. An additional key will be needed to disambiguate. For now the brand
145
+ * in the amount suffices.
133
146
  */
134
147
 
135
148
  /**
136
149
  * @typedef {{
137
- * brand: Brand,
138
- * displayInfo: DisplayInfo,
139
- * issuer: Issuer,
140
- * petname: import('./types.js').Petname
150
+ * brand: Brand;
151
+ * displayInfo: DisplayInfo;
152
+ * issuer: Issuer;
153
+ * petname: import('./types.js').Petname;
141
154
  * }} BrandDescriptor
142
- * For use by clients to describe brands to users. Includes `displayInfo` to save a remote call.
155
+ * For use by clients to describe brands to users. Includes `displayInfo` to
156
+ * save a remote call.
143
157
  */
144
158
 
145
159
  /**
146
160
  * @typedef {{
147
- * address: string,
148
- * bank: ERef<import('@agoric/vats/src/vat-bank.js').Bank>,
149
- * currentStorageNode: StorageNode,
150
- * invitationPurse: Purse<'set', InvitationDetails>,
151
- * walletStorageNode: StorageNode,
161
+ * address: string;
162
+ * bank: ERef<import('@agoric/vats/src/vat-bank.js').Bank>;
163
+ * currentStorageNode: StorageNode;
164
+ * invitationPurse: Purse<'set', InvitationDetails>;
165
+ * walletStorageNode: StorageNode;
152
166
  * }} UniqueParams
153
167
  *
168
+ *
154
169
  * @typedef {Pick<MapStore<Brand, BrandDescriptor>, 'has' | 'get' | 'values'>} BrandDescriptorRegistry
170
+ *
171
+ *
155
172
  * @typedef {{
156
- * agoricNames: ERef<import('@agoric/vats').NameHub>,
157
- * registry: BrandDescriptorRegistry,
158
- * invitationIssuer: Issuer<'set'>,
159
- * invitationBrand: Brand<'set'>,
160
- * invitationDisplayInfo: DisplayInfo,
161
- * publicMarshaller: Marshaller,
162
- * zoe: ERef<ZoeService>,
163
- * secretWalletFactoryKey: any,
173
+ * agoricNames: ERef<import('@agoric/vats').NameHub>;
174
+ * registry: BrandDescriptorRegistry;
175
+ * invitationIssuer: Issuer<'set'>;
176
+ * invitationBrand: Brand<'set'>;
177
+ * invitationDisplayInfo: DisplayInfo;
178
+ * publicMarshaller: Marshaller;
179
+ * zoe: ERef<ZoeService>;
180
+ * secretWalletFactoryKey: any;
164
181
  * }} SharedParams
165
182
  *
166
- * @typedef {ImmutableState & MutableState} State
167
- * - `brandPurses` is precious and closely held. defined as late as possible to reduce its scope.
168
- * - `offerToInvitationMakers` is precious and closely held.
169
- * - `offerToPublicSubscriberPaths` is precious and closely held.
170
- * - `purseBalances` is a cache of what we've received from purses. Held so we can publish all balances on change.
171
183
  *
172
- * @typedef {Readonly<UniqueParams & {
173
- * paymentQueues: MapStore<Brand, Array<Payment>>,
174
- * offerToInvitationMakers: MapStore<string, import('./types.js').InvitationMakers>,
175
- * offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>,
176
- * offerToUsedInvitation: MapStore<string, Amount<'set'>>,
177
- * purseBalances: MapStore<Purse, Amount>,
178
- * updateRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<UpdateRecord>,
179
- * currentRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<CurrentWalletRecord>,
180
- * liveOffers: MapStore<OfferId, import('./offers.js').OfferStatus>,
181
- * liveOfferSeats: MapStore<OfferId, UserSeat<unknown>>,
182
- * liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>>,
183
- * }>} ImmutableState
184
+ * @typedef {ImmutableState & MutableState} State - `brandPurses` is precious
185
+ * and closely held. defined as late as possible to reduce its scope.
186
+ *
187
+ * - `offerToInvitationMakers` is precious and closely held.
188
+ * - `offerToPublicSubscriberPaths` is precious and closely held.
189
+ * - `purseBalances` is a cache of what we've received from purses. Held so we can
190
+ * publish all balances on change.
191
+ *
192
+ *
193
+ * @typedef {Readonly<
194
+ * UniqueParams & {
195
+ * paymentQueues: MapStore<Brand, Payment[]>;
196
+ * offerToInvitationMakers: MapStore<
197
+ * string,
198
+ * import('./types.js').InvitationMakers
199
+ * >;
200
+ * offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
201
+ * offerToUsedInvitation: MapStore<string, Amount<'set'>>;
202
+ * purseBalances: MapStore<Purse, Amount>;
203
+ * updateRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<UpdateRecord>;
204
+ * currentRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').RecorderKit<CurrentWalletRecord>;
205
+ * liveOffers: MapStore<OfferId, OfferStatus>;
206
+ * liveOfferSeats: MapStore<OfferId, UserSeat<unknown>>;
207
+ * liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>>;
208
+ * }
209
+ * >} ImmutableState
210
+ *
184
211
  *
185
212
  * @typedef {BrandDescriptor & { purse: Purse }} PurseRecord
186
- * @typedef {{
187
- * }} MutableState
213
+ *
214
+ * @typedef {{}} MutableState
188
215
  */
189
216
 
190
217
  /**
@@ -296,8 +323,8 @@ export const prepareSmartWallet = (baggage, shared) => {
296
323
  (purse, helper) => ({ purse, helper }),
297
324
  {
298
325
  /**
299
- * @param {{ value: Amount, updateCount: bigint | undefined }} updateRecord
300
- * @param { Notifier<Amount> } notifier
326
+ * @param {{ value: Amount; updateCount: bigint | undefined }} updateRecord
327
+ * @param {Notifier<Amount>} notifier
301
328
  * @returns {void}
302
329
  */
303
330
  onFulfilled(updateRecord, notifier) {
@@ -458,9 +485,10 @@ export const prepareSmartWallet = (baggage, shared) => {
458
485
 
459
486
  // TODO move to top level so its type can be exported
460
487
  /**
461
- * Make the durable object to return, but taking some parameters that are awaited by a wrapping function.
462
- * This is necessary because the class kit construction helpers, `initState` and `finish` run synchronously
463
- * and the child storage node must be awaited until we have durable promises.
488
+ * Make the durable object to return, but taking some parameters that are
489
+ * awaited by a wrapping function. This is necessary because the class kit
490
+ * construction helpers, `initState` and `finish` run synchronously and the
491
+ * child storage node must be awaited until we have durable promises.
464
492
  */
465
493
  const makeWalletWithResolvedStorageNodes = prepareExoClassKit(
466
494
  baggage,
@@ -557,15 +585,15 @@ export const prepareSmartWallet = (baggage, shared) => {
557
585
  },
558
586
 
559
587
  /**
560
- * Provide a purse given a NameHub of issuers and their
561
- * brands.
588
+ * Provide a purse given a NameHub of issuers and their brands.
562
589
  *
563
- * We currently support only one NameHub, agoricNames, and
564
- * hence one purse per brand. But we store an array of them
565
- * to facilitate a transition to decentralized introductions.
590
+ * We currently support only one NameHub, agoricNames, and hence one
591
+ * purse per brand. But we store an array of them to facilitate a
592
+ * transition to decentralized introductions.
566
593
  *
567
594
  * @param {Brand} brand
568
- * @param {ERef<import('@agoric/vats').NameHub>} known - namehub with brand, issuer branches
595
+ * @param {ERef<import('@agoric/vats').NameHub>} known - namehub with
596
+ * brand, issuer branches
569
597
  * @returns {Promise<Purse | undefined>} undefined if brand is not known
570
598
  */
571
599
  async getPurseIfKnownBrand(brand, known) {
@@ -706,7 +734,7 @@ export const prepareSmartWallet = (baggage, shared) => {
706
734
  void helper.watchPurse(invitationPurse);
707
735
  },
708
736
 
709
- /** @param {import('./offers.js').OfferStatus} offerStatus */
737
+ /** @param {OfferStatus} offerStatus */
710
738
  updateStatus(offerStatus) {
711
739
  const { state, facets } = this;
712
740
  facets.helper.logWalletInfo('offerStatus', offerStatus);
@@ -736,9 +764,9 @@ export const prepareSmartWallet = (baggage, shared) => {
736
764
 
737
765
  /**
738
766
  * @param {string} offerId
739
- * @param {Amount<"set">} invitationAmount
740
- * @param {import("./types.js").InvitationMakers} invitationMakers
741
- * @param {import("./types.js").PublicSubscribers} publicSubscribers
767
+ * @param {Amount<'set'>} invitationAmount
768
+ * @param {import('./types.js').InvitationMakers} invitationMakers
769
+ * @param {import('./types.js').PublicSubscribers} publicSubscribers
742
770
  */
743
771
  async addContinuingOffer(
744
772
  offerId,
@@ -812,7 +840,8 @@ export const prepareSmartWallet = (baggage, shared) => {
812
840
  },
813
841
  },
814
842
  /**
815
- * Similar to {DepositFacet} but async because it has to look up the purse.
843
+ * Similar to {DepositFacet} but async because it has to look up the
844
+ * purse.
816
845
  */
817
846
  deposit: {
818
847
  /**
@@ -822,7 +851,8 @@ export const prepareSmartWallet = (baggage, shared) => {
822
851
  *
823
852
  * @param {Payment} payment
824
853
  * @returns {Promise<Amount>}
825
- * @throws if there's not yet a purse, though the payment is held to try again when there is
854
+ * @throws if there's not yet a purse, though the payment is held to try
855
+ * again when there is
826
856
  */
827
857
  async receive(payment) {
828
858
  const {
@@ -861,9 +891,11 @@ export const prepareSmartWallet = (baggage, shared) => {
861
891
 
862
892
  payments: {
863
893
  /**
864
- * Withdraw the offered amount from the appropriate purse of this wallet.
894
+ * Withdraw the offered amount from the appropriate purse of this
895
+ * wallet.
865
896
  *
866
- * Save its amount in liveOfferPayments in case we need to reclaim the payment.
897
+ * Save its amount in liveOfferPayments in case we need to reclaim the
898
+ * payment.
867
899
  *
868
900
  * @param {AmountKeywordRecord} give
869
901
  * @param {OfferId} offerId
@@ -903,7 +935,8 @@ export const prepareSmartWallet = (baggage, shared) => {
903
935
  },
904
936
 
905
937
  /**
906
- * Find the live payments for the offer and deposit them back in the appropriate purses.
938
+ * Find the live payments for the offer and deposit them back in the
939
+ * appropriate purses.
907
940
  *
908
941
  * @param {OfferId} offerId
909
942
  * @returns {Promise<Amount[]>}
@@ -944,11 +977,14 @@ export const prepareSmartWallet = (baggage, shared) => {
944
977
 
945
978
  offers: {
946
979
  /**
947
- * Take an offer description provided in capData, augment it with payments and call zoe.offer()
980
+ * Take an offer description provided in capData, augment it with
981
+ * payments and call zoe.offer()
948
982
  *
949
983
  * @param {OfferSpec} offerSpec
950
- * @returns {Promise<void>} after the offer has been both seated and exited by Zoe.
951
- * @throws if any parts of the offer can be determined synchronously to be invalid
984
+ * @returns {Promise<void>} after the offer has been both seated and
985
+ * exited by Zoe.
986
+ * @throws if any parts of the offer can be determined synchronously to
987
+ * be invalid
952
988
  */
953
989
  async executeOffer(offerSpec) {
954
990
  const { facets, state } = this;
@@ -1078,9 +1114,11 @@ export const prepareSmartWallet = (baggage, shared) => {
1078
1114
  },
1079
1115
  self: {
1080
1116
  /**
1081
- * Umarshals the actionCapData and delegates to the appropriate action handler.
1117
+ * Umarshals the actionCapData and delegates to the appropriate action
1118
+ * handler.
1082
1119
  *
1083
- * @param {import('@endo/marshal').CapData<string | null>} actionCapData of type BridgeAction
1120
+ * @param {import('@endo/marshal').CapData<string | null>} actionCapData
1121
+ * of type BridgeAction
1084
1122
  * @param {boolean} [canSpend]
1085
1123
  * @returns {Promise<void>}
1086
1124
  */
@@ -1196,7 +1234,12 @@ export const prepareSmartWallet = (baggage, shared) => {
1196
1234
  );
1197
1235
 
1198
1236
  /**
1199
- * @param {Omit<UniqueParams, 'currentStorageNode' | 'walletStorageNode'> & {walletStorageNode: ERef<StorageNode>}} uniqueWithoutChildNodes
1237
+ * @param {Omit<
1238
+ * UniqueParams,
1239
+ * 'currentStorageNode' | 'walletStorageNode'
1240
+ * > & {
1241
+ * walletStorageNode: ERef<StorageNode>;
1242
+ * }} uniqueWithoutChildNodes
1200
1243
  */
1201
1244
  const makeSmartWallet = async uniqueWithoutChildNodes => {
1202
1245
  const [walletStorageNode, currentStorageNode] = await Promise.all([
package/src/types.d.ts CHANGED
@@ -29,6 +29,11 @@ export type InvitationMakers = Record<
29
29
 
30
30
  export type PublicSubscribers = Record<string, ERef<StoredFacet>>;
31
31
 
32
+ export interface ContinuingOfferResult {
33
+ invitationMakers: InvitationMakers;
34
+ publicSubscribers: PublicSubscribers;
35
+ }
36
+
32
37
  export type Cell<T> = {
33
38
  get: () => T;
34
39
  set(val: T): void;
package/src/utils.d.ts CHANGED
@@ -1,26 +1,29 @@
1
+ /** @import {OfferId, OfferStatus} from './offers.js'; */
1
2
  export const NO_SMART_WALLET_ERROR: "no smart wallet";
2
3
  export function makeWalletStateCoalescer(invitationBrand?: globalThis.Brand<"set"> | undefined): {
3
4
  state: {
4
- invitationsReceived: Map<import("./offers.js").OfferId, {
5
- acceptedIn: import("./offers.js").OfferId;
5
+ invitationsReceived: Map<OfferId, {
6
+ acceptedIn: OfferId;
6
7
  description: string;
7
8
  instance: Instance;
8
9
  }>;
9
- offerStatuses: Map<import("./offers.js").OfferId, import("./offers.js").OfferStatus>;
10
+ offerStatuses: Map<OfferId, OfferStatus>;
10
11
  balances: Map<globalThis.Brand, globalThis.Amount>;
11
12
  };
12
13
  update: (updateRecord: import("./smartWallet.js").UpdateRecord | {}) => void;
13
14
  };
14
15
  export function coalesceUpdates(updates: ERef<Subscriber<import("./smartWallet.js").UpdateRecord>>, invitationBrand?: globalThis.Brand<"set"> | undefined): {
15
- invitationsReceived: Map<import("./offers.js").OfferId, {
16
- acceptedIn: import("./offers.js").OfferId;
16
+ invitationsReceived: Map<OfferId, {
17
+ acceptedIn: OfferId;
17
18
  description: string;
18
19
  instance: Instance;
19
20
  }>;
20
- offerStatuses: Map<import("./offers.js").OfferId, import("./offers.js").OfferStatus>;
21
+ offerStatuses: Map<OfferId, OfferStatus>;
21
22
  balances: Map<globalThis.Brand, globalThis.Amount>;
22
23
  };
23
24
  export function assertHasData(follower: import("@agoric/casting").Follower<any>): Promise<void>;
24
25
  export function objectMapStoragePath(subscribers?: import("@agoric/zoe/src/contractSupport/topics.js").TopicsRecord | import("./types.js").PublicSubscribers | undefined): ERef<Record<string, string>> | null;
25
26
  export type CoalescedWalletState = ReturnType<typeof makeWalletStateCoalescer>["state"];
27
+ import type { OfferId } from './offers.js';
28
+ import type { OfferStatus } from './offers.js';
26
29
  //# sourceMappingURL=utils.d.ts.map