@agoric/smart-wallet 0.5.4-u11.0 → 0.5.4-u12.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/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.5.4-u12.0](https://github.com/Agoric/agoric/compare/@agoric/smart-wallet@0.5.4-u11wf.0...@agoric/smart-wallet@0.5.4-u12.0) (2023-11-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **walletFactory:** move upgrading check before baggage is populated ([#8322](https://github.com/Agoric/agoric/issues/8322)) ([330b7a2](https://github.com/Agoric/agoric/commit/330b7a26da9a8eefb95e3e0fd082714fdfad7873))
12
+
13
+
14
+
15
+ ### [0.5.4-u11wf.0](https://github.com/Agoric/agoric/compare/@agoric/smart-wallet@0.5.4-u11.0...@agoric/smart-wallet@0.5.4-u11wf.0) (2023-09-23)
16
+
17
+
18
+ ### Features
19
+
20
+ * **smart-wallet:** trading in non-vbank asset ([dc99ca0](https://github.com/Agoric/agoric/commit/dc99ca0b58af3a66778071993f0d73d099605069))
21
+ * **smart-wallet:** upgrade walletFactory for non-vbank assets ([073b450](https://github.com/Agoric/agoric/commit/073b450b0790d1837d59e80c0109f0923b5f0cd2))
22
+ * **smart-wallet:** withdraw payments before getting invitation ([82ed64e](https://github.com/Agoric/agoric/commit/82ed64ec20ce7884d6cdf6caac63fab85d02af40)), closes [#7098](https://github.com/Agoric/agoric/issues/7098)
23
+
24
+
25
+
6
26
  ### [0.5.4-u11.0](https://github.com/Agoric/agoric/compare/@agoric/smart-wallet@0.5.3...@agoric/smart-wallet@0.5.4-u11.0) (2023-08-24)
7
27
 
8
28
  **Note:** Version bump only for package @agoric/smart-wallet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/smart-wallet",
3
- "version": "0.5.4-u11.0",
3
+ "version": "0.5.4-u12.0",
4
4
  "description": "Wallet contract",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -17,26 +17,28 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@agoric/cosmic-proto": "^0.3.0",
20
- "@endo/captp": "^3.1.1",
21
- "@endo/init": "^0.5.56",
22
- "ava": "^5.2.0"
20
+ "@endo/bundle-source": "2.5.2-upstream-rollup",
21
+ "@endo/captp": "3.1.1",
22
+ "@endo/init": "0.5.56",
23
+ "ava": "^5.2.0",
24
+ "import-meta-resolve": "^2.2.1"
23
25
  },
24
26
  "dependencies": {
25
- "@agoric/assert": "^0.6.0",
26
- "@agoric/casting": "^0.4.3-u11.0",
27
- "@agoric/ertp": "^0.16.3-u11.0",
28
- "@agoric/internal": "^0.3.3-u11.0",
29
- "@agoric/notifier": "^0.6.3-u11.0",
30
- "@agoric/store": "^0.9.3-u11.0",
31
- "@agoric/swingset-vat": "^0.32.3-u11.0",
32
- "@agoric/vat-data": "^0.5.3-u11.0",
33
- "@agoric/vats": "^0.15.2-u11.0",
34
- "@agoric/zoe": "^0.26.3-u11.0",
35
- "@endo/eventual-send": "^0.17.2",
36
- "@endo/far": "^0.2.18",
37
- "@endo/marshal": "^0.8.5",
38
- "@endo/nat": "^4.1.27",
39
- "@endo/promise-kit": "^0.2.56"
27
+ "@agoric/assert": "^0.6.1-u11wf.0",
28
+ "@agoric/casting": "^0.4.3-u12.0",
29
+ "@agoric/ertp": "^0.16.3-u12.0",
30
+ "@agoric/internal": "^0.4.0-u12.0",
31
+ "@agoric/notifier": "^0.6.3-u12.0",
32
+ "@agoric/store": "^0.9.3-u12.0",
33
+ "@agoric/swingset-vat": "^0.32.3-u12.0",
34
+ "@agoric/vat-data": "^0.5.3-u12.0",
35
+ "@agoric/vats": "^0.15.2-u12.0",
36
+ "@agoric/zoe": "^0.26.3-u12.0",
37
+ "@endo/eventual-send": "0.17.2",
38
+ "@endo/far": "0.2.18",
39
+ "@endo/marshal": "0.8.5",
40
+ "@endo/nat": "4.1.27",
41
+ "@endo/promise-kit": "0.2.56"
40
42
  },
41
43
  "files": [
42
44
  "src/"
@@ -61,5 +63,5 @@
61
63
  "publishConfig": {
62
64
  "access": "public"
63
65
  },
64
- "gitHead": "92b6cd72484079b0349d8ccfa4510aeb820e8d67"
66
+ "gitHead": "ee5a5fdad9187a6b1b7b26b772b6564c0db3062e"
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["offers.js"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;GAOG;AAEH,kEAAkE;AAClE,+CAAgD;AAwBzC;SAVI,KAAK,UAAU,CAAC;;mCACW,QAAQ,MAAM,CAAC;;sBAC1C,KAAK,OAAO,KAAK,CAAC,CAAC;;gBAEnB,KAAK,OAAO,EAAE,MAAM,GAAE,OAAO,CAAC;mCACvB,OAAO,eAAe,EAAE,cAAc,KAAK,KAAK,UAAU,CAAC;+BAC1D,KAAK,KAAK,QAAQ,OAAO,SAAS,EAAE,WAAW,CAAC;;6BAC/C,WAAW,KAAK,IAAI;oCACnB,MAAM,oBAAoB,OAAO,KAAK,CAAC,oBAAoB,OAAO,SAAS,EAAE,sBAAsB,qBAAqB,OAAO,SAAS,EAAE,iBAAiB,GAAG,OAAO,iCAAiC,EAAE,YAAY,KAAM,QAAQ,IAAI,CAAC;;IAaxP;;;;;;;OAOG;4BAJQ,SAAS,2BACC,QAAQ,KAAK,IAAI,GACzB,QAAQ,IAAI,CAAC;EA0I7B;sBA/LY,MAAM,GAAG,MAAM;wBAIf;IACZ,EAAM,EAAE,OAAO,CAAC;IAChB,cAAkB,EAAE,OAAO,eAAe,EAAE,cAAc,CAAC;IAC3D,QAAY,EAAE,QAAQ,CAAC;IACvB,SAAa,CAAC,EAAE,OAAO,CAAA;CACpB;0BAOS,OAAO,aAAa,EAAE,SAAS,GAAG;IAC9C,KAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAmB,CA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1,5 @@
1
1
  import { E, passStyleOf } from '@endo/far';
2
+ import { deeplyFulfilledObject } from '@agoric/internal';
2
3
  import { makePaymentsHelper } from './payments.js';
3
4
 
4
5
  /**
@@ -80,15 +81,15 @@ export const makeOfferExecutor = ({
80
81
  // 1. Prepare values and validate synchronously.
81
82
  const { id, invitationSpec, proposal, offerArgs } = offerSpec;
82
83
 
84
+ /** @type {PaymentKeywordRecord | undefined} */
85
+ const paymentKeywordRecord = await (proposal?.give &&
86
+ deeplyFulfilledObject(paymentsManager.withdrawGive(proposal.give)));
87
+
83
88
  const invitation = invitationFromSpec(invitationSpec);
84
89
  const invitationAmount = await E(invitationIssuer).getAmountOf(
85
90
  invitation,
86
91
  );
87
92
 
88
- const paymentKeywordRecord = proposal?.give
89
- ? paymentsManager.withdrawGive(proposal.give)
90
- : undefined;
91
-
92
93
  // 2. Begin executing offer
93
94
  // No explicit signal to user that we reached here but if anything above
94
95
  // failed they'd get an 'error' status update.
@@ -0,0 +1,17 @@
1
+ export function upgradeWalletFactory({ consume: { contractKits: kitsP, instancePrivateArgs: argsP }, instance: { consume: { walletFactory: wfInstanceP }, }, }: BootstrapPowers, config: {
2
+ options: {
3
+ walletFactoryRef: VatSourceRef & {
4
+ bundleID: string;
5
+ };
6
+ };
7
+ }): Promise<void>;
8
+ export function publishAgoricBrandsDisplayInfo({ consume: { agoricNames, board, chainStorage }, }: BootstrapPowers): Promise<void>;
9
+ export function getManifestForUpgrade(_powers: any, { walletFactoryRef }: {
10
+ walletFactoryRef: any;
11
+ }): {
12
+ manifest: import("@agoric/vats/src/core/lib-boot").BootstrapManifest;
13
+ options: {
14
+ walletFactoryRef: any;
15
+ };
16
+ };
17
+ //# sourceMappingURL=upgrade-walletFactory-proposal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-walletFactory-proposal.d.ts","sourceRoot":"","sources":["upgrade-walletFactory-proposal.js"],"names":[],"mappings":"AAoBO,gKALK,eAAe;;0BAGI,YAAY,GAAG;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE;;kBA6BjE;AAMM,mGAFK,eAAe,iBAwB1B;AAsBM;;;;;;;EAKN"}
@@ -0,0 +1,103 @@
1
+ // @ts-check
2
+ import { E } from '@endo/far';
3
+ import { makeMarshal } from '@endo/marshal';
4
+ import { allValues } from '@agoric/internal';
5
+
6
+ console.warn('upgrade-walletFactory-proposal.js module evaluating');
7
+
8
+ const { Fail } = assert;
9
+
10
+ // vstorage paths under published.*
11
+ const BOARD_AUX = 'boardAux';
12
+
13
+ const marshalData = makeMarshal(_val => Fail`data only`);
14
+
15
+ /**
16
+ * @param { BootstrapPowers } powers
17
+ *
18
+ * @param {object} config
19
+ * @param {{ walletFactoryRef: VatSourceRef & { bundleID: string } }} config.options
20
+ */
21
+ export const upgradeWalletFactory = async (
22
+ {
23
+ consume: { contractKits: kitsP, instancePrivateArgs: argsP },
24
+ instance: {
25
+ consume: { walletFactory: wfInstanceP },
26
+ },
27
+ },
28
+ config,
29
+ ) => {
30
+ console.log('upgradeWalletFactory: config', config);
31
+ const { walletFactoryRef } = config.options;
32
+
33
+ console.log('upgradeWalletFactory: awaiting instance');
34
+ const wfInstance = await wfInstanceP;
35
+ console.log('upgradeWalletFactory: awaiting contract kits');
36
+ const { contractKits, instancePrivateArgs } = await allValues({
37
+ contractKits: kitsP,
38
+ instancePrivateArgs: argsP,
39
+ });
40
+ const { adminFacet } = contractKits.get(wfInstance);
41
+ /** @type {Parameters<typeof import('../walletFactory').prepare>[1]} */
42
+ // @ts-expect-error cast
43
+ const unsettledArgs = instancePrivateArgs.get(wfInstance);
44
+ const privateArgs = await allValues(unsettledArgs);
45
+ console.log('upgradeWalletFactory: upgrading with privateArgs', privateArgs);
46
+ await E(adminFacet).upgradeContract(walletFactoryRef.bundleID, privateArgs);
47
+ console.log('upgradeWalletFactory: done');
48
+ };
49
+ harden(upgradeWalletFactory);
50
+
51
+ /**
52
+ * @param { BootstrapPowers } powers
53
+ */
54
+ export const publishAgoricBrandsDisplayInfo = async ({
55
+ consume: { agoricNames, board, chainStorage },
56
+ }) => {
57
+ // chainStorage type includes undefined, which doesn't apply here.
58
+ // @ts-expect-error UNTIL https://github.com/Agoric/agoric-sdk/issues/8247
59
+ const boardAux = E(chainStorage).makeChildNode(BOARD_AUX);
60
+ const publishBrandInfo = async brand => {
61
+ const [id, displayInfo, allegedName] = await Promise.all([
62
+ E(board).getId(brand),
63
+ E(brand).getDisplayInfo(),
64
+ E(brand).getAllegedName(),
65
+ ]);
66
+ const node = E(boardAux).makeChildNode(id);
67
+ const aux = marshalData.toCapData(harden({ allegedName, displayInfo }));
68
+ await E(node).setValue(JSON.stringify(aux));
69
+ };
70
+
71
+ /** @type {ERef<NameHub>} */
72
+ const brandHub = E(agoricNames).lookup('brand');
73
+ const brands = await E(brandHub).values();
74
+ // tolerate failure; in particular, for the timer brand
75
+ await Promise.allSettled(brands.map(publishBrandInfo));
76
+ };
77
+ harden(publishAgoricBrandsDisplayInfo);
78
+
79
+ /** @type { import("@agoric/vats/src/core/lib-boot").BootstrapManifest } */
80
+ const manifest = {
81
+ [upgradeWalletFactory.name]: {
82
+ // include rationale for closely-held, high authority capabilities
83
+ consume: {
84
+ contractKits: `to upgrade walletFactory using its adminFacet`,
85
+ instancePrivateArgs: `to get privateArgs for walletFactory`,
86
+ },
87
+ // widely-shared, low authority instance handles need no rationale
88
+ instance: {
89
+ consume: { walletFactory: true, provisionPool: true },
90
+ },
91
+ },
92
+ [publishAgoricBrandsDisplayInfo.name]: {
93
+ consume: { agoricNames: true, board: true, chainStorage: true },
94
+ },
95
+ };
96
+ harden(manifest);
97
+
98
+ export const getManifestForUpgrade = (_powers, { walletFactoryRef }) => {
99
+ return harden({
100
+ manifest,
101
+ options: { walletFactoryRef },
102
+ });
103
+ };
@@ -1,3 +1,4 @@
1
+ export const BRAND_TO_PURSES_KEY: "brandToPurses";
1
2
  export function prepareSmartWallet(baggage: MapStore<string, unknown>, shared: SharedParams): (uniqueWithoutChildNodes: Omit<UniqueParams, "currentStorageNode" | "walletStorageNode"> & {
2
3
  walletStorageNode: ERef<StorageNode>;
3
4
  }) => Promise<{
@@ -5,7 +6,7 @@ export function prepareSmartWallet(baggage: MapStore<string, unknown>, shared: S
5
6
  * Umarshals the actionCapData and delegates to the appropriate action handler.
6
7
  *
7
8
  * @param {import('@endo/marshal').CapData<string>} actionCapData of type BridgeAction
8
- * @param {boolean} [canSpend=false]
9
+ * @param {boolean} [canSpend]
9
10
  * @returns {Promise<void>}
10
11
  */
11
12
  handleBridgeAction(actionCapData: import('@endo/marshal').CapData<string>, canSpend?: boolean | undefined): Promise<void>;
@@ -15,10 +16,11 @@ export function prepareSmartWallet(baggage: MapStore<string, unknown>, shared: S
15
16
  *
16
17
  * If the purse doesn't exist, we hold the payment in durable storage.
17
18
  *
18
- * @param {import('@endo/far').FarRef<Payment>} payment
19
- * @returns {Promise<Amount>} amounts for deferred deposits will be empty
19
+ * @param {Payment} payment
20
+ * @returns {Promise<Amount>}
21
+ * @throws if there's not yet a purse, though the payment is held to try again when there is
20
22
  */
21
- receive(payment: import('@endo/far').FarRef<Payment>): Promise<Amount>;
23
+ receive(payment: Payment): Promise<Amount>;
22
24
  };
23
25
  getOffersFacet(): {
24
26
  /**
@@ -150,8 +152,8 @@ export type SharedParams = {
150
152
  */
151
153
  export type State = ImmutableState & MutableState;
152
154
  export type ImmutableState = Readonly<UniqueParams & {
153
- paymentQueues: MapStore<Brand, Array<import('@endo/far').FarRef<Payment>>>;
154
- offerToInvitationMakers: MapStore<string, import('./types').RemoteInvitationMakers>;
155
+ paymentQueues: MapStore<Brand, Array<Payment>>;
156
+ offerToInvitationMakers: MapStore<string, import('./types').InvitationMakers>;
155
157
  offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>;
156
158
  offerToUsedInvitation: MapStore<string, Amount>;
157
159
  purseBalances: MapStore<RemotePurse, Amount>;
@@ -160,6 +162,9 @@ export type ImmutableState = Readonly<UniqueParams & {
160
162
  liveOffers: MapStore<import('./offers.js').OfferId, import('./offers.js').OfferStatus>;
161
163
  liveOfferSeats: WeakMapStore<import('./offers.js').OfferId, UserSeat<unknown>>;
162
164
  }>;
165
+ export type PurseRecord = BrandDescriptor & {
166
+ purse: Purse;
167
+ };
163
168
  export type MutableState = {};
164
169
  export type SmartWallet = Awaited<ReturnType<ReturnType<typeof prepareSmartWallet>>>;
165
170
  //# sourceMappingURL=smartWallet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"smartWallet.d.ts","sourceRoot":"","sources":["smartWallet.js"],"names":[],"mappings":"AAyJO,+EAFI,YAAY;uBA8c2E,KAAK,WAAW,CAAC;;IA/F3G;;;;;;OAMG;sCAHQ,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,mCAErC,QAAQ,IAAI,CAAC;;QAnJ1B;;;;;;;WAOG;yBAFQ,OAAO,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,GACjC,QAAQ,MAAM,CAAC;;;QAwB5B;;;;;;WAMG;gCAHQ,OAAO,aAAa,EAAE,SAAS,GAC7B,QAAQ,IAAI,CAAC;QA+F1B;;;;;;WAMG;8BAHQ,OAAO,aAAa,EAAE,OAAO,GAC3B,QAAQ,IAAI,CAAC;;IAmE1B,sCAAsC;;IAItC,sCAAsC;;;;;;;;;;;;;;GAkD7C;iCAplBY;IACZ,MAAU,EAAE,cAAc,CAAA;IAC1B,KAAS,EAAE,OAAO,aAAa,EAAE,SAAS,CAAC;CACxC;iCAIS;IACZ,MAAU,EAAE,cAAc,CAAA;IAC1B,OAAW,EAAE,OAAO,aAAa,EAAE,OAAO,CAAC;CACxC;2BAOU,kBAAkB,GAAG,kBAAkB;;;;;;;;;;;;;;;;;;YAoBxC,MAAM;QAAC,KAAK,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;2BACvB,MAAM,CAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,CAAE,CAAC;;;;gBAE7D,MAAM,CAAC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sync
2
+ // @ts-nocheck
1
3
  import {
2
- AmountMath,
3
4
  AmountShape,
4
5
  BrandShape,
5
6
  DisplayInfoShape,
@@ -7,15 +8,23 @@ import {
7
8
  PaymentShape,
8
9
  PurseShape,
9
10
  } from '@agoric/ertp';
10
- import { StorageNodeShape } from '@agoric/internal';
11
+ import { StorageNodeShape, makeTracer } from '@agoric/internal';
11
12
  import { observeNotifier } from '@agoric/notifier';
12
13
  import { M, mustMatch } from '@agoric/store';
13
- import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
14
- import { makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
15
14
  import {
16
- prepareRecorderKit,
15
+ appendToStoredArray,
16
+ provideLazy,
17
+ } from '@agoric/store/src/stores/store-utils.js';
18
+ import {
19
+ makeScalarBigMapStore,
20
+ makeScalarBigWeakMapStore,
21
+ prepareExoClassKit,
22
+ provide,
23
+ } from '@agoric/vat-data';
24
+ import {
17
25
  SubscriberShape,
18
26
  TopicsRecordShape,
27
+ prepareRecorderKit,
19
28
  } from '@agoric/zoe/src/contractSupport/index.js';
20
29
  import { E } from '@endo/far';
21
30
  import { makeInvitationsHelper } from './invitations.js';
@@ -25,6 +34,8 @@ import { objectMapStoragePath } from './utils.js';
25
34
 
26
35
  const { Fail, quote: q } = assert;
27
36
 
37
+ const trace = makeTracer('SmrtWlt');
38
+
28
39
  /**
29
40
  * @file Smart wallet module
30
41
  *
@@ -132,8 +143,8 @@ const { Fail, quote: q } = assert;
132
143
  * - `purseBalances` is a cache of what we've received from purses. Held so we can publish all balances on change.
133
144
  *
134
145
  * @typedef {Readonly<UniqueParams & {
135
- * paymentQueues: MapStore<Brand, Array<import('@endo/far').FarRef<Payment>>>,
136
- * offerToInvitationMakers: MapStore<string, import('./types').RemoteInvitationMakers>,
146
+ * paymentQueues: MapStore<Brand, Array<Payment>>,
147
+ * offerToInvitationMakers: MapStore<string, import('./types').InvitationMakers>,
137
148
  * offerToPublicSubscriberPaths: MapStore<string, Record<string, string>>,
138
149
  * offerToUsedInvitation: MapStore<string, Amount>,
139
150
  * purseBalances: MapStore<RemotePurse, Amount>,
@@ -143,16 +154,66 @@ const { Fail, quote: q } = assert;
143
154
  * liveOfferSeats: WeakMapStore<import('./offers.js').OfferId, UserSeat<unknown>>,
144
155
  * }>} ImmutableState
145
156
  *
157
+ * @typedef {BrandDescriptor & { purse: Purse }} PurseRecord
146
158
  * @typedef {{
147
159
  * }} MutableState
148
160
  */
149
161
 
162
+ /**
163
+ * NameHub reverse-lookup, finding 0 or more names for a target value
164
+ *
165
+ * TODO: consider moving to nameHub.js?
166
+ *
167
+ * @param {unknown} target - passable Key
168
+ * @param {ERef<NameHub>} nameHub
169
+ */
170
+ const namesOf = async (target, nameHub) => {
171
+ const entries = await E(nameHub).entries();
172
+ const matches = [];
173
+ for (const [name, candidate] of entries) {
174
+ if (candidate === target) {
175
+ matches.push(name);
176
+ }
177
+ }
178
+ return harden(matches);
179
+ };
180
+
181
+ /**
182
+ * Check that an issuer and its brand belong to each other.
183
+ *
184
+ * TODO: move to ERTP?
185
+ *
186
+ * @param {Issuer} issuer
187
+ * @param {Brand} brand
188
+ * @returns {Promise<boolean>} true iff the the brand and issuer match
189
+ */
190
+ const checkMutual = (issuer, brand) =>
191
+ Promise.all([
192
+ E(issuer)
193
+ .getBrand()
194
+ .then(b => b === brand),
195
+ E(brand).isMyIssuer(issuer),
196
+ ]).then(checks => checks.every(Boolean));
197
+
198
+ export const BRAND_TO_PURSES_KEY = 'brandToPurses';
199
+
200
+ const getBrandToPurses = (walletPurses, key) => {
201
+ const brandToPurses = provideLazy(walletPurses, key, _k => {
202
+ /** @type {MapStore<Brand, PurseRecord[]>} */
203
+ const store = makeScalarBigMapStore('purses by brand', {
204
+ durable: true,
205
+ });
206
+ return store;
207
+ });
208
+ return brandToPurses;
209
+ };
210
+
150
211
  /**
151
212
  * @param {import('@agoric/vat-data').Baggage} baggage
152
213
  * @param {SharedParams} shared
153
214
  */
154
215
  export const prepareSmartWallet = (baggage, shared) => {
155
- const { registry: _, ...passableShared } = shared;
216
+ const { registry: _r, ...passableShared } = shared;
156
217
  mustMatch(
157
218
  harden(passableShared),
158
219
  harden({
@@ -167,6 +228,15 @@ export const prepareSmartWallet = (baggage, shared) => {
167
228
 
168
229
  const makeRecorderKit = prepareRecorderKit(baggage, shared.publicMarshaller);
169
230
 
231
+ const walletPurses = provide(baggage, BRAND_TO_PURSES_KEY, () => {
232
+ trace('make purses by wallet and save in baggage at', BRAND_TO_PURSES_KEY);
233
+ /** @type {WeakMapStore<unknown, MapStore<Brand, PurseRecord[]>>} */
234
+ const store = makeScalarBigWeakMapStore('purses by wallet', {
235
+ durable: true,
236
+ });
237
+ return store;
238
+ });
239
+
170
240
  /**
171
241
  *
172
242
  * @param {UniqueParams} unique
@@ -245,6 +315,9 @@ export const prepareSmartWallet = (baggage, shared) => {
245
315
  helper: M.interface('helperFacetI', {
246
316
  assertUniqueOfferId: M.call(M.string()).returns(),
247
317
  updateBalance: M.call(PurseShape, AmountShape).optional('init').returns(),
318
+ getPurseIfKnownBrand: M.call(BrandShape)
319
+ .optional(M.eref(M.remotable()))
320
+ .returns(M.promise()),
248
321
  publishCurrentState: M.call().returns(),
249
322
  watchPurse: M.call(M.eref(PurseShape)).returns(M.promise()),
250
323
  }),
@@ -369,6 +442,63 @@ export const prepareSmartWallet = (baggage, shared) => {
369
442
  },
370
443
  });
371
444
  },
445
+
446
+ /**
447
+ * Provide a purse given a NameHub of issuers and their
448
+ * brands.
449
+ *
450
+ * We current support only one NameHub, agoricNames, and
451
+ * hence one purse per brand. But we store an array of them
452
+ * to facilitate a transition to decentralized introductions.
453
+ *
454
+ * @param {Brand} brand
455
+ * @param {ERef<NameHub>} known - namehub with brand, issuer branches
456
+ * @returns {Promise<Purse | undefined>} undefined if brand is not known
457
+ */
458
+ async getPurseIfKnownBrand(brand, known) {
459
+ const { helper, self } = this.facets;
460
+ const brandToPurses = getBrandToPurses(walletPurses, self);
461
+
462
+ if (brandToPurses.has(brand)) {
463
+ const purses = brandToPurses.get(brand);
464
+ if (purses.length > 0) {
465
+ // UNTIL https://github.com/Agoric/agoric-sdk/issues/6126
466
+ // multiple purses
467
+ return purses[0].purse;
468
+ }
469
+ }
470
+
471
+ const found = await namesOf(brand, E(known).lookup('brand'));
472
+ if (found.length === 0) {
473
+ return undefined;
474
+ }
475
+ const [edgeName] = found;
476
+ const issuer = await E(known).lookup('issuer', edgeName);
477
+
478
+ // Even though we rely on this nameHub, double-check
479
+ // that the issuer and the brand belong to each other.
480
+ if (!(await checkMutual(issuer, brand))) {
481
+ // if they don't, it's not a "known" brand in a coherent way
482
+ return undefined;
483
+ }
484
+
485
+ // Accept the issuer; rely on it in future offers.
486
+ const [displayInfo, purse] = await Promise.all([
487
+ E(issuer).getDisplayInfo(),
488
+ E(issuer).makeEmptyPurse(),
489
+ ]);
490
+
491
+ // adopt edgeName as petname
492
+ // NOTE: for decentralized introductions, qualify edgename by nameHub petname
493
+ const petname = edgeName;
494
+ const assetInfo = { petname, brand, issuer, purse, displayInfo };
495
+ appendToStoredArray(brandToPurses, brand, assetInfo);
496
+ // NOTE: when we decentralize introduction of issuers,
497
+ // process queued payments for this brand.
498
+
499
+ void helper.watchPurse(purse);
500
+ return purse;
501
+ },
372
502
  },
373
503
  /**
374
504
  * Similar to {DepositFacet} but async because it has to look up the purse.
@@ -379,10 +509,12 @@ export const prepareSmartWallet = (baggage, shared) => {
379
509
  *
380
510
  * If the purse doesn't exist, we hold the payment in durable storage.
381
511
  *
382
- * @param {import('@endo/far').FarRef<Payment>} payment
383
- * @returns {Promise<Amount>} amounts for deferred deposits will be empty
512
+ * @param {Payment} payment
513
+ * @returns {Promise<Amount>}
514
+ * @throws if there's not yet a purse, though the payment is held to try again when there is
384
515
  */
385
516
  async receive(payment) {
517
+ const { helper } = this.facets;
386
518
  const { paymentQueues: queues, bank, invitationPurse } = this.state;
387
519
  const { registry, invitationBrand } = shared;
388
520
  const brand = await E(payment).getAllegedBrand();
@@ -390,17 +522,24 @@ export const prepareSmartWallet = (baggage, shared) => {
390
522
  // When there is a purse deposit into it
391
523
  if (registry.has(brand)) {
392
524
  const purse = E(bank).getPurse(brand);
393
- // @ts-expect-error deposit does take a FarRef<Payment>
394
525
  return E(purse).deposit(payment);
395
526
  } else if (invitationBrand === brand) {
396
- // @ts-expect-error deposit does take a FarRef<Payment>
527
+ // @ts-expect-error narrow assetKind to 'set'
397
528
  return E(invitationPurse).deposit(payment);
398
529
  }
399
530
 
531
+ const purse = await helper.getPurseIfKnownBrand(
532
+ brand,
533
+ shared.agoricNames,
534
+ );
535
+ if (purse) {
536
+ return E(purse).deposit(payment);
537
+ }
538
+
400
539
  // When there is no purse, save the payment into a queue.
401
540
  // It's not yet ever read but a future version of the contract can
402
541
  appendToStoredArray(queues, brand, payment);
403
- return AmountMath.makeEmpty(brand);
542
+ throw Fail`cannot deposit payment with brand ${brand}: no purse`;
404
543
  },
405
544
  },
406
545
  offers: {
@@ -448,6 +587,7 @@ export const prepareSmartWallet = (baggage, shared) => {
448
587
  * @returns {Promise<RemotePurse>}
449
588
  */
450
589
  purseForBrand: async brand => {
590
+ const { helper } = facets;
451
591
  if (registry.has(brand)) {
452
592
  // @ts-expect-error RemotePurse cast
453
593
  return E(bank).getPurse(brand);
@@ -455,6 +595,14 @@ export const prepareSmartWallet = (baggage, shared) => {
455
595
  // @ts-expect-error RemotePurse cast
456
596
  return invitationPurse;
457
597
  }
598
+
599
+ const purse = await helper.getPurseIfKnownBrand(
600
+ brand,
601
+ shared.agoricNames,
602
+ );
603
+ if (purse) {
604
+ return purse;
605
+ }
458
606
  throw Fail`cannot find/make purse for ${brand}`;
459
607
  },
460
608
  logger,
@@ -520,7 +668,7 @@ export const prepareSmartWallet = (baggage, shared) => {
520
668
  * Umarshals the actionCapData and delegates to the appropriate action handler.
521
669
  *
522
670
  * @param {import('@endo/marshal').CapData<string>} actionCapData of type BridgeAction
523
- * @param {boolean} [canSpend=false]
671
+ * @param {boolean} [canSpend]
524
672
  * @returns {Promise<void>}
525
673
  */
526
674
  handleBridgeAction(actionCapData, canSpend = false) {
@@ -1,9 +1,9 @@
1
- export const privateArgsShape: import("@endo/patterns").Matcher;
2
1
  export namespace customTermsShape {
3
2
  const agoricNames: any;
4
3
  const board: any;
5
4
  const assetPublisher: any;
6
5
  }
6
+ export const privateArgsShape: import("@endo/patterns").Matcher;
7
7
  export function publishDepositFacet(address: string, wallet: import('./smartWallet.js').SmartWallet, namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>): Promise<unknown>;
8
8
  export function makeAssetRegistry(assetPublisher: AssetPublisher): {
9
9
  /** @param {Brand} brand */
@@ -39,7 +39,7 @@ export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
39
39
  provideSmartWallet(address: string, bank: ERef<import('@agoric/vats/src/vat-bank').Bank>, namesByAddressAdmin: ERef<import('@agoric/vats/').NameAdmin>): Promise<[wallet: {
40
40
  handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
41
41
  getDepositFacet(): {
42
- receive(payment: import("@endo/far").FarRef<Payment<AssetKind>, import("@endo/eventual-send").DataOnly<Payment<AssetKind>>>): Promise<Amount<AssetKind>>;
42
+ receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
43
43
  };
44
44
  getOffersFacet(): {
45
45
  executeOffer(offerSpec: import("./offers.js").OfferSpec): Promise<void>;
@@ -72,7 +72,7 @@ export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
72
72
  provideSmartWallet(address: string, bank: ERef<import('@agoric/vats/src/vat-bank').Bank>, namesByAddressAdmin: ERef<import('@agoric/vats/').NameAdmin>): Promise<[wallet: {
73
73
  handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
74
74
  getDepositFacet(): {
75
- receive(payment: import("@endo/far").FarRef<Payment<AssetKind>, import("@endo/eventual-send").DataOnly<Payment<AssetKind>>>): Promise<Amount<AssetKind>>;
75
+ receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
76
76
  };
77
77
  getOffersFacet(): {
78
78
  executeOffer(offerSpec: import("./offers.js").OfferSpec): Promise<void>;
@@ -109,4 +109,5 @@ export type WalletReviver = {
109
109
  reviveWallet: (address: string) => Promise<import('./smartWallet').SmartWallet>;
110
110
  ackWallet: (address: string) => isRevive;
111
111
  };
112
+ export type start = typeof prepare;
112
113
  //# sourceMappingURL=walletFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"walletFactory.d.ts","sourceRoot":"","sources":["walletFactory.js"],"names":[],"mappings":"AAkBA,gEAKE;;;;;;AAgBK,6CAJI,MAAM,UACN,OAAO,kBAAkB,EAAE,WAAW,uBACtC,KAAK,OAAO,cAAc,EAAE,SAAS,CAAC,oBAehD;AAWM,kDAFI,cAAc;IAwCrB,2BAA2B;iBAAf,KAAK;IAEjB,2BAA2B;iBAAf,KAAK;eApCP,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO,SAAS,EAAE,OAAO;;;eAH3B,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO,SAAS,EAAE,OAAO;;EAsCxC;AAmCM,6BARI,IAAI,wBAAwB,CAAC;iBAEtB,KAAK,WAAW,CAAC;;;;;QAgH7B;;;;;;;WAOG;oCANQ,MAAM,QACN,KAAK,OAAO,2BAA2B,EAAE,IAAI,CAAC,uBAC9C,KAAK,OAAO,eAAe,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;QAHlD;;;;;;;WAOG;oCANQ,MAAM,QACN,KAAK,OAAO,2BAA2B,EAAE,IAAI,CAAC,uBAC9C,KAAK,OAAO,eAAe,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAgDvD;uCA7LY;IACZ,WAAe,EAAE,KAAK,OAAO,CAAC,CAAC;IAC/B,KAAS,EAAE,KAAK,OAAO,cAAc,EAAE,KAAK,CAAC,CAAC;IAC9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AO;6BAE9B;IACZ,oBAAwB,EAAE,MAAM,KAChC,kBAAwB,OAAO,2BAA2B,EAAE,eAAe,CAAC,CAAC,CAAA;CAC1E;uBAES,OAAO;;4BAES,MAAM,KAAK,QAAQ,OAAO,eAAe,EAAE,WAAW,CAAC;yBAC1D,MAAM,KAAK,QAAQ;;oBAuL/B,cAAc"}
@@ -16,6 +16,12 @@ import { shape } from './typeGuards.js';
16
16
 
17
17
  const trace = makeTracer('WltFct');
18
18
 
19
+ export const customTermsShape = harden({
20
+ agoricNames: M.eref(M.remotable('agoricNames')),
21
+ board: M.eref(M.remotable('board')),
22
+ assetPublisher: M.eref(M.remotable('Bank')),
23
+ });
24
+
19
25
  export const privateArgsShape = harden(
20
26
  M.splitRecord(
21
27
  { storageNode: M.eref(M.remotable('StorageNode')) },
@@ -23,12 +29,6 @@ export const privateArgsShape = harden(
23
29
  ),
24
30
  );
25
31
 
26
- export const customTermsShape = harden({
27
- agoricNames: M.eref(M.remotable('agoricNames')),
28
- board: M.eref(M.remotable('board')),
29
- assetPublisher: M.eref(M.remotable('Bank')),
30
- });
31
-
32
32
  /**
33
33
  * Provide a NameHub for this address and insert depositFacet only if not
34
34
  * already done.
@@ -142,6 +142,7 @@ export const makeAssetRegistry = assetPublisher => {
142
142
  * @param {import('@agoric/vat-data').Baggage} baggage
143
143
  */
144
144
  export const prepare = async (zcf, privateArgs, baggage) => {
145
+ const upgrading = baggage.has('walletsByAddress');
145
146
  const { agoricNames, board, assetPublisher } = zcf.getTerms();
146
147
 
147
148
  const zoe = zcf.getZoeService();
@@ -292,10 +293,19 @@ export const prepare = async (zcf, privateArgs, baggage) => {
292
293
  if (walletBridgeManager) {
293
294
  // NB: may not be in service when creatorFacet is used, or ever
294
295
  // It can't be awaited because that fails vat restart
295
- void E(walletBridgeManager).initHandler(handleWalletAction);
296
+ if (upgrading) {
297
+ void E(walletBridgeManager).setHandler(handleWalletAction);
298
+ } else {
299
+ void E(walletBridgeManager).initHandler(handleWalletAction);
300
+ }
296
301
  }
297
302
 
298
303
  return {
299
304
  creatorFacet,
300
305
  };
301
306
  };
307
+ harden(prepare);
308
+
309
+ // So we can consistently import `start` from contracts.
310
+ // Can't be a value export because Zoe enforces that contracts export one or the other.
311
+ /** @typedef {typeof prepare} start */