@agoric/smart-wallet 0.5.4-other-dev-fbe72e7.0.fbe72e7 → 0.5.4-other-dev-d15096d.0.d15096d
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 +15 -15
- package/src/index.js +3 -3
- package/src/invitations.d.ts +7 -3
- package/src/invitations.d.ts.map +1 -1
- package/src/invitations.js +12 -8
- package/src/offerWatcher.d.ts +5 -3
- package/src/offerWatcher.d.ts.map +1 -1
- package/src/offerWatcher.js +8 -8
- package/src/offers.d.ts +4 -2
- package/src/offers.d.ts.map +1 -1
- package/src/offers.js +2 -1
- package/src/proposals/upgrade-wallet-factory2-proposal.js +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.js +7 -2
- package/src/smartWallet.d.ts +25 -15
- package/src/smartWallet.d.ts.map +1 -1
- package/src/smartWallet.js +70 -33
- package/src/typeGuards.js +1 -1
- package/src/utils.d.ts +17 -7
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +12 -8
- package/src/walletFactory.d.ts +25 -17
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +33 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/smart-wallet",
|
|
3
|
-
"version": "0.5.4-other-dev-
|
|
3
|
+
"version": "0.5.4-other-dev-d15096d.0.d15096d",
|
|
4
4
|
"description": "Wallet contract",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"lint:eslint": "yarn run -T eslint ."
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@agoric/casting": "0.4.3-other-dev-
|
|
22
|
-
"@agoric/cosmic-proto": "0.4.1-other-dev-
|
|
23
|
-
"@agoric/swingset-vat": "0.32.3-other-dev-
|
|
21
|
+
"@agoric/casting": "0.4.3-other-dev-d15096d.0.d15096d",
|
|
22
|
+
"@agoric/cosmic-proto": "0.4.1-other-dev-d15096d.0.d15096d",
|
|
23
|
+
"@agoric/swingset-vat": "0.32.3-other-dev-d15096d.0.d15096d",
|
|
24
24
|
"@endo/bundle-source": "^4.1.2",
|
|
25
25
|
"@endo/captp": "^4.4.8",
|
|
26
26
|
"@endo/init": "^1.1.12",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"import-meta-resolve": "^4.1.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agoric/ertp": "0.16.3-other-dev-
|
|
32
|
-
"@agoric/internal": "0.3.3-other-dev-
|
|
33
|
-
"@agoric/notifier": "0.6.3-other-dev-
|
|
34
|
-
"@agoric/store": "0.9.3-other-dev-
|
|
35
|
-
"@agoric/vat-data": "0.5.3-other-dev-
|
|
36
|
-
"@agoric/vats": "0.15.2-other-dev-
|
|
37
|
-
"@agoric/vow": "0.1.1-other-dev-
|
|
38
|
-
"@agoric/zoe": "0.26.3-other-dev-
|
|
39
|
-
"@agoric/zone": "0.2.3-other-dev-
|
|
31
|
+
"@agoric/ertp": "0.16.3-other-dev-d15096d.0.d15096d",
|
|
32
|
+
"@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
33
|
+
"@agoric/notifier": "0.6.3-other-dev-d15096d.0.d15096d",
|
|
34
|
+
"@agoric/store": "0.9.3-other-dev-d15096d.0.d15096d",
|
|
35
|
+
"@agoric/vat-data": "0.5.3-other-dev-d15096d.0.d15096d",
|
|
36
|
+
"@agoric/vats": "0.15.2-other-dev-d15096d.0.d15096d",
|
|
37
|
+
"@agoric/vow": "0.1.1-other-dev-d15096d.0.d15096d",
|
|
38
|
+
"@agoric/zoe": "0.26.3-other-dev-d15096d.0.d15096d",
|
|
39
|
+
"@agoric/zone": "0.2.3-other-dev-d15096d.0.d15096d",
|
|
40
40
|
"@endo/errors": "^1.2.13",
|
|
41
41
|
"@endo/eventual-send": "^1.3.4",
|
|
42
42
|
"@endo/far": "^1.1.14",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
74
|
"typeCoverage": {
|
|
75
|
-
"atLeast":
|
|
75
|
+
"atLeast": 93.68
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": "^20.9 || ^22.11"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
|
|
81
81
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="@agoric/internal/exported" />
|
|
2
|
-
/// <reference types="@agoric/ertp/exported" />
|
|
3
|
-
/// <reference types="@agoric/zoe/exported" />
|
|
1
|
+
/// <reference types="@agoric/internal/exported.js" />
|
|
2
|
+
/// <reference types="@agoric/ertp/exported.js" />
|
|
3
|
+
/// <reference types="@agoric/zoe/exported.js" />
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line import/export
|
|
6
6
|
export * from './types-index.js'; // no named exports
|
package/src/invitations.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function makeInvitationsHelper(zoe: ERef<ZoeService>, agoricNames: ERef<
|
|
1
|
+
export function makeInvitationsHelper(zoe: ERef<ZoeService>, agoricNames: ERef<NameHub>, invitationBrand: Brand<"set">, invitationsPurse: Purse<"set", InvitationDetails>, getInvitationContinuation: (fromOfferId: string) => InvitationMakers): (spec: InvitationSpec) => ERef<Invitation>;
|
|
2
2
|
/**
|
|
3
3
|
* Specify how to produce an invitation. See each type in the union for details.
|
|
4
4
|
*/
|
|
@@ -41,9 +41,13 @@ export type PurseInvitationSpec = {
|
|
|
41
41
|
*/
|
|
42
42
|
export type ContinuingInvitationSpec = {
|
|
43
43
|
source: "continuing";
|
|
44
|
-
previousOffer:
|
|
44
|
+
previousOffer: OfferId;
|
|
45
45
|
invitationMakerName: string;
|
|
46
46
|
invitationArgs?: any[];
|
|
47
47
|
};
|
|
48
|
-
export type InvitationsPurseQuery = Pick<
|
|
48
|
+
export type InvitationsPurseQuery = Pick<InvitationDetails, "description" | "instance">;
|
|
49
|
+
import type { NameHub } from '@agoric/vats';
|
|
50
|
+
import type { InvitationDetails } from '@agoric/zoe';
|
|
51
|
+
import type { InvitationMakers } from './types.js';
|
|
52
|
+
import type { OfferId } from './offers.js';
|
|
49
53
|
//# sourceMappingURL=invitations.d.ts.map
|
package/src/invitations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["invitations.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["invitations.js"],"names":[],"mappings":"AA8EO,2CANI,IAAI,CAAC,UAAU,CAAC,eAChB,IAAI,CAAC,OAAO,CAAC,mBACb,KAAK,CAAC,KAAK,CAAC,oBACZ,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,6BAC/B,CAAC,WAAW,EAAE,MAAM,KAAK,gBAAgB,UAoFhC,cAAc,KAAK,IAAI,CAAC,UAAU,CAAC,CAgBtD;;;;6BA9JY,4BAA4B,GAClC,sBAAsB,GACtB,mBAAmB,GACnB,wBAAwB;;;;;;;;2CAKlB;IACR,MAAM,EAAE,gBAAgB,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;CACtD;;;;qCAQS;IACR,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;CACxB;;;;;;;kCAGS;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;uCAOS;IACR,MAAM,EAAE,YAAY,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;CACxB;oCAMS,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,UAAU,CAAC;6BA1DtC,cAAc;uCADJ,aAAa;sCAEd,YAAY;6BAHrB,aAAa"}
|
package/src/invitations.js
CHANGED
|
@@ -5,6 +5,13 @@ import { Fail } from '@endo/errors';
|
|
|
5
5
|
import { E } from '@endo/far';
|
|
6
6
|
import { shape } from './typeGuards.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @import {OfferId} from './offers.js';
|
|
10
|
+
* @import {InvitationDetails} from '@agoric/zoe';
|
|
11
|
+
* @import {NameHub} from '@agoric/vats';
|
|
12
|
+
* @import {InvitationMakers} from './types.js';
|
|
13
|
+
*/
|
|
14
|
+
|
|
8
15
|
// A safety limit
|
|
9
16
|
const MAX_PIPE_LENGTH = 2;
|
|
10
17
|
|
|
@@ -50,7 +57,7 @@ const MAX_PIPE_LENGTH = 2;
|
|
|
50
57
|
*
|
|
51
58
|
* @typedef {{
|
|
52
59
|
* source: 'continuing';
|
|
53
|
-
* previousOffer:
|
|
60
|
+
* previousOffer: OfferId;
|
|
54
61
|
* invitationMakerName: string;
|
|
55
62
|
* invitationArgs?: any[];
|
|
56
63
|
* }} ContinuingInvitationSpec
|
|
@@ -59,18 +66,15 @@ const MAX_PIPE_LENGTH = 2;
|
|
|
59
66
|
*/
|
|
60
67
|
|
|
61
68
|
/**
|
|
62
|
-
* @typedef {Pick<
|
|
63
|
-
* import('@agoric/zoe').InvitationDetails,
|
|
64
|
-
* 'description' | 'instance'
|
|
65
|
-
* >} InvitationsPurseQuery
|
|
69
|
+
* @typedef {Pick<InvitationDetails, 'description' | 'instance'>} InvitationsPurseQuery
|
|
66
70
|
*/
|
|
67
71
|
|
|
68
72
|
/**
|
|
69
73
|
* @param {ERef<ZoeService>} zoe
|
|
70
|
-
* @param {ERef<
|
|
74
|
+
* @param {ERef<NameHub>} agoricNames
|
|
71
75
|
* @param {Brand<'set'>} invitationBrand
|
|
72
|
-
* @param {Purse<'set',
|
|
73
|
-
* @param {(fromOfferId: string) =>
|
|
76
|
+
* @param {Purse<'set', InvitationDetails>} invitationsPurse
|
|
77
|
+
* @param {(fromOfferId: string) => InvitationMakers} getInvitationContinuation
|
|
74
78
|
*/
|
|
75
79
|
export const makeInvitationsHelper = (
|
|
76
80
|
zoe,
|
package/src/offerWatcher.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export function prepareOfferWatcher(baggage: Baggage, vowTools: VowTools): (wall
|
|
|
10
10
|
/**
|
|
11
11
|
* @param {string} offerId
|
|
12
12
|
* @param {Amount<'set'>} invitationAmount
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {InvitationMakers} invitationMakers
|
|
14
|
+
* @param {PublicSubscribers} publicSubscribers
|
|
15
15
|
*/
|
|
16
|
-
onNewContinuingOffer(offerId: string, invitationAmount: Amount<"set">, invitationMakers:
|
|
16
|
+
onNewContinuingOffer(offerId: string, invitationAmount: Amount<"set">, invitationMakers: InvitationMakers, publicSubscribers: PublicSubscribers): void;
|
|
17
17
|
/** @param {Passable | ContinuingOfferResult} result */
|
|
18
18
|
publishResult(result: Passable | ContinuingOfferResult): void;
|
|
19
19
|
/**
|
|
@@ -47,6 +47,8 @@ import type { VowTools } from '@agoric/vow';
|
|
|
47
47
|
import type { UserSeat } from '@agoric/zoe';
|
|
48
48
|
import type { Baggage } from '@agoric/vat-data';
|
|
49
49
|
import type { OfferSpec } from './offers.js';
|
|
50
|
+
import type { InvitationMakers } from './types.js';
|
|
51
|
+
import type { PublicSubscribers } from './types.js';
|
|
50
52
|
import type { Passable } from '@endo/pass-style';
|
|
51
53
|
import type { ContinuingOfferResult } from './types.js';
|
|
52
54
|
import type { PromiseWatcher } from '@agoric/swingset-liveslots';
|
|
@@ -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":"AA4EO,iDADK,QAAQ,cAKP,eAAe,QACf,QAAQ,oBAiBpB;AAmCM,6CAHI,OAAO,YACP,QAAQ;aAWO,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC;;;QAgBvD;;WAEG;yCADQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;QAQlC;;;;;WAKG;sCAJQ,MAAM,oBACN,MAAM,CAAC,KAAK,CAAC,oBACb,gBAAgB,qBAChB,iBAAiB;QAkB5B,uDAAuD;8BAA3C,QAAQ,GAAG,qBAAqB;QAoC5C;;;;;;WAMG;yBADQ,KAAK;;IAclB,gDAAgD;oBAArC,eAAe,CAAC,gBAAgB,CAAC;IA8B5C,+CAA+C;mBAApC,eAAe,CAAC,eAAe,CAAC;IAsC3C,iDAAiD;qBAAtC,eAAe,CAAC,iBAAiB,CAAC;GA0BlD;;;;gCAtTkB,CAAC,oBACP,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;8BAI7B;IACR,aAAa,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC7C,eAAe,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC7C,cAAc,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;CAC5D;+BAgTU,UAAU,CAAC,OAAO,mBAAmB,CAAC;2BACtC,UAAU,CAAC,gBAAgB,CAAC;8BAlUV,aAAa;8BAC2B,aAAa;6BAF3D,kBAAkB;+BAJhB,aAAa;sCAON,YAAY;uCACX,YAAY;8BANrB,kBAAkB;2CADL,YAAY;oCAEnB,4BAA4B;2CAGW,aAAa"}
|
package/src/offerWatcher.js
CHANGED
|
@@ -20,6 +20,9 @@ import { UNPUBLISHED_RESULT } from './offers.js';
|
|
|
20
20
|
* @import {Baggage} from '@agoric/vat-data';
|
|
21
21
|
* @import {Vow, VowTools} from '@agoric/vow';
|
|
22
22
|
* @import {PaymentPKeywordRecord, Proposal, UserSeat, ZoeService} from '@agoric/zoe';
|
|
23
|
+
* @import {InvitationMakers} from './types.js';
|
|
24
|
+
* @import {PublicSubscribers} from './types.js';
|
|
25
|
+
* @import {UpgradeDisconnection} from '@agoric/internal/src/upgrade-api.js';
|
|
23
26
|
*/
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -165,8 +168,8 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
|
|
|
165
168
|
/**
|
|
166
169
|
* @param {string} offerId
|
|
167
170
|
* @param {Amount<'set'>} invitationAmount
|
|
168
|
-
* @param {
|
|
169
|
-
* @param {
|
|
171
|
+
* @param {InvitationMakers} invitationMakers
|
|
172
|
+
* @param {PublicSubscribers} publicSubscribers
|
|
170
173
|
*/
|
|
171
174
|
onNewContinuingOffer(
|
|
172
175
|
offerId,
|
|
@@ -256,8 +259,7 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
|
|
|
256
259
|
* If promise disconnected, watch again. Or if there's an Error, handle
|
|
257
260
|
* it.
|
|
258
261
|
*
|
|
259
|
-
* @param {Error
|
|
260
|
-
* | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
|
|
262
|
+
* @param {Error | UpgradeDisconnection} reason
|
|
261
263
|
* @param {UserSeat} seat
|
|
262
264
|
*/
|
|
263
265
|
onRejected(reason, seat) {
|
|
@@ -293,8 +295,7 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
|
|
|
293
295
|
* If promise disconnected, watch again. Or if there's an Error, handle
|
|
294
296
|
* it.
|
|
295
297
|
*
|
|
296
|
-
* @param {Error
|
|
297
|
-
* | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
|
|
298
|
+
* @param {Error | UpgradeDisconnection} reason
|
|
298
299
|
* @param {UserSeat} seat
|
|
299
300
|
*/
|
|
300
301
|
onRejected(reason, seat) {
|
|
@@ -323,8 +324,7 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
|
|
|
323
324
|
* and getPayouts() settle the same (they await the same promise and
|
|
324
325
|
* then synchronously return a local value).
|
|
325
326
|
*
|
|
326
|
-
* @param {Error
|
|
327
|
-
* | import('@agoric/internal/src/upgrade-api.js').UpgradeDisconnection} reason
|
|
327
|
+
* @param {Error | UpgradeDisconnection} reason
|
|
328
328
|
* @param {UserSeat} seat
|
|
329
329
|
*/
|
|
330
330
|
onRejected(reason, seat) {
|
package/src/offers.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import {Proposal} from '@agoric/zoe';
|
|
3
3
|
* @import {Passable} from '@endo/pass-style';
|
|
4
|
+
* @import {InvitationSpec} from './invitations.js';
|
|
4
5
|
*/
|
|
5
6
|
/**
|
|
6
7
|
* @typedef {number | string} OfferId
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
/**
|
|
25
26
|
* @typedef {{
|
|
26
27
|
* id: OfferId;
|
|
27
|
-
* invitationSpec:
|
|
28
|
+
* invitationSpec: InvitationSpec;
|
|
28
29
|
* proposal: Proposal;
|
|
29
30
|
* offerArgs?: any;
|
|
30
31
|
* saveResult?: ResultPlan;
|
|
@@ -62,7 +63,7 @@ export type InvokeEntryMessage = {
|
|
|
62
63
|
*/
|
|
63
64
|
export type OfferSpec = {
|
|
64
65
|
id: OfferId;
|
|
65
|
-
invitationSpec:
|
|
66
|
+
invitationSpec: InvitationSpec;
|
|
66
67
|
proposal: Proposal;
|
|
67
68
|
offerArgs?: any;
|
|
68
69
|
saveResult?: ResultPlan;
|
|
@@ -77,5 +78,6 @@ export type OfferStatus = OfferSpec & {
|
|
|
77
78
|
payouts?: AmountKeywordRecord;
|
|
78
79
|
};
|
|
79
80
|
import type { Passable } from '@endo/pass-style';
|
|
81
|
+
import type { InvitationSpec } from './invitations.js';
|
|
80
82
|
import type { Proposal } from '@agoric/zoe';
|
|
81
83
|
//# sourceMappingURL=offers.d.ts.map
|
package/src/offers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["offers.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["offers.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AAEH,kEAAkE;AAClE,iCAAkC,aAAa,CAAC;sBAnCnC,MAAM,GAAG,MAAM;;;;;UAKd,MAAM;;;;;;;;iCAOP;IACR,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;;;;;;wBAIS;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;0BAUS,SAAS,GAAG;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EACH,OAAO,GACP,OAAO,kBAAkB,GACzB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;8BAnDuB,kBAAkB;oCACZ,kBAAkB;8BAFxB,aAAa"}
|
package/src/offers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @import {Proposal} from '@agoric/zoe';
|
|
3
3
|
* @import {Passable} from '@endo/pass-style';
|
|
4
|
+
* @import {InvitationSpec} from './invitations.js';
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
/**
|
|
29
30
|
* @typedef {{
|
|
30
31
|
* id: OfferId;
|
|
31
|
-
* invitationSpec:
|
|
32
|
+
* invitationSpec: InvitationSpec;
|
|
32
33
|
* proposal: Proposal;
|
|
33
34
|
* offerArgs?: any;
|
|
34
35
|
* saveResult?: ResultPlan;
|
|
@@ -4,6 +4,11 @@ import { E } from '@endo/far';
|
|
|
4
4
|
import { makeMarshal } from '@endo/marshal';
|
|
5
5
|
import { allValues } from '@agoric/internal';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @import {NameHub} from '@agoric/vats';
|
|
9
|
+
* @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js';
|
|
10
|
+
*/
|
|
11
|
+
|
|
7
12
|
console.warn('upgrade-walletFactory-proposal.js module evaluating');
|
|
8
13
|
|
|
9
14
|
// vstorage paths under published.*
|
|
@@ -88,7 +93,7 @@ export const publishAgoricBrandsDisplayInfo = async ({
|
|
|
88
93
|
await E(node).setValue(JSON.stringify(aux));
|
|
89
94
|
};
|
|
90
95
|
|
|
91
|
-
/** @type {ERef<
|
|
96
|
+
/** @type {ERef<NameHub>} */
|
|
92
97
|
const brandHub = E(agoricNames).lookup('brand');
|
|
93
98
|
const brands = await E(brandHub).values();
|
|
94
99
|
// tolerate failure; in particular, for the timer brand
|
|
@@ -96,7 +101,7 @@ export const publishAgoricBrandsDisplayInfo = async ({
|
|
|
96
101
|
};
|
|
97
102
|
harden(publishAgoricBrandsDisplayInfo);
|
|
98
103
|
|
|
99
|
-
/** @type {
|
|
104
|
+
/** @type {BootstrapManifest} */
|
|
100
105
|
const manifest = {
|
|
101
106
|
[upgradeWalletFactory.name]: {
|
|
102
107
|
// include rationale for closely-held, high authority capabilities
|
package/src/smartWallet.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export const BRAND_TO_PURSES_KEY: "brandToPurses";
|
|
2
|
-
export function prepareSmartWallet(baggage:
|
|
3
|
-
walletStorageNode:
|
|
2
|
+
export function prepareSmartWallet(baggage: Baggage, shared: SharedParams): (uniqueWithoutChildNodes: Omit<UniqueParams, "currentStorageNode" | "walletStorageNode"> & {
|
|
3
|
+
walletStorageNode: ERemote<StorageNode>;
|
|
4
4
|
}) => Promise<import("@endo/exo").Guarded<{
|
|
5
5
|
/**
|
|
6
6
|
* Umarshals the actionCapData and delegates to the appropriate action
|
|
7
7
|
* handler.
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
10
|
-
* of type BridgeAction
|
|
9
|
+
* @param {CapData<string | null>} actionCapData of type BridgeAction
|
|
11
10
|
* @param {boolean} [canSpend]
|
|
12
11
|
* @returns {Promise<void>}
|
|
13
12
|
*/
|
|
14
|
-
handleBridgeAction(actionCapData:
|
|
13
|
+
handleBridgeAction(actionCapData: CapData<string | null>, canSpend?: boolean): Promise<void>;
|
|
15
14
|
getDepositFacet(): import("@endo/exo").Guarded<{
|
|
16
15
|
/**
|
|
17
16
|
* Put the assets from the payment into the appropriate purse.
|
|
@@ -74,7 +73,7 @@ export type ExecutorPowers = {
|
|
|
74
73
|
info: (...args: any[]) => void;
|
|
75
74
|
error: (...args: any[]) => void;
|
|
76
75
|
};
|
|
77
|
-
makeOfferWatcher:
|
|
76
|
+
makeOfferWatcher: MakeOfferWatcher;
|
|
78
77
|
invitationFromSpec: ERef<Invitation>;
|
|
79
78
|
};
|
|
80
79
|
export type ExecuteOfferAction = {
|
|
@@ -171,23 +170,23 @@ export type BrandDescriptor = {
|
|
|
171
170
|
brand: Brand;
|
|
172
171
|
displayInfo: DisplayInfo;
|
|
173
172
|
issuer: Issuer;
|
|
174
|
-
petname:
|
|
173
|
+
petname: Petname;
|
|
175
174
|
};
|
|
176
175
|
export type UniqueParams = {
|
|
177
176
|
address: string;
|
|
178
|
-
bank: ERef<
|
|
179
|
-
currentStorageNode: StorageNode
|
|
177
|
+
bank: ERef<Bank>;
|
|
178
|
+
currentStorageNode: Remote<StorageNode>;
|
|
180
179
|
invitationPurse: Purse<"set", InvitationDetails>;
|
|
181
|
-
walletStorageNode: StorageNode
|
|
180
|
+
walletStorageNode: Remote<StorageNode>;
|
|
182
181
|
};
|
|
183
182
|
export type BrandDescriptorRegistry = Pick<MapStore<Brand, BrandDescriptor>, "has" | "get" | "values">;
|
|
184
183
|
export type SharedParams = {
|
|
185
|
-
agoricNames: ERef<
|
|
184
|
+
agoricNames: ERef<NameHub>;
|
|
186
185
|
registry: BrandDescriptorRegistry;
|
|
187
186
|
invitationIssuer: Issuer<"set">;
|
|
188
187
|
invitationBrand: Brand<"set">;
|
|
189
188
|
invitationDisplayInfo: DisplayInfo;
|
|
190
|
-
publicMarshaller:
|
|
189
|
+
publicMarshaller: ERemote<EMarshaller>;
|
|
191
190
|
zoe: ERef<ZoeService>;
|
|
192
191
|
};
|
|
193
192
|
/**
|
|
@@ -202,12 +201,12 @@ export type SharedParams = {
|
|
|
202
201
|
export type State = ImmutableState & MutableState;
|
|
203
202
|
export type ImmutableState = Readonly<UniqueParams & {
|
|
204
203
|
paymentQueues: MapStore<Brand, Payment[]>;
|
|
205
|
-
offerToInvitationMakers: MapStore<string,
|
|
204
|
+
offerToInvitationMakers: MapStore<string, InvitationMakers>;
|
|
206
205
|
offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
|
|
207
206
|
offerToUsedInvitation: MapStore<string, Amount<"set">>;
|
|
208
207
|
purseBalances: MapStore<Purse, Amount>;
|
|
209
|
-
updateRecorderKit:
|
|
210
|
-
currentRecorderKit:
|
|
208
|
+
updateRecorderKit: RecorderKit<UpdateRecord>;
|
|
209
|
+
currentRecorderKit: RecorderKit<CurrentWalletRecord>;
|
|
211
210
|
liveOffers: MapStore<OfferId, OfferStatus>;
|
|
212
211
|
liveOfferSeats: MapStore<OfferId, UserSeat<unknown>>;
|
|
213
212
|
liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>>;
|
|
@@ -218,17 +217,28 @@ export type PurseRecord = BrandDescriptor & {
|
|
|
218
217
|
};
|
|
219
218
|
export type MutableState = {};
|
|
220
219
|
export type SmartWallet = EReturn<EReturn<typeof prepareSmartWallet>>;
|
|
220
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
221
|
+
import type { ERemote } from '@agoric/internal';
|
|
222
|
+
import type { CapData } from '@endo/marshal';
|
|
221
223
|
import type { Payment } from '@agoric/ertp';
|
|
222
224
|
import type { Amount } from '@agoric/ertp';
|
|
223
225
|
import type { InvokeEntryMessage } from './offers.js';
|
|
224
226
|
import type { OfferSpec } from './offers.js';
|
|
225
227
|
import type { OfferId } from './offers.js';
|
|
228
|
+
import type { MakeOfferWatcher } from './offerWatcher.js';
|
|
226
229
|
import type { Brand } from '@agoric/ertp';
|
|
227
230
|
import type { OfferStatus } from './offers.js';
|
|
228
231
|
import type { Issuer } from '@agoric/ertp';
|
|
232
|
+
import type { Petname } from './types.js';
|
|
233
|
+
import type { Bank } from '@agoric/vats/src/vat-bank.js';
|
|
234
|
+
import type { Remote } from '@agoric/internal';
|
|
229
235
|
import type { InvitationDetails } from '@agoric/zoe';
|
|
230
236
|
import type { Purse } from '@agoric/ertp';
|
|
231
237
|
import type { MapStore } from '@agoric/store';
|
|
238
|
+
import type { NameHub } from '@agoric/vats';
|
|
239
|
+
import type { EMarshaller } from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
240
|
+
import type { InvitationMakers } from './types.js';
|
|
241
|
+
import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
232
242
|
import type { UserSeat } from '@agoric/zoe';
|
|
233
243
|
import type { EReturn } from '@endo/far';
|
|
234
244
|
//# sourceMappingURL=smartWallet.d.ts.map
|
package/src/smartWallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartWallet.d.ts","sourceRoot":"","sources":["smartWallet.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartWallet.d.ts","sourceRoot":"","sources":["smartWallet.js"],"names":[],"mappings":"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"}
|
package/src/smartWallet.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
StorageNodeShape,
|
|
16
16
|
} from '@agoric/internal';
|
|
17
17
|
import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
|
|
18
|
-
import { M, mustMatch } from '@agoric/store';
|
|
18
|
+
import { M, matches, mustMatch } from '@agoric/store';
|
|
19
19
|
import {
|
|
20
20
|
appendToStoredArray,
|
|
21
21
|
provideLazy,
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
import {
|
|
37
37
|
AmountKeywordRecordShape,
|
|
38
38
|
PaymentPKeywordRecordShape,
|
|
39
|
+
InvitationElementShape,
|
|
39
40
|
} from '@agoric/zoe/src/typeGuards.js';
|
|
40
41
|
import { prepareVowTools } from '@agoric/vow';
|
|
41
42
|
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
@@ -46,12 +47,23 @@ import { objectMapStoragePath } from './utils.js';
|
|
|
46
47
|
import { prepareOfferWatcher, makeWatchOfferOutcomes } from './offerWatcher.js';
|
|
47
48
|
|
|
48
49
|
/**
|
|
50
|
+
* @import {ERemote, Remote} from '@agoric/internal';
|
|
51
|
+
* @import {EMarshaller} from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
49
52
|
* @import {Amount, Brand, Issuer, Payment, Purse} from '@agoric/ertp';
|
|
50
53
|
* @import {WeakMapStore, MapStore} from '@agoric/store'
|
|
51
|
-
* @import {InvitationDetails, PaymentPKeywordRecord, Proposal, UserSeat} from '@agoric/zoe';
|
|
54
|
+
* @import {InvitationAmount, InvitationDetails, PaymentPKeywordRecord, Proposal, UserSeat} from '@agoric/zoe';
|
|
52
55
|
* @import {CopyRecord} from '@endo/pass-style';
|
|
53
56
|
* @import {EReturn} from '@endo/far';
|
|
54
57
|
* @import {OfferId, OfferStatus, OfferSpec, InvokeEntryMessage, ResultPlan} from './offers.js';
|
|
58
|
+
* @import {MakeOfferWatcher} from './offerWatcher.js';
|
|
59
|
+
* @import {Petname} from './types.js';
|
|
60
|
+
* @import {Bank} from '@agoric/vats/src/vat-bank.js';
|
|
61
|
+
* @import {NameHub} from '@agoric/vats';
|
|
62
|
+
* @import {InvitationMakers} from './types.js';
|
|
63
|
+
* @import {RecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
64
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
65
|
+
* @import {PublicSubscribers} from './types.js';
|
|
66
|
+
* @import {CapData} from '@endo/marshal';
|
|
55
67
|
*/
|
|
56
68
|
|
|
57
69
|
const trace = makeTracer('SmrtWlt');
|
|
@@ -67,7 +79,7 @@ const trace = makeTracer('SmrtWlt');
|
|
|
67
79
|
* info: (...args: any[]) => void;
|
|
68
80
|
* error: (...args: any[]) => void;
|
|
69
81
|
* };
|
|
70
|
-
* makeOfferWatcher:
|
|
82
|
+
* makeOfferWatcher: MakeOfferWatcher;
|
|
71
83
|
* invitationFromSpec: ERef<Invitation>;
|
|
72
84
|
* }} ExecutorPowers
|
|
73
85
|
*/
|
|
@@ -159,7 +171,7 @@ const trace = makeTracer('SmrtWlt');
|
|
|
159
171
|
* brand: Brand;
|
|
160
172
|
* displayInfo: DisplayInfo;
|
|
161
173
|
* issuer: Issuer;
|
|
162
|
-
* petname:
|
|
174
|
+
* petname: Petname;
|
|
163
175
|
* }} BrandDescriptor
|
|
164
176
|
* For use by clients to describe brands to users. Includes `displayInfo` to
|
|
165
177
|
* save a remote call.
|
|
@@ -168,10 +180,10 @@ const trace = makeTracer('SmrtWlt');
|
|
|
168
180
|
/**
|
|
169
181
|
* @typedef {{
|
|
170
182
|
* address: string;
|
|
171
|
-
* bank: ERef<
|
|
172
|
-
* currentStorageNode: StorageNode
|
|
183
|
+
* bank: ERef<Bank>;
|
|
184
|
+
* currentStorageNode: Remote<StorageNode>;
|
|
173
185
|
* invitationPurse: Purse<'set', InvitationDetails>;
|
|
174
|
-
* walletStorageNode: StorageNode
|
|
186
|
+
* walletStorageNode: Remote<StorageNode>;
|
|
175
187
|
* }} UniqueParams
|
|
176
188
|
*
|
|
177
189
|
*
|
|
@@ -179,12 +191,12 @@ const trace = makeTracer('SmrtWlt');
|
|
|
179
191
|
*
|
|
180
192
|
*
|
|
181
193
|
* @typedef {{
|
|
182
|
-
* agoricNames: ERef<
|
|
194
|
+
* agoricNames: ERef<NameHub>;
|
|
183
195
|
* registry: BrandDescriptorRegistry;
|
|
184
196
|
* invitationIssuer: Issuer<'set'>;
|
|
185
197
|
* invitationBrand: Brand<'set'>;
|
|
186
198
|
* invitationDisplayInfo: DisplayInfo;
|
|
187
|
-
* publicMarshaller:
|
|
199
|
+
* publicMarshaller: ERemote<EMarshaller>;
|
|
188
200
|
* zoe: ERef<ZoeService>;
|
|
189
201
|
* }} SharedParams
|
|
190
202
|
*
|
|
@@ -201,15 +213,12 @@ const trace = makeTracer('SmrtWlt');
|
|
|
201
213
|
* @typedef {Readonly<
|
|
202
214
|
* UniqueParams & {
|
|
203
215
|
* paymentQueues: MapStore<Brand, Payment[]>;
|
|
204
|
-
* offerToInvitationMakers: MapStore<
|
|
205
|
-
* string,
|
|
206
|
-
* import('./types.js').InvitationMakers
|
|
207
|
-
* >;
|
|
216
|
+
* offerToInvitationMakers: MapStore<string, InvitationMakers>;
|
|
208
217
|
* offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
|
|
209
218
|
* offerToUsedInvitation: MapStore<string, Amount<'set'>>;
|
|
210
219
|
* purseBalances: MapStore<Purse, Amount>;
|
|
211
|
-
* updateRecorderKit:
|
|
212
|
-
* currentRecorderKit:
|
|
220
|
+
* updateRecorderKit: RecorderKit<UpdateRecord>;
|
|
221
|
+
* currentRecorderKit: RecorderKit<CurrentWalletRecord>;
|
|
213
222
|
* liveOffers: MapStore<OfferId, OfferStatus>;
|
|
214
223
|
* liveOfferSeats: MapStore<OfferId, UserSeat<unknown>>;
|
|
215
224
|
* liveOfferPayments: MapStore<OfferId, MapStore<Brand, Payment>>;
|
|
@@ -229,17 +238,17 @@ const trace = makeTracer('SmrtWlt');
|
|
|
229
238
|
* TODO: consider moving to nameHub.js?
|
|
230
239
|
*
|
|
231
240
|
* @param {unknown} target - passable Key
|
|
232
|
-
* @param {ERef<
|
|
241
|
+
* @param {ERef<NameHub>} nameHub
|
|
233
242
|
*/
|
|
234
243
|
const namesOf = async (target, nameHub) => {
|
|
235
244
|
const entries = await E(nameHub).entries();
|
|
236
|
-
const
|
|
245
|
+
const results = [];
|
|
237
246
|
for (const [name, candidate] of entries) {
|
|
238
247
|
if (candidate === target) {
|
|
239
|
-
|
|
248
|
+
results.push(name);
|
|
240
249
|
}
|
|
241
250
|
}
|
|
242
|
-
return harden(
|
|
251
|
+
return harden(results);
|
|
243
252
|
};
|
|
244
253
|
|
|
245
254
|
/**
|
|
@@ -273,7 +282,7 @@ const getBrandToPurses = (walletPurses, key) => {
|
|
|
273
282
|
};
|
|
274
283
|
|
|
275
284
|
/**
|
|
276
|
-
* @param {
|
|
285
|
+
* @param {Baggage} baggage
|
|
277
286
|
* @param {SharedParams} shared
|
|
278
287
|
*/
|
|
279
288
|
export const prepareSmartWallet = (baggage, shared) => {
|
|
@@ -324,7 +333,9 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
324
333
|
amountWatcherGuard,
|
|
325
334
|
/**
|
|
326
335
|
* @param {Purse} purse
|
|
327
|
-
* @param {ReturnType<
|
|
336
|
+
* @param {ReturnType<
|
|
337
|
+
* typeof makeWalletWithResolvedStorageNodes
|
|
338
|
+
* >['helper']} helper
|
|
328
339
|
*/
|
|
329
340
|
(purse, helper) => ({ purse, helper }),
|
|
330
341
|
{
|
|
@@ -359,6 +370,31 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
359
370
|
|
|
360
371
|
const makeAmountWatcher = prepareAmountWatcher();
|
|
361
372
|
|
|
373
|
+
/**
|
|
374
|
+
* @param {Amount} amount
|
|
375
|
+
* @returns {Amount}
|
|
376
|
+
*/
|
|
377
|
+
const cleanAmountForPublish = amount => {
|
|
378
|
+
mustMatch(amount, AmountShape);
|
|
379
|
+
if (
|
|
380
|
+
!matches(amount.brand, shared.invitationBrand) ||
|
|
381
|
+
!matches(amount.value, M.arrayOf(InvitationElementShape))
|
|
382
|
+
) {
|
|
383
|
+
return amount;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const invitationAmount = /** @type {InvitationAmount} */ (amount);
|
|
387
|
+
const filteredInvitationValue = invitationAmount.value.map(
|
|
388
|
+
({ handle: _, ...filteredInvitationDetails }) =>
|
|
389
|
+
filteredInvitationDetails,
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
return harden({
|
|
393
|
+
brand: shared.invitationBrand,
|
|
394
|
+
value: filteredInvitationValue,
|
|
395
|
+
});
|
|
396
|
+
};
|
|
397
|
+
|
|
362
398
|
/**
|
|
363
399
|
* @param {UniqueParams} unique
|
|
364
400
|
* @returns {State}
|
|
@@ -371,6 +407,7 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
371
407
|
address: M.string(),
|
|
372
408
|
bank: M.eref(M.remotable()),
|
|
373
409
|
invitationPurse: PurseShape,
|
|
410
|
+
// Should not be M.eref, makeRecordedKit assumes resolved
|
|
374
411
|
currentStorageNode: M.eref(StorageNodeShape),
|
|
375
412
|
walletStorageNode: M.eref(StorageNodeShape),
|
|
376
413
|
}),
|
|
@@ -408,12 +445,12 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
408
445
|
myStore: zone.detached().mapStore('my items'),
|
|
409
446
|
};
|
|
410
447
|
|
|
411
|
-
/** @type {
|
|
448
|
+
/** @type {RecorderKit<UpdateRecord>} */
|
|
412
449
|
const updateRecorderKit = makeRecorderKit(unique.walletStorageNode);
|
|
413
450
|
// NB: state size must not grow monotonically
|
|
414
451
|
// This is the node that UIs subscribe to for everything they need.
|
|
415
452
|
// e.g. agoric follow :published.wallet.agoric1nqxg4pye30n3trct0hf7dclcwfxz8au84hr3ht
|
|
416
|
-
/** @type {
|
|
453
|
+
/** @type {RecorderKit<CurrentWalletRecord>} */
|
|
417
454
|
const currentRecorderKit = makeRecorderKit(unique.currentStorageNode);
|
|
418
455
|
|
|
419
456
|
const nonpreciousState = {
|
|
@@ -556,7 +593,7 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
556
593
|
}
|
|
557
594
|
void updateRecorderKit.recorder.write({
|
|
558
595
|
updated: 'balance',
|
|
559
|
-
currentAmount: balance,
|
|
596
|
+
currentAmount: cleanAmountForPublish(balance),
|
|
560
597
|
});
|
|
561
598
|
const { helper } = this.facets;
|
|
562
599
|
helper.publishCurrentState();
|
|
@@ -573,9 +610,11 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
573
610
|
void currentRecorderKit.recorder.write({
|
|
574
611
|
purses: [...purseBalances.values()].map(a => ({
|
|
575
612
|
brand: a.brand,
|
|
576
|
-
balance: a,
|
|
613
|
+
balance: cleanAmountForPublish(a),
|
|
577
614
|
})),
|
|
578
|
-
offerToUsedInvitation: [...offerToUsedInvitation.entries()]
|
|
615
|
+
offerToUsedInvitation: [...offerToUsedInvitation.entries()].map(
|
|
616
|
+
([offerId, a]) => [offerId, cleanAmountForPublish(a)],
|
|
617
|
+
),
|
|
579
618
|
offerToPublicSubscriberPaths: [
|
|
580
619
|
...offerToPublicSubscriberPaths.entries(),
|
|
581
620
|
],
|
|
@@ -613,8 +652,7 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
613
652
|
* transition to decentralized introductions.
|
|
614
653
|
*
|
|
615
654
|
* @param {Brand} brand
|
|
616
|
-
* @param {ERef<
|
|
617
|
-
* brand, issuer branches
|
|
655
|
+
* @param {ERef<NameHub>} known - namehub with brand, issuer branches
|
|
618
656
|
* @returns {Promise<Purse | undefined>} undefined if brand is not known
|
|
619
657
|
*/
|
|
620
658
|
async getPurseIfKnownBrand(brand, known) {
|
|
@@ -693,8 +731,8 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
693
731
|
/**
|
|
694
732
|
* @param {string} offerId
|
|
695
733
|
* @param {Amount<'set'>} invitationAmount
|
|
696
|
-
* @param {
|
|
697
|
-
* @param {
|
|
734
|
+
* @param {InvitationMakers} invitationMakers
|
|
735
|
+
* @param {PublicSubscribers} publicSubscribers
|
|
698
736
|
*/
|
|
699
737
|
async addContinuingOffer(
|
|
700
738
|
offerId,
|
|
@@ -1146,8 +1184,7 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
1146
1184
|
* Umarshals the actionCapData and delegates to the appropriate action
|
|
1147
1185
|
* handler.
|
|
1148
1186
|
*
|
|
1149
|
-
* @param {
|
|
1150
|
-
* of type BridgeAction
|
|
1187
|
+
* @param {CapData<string | null>} actionCapData of type BridgeAction
|
|
1151
1188
|
* @param {boolean} [canSpend]
|
|
1152
1189
|
* @returns {Promise<void>}
|
|
1153
1190
|
*/
|
|
@@ -1260,7 +1297,7 @@ export const prepareSmartWallet = (baggage, shared) => {
|
|
|
1260
1297
|
* UniqueParams,
|
|
1261
1298
|
* 'currentStorageNode' | 'walletStorageNode'
|
|
1262
1299
|
* > & {
|
|
1263
|
-
* walletStorageNode:
|
|
1300
|
+
* walletStorageNode: ERemote<StorageNode>;
|
|
1264
1301
|
* }} uniqueWithoutChildNodes
|
|
1265
1302
|
*/
|
|
1266
1303
|
const makeSmartWallet = async uniqueWithoutChildNodes => {
|
package/src/typeGuards.js
CHANGED
package/src/utils.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @import {OfferId, OfferStatus} from './offers.js';
|
|
3
|
+
* @import {UpdateRecord} from './smartWallet.js';
|
|
4
|
+
* @import {Follower} from '@agoric/casting';
|
|
5
|
+
* @import {PublicSubscribers} from './types.js';
|
|
6
|
+
* @import {TopicsRecord} from '@agoric/zoe/src/contractSupport/index.js';
|
|
7
|
+
*/
|
|
2
8
|
export const NO_SMART_WALLET_ERROR: "no smart wallet";
|
|
3
9
|
export function makeWalletStateCoalescer(invitationBrand?: Brand<"set">): {
|
|
4
10
|
state: {
|
|
5
|
-
invitationsReceived: Map<
|
|
11
|
+
invitationsReceived: Map<string, {
|
|
6
12
|
acceptedIn: OfferId;
|
|
7
13
|
description: string;
|
|
8
14
|
instance: Instance;
|
|
@@ -10,10 +16,10 @@ export function makeWalletStateCoalescer(invitationBrand?: Brand<"set">): {
|
|
|
10
16
|
offerStatuses: Map<OfferId, OfferStatus>;
|
|
11
17
|
balances: Map<globalThis.Brand, globalThis.Amount>;
|
|
12
18
|
};
|
|
13
|
-
update: (updateRecord:
|
|
19
|
+
update: (updateRecord: UpdateRecord | {}) => void;
|
|
14
20
|
};
|
|
15
|
-
export function coalesceUpdates(updates: ERef<Subscriber<
|
|
16
|
-
invitationsReceived: Map<
|
|
21
|
+
export function coalesceUpdates(updates: ERef<Subscriber<UpdateRecord>>, invitationBrand?: Brand<"set">): {
|
|
22
|
+
invitationsReceived: Map<string, {
|
|
17
23
|
acceptedIn: OfferId;
|
|
18
24
|
description: string;
|
|
19
25
|
instance: Instance;
|
|
@@ -21,9 +27,13 @@ export function coalesceUpdates(updates: ERef<Subscriber<import("./smartWallet.j
|
|
|
21
27
|
offerStatuses: Map<OfferId, OfferStatus>;
|
|
22
28
|
balances: Map<globalThis.Brand, globalThis.Amount>;
|
|
23
29
|
};
|
|
24
|
-
export function assertHasData(follower:
|
|
25
|
-
export function objectMapStoragePath(subscribers?:
|
|
30
|
+
export function assertHasData(follower: Follower<any>): Promise<void>;
|
|
31
|
+
export function objectMapStoragePath(subscribers?: PublicSubscribers | TopicsRecord): ERef<Record<string, string>> | null;
|
|
26
32
|
export type CoalescedWalletState = ReturnType<typeof makeWalletStateCoalescer>["state"];
|
|
27
33
|
import type { OfferId } from './offers.js';
|
|
28
34
|
import type { OfferStatus } from './offers.js';
|
|
35
|
+
import type { UpdateRecord } from './smartWallet.js';
|
|
36
|
+
import type { Follower } from '@agoric/casting';
|
|
37
|
+
import type { PublicSubscribers } from './types.js';
|
|
38
|
+
import type { TopicsRecord } from '@agoric/zoe/src/contractSupport/index.js';
|
|
29
39
|
//# sourceMappingURL=utils.d.ts.map
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,oCAAqC,iBAAiB,CAAC;AAKhD,2DADK,KAAK,CAAC,KAAK,CAAC;;;wBAaH,OAAO;yBACN,MAAM;sBACT,QAAQ;;;;;2BAOd,YAAY,GAAG,EAAE;EA+D7B;AAaM,yCAHI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,oBAC9B,KAAK,CAAC,KAAK,CAAC;;oBAnFF,OAAO;qBACN,MAAM;kBACT,QAAQ;;;;EA4F1B;AAMM,wCAHI,SAAS,GAAG,CAAC,iBAYvB;AAQM,mDAHI,iBAAiB,GAAG,YAAY,GAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAY/C;mCAtDa,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,OAAO,CAAC;6BAjG3B,aAAa;iCAAb,aAAa;kCACrB,kBAAkB;8BACtB,iBAAiB;uCACR,YAAY;kCACjB,0CAA0C"}
|
package/src/utils.js
CHANGED
|
@@ -2,7 +2,13 @@ import { deeplyFulfilledObject, objectMap, makeTracer } from '@agoric/internal';
|
|
|
2
2
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
3
3
|
import { E } from '@endo/far';
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* @import {OfferId, OfferStatus} from './offers.js';
|
|
7
|
+
* @import {UpdateRecord} from './smartWallet.js';
|
|
8
|
+
* @import {Follower} from '@agoric/casting';
|
|
9
|
+
* @import {PublicSubscribers} from './types.js';
|
|
10
|
+
* @import {TopicsRecord} from '@agoric/zoe/src/contractSupport/index.js';
|
|
11
|
+
*/
|
|
6
12
|
|
|
7
13
|
export const NO_SMART_WALLET_ERROR = 'no smart wallet';
|
|
8
14
|
|
|
@@ -19,7 +25,7 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
19
25
|
* keyed by description; xxx assumes unique
|
|
20
26
|
*
|
|
21
27
|
* @type {Map<
|
|
22
|
-
*
|
|
28
|
+
* string,
|
|
23
29
|
* {
|
|
24
30
|
* acceptedIn: OfferId;
|
|
25
31
|
* description: string;
|
|
@@ -30,8 +36,7 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
30
36
|
const invitationsReceived = new Map();
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
|
-
* @param {
|
|
34
|
-
* than previous
|
|
39
|
+
* @param {UpdateRecord | {}} updateRecord newer than previous
|
|
35
40
|
*/
|
|
36
41
|
const update = updateRecord => {
|
|
37
42
|
if (!('updated' in updateRecord)) {
|
|
@@ -104,7 +109,7 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
104
109
|
* If this proves to be a problem we can add an option to this or a related
|
|
105
110
|
* utility to reset state from RPC.
|
|
106
111
|
*
|
|
107
|
-
* @param {ERef<Subscriber<
|
|
112
|
+
* @param {ERef<Subscriber<UpdateRecord>>} updates
|
|
108
113
|
* @param {Brand<'set'>} [invitationBrand]
|
|
109
114
|
*/
|
|
110
115
|
export const coalesceUpdates = (updates, invitationBrand) => {
|
|
@@ -119,7 +124,7 @@ export const coalesceUpdates = (updates, invitationBrand) => {
|
|
|
119
124
|
};
|
|
120
125
|
|
|
121
126
|
/**
|
|
122
|
-
* @param {
|
|
127
|
+
* @param {Follower<any>} follower
|
|
123
128
|
* @throws if there is no first height
|
|
124
129
|
*/
|
|
125
130
|
export const assertHasData = async follower => {
|
|
@@ -136,8 +141,7 @@ export const assertHasData = async follower => {
|
|
|
136
141
|
/**
|
|
137
142
|
* Handles the case of falsy argument so the caller can consistently await.
|
|
138
143
|
*
|
|
139
|
-
* @param {
|
|
140
|
-
* | import('@agoric/zoe/src/contractSupport/index.js').TopicsRecord} [subscribers]
|
|
144
|
+
* @param {PublicSubscribers | TopicsRecord} [subscribers]
|
|
141
145
|
* @returns {ERef<Record<string, string>> | null}
|
|
142
146
|
*/
|
|
143
147
|
export const objectMapStoragePath = subscribers => {
|
package/src/walletFactory.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export namespace customTermsShape {
|
|
|
4
4
|
let assetPublisher: Pattern;
|
|
5
5
|
}
|
|
6
6
|
export const privateArgsShape: import("@endo/patterns").Matcher;
|
|
7
|
-
export function publishDepositFacet(address: string, wallet:
|
|
7
|
+
export function publishDepositFacet(address: string, wallet: SmartWallet, namesByAddressAdmin: ERef<NameAdmin>): Promise<unknown>;
|
|
8
8
|
export function makeAssetRegistry(assetPublisher: AssetPublisher): {
|
|
9
9
|
/** @param {Brand} brand */
|
|
10
10
|
has: (brand: Brand) => boolean;
|
|
@@ -13,47 +13,55 @@ export function makeAssetRegistry(assetPublisher: AssetPublisher): {
|
|
|
13
13
|
brand: Brand;
|
|
14
14
|
displayInfo: DisplayInfo;
|
|
15
15
|
issuer: Issuer;
|
|
16
|
-
petname:
|
|
16
|
+
petname: Petname;
|
|
17
17
|
};
|
|
18
18
|
values: () => Iterable<{
|
|
19
19
|
brand: Brand;
|
|
20
20
|
displayInfo: DisplayInfo;
|
|
21
21
|
issuer: Issuer;
|
|
22
|
-
petname:
|
|
22
|
+
petname: Petname;
|
|
23
23
|
}>;
|
|
24
24
|
};
|
|
25
25
|
export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
|
|
26
|
-
storageNode:
|
|
27
|
-
walletBridgeManager?: ERef<
|
|
26
|
+
storageNode: ERemote<StorageNode>;
|
|
27
|
+
walletBridgeManager?: ERef<ScopedBridgeManager<"wallet">>;
|
|
28
28
|
walletReviver?: ERef<WalletReviver>;
|
|
29
|
-
}, baggage:
|
|
29
|
+
}, baggage: Baggage): Promise<{
|
|
30
30
|
creatorFacet: import("@endo/exo").Guarded<{
|
|
31
31
|
/**
|
|
32
32
|
* @param {string} address
|
|
33
|
-
* @param {ERef<
|
|
34
|
-
* @param {ERef<
|
|
35
|
-
* @returns {Promise<
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* wallet along with a flag to distinguish between looking up an existing
|
|
39
|
-
* wallet and creating a new one.
|
|
33
|
+
* @param {ERef<Bank>} bank
|
|
34
|
+
* @param {ERef<NameAdmin>} namesByAddressAdmin
|
|
35
|
+
* @returns {Promise<[wallet: SmartWallet, isNew: boolean]>} wallet along
|
|
36
|
+
* with a flag to distinguish between looking up an existing wallet and
|
|
37
|
+
* creating a new one.
|
|
40
38
|
*/
|
|
41
|
-
provideSmartWallet(address: string, bank: ERef<
|
|
39
|
+
provideSmartWallet(address: string, bank: ERef<Bank>, namesByAddressAdmin: ERef<NameAdmin>): Promise<[wallet: SmartWallet, isNew: boolean]>;
|
|
42
40
|
}>;
|
|
43
41
|
}>;
|
|
44
42
|
export type SmartWalletContractTerms = {
|
|
45
43
|
agoricNames: ERef<NameHub>;
|
|
46
|
-
board: ERef<
|
|
44
|
+
board: ERef<Board>;
|
|
47
45
|
assetPublisher: AssetPublisher;
|
|
48
46
|
};
|
|
49
47
|
export type AssetPublisher = {
|
|
50
|
-
getAssetSubscription: () => ERef<IterableEachTopic<
|
|
48
|
+
getAssetSubscription: () => ERef<IterableEachTopic<AssetDescriptor>>;
|
|
51
49
|
};
|
|
52
50
|
export type IsRevive = boolean;
|
|
53
51
|
export type WalletReviver = {
|
|
54
|
-
reviveWallet: (address: string) => Promise<
|
|
52
|
+
reviveWallet: (address: string) => Promise<SmartWallet>;
|
|
55
53
|
ackWallet: (address: string) => IsRevive;
|
|
56
54
|
};
|
|
57
55
|
export type start = typeof prepare;
|
|
56
|
+
import type { SmartWallet } from './smartWallet.js';
|
|
57
|
+
import type { NameAdmin } from '@agoric/vats';
|
|
58
|
+
import type { Petname } from './types.js';
|
|
59
|
+
import type { StorageNode } from '@agoric/internal/src/lib-chainStorage.js';
|
|
60
|
+
import type { ERemote } from '@agoric/internal';
|
|
61
|
+
import type { ScopedBridgeManager } from '@agoric/vats';
|
|
62
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
63
|
+
import type { Bank } from '@agoric/vats/src/vat-bank.js';
|
|
58
64
|
import type { NameHub } from '@agoric/vats';
|
|
65
|
+
import type { Board } from '@agoric/vats';
|
|
66
|
+
import type { AssetDescriptor } from '@agoric/vats/src/vat-bank.js';
|
|
59
67
|
//# sourceMappingURL=walletFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walletFactory.d.ts","sourceRoot":"","sources":["walletFactory.js"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"walletFactory.d.ts","sourceRoot":"","sources":["walletFactory.js"],"names":[],"mappings":";;;;;AA4CA,gEAKE;AAYK,6CAJI,MAAM,UACN,WAAW,uBACX,IAAI,CAAC,SAAS,CAAC,oBAezB;AAWM,kDAFI,cAAc;IAyCrB,2BAA2B;iBAAf,KAAK;IAEjB,2BAA2B;iBAAf,KAAK;eArCP,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO;;;eAHT,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO;;EAuCtB;AAmCM,6BARI,GAAG,CAAC,wBAAwB,CAAC,eAC7B;IACN,WAAW,EAAE,QAAQ,WAAW,CAAC,CAAC;IAClC,mBAAmB,CAAC,EAAE,IAAI,CAAC,oBAAoB,QAAQ,CAAC,CAAC,CAAC;IAC1D,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;CACrC,WACO,OAAO;;QAkHZ;;;;;;;WAOG;oCANQ,MAAM,QACN,IAAI,CAAC,IAAI,CAAC,uBACV,IAAI,CAAC,SAAS,CAAC,GACb,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;;GAqDhE;uCAzMY;IACR,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;CAChC;6BAGS;IACR,oBAAoB,EAAE,MAAM,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC;CACtE;uBAGS,OAAO;4BAEP;IACR,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACxD,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,QAAQ,CAAC;CAC1C;oBA6LU,OAAO,OAAO;iCA3TE,kBAAkB;+BACpB,cAAc;6BAChB,YAAY;iCALR,0CAA0C;6BAD9C,kBAAkB;yCASN,cAAc;6BAC1B,kBAAkB;0BAErB,8BAA8B;6BAT3B,cAAc;2BAIhB,cAAc;qCACJ,8BAA8B"}
|
package/src/walletFactory.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { makeTracer, WalletName } from '@agoric/internal';
|
|
11
|
+
import { wrapRemoteMarshaller } from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
11
12
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
12
13
|
import { M, makeExo, makeScalarMapStore, mustMatch } from '@agoric/store';
|
|
13
14
|
import { makeAtomicProvider } from '@agoric/store/src/stores/store-utils.js';
|
|
@@ -18,8 +19,19 @@ import { prepareSmartWallet } from './smartWallet.js';
|
|
|
18
19
|
import { shape } from './typeGuards.js';
|
|
19
20
|
|
|
20
21
|
/**
|
|
22
|
+
* @import {ERemote} from '@agoric/internal';
|
|
23
|
+
* @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js';
|
|
21
24
|
* @import {MapStore} from '@agoric/swingset-liveslots';
|
|
22
25
|
* @import {NameHub} from '@agoric/vats';
|
|
26
|
+
* @import {SmartWallet} from './smartWallet.js';
|
|
27
|
+
* @import {NameAdmin} from '@agoric/vats';
|
|
28
|
+
* @import {Petname} from './types.js';
|
|
29
|
+
* @import {Board} from '@agoric/vats';
|
|
30
|
+
* @import {AssetDescriptor} from '@agoric/vats/src/vat-bank.js';
|
|
31
|
+
* @import {ScopedBridgeManager} from '@agoric/vats';
|
|
32
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
33
|
+
* @import {WalletBridgeMsg} from './types.js';
|
|
34
|
+
* @import {Bank} from '@agoric/vats/src/vat-bank.js';
|
|
23
35
|
*/
|
|
24
36
|
|
|
25
37
|
const trace = makeTracer('WltFct');
|
|
@@ -44,8 +56,8 @@ const WALLETS_BY_ADDRESS = 'walletsByAddress';
|
|
|
44
56
|
* already done.
|
|
45
57
|
*
|
|
46
58
|
* @param {string} address
|
|
47
|
-
* @param {
|
|
48
|
-
* @param {ERef<
|
|
59
|
+
* @param {SmartWallet} wallet
|
|
60
|
+
* @param {ERef<NameAdmin>} namesByAddressAdmin
|
|
49
61
|
*/
|
|
50
62
|
export const publishDepositFacet = async (
|
|
51
63
|
address,
|
|
@@ -78,7 +90,7 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
78
90
|
* brand: Brand;
|
|
79
91
|
* displayInfo: DisplayInfo;
|
|
80
92
|
* issuer: Issuer;
|
|
81
|
-
* petname:
|
|
93
|
+
* petname: Petname;
|
|
82
94
|
* }} BrandDescriptor
|
|
83
95
|
* For use by clients to describe brands to users. Includes `displayInfo` to
|
|
84
96
|
* save a remote call.
|
|
@@ -122,24 +134,20 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
122
134
|
/**
|
|
123
135
|
* @typedef {{
|
|
124
136
|
* agoricNames: ERef<NameHub>;
|
|
125
|
-
* board: ERef<
|
|
137
|
+
* board: ERef<Board>;
|
|
126
138
|
* assetPublisher: AssetPublisher;
|
|
127
139
|
* }} SmartWalletContractTerms
|
|
128
140
|
*
|
|
129
141
|
*
|
|
130
142
|
* @typedef {{
|
|
131
|
-
* getAssetSubscription: () => ERef<
|
|
132
|
-
* IterableEachTopic<import('@agoric/vats/src/vat-bank.js').AssetDescriptor>
|
|
133
|
-
* >;
|
|
143
|
+
* getAssetSubscription: () => ERef<IterableEachTopic<AssetDescriptor>>;
|
|
134
144
|
* }} AssetPublisher
|
|
135
145
|
*
|
|
136
146
|
*
|
|
137
147
|
* @typedef {boolean} IsRevive
|
|
138
148
|
*
|
|
139
149
|
* @typedef {{
|
|
140
|
-
* reviveWallet: (
|
|
141
|
-
* address: string,
|
|
142
|
-
* ) => Promise<import('./smartWallet.js').SmartWallet>;
|
|
150
|
+
* reviveWallet: (address: string) => Promise<SmartWallet>;
|
|
143
151
|
* ackWallet: (address: string) => IsRevive;
|
|
144
152
|
* }} WalletReviver
|
|
145
153
|
*/
|
|
@@ -150,13 +158,11 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
150
158
|
/**
|
|
151
159
|
* @param {ZCF<SmartWalletContractTerms>} zcf
|
|
152
160
|
* @param {{
|
|
153
|
-
* storageNode:
|
|
154
|
-
* walletBridgeManager?: ERef<
|
|
155
|
-
* import('@agoric/vats').ScopedBridgeManager<'wallet'>
|
|
156
|
-
* >;
|
|
161
|
+
* storageNode: ERemote<StorageNode>;
|
|
162
|
+
* walletBridgeManager?: ERef<ScopedBridgeManager<'wallet'>>;
|
|
157
163
|
* walletReviver?: ERef<WalletReviver>;
|
|
158
164
|
* }} privateArgs
|
|
159
|
-
* @param {
|
|
165
|
+
* @param {Baggage} baggage
|
|
160
166
|
*/
|
|
161
167
|
export const prepare = async (zcf, privateArgs, baggage) => {
|
|
162
168
|
const upgrading = baggage.has(WALLETS_BY_ADDRESS);
|
|
@@ -165,7 +171,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
165
171
|
const zoe = zcf.getZoeService();
|
|
166
172
|
const { storageNode, walletBridgeManager, walletReviver } = privateArgs;
|
|
167
173
|
|
|
168
|
-
/** @type {MapStore<string,
|
|
174
|
+
/** @type {MapStore<string, SmartWallet>} */
|
|
169
175
|
const walletsByAddress = provideDurableMapStore(baggage, WALLETS_BY_ADDRESS);
|
|
170
176
|
const provider = makeAtomicProvider(walletsByAddress);
|
|
171
177
|
|
|
@@ -190,8 +196,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
190
196
|
* Once the owner is known, this calls handleBridgeAction which ensures
|
|
191
197
|
* that all errors are published in the owner wallet's vstorage path.
|
|
192
198
|
*
|
|
193
|
-
* @param {
|
|
194
|
-
* shape.WalletBridgeMsg
|
|
199
|
+
* @param {WalletBridgeMsg} obj validated by shape.WalletBridgeMsg
|
|
195
200
|
* @returns {Promise<void>}
|
|
196
201
|
*/
|
|
197
202
|
fromBridge: async obj => {
|
|
@@ -229,7 +234,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
229
234
|
invitationIssuer,
|
|
230
235
|
invitationBrand,
|
|
231
236
|
invitationDisplayInfo,
|
|
232
|
-
publicMarshaller,
|
|
237
|
+
publicMarshaller: remotePublicMarshaller,
|
|
233
238
|
} = await provideAll(baggage, {
|
|
234
239
|
invitationIssuer: () => invitationIssuerP,
|
|
235
240
|
invitationBrand: () => E(invitationIssuerP).getBrand(),
|
|
@@ -240,12 +245,14 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
240
245
|
|
|
241
246
|
const registry = makeAssetRegistry(assetPublisher);
|
|
242
247
|
|
|
248
|
+
const publicCachingMarshaller = wrapRemoteMarshaller(remotePublicMarshaller);
|
|
249
|
+
|
|
243
250
|
const shared = harden({
|
|
244
251
|
agoricNames,
|
|
245
252
|
invitationBrand,
|
|
246
253
|
invitationDisplayInfo,
|
|
247
254
|
invitationIssuer,
|
|
248
|
-
publicMarshaller,
|
|
255
|
+
publicMarshaller: publicCachingMarshaller,
|
|
249
256
|
registry,
|
|
250
257
|
zoe,
|
|
251
258
|
});
|
|
@@ -271,21 +278,17 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
271
278
|
{
|
|
272
279
|
/**
|
|
273
280
|
* @param {string} address
|
|
274
|
-
* @param {ERef<
|
|
275
|
-
* @param {ERef<
|
|
276
|
-
* @returns {Promise<
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* wallet along with a flag to distinguish between looking up an existing
|
|
280
|
-
* wallet and creating a new one.
|
|
281
|
+
* @param {ERef<Bank>} bank
|
|
282
|
+
* @param {ERef<NameAdmin>} namesByAddressAdmin
|
|
283
|
+
* @returns {Promise<[wallet: SmartWallet, isNew: boolean]>} wallet along
|
|
284
|
+
* with a flag to distinguish between looking up an existing wallet and
|
|
285
|
+
* creating a new one.
|
|
281
286
|
*/
|
|
282
287
|
provideSmartWallet(address, bank, namesByAddressAdmin) {
|
|
283
288
|
let isNew = false;
|
|
284
289
|
|
|
285
290
|
/**
|
|
286
|
-
* @type {(
|
|
287
|
-
* address: string,
|
|
288
|
-
* ) => Promise<import('./smartWallet.js').SmartWallet>}
|
|
291
|
+
* @type {(address: string) => Promise<SmartWallet>}
|
|
289
292
|
*/
|
|
290
293
|
const maker = async _address => {
|
|
291
294
|
const invitationPurse = await E(invitationIssuer).makeEmptyPurse();
|