@agoric/wallet 0.18.4-upgrade-14-dev-c8f9e7b.0 → 0.18.4-upgrade-16-dev-8879538.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 -33
- package/README.md +2 -2
- package/api/CHANGELOG.md +0 -32
- package/api/bundles/bundle-wallet-js-meta.json +472 -268
- package/api/bundles/bundle-wallet.js +1 -1
- package/api/deploy.js +1 -2
- package/api/package.json +30 -22
- package/api/src/findOrMakeInvitation.js +3 -1
- package/api/src/internal-types.js +8 -5
- package/api/src/issuerTable.js +0 -1
- package/api/src/lib-dehydrate.js +7 -8
- package/api/src/lib-wallet.js +51 -46
- package/api/src/wallet.js +8 -8
- 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} +12 -22
- package/api/test/{test-middleware.js → middleware.test.js} +0 -1
- package/api/{jsconfig.json → tsconfig.json} +1 -0
- package/package.json +2 -2
- 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
|
@@ -6,8 +6,7 @@ import { E } from '@endo/eventual-send';
|
|
|
6
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,
|
package/api/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/wallet-backend",
|
|
3
|
-
"version": "0.14.4-upgrade-
|
|
3
|
+
"version": "0.14.4-upgrade-16-dev-8879538.0+8879538",
|
|
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-upgrade-
|
|
18
|
-
"@endo/bundle-source": "2.
|
|
19
|
-
"@endo/
|
|
20
|
-
"
|
|
17
|
+
"@agoric/vats": "0.15.2-upgrade-16-dev-8879538.0+8879538",
|
|
18
|
+
"@endo/bundle-source": "^3.2.3",
|
|
19
|
+
"@endo/far": "^1.1.2",
|
|
20
|
+
"@endo/init": "^1.1.2",
|
|
21
|
+
"ava": "^5.3.0"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@agoric/assert": "0.6.1-upgrade-
|
|
24
|
-
"@agoric/cache": "0.3.3-upgrade-
|
|
25
|
-
"@agoric/ertp": "0.16.3-upgrade-
|
|
26
|
-
"@agoric/internal": "0.
|
|
27
|
-
"@agoric/notifier": "0.6.3-upgrade-
|
|
28
|
-
"@agoric/smart-wallet": "0.5.4-upgrade-
|
|
29
|
-
"@agoric/store": "0.9.3-upgrade-
|
|
30
|
-
"@agoric/time": "0.3.3-upgrade-
|
|
31
|
-
"@agoric/vat-data": "0.5.3-upgrade-
|
|
32
|
-
"@agoric/zoe": "0.26.3-upgrade-
|
|
33
|
-
"@
|
|
34
|
-
"@endo/
|
|
35
|
-
"@endo/
|
|
36
|
-
"@endo/
|
|
24
|
+
"@agoric/assert": "0.6.1-upgrade-16-dev-8879538.0+8879538",
|
|
25
|
+
"@agoric/cache": "0.3.3-upgrade-16-dev-8879538.0+8879538",
|
|
26
|
+
"@agoric/ertp": "0.16.3-upgrade-16-dev-8879538.0+8879538",
|
|
27
|
+
"@agoric/internal": "0.3.3-upgrade-16-dev-8879538.0+8879538",
|
|
28
|
+
"@agoric/notifier": "0.6.3-upgrade-16-dev-8879538.0+8879538",
|
|
29
|
+
"@agoric/smart-wallet": "0.5.4-upgrade-16-dev-8879538.0+8879538",
|
|
30
|
+
"@agoric/store": "0.9.3-upgrade-16-dev-8879538.0+8879538",
|
|
31
|
+
"@agoric/time": "0.3.3-upgrade-16-dev-8879538.0+8879538",
|
|
32
|
+
"@agoric/vat-data": "0.5.3-upgrade-16-dev-8879538.0+8879538",
|
|
33
|
+
"@agoric/zoe": "0.26.3-upgrade-16-dev-8879538.0+8879538",
|
|
34
|
+
"@agoric/zone": "0.2.3-upgrade-16-dev-8879538.0+8879538",
|
|
35
|
+
"@endo/eventual-send": "^1.2.2",
|
|
36
|
+
"@endo/marshal": "^1.5.0",
|
|
37
|
+
"@endo/nat": "^5.0.7",
|
|
38
|
+
"@endo/promise-kit": "^1.1.2",
|
|
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": "8879538cd1d125a08346f02dd5701d0d70c90bb8"
|
|
61
69
|
}
|
|
@@ -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
package/api/src/lib-dehydrate.js
CHANGED
|
@@ -86,10 +86,9 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* @template T
|
|
90
89
|
* @param {string} kind
|
|
91
90
|
* @param {{ useLegacyMap?: boolean }} [legacyOptions]
|
|
92
|
-
* @returns {Mapping<
|
|
91
|
+
* @returns {Mapping<any>}
|
|
93
92
|
*/
|
|
94
93
|
const makeMapping = (kind, { useLegacyMap = false } = {}) => {
|
|
95
94
|
typeof kind === 'string' || `kind ${kind} must be a string`;
|
|
@@ -97,9 +96,9 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
97
96
|
// These are actually either a LegacyMap or a MapStore depending on
|
|
98
97
|
// useLegacyMap. Fortunately, the LegacyMap type is approximately the
|
|
99
98
|
// intersection of these, so we can just use it.
|
|
100
|
-
/** @type {LegacyMap<
|
|
99
|
+
/** @type {LegacyMap<any, string>} */
|
|
101
100
|
const rawValToPetname = makeMap('value');
|
|
102
|
-
/** @type {LegacyMap<
|
|
101
|
+
/** @type {LegacyMap<any, string | Path>} */
|
|
103
102
|
const valToPetname = {
|
|
104
103
|
...rawValToPetname,
|
|
105
104
|
set(key, val) {
|
|
@@ -121,9 +120,9 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
121
120
|
return mapIterable(rawValToPetname.values(), val => explode(val));
|
|
122
121
|
},
|
|
123
122
|
};
|
|
124
|
-
/** @type {MapStore<string,
|
|
123
|
+
/** @type {MapStore<string, any>} */
|
|
125
124
|
const rawPetnameToVal = makeScalarMapStore('petname');
|
|
126
|
-
/** @type {MapStore<Path | string,
|
|
125
|
+
/** @type {MapStore<Path | string, any>} */
|
|
127
126
|
const petnameToVal = {
|
|
128
127
|
...rawPetnameToVal,
|
|
129
128
|
init(key, val) {
|
|
@@ -270,7 +269,7 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
270
269
|
petnameToVal.delete(petname);
|
|
271
270
|
valToPetname.delete(val);
|
|
272
271
|
};
|
|
273
|
-
/** @type {Mapping<
|
|
272
|
+
/** @type {Mapping<any>} */
|
|
274
273
|
const mapping = harden({
|
|
275
274
|
implode,
|
|
276
275
|
explode,
|
|
@@ -340,7 +339,7 @@ export const makeDehydrator = (initialUnnamedCount = 0) => {
|
|
|
340
339
|
marshalName: 'hydration',
|
|
341
340
|
// TODO Temporary hack.
|
|
342
341
|
// See https://github.com/Agoric/agoric-sdk/issues/2780
|
|
343
|
-
errorIdNum:
|
|
342
|
+
errorIdNum: 30_000,
|
|
344
343
|
serializeBodyFormat: 'smallcaps',
|
|
345
344
|
},
|
|
346
345
|
);
|
package/api/src/lib-wallet.js
CHANGED
|
@@ -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,
|
|
@@ -502,9 +498,8 @@ export function makeWalletRoot({
|
|
|
502
498
|
const alreadyDisplayed =
|
|
503
499
|
inboxState.has(id) && inboxState.get(id).proposalForDisplay;
|
|
504
500
|
|
|
505
|
-
const augmentedInvitationDetails =
|
|
506
|
-
invitationDetails
|
|
507
|
-
);
|
|
501
|
+
const augmentedInvitationDetails =
|
|
502
|
+
await expandInvitationBrands(invitationDetails);
|
|
508
503
|
|
|
509
504
|
const offerForDisplay = {
|
|
510
505
|
...offer,
|
|
@@ -583,7 +578,7 @@ export function makeWalletRoot({
|
|
|
583
578
|
status: 'complete',
|
|
584
579
|
});
|
|
585
580
|
idToOffer.set(id, completedOffer);
|
|
586
|
-
updateInboxState(id, completedOffer);
|
|
581
|
+
void updateInboxState(id, completedOffer);
|
|
587
582
|
}
|
|
588
583
|
|
|
589
584
|
/**
|
|
@@ -592,8 +587,8 @@ export function makeWalletRoot({
|
|
|
592
587
|
* @param {string} id
|
|
593
588
|
* @param {ERef<UserSeat>} seat
|
|
594
589
|
*/
|
|
595
|
-
|
|
596
|
-
E(E(seat).getExitSubscriber())
|
|
590
|
+
function subscribeToUpdates(id, seat) {
|
|
591
|
+
return E(E(seat).getExitSubscriber())
|
|
597
592
|
.subscribeAfter()
|
|
598
593
|
.then(update => updateOrResubscribe(id, seat, update));
|
|
599
594
|
}
|
|
@@ -680,7 +675,7 @@ export function makeWalletRoot({
|
|
|
680
675
|
);
|
|
681
676
|
// By the time Zoe settles the seat promise, the escrow should be complete.
|
|
682
677
|
// Reclaim if it is somehow not.
|
|
683
|
-
seat.finally(tryReclaimingWithdrawnPayments);
|
|
678
|
+
void seat.finally(tryReclaimingWithdrawnPayments);
|
|
684
679
|
|
|
685
680
|
// Even if the seat doesn't settle, we can still pipeline our request for
|
|
686
681
|
// payouts.
|
|
@@ -702,7 +697,7 @@ export function makeWalletRoot({
|
|
|
702
697
|
// Regardless of the status of the offer, we try to clean up any of our
|
|
703
698
|
// unclaimed payments. Defensively, we want to do this as soon as possible
|
|
704
699
|
// even if the seat doesn't settle.
|
|
705
|
-
depositedP.finally(tryReclaimingWithdrawnPayments);
|
|
700
|
+
void depositedP.finally(tryReclaimingWithdrawnPayments);
|
|
706
701
|
|
|
707
702
|
// Return a promise that will resolve after successful deposit, as well as
|
|
708
703
|
// the promise for the seat.
|
|
@@ -726,7 +721,7 @@ export function makeWalletRoot({
|
|
|
726
721
|
// eslint-disable-next-line no-use-before-define
|
|
727
722
|
p = makeEmptyPurse(petnameForBrand, petnameForBrand, true);
|
|
728
723
|
} else {
|
|
729
|
-
p = Promise.resolve();
|
|
724
|
+
p = Promise.resolve(undefined);
|
|
730
725
|
}
|
|
731
726
|
return E.when(p, _ => petnameForBrand);
|
|
732
727
|
};
|
|
@@ -754,7 +749,9 @@ export function makeWalletRoot({
|
|
|
754
749
|
* @param {string} [address]
|
|
755
750
|
*/
|
|
756
751
|
const addContact = async (petname, actions, address = undefined) => {
|
|
752
|
+
// @ts-expect-error XXX ERef
|
|
757
753
|
const already = await E(board).has(actions);
|
|
754
|
+
/** @type {any} */
|
|
758
755
|
let depositFacet;
|
|
759
756
|
if (already) {
|
|
760
757
|
depositFacet = actions;
|
|
@@ -793,7 +790,7 @@ export function makeWalletRoot({
|
|
|
793
790
|
// possible display in the wallet.
|
|
794
791
|
petname = instanceMapping.suggestPetname(petname, instanceHandle);
|
|
795
792
|
// We don't wait for the update before returning.
|
|
796
|
-
updateAllState();
|
|
793
|
+
void updateAllState();
|
|
797
794
|
return `instance ${q(petname)} successfully added to wallet`;
|
|
798
795
|
};
|
|
799
796
|
|
|
@@ -831,7 +828,7 @@ export function makeWalletRoot({
|
|
|
831
828
|
await updatePursesState(petnameForPurse, purse);
|
|
832
829
|
|
|
833
830
|
// Just notice the balance updates for the purse.
|
|
834
|
-
observeNotifier(E(purse).getCurrentAmountNotifier(), {
|
|
831
|
+
void observeNotifier(E(purse).getCurrentAmountNotifier(), {
|
|
835
832
|
updateState(_balance) {
|
|
836
833
|
updatePursesState(purseMapping.valToPetname.get(purse), purse).catch(
|
|
837
834
|
e => console.error('cannot updateState', e),
|
|
@@ -1031,7 +1028,7 @@ export function makeWalletRoot({
|
|
|
1031
1028
|
petname,
|
|
1032
1029
|
});
|
|
1033
1030
|
updateDapp(dappRecord);
|
|
1034
|
-
updateAllState();
|
|
1031
|
+
void updateAllState();
|
|
1035
1032
|
return dappRecord.actions;
|
|
1036
1033
|
},
|
|
1037
1034
|
enable() {
|
|
@@ -1153,7 +1150,7 @@ export function makeWalletRoot({
|
|
|
1153
1150
|
status: 'decline',
|
|
1154
1151
|
});
|
|
1155
1152
|
idToOffer.set(id, declinedOffer);
|
|
1156
|
-
updateInboxState(id, declinedOffer);
|
|
1153
|
+
void updateInboxState(id, declinedOffer);
|
|
1157
1154
|
|
|
1158
1155
|
// Try to reclaim the invitation.
|
|
1159
1156
|
const compiledOfferP = idToCompiledOfferP.get(id);
|
|
@@ -1180,7 +1177,7 @@ export function makeWalletRoot({
|
|
|
1180
1177
|
status: 'cancel',
|
|
1181
1178
|
});
|
|
1182
1179
|
idToOffer.set(id, cancelledOffer);
|
|
1183
|
-
updateInboxState(id, cancelledOffer);
|
|
1180
|
+
return updateInboxState(id, cancelledOffer);
|
|
1184
1181
|
})
|
|
1185
1182
|
.catch(e => console.error(`Cannot cancel offer ${id}:`, e));
|
|
1186
1183
|
|
|
@@ -1206,16 +1203,17 @@ export function makeWalletRoot({
|
|
|
1206
1203
|
error: `${e}`,
|
|
1207
1204
|
});
|
|
1208
1205
|
idToOffer.set(id, rejectOffer);
|
|
1209
|
-
updateInboxState(id, rejectOffer);
|
|
1206
|
+
void updateInboxState(id, rejectOffer);
|
|
1210
1207
|
};
|
|
1211
1208
|
|
|
1209
|
+
await null;
|
|
1212
1210
|
try {
|
|
1213
1211
|
const pendingOffer = addMeta({
|
|
1214
1212
|
...offer,
|
|
1215
1213
|
status: 'pending',
|
|
1216
1214
|
});
|
|
1217
1215
|
idToOffer.set(id, pendingOffer);
|
|
1218
|
-
updateInboxState(id, pendingOffer);
|
|
1216
|
+
void updateInboxState(id, pendingOffer);
|
|
1219
1217
|
const compiledOffer = await idToCompiledOfferP.get(id);
|
|
1220
1218
|
|
|
1221
1219
|
const { depositedP, seat } = await executeOffer(compiledOffer);
|
|
@@ -1227,11 +1225,11 @@ export function makeWalletRoot({
|
|
|
1227
1225
|
idToSeat.set(id, seat);
|
|
1228
1226
|
// The offer might have been postponed, or it might have been immediately
|
|
1229
1227
|
// consummated. Only subscribe if it was postponed.
|
|
1230
|
-
E(seat)
|
|
1228
|
+
void E(seat)
|
|
1231
1229
|
.hasExited()
|
|
1232
1230
|
.then(exited => {
|
|
1233
1231
|
if (!exited) {
|
|
1234
|
-
subscribeToUpdates(id, seat);
|
|
1232
|
+
return subscribeToUpdates(id, seat);
|
|
1235
1233
|
}
|
|
1236
1234
|
});
|
|
1237
1235
|
|
|
@@ -1254,7 +1252,7 @@ export function makeWalletRoot({
|
|
|
1254
1252
|
status: 'accept',
|
|
1255
1253
|
});
|
|
1256
1254
|
idToOffer.set(id, acceptedOffer);
|
|
1257
|
-
updateInboxState(id, acceptedOffer);
|
|
1255
|
+
void updateInboxState(id, acceptedOffer);
|
|
1258
1256
|
}
|
|
1259
1257
|
})
|
|
1260
1258
|
.catch(rejected);
|
|
@@ -1372,6 +1370,7 @@ export function makeWalletRoot({
|
|
|
1372
1370
|
brandToAutoDepositPurse.init(brand, purse);
|
|
1373
1371
|
}
|
|
1374
1372
|
|
|
1373
|
+
await null;
|
|
1375
1374
|
if (updateState) {
|
|
1376
1375
|
await updateAllPurseState();
|
|
1377
1376
|
}
|
|
@@ -1406,11 +1405,13 @@ export function makeWalletRoot({
|
|
|
1406
1405
|
boardId,
|
|
1407
1406
|
dappOrigin = undefined,
|
|
1408
1407
|
) {
|
|
1408
|
+
/** @type {Petname} */
|
|
1409
1409
|
let petname;
|
|
1410
1410
|
if (dappOrigin === undefined) {
|
|
1411
1411
|
petname = suggestedPetname;
|
|
1412
1412
|
} else {
|
|
1413
1413
|
const edgename = edgeMapping.valToPetname.get(dappOrigin);
|
|
1414
|
+
// @ts-expect-error if suggestedPetname is itself an array, this nests
|
|
1414
1415
|
petname = [edgename, suggestedPetname];
|
|
1415
1416
|
}
|
|
1416
1417
|
|
|
@@ -1893,28 +1894,32 @@ export function makeWalletRoot({
|
|
|
1893
1894
|
// don't really trust.
|
|
1894
1895
|
// The param is{import('@agoric/vats/src/vat-bank.js').Bank} but that here triggers https://github.com/Agoric/agoric-sdk/issues/4620
|
|
1895
1896
|
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
|
-
|
|
1897
|
+
void observeIteration(
|
|
1898
|
+
subscribeEach(E(bank).getAssetSubscription()),
|
|
1899
|
+
harden({
|
|
1900
|
+
async updateState({ proposedName, issuerName, issuer, brand }) {
|
|
1901
|
+
await null;
|
|
1902
|
+
try {
|
|
1903
|
+
issuerName = await addIssuer(issuerName, issuer);
|
|
1904
|
+
const purse = await E(bank).getPurse(brand);
|
|
1905
|
+
// We can import this purse, because we trust the bank.
|
|
1906
|
+
await internalUnsafeImportPurse(
|
|
1907
|
+
issuerName,
|
|
1908
|
+
proposedName,
|
|
1909
|
+
true,
|
|
1910
|
+
purse,
|
|
1911
|
+
);
|
|
1912
|
+
} catch (e) {
|
|
1913
|
+
console.error('/// could not add bank asset purse', e, {
|
|
1914
|
+
issuerName,
|
|
1915
|
+
proposedName,
|
|
1916
|
+
issuer,
|
|
1917
|
+
brand,
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
},
|
|
1921
|
+
}),
|
|
1922
|
+
).finally(() => console.error('/// This is the end of the bank assets'));
|
|
1918
1923
|
};
|
|
1919
1924
|
return {
|
|
1920
1925
|
admin: wallet,
|
package/api/src/wallet.js
CHANGED
|
@@ -25,7 +25,7 @@ import './internal-types.js';
|
|
|
25
25
|
* board: ERef<import('@agoric/vats').Board>,
|
|
26
26
|
* cacheStorageNode: ERef<StorageNode>,
|
|
27
27
|
* localTimerPollInterval?: bigint,
|
|
28
|
-
* localTimerService?: import('@agoric/time
|
|
28
|
+
* localTimerService?: import('@agoric/time').TimerService,
|
|
29
29
|
* myAddressNameAdmin: ERef<import('@agoric/vats').MyAddressNameAdmin>,
|
|
30
30
|
* namesByAddress: ERef<NameHub>,
|
|
31
31
|
* timerDevice?: unknown,
|
|
@@ -33,7 +33,7 @@ import './internal-types.js';
|
|
|
33
33
|
* zoe: ERef<ZoeService>,
|
|
34
34
|
* }} StartupTerms
|
|
35
35
|
*
|
|
36
|
-
* @
|
|
36
|
+
* @import {NameHub} from '@agoric/vats'
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
export function buildRootObject(vatPowers) {
|
|
@@ -164,6 +164,7 @@ export function buildRootObject(vatPowers) {
|
|
|
164
164
|
yield state;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
harden(makeApprovedNotifier);
|
|
167
168
|
|
|
168
169
|
/** @type {WalletBridge} */
|
|
169
170
|
const bridge = Far('bridge', {
|
|
@@ -171,7 +172,7 @@ export function buildRootObject(vatPowers) {
|
|
|
171
172
|
await approve();
|
|
172
173
|
const pursesNotifier = walletAdmin.getAttenuatedPursesNotifier();
|
|
173
174
|
const { notifier, updater } = makeNotifierKit();
|
|
174
|
-
observeIteration(makeApprovedNotifier(pursesNotifier), updater);
|
|
175
|
+
void observeIteration(makeApprovedNotifier(pursesNotifier), updater);
|
|
175
176
|
return notifier;
|
|
176
177
|
},
|
|
177
178
|
async getCacheCoordinator() {
|
|
@@ -200,7 +201,7 @@ export function buildRootObject(vatPowers) {
|
|
|
200
201
|
}));
|
|
201
202
|
};
|
|
202
203
|
|
|
203
|
-
observeIteration(makeApprovedNotifier(offerNotifier), {
|
|
204
|
+
void observeIteration(makeApprovedNotifier(offerNotifier), {
|
|
204
205
|
updateState(offers) {
|
|
205
206
|
updater.updateState(filteredOffers(offers));
|
|
206
207
|
},
|
|
@@ -439,7 +440,7 @@ export function buildRootObject(vatPowers) {
|
|
|
439
440
|
},
|
|
440
441
|
);
|
|
441
442
|
if (notYetEnabled) {
|
|
442
|
-
E(otherSide).dappApproved(dappOrigin);
|
|
443
|
+
await E(otherSide).dappApproved(dappOrigin);
|
|
443
444
|
}
|
|
444
445
|
};
|
|
445
446
|
|
|
@@ -587,9 +588,8 @@ export function buildRootObject(vatPowers) {
|
|
|
587
588
|
|
|
588
589
|
case 'walletGetDepositFacetId': {
|
|
589
590
|
const { brandBoardId } = obj;
|
|
590
|
-
const result =
|
|
591
|
-
brandBoardId
|
|
592
|
-
);
|
|
591
|
+
const result =
|
|
592
|
+
await walletAdmin.getDepositFacetId(brandBoardId);
|
|
593
593
|
return {
|
|
594
594
|
type: 'walletDepositFacetIdResponse',
|
|
595
595
|
data: result,
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import { makeNotifierFromSubscriber, makePublishKit } from '@agoric/notifier';
|
|
4
4
|
import { Far } from '@endo/marshal';
|
|
5
5
|
|
|
6
|
-
import '@agoric/zoe/exported.js';
|
|
7
|
-
|
|
8
6
|
export const start = zcf => {
|
|
9
7
|
const { subscriber, publisher } = makePublishKit();
|
|
10
8
|
const notifier = makeNotifierFromSubscriber(subscriber);
|
|
@@ -3,19 +3,15 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
|
|
|
3
3
|
|
|
4
4
|
import { makeIssuerKit } from '@agoric/ertp';
|
|
5
5
|
import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
|
|
6
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
6
|
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
|
|
8
|
-
|
|
9
|
-
import { heapZone } from '@agoric/zone';
|
|
7
|
+
import { makeHeapZone } from '@agoric/zone';
|
|
10
8
|
import {
|
|
11
9
|
makeNameHubKit,
|
|
12
10
|
prepareMixinMyAddress,
|
|
13
11
|
} from '@agoric/vats/src/nameHub.js';
|
|
14
12
|
import { makeWalletRoot } from '../src/lib-wallet.js';
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const mixinMyAddress = prepareMixinMyAddress(heapZone);
|
|
14
|
+
const mixinMyAddress = prepareMixinMyAddress(makeHeapZone());
|
|
19
15
|
|
|
20
16
|
function makeFakeMyAddressNameAdmin() {
|
|
21
17
|
const { nameAdmin } = makeNameHubKit();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
4
|
import bundleSource from '@endo/bundle-source';
|
|
6
5
|
import { makeCache } from '@agoric/cache';
|
|
7
6
|
import { makeIssuerKit, AmountMath, AssetKind } from '@agoric/ertp';
|
|
@@ -12,23 +11,18 @@ import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
|
|
|
12
11
|
import { E } from '@endo/eventual-send';
|
|
13
12
|
|
|
14
13
|
import { assert } from '@agoric/assert';
|
|
15
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16
14
|
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
|
|
17
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
15
|
import {
|
|
19
16
|
makeNameHubKit,
|
|
20
17
|
prepareMixinMyAddress,
|
|
21
18
|
} from '@agoric/vats/src/nameHub.js';
|
|
22
19
|
import { resolve as importMetaResolve } from 'import-meta-resolve';
|
|
23
|
-
|
|
24
|
-
import { heapZone } from '@agoric/zone';
|
|
20
|
+
import { makeHeapZone } from '@agoric/zone';
|
|
25
21
|
import { makeWalletRoot } from '../src/lib-wallet.js';
|
|
26
22
|
|
|
27
|
-
import '../src/types.js';
|
|
28
|
-
|
|
29
23
|
const ZOE_INVITE_PURSE_PETNAME = 'Default Zoe invite purse';
|
|
30
24
|
|
|
31
|
-
const mixinMyAddress = prepareMixinMyAddress(
|
|
25
|
+
const mixinMyAddress = prepareMixinMyAddress(makeHeapZone());
|
|
32
26
|
|
|
33
27
|
function makeFakeMyAddressNameAdmin() {
|
|
34
28
|
const { nameAdmin } = makeNameHubKit();
|
|
@@ -303,12 +297,12 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
303
297
|
const {
|
|
304
298
|
board,
|
|
305
299
|
automaticRefundInvitation,
|
|
306
|
-
autoswapInstallationHandle,
|
|
307
300
|
automaticRefundInstance,
|
|
308
301
|
wallet,
|
|
309
302
|
pursesStateChangeLog,
|
|
310
303
|
inboxStateChangeLog,
|
|
311
304
|
} = await setupTest(t, { autoswap: true, automaticRefund: true });
|
|
305
|
+
const { autoswapInstallation: autoswapInstallationHandle } = t.context;
|
|
312
306
|
|
|
313
307
|
const { issuer: bucksIssuer } = makeIssuerKit('bucks');
|
|
314
308
|
const bucksIssuerBoardId = await E(board).getId(bucksIssuer);
|
|
@@ -1639,17 +1633,14 @@ test('stamps from dateNow', async t => {
|
|
|
1639
1633
|
const paymentNotifier = E(wallet).getPaymentsNotifier();
|
|
1640
1634
|
|
|
1641
1635
|
const date0 = currentDateMS;
|
|
1642
|
-
const { value: val0, updateCount: count0 } =
|
|
1643
|
-
paymentNotifier
|
|
1644
|
-
).getUpdateSince();
|
|
1636
|
+
const { value: val0, updateCount: count0 } =
|
|
1637
|
+
await E(paymentNotifier).getUpdateSince();
|
|
1645
1638
|
await E(wallet).addPayment(pmt1);
|
|
1646
|
-
const { value: val1a, updateCount: count1a } =
|
|
1647
|
-
paymentNotifier
|
|
1648
|
-
).
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
paymentNotifier,
|
|
1652
|
-
).getUpdateSince(count1a);
|
|
1639
|
+
const { value: val1a, updateCount: count1a } =
|
|
1640
|
+
await E(paymentNotifier).getUpdateSince(count0);
|
|
1641
|
+
void E(wallet).addPayment(pmt4);
|
|
1642
|
+
const { value: val1, updateCount: count1 } =
|
|
1643
|
+
await E(paymentNotifier).getUpdateSince(count1a);
|
|
1653
1644
|
|
|
1654
1645
|
// Wait for tick to take effect.
|
|
1655
1646
|
currentDateMS += 1234;
|
|
@@ -1657,9 +1648,8 @@ test('stamps from dateNow', async t => {
|
|
|
1657
1648
|
t.is(dateNow(), startDateMS + 1234);
|
|
1658
1649
|
|
|
1659
1650
|
await E(wallet).addPayment(pmt2);
|
|
1660
|
-
const { value: val2, updateCount: count2 } =
|
|
1661
|
-
paymentNotifier
|
|
1662
|
-
).getUpdateSince(count1);
|
|
1651
|
+
const { value: val2, updateCount: count2 } =
|
|
1652
|
+
await E(paymentNotifier).getUpdateSince(count1);
|
|
1663
1653
|
await E(wallet).addPayment(pmt3);
|
|
1664
1654
|
const { value: payments } = await E(paymentNotifier).getUpdateSince(count2);
|
|
1665
1655
|
|