@agoric/smart-wallet 0.5.4-u14.1 → 0.5.4-u16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -27
- package/src/invitations.d.ts +14 -10
- package/src/invitations.d.ts.map +1 -1
- package/src/invitations.js +32 -28
- package/src/marshal-contexts.d.ts +44 -41
- package/src/marshal-contexts.d.ts.map +1 -1
- package/src/marshal-contexts.js +65 -58
- package/src/offerWatcher.d.ts +21 -39
- package/src/offerWatcher.d.ts.map +1 -1
- package/src/offerWatcher.js +34 -24
- package/src/offers.d.ts +7 -7
- package/src/offers.d.ts.map +1 -1
- package/src/offers.js +9 -9
- package/src/proposals/upgrade-wallet-factory2-proposal.d.ts.map +1 -1
- package/src/proposals/upgrade-wallet-factory2-proposal.js +2 -1
- package/src/proposals/upgrade-walletFactory-proposal.d.ts +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.d.ts.map +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.js +45 -21
- package/src/smartWallet.d.ts +80 -60
- package/src/smartWallet.d.ts.map +1 -1
- package/src/smartWallet.js +188 -120
- package/src/typeGuards.d.ts +1 -1
- package/src/types.d.ts +14 -13
- package/src/utils.d.ts +17 -14
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +18 -6
- package/src/walletFactory.d.ts +24 -80
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +55 -36
- package/CHANGELOG.md +0 -236
package/src/utils.d.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
/** @import {OfferId, OfferStatus} from './offers.js'; */
|
|
1
2
|
export const NO_SMART_WALLET_ERROR: "no smart wallet";
|
|
2
|
-
export function makeWalletStateCoalescer(invitationBrand?: Brand<"set"> | undefined): {
|
|
3
|
+
export function makeWalletStateCoalescer(invitationBrand?: globalThis.Brand<"set"> | undefined): {
|
|
3
4
|
state: {
|
|
4
|
-
invitationsReceived: Map<
|
|
5
|
-
acceptedIn:
|
|
5
|
+
invitationsReceived: Map<OfferId, {
|
|
6
|
+
acceptedIn: OfferId;
|
|
6
7
|
description: string;
|
|
7
8
|
instance: Instance;
|
|
8
9
|
}>;
|
|
9
|
-
offerStatuses: Map<
|
|
10
|
-
balances: Map<Brand
|
|
10
|
+
offerStatuses: Map<OfferId, OfferStatus>;
|
|
11
|
+
balances: Map<globalThis.Brand, globalThis.Amount>;
|
|
11
12
|
};
|
|
12
|
-
update: (updateRecord: import(
|
|
13
|
+
update: (updateRecord: import("./smartWallet.js").UpdateRecord | {}) => void;
|
|
13
14
|
};
|
|
14
|
-
export function coalesceUpdates(updates: ERef<Subscriber<import(
|
|
15
|
-
invitationsReceived: Map<
|
|
16
|
-
acceptedIn:
|
|
15
|
+
export function coalesceUpdates(updates: ERef<Subscriber<import("./smartWallet.js").UpdateRecord>>, invitationBrand?: globalThis.Brand<"set"> | undefined): {
|
|
16
|
+
invitationsReceived: Map<OfferId, {
|
|
17
|
+
acceptedIn: OfferId;
|
|
17
18
|
description: string;
|
|
18
19
|
instance: Instance;
|
|
19
20
|
}>;
|
|
20
|
-
offerStatuses: Map<
|
|
21
|
-
balances: Map<Brand
|
|
21
|
+
offerStatuses: Map<OfferId, OfferStatus>;
|
|
22
|
+
balances: Map<globalThis.Brand, globalThis.Amount>;
|
|
22
23
|
};
|
|
23
|
-
export function assertHasData(follower: import(
|
|
24
|
-
export function objectMapStoragePath(subscribers?: import("@agoric/zoe/src/contractSupport").TopicsRecord | import("./types.js").PublicSubscribers | undefined): ERef<Record<string, string>> | null;
|
|
25
|
-
export type CoalescedWalletState = ReturnType<typeof makeWalletStateCoalescer>[
|
|
24
|
+
export function assertHasData(follower: import("@agoric/casting").Follower<any>): Promise<void>;
|
|
25
|
+
export function objectMapStoragePath(subscribers?: import("@agoric/zoe/src/contractSupport/topics.js").TopicsRecord | import("./types.js").PublicSubscribers | undefined): ERef<Record<string, string>> | null;
|
|
26
|
+
export type CoalescedWalletState = ReturnType<typeof makeWalletStateCoalescer>["state"];
|
|
27
|
+
import type { OfferId } from './offers.js';
|
|
28
|
+
import type { OfferStatus } from './offers.js';
|
|
26
29
|
//# sourceMappingURL=utils.d.ts.map
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAIA,yDAAyD;AAEzD,sDAAuD;AAKhD;;;wBAYc,OAAO;yBACN,MAAM;sBACT,QAAQ;;;;;2BAOd,OAAO,kBAAkB,EAAE,YAAY,GAAG,EAAE;EAgExD;AAaM,yCAHI,IAAI,CAAC,UAAU,CAAC,OAAO,kBAAkB,EAAE,YAAY,CAAC,CAAC;;oBAnF/C,OAAO;qBACN,MAAM;kBACT,QAAQ;;;;EA6F1B;AAMM,wCAHI,OAAO,iBAAiB,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAYjD;AASM,2KAFM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAW/C;mCAtDa,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,OAAO,CAAC;6BA7F1B,aAAa;iCAAb,aAAa"}
|
package/src/utils.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
/* eslint-disable no-undef-init */
|
|
2
1
|
import { deeplyFulfilledObject, objectMap, makeTracer } from '@agoric/internal';
|
|
3
2
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
4
3
|
import { E } from '@endo/far';
|
|
5
4
|
|
|
5
|
+
/** @import {OfferId, OfferStatus} from './offers.js'; */
|
|
6
|
+
|
|
6
7
|
export const NO_SMART_WALLET_ERROR = 'no smart wallet';
|
|
7
8
|
|
|
8
9
|
const trace = makeTracer('WUTIL', false);
|
|
9
10
|
|
|
10
11
|
/** @param {Brand<'set'>} [invitationBrand] */
|
|
11
12
|
export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
12
|
-
/** @type {Map<
|
|
13
|
+
/** @type {Map<OfferId, OfferStatus>} */
|
|
13
14
|
const offerStatuses = new Map();
|
|
14
15
|
/** @type {Map<Brand, Amount>} */
|
|
15
16
|
const balances = new Map();
|
|
@@ -17,11 +18,21 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
17
18
|
/**
|
|
18
19
|
* keyed by description; xxx assumes unique
|
|
19
20
|
*
|
|
20
|
-
* @type {Map<
|
|
21
|
+
* @type {Map<
|
|
22
|
+
* OfferId,
|
|
23
|
+
* {
|
|
24
|
+
* acceptedIn: OfferId;
|
|
25
|
+
* description: string;
|
|
26
|
+
* instance: Instance;
|
|
27
|
+
* }
|
|
28
|
+
* >}
|
|
21
29
|
*/
|
|
22
30
|
const invitationsReceived = new Map();
|
|
23
31
|
|
|
24
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* @param {import('./smartWallet.js').UpdateRecord | {}} updateRecord newer
|
|
34
|
+
* than previous
|
|
35
|
+
*/
|
|
25
36
|
const update = updateRecord => {
|
|
26
37
|
if (!('updated' in updateRecord)) {
|
|
27
38
|
return;
|
|
@@ -93,7 +104,7 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
93
104
|
* If this proves to be a problem we can add an option to this or a related
|
|
94
105
|
* utility to reset state from RPC.
|
|
95
106
|
*
|
|
96
|
-
* @param {ERef<Subscriber<import('./smartWallet').UpdateRecord>>} updates
|
|
107
|
+
* @param {ERef<Subscriber<import('./smartWallet.js').UpdateRecord>>} updates
|
|
97
108
|
* @param {Brand<'set'>} [invitationBrand]
|
|
98
109
|
*/
|
|
99
110
|
export const coalesceUpdates = (updates, invitationBrand) => {
|
|
@@ -125,7 +136,8 @@ export const assertHasData = async follower => {
|
|
|
125
136
|
/**
|
|
126
137
|
* Handles the case of falsy argument so the caller can consistently await.
|
|
127
138
|
*
|
|
128
|
-
* @param {import('./types.js').PublicSubscribers
|
|
139
|
+
* @param {import('./types.js').PublicSubscribers
|
|
140
|
+
* | import('@agoric/zoe/src/contractSupport/index.js').TopicsRecord} [subscribers]
|
|
129
141
|
* @returns {ERef<Record<string, string>> | null}
|
|
130
142
|
*/
|
|
131
143
|
export const objectMapStoragePath = subscribers => {
|
package/src/walletFactory.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export namespace customTermsShape {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
let agoricNames: globalThis.Pattern;
|
|
3
|
+
let board: globalThis.Pattern;
|
|
4
|
+
let assetPublisher: globalThis.Pattern;
|
|
5
5
|
}
|
|
6
6
|
export const privateArgsShape: import("@endo/patterns").Matcher;
|
|
7
|
-
export function publishDepositFacet(address: string, wallet: import(
|
|
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 */
|
|
10
10
|
has: (brand: Brand) => boolean;
|
|
@@ -13,103 +13,47 @@ export function makeAssetRegistry(assetPublisher: AssetPublisher): {
|
|
|
13
13
|
brand: Brand;
|
|
14
14
|
displayInfo: DisplayInfo;
|
|
15
15
|
issuer: Issuer;
|
|
16
|
-
petname: import(
|
|
16
|
+
petname: import("./types.js").Petname;
|
|
17
17
|
};
|
|
18
18
|
values: () => Iterable<{
|
|
19
19
|
brand: Brand;
|
|
20
20
|
displayInfo: DisplayInfo;
|
|
21
21
|
issuer: Issuer;
|
|
22
|
-
petname: import(
|
|
22
|
+
petname: import("./types.js").Petname;
|
|
23
23
|
}>;
|
|
24
24
|
};
|
|
25
25
|
export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
|
|
26
26
|
storageNode: ERef<StorageNode>;
|
|
27
|
-
walletBridgeManager?: ERef<import("@agoric/vats").ScopedBridgeManager
|
|
28
|
-
walletReviver?: ERef<WalletReviver
|
|
29
|
-
}, baggage:
|
|
30
|
-
creatorFacet: {
|
|
27
|
+
walletBridgeManager?: ERef<import("@agoric/vats").ScopedBridgeManager<"wallet">>;
|
|
28
|
+
walletReviver?: ERef<WalletReviver>;
|
|
29
|
+
}, baggage: import("@agoric/vat-data").Baggage): Promise<{
|
|
30
|
+
creatorFacet: import("@endo/exo").Guarded<{
|
|
31
31
|
/**
|
|
32
32
|
* @param {string} address
|
|
33
|
-
* @param {ERef<import('@agoric/vats/src/vat-bank').Bank>} bank
|
|
34
|
-
* @param {ERef<import('@agoric/vats/').NameAdmin>} namesByAddressAdmin
|
|
35
|
-
* @returns {Promise<
|
|
36
|
-
*
|
|
37
|
-
*
|
|
33
|
+
* @param {ERef<import('@agoric/vats/src/vat-bank.js').Bank>} bank
|
|
34
|
+
* @param {ERef<import('@agoric/vats/src/types.js').NameAdmin>} namesByAddressAdmin
|
|
35
|
+
* @returns {Promise<
|
|
36
|
+
* [wallet: import('./smartWallet.js').SmartWallet, isNew: boolean]
|
|
37
|
+
* >}
|
|
38
|
+
* wallet along with a flag to distinguish between looking up an existing
|
|
39
|
+
* wallet and creating a new one.
|
|
38
40
|
*/
|
|
39
|
-
provideSmartWallet(address: string, bank: ERef<import(
|
|
40
|
-
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
41
|
-
getDepositFacet(): {
|
|
42
|
-
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
43
|
-
};
|
|
44
|
-
getOffersFacet(): {
|
|
45
|
-
executeOffer(offerSpec: import("./smartWallet.js").OfferSpec): Promise<void>;
|
|
46
|
-
tryExitOffer(offerId: import("./smartWallet.js").OfferId): Promise<void>;
|
|
47
|
-
};
|
|
48
|
-
getCurrentSubscriber(): Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
49
|
-
getUpdatesSubscriber(): Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
50
|
-
getPublicTopics(): {
|
|
51
|
-
current: {
|
|
52
|
-
description: string;
|
|
53
|
-
subscriber: Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
54
|
-
storagePath: Promise<string>;
|
|
55
|
-
};
|
|
56
|
-
updates: {
|
|
57
|
-
description: string;
|
|
58
|
-
subscriber: Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
59
|
-
storagePath: Promise<string>;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
repairWalletForIncarnation2(key: any): void;
|
|
63
|
-
}, isNew: boolean]>;
|
|
64
|
-
} & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
65
|
-
/**
|
|
66
|
-
* @param {string} address
|
|
67
|
-
* @param {ERef<import('@agoric/vats/src/vat-bank').Bank>} bank
|
|
68
|
-
* @param {ERef<import('@agoric/vats/').NameAdmin>} namesByAddressAdmin
|
|
69
|
-
* @returns {Promise<[wallet: import('./smartWallet').SmartWallet, isNew: boolean]>} wallet
|
|
70
|
-
* along with a flag to distinguish between looking up an existing wallet
|
|
71
|
-
* and creating a new one.
|
|
72
|
-
*/
|
|
73
|
-
provideSmartWallet(address: string, bank: ERef<import('@agoric/vats/src/vat-bank').Bank>, namesByAddressAdmin: ERef<import('@agoric/vats/').NameAdmin>): Promise<[wallet: {
|
|
74
|
-
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
75
|
-
getDepositFacet(): {
|
|
76
|
-
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
77
|
-
};
|
|
78
|
-
getOffersFacet(): {
|
|
79
|
-
executeOffer(offerSpec: import("./smartWallet.js").OfferSpec): Promise<void>;
|
|
80
|
-
tryExitOffer(offerId: import("./smartWallet.js").OfferId): Promise<void>;
|
|
81
|
-
};
|
|
82
|
-
getCurrentSubscriber(): Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
83
|
-
getUpdatesSubscriber(): Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
84
|
-
getPublicTopics(): {
|
|
85
|
-
current: {
|
|
86
|
-
description: string;
|
|
87
|
-
subscriber: Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
88
|
-
storagePath: Promise<string>;
|
|
89
|
-
};
|
|
90
|
-
updates: {
|
|
91
|
-
description: string;
|
|
92
|
-
subscriber: Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
93
|
-
storagePath: Promise<string>;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
repairWalletForIncarnation2(key: any): void;
|
|
97
|
-
}, isNew: boolean]>;
|
|
41
|
+
provideSmartWallet(address: string, bank: ERef<import("@agoric/vats/src/vat-bank.js").Bank>, namesByAddressAdmin: ERef<import("@agoric/vats/src/types.js").NameAdmin>): Promise<[wallet: import("./smartWallet.js").SmartWallet, isNew: boolean]>;
|
|
98
42
|
}>;
|
|
99
43
|
}>;
|
|
100
44
|
export type SmartWalletContractTerms = {
|
|
101
45
|
agoricNames: ERef<NameHub>;
|
|
102
|
-
board: ERef<import(
|
|
46
|
+
board: ERef<import("@agoric/vats").Board>;
|
|
103
47
|
assetPublisher: AssetPublisher;
|
|
104
48
|
};
|
|
105
|
-
export type NameHub = import('@agoric/vats').NameHub;
|
|
106
49
|
export type AssetPublisher = {
|
|
107
|
-
getAssetSubscription: () => ERef<IterableEachTopic<import(
|
|
50
|
+
getAssetSubscription: () => ERef<IterableEachTopic<import("@agoric/vats/src/vat-bank.js").AssetDescriptor>>;
|
|
108
51
|
};
|
|
109
|
-
export type
|
|
52
|
+
export type IsRevive = boolean;
|
|
110
53
|
export type WalletReviver = {
|
|
111
|
-
reviveWallet: (address: string) => Promise<import(
|
|
112
|
-
ackWallet: (address: string) =>
|
|
54
|
+
reviveWallet: (address: string) => Promise<import("./smartWallet.js").SmartWallet>;
|
|
55
|
+
ackWallet: (address: string) => IsRevive;
|
|
113
56
|
};
|
|
114
57
|
export type start = typeof prepare;
|
|
58
|
+
import type { NameHub } from '@agoric/vats';
|
|
115
59
|
//# 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":";;;;;AA6BA,gEAKE;AAaK,6CAJI,MAAM,UACN,OAAO,kBAAkB,EAAE,WAAW,uBACtC,IAAI,CAAC,OAAO,cAAc,EAAE,SAAS,CAAC,oBAehD;AAWM,kDAFI,cAAc;IAyCrB,2BAA2B;iBAAf,KAAK;IAEjB,2BAA2B;iBAAf,KAAK;eArCP,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO,YAAY,EAAE,OAAO;;;eAH9B,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO,YAAY,EAAE,OAAO;;EAuC3C;AAyCM,6BAVI,GAAG,CAAC,wBAAwB,CAAC,eAC7B;IACV,WAAe,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnC,mBAAuB,CAAC,EAAE,IAAI,CAC9B,OAAa,cAAc,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CACrD,CAAC;IACN,aAAiB,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;CACrC,WACO,OAAO,kBAAkB,EAAE,OAAO;;QA2IvC;;;;;;;;;WASG;oCARQ,MAAM,QACN,IAAI,CAAC,OAAO,8BAA8B,EAAE,IAAI,CAAC,uBACjD,IAAI,CAAC,OAAO,2BAA2B,EAAE,SAAS,CAAC,GACjD,OAAO,CACnB,CAAK,MAAM,EAAE,OAAO,kBAAkB,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,CACjE;;GAuDT;uCA5OY;IACZ,WAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,KAAS,EAAE,IAAI,CAAC,OAAO,cAAc,EAAE,KAAK,CAAC,CAAC;IAC9C,cAAkB,EAAE,cAAc,CAAC;CAChC;6BAGS;IACZ,oBAAwB,EAAE,MAAM,IAAI,CACpC,iBAAuB,CAAC,OAAO,8BAA8B,EAAE,eAAe,CAAC,CAC1E,CAAC;CACH;uBAGS,OAAO;4BAEP;IACZ,YAAgB,EAAE,CAClB,OAAa,EAAE,MAAM,KACZ,OAAO,CAAC,OAAO,kBAAkB,EAAE,WAAW,CAAC,CAAC;IACzD,SAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,QAAQ,CAAC;CAC1C;oBA4NU,OAAO,OAAO;6BAtVD,cAAc"}
|
package/src/walletFactory.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Wallet Factory
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Contract to make smart wallets.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Note: The upgrade test uses a slightly modified copy of this file. When the
|
|
7
|
+
* interface changes here, that will also need to change.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { makeTracer, WalletName } from '@agoric/internal';
|
|
@@ -17,6 +17,8 @@ import { E } from '@endo/far';
|
|
|
17
17
|
import { prepareSmartWallet } from './smartWallet.js';
|
|
18
18
|
import { shape } from './typeGuards.js';
|
|
19
19
|
|
|
20
|
+
/** @import {NameHub} from '@agoric/vats'; */
|
|
21
|
+
|
|
20
22
|
const trace = makeTracer('WltFct');
|
|
21
23
|
|
|
22
24
|
export const customTermsShape = harden({
|
|
@@ -62,8 +64,8 @@ export const publishDepositFacet = async (
|
|
|
62
64
|
* Make a registry for use by the wallet instances.
|
|
63
65
|
*
|
|
64
66
|
* This doesn't need to persist durably because the `assetPublisher` has a
|
|
65
|
-
* "pinned" topic and call to getAssetSubscription gets a fresh stream of all
|
|
66
|
-
* assets that it knows of.
|
|
67
|
+
* "pinned" topic and call to getAssetSubscription gets a fresh stream of all
|
|
68
|
+
* the assets that it knows of.
|
|
67
69
|
*
|
|
68
70
|
* @param {AssetPublisher} assetPublisher
|
|
69
71
|
*/
|
|
@@ -71,12 +73,13 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
71
73
|
trace('makeAssetRegistry', assetPublisher);
|
|
72
74
|
/**
|
|
73
75
|
* @typedef {{
|
|
74
|
-
* brand: Brand
|
|
75
|
-
* displayInfo: DisplayInfo
|
|
76
|
-
* issuer: Issuer
|
|
77
|
-
* petname: import('./types').Petname
|
|
76
|
+
* brand: Brand;
|
|
77
|
+
* displayInfo: DisplayInfo;
|
|
78
|
+
* issuer: Issuer;
|
|
79
|
+
* petname: import('./types.js').Petname;
|
|
78
80
|
* }} BrandDescriptor
|
|
79
|
-
*
|
|
81
|
+
* For use by clients to describe brands to users. Includes `displayInfo` to
|
|
82
|
+
* save a remote call.
|
|
80
83
|
*/
|
|
81
84
|
/** @type {MapStore<Brand, BrandDescriptor>} */
|
|
82
85
|
const brandDescriptors = makeScalarMapStore();
|
|
@@ -116,22 +119,26 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
116
119
|
|
|
117
120
|
/**
|
|
118
121
|
* @typedef {{
|
|
119
|
-
* agoricNames: ERef<NameHub
|
|
120
|
-
* board: ERef<import('@agoric/vats').Board
|
|
121
|
-
* assetPublisher: AssetPublisher
|
|
122
|
+
* agoricNames: ERef<NameHub>;
|
|
123
|
+
* board: ERef<import('@agoric/vats').Board>;
|
|
124
|
+
* assetPublisher: AssetPublisher;
|
|
122
125
|
* }} SmartWalletContractTerms
|
|
123
126
|
*
|
|
124
|
-
* @typedef {import('@agoric/vats').NameHub} NameHub
|
|
125
127
|
*
|
|
126
128
|
* @typedef {{
|
|
127
129
|
* getAssetSubscription: () => ERef<
|
|
128
|
-
* IterableEachTopic<import('@agoric/vats/src/vat-bank').AssetDescriptor
|
|
130
|
+
* IterableEachTopic<import('@agoric/vats/src/vat-bank.js').AssetDescriptor>
|
|
131
|
+
* >;
|
|
129
132
|
* }} AssetPublisher
|
|
130
133
|
*
|
|
131
|
-
*
|
|
134
|
+
*
|
|
135
|
+
* @typedef {boolean} IsRevive
|
|
136
|
+
*
|
|
132
137
|
* @typedef {{
|
|
133
|
-
* reviveWallet: (
|
|
134
|
-
*
|
|
138
|
+
* reviveWallet: (
|
|
139
|
+
* address: string,
|
|
140
|
+
* ) => Promise<import('./smartWallet.js').SmartWallet>;
|
|
141
|
+
* ackWallet: (address: string) => IsRevive;
|
|
135
142
|
* }} WalletReviver
|
|
136
143
|
*/
|
|
137
144
|
|
|
@@ -141,9 +148,11 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
141
148
|
/**
|
|
142
149
|
* @param {ZCF<SmartWalletContractTerms>} zcf
|
|
143
150
|
* @param {{
|
|
144
|
-
* storageNode: ERef<StorageNode
|
|
145
|
-
* walletBridgeManager?: ERef<
|
|
146
|
-
*
|
|
151
|
+
* storageNode: ERef<StorageNode>;
|
|
152
|
+
* walletBridgeManager?: ERef<
|
|
153
|
+
* import('@agoric/vats').ScopedBridgeManager<'wallet'>
|
|
154
|
+
* >;
|
|
155
|
+
* walletReviver?: ERef<WalletReviver>;
|
|
147
156
|
* }} privateArgs
|
|
148
157
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
149
158
|
*/
|
|
@@ -167,17 +176,20 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
167
176
|
/**
|
|
168
177
|
* Designed to be called by the bridgeManager vat.
|
|
169
178
|
*
|
|
170
|
-
* If this errors before calling handleBridgeAction(), the failure will
|
|
171
|
-
* promise does reject, but as of now bridge
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
179
|
+
* If this errors before calling handleBridgeAction(), the failure will
|
|
180
|
+
* not be observable. The promise does reject, but as of now bridge
|
|
181
|
+
* manager drops instead of handling it. Eventually we'll make the bridge
|
|
182
|
+
* able to give feedback about the requesting transaction. Meanwhile we
|
|
183
|
+
* could write the error to chainStorage but we don't have a guarantee of
|
|
184
|
+
* the wallet owner to associate it with. (We could have a shared
|
|
185
|
+
* `lastError` node but it would be so noisy as to not provide much info
|
|
186
|
+
* to the end user.)
|
|
176
187
|
*
|
|
177
|
-
* Once the owner is known, this calls handleBridgeAction which ensures
|
|
178
|
-
* are published in the owner wallet's vstorage path.
|
|
188
|
+
* Once the owner is known, this calls handleBridgeAction which ensures
|
|
189
|
+
* that all errors are published in the owner wallet's vstorage path.
|
|
179
190
|
*
|
|
180
|
-
* @param {import('./types.js').WalletBridgeMsg} obj validated by
|
|
191
|
+
* @param {import('./types.js').WalletBridgeMsg} obj validated by
|
|
192
|
+
* shape.WalletBridgeMsg
|
|
181
193
|
* @returns {Promise<void>}
|
|
182
194
|
*/
|
|
183
195
|
fromBridge: async obj => {
|
|
@@ -248,6 +260,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
248
260
|
|
|
249
261
|
/**
|
|
250
262
|
* Holders of this object:
|
|
263
|
+
*
|
|
251
264
|
* - vat (transitively from holding the wallet factory)
|
|
252
265
|
* - wallet-ui (which has key material; dapps use wallet-ui to propose actions)
|
|
253
266
|
*/
|
|
@@ -282,16 +295,22 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
282
295
|
{
|
|
283
296
|
/**
|
|
284
297
|
* @param {string} address
|
|
285
|
-
* @param {ERef<import('@agoric/vats/src/vat-bank').Bank>} bank
|
|
286
|
-
* @param {ERef<import('@agoric/vats/').NameAdmin>} namesByAddressAdmin
|
|
287
|
-
* @returns {Promise<
|
|
288
|
-
*
|
|
289
|
-
*
|
|
298
|
+
* @param {ERef<import('@agoric/vats/src/vat-bank.js').Bank>} bank
|
|
299
|
+
* @param {ERef<import('@agoric/vats/src/types.js').NameAdmin>} namesByAddressAdmin
|
|
300
|
+
* @returns {Promise<
|
|
301
|
+
* [wallet: import('./smartWallet.js').SmartWallet, isNew: boolean]
|
|
302
|
+
* >}
|
|
303
|
+
* wallet along with a flag to distinguish between looking up an existing
|
|
304
|
+
* wallet and creating a new one.
|
|
290
305
|
*/
|
|
291
306
|
provideSmartWallet(address, bank, namesByAddressAdmin) {
|
|
292
307
|
let isNew = false;
|
|
293
308
|
|
|
294
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* @type {(
|
|
311
|
+
* address: string,
|
|
312
|
+
* ) => Promise<import('./smartWallet.js').SmartWallet>}
|
|
313
|
+
*/
|
|
295
314
|
const maker = async _address => {
|
|
296
315
|
const invitationPurse = await E(invitationIssuer).makeEmptyPurse();
|
|
297
316
|
const walletStorageNode = E(storageNode).makeChildNode(address);
|