@agoric/wallet-backend 0.14.4-dev-b2b928a.0 → 0.14.4-dev-a07bcaa.0.a07bcaa
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/bundles/bundle-wallet-js-meta.json +229 -219
- package/bundles/bundle-wallet.js +1 -1
- package/package.json +16 -13
- package/src/findOrMakeInvitation.js +6 -2
- package/src/internal-types.js +11 -5
- package/src/issuerTable.js +4 -1
- package/src/lib-dehydrate.js +5 -0
- package/src/lib-wallet.js +16 -6
- package/src/types-ambient.js +10 -2
- package/src/wallet.js +16 -5
- package/test/lib-wallet.test.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/wallet-backend",
|
|
3
|
-
"version": "0.14.4-dev-
|
|
3
|
+
"version": "0.14.4-dev-a07bcaa.0.a07bcaa",
|
|
4
4
|
"description": "Wallet backend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -14,23 +14,23 @@
|
|
|
14
14
|
"lint:eslint": "yarn run -T eslint ."
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@agoric/vats": "0.15.2-dev-
|
|
17
|
+
"@agoric/vats": "0.15.2-dev-a07bcaa.0.a07bcaa",
|
|
18
18
|
"@endo/bundle-source": "^4.1.2",
|
|
19
19
|
"@endo/far": "^1.1.14",
|
|
20
20
|
"@endo/init": "^1.1.12",
|
|
21
21
|
"ava": "^5.3.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@agoric/cache": "0.3.3-dev-
|
|
25
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
26
|
-
"@agoric/internal": "0.3.3-dev-
|
|
27
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
28
|
-
"@agoric/smart-wallet": "0.5.4-dev-
|
|
29
|
-
"@agoric/store": "0.9.3-dev-
|
|
30
|
-
"@agoric/time": "0.3.3-dev-
|
|
31
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
32
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
33
|
-
"@agoric/zone": "0.2.3-dev-
|
|
24
|
+
"@agoric/cache": "0.3.3-dev-a07bcaa.0.a07bcaa",
|
|
25
|
+
"@agoric/ertp": "0.16.3-dev-a07bcaa.0.a07bcaa",
|
|
26
|
+
"@agoric/internal": "0.3.3-dev-a07bcaa.0.a07bcaa",
|
|
27
|
+
"@agoric/notifier": "0.6.3-dev-a07bcaa.0.a07bcaa",
|
|
28
|
+
"@agoric/smart-wallet": "0.5.4-dev-a07bcaa.0.a07bcaa",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-a07bcaa.0.a07bcaa",
|
|
30
|
+
"@agoric/time": "0.3.3-dev-a07bcaa.0.a07bcaa",
|
|
31
|
+
"@agoric/vat-data": "0.5.3-dev-a07bcaa.0.a07bcaa",
|
|
32
|
+
"@agoric/zoe": "0.26.3-dev-a07bcaa.0.a07bcaa",
|
|
33
|
+
"@agoric/zone": "0.2.3-dev-a07bcaa.0.a07bcaa",
|
|
34
34
|
"@endo/errors": "^1.2.13",
|
|
35
35
|
"@endo/eventual-send": "^1.3.4",
|
|
36
36
|
"@endo/marshal": "^1.8.0",
|
|
@@ -65,5 +65,8 @@
|
|
|
65
65
|
"typeCoverage": {
|
|
66
66
|
"atLeast": 0
|
|
67
67
|
},
|
|
68
|
-
"
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": "^20.9 || ^22.11"
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "a07bcaafea902c18b6d1c5233636240237bc8a6e"
|
|
69
72
|
}
|
|
@@ -3,6 +3,10 @@ import { E } from '@endo/eventual-send';
|
|
|
3
3
|
import { passStyleOf } from '@endo/marshal';
|
|
4
4
|
import { AmountMath } from '@agoric/ertp';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @import {Board} from '@agoric/vats';
|
|
8
|
+
*/
|
|
9
|
+
|
|
6
10
|
export const makeId = (dappOrigin, rawId) => `${dappOrigin}#${rawId}`;
|
|
7
11
|
|
|
8
12
|
const assertFirstCapASCII = str => {
|
|
@@ -19,7 +23,7 @@ const assertFirstCapASCII = str => {
|
|
|
19
23
|
/**
|
|
20
24
|
* @param {Amount<'set'>} invitationPurseBalance
|
|
21
25
|
* @param {object} query
|
|
22
|
-
* @param {
|
|
26
|
+
* @param {Board} query.board
|
|
23
27
|
* @param {string} query.boardId
|
|
24
28
|
* @returns {Promise<Array>}
|
|
25
29
|
* @deprecated
|
|
@@ -91,7 +95,7 @@ const makeContinuingInvitation = async (
|
|
|
91
95
|
/**
|
|
92
96
|
* @param {InvitationMaker} invitationMaker
|
|
93
97
|
* @param {string} instanceHandleBoardId
|
|
94
|
-
* @param {
|
|
98
|
+
* @param {Board} board
|
|
95
99
|
* @param {ZoeService} zoe
|
|
96
100
|
* @returns {Promise<Invitation>}
|
|
97
101
|
*/
|
package/src/internal-types.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
/** @import {PursesJSONState, RecordMetadata} from './types-ambient.js'; */
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @typedef {object} PursesAddedState
|
|
5
7
|
* @property {Purse} purse
|
|
@@ -8,8 +10,12 @@
|
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
|
-
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
12
13
|
* @import {Key} from '@endo/patterns';
|
|
14
|
+
* @import {Coordinator} from '@agoric/cache';
|
|
15
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
16
|
+
* @import {AmountValue} from '@agoric/ertp/src/types.js';
|
|
17
|
+
* @import {ZoeIssuerRecord} from '@agoric/zoe';
|
|
18
|
+
* @import {WalletRoot} from './lib-wallet.js';
|
|
13
19
|
*/
|
|
14
20
|
|
|
15
21
|
/**
|
|
@@ -18,7 +24,7 @@
|
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* @typedef {object} PurseActions
|
|
21
|
-
* @property {(receiverP: ERef<{ receive: (payment: Payment) => void }>, valueToSend:
|
|
27
|
+
* @property {(receiverP: ERef<{ receive: (payment: Payment) => void }>, valueToSend: AmountValue) => Promise<void>} send
|
|
22
28
|
* @property {(payment: Payment) => Promise<Amount>} receive
|
|
23
29
|
* @property {(payment: Payment, amount?: Amount) => Promise<Amount>} deposit
|
|
24
30
|
*/
|
|
@@ -42,7 +48,7 @@
|
|
|
42
48
|
* @property {Petname} petname
|
|
43
49
|
* @property {boolean} enable
|
|
44
50
|
* @property {string} origin
|
|
45
|
-
* @property {ERef<
|
|
51
|
+
* @property {ERef<Coordinator>} cacheCoordinator
|
|
46
52
|
* @property {DappActions} actions
|
|
47
53
|
*/
|
|
48
54
|
|
|
@@ -85,7 +91,7 @@
|
|
|
85
91
|
* @property {string} [issuerBoardId]
|
|
86
92
|
*
|
|
87
93
|
* @typedef {object} PaymentActions
|
|
88
|
-
* @property {(purseOrPetname?: (Purse | Petname)) => Promise<
|
|
94
|
+
* @property {(purseOrPetname?: (Purse | Petname)) => Promise<AmountValue>} deposit
|
|
89
95
|
* @property {() => Promise<boolean>} refresh
|
|
90
96
|
* @property {() => Promise<boolean>} getAmountOf
|
|
91
97
|
*/
|
|
@@ -96,6 +102,6 @@
|
|
|
96
102
|
* would make them part of the WalletUser available as `home.wallet` in the
|
|
97
103
|
* REPL. Then, the Wallet UI could use that instead.
|
|
98
104
|
*
|
|
99
|
-
* @typedef {
|
|
105
|
+
* @typedef {WalletRoot['admin']}
|
|
100
106
|
* WalletAdminFacet
|
|
101
107
|
*/
|
package/src/issuerTable.js
CHANGED
|
@@ -5,7 +5,10 @@ import { E } from '@endo/eventual-send';
|
|
|
5
5
|
|
|
6
6
|
import { makeScalarWeakMapStore } from '@agoric/store';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @import {ZoeIssuerRecord} from '@agoric/zoe';
|
|
10
|
+
* @import {IssuerTable} from './types-ambient.js';
|
|
11
|
+
*/
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* IssuerTable
|
package/src/lib-dehydrate.js
CHANGED
|
@@ -4,6 +4,11 @@ import { assert, Fail, q } from '@endo/errors';
|
|
|
4
4
|
import { makeMarshal, mapIterable } from '@endo/marshal';
|
|
5
5
|
import { makeLegacyMap, makeScalarMapStore } from '@agoric/store';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
9
|
+
* @import {Mapping} from './internal-types.js';
|
|
10
|
+
*/
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* @typedef {string[]} Path
|
|
9
14
|
* @typedef {{} & 'Strongname'} Strongname
|
package/src/lib-wallet.js
CHANGED
|
@@ -42,7 +42,12 @@ import { makeId, findOrMakeInvitation } from './findOrMakeInvitation.js';
|
|
|
42
42
|
import { bigintStringify } from './bigintStringify.js';
|
|
43
43
|
import { makePaymentActions } from './actions.js';
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
47
|
+
* @import {UserSeat} from '@agoric/zoe';
|
|
48
|
+
* @import {BrandRecord, Contact, DappRecord, Mapping, PaymentRecord, PursesFullState} from './internal-types.js';
|
|
49
|
+
* @import {InstallationManager, InstanceManager, IssuerManager, OfferState, PursesJSONState, RecordMetadata} from './types-ambient.js';
|
|
50
|
+
*/
|
|
46
51
|
|
|
47
52
|
// does nothing
|
|
48
53
|
const noActionStateChangeHandler = _newState => {};
|
|
@@ -57,13 +62,19 @@ const cmp = (a, b) => {
|
|
|
57
62
|
return -1;
|
|
58
63
|
};
|
|
59
64
|
|
|
65
|
+
/**
|
|
66
|
+
* @import {Board} from '@agoric/vats';
|
|
67
|
+
* @import {MyAddressNameAdmin} from '@agoric/vats';
|
|
68
|
+
* @import {makeMarshal} from '@endo/marshal';
|
|
69
|
+
*/
|
|
70
|
+
|
|
60
71
|
/**
|
|
61
72
|
* @param {{
|
|
62
73
|
* agoricNames?: ERef<NameHub>
|
|
63
|
-
* board: ERef<
|
|
74
|
+
* board: ERef<Board>
|
|
64
75
|
* dateNow?: () => number,
|
|
65
76
|
* inboxStateChangeHandler?: (state: any) => void,
|
|
66
|
-
* myAddressNameAdmin: ERef<
|
|
77
|
+
* myAddressNameAdmin: ERef<MyAddressNameAdmin>
|
|
67
78
|
* namesByAddress?: ERef<NameHub>
|
|
68
79
|
* pursesStateChangeHandler?: (state: any) => void,
|
|
69
80
|
* zoe: ERef<ZoeService>,
|
|
@@ -1264,11 +1275,10 @@ export function makeWalletRoot({
|
|
|
1264
1275
|
const { updater: paymentsUpdater, notifier: paymentsNotifier } =
|
|
1265
1276
|
/** @type {NotifierRecord<PaymentRecord[]>} */ (makeNotifierKit([]));
|
|
1266
1277
|
/**
|
|
1267
|
-
* @param {PaymentRecord} param0
|
|
1278
|
+
* @param {PaymentRecord & {displayPayment?: ReturnType<typeof fillInSlots>}} param0
|
|
1268
1279
|
*/
|
|
1269
1280
|
const updatePaymentRecord = ({ actions, ...preDisplay }) => {
|
|
1270
1281
|
// in case we have been here before...
|
|
1271
|
-
// @ts-expect-error
|
|
1272
1282
|
delete preDisplay.displayPayment;
|
|
1273
1283
|
const displayPayment = fillInSlots(dehydrate(harden(preDisplay)));
|
|
1274
1284
|
const paymentRecord = addMeta({
|
|
@@ -1690,7 +1700,7 @@ export function makeWalletRoot({
|
|
|
1690
1700
|
|
|
1691
1701
|
const firstPathToLookup = createRootLookups();
|
|
1692
1702
|
|
|
1693
|
-
/** @type {ReturnType<typeof
|
|
1703
|
+
/** @type {ReturnType<typeof makeMarshal>} */
|
|
1694
1704
|
const marshaller = harden({
|
|
1695
1705
|
fromCapData: context.fromCapData,
|
|
1696
1706
|
toCapData: context.toCapData,
|
package/src/types-ambient.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @import {Coordinator} from '@agoric/cache';
|
|
5
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
6
|
+
* @import {Board} from '@agoric/vats';
|
|
7
|
+
* @import {ZoeIssuerRecord} from '@agoric/zoe';
|
|
8
|
+
* @import {BrandRecord, WalletAdminFacet} from './internal-types.js';
|
|
9
|
+
*/
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* This is the complete wallet, including the means to get the WalletAdminFacet
|
|
5
13
|
* (necessary for the operation of the Wallet UI, and useful for the REPL).
|
|
@@ -57,7 +65,7 @@
|
|
|
57
65
|
* wallet.
|
|
58
66
|
*
|
|
59
67
|
* @property {(offer: OfferState) => Promise<string>} addOffer
|
|
60
|
-
* @property {() => Promise<
|
|
68
|
+
* @property {() => Promise<Coordinator>} getCacheCoordinator
|
|
61
69
|
* @property {(brandBoardId: string) => Promise<string>} getDepositFacetId
|
|
62
70
|
* Return the board ID to use to receive payments of the specified brand.
|
|
63
71
|
* @property {() => Promise<Notifier<Array<PursesJSONState>>>} getPursesNotifier
|
|
@@ -85,7 +93,7 @@
|
|
|
85
93
|
* is safe to pass to the dapp UI.
|
|
86
94
|
* @property {() => Promise<ZoeService>} getZoe
|
|
87
95
|
* Get the Zoe Service
|
|
88
|
-
* @property {() => Promise<
|
|
96
|
+
* @property {() => Promise<Board>} getBoard
|
|
89
97
|
* Get the Board
|
|
90
98
|
* @property {(...path: Array<unknown>) => Promise<unknown>} getAgoricNames
|
|
91
99
|
* Get the curated Agoric public naming hub
|
package/src/wallet.js
CHANGED
|
@@ -18,16 +18,27 @@ import pubsub from './pubsub.js';
|
|
|
18
18
|
import { bigintStringify } from './bigintStringify.js';
|
|
19
19
|
import { makeTimerDeviceDateNow, makeTimerServiceDateNow } from './date-now.js';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @import {Petname} from '@agoric/deploy-script-support/src/externalTypes.js';
|
|
23
|
+
* @import {WalletAdminFacet} from './internal-types.js';
|
|
24
|
+
* @import {OfferState, PursesJSONState, WalletAdmin, WalletBridge} from './types-ambient.js';
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @import {Board} from '@agoric/vats';
|
|
29
|
+
* @import {TimerService} from '@agoric/time';
|
|
30
|
+
* @import {MyAddressNameAdmin} from '@agoric/vats';
|
|
31
|
+
* @import {WalletRoot} from './lib-wallet.js';
|
|
32
|
+
*/
|
|
22
33
|
|
|
23
34
|
/**
|
|
24
35
|
* @typedef {{
|
|
25
36
|
* agoricNames: ERef<NameHub>,
|
|
26
|
-
* board: ERef<
|
|
37
|
+
* board: ERef<Board>,
|
|
27
38
|
* cacheStorageNode: ERef<StorageNode>,
|
|
28
39
|
* localTimerPollInterval?: bigint,
|
|
29
|
-
* localTimerService?:
|
|
30
|
-
* myAddressNameAdmin: ERef<
|
|
40
|
+
* localTimerService?: TimerService,
|
|
41
|
+
* myAddressNameAdmin: ERef<MyAddressNameAdmin>,
|
|
31
42
|
* namesByAddress: ERef<NameHub>,
|
|
32
43
|
* timerDevice?: unknown,
|
|
33
44
|
* timerDeviceScale?: number,
|
|
@@ -41,7 +52,7 @@ export function buildRootObject(vatPowers) {
|
|
|
41
52
|
// See if we have the device vat power.
|
|
42
53
|
const { D } = vatPowers || {};
|
|
43
54
|
|
|
44
|
-
/** @type {
|
|
55
|
+
/** @type {WalletRoot} */
|
|
45
56
|
let walletRoot;
|
|
46
57
|
/** @type {WalletAdminFacet} */
|
|
47
58
|
let walletAdmin;
|
package/test/lib-wallet.test.js
CHANGED
|
@@ -19,6 +19,11 @@ import { resolve as importMetaResolve } from 'import-meta-resolve';
|
|
|
19
19
|
import { makeHeapZone } from '@agoric/zone';
|
|
20
20
|
import { makeWalletRoot } from '../src/lib-wallet.js';
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @import {TestFn} from 'ava';
|
|
24
|
+
* @import {ExecutionContext} from 'ava';
|
|
25
|
+
*/
|
|
26
|
+
|
|
22
27
|
const ZOE_INVITE_PURSE_PETNAME = 'Default Zoe invite purse';
|
|
23
28
|
|
|
24
29
|
const mixinMyAddress = prepareMixinMyAddress(makeHeapZone());
|
|
@@ -28,7 +33,7 @@ function makeFakeMyAddressNameAdmin() {
|
|
|
28
33
|
return mixinMyAddress(nameAdmin, 'agoric1test1');
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
/** @type {
|
|
36
|
+
/** @type {TestFn<Awaited<LibWalletTestContext>>} */
|
|
32
37
|
const test = anyTest;
|
|
33
38
|
|
|
34
39
|
/**
|
|
@@ -40,7 +45,7 @@ const test = anyTest;
|
|
|
40
45
|
*/
|
|
41
46
|
|
|
42
47
|
async function setupTest(
|
|
43
|
-
/** @type {
|
|
48
|
+
/** @type {ExecutionContext<LibWalletTestContext>} */ t,
|
|
44
49
|
{ autoswap = false, automaticRefund = false } = {},
|
|
45
50
|
) {
|
|
46
51
|
const pursesStateChangeLog = [];
|