@agoric/smart-wallet 0.5.4-mainnet1B-dev-b0c1f78.0 → 0.5.4-orchestration-dev-096c4e8.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 +30 -24
- package/src/invitations.d.ts +1 -1
- package/src/invitations.d.ts.map +1 -1
- package/src/invitations.js +2 -2
- package/src/offerWatcher.d.ts +42 -0
- package/src/offerWatcher.d.ts.map +1 -0
- package/src/offerWatcher.js +294 -0
- package/src/offers.d.ts +2 -26
- package/src/offers.d.ts.map +1 -1
- package/src/offers.js +1 -175
- package/src/proposals/upgrade-wallet-factory2-proposal.d.ts +23 -0
- package/src/proposals/upgrade-wallet-factory2-proposal.d.ts.map +1 -0
- package/src/proposals/upgrade-wallet-factory2-proposal.js +58 -0
- package/src/proposals/upgrade-walletFactory-proposal.d.ts +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.d.ts.map +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.js +42 -17
- package/src/smartWallet.d.ts +46 -24
- package/src/smartWallet.d.ts.map +1 -1
- package/src/smartWallet.js +554 -145
- package/src/typeGuards.d.ts +1 -1
- package/src/types.d.ts +7 -8
- package/src/utils.d.ts +9 -9
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +5 -5
- package/src/walletFactory.d.ts +77 -37
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +42 -10
- package/CHANGELOG.md +0 -208
- package/src/payments.d.ts +0 -20
- package/src/payments.d.ts.map +0 -1
- package/src/payments.js +0 -89
package/src/typeGuards.d.ts
CHANGED
package/src/types.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* Downside is it can't reference any ambient types, which most of agoric-sdk type are presently.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ERef
|
|
8
|
+
import type { ERef } from '@endo/far';
|
|
9
9
|
import type { CapData } from '@endo/marshal';
|
|
10
|
-
import type {
|
|
10
|
+
import type { agoric } from '@agoric/cosmic-proto';
|
|
11
11
|
import type { AgoricNamesRemotes } from '@agoric/vats/tools/board-utils.js';
|
|
12
12
|
import type { OfferSpec } from './offers.js';
|
|
13
13
|
|
|
@@ -21,10 +21,9 @@ declare const CapDataShape: unique symbol;
|
|
|
21
21
|
*/
|
|
22
22
|
export type Petname = string | string[];
|
|
23
23
|
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Record<string, (...args: any[]) => Promise<Invitation>>
|
|
24
|
+
export type InvitationMakers = Record<
|
|
25
|
+
string,
|
|
26
|
+
(...args: any[]) => Promise<Invitation>
|
|
28
27
|
>;
|
|
29
28
|
|
|
30
29
|
export type PublicSubscribers = Record<string, ERef<StoredFacet>>;
|
|
@@ -41,7 +40,7 @@ export type BridgeActionCapData = WalletCapData<
|
|
|
41
40
|
/**
|
|
42
41
|
* Defined by walletAction struct in msg_server.go
|
|
43
42
|
*
|
|
44
|
-
* @see {
|
|
43
|
+
* @see {agoric.swingset.MsgWalletAction} and walletSpendAction in msg_server.go
|
|
45
44
|
*/
|
|
46
45
|
export type WalletActionMsg = {
|
|
47
46
|
type: 'WALLET_ACTION';
|
|
@@ -56,7 +55,7 @@ export type WalletActionMsg = {
|
|
|
56
55
|
/**
|
|
57
56
|
* Defined by walletSpendAction struct in msg_server.go
|
|
58
57
|
*
|
|
59
|
-
* @see {MsgWalletSpendAction} and walletSpendAction in msg_server.go
|
|
58
|
+
* @see {agoric.swingset.MsgWalletSpendAction} and walletSpendAction in msg_server.go
|
|
60
59
|
*/
|
|
61
60
|
export type WalletSpendActionMsg = {
|
|
62
61
|
type: 'WALLET_SPEND_ACTION';
|
package/src/utils.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
export const NO_SMART_WALLET_ERROR: "no smart wallet";
|
|
2
2
|
export function makeWalletStateCoalescer(invitationBrand?: Brand<"set"> | undefined): {
|
|
3
3
|
state: {
|
|
4
|
-
invitationsReceived: Map<import("./offers").OfferId, {
|
|
5
|
-
acceptedIn: import('./offers').OfferId;
|
|
4
|
+
invitationsReceived: Map<import("./offers.js").OfferId, {
|
|
5
|
+
acceptedIn: import('./offers.js').OfferId;
|
|
6
6
|
description: string;
|
|
7
7
|
instance: Instance;
|
|
8
8
|
}>;
|
|
9
|
-
offerStatuses: Map<import("./offers").OfferId, import("./offers").OfferStatus>;
|
|
9
|
+
offerStatuses: Map<import("./offers.js").OfferId, import("./offers.js").OfferStatus>;
|
|
10
10
|
balances: Map<Brand<AssetKind>, Amount<AssetKind>>;
|
|
11
11
|
};
|
|
12
|
-
update: (updateRecord: import('./smartWallet').UpdateRecord | {}) => void;
|
|
12
|
+
update: (updateRecord: import('./smartWallet.js').UpdateRecord | {}) => void;
|
|
13
13
|
};
|
|
14
|
-
export function coalesceUpdates(updates: ERef<Subscriber<import('./smartWallet').UpdateRecord>>, invitationBrand?: Brand<"set"> | undefined): {
|
|
15
|
-
invitationsReceived: Map<import("./offers").OfferId, {
|
|
16
|
-
acceptedIn: import('./offers').OfferId;
|
|
14
|
+
export function coalesceUpdates(updates: ERef<Subscriber<import('./smartWallet.js').UpdateRecord>>, invitationBrand?: Brand<"set"> | undefined): {
|
|
15
|
+
invitationsReceived: Map<import("./offers.js").OfferId, {
|
|
16
|
+
acceptedIn: import('./offers.js').OfferId;
|
|
17
17
|
description: string;
|
|
18
18
|
instance: Instance;
|
|
19
19
|
}>;
|
|
20
|
-
offerStatuses: Map<import("./offers").OfferId, import("./offers").OfferStatus>;
|
|
20
|
+
offerStatuses: Map<import("./offers.js").OfferId, import("./offers.js").OfferStatus>;
|
|
21
21
|
balances: Map<Brand<AssetKind>, Amount<AssetKind>>;
|
|
22
22
|
};
|
|
23
23
|
export function assertHasData(follower: import('@agoric/casting').Follower<any>): Promise<void>;
|
|
24
|
-
export function objectMapStoragePath(subscribers?: import("
|
|
24
|
+
export function objectMapStoragePath(subscribers?: import("./types.js").PublicSubscribers | import("@agoric/zoe/src/contractSupport/topics.js").TopicsRecord | undefined): ERef<Record<string, string>> | null;
|
|
25
25
|
export type CoalescedWalletState = ReturnType<typeof makeWalletStateCoalescer>['state'];
|
|
26
26
|
//# 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":"AAKA,sDAAuD;AAKhD;;;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAKA,sDAAuD;AAKhD;;;wBASsD,OAAO,aAAa,EAAE,OAAO;yBAAe,MAAM;sBAAY,QAAQ;;;;;2BAIrH,OAAO,kBAAkB,EAAE,YAAY,GAAG,EAAE;EA8DzD;AAaM,yCAHI,KAAK,WAAW,OAAO,kBAAkB,EAAE,YAAY,CAAC,CAAC;;oBA5EP,OAAO,aAAa,EAAE,OAAO;qBAAe,MAAM;kBAAY,QAAQ;;;;EAwFlI;AAMM,wCAHI,OAAO,iBAAiB,EAAE,QAAQ,CAAC,GAAG,CAAC,iBAYjD;AAQM,2KAFM,KAAK,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAW/C;mCArDa,WAAW,+BAA+B,CAAC,CAAC,OAAO,CAAC"}
|
package/src/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ const trace = makeTracer('WUTIL', false);
|
|
|
9
9
|
|
|
10
10
|
/** @param {Brand<'set'>} [invitationBrand] */
|
|
11
11
|
export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
12
|
-
/** @type {Map<import('./offers').OfferId, import('./offers').OfferStatus>} */
|
|
12
|
+
/** @type {Map<import('./offers.js').OfferId, import('./offers.js').OfferStatus>} */
|
|
13
13
|
const offerStatuses = new Map();
|
|
14
14
|
/** @type {Map<Brand, Amount>} */
|
|
15
15
|
const balances = new Map();
|
|
@@ -17,11 +17,11 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
17
17
|
/**
|
|
18
18
|
* keyed by description; xxx assumes unique
|
|
19
19
|
*
|
|
20
|
-
* @type {Map<import('./offers').OfferId, { acceptedIn: import('./offers').OfferId, description: string, instance: Instance }>}
|
|
20
|
+
* @type {Map<import('./offers.js').OfferId, { acceptedIn: import('./offers.js').OfferId, description: string, instance: Instance }>}
|
|
21
21
|
*/
|
|
22
22
|
const invitationsReceived = new Map();
|
|
23
23
|
|
|
24
|
-
/** @param {import('./smartWallet').UpdateRecord | {}} updateRecord newer than previous */
|
|
24
|
+
/** @param {import('./smartWallet.js').UpdateRecord | {}} updateRecord newer than previous */
|
|
25
25
|
const update = updateRecord => {
|
|
26
26
|
if (!('updated' in updateRecord)) {
|
|
27
27
|
return;
|
|
@@ -93,7 +93,7 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
93
93
|
* If this proves to be a problem we can add an option to this or a related
|
|
94
94
|
* utility to reset state from RPC.
|
|
95
95
|
*
|
|
96
|
-
* @param {ERef<Subscriber<import('./smartWallet').UpdateRecord>>} updates
|
|
96
|
+
* @param {ERef<Subscriber<import('./smartWallet.js').UpdateRecord>>} updates
|
|
97
97
|
* @param {Brand<'set'>} [invitationBrand]
|
|
98
98
|
*/
|
|
99
99
|
export const coalesceUpdates = (updates, invitationBrand) => {
|
|
@@ -125,7 +125,7 @@ export const assertHasData = async follower => {
|
|
|
125
125
|
/**
|
|
126
126
|
* Handles the case of falsy argument so the caller can consistently await.
|
|
127
127
|
*
|
|
128
|
-
* @param {import('./types.js').PublicSubscribers | import('@agoric/zoe/src/contractSupport').TopicsRecord} [subscribers]
|
|
128
|
+
* @param {import('./types.js').PublicSubscribers | import('@agoric/zoe/src/contractSupport/index.js').TopicsRecord} [subscribers]
|
|
129
129
|
* @returns {ERef<Record<string, string>> | null}
|
|
130
130
|
*/
|
|
131
131
|
export const objectMapStoragePath = subscribers => {
|
package/src/walletFactory.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export namespace customTermsShape {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
let agoricNames: any;
|
|
3
|
+
let board: any;
|
|
4
|
+
let assetPublisher: any;
|
|
5
5
|
}
|
|
6
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>;
|
|
@@ -13,38 +13,38 @@ export function makeAssetRegistry(assetPublisher: AssetPublisher): {
|
|
|
13
13
|
brand: Brand;
|
|
14
14
|
displayInfo: DisplayInfo;
|
|
15
15
|
issuer: Issuer;
|
|
16
|
-
petname: import('./types').Petname;
|
|
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('./types').Petname;
|
|
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
27
|
walletBridgeManager?: ERef<import("@agoric/vats").ScopedBridgeManager> | undefined;
|
|
28
28
|
walletReviver?: ERef<WalletReviver> | undefined;
|
|
29
|
-
}, baggage:
|
|
30
|
-
creatorFacet: {
|
|
29
|
+
}, baggage: import('@agoric/vat-data').Baggage): Promise<{
|
|
30
|
+
creatorFacet: import("@endo/exo/src/exo-makers.js").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<[wallet: import('./smartWallet').SmartWallet, isNew: boolean]>} wallet
|
|
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<[wallet: import('./smartWallet.js').SmartWallet, isNew: boolean]>} wallet
|
|
36
36
|
* along with a flag to distinguish between looking up an existing wallet
|
|
37
37
|
* and creating a new one.
|
|
38
38
|
*/
|
|
39
|
-
provideSmartWallet(address: string, bank: ERef<import('@agoric/vats/src/vat-bank').Bank>, namesByAddressAdmin: ERef<import('@agoric/vats/').NameAdmin>): Promise<[wallet: {
|
|
40
|
-
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
41
|
-
getDepositFacet(): {
|
|
39
|
+
provideSmartWallet(address: string, bank: ERef<import('@agoric/vats/src/vat-bank.js').Bank>, namesByAddressAdmin: ERef<import('@agoric/vats/src/types.js').NameAdmin>): Promise<[wallet: {
|
|
40
|
+
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string | null>, canSpend?: boolean | undefined): Promise<void>;
|
|
41
|
+
getDepositFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
42
42
|
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
43
|
-
}
|
|
44
|
-
getOffersFacet(): {
|
|
45
|
-
executeOffer(offerSpec: import("./
|
|
46
|
-
tryExitOffer(offerId: import("./
|
|
47
|
-
}
|
|
43
|
+
}>;
|
|
44
|
+
getOffersFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
45
|
+
executeOffer(offerSpec: import("./smartWallet.js").OfferSpec): Promise<void>;
|
|
46
|
+
tryExitOffer(offerId: import("./smartWallet.js").OfferId): Promise<void>;
|
|
47
|
+
}>;
|
|
48
48
|
getCurrentSubscriber(): Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
49
49
|
getUpdatesSubscriber(): Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
50
50
|
getPublicTopics(): {
|
|
@@ -59,25 +59,64 @@ export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
|
|
|
59
59
|
storagePath: Promise<string>;
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @param {ERef<import('@agoric/vats/src/vat-bank').Bank>} bank
|
|
67
|
-
* @param {ERef<import('@agoric/vats/').NameAdmin>} namesByAddressAdmin
|
|
68
|
-
* @returns {Promise<[wallet: import('./smartWallet').SmartWallet, isNew: boolean]>} wallet
|
|
69
|
-
* along with a flag to distinguish between looking up an existing wallet
|
|
70
|
-
* and creating a new one.
|
|
71
|
-
*/
|
|
72
|
-
provideSmartWallet(address: string, bank: ERef<import('@agoric/vats/src/vat-bank').Bank>, namesByAddressAdmin: ERef<import('@agoric/vats/').NameAdmin>): Promise<[wallet: {
|
|
73
|
-
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
74
|
-
getDepositFacet(): {
|
|
62
|
+
repairWalletForIncarnation2(key: any): void;
|
|
63
|
+
} & import("@endo/exo/src/get-interface.js").GetInterfaceGuard<{
|
|
64
|
+
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string | null>, canSpend?: boolean | undefined): Promise<void>;
|
|
65
|
+
getDepositFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
75
66
|
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
67
|
+
}>;
|
|
68
|
+
getOffersFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
69
|
+
executeOffer(offerSpec: import("./smartWallet.js").OfferSpec): Promise<void>;
|
|
70
|
+
tryExitOffer(offerId: import("./smartWallet.js").OfferId): Promise<void>;
|
|
71
|
+
}>;
|
|
72
|
+
getCurrentSubscriber(): Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
73
|
+
getUpdatesSubscriber(): Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
74
|
+
getPublicTopics(): {
|
|
75
|
+
current: {
|
|
76
|
+
description: string;
|
|
77
|
+
subscriber: Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
78
|
+
storagePath: Promise<string>;
|
|
79
|
+
};
|
|
80
|
+
updates: {
|
|
81
|
+
description: string;
|
|
82
|
+
subscriber: Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
83
|
+
storagePath: Promise<string>;
|
|
84
|
+
};
|
|
76
85
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
repairWalletForIncarnation2(key: any): void;
|
|
87
|
+
}> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
88
|
+
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string | null>, canSpend?: boolean | undefined): Promise<void>;
|
|
89
|
+
getDepositFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
90
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
91
|
+
}>;
|
|
92
|
+
getOffersFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
93
|
+
executeOffer(offerSpec: import("./smartWallet.js").OfferSpec): Promise<void>;
|
|
94
|
+
tryExitOffer(offerId: import("./smartWallet.js").OfferId): Promise<void>;
|
|
95
|
+
}>;
|
|
96
|
+
getCurrentSubscriber(): Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
97
|
+
getUpdatesSubscriber(): Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
98
|
+
getPublicTopics(): {
|
|
99
|
+
current: {
|
|
100
|
+
description: string;
|
|
101
|
+
subscriber: Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
102
|
+
storagePath: Promise<string>;
|
|
103
|
+
};
|
|
104
|
+
updates: {
|
|
105
|
+
description: string;
|
|
106
|
+
subscriber: Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
107
|
+
storagePath: Promise<string>;
|
|
108
|
+
};
|
|
80
109
|
};
|
|
110
|
+
repairWalletForIncarnation2(key: any): void;
|
|
111
|
+
} & import("@endo/exo/src/get-interface.js").GetInterfaceGuard<{
|
|
112
|
+
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string | null>, canSpend?: boolean | undefined): Promise<void>;
|
|
113
|
+
getDepositFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
114
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
115
|
+
}>;
|
|
116
|
+
getOffersFacet(): import("@endo/exo/src/exo-makers.js").Guarded<{
|
|
117
|
+
executeOffer(offerSpec: import("./smartWallet.js").OfferSpec): Promise<void>;
|
|
118
|
+
tryExitOffer(offerId: import("./smartWallet.js").OfferId): Promise<void>;
|
|
119
|
+
}>;
|
|
81
120
|
getCurrentSubscriber(): Subscriber<import("./smartWallet.js").CurrentWalletRecord>;
|
|
82
121
|
getUpdatesSubscriber(): Subscriber<import("./smartWallet.js").UpdateRecord>;
|
|
83
122
|
getPublicTopics(): {
|
|
@@ -92,7 +131,8 @@ export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
|
|
|
92
131
|
storagePath: Promise<string>;
|
|
93
132
|
};
|
|
94
133
|
};
|
|
95
|
-
|
|
134
|
+
repairWalletForIncarnation2(key: any): void;
|
|
135
|
+
}>>, isNew: boolean]>;
|
|
96
136
|
}>;
|
|
97
137
|
}>;
|
|
98
138
|
export type SmartWalletContractTerms = {
|
|
@@ -102,11 +142,11 @@ export type SmartWalletContractTerms = {
|
|
|
102
142
|
};
|
|
103
143
|
export type NameHub = import('@agoric/vats').NameHub;
|
|
104
144
|
export type AssetPublisher = {
|
|
105
|
-
getAssetSubscription: () => ERef<IterableEachTopic<import('@agoric/vats/src/vat-bank').AssetDescriptor>>;
|
|
145
|
+
getAssetSubscription: () => ERef<IterableEachTopic<import('@agoric/vats/src/vat-bank.js').AssetDescriptor>>;
|
|
106
146
|
};
|
|
107
147
|
export type isRevive = boolean;
|
|
108
148
|
export type WalletReviver = {
|
|
109
|
-
reviveWallet: (address: string) => Promise<import('./smartWallet').SmartWallet>;
|
|
149
|
+
reviveWallet: (address: string) => Promise<import('./smartWallet.js').SmartWallet>;
|
|
110
150
|
ackWallet: (address: string) => isRevive;
|
|
111
151
|
};
|
|
112
152
|
export type start = typeof prepare;
|
|
@@ -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":";;;;;AA2BA,gEAKE;AAaK,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,YAAY,EAAE,OAAO;;;eAH9B,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO,YAAY,EAAE,OAAO;;EAsC3C;AAmCM,6BARI,IAAI,wBAAwB,CAAC;iBAEtB,KAAK,WAAW,CAAC;;;YAIxB,OAAO,kBAAkB,EAAE,OAAO;;QAuIvC;;;;;;;WAOG;oCANQ,MAAM,QACN,KAAK,OAAO,8BAA8B,EAAE,IAAI,CAAC,uBACjD,KAAK,OAAO,2BAA2B,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDnE;uCA5NY;IACZ,WAAe,EAAE,KAAK,OAAO,CAAC,CAAC;IAC/B,KAAS,EAAE,KAAK,OAAO,cAAc,EAAE,KAAK,CAAC,CAAC;IAC9C,cAAkB,EAAE,cAAc,CAAC;CAChC;sBAES,OAAO,cAAc,EAAE,OAAO;6BAE9B;IACZ,oBAAwB,EAAE,MAAM,KAChC,kBAAwB,OAAO,8BAA8B,EAAE,eAAe,CAAC,CAAC,CAAA;CAC7E;uBAES,OAAO;;4BAES,MAAM,KAAK,QAAQ,OAAO,kBAAkB,EAAE,WAAW,CAAC;yBAC7D,MAAM,KAAK,QAAQ;;oBAiN/B,cAAc"}
|
package/src/walletFactory.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* @file Wallet Factory
|
|
3
3
|
*
|
|
4
4
|
* Contract to make smart wallets.
|
|
5
|
+
*
|
|
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.
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
10
|
import { makeTracer, WalletName } from '@agoric/internal';
|
|
@@ -29,6 +32,9 @@ export const privateArgsShape = harden(
|
|
|
29
32
|
),
|
|
30
33
|
);
|
|
31
34
|
|
|
35
|
+
const WALLETS_BY_ADDRESS = 'walletsByAddress';
|
|
36
|
+
const UPGRADE_TO_INCARNATION_TWO = 'upgrade to incarnation two';
|
|
37
|
+
|
|
32
38
|
/**
|
|
33
39
|
* Provide a NameHub for this address and insert depositFacet only if not
|
|
34
40
|
* already done.
|
|
@@ -68,7 +74,7 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
68
74
|
* brand: Brand,
|
|
69
75
|
* displayInfo: DisplayInfo,
|
|
70
76
|
* issuer: Issuer,
|
|
71
|
-
* petname: import('./types').Petname
|
|
77
|
+
* petname: import('./types.js').Petname
|
|
72
78
|
* }} BrandDescriptor
|
|
73
79
|
* For use by clients to describe brands to users. Includes `displayInfo` to save a remote call.
|
|
74
80
|
*/
|
|
@@ -119,17 +125,17 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
119
125
|
*
|
|
120
126
|
* @typedef {{
|
|
121
127
|
* getAssetSubscription: () => ERef<
|
|
122
|
-
* IterableEachTopic<import('@agoric/vats/src/vat-bank').AssetDescriptor>>
|
|
128
|
+
* IterableEachTopic<import('@agoric/vats/src/vat-bank.js').AssetDescriptor>>
|
|
123
129
|
* }} AssetPublisher
|
|
124
130
|
*
|
|
125
131
|
* @typedef {boolean} isRevive
|
|
126
132
|
* @typedef {{
|
|
127
|
-
* reviveWallet: (address: string) => Promise<import('./smartWallet').SmartWallet>,
|
|
133
|
+
* reviveWallet: (address: string) => Promise<import('./smartWallet.js').SmartWallet>,
|
|
128
134
|
* ackWallet: (address: string) => isRevive,
|
|
129
135
|
* }} WalletReviver
|
|
130
136
|
*/
|
|
131
137
|
|
|
132
|
-
// NB: even though all the wallets share this contract,
|
|
138
|
+
// NB: even though all the wallets share this contract,
|
|
133
139
|
// 1. they should not rely on that; they may be partitioned later
|
|
134
140
|
// 2. they should never be able to detect behaviors from another wallet
|
|
135
141
|
/**
|
|
@@ -142,14 +148,14 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
142
148
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
143
149
|
*/
|
|
144
150
|
export const prepare = async (zcf, privateArgs, baggage) => {
|
|
145
|
-
const upgrading = baggage.has(
|
|
151
|
+
const upgrading = baggage.has(WALLETS_BY_ADDRESS);
|
|
146
152
|
const { agoricNames, board, assetPublisher } = zcf.getTerms();
|
|
147
153
|
|
|
148
154
|
const zoe = zcf.getZoeService();
|
|
149
155
|
const { storageNode, walletBridgeManager, walletReviver } = privateArgs;
|
|
150
156
|
|
|
151
157
|
/** @type {MapStore<string, import('./smartWallet.js').SmartWallet>} */
|
|
152
|
-
const walletsByAddress = provideDurableMapStore(baggage,
|
|
158
|
+
const walletsByAddress = provideDurableMapStore(baggage, WALLETS_BY_ADDRESS);
|
|
153
159
|
const provider = makeAtomicProvider(walletsByAddress);
|
|
154
160
|
|
|
155
161
|
const handleWalletAction = makeExo(
|
|
@@ -220,6 +226,15 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
220
226
|
|
|
221
227
|
const registry = makeAssetRegistry(assetPublisher);
|
|
222
228
|
|
|
229
|
+
/**
|
|
230
|
+
* An object known only to walletFactory and smartWallets. The WalletFactory
|
|
231
|
+
* only has the self facet for the pre-existing wallets that must be repaired.
|
|
232
|
+
* Self is too accessible, so use of the repair function requires use of a
|
|
233
|
+
* secret that clients won't have. This can be removed once the upgrade has
|
|
234
|
+
* taken place.
|
|
235
|
+
*/
|
|
236
|
+
const upgradeToIncarnation2Key = harden({});
|
|
237
|
+
|
|
223
238
|
const shared = harden({
|
|
224
239
|
agoricNames,
|
|
225
240
|
invitationBrand,
|
|
@@ -228,6 +243,7 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
228
243
|
publicMarshaller,
|
|
229
244
|
registry,
|
|
230
245
|
zoe,
|
|
246
|
+
secretWalletFactoryKey: upgradeToIncarnation2Key,
|
|
231
247
|
});
|
|
232
248
|
|
|
233
249
|
/**
|
|
@@ -237,6 +253,22 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
237
253
|
*/
|
|
238
254
|
const makeSmartWallet = prepareSmartWallet(baggage, shared);
|
|
239
255
|
|
|
256
|
+
// One time repair for incarnation 2. We're adding WatchedPromises to allow
|
|
257
|
+
// wallets to durably monitor offer outcomes, but wallets that already exist
|
|
258
|
+
// need to be backfilled. This code needs to run once at the beginning of
|
|
259
|
+
// incarnation 2, and then shouldn't be needed again.
|
|
260
|
+
if (!baggage.has(UPGRADE_TO_INCARNATION_TWO)) {
|
|
261
|
+
trace('Wallet Factory upgrading to incarnation 2');
|
|
262
|
+
|
|
263
|
+
// This could take a while, depending on how many outstanding wallets exist.
|
|
264
|
+
// The current plan is that it will run exactly once, and inside an upgrade
|
|
265
|
+
// handler, between blocks.
|
|
266
|
+
for (const wallet of walletsByAddress.values()) {
|
|
267
|
+
wallet.repairWalletForIncarnation2(upgradeToIncarnation2Key);
|
|
268
|
+
}
|
|
269
|
+
baggage.init(UPGRADE_TO_INCARNATION_TWO, 'done');
|
|
270
|
+
}
|
|
271
|
+
|
|
240
272
|
const creatorFacet = prepareExo(
|
|
241
273
|
baggage,
|
|
242
274
|
'walletFactoryCreator',
|
|
@@ -250,16 +282,16 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
250
282
|
{
|
|
251
283
|
/**
|
|
252
284
|
* @param {string} address
|
|
253
|
-
* @param {ERef<import('@agoric/vats/src/vat-bank').Bank>} bank
|
|
254
|
-
* @param {ERef<import('@agoric/vats/').NameAdmin>} namesByAddressAdmin
|
|
255
|
-
* @returns {Promise<[wallet: import('./smartWallet').SmartWallet, isNew: boolean]>} wallet
|
|
285
|
+
* @param {ERef<import('@agoric/vats/src/vat-bank.js').Bank>} bank
|
|
286
|
+
* @param {ERef<import('@agoric/vats/src/types.js').NameAdmin>} namesByAddressAdmin
|
|
287
|
+
* @returns {Promise<[wallet: import('./smartWallet.js').SmartWallet, isNew: boolean]>} wallet
|
|
256
288
|
* along with a flag to distinguish between looking up an existing wallet
|
|
257
289
|
* and creating a new one.
|
|
258
290
|
*/
|
|
259
291
|
provideSmartWallet(address, bank, namesByAddressAdmin) {
|
|
260
292
|
let isNew = false;
|
|
261
293
|
|
|
262
|
-
/** @type {(address: string) => Promise<import('./smartWallet').SmartWallet>} */
|
|
294
|
+
/** @type {(address: string) => Promise<import('./smartWallet.js').SmartWallet>} */
|
|
263
295
|
const maker = async _address => {
|
|
264
296
|
const invitationPurse = await E(invitationIssuer).makeEmptyPurse();
|
|
265
297
|
const walletStorageNode = E(storageNode).makeChildNode(address);
|