@agoric/smart-wallet 0.5.4-upgrade-14-dev-c8f9e7b.0 → 0.5.4-upgrade-16-dev-8879538.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 -27
- package/src/invitations.d.ts +7 -7
- package/src/invitations.d.ts.map +1 -1
- package/src/invitations.js +3 -8
- package/src/marshal-contexts.d.ts +43 -39
- package/src/marshal-contexts.d.ts.map +1 -1
- package/src/marshal-contexts.js +29 -25
- package/src/offerWatcher.d.ts +28 -27
- package/src/offerWatcher.d.ts.map +1 -1
- package/src/offerWatcher.js +71 -23
- package/src/offers.d.ts +5 -5
- package/src/offers.d.ts.map +1 -1
- package/src/offers.js +3 -3
- 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 +42 -17
- package/src/smartWallet.d.ts +38 -39
- package/src/smartWallet.d.ts.map +1 -1
- package/src/smartWallet.js +121 -59
- package/src/typeGuards.d.ts +1 -1
- package/src/types.d.ts +9 -13
- package/src/utils.d.ts +14 -14
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +5 -6
- package/src/walletFactory.d.ts +19 -77
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +9 -9
- package/CHANGELOG.md +0 -208
package/src/offerWatcher.js
CHANGED
|
@@ -12,18 +12,12 @@ import { deeplyFulfilledObject, objectMap } from '@agoric/internal';
|
|
|
12
12
|
|
|
13
13
|
import { UNPUBLISHED_RESULT } from './offers.js';
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
* error?: string,
|
|
18
|
-
* numWantsSatisfied?: number
|
|
19
|
-
* result?: unknown | typeof import('./offers.js').UNPUBLISHED_RESULT,
|
|
20
|
-
* payouts?: AmountKeywordRecord,
|
|
21
|
-
* }} OfferStatus
|
|
22
|
-
*/
|
|
15
|
+
/** @import {OfferSpec} from "./offers.js" */
|
|
16
|
+
/** @import {PromiseWatcher} from '@agoric/swingset-liveslots' */
|
|
23
17
|
|
|
24
18
|
/**
|
|
25
19
|
* @template {any} T
|
|
26
|
-
* @typedef {
|
|
20
|
+
* @typedef {PromiseWatcher<T, [UserSeat]>} OfferPromiseWatcher<T, [UserSeat]
|
|
27
21
|
*/
|
|
28
22
|
|
|
29
23
|
/**
|
|
@@ -40,7 +34,6 @@ import { UNPUBLISHED_RESULT } from './offers.js';
|
|
|
40
34
|
*/
|
|
41
35
|
const watchForOfferResult = ({ resultWatcher }, seat) => {
|
|
42
36
|
const p = E(seat).getOfferResult();
|
|
43
|
-
// @ts-expect-error missing declarations?
|
|
44
37
|
watchPromise(p, resultWatcher, seat);
|
|
45
38
|
return p;
|
|
46
39
|
};
|
|
@@ -51,7 +44,6 @@ const watchForOfferResult = ({ resultWatcher }, seat) => {
|
|
|
51
44
|
*/
|
|
52
45
|
const watchForNumWants = ({ numWantsWatcher }, seat) => {
|
|
53
46
|
const p = E(seat).numWantsSatisfied();
|
|
54
|
-
// @ts-expect-error missing declarations?
|
|
55
47
|
watchPromise(p, numWantsWatcher, seat);
|
|
56
48
|
return p;
|
|
57
49
|
};
|
|
@@ -62,7 +54,6 @@ const watchForNumWants = ({ numWantsWatcher }, seat) => {
|
|
|
62
54
|
*/
|
|
63
55
|
const watchForPayout = ({ paymentWatcher }, seat) => {
|
|
64
56
|
const p = E(seat).getPayouts();
|
|
65
|
-
// @ts-expect-error missing declarations?
|
|
66
57
|
watchPromise(p, paymentWatcher, seat);
|
|
67
58
|
return p;
|
|
68
59
|
};
|
|
@@ -90,6 +81,7 @@ const offerWatcherGuard = harden({
|
|
|
90
81
|
.optional(M.record())
|
|
91
82
|
.returns(),
|
|
92
83
|
publishResult: M.call(M.any()).returns(),
|
|
84
|
+
handleError: M.call(M.error()).returns(),
|
|
93
85
|
}),
|
|
94
86
|
paymentWatcher: M.interface('paymentWatcher', {
|
|
95
87
|
onFulfilled: M.call(PaymentPKeywordRecordShape, SeatShape).returns(
|
|
@@ -107,27 +99,48 @@ const offerWatcherGuard = harden({
|
|
|
107
99
|
}),
|
|
108
100
|
});
|
|
109
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
104
|
+
*/
|
|
110
105
|
export const prepareOfferWatcher = baggage => {
|
|
111
106
|
return prepareExoClassKit(
|
|
112
107
|
baggage,
|
|
113
108
|
'OfferWatcher',
|
|
114
109
|
offerWatcherGuard,
|
|
115
|
-
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param {*} walletHelper
|
|
113
|
+
* @param {*} deposit
|
|
114
|
+
* @param {OfferSpec} offerSpec
|
|
115
|
+
* @param {string} address
|
|
116
|
+
* @param {Amount<'set'>} invitationAmount
|
|
117
|
+
* @param {UserSeat} seatRef
|
|
118
|
+
*/
|
|
119
|
+
(walletHelper, deposit, offerSpec, address, invitationAmount, seatRef) => ({
|
|
116
120
|
walletHelper,
|
|
117
121
|
deposit,
|
|
118
122
|
status: offerSpec,
|
|
119
123
|
address,
|
|
120
|
-
invitationAmount
|
|
124
|
+
invitationAmount,
|
|
121
125
|
seatRef,
|
|
122
126
|
}),
|
|
123
127
|
{
|
|
124
128
|
helper: {
|
|
129
|
+
/**
|
|
130
|
+
* @param {Record<string, unknown>} offerStatusUpdates
|
|
131
|
+
*/
|
|
125
132
|
updateStatus(offerStatusUpdates) {
|
|
126
133
|
const { state } = this;
|
|
127
134
|
state.status = harden({ ...state.status, ...offerStatusUpdates });
|
|
128
135
|
|
|
129
136
|
state.walletHelper.updateStatus(state.status);
|
|
130
137
|
},
|
|
138
|
+
/**
|
|
139
|
+
* @param {string} offerId
|
|
140
|
+
* @param {Amount<"set">} invitationAmount
|
|
141
|
+
* @param {import('./types.js').InvitationMakers} invitationMakers
|
|
142
|
+
* @param {import("./types.js").PublicSubscribers} publicSubscribers
|
|
143
|
+
*/
|
|
131
144
|
onNewContinuingOffer(
|
|
132
145
|
offerId,
|
|
133
146
|
invitationAmount,
|
|
@@ -144,6 +157,7 @@ export const prepareOfferWatcher = baggage => {
|
|
|
144
157
|
);
|
|
145
158
|
},
|
|
146
159
|
|
|
160
|
+
/** @param {unknown} result */
|
|
147
161
|
publishResult(result) {
|
|
148
162
|
const { state, facets } = this;
|
|
149
163
|
|
|
@@ -160,13 +174,16 @@ export const prepareOfferWatcher = baggage => {
|
|
|
160
174
|
facets.helper.updateStatus({ result });
|
|
161
175
|
break;
|
|
162
176
|
case 'copyRecord':
|
|
177
|
+
// @ts-expect-error narrowed by passStyle
|
|
163
178
|
if ('invitationMakers' in result) {
|
|
164
179
|
// save for continuing invitation offer
|
|
165
180
|
|
|
166
181
|
void facets.helper.onNewContinuingOffer(
|
|
167
182
|
String(state.status.id),
|
|
168
183
|
state.invitationAmount,
|
|
184
|
+
// @ts-expect-error narrowed by passStyle
|
|
169
185
|
result.invitationMakers,
|
|
186
|
+
// @ts-expect-error narrowed by passStyle
|
|
170
187
|
result.publicSubscribers,
|
|
171
188
|
);
|
|
172
189
|
}
|
|
@@ -177,6 +194,22 @@ export const prepareOfferWatcher = baggage => {
|
|
|
177
194
|
facets.helper.updateStatus({ result: UNPUBLISHED_RESULT });
|
|
178
195
|
}
|
|
179
196
|
},
|
|
197
|
+
/**
|
|
198
|
+
* Called when the offer result promise rejects. The other two watchers
|
|
199
|
+
* are waiting for particular values out of Zoe but they settle at the same time
|
|
200
|
+
* and don't need their own error handling.
|
|
201
|
+
* @param {Error} err
|
|
202
|
+
*/
|
|
203
|
+
handleError(err) {
|
|
204
|
+
const { facets } = this;
|
|
205
|
+
facets.helper.updateStatus({ error: err.toString() });
|
|
206
|
+
const { seatRef } = this.state;
|
|
207
|
+
void E.when(E(seatRef).hasExited(), hasExited => {
|
|
208
|
+
if (!hasExited) {
|
|
209
|
+
void E(seatRef).tryExit();
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
},
|
|
180
213
|
},
|
|
181
214
|
|
|
182
215
|
/** @type {OutcomeWatchers['paymentWatcher']} */
|
|
@@ -193,13 +226,17 @@ export const prepareOfferWatcher = baggage => {
|
|
|
193
226
|
facets.helper.updateStatus({ payouts: amounts });
|
|
194
227
|
},
|
|
195
228
|
/**
|
|
196
|
-
*
|
|
229
|
+
* If promise disconnected, watch again. Or if there's an Error, handle it.
|
|
230
|
+
*
|
|
231
|
+
* @param {Error | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
|
|
197
232
|
* @param {UserSeat} seat
|
|
198
233
|
*/
|
|
199
|
-
onRejected(
|
|
234
|
+
onRejected(reason, seat) {
|
|
200
235
|
const { facets } = this;
|
|
201
|
-
if (isUpgradeDisconnection(
|
|
236
|
+
if (isUpgradeDisconnection(reason)) {
|
|
202
237
|
void watchForPayout(facets, seat);
|
|
238
|
+
} else {
|
|
239
|
+
facets.helper.handleError(reason);
|
|
203
240
|
}
|
|
204
241
|
},
|
|
205
242
|
},
|
|
@@ -211,13 +248,17 @@ export const prepareOfferWatcher = baggage => {
|
|
|
211
248
|
facets.helper.publishResult(result);
|
|
212
249
|
},
|
|
213
250
|
/**
|
|
214
|
-
*
|
|
251
|
+
* If promise disconnected, watch again. Or if there's an Error, handle it.
|
|
252
|
+
*
|
|
253
|
+
* @param {Error | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
|
|
215
254
|
* @param {UserSeat} seat
|
|
216
255
|
*/
|
|
217
|
-
onRejected(
|
|
256
|
+
onRejected(reason, seat) {
|
|
218
257
|
const { facets } = this;
|
|
219
|
-
if (isUpgradeDisconnection(
|
|
258
|
+
if (isUpgradeDisconnection(reason)) {
|
|
220
259
|
void watchForOfferResult(facets, seat);
|
|
260
|
+
} else {
|
|
261
|
+
facets.helper.handleError(reason);
|
|
221
262
|
}
|
|
222
263
|
},
|
|
223
264
|
},
|
|
@@ -230,12 +271,18 @@ export const prepareOfferWatcher = baggage => {
|
|
|
230
271
|
facets.helper.updateStatus({ numWantsSatisfied: numSatisfied });
|
|
231
272
|
},
|
|
232
273
|
/**
|
|
233
|
-
*
|
|
274
|
+
* If promise disconnected, watch again.
|
|
275
|
+
*
|
|
276
|
+
* Errors are handled by the paymentWatcher because numWantsSatisfied()
|
|
277
|
+
* and getPayouts() settle the same (they await the same promise and
|
|
278
|
+
* then synchronously return a local value).
|
|
279
|
+
*
|
|
280
|
+
* @param {Error | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
|
|
234
281
|
* @param {UserSeat} seat
|
|
235
282
|
*/
|
|
236
|
-
onRejected(
|
|
283
|
+
onRejected(reason, seat) {
|
|
237
284
|
const { facets } = this;
|
|
238
|
-
if (isUpgradeDisconnection(
|
|
285
|
+
if (isUpgradeDisconnection(reason)) {
|
|
239
286
|
void watchForNumWants(facets, seat);
|
|
240
287
|
}
|
|
241
288
|
},
|
|
@@ -246,3 +293,4 @@ export const prepareOfferWatcher = baggage => {
|
|
|
246
293
|
harden(prepareOfferWatcher);
|
|
247
294
|
|
|
248
295
|
/** @typedef {ReturnType<typeof prepareOfferWatcher>} MakeOfferWatcher */
|
|
296
|
+
/** @typedef {ReturnType<MakeOfferWatcher>} OfferWatcher */
|
package/src/offers.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {{
|
|
6
6
|
* id: OfferId,
|
|
7
|
-
* invitationSpec: import('./invitations').InvitationSpec,
|
|
7
|
+
* invitationSpec: import('./invitations.js').InvitationSpec,
|
|
8
8
|
* proposal: Proposal,
|
|
9
|
-
* offerArgs?:
|
|
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,CAAA;CAChB;0BAOS,SAAS,GAAG;IACxB,KAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,MAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,kBAAkB,CAAC;IAC/C,OAAS,CAAC,EAAE,mBAAmB,CAAC;CAC7B"}
|
package/src/offers.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {{
|
|
7
7
|
* id: OfferId,
|
|
8
|
-
* invitationSpec: import('./invitations').InvitationSpec,
|
|
8
|
+
* invitationSpec: import('./invitations.js').InvitationSpec,
|
|
9
9
|
* proposal: Proposal,
|
|
10
|
-
* offerArgs?:
|
|
10
|
+
* offerArgs?: any
|
|
11
11
|
* }} OfferSpec
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export const UNPUBLISHED_RESULT = 'UNPUBLISHED';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {
|
|
18
|
+
* @typedef {OfferSpec & {
|
|
19
19
|
* error?: string,
|
|
20
20
|
* numWantsSatisfied?: number
|
|
21
21
|
* result?: unknown | typeof UNPUBLISHED_RESULT,
|
|
@@ -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;IAEA,OAAO,EAA5C;QAAE,SAAS,EAAE,YAAY,CAAA;KAAE;kBAoCrC;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":"
|
|
1
|
+
{"version":3,"file":"upgrade-walletFactory-proposal.d.ts","sourceRoot":"","sources":["upgrade-walletFactory-proposal.js"],"names":[],"mappings":"AAqBO,yOALK,eAAe;IAGkD,OAAO,EAAzE;QAAE,gBAAgB,EAAE,YAAY,GAAG;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;kBAkDnE;AAMM,mGAFK,eAAe,iBAwB1B;AAyBM;;;;;;;EAKN"}
|
|
@@ -8,6 +8,7 @@ console.warn('upgrade-walletFactory-proposal.js module evaluating');
|
|
|
8
8
|
const { Fail } = assert;
|
|
9
9
|
|
|
10
10
|
// vstorage paths under published.*
|
|
11
|
+
const WALLET_STORAGE_PATH_SEGMENT = 'wallet';
|
|
11
12
|
const BOARD_AUX = 'boardAux';
|
|
12
13
|
|
|
13
14
|
const marshalData = makeMarshal(_val => Fail`data only`);
|
|
@@ -20,9 +21,14 @@ const marshalData = makeMarshal(_val => Fail`data only`);
|
|
|
20
21
|
*/
|
|
21
22
|
export const upgradeWalletFactory = async (
|
|
22
23
|
{
|
|
23
|
-
consume: {
|
|
24
|
+
consume: {
|
|
25
|
+
contractKits,
|
|
26
|
+
governedContractKits,
|
|
27
|
+
chainStorage,
|
|
28
|
+
walletBridgeManager: walletBridgeManagerP,
|
|
29
|
+
},
|
|
24
30
|
instance: {
|
|
25
|
-
consume: { walletFactory: wfInstanceP },
|
|
31
|
+
consume: { walletFactory: wfInstanceP, provisionPool: ppInstanceP },
|
|
26
32
|
},
|
|
27
33
|
},
|
|
28
34
|
config,
|
|
@@ -30,20 +36,36 @@ export const upgradeWalletFactory = async (
|
|
|
30
36
|
console.log('upgradeWalletFactory: config', config);
|
|
31
37
|
const { walletFactoryRef } = config.options;
|
|
32
38
|
|
|
33
|
-
console.log('upgradeWalletFactory: awaiting
|
|
34
|
-
const wfInstance
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
// console.log('upgradeWalletFactory: awaiting instances etc.');
|
|
40
|
+
const { wfInstance, ppInstance, walletBridgeManager, storageNode } =
|
|
41
|
+
await allValues({
|
|
42
|
+
wfInstance: wfInstanceP,
|
|
43
|
+
ppInstance: ppInstanceP,
|
|
44
|
+
walletBridgeManager: walletBridgeManagerP,
|
|
45
|
+
// @ts-expect-error chainStorage is only falsy in testing
|
|
46
|
+
storageNode: E(chainStorage).makeChildNode(WALLET_STORAGE_PATH_SEGMENT),
|
|
47
|
+
});
|
|
48
|
+
// console.log('upgradeWalletFactory: awaiting contract kits');
|
|
49
|
+
const { wfKit, ppKit } = await allValues({
|
|
50
|
+
wfKit: E(contractKits).get(wfInstance),
|
|
51
|
+
ppKit: E(governedContractKits).get(ppInstance),
|
|
39
52
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
// console.log('upgradeWalletFactory: awaiting walletReviver');
|
|
54
|
+
const walletReviver = await E(ppKit.creatorFacet).getWalletReviver();
|
|
55
|
+
const newPrivateArgs = harden({
|
|
56
|
+
storageNode,
|
|
57
|
+
walletBridgeManager,
|
|
58
|
+
walletReviver,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
'upgradeWalletFactory: upgrading with newPrivateArgs',
|
|
63
|
+
newPrivateArgs,
|
|
64
|
+
);
|
|
65
|
+
await E(wfKit.adminFacet).upgradeContract(
|
|
66
|
+
walletFactoryRef.bundleID,
|
|
67
|
+
newPrivateArgs,
|
|
68
|
+
);
|
|
47
69
|
console.log('upgradeWalletFactory: done');
|
|
48
70
|
};
|
|
49
71
|
harden(upgradeWalletFactory);
|
|
@@ -68,7 +90,7 @@ export const publishAgoricBrandsDisplayInfo = async ({
|
|
|
68
90
|
await E(node).setValue(JSON.stringify(aux));
|
|
69
91
|
};
|
|
70
92
|
|
|
71
|
-
/** @type {ERef<NameHub>} */
|
|
93
|
+
/** @type {ERef<import('@agoric/vats').NameHub>} */
|
|
72
94
|
const brandHub = E(agoricNames).lookup('brand');
|
|
73
95
|
const brands = await E(brandHub).values();
|
|
74
96
|
// tolerate failure; in particular, for the timer brand
|
|
@@ -82,7 +104,10 @@ const manifest = {
|
|
|
82
104
|
// include rationale for closely-held, high authority capabilities
|
|
83
105
|
consume: {
|
|
84
106
|
contractKits: `to upgrade walletFactory using its adminFacet`,
|
|
85
|
-
|
|
107
|
+
governedContractKits:
|
|
108
|
+
'to get walletReviver from provisionPool.creatorFacet',
|
|
109
|
+
chainStorage: 'to allow walletFactory to (continue) write to vstorage',
|
|
110
|
+
walletBridgeManager: 'to handle bridged cosmos SpendAction messages',
|
|
86
111
|
},
|
|
87
112
|
// widely-shared, low authority instance handles need no rationale
|
|
88
113
|
instance: {
|
package/src/smartWallet.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export const BRAND_TO_PURSES_KEY: "brandToPurses";
|
|
2
|
-
export function prepareSmartWallet(baggage:
|
|
2
|
+
export function prepareSmartWallet(baggage: import("@agoric/vat-data").Baggage, shared: SharedParams): (uniqueWithoutChildNodes: Omit<UniqueParams, "currentStorageNode" | "walletStorageNode"> & {
|
|
3
3
|
walletStorageNode: ERef<StorageNode>;
|
|
4
|
-
}) => Promise<{
|
|
4
|
+
}) => Promise<import("@endo/exo").Guarded<{
|
|
5
5
|
/**
|
|
6
6
|
* Umarshals the actionCapData and delegates to the appropriate action handler.
|
|
7
7
|
*
|
|
8
|
-
* @param {import('@endo/marshal').CapData<string>} actionCapData of type BridgeAction
|
|
8
|
+
* @param {import('@endo/marshal').CapData<string | null>} actionCapData of type BridgeAction
|
|
9
9
|
* @param {boolean} [canSpend]
|
|
10
10
|
* @returns {Promise<void>}
|
|
11
11
|
*/
|
|
12
|
-
handleBridgeAction(actionCapData: import(
|
|
13
|
-
getDepositFacet(): {
|
|
12
|
+
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string | null>, canSpend?: boolean | undefined): Promise<void>;
|
|
13
|
+
getDepositFacet(): import("@endo/exo").Guarded<{
|
|
14
14
|
/**
|
|
15
15
|
* Put the assets from the payment into the appropriate purse.
|
|
16
16
|
*
|
|
@@ -21,8 +21,8 @@ export function prepareSmartWallet(baggage: MapStore<string, unknown>, shared: S
|
|
|
21
21
|
* @throws if there's not yet a purse, though the payment is held to try again when there is
|
|
22
22
|
*/
|
|
23
23
|
receive(payment: Payment): Promise<Amount>;
|
|
24
|
-
}
|
|
25
|
-
getOffersFacet(): {
|
|
24
|
+
}>;
|
|
25
|
+
getOffersFacet(): import("@endo/exo").Guarded<{
|
|
26
26
|
/**
|
|
27
27
|
* Take an offer description provided in capData, augment it with payments and call zoe.offer()
|
|
28
28
|
*
|
|
@@ -39,52 +39,51 @@ export function prepareSmartWallet(baggage: MapStore<string, unknown>, shared: S
|
|
|
39
39
|
* @throws if the seat can't be found or E(seatRef).tryExit() fails.
|
|
40
40
|
*/
|
|
41
41
|
tryExitOffer(offerId: OfferId): Promise<void>;
|
|
42
|
-
}
|
|
42
|
+
}>;
|
|
43
43
|
/** @deprecated use getPublicTopics */
|
|
44
|
-
getCurrentSubscriber(): Subscriber<CurrentWalletRecord>;
|
|
44
|
+
getCurrentSubscriber(): globalThis.Subscriber<CurrentWalletRecord>;
|
|
45
45
|
/** @deprecated use getPublicTopics */
|
|
46
|
-
getUpdatesSubscriber(): Subscriber<UpdateRecord>;
|
|
46
|
+
getUpdatesSubscriber(): globalThis.Subscriber<UpdateRecord>;
|
|
47
47
|
getPublicTopics(): {
|
|
48
48
|
current: {
|
|
49
49
|
description: string;
|
|
50
|
-
subscriber: Subscriber<CurrentWalletRecord>;
|
|
50
|
+
subscriber: globalThis.Subscriber<CurrentWalletRecord>;
|
|
51
51
|
storagePath: Promise<string>;
|
|
52
52
|
};
|
|
53
53
|
updates: {
|
|
54
54
|
description: string;
|
|
55
|
-
subscriber: Subscriber<UpdateRecord>;
|
|
55
|
+
subscriber: globalThis.Subscriber<UpdateRecord>;
|
|
56
56
|
storagePath: Promise<string>;
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
* repair has taken place.
|
|
60
|
+
* To be called once ever per wallet.
|
|
62
61
|
*
|
|
63
62
|
* @param {object} key
|
|
64
63
|
*/
|
|
65
64
|
repairWalletForIncarnation2(key: object): void;
|
|
66
|
-
}
|
|
65
|
+
}>>;
|
|
67
66
|
export type OfferId = number | string;
|
|
68
67
|
export type OfferSpec = {
|
|
69
68
|
id: OfferId;
|
|
70
|
-
invitationSpec: import(
|
|
69
|
+
invitationSpec: import("./invitations").InvitationSpec;
|
|
71
70
|
proposal: Proposal;
|
|
72
|
-
offerArgs?:
|
|
71
|
+
offerArgs?: any;
|
|
73
72
|
};
|
|
74
73
|
export type ExecutorPowers = {
|
|
75
74
|
logger: {
|
|
76
75
|
info: (...args: any[]) => void;
|
|
77
76
|
error: (...args: any[]) => void;
|
|
78
77
|
};
|
|
79
|
-
makeOfferWatcher: import(
|
|
78
|
+
makeOfferWatcher: import("./offerWatcher.js").MakeOfferWatcher;
|
|
80
79
|
invitationFromSpec: ERef<Invitation>;
|
|
81
80
|
};
|
|
82
81
|
export type ExecuteOfferAction = {
|
|
83
|
-
method:
|
|
82
|
+
method: "executeOffer";
|
|
84
83
|
offer: OfferSpec;
|
|
85
84
|
};
|
|
86
85
|
export type TryExitOfferAction = {
|
|
87
|
-
method:
|
|
86
|
+
method: "tryExitOffer";
|
|
88
87
|
offerId: OfferId;
|
|
89
88
|
};
|
|
90
89
|
export type BridgeAction = ExecuteOfferAction | TryExitOfferAction;
|
|
@@ -110,10 +109,10 @@ export type CurrentWalletRecord = {
|
|
|
110
109
|
balance: Amount;
|
|
111
110
|
}>;
|
|
112
111
|
offerToUsedInvitation: Array<[offerId: string, usedInvitation: Amount]>;
|
|
113
|
-
offerToPublicSubscriberPaths: [offerId: string, publicTopics: {
|
|
112
|
+
offerToPublicSubscriberPaths: Array<[offerId: string, publicTopics: {
|
|
114
113
|
[subscriberName: string]: string;
|
|
115
|
-
}]
|
|
116
|
-
liveOffers: Array<[OfferId, import(
|
|
114
|
+
}]>;
|
|
115
|
+
liveOffers: Array<[OfferId, import("./offers.js").OfferStatus]>;
|
|
117
116
|
};
|
|
118
117
|
/**
|
|
119
118
|
* Record of an update to the state of this wallet.
|
|
@@ -128,13 +127,13 @@ export type CurrentWalletRecord = {
|
|
|
128
127
|
* the amount suffices.
|
|
129
128
|
*/
|
|
130
129
|
export type UpdateRecord = {
|
|
131
|
-
updated:
|
|
132
|
-
status: import(
|
|
130
|
+
updated: "offerStatus";
|
|
131
|
+
status: import("./offers.js").OfferStatus;
|
|
133
132
|
} | {
|
|
134
|
-
updated:
|
|
133
|
+
updated: "balance";
|
|
135
134
|
currentAmount: Amount;
|
|
136
135
|
} | {
|
|
137
|
-
updated:
|
|
136
|
+
updated: "walletAction";
|
|
138
137
|
status: {
|
|
139
138
|
error: string;
|
|
140
139
|
};
|
|
@@ -146,21 +145,21 @@ export type BrandDescriptor = {
|
|
|
146
145
|
brand: Brand;
|
|
147
146
|
displayInfo: DisplayInfo;
|
|
148
147
|
issuer: Issuer;
|
|
149
|
-
petname: import(
|
|
148
|
+
petname: import("./types.js").Petname;
|
|
150
149
|
};
|
|
151
150
|
export type UniqueParams = {
|
|
152
151
|
address: string;
|
|
153
|
-
bank: ERef<import(
|
|
152
|
+
bank: ERef<import("@agoric/vats/src/vat-bank.js").Bank>;
|
|
154
153
|
currentStorageNode: StorageNode;
|
|
155
|
-
invitationPurse: Purse<
|
|
154
|
+
invitationPurse: Purse<"set", InvitationDetails>;
|
|
156
155
|
walletStorageNode: StorageNode;
|
|
157
156
|
};
|
|
158
|
-
export type BrandDescriptorRegistry = Pick<MapStore<Brand, BrandDescriptor>,
|
|
157
|
+
export type BrandDescriptorRegistry = Pick<MapStore<Brand, BrandDescriptor>, "has" | "get" | "values">;
|
|
159
158
|
export type SharedParams = {
|
|
160
|
-
agoricNames: ERef<import(
|
|
159
|
+
agoricNames: ERef<import("@agoric/vats").NameHub>;
|
|
161
160
|
registry: BrandDescriptorRegistry;
|
|
162
|
-
invitationIssuer: Issuer<
|
|
163
|
-
invitationBrand: Brand<
|
|
161
|
+
invitationIssuer: Issuer<"set">;
|
|
162
|
+
invitationBrand: Brand<"set">;
|
|
164
163
|
invitationDisplayInfo: DisplayInfo;
|
|
165
164
|
publicMarshaller: Marshaller;
|
|
166
165
|
zoe: ERef<ZoeService>;
|
|
@@ -175,13 +174,13 @@ export type SharedParams = {
|
|
|
175
174
|
export type State = ImmutableState & MutableState;
|
|
176
175
|
export type ImmutableState = Readonly<UniqueParams & {
|
|
177
176
|
paymentQueues: MapStore<Brand, Array<Payment>>;
|
|
178
|
-
offerToInvitationMakers: MapStore<string, import(
|
|
177
|
+
offerToInvitationMakers: MapStore<string, import("./types.js").InvitationMakers>;
|
|
179
178
|
offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
|
|
180
|
-
offerToUsedInvitation: MapStore<string, Amount
|
|
179
|
+
offerToUsedInvitation: MapStore<string, Amount<"set">>;
|
|
181
180
|
purseBalances: MapStore<Purse, Amount>;
|
|
182
|
-
updateRecorderKit: import(
|
|
183
|
-
currentRecorderKit: import(
|
|
184
|
-
liveOffers: MapStore<OfferId, import(
|
|
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>;
|
|
185
184
|
liveOfferSeats: MapStore<OfferId, UserSeat<unknown>>;
|
|
186
185
|
liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>>;
|
|
187
186
|
}>;
|
package/src/smartWallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartWallet.d.ts","sourceRoot":"","sources":["smartWallet.js"],"names":[],"mappings":"AAiOA,kDAAmD;AAiB5C
|
|
1
|
+
{"version":3,"file":"smartWallet.d.ts","sourceRoot":"","sources":["smartWallet.js"],"names":[],"mappings":"AAiOA,kDAAmD;AAiB5C,4CAHI,OAAO,kBAAkB,EAAE,OAAO,UAClC,YAAY,6BA87BV,IAAI,CAAC,YAAY,EAAE,oBAAoB,GAAG,mBAAmB,CAAC,GAAG;IAAC,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;CAAC;IAvH5G;;;;;;OAMG;sCAHQ,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,mCAE5C,OAAO,CAAC,IAAI,CAAC;;QA3Q1B;;;;;;;;WAQG;yBAHQ,OAAO,GACL,OAAO,CAAC,MAAM,CAAC;;;QA0H5B;;;;;;WAMG;gCAHQ,SAAS,GACP,OAAO,CAAC,IAAI,CAAC;QAwG1B;;;;;;WAMG;8BAHQ,OAAO,GACL,OAAO,CAAC,IAAI,CAAC;;IAgF1B,sCAAsC;;IAKtC,sCAAsC;;;;;;;;;;;;;;IAuBtC;;;;OAIG;qCADQ,MAAM;IA+CxB;sBAzoCa,MAAM,GAAG,MAAM;wBAGhB;IACZ,EAAM,EAAE,OAAO,C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