@agoric/smart-wallet 0.5.4-upgrade-16-fi-dev-8879538.0 → 0.5.4-upgrade-16-dev-24665a9.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 +15 -15
- package/src/invitations.d.ts +7 -3
- package/src/invitations.d.ts.map +1 -1
- package/src/invitations.js +29 -20
- package/src/marshal-contexts.d.ts +5 -7
- package/src/marshal-contexts.d.ts.map +1 -1
- package/src/marshal-contexts.js +36 -33
- package/src/offerWatcher.d.ts +10 -7
- package/src/offerWatcher.d.ts.map +1 -1
- package/src/offerWatcher.js +27 -19
- package/src/offers.d.ts +4 -4
- package/src/offers.d.ts.map +1 -1
- package/src/offers.js +8 -8
- package/src/proposals/upgrade-walletFactory-proposal.d.ts.map +1 -1
- package/src/proposals/upgrade-walletFactory-proposal.js +3 -4
- package/src/smartWallet.d.ts +66 -41
- package/src/smartWallet.d.ts.map +1 -1
- package/src/smartWallet.js +143 -100
- package/src/types.d.ts +5 -0
- package/src/utils.d.ts +9 -6
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +17 -4
- package/src/walletFactory.d.ts +7 -5
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +53 -34
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAIA,sDAAuD;AAKhD
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAIA,yDAAyD;AAEzD,sDAAuD;AAKhD;;;;yBAae,MAAM;sBACT,QAAQ;;;;;2BAOd,OAAO,kBAAkB,EAAE,YAAY,GAAG,EAAE;EAgExD;AAaM,yCAHI,IAAI,CAAC,UAAU,CAAC,OAAO,kBAAkB,EAAE,YAAY,CAAC,CAAC;;;qBAlF9C,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
|
@@ -2,13 +2,15 @@ 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
|
+
/** @import {OfferId, OfferStatus} from './offers.js'; */
|
|
6
|
+
|
|
5
7
|
export const NO_SMART_WALLET_ERROR = 'no smart wallet';
|
|
6
8
|
|
|
7
9
|
const trace = makeTracer('WUTIL', false);
|
|
8
10
|
|
|
9
11
|
/** @param {Brand<'set'>} [invitationBrand] */
|
|
10
12
|
export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
11
|
-
/** @type {Map<
|
|
13
|
+
/** @type {Map<OfferId, OfferStatus>} */
|
|
12
14
|
const offerStatuses = new Map();
|
|
13
15
|
/** @type {Map<Brand, Amount>} */
|
|
14
16
|
const balances = new Map();
|
|
@@ -16,11 +18,21 @@ export const makeWalletStateCoalescer = (invitationBrand = undefined) => {
|
|
|
16
18
|
/**
|
|
17
19
|
* keyed by description; xxx assumes unique
|
|
18
20
|
*
|
|
19
|
-
* @type {Map<
|
|
21
|
+
* @type {Map<
|
|
22
|
+
* OfferId,
|
|
23
|
+
* {
|
|
24
|
+
* acceptedIn: OfferId;
|
|
25
|
+
* description: string;
|
|
26
|
+
* instance: Instance;
|
|
27
|
+
* }
|
|
28
|
+
* >}
|
|
20
29
|
*/
|
|
21
30
|
const invitationsReceived = new Map();
|
|
22
31
|
|
|
23
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* @param {import('./smartWallet.js').UpdateRecord | {}} updateRecord newer
|
|
34
|
+
* than previous
|
|
35
|
+
*/
|
|
24
36
|
const update = updateRecord => {
|
|
25
37
|
if (!('updated' in updateRecord)) {
|
|
26
38
|
return;
|
|
@@ -124,7 +136,8 @@ export const assertHasData = async follower => {
|
|
|
124
136
|
/**
|
|
125
137
|
* Handles the case of falsy argument so the caller can consistently await.
|
|
126
138
|
*
|
|
127
|
-
* @param {import('./types.js').PublicSubscribers
|
|
139
|
+
* @param {import('./types.js').PublicSubscribers
|
|
140
|
+
* | import('@agoric/zoe/src/contractSupport/index.js').TopicsRecord} [subscribers]
|
|
128
141
|
* @returns {ERef<Record<string, string>> | null}
|
|
129
142
|
*/
|
|
130
143
|
export const objectMapStoragePath = subscribers => {
|
package/src/walletFactory.d.ts
CHANGED
|
@@ -32,9 +32,11 @@ export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
|
|
|
32
32
|
* @param {string} address
|
|
33
33
|
* @param {ERef<import('@agoric/vats/src/vat-bank.js').Bank>} bank
|
|
34
34
|
* @param {ERef<import('@agoric/vats/src/types.js').NameAdmin>} namesByAddressAdmin
|
|
35
|
-
* @returns {Promise<
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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
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]>;
|
|
40
42
|
}>;
|
|
@@ -47,10 +49,10 @@ export type SmartWalletContractTerms = {
|
|
|
47
49
|
export type AssetPublisher = {
|
|
48
50
|
getAssetSubscription: () => ERef<IterableEachTopic<import("@agoric/vats/src/vat-bank.js").AssetDescriptor>>;
|
|
49
51
|
};
|
|
50
|
-
export type
|
|
52
|
+
export type IsRevive = boolean;
|
|
51
53
|
export type WalletReviver = {
|
|
52
54
|
reviveWallet: (address: string) => Promise<import("./smartWallet.js").SmartWallet>;
|
|
53
|
-
ackWallet: (address: string) =>
|
|
55
|
+
ackWallet: (address: string) => IsRevive;
|
|
54
56
|
};
|
|
55
57
|
export type start = typeof prepare;
|
|
56
58
|
import type { NameHub } from '@agoric/vats';
|
|
@@ -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;;;WA1OW,IAAI,CAAC,OAAO,cAAc,EAAE,KAAK,CAAC;oBACzB,cAAc;;6BAItB;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.js').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
|
-
* @import {NameHub} from '@agoric/vats'
|
|
125
127
|
*
|
|
126
128
|
* @typedef {{
|
|
127
129
|
* getAssetSubscription: () => ERef<
|
|
128
|
-
* IterableEachTopic<import('@agoric/vats/src/vat-bank.js').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
|
*/
|
|
@@ -284,14 +297,20 @@ export const prepare = async (zcf, privateArgs, baggage) => {
|
|
|
284
297
|
* @param {string} address
|
|
285
298
|
* @param {ERef<import('@agoric/vats/src/vat-bank.js').Bank>} bank
|
|
286
299
|
* @param {ERef<import('@agoric/vats/src/types.js').NameAdmin>} namesByAddressAdmin
|
|
287
|
-
* @returns {Promise<
|
|
288
|
-
*
|
|
289
|
-
*
|
|
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);
|