@agoric/wallet 0.18.4-other-dev-1f26562.0 → 0.18.4-other-dev-3eb1a1d.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 +0 -8
- package/README.md +2 -2
- package/api/CHANGELOG.md +0 -8
- package/api/bundles/bundle-wallet-js-meta.json +497 -269
- package/api/bundles/bundle-wallet.js +1 -1
- package/api/deploy.js +8 -3
- package/api/package.json +30 -22
- package/api/src/findOrMakeInvitation.js +4 -2
- package/api/src/internal-types.js +8 -5
- package/api/src/issuerTable.js +1 -2
- package/api/src/lib-dehydrate.js +9 -16
- package/api/src/lib-wallet.js +53 -56
- package/api/src/pubsub.js +2 -2
- package/api/src/wallet.js +13 -12
- package/api/test/continuingInvitationExample.js +0 -2
- package/api/test/{test-getPursesNotifier.js → getPursesNotifier.test.js} +2 -6
- package/api/test/{test-lib-wallet.js → lib-wallet.test.js} +16 -27
- package/api/test/{test-middleware.js → middleware.test.js} +0 -1
- package/api/{jsconfig.json → tsconfig.json} +1 -0
- package/package.json +4 -4
- package/api/exported.js +0 -1
- /package/api/src/{types.js → types-ambient.js} +0 -0
- /package/api/test/{test-lib-dehydrate.js → lib-dehydrate.test.js} +0 -0
package/api/deploy.js
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// Agoric wallet deployment script.
|
|
3
3
|
// FIXME: This is just hacked together for the legacy wallet.
|
|
4
4
|
|
|
5
|
+
import { Fail } from '@endo/errors';
|
|
5
6
|
import { E } from '@endo/eventual-send';
|
|
6
|
-
import { Fail } from '@agoric/assert';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const dirname = path.dirname(filename);
|
|
9
|
+
const dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
11
10
|
|
|
12
11
|
export default async function deployWallet(
|
|
13
12
|
homePromise,
|
|
@@ -17,6 +16,7 @@ export default async function deployWallet(
|
|
|
17
16
|
// console.log('have home', home);
|
|
18
17
|
const {
|
|
19
18
|
agoric: {
|
|
19
|
+
DISCONNECTED,
|
|
20
20
|
agoricNames,
|
|
21
21
|
bank,
|
|
22
22
|
namesByAddress,
|
|
@@ -28,6 +28,11 @@ export default async function deployWallet(
|
|
|
28
28
|
local: { http, localTimerService, spawner, wallet: oldWallet, scratch },
|
|
29
29
|
} = home;
|
|
30
30
|
|
|
31
|
+
if (DISCONNECTED) {
|
|
32
|
+
console.warn(DISCONNECTED);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
let walletVat = await E(scratch).get('wallet/api');
|
|
32
37
|
if (!walletVat) {
|
|
33
38
|
// Bundle the wallet sources.
|
package/api/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/wallet-backend",
|
|
3
|
-
"version": "0.14.4-other-dev-
|
|
3
|
+
"version": "0.14.4-other-dev-3eb1a1d.0+3eb1a1d",
|
|
4
4
|
"description": "Wallet backend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -10,30 +10,32 @@
|
|
|
10
10
|
"test:xs": "exit 0",
|
|
11
11
|
"lint": "run-s --continue-on-error lint:*",
|
|
12
12
|
"lint-fix": "yarn lint:eslint --fix",
|
|
13
|
-
"lint:types": "tsc
|
|
13
|
+
"lint:types": "tsc",
|
|
14
14
|
"lint:eslint": "eslint ."
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@agoric/vats": "0.15.2-other-dev-
|
|
18
|
-
"@endo/bundle-source": "
|
|
19
|
-
"@endo/
|
|
20
|
-
"
|
|
17
|
+
"@agoric/vats": "0.15.2-other-dev-3eb1a1d.0+3eb1a1d",
|
|
18
|
+
"@endo/bundle-source": "^3.5.0",
|
|
19
|
+
"@endo/far": "^1.1.9",
|
|
20
|
+
"@endo/init": "^1.1.7",
|
|
21
|
+
"ava": "^5.3.0"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@agoric/
|
|
24
|
-
"@agoric/
|
|
25
|
-
"@agoric/
|
|
26
|
-
"@agoric/
|
|
27
|
-
"@agoric/
|
|
28
|
-
"@agoric/
|
|
29
|
-
"@agoric/
|
|
30
|
-
"@agoric/
|
|
31
|
-
"@agoric/
|
|
32
|
-
"@agoric/
|
|
33
|
-
"@endo/
|
|
34
|
-
"@endo/
|
|
35
|
-
"@endo/
|
|
36
|
-
"@endo/
|
|
24
|
+
"@agoric/cache": "0.3.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
25
|
+
"@agoric/ertp": "0.16.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
26
|
+
"@agoric/internal": "0.3.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
27
|
+
"@agoric/notifier": "0.6.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
28
|
+
"@agoric/smart-wallet": "0.5.4-other-dev-3eb1a1d.0+3eb1a1d",
|
|
29
|
+
"@agoric/store": "0.9.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
30
|
+
"@agoric/time": "0.3.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
31
|
+
"@agoric/vat-data": "0.5.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
32
|
+
"@agoric/zoe": "0.26.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
33
|
+
"@agoric/zone": "0.2.3-other-dev-3eb1a1d.0+3eb1a1d",
|
|
34
|
+
"@endo/errors": "^1.2.8",
|
|
35
|
+
"@endo/eventual-send": "^1.2.8",
|
|
36
|
+
"@endo/marshal": "^1.6.2",
|
|
37
|
+
"@endo/nat": "^5.0.13",
|
|
38
|
+
"@endo/promise-kit": "^1.1.8",
|
|
37
39
|
"import-meta-resolve": "^2.2.1"
|
|
38
40
|
},
|
|
39
41
|
"keywords": [],
|
|
@@ -49,7 +51,10 @@
|
|
|
49
51
|
"homepage": "https://github.com/Agoric/agoric#readme",
|
|
50
52
|
"ava": {
|
|
51
53
|
"files": [
|
|
52
|
-
"test
|
|
54
|
+
"test/**/*.test.*"
|
|
55
|
+
],
|
|
56
|
+
"require": [
|
|
57
|
+
"@endo/init/debug.js"
|
|
53
58
|
],
|
|
54
59
|
"timeout": "2m",
|
|
55
60
|
"workerThreads": false
|
|
@@ -57,5 +62,8 @@
|
|
|
57
62
|
"publishConfig": {
|
|
58
63
|
"access": "public"
|
|
59
64
|
},
|
|
60
|
-
"
|
|
65
|
+
"typeCoverage": {
|
|
66
|
+
"atLeast": 0
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "3eb1a1d2d75b2b4a94807cd3bf759bc9fc531f05"
|
|
61
69
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert, Fail, q } from '@
|
|
1
|
+
import { assert, Fail, q } from '@endo/errors';
|
|
2
2
|
import { E } from '@endo/eventual-send';
|
|
3
3
|
import { passStyleOf } from '@endo/marshal';
|
|
4
4
|
import { AmountMath } from '@agoric/ertp';
|
|
@@ -101,7 +101,9 @@ const makeInvitation = async (
|
|
|
101
101
|
board,
|
|
102
102
|
zoe,
|
|
103
103
|
) => {
|
|
104
|
-
const instance =
|
|
104
|
+
const instance = /** @type {Promise<Instance>} */ (
|
|
105
|
+
E(board).getValue(instanceHandleBoardId)
|
|
106
|
+
);
|
|
105
107
|
const publicFacet = E(zoe).getPublicFacet(instance);
|
|
106
108
|
const { method, args = [] } = invitationMaker;
|
|
107
109
|
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
* @property {PurseActions} actions
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
12
|
+
* @import {Key} from '@endo/patterns';
|
|
13
|
+
*/
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* @typedef {PursesJSONState & PursesAddedState} PursesFullState
|
|
@@ -15,7 +18,7 @@
|
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* @typedef {object} PurseActions
|
|
18
|
-
* @property {(receiverP: ERef<{ receive: (payment: Payment) => void }>, valueToSend: AmountValue) => Promise<void>} send
|
|
21
|
+
* @property {(receiverP: ERef<{ receive: (payment: Payment) => void }>, valueToSend: import('@agoric/ertp/src/types.js').AmountValue) => Promise<void>} send
|
|
19
22
|
* @property {(payment: Payment) => Promise<Amount>} receive
|
|
20
23
|
* @property {(payment: Payment, amount?: Amount) => Promise<Amount>} deposit
|
|
21
24
|
*/
|
|
@@ -51,7 +54,7 @@
|
|
|
51
54
|
*/
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
|
-
* @template T
|
|
57
|
+
* @template {Key} T
|
|
55
58
|
* @typedef {object} Mapping
|
|
56
59
|
* @property {(petname: Petname) => string} implode
|
|
57
60
|
* @property {(str: string) => Petname} explode
|
|
@@ -82,7 +85,7 @@
|
|
|
82
85
|
* @property {string} [issuerBoardId]
|
|
83
86
|
*
|
|
84
87
|
* @typedef {object} PaymentActions
|
|
85
|
-
* @property {(purseOrPetname?: (Purse | Petname)) => Promise<AmountValue>} deposit
|
|
88
|
+
* @property {(purseOrPetname?: (Purse | Petname)) => Promise<import('@agoric/ertp/src/types.js').AmountValue>} deposit
|
|
86
89
|
* @property {() => Promise<boolean>} refresh
|
|
87
90
|
* @property {() => Promise<boolean>} getAmountOf
|
|
88
91
|
*/
|
|
@@ -93,6 +96,6 @@
|
|
|
93
96
|
* would make them part of the WalletUser available as `home.wallet` in the
|
|
94
97
|
* REPL. Then, the Wallet UI could use that instead.
|
|
95
98
|
*
|
|
96
|
-
* @typedef {import('./lib-wallet').WalletRoot['admin']}
|
|
99
|
+
* @typedef {import('./lib-wallet.js').WalletRoot['admin']}
|
|
97
100
|
* WalletAdminFacet
|
|
98
101
|
*/
|
package/api/src/issuerTable.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { assert } from '@
|
|
3
|
+
import { assert } from '@endo/errors';
|
|
4
4
|
import { E } from '@endo/eventual-send';
|
|
5
5
|
|
|
6
6
|
import { makeScalarWeakMapStore } from '@agoric/store';
|
|
7
7
|
|
|
8
|
-
import '../exported.js';
|
|
9
8
|
import './internal-types.js';
|
|
10
9
|
|
|
11
10
|
/**
|
package/api/src/lib-dehydrate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
import { assert, Fail, q } from '@endo/errors';
|
|
3
4
|
import { makeMarshal, mapIterable } from '@endo/marshal';
|
|
4
5
|
import { makeLegacyMap, makeScalarMapStore } from '@agoric/store';
|
|
5
|
-
import { assert, Fail, q } from '@agoric/assert';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {string[]} Path
|
|
@@ -54,7 +54,6 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
54
54
|
if (!isPath(strongname)) {
|
|
55
55
|
return strongname;
|
|
56
56
|
}
|
|
57
|
-
// eslint-disable-next-line no-use-before-define
|
|
58
57
|
const { valToPetname: rootToPetname } = edgeMapping;
|
|
59
58
|
const petname = rootToPetname.get(strongname[0]);
|
|
60
59
|
assert(!isPath(petname));
|
|
@@ -73,7 +72,6 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
73
72
|
|
|
74
73
|
// A strong path must have a root name we have mapped.
|
|
75
74
|
const path = [...strongname];
|
|
76
|
-
// eslint-disable-next-line no-use-before-define
|
|
77
75
|
const { petnameToVal: petnameToRoot } = edgeMapping;
|
|
78
76
|
if (!petnameToRoot.has(path[0])) {
|
|
79
77
|
// Avoid asserting, which fills up the logs.
|
|
@@ -86,10 +84,9 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
86
84
|
};
|
|
87
85
|
|
|
88
86
|
/**
|
|
89
|
-
* @template T
|
|
90
87
|
* @param {string} kind
|
|
91
88
|
* @param {{ useLegacyMap?: boolean }} [legacyOptions]
|
|
92
|
-
* @returns {Mapping<
|
|
89
|
+
* @returns {Mapping<any>}
|
|
93
90
|
*/
|
|
94
91
|
const makeMapping = (kind, { useLegacyMap = false } = {}) => {
|
|
95
92
|
typeof kind === 'string' || `kind ${kind} must be a string`;
|
|
@@ -97,9 +94,9 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
97
94
|
// These are actually either a LegacyMap or a MapStore depending on
|
|
98
95
|
// useLegacyMap. Fortunately, the LegacyMap type is approximately the
|
|
99
96
|
// intersection of these, so we can just use it.
|
|
100
|
-
/** @type {LegacyMap<
|
|
97
|
+
/** @type {LegacyMap<any, string>} */
|
|
101
98
|
const rawValToPetname = makeMap('value');
|
|
102
|
-
/** @type {LegacyMap<
|
|
99
|
+
/** @type {LegacyMap<any, string | Path>} */
|
|
103
100
|
const valToPetname = {
|
|
104
101
|
...rawValToPetname,
|
|
105
102
|
set(key, val) {
|
|
@@ -121,9 +118,9 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
121
118
|
return mapIterable(rawValToPetname.values(), val => explode(val));
|
|
122
119
|
},
|
|
123
120
|
};
|
|
124
|
-
/** @type {MapStore<string,
|
|
121
|
+
/** @type {MapStore<string, any>} */
|
|
125
122
|
const rawPetnameToVal = makeScalarMapStore('petname');
|
|
126
|
-
/** @type {MapStore<Path | string,
|
|
123
|
+
/** @type {MapStore<Path | string, any>} */
|
|
127
124
|
const petnameToVal = {
|
|
128
125
|
...rawPetnameToVal,
|
|
129
126
|
init(key, val) {
|
|
@@ -164,11 +161,7 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
164
161
|
const addPath = (path, val) => {
|
|
165
162
|
isPath(path) || Fail`path ${q(path)} must be an array of strings`;
|
|
166
163
|
|
|
167
|
-
if (
|
|
168
|
-
!valToPetname.has(val) &&
|
|
169
|
-
// eslint-disable-next-line no-use-before-define
|
|
170
|
-
edgeMapping.valToPetname.has(path[0])
|
|
171
|
-
) {
|
|
164
|
+
if (!valToPetname.has(val) && edgeMapping.valToPetname.has(path[0])) {
|
|
172
165
|
// We have a petname for the root of the path, so use it as our
|
|
173
166
|
// strongname.
|
|
174
167
|
valToPetname.init(val, path);
|
|
@@ -270,7 +263,7 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
270
263
|
petnameToVal.delete(petname);
|
|
271
264
|
valToPetname.delete(val);
|
|
272
265
|
};
|
|
273
|
-
/** @type {Mapping<
|
|
266
|
+
/** @type {Mapping<any>} */
|
|
274
267
|
const mapping = harden({
|
|
275
268
|
implode,
|
|
276
269
|
explode,
|
|
@@ -340,7 +333,7 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
340
333
|
marshalName: 'hydration',
|
|
341
334
|
// TODO Temporary hack.
|
|
342
335
|
// See https://github.com/Agoric/agoric-sdk/issues/2780
|
|
343
|
-
errorIdNum:
|
|
336
|
+
errorIdNum: 30_000,
|
|
344
337
|
serializeBodyFormat: 'smallcaps',
|
|
345
338
|
},
|
|
346
339
|
);
|
package/api/src/lib-wallet.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* and dapps.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { assert, q, Fail } from '@
|
|
14
|
+
import { assert, q, Fail } from '@endo/errors';
|
|
15
15
|
import { makeScalarStoreCoordinator } from '@agoric/cache';
|
|
16
16
|
import { objectMap, WalletName } from '@agoric/internal';
|
|
17
17
|
import { slotStringUnserialize } from '@agoric/internal/src/storage-test-utils.js';
|
|
@@ -42,11 +42,7 @@ import { makeId, findOrMakeInvitation } from './findOrMakeInvitation.js';
|
|
|
42
42
|
import { bigintStringify } from './bigintStringify.js';
|
|
43
43
|
import { makePaymentActions } from './actions.js';
|
|
44
44
|
|
|
45
|
-
import '@agoric/store/exported.js';
|
|
46
|
-
import '@agoric/zoe/exported.js';
|
|
47
|
-
|
|
48
45
|
import './internal-types.js';
|
|
49
|
-
import './types.js';
|
|
50
46
|
|
|
51
47
|
// does nothing
|
|
52
48
|
const noActionStateChangeHandler = _newState => {};
|
|
@@ -73,7 +69,7 @@ const cmp = (a, b) => {
|
|
|
73
69
|
* zoe: ERef<ZoeService>,
|
|
74
70
|
* }} opt
|
|
75
71
|
*
|
|
76
|
-
* @
|
|
72
|
+
* @import {NameHub} from '@agoric/vats'
|
|
77
73
|
*/
|
|
78
74
|
export function makeWalletRoot({
|
|
79
75
|
zoe,
|
|
@@ -413,7 +409,6 @@ export function makeWalletRoot({
|
|
|
413
409
|
Object.entries(pursePetnameValueKeywordRecord).map(
|
|
414
410
|
([keyword, { pursePetname, value, amount, purse }]) => {
|
|
415
411
|
if (!amount) {
|
|
416
|
-
// eslint-disable-next-line no-use-before-define
|
|
417
412
|
purse = getPurse(pursePetname);
|
|
418
413
|
amount = { value };
|
|
419
414
|
} else {
|
|
@@ -502,9 +497,8 @@ export function makeWalletRoot({
|
|
|
502
497
|
const alreadyDisplayed =
|
|
503
498
|
inboxState.has(id) && inboxState.get(id).proposalForDisplay;
|
|
504
499
|
|
|
505
|
-
const augmentedInvitationDetails =
|
|
506
|
-
invitationDetails
|
|
507
|
-
);
|
|
500
|
+
const augmentedInvitationDetails =
|
|
501
|
+
await expandInvitationBrands(invitationDetails);
|
|
508
502
|
|
|
509
503
|
const offerForDisplay = {
|
|
510
504
|
...offer,
|
|
@@ -583,7 +577,7 @@ export function makeWalletRoot({
|
|
|
583
577
|
status: 'complete',
|
|
584
578
|
});
|
|
585
579
|
idToOffer.set(id, completedOffer);
|
|
586
|
-
updateInboxState(id, completedOffer);
|
|
580
|
+
void updateInboxState(id, completedOffer);
|
|
587
581
|
}
|
|
588
582
|
|
|
589
583
|
/**
|
|
@@ -592,8 +586,8 @@ export function makeWalletRoot({
|
|
|
592
586
|
* @param {string} id
|
|
593
587
|
* @param {ERef<UserSeat>} seat
|
|
594
588
|
*/
|
|
595
|
-
|
|
596
|
-
E(E(seat).getExitSubscriber())
|
|
589
|
+
function subscribeToUpdates(id, seat) {
|
|
590
|
+
return E(E(seat).getExitSubscriber())
|
|
597
591
|
.subscribeAfter()
|
|
598
592
|
.then(update => updateOrResubscribe(id, seat, update));
|
|
599
593
|
}
|
|
@@ -647,7 +641,6 @@ export function makeWalletRoot({
|
|
|
647
641
|
|
|
648
642
|
// Now send it back to the purse.
|
|
649
643
|
try {
|
|
650
|
-
// eslint-disable-next-line no-use-before-define
|
|
651
644
|
return addPayment(payment, purse);
|
|
652
645
|
} finally {
|
|
653
646
|
// Once we've called addPayment, mark this one as done.
|
|
@@ -680,7 +673,7 @@ export function makeWalletRoot({
|
|
|
680
673
|
);
|
|
681
674
|
// By the time Zoe settles the seat promise, the escrow should be complete.
|
|
682
675
|
// Reclaim if it is somehow not.
|
|
683
|
-
seat.finally(tryReclaimingWithdrawnPayments);
|
|
676
|
+
void seat.finally(tryReclaimingWithdrawnPayments);
|
|
684
677
|
|
|
685
678
|
// Even if the seat doesn't settle, we can still pipeline our request for
|
|
686
679
|
// payouts.
|
|
@@ -693,7 +686,6 @@ export function makeWalletRoot({
|
|
|
693
686
|
// we still make it a normal incoming payment.
|
|
694
687
|
const purseOrUndefined = purseKeywordRecord[keyword];
|
|
695
688
|
|
|
696
|
-
// eslint-disable-next-line no-use-before-define
|
|
697
689
|
return addPayment(payoutP, purseOrUndefined);
|
|
698
690
|
}),
|
|
699
691
|
);
|
|
@@ -702,7 +694,7 @@ export function makeWalletRoot({
|
|
|
702
694
|
// Regardless of the status of the offer, we try to clean up any of our
|
|
703
695
|
// unclaimed payments. Defensively, we want to do this as soon as possible
|
|
704
696
|
// even if the seat doesn't settle.
|
|
705
|
-
depositedP.finally(tryReclaimingWithdrawnPayments);
|
|
697
|
+
void depositedP.finally(tryReclaimingWithdrawnPayments);
|
|
706
698
|
|
|
707
699
|
// Return a promise that will resolve after successful deposit, as well as
|
|
708
700
|
// the promise for the seat.
|
|
@@ -723,10 +715,9 @@ export function makeWalletRoot({
|
|
|
723
715
|
const already = brandMapping.valToPetname.has(brand);
|
|
724
716
|
petnameForBrand = brandMapping.suggestPetname(petnameForBrand, brand);
|
|
725
717
|
if (!already && makePurse) {
|
|
726
|
-
// eslint-disable-next-line no-use-before-define
|
|
727
718
|
p = makeEmptyPurse(petnameForBrand, petnameForBrand, true);
|
|
728
719
|
} else {
|
|
729
|
-
p = Promise.resolve();
|
|
720
|
+
p = Promise.resolve(undefined);
|
|
730
721
|
}
|
|
731
722
|
return E.when(p, _ => petnameForBrand);
|
|
732
723
|
};
|
|
@@ -754,7 +745,9 @@ export function makeWalletRoot({
|
|
|
754
745
|
* @param {string} [address]
|
|
755
746
|
*/
|
|
756
747
|
const addContact = async (petname, actions, address = undefined) => {
|
|
748
|
+
// @ts-expect-error XXX ERef
|
|
757
749
|
const already = await E(board).has(actions);
|
|
750
|
+
/** @type {any} */
|
|
758
751
|
let depositFacet;
|
|
759
752
|
if (already) {
|
|
760
753
|
depositFacet = actions;
|
|
@@ -793,7 +786,7 @@ export function makeWalletRoot({
|
|
|
793
786
|
// possible display in the wallet.
|
|
794
787
|
petname = instanceMapping.suggestPetname(petname, instanceHandle);
|
|
795
788
|
// We don't wait for the update before returning.
|
|
796
|
-
updateAllState();
|
|
789
|
+
void updateAllState();
|
|
797
790
|
return `instance ${q(petname)} successfully added to wallet`;
|
|
798
791
|
};
|
|
799
792
|
|
|
@@ -824,14 +817,13 @@ export function makeWalletRoot({
|
|
|
824
817
|
if (defaultAutoDeposit && !brandToAutoDepositPurse.has(brand)) {
|
|
825
818
|
// Try to initialize the autodeposit purse for this brand.
|
|
826
819
|
// Don't do state updates, since we'll do that next.
|
|
827
|
-
// eslint-disable-next-line no-use-before-define
|
|
828
820
|
await doEnableAutoDeposit(petnameForPurse, false);
|
|
829
821
|
}
|
|
830
822
|
|
|
831
823
|
await updatePursesState(petnameForPurse, purse);
|
|
832
824
|
|
|
833
825
|
// Just notice the balance updates for the purse.
|
|
834
|
-
observeNotifier(E(purse).getCurrentAmountNotifier(), {
|
|
826
|
+
void observeNotifier(E(purse).getCurrentAmountNotifier(), {
|
|
835
827
|
updateState(_balance) {
|
|
836
828
|
updatePursesState(purseMapping.valToPetname.get(purse), purse).catch(
|
|
837
829
|
e => console.error('cannot updateState', e),
|
|
@@ -946,7 +938,6 @@ export function makeWalletRoot({
|
|
|
946
938
|
arguments: args,
|
|
947
939
|
} = compileProposal(offer.proposalTemplate);
|
|
948
940
|
|
|
949
|
-
// eslint-disable-next-line no-use-before-define
|
|
950
941
|
const zoeIssuer = issuerManager.get(ZOE_INVITE_BRAND_PETNAME);
|
|
951
942
|
const { brand: invitationBrand } = brandTable.getByIssuer(zoeIssuer);
|
|
952
943
|
const invitationP = findOrMakeInvitation(
|
|
@@ -1031,7 +1022,7 @@ export function makeWalletRoot({
|
|
|
1031
1022
|
petname,
|
|
1032
1023
|
});
|
|
1033
1024
|
updateDapp(dappRecord);
|
|
1034
|
-
updateAllState();
|
|
1025
|
+
void updateAllState();
|
|
1035
1026
|
return dappRecord.actions;
|
|
1036
1027
|
},
|
|
1037
1028
|
enable() {
|
|
@@ -1153,7 +1144,7 @@ export function makeWalletRoot({
|
|
|
1153
1144
|
status: 'decline',
|
|
1154
1145
|
});
|
|
1155
1146
|
idToOffer.set(id, declinedOffer);
|
|
1156
|
-
updateInboxState(id, declinedOffer);
|
|
1147
|
+
void updateInboxState(id, declinedOffer);
|
|
1157
1148
|
|
|
1158
1149
|
// Try to reclaim the invitation.
|
|
1159
1150
|
const compiledOfferP = idToCompiledOfferP.get(id);
|
|
@@ -1161,7 +1152,6 @@ export function makeWalletRoot({
|
|
|
1161
1152
|
return;
|
|
1162
1153
|
}
|
|
1163
1154
|
|
|
1164
|
-
// eslint-disable-next-line no-use-before-define
|
|
1165
1155
|
await addPayment(E.get(compiledOfferP).inviteP).catch(console.error);
|
|
1166
1156
|
}
|
|
1167
1157
|
|
|
@@ -1180,7 +1170,7 @@ export function makeWalletRoot({
|
|
|
1180
1170
|
status: 'cancel',
|
|
1181
1171
|
});
|
|
1182
1172
|
idToOffer.set(id, cancelledOffer);
|
|
1183
|
-
updateInboxState(id, cancelledOffer);
|
|
1173
|
+
return updateInboxState(id, cancelledOffer);
|
|
1184
1174
|
})
|
|
1185
1175
|
.catch(e => console.error(`Cannot cancel offer ${id}:`, e));
|
|
1186
1176
|
|
|
@@ -1206,16 +1196,17 @@ export function makeWalletRoot({
|
|
|
1206
1196
|
error: `${e}`,
|
|
1207
1197
|
});
|
|
1208
1198
|
idToOffer.set(id, rejectOffer);
|
|
1209
|
-
updateInboxState(id, rejectOffer);
|
|
1199
|
+
void updateInboxState(id, rejectOffer);
|
|
1210
1200
|
};
|
|
1211
1201
|
|
|
1202
|
+
await null;
|
|
1212
1203
|
try {
|
|
1213
1204
|
const pendingOffer = addMeta({
|
|
1214
1205
|
...offer,
|
|
1215
1206
|
status: 'pending',
|
|
1216
1207
|
});
|
|
1217
1208
|
idToOffer.set(id, pendingOffer);
|
|
1218
|
-
updateInboxState(id, pendingOffer);
|
|
1209
|
+
void updateInboxState(id, pendingOffer);
|
|
1219
1210
|
const compiledOffer = await idToCompiledOfferP.get(id);
|
|
1220
1211
|
|
|
1221
1212
|
const { depositedP, seat } = await executeOffer(compiledOffer);
|
|
@@ -1227,11 +1218,11 @@ export function makeWalletRoot({
|
|
|
1227
1218
|
idToSeat.set(id, seat);
|
|
1228
1219
|
// The offer might have been postponed, or it might have been immediately
|
|
1229
1220
|
// consummated. Only subscribe if it was postponed.
|
|
1230
|
-
E(seat)
|
|
1221
|
+
void E(seat)
|
|
1231
1222
|
.hasExited()
|
|
1232
1223
|
.then(exited => {
|
|
1233
1224
|
if (!exited) {
|
|
1234
|
-
subscribeToUpdates(id, seat);
|
|
1225
|
+
return subscribeToUpdates(id, seat);
|
|
1235
1226
|
}
|
|
1236
1227
|
});
|
|
1237
1228
|
|
|
@@ -1254,7 +1245,7 @@ export function makeWalletRoot({
|
|
|
1254
1245
|
status: 'accept',
|
|
1255
1246
|
});
|
|
1256
1247
|
idToOffer.set(id, acceptedOffer);
|
|
1257
|
-
updateInboxState(id, acceptedOffer);
|
|
1248
|
+
void updateInboxState(id, acceptedOffer);
|
|
1258
1249
|
}
|
|
1259
1250
|
})
|
|
1260
1251
|
.catch(rejected);
|
|
@@ -1372,6 +1363,7 @@ export function makeWalletRoot({
|
|
|
1372
1363
|
brandToAutoDepositPurse.init(brand, purse);
|
|
1373
1364
|
}
|
|
1374
1365
|
|
|
1366
|
+
await null;
|
|
1375
1367
|
if (updateState) {
|
|
1376
1368
|
await updateAllPurseState();
|
|
1377
1369
|
}
|
|
@@ -1406,11 +1398,13 @@ export function makeWalletRoot({
|
|
|
1406
1398
|
boardId,
|
|
1407
1399
|
dappOrigin = undefined,
|
|
1408
1400
|
) {
|
|
1401
|
+
/** @type {Petname} */
|
|
1409
1402
|
let petname;
|
|
1410
1403
|
if (dappOrigin === undefined) {
|
|
1411
1404
|
petname = suggestedPetname;
|
|
1412
1405
|
} else {
|
|
1413
1406
|
const edgename = edgeMapping.valToPetname.get(dappOrigin);
|
|
1407
|
+
// @ts-expect-error if suggestedPetname is itself an array, this nests
|
|
1414
1408
|
petname = [edgename, suggestedPetname];
|
|
1415
1409
|
}
|
|
1416
1410
|
|
|
@@ -1480,7 +1474,6 @@ export function makeWalletRoot({
|
|
|
1480
1474
|
// suggestion can be rejected and the suggested petname can be
|
|
1481
1475
|
// changed
|
|
1482
1476
|
return acceptPetname(
|
|
1483
|
-
// eslint-disable-next-line no-use-before-define
|
|
1484
1477
|
installationManager.add,
|
|
1485
1478
|
suggestedPetname,
|
|
1486
1479
|
installationHandleBoardId,
|
|
@@ -1681,7 +1674,7 @@ export function makeWalletRoot({
|
|
|
1681
1674
|
(kind, lookup) =>
|
|
1682
1675
|
(...path) => {
|
|
1683
1676
|
path.length === 1 ||
|
|
1684
|
-
Fail`${
|
|
1677
|
+
Fail`${q(
|
|
1685
1678
|
kind,
|
|
1686
1679
|
)} lookup must be called with a single offer ID, not ${path}`;
|
|
1687
1680
|
return lookup(path[0]);
|
|
@@ -1893,28 +1886,32 @@ export function makeWalletRoot({
|
|
|
1893
1886
|
// don't really trust.
|
|
1894
1887
|
// The param is{import('@agoric/vats/src/vat-bank.js').Bank} but that here triggers https://github.com/Agoric/agoric-sdk/issues/4620
|
|
1895
1888
|
const importBankAssets = async bank => {
|
|
1896
|
-
observeIteration(
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1889
|
+
void observeIteration(
|
|
1890
|
+
subscribeEach(E(bank).getAssetSubscription()),
|
|
1891
|
+
harden({
|
|
1892
|
+
async updateState({ proposedName, issuerName, issuer, brand }) {
|
|
1893
|
+
await null;
|
|
1894
|
+
try {
|
|
1895
|
+
issuerName = await addIssuer(issuerName, issuer);
|
|
1896
|
+
const purse = await E(bank).getPurse(brand);
|
|
1897
|
+
// We can import this purse, because we trust the bank.
|
|
1898
|
+
await internalUnsafeImportPurse(
|
|
1899
|
+
issuerName,
|
|
1900
|
+
proposedName,
|
|
1901
|
+
true,
|
|
1902
|
+
purse,
|
|
1903
|
+
);
|
|
1904
|
+
} catch (e) {
|
|
1905
|
+
console.error('/// could not add bank asset purse', e, {
|
|
1906
|
+
issuerName,
|
|
1907
|
+
proposedName,
|
|
1908
|
+
issuer,
|
|
1909
|
+
brand,
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
},
|
|
1913
|
+
}),
|
|
1914
|
+
).finally(() => console.error('/// This is the end of the bank assets'));
|
|
1918
1915
|
};
|
|
1919
1916
|
return {
|
|
1920
1917
|
admin: wallet,
|