@agoric/smart-wallet 0.5.4-dev-7cc5def.0 → 0.5.4-dev-3ce0599.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 +16 -13
- package/src/proposals/upgrade-walletFactory-proposal.d.ts +17 -0
- package/src/proposals/upgrade-walletFactory-proposal.d.ts.map +1 -0
- package/src/proposals/upgrade-walletFactory-proposal.js +128 -0
- package/src/walletFactory.d.ts +8 -3
- package/src/walletFactory.d.ts.map +1 -1
- package/src/walletFactory.js +21 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/smart-wallet",
|
|
3
|
-
"version": "0.5.4-dev-
|
|
3
|
+
"version": "0.5.4-dev-3ce0599.0+3ce0599",
|
|
4
4
|
"description": "Wallet contract",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint:eslint": "eslint ."
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@agoric/cosmic-proto": "0.3.1-dev-
|
|
19
|
+
"@agoric/cosmic-proto": "0.3.1-dev-3ce0599.0+3ce0599",
|
|
20
20
|
"@endo/bundle-source": "^2.5.2",
|
|
21
21
|
"@endo/captp": "^3.1.2",
|
|
22
22
|
"@endo/init": "^0.5.57",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"import-meta-resolve": "^2.2.1"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agoric/assert": "0.6.1-dev-
|
|
28
|
-
"@agoric/casting": "0.4.3-dev-
|
|
29
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
30
|
-
"@agoric/internal": "0.3.3-dev-
|
|
31
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
32
|
-
"@agoric/store": "0.9.3-dev-
|
|
33
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
34
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
35
|
-
"@agoric/vats": "0.15.2-dev-
|
|
36
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
27
|
+
"@agoric/assert": "0.6.1-dev-3ce0599.0+3ce0599",
|
|
28
|
+
"@agoric/casting": "0.4.3-dev-3ce0599.0+3ce0599",
|
|
29
|
+
"@agoric/ertp": "0.16.3-dev-3ce0599.0+3ce0599",
|
|
30
|
+
"@agoric/internal": "0.3.3-dev-3ce0599.0+3ce0599",
|
|
31
|
+
"@agoric/notifier": "0.6.3-dev-3ce0599.0+3ce0599",
|
|
32
|
+
"@agoric/store": "0.9.3-dev-3ce0599.0+3ce0599",
|
|
33
|
+
"@agoric/swingset-vat": "0.32.3-dev-3ce0599.0+3ce0599",
|
|
34
|
+
"@agoric/vat-data": "0.5.3-dev-3ce0599.0+3ce0599",
|
|
35
|
+
"@agoric/vats": "0.15.2-dev-3ce0599.0+3ce0599",
|
|
36
|
+
"@agoric/zoe": "0.26.3-dev-3ce0599.0+3ce0599",
|
|
37
37
|
"@endo/eventual-send": "^0.17.3",
|
|
38
38
|
"@endo/far": "^0.2.19",
|
|
39
39
|
"@endo/marshal": "^0.8.6",
|
|
@@ -58,10 +58,13 @@
|
|
|
58
58
|
"files": [
|
|
59
59
|
"test/**/test-*.js"
|
|
60
60
|
],
|
|
61
|
+
"require": [
|
|
62
|
+
"@endo/init/debug.js"
|
|
63
|
+
],
|
|
61
64
|
"timeout": "2m"
|
|
62
65
|
},
|
|
63
66
|
"publishConfig": {
|
|
64
67
|
"access": "public"
|
|
65
68
|
},
|
|
66
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "3ce0599d5173b802598b5bedf57d3c30f016f789"
|
|
67
70
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function upgradeWalletFactory({ consume: { contractKits, governedContractKits, chainStorage, walletBridgeManager: walletBridgeManagerP, }, instance: { consume: { walletFactory: wfInstanceP, provisionPool: ppInstanceP }, }, }: BootstrapPowers, config: {
|
|
2
|
+
options: {
|
|
3
|
+
walletFactoryRef: VatSourceRef & {
|
|
4
|
+
bundleID: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export function publishAgoricBrandsDisplayInfo({ consume: { agoricNames, board, chainStorage }, }: BootstrapPowers): Promise<void>;
|
|
9
|
+
export function getManifestForUpgrade(_powers: any, { walletFactoryRef }: {
|
|
10
|
+
walletFactoryRef: any;
|
|
11
|
+
}): {
|
|
12
|
+
manifest: import("@agoric/vats/src/core/lib-boot").BootstrapManifest;
|
|
13
|
+
options: {
|
|
14
|
+
walletFactoryRef: any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=upgrade-walletFactory-proposal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade-walletFactory-proposal.d.ts","sourceRoot":"","sources":["upgrade-walletFactory-proposal.js"],"names":[],"mappings":"AAqBO,yOALK,eAAe;;0BAGI,YAAY,GAAG;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE;;kBAkDjE;AAMM,mGAFK,eAAe,iBAwB1B;AAyBM;;;;;;;EAKN"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { E } from '@endo/far';
|
|
3
|
+
import { makeMarshal } from '@endo/marshal';
|
|
4
|
+
import { allValues } from '@agoric/internal';
|
|
5
|
+
|
|
6
|
+
console.warn('upgrade-walletFactory-proposal.js module evaluating');
|
|
7
|
+
|
|
8
|
+
const { Fail } = assert;
|
|
9
|
+
|
|
10
|
+
// vstorage paths under published.*
|
|
11
|
+
const WALLET_STORAGE_PATH_SEGMENT = 'wallet';
|
|
12
|
+
const BOARD_AUX = 'boardAux';
|
|
13
|
+
|
|
14
|
+
const marshalData = makeMarshal(_val => Fail`data only`);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param { BootstrapPowers } powers
|
|
18
|
+
*
|
|
19
|
+
* @param {object} config
|
|
20
|
+
* @param {{ walletFactoryRef: VatSourceRef & { bundleID: string } }} config.options
|
|
21
|
+
*/
|
|
22
|
+
export const upgradeWalletFactory = async (
|
|
23
|
+
{
|
|
24
|
+
consume: {
|
|
25
|
+
contractKits,
|
|
26
|
+
governedContractKits,
|
|
27
|
+
chainStorage,
|
|
28
|
+
walletBridgeManager: walletBridgeManagerP,
|
|
29
|
+
},
|
|
30
|
+
instance: {
|
|
31
|
+
consume: { walletFactory: wfInstanceP, provisionPool: ppInstanceP },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
config,
|
|
35
|
+
) => {
|
|
36
|
+
console.log('upgradeWalletFactory: config', config);
|
|
37
|
+
const { walletFactoryRef } = config.options;
|
|
38
|
+
|
|
39
|
+
// console.log('upgradeWalletFactory: awaiting instances etc.');
|
|
40
|
+
const { wfInstance, ppInstance, walletBridgeManager, storageNode } =
|
|
41
|
+
await allValues({
|
|
42
|
+
wfInstance: wfInstanceP,
|
|
43
|
+
ppInstance: ppInstanceP,
|
|
44
|
+
walletBridgeManager: walletBridgeManagerP,
|
|
45
|
+
// @ts-expect-error chainStorage is only falsy in testing
|
|
46
|
+
storageNode: E(chainStorage).makeChildNode(WALLET_STORAGE_PATH_SEGMENT),
|
|
47
|
+
});
|
|
48
|
+
// console.log('upgradeWalletFactory: awaiting contract kits');
|
|
49
|
+
const { wfKit, ppKit } = await allValues({
|
|
50
|
+
wfKit: E(contractKits).get(wfInstance),
|
|
51
|
+
ppKit: E(governedContractKits).get(ppInstance),
|
|
52
|
+
});
|
|
53
|
+
// console.log('upgradeWalletFactory: awaiting walletReviver');
|
|
54
|
+
const walletReviver = await E(ppKit.creatorFacet).getWalletReviver();
|
|
55
|
+
const newPrivateArgs = harden({
|
|
56
|
+
storageNode,
|
|
57
|
+
walletBridgeManager,
|
|
58
|
+
walletReviver,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
'upgradeWalletFactory: upgrading with newPrivateArgs',
|
|
63
|
+
newPrivateArgs,
|
|
64
|
+
);
|
|
65
|
+
await E(wfKit.adminFacet).upgradeContract(
|
|
66
|
+
walletFactoryRef.bundleID,
|
|
67
|
+
newPrivateArgs,
|
|
68
|
+
);
|
|
69
|
+
console.log('upgradeWalletFactory: done');
|
|
70
|
+
};
|
|
71
|
+
harden(upgradeWalletFactory);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param { BootstrapPowers } powers
|
|
75
|
+
*/
|
|
76
|
+
export const publishAgoricBrandsDisplayInfo = async ({
|
|
77
|
+
consume: { agoricNames, board, chainStorage },
|
|
78
|
+
}) => {
|
|
79
|
+
// chainStorage type includes undefined, which doesn't apply here.
|
|
80
|
+
// @ts-expect-error UNTIL https://github.com/Agoric/agoric-sdk/issues/8247
|
|
81
|
+
const boardAux = E(chainStorage).makeChildNode(BOARD_AUX);
|
|
82
|
+
const publishBrandInfo = async brand => {
|
|
83
|
+
const [id, displayInfo, allegedName] = await Promise.all([
|
|
84
|
+
E(board).getId(brand),
|
|
85
|
+
E(brand).getDisplayInfo(),
|
|
86
|
+
E(brand).getAllegedName(),
|
|
87
|
+
]);
|
|
88
|
+
const node = E(boardAux).makeChildNode(id);
|
|
89
|
+
const aux = marshalData.toCapData(harden({ allegedName, displayInfo }));
|
|
90
|
+
await E(node).setValue(JSON.stringify(aux));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** @type {ERef<NameHub>} */
|
|
94
|
+
const brandHub = E(agoricNames).lookup('brand');
|
|
95
|
+
const brands = await E(brandHub).values();
|
|
96
|
+
// tolerate failure; in particular, for the timer brand
|
|
97
|
+
await Promise.allSettled(brands.map(publishBrandInfo));
|
|
98
|
+
};
|
|
99
|
+
harden(publishAgoricBrandsDisplayInfo);
|
|
100
|
+
|
|
101
|
+
/** @type { import("@agoric/vats/src/core/lib-boot").BootstrapManifest } */
|
|
102
|
+
const manifest = {
|
|
103
|
+
[upgradeWalletFactory.name]: {
|
|
104
|
+
// include rationale for closely-held, high authority capabilities
|
|
105
|
+
consume: {
|
|
106
|
+
contractKits: `to upgrade walletFactory using its adminFacet`,
|
|
107
|
+
governedContractKits:
|
|
108
|
+
'to get walletReviver from provisionPool.creatorFacet',
|
|
109
|
+
chainStorage: 'to allow walletFactory to (continue) write to vstorage',
|
|
110
|
+
walletBridgeManager: 'to handle bridged cosmos SpendAction messages',
|
|
111
|
+
},
|
|
112
|
+
// widely-shared, low authority instance handles need no rationale
|
|
113
|
+
instance: {
|
|
114
|
+
consume: { walletFactory: true, provisionPool: true },
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
[publishAgoricBrandsDisplayInfo.name]: {
|
|
118
|
+
consume: { agoricNames: true, board: true, chainStorage: true },
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
harden(manifest);
|
|
122
|
+
|
|
123
|
+
export const getManifestForUpgrade = (_powers, { walletFactoryRef }) => {
|
|
124
|
+
return harden({
|
|
125
|
+
manifest,
|
|
126
|
+
options: { walletFactoryRef },
|
|
127
|
+
});
|
|
128
|
+
};
|
package/src/walletFactory.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export namespace customTermsShape {
|
|
2
|
+
let agoricNames: any;
|
|
3
|
+
let board: any;
|
|
4
|
+
let assetPublisher: any;
|
|
5
|
+
}
|
|
6
|
+
export const privateArgsShape: import("@endo/patterns").Matcher;
|
|
3
7
|
export function publishDepositFacet(address: string, wallet: import('./smartWallet.js').SmartWallet, namesByAddressAdmin: ERef<import('@agoric/vats').NameAdmin>): Promise<unknown>;
|
|
4
8
|
export function makeAssetRegistry(assetPublisher: AssetPublisher): {
|
|
5
9
|
/** @param {Brand} brand */
|
|
@@ -18,7 +22,7 @@ export function makeAssetRegistry(assetPublisher: AssetPublisher): {
|
|
|
18
22
|
petname: import('./types').Petname;
|
|
19
23
|
}>;
|
|
20
24
|
};
|
|
21
|
-
export function
|
|
25
|
+
export function prepare(zcf: ZCF<SmartWalletContractTerms>, privateArgs: {
|
|
22
26
|
storageNode: ERef<StorageNode>;
|
|
23
27
|
walletBridgeManager?: ERef<import("@agoric/vats").ScopedBridgeManager> | undefined;
|
|
24
28
|
walletReviver?: ERef<WalletReviver> | undefined;
|
|
@@ -105,4 +109,5 @@ export type WalletReviver = {
|
|
|
105
109
|
reviveWallet: (address: string) => Promise<import('./smartWallet').SmartWallet>;
|
|
106
110
|
ackWallet: (address: string) => isRevive;
|
|
107
111
|
};
|
|
112
|
+
export type start = typeof prepare;
|
|
108
113
|
//# sourceMappingURL=walletFactory.d.ts.map
|
|
@@ -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":";;;;;AAwBA,gEAKE;AAUK,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,SAAS,EAAE,OAAO;;;eAH3B,KAAK;qBACC,WAAW;gBAChB,MAAM;iBACL,OAAO,SAAS,EAAE,OAAO;;EAsCxC;AAmCM,6BARI,IAAI,wBAAwB,CAAC;iBAEtB,KAAK,WAAW,CAAC;;;;;QAgH7B;;;;;;;WAOG;oCANQ,MAAM,QACN,KAAK,OAAO,2BAA2B,EAAE,IAAI,CAAC,uBAC9C,KAAK,OAAO,eAAe,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;QAHlD;;;;;;;WAOG;oCANQ,MAAM,QACN,KAAK,OAAO,2BAA2B,EAAE,IAAI,CAAC,uBAC9C,KAAK,OAAO,eAAe,EAAE,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAqDvD;uCAlMY;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,2BAA2B,EAAE,eAAe,CAAC,CAAC,CAAA;CAC1E;uBAES,OAAO;;4BAES,MAAM,KAAK,QAAQ,OAAO,eAAe,EAAE,WAAW,CAAC;yBAC1D,MAAM,KAAK,QAAQ;;oBAuL/B,cAAc"}
|
package/src/walletFactory.js
CHANGED
|
@@ -16,20 +16,18 @@ import { shape } from './typeGuards.js';
|
|
|
16
16
|
|
|
17
17
|
const trace = makeTracer('WltFct');
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
export const customTermsShape = harden({
|
|
20
|
+
agoricNames: M.eref(M.remotable('agoricNames')),
|
|
21
|
+
board: M.eref(M.remotable('board')),
|
|
22
|
+
assetPublisher: M.eref(M.remotable('Bank')),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const privateArgsShape = harden(
|
|
26
|
+
M.splitRecord(
|
|
27
27
|
{ storageNode: M.eref(M.remotable('StorageNode')) },
|
|
28
28
|
{ walletBridgeManager: M.eref(M.remotable('walletBridgeManager')) },
|
|
29
29
|
),
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
harden(meta);
|
|
30
|
+
);
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Provide a NameHub for this address and insert depositFacet only if not
|
|
@@ -143,7 +141,7 @@ export const makeAssetRegistry = assetPublisher => {
|
|
|
143
141
|
* }} privateArgs
|
|
144
142
|
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
145
143
|
*/
|
|
146
|
-
export const
|
|
144
|
+
export const prepare = async (zcf, privateArgs, baggage) => {
|
|
147
145
|
const { agoricNames, board, assetPublisher } = zcf.getTerms();
|
|
148
146
|
|
|
149
147
|
const zoe = zcf.getZoeService();
|
|
@@ -294,11 +292,20 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
294
292
|
if (walletBridgeManager) {
|
|
295
293
|
// NB: may not be in service when creatorFacet is used, or ever
|
|
296
294
|
// It can't be awaited because that fails vat restart
|
|
297
|
-
|
|
295
|
+
const upgrading = baggage.has('walletsByAddress');
|
|
296
|
+
if (upgrading) {
|
|
297
|
+
void E(walletBridgeManager).setHandler(handleWalletAction);
|
|
298
|
+
} else {
|
|
299
|
+
void E(walletBridgeManager).initHandler(handleWalletAction);
|
|
300
|
+
}
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
return {
|
|
301
304
|
creatorFacet,
|
|
302
305
|
};
|
|
303
306
|
};
|
|
304
|
-
harden(
|
|
307
|
+
harden(prepare);
|
|
308
|
+
|
|
309
|
+
// So we can consistently import `start` from contracts.
|
|
310
|
+
// Can't be a value export because Zoe enforces that contracts export one or the other.
|
|
311
|
+
/** @typedef {typeof prepare} start */
|