@agoric/smart-wallet 0.5.4-u15.0 → 0.5.4-u16.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.
- package/package.json +32 -28
- package/src/invitations.d.ts +14 -10
- package/src/invitations.d.ts.map +1 -1
- package/src/invitations.js +32 -28
- package/src/marshal-contexts.d.ts +44 -41
- package/src/marshal-contexts.d.ts.map +1 -1
- package/src/marshal-contexts.js +65 -58
- package/src/offerWatcher.d.ts +21 -39
- package/src/offerWatcher.d.ts.map +1 -1
- package/src/offerWatcher.js +34 -24
- package/src/offers.d.ts +7 -7
- package/src/offers.d.ts.map +1 -1
- package/src/offers.js +9 -9
- package/src/proposals/upgrade-wallet-factory2-proposal.d.ts.map +1 -1
- package/src/proposals/upgrade-wallet-factory2-proposal.js +2 -1
- package/src/proposals/upgrade-walletFactory-proposal.d.ts +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.d.ts.map +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.js +45 -21
- package/src/smartWallet.d.ts +80 -60
- package/src/smartWallet.d.ts.map +1 -1
- package/src/smartWallet.js +156 -109
- package/src/typeGuards.d.ts +1 -1
- package/src/types.d.ts +14 -13
- package/src/utils.d.ts +17 -14
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +18 -6
- package/src/walletFactory.d.ts +24 -80
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +55 -36
- package/CHANGELOG.md +0 -250
package/src/marshal-contexts.js
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
|
26
|
-
* @typedef {`${string & keyof T}:${Digits}`} WalletSlot
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
|
73
|
-
* @typedef {WalletSlot<T> | BoardId} MixedSlot
|
|
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
|
-
*
|
|
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,
|
|
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
|
|
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
|
-
*
|
|
110
|
-
*
|
|
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
|
|
113
|
-
*
|
|
114
|
-
*
|
|
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,
|
|
133
|
+
/** @type {IdTable<number, PassableCap>} */
|
|
130
134
|
unknown: {
|
|
131
135
|
bySlot: makeScalarMapStore(),
|
|
132
136
|
byVal: makeScalarMapStore(),
|
|
133
137
|
},
|
|
134
138
|
};
|
|
135
|
-
/** @type {IdTable<BoardId,
|
|
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
|
-
*
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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
|
-
*
|
|
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) =>
|
|
244
|
+
* @param {(iface: string) => PassableCap} [makePresence]
|
|
242
245
|
*/
|
|
243
246
|
export const makeImportContext = (makePresence = defaultMakePresence) => {
|
|
244
247
|
const walletObjects = {
|
|
245
|
-
/** @type {IdTable<number,
|
|
248
|
+
/** @type {IdTable<number, PassableCap>} */
|
|
246
249
|
purse: {
|
|
247
250
|
bySlot: makeScalarMapStore(),
|
|
248
251
|
byVal: makeScalarMapStore(),
|
|
249
252
|
},
|
|
250
|
-
/** @type {IdTable<number,
|
|
253
|
+
/** @type {IdTable<number, PassableCap>} */
|
|
251
254
|
payment: {
|
|
252
255
|
bySlot: makeScalarMapStore(),
|
|
253
256
|
byVal: makeScalarMapStore(),
|
|
254
257
|
},
|
|
255
|
-
/** @type {IdTable<number,
|
|
258
|
+
/** @type {IdTable<number, PassableCap>} */
|
|
256
259
|
unknown: {
|
|
257
260
|
bySlot: makeScalarMapStore(),
|
|
258
261
|
byVal: makeScalarMapStore(),
|
|
259
262
|
},
|
|
260
263
|
};
|
|
261
|
-
/** @type {IdTable<BoardId,
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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: (
|
|
363
|
-
*
|
|
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
|
-
|
|
375
|
+
|
|
369
376
|
void new HandledPromise((resolve, reject, resolveWithPresence) => {
|
|
370
377
|
obj = resolveWithPresence(handler);
|
|
371
378
|
});
|
package/src/offerWatcher.d.ts
CHANGED
|
@@ -1,66 +1,48 @@
|
|
|
1
1
|
export function watchOfferOutcomes(watchers: OutcomeWatchers, seat: UserSeat): Promise<[unknown, 0 | 1, PaymentPKeywordRecord]>;
|
|
2
|
-
export function prepareOfferWatcher(baggage:
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param {
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
publishResult(result:
|
|
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
|
|
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[
|
|
27
|
+
paymentWatcher: OutcomeWatchers["paymentWatcher"];
|
|
42
28
|
/** @type {OutcomeWatchers['resultWatcher']} */
|
|
43
|
-
resultWatcher: OutcomeWatchers[
|
|
29
|
+
resultWatcher: OutcomeWatchers["resultWatcher"];
|
|
44
30
|
/** @type {OutcomeWatchers['numWantsWatcher']} */
|
|
45
|
-
numWantsWatcher: OutcomeWatchers[
|
|
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<
|
|
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":"
|
|
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"}
|
package/src/offerWatcher.js
CHANGED
|
@@ -13,24 +13,22 @@ import { deeplyFulfilledObject, objectMap } from '@agoric/internal';
|
|
|
13
13
|
import { UNPUBLISHED_RESULT } from './offers.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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 {
|
|
24
|
+
* @typedef {PromiseWatcher<T, [UserSeat]>} OfferPromiseWatcher<T, [UserSeat]
|
|
27
25
|
*/
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* @typedef {{
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
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 {
|
|
122
|
-
* @param {
|
|
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
|
|
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
|
|
232
|
+
* If promise disconnected, watch again. Or if there's an Error, handle
|
|
233
|
+
* it.
|
|
229
234
|
*
|
|
230
|
-
* @param {Error
|
|
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
|
|
256
|
+
* If promise disconnected, watch again. Or if there's an Error, handle
|
|
257
|
+
* it.
|
|
251
258
|
*
|
|
252
|
-
* @param {Error
|
|
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
|
|
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?:
|
|
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(
|
|
17
|
+
invitationSpec: import("./invitations.js").InvitationSpec;
|
|
18
18
|
proposal: Proposal;
|
|
19
|
-
offerArgs?:
|
|
19
|
+
offerArgs?: any;
|
|
20
20
|
};
|
|
21
|
-
export type OfferStatus =
|
|
21
|
+
export type OfferStatus = OfferSpec & {
|
|
22
22
|
error?: string;
|
|
23
23
|
numWantsSatisfied?: number;
|
|
24
24
|
result?: unknown | typeof UNPUBLISHED_RESULT;
|
package/src/offers.d.ts.map
CHANGED
|
@@ -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,
|
|
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?:
|
|
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 {
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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":"
|
|
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
|
|
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,
|
|
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"}
|