@agoric/deploy-script-support 0.11.0 → 0.11.1-upgrade-23-dev-bd79330.0.bd79330

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/README.md CHANGED
@@ -21,18 +21,18 @@ Here's a simple example:
21
21
 
22
22
  ```js
23
23
  import { makeHelpers } from '@agoric/deploy-script-support';
24
- import { getManifestForGame1 } from '@agoric/smart-wallet/test/start-game1-proposal.js';
24
+ import { getManifestForGame1 } from '@agoric/smart-wallet/tools/fixtures/start-game1-proposal.js';
25
25
 
26
26
  /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
27
27
  const game1ProposalBuilder = async ({ publishRef, install }) => {
28
28
  return harden({
29
- sourceSpec: '@agoric/smart-wallet/test/start-game1-proposal.js',
29
+ sourceSpec: '@agoric/smart-wallet/tools/fixtures/start-game1-proposal.js',
30
30
  getManifestCall: [
31
31
  getManifestForGame1.name,
32
32
  {
33
33
  game1Ref: publishRef(
34
34
  install(
35
- '@agoric/smart-wallet/test/gameAssetContract.js',
35
+ '@agoric/smart-wallet/tools/fixtures/gameAssetContract.js',
36
36
  '../bundles/bundle-game1.js',
37
37
  { persist: true },
38
38
  ),
@@ -49,7 +49,7 @@ export default async (homeP, endowments) => {
49
49
  ```
50
50
 
51
51
  This CoreEvalBuilder returns an object whose "sourceSpec" indicates that the
52
- proposal to run is "@agoric/smart-wallet/test/start-game1-proposal.js" and whose
52
+ proposal to run is "@agoric/smart-wallet/tools/fixtures/start-game1-proposal.js" and whose
53
53
  "getManifestCall" is a [functionName, ...args] array describing an invocation of
54
54
  `getManifestForGame1` exported from that file which is expected to return an
55
55
  object including a "manifest" as described below (but the actual invocation will
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/deploy-script-support",
3
- "version": "0.11.0",
3
+ "version": "0.11.1-upgrade-23-dev-bd79330.0.bd79330",
4
4
  "description": "Helpers and other support for writing deploy scripts",
5
5
  "type": "module",
6
6
  "main": "src/helpers.js",
@@ -12,7 +12,7 @@
12
12
  "test": "ava",
13
13
  "test:xs": "exit 0",
14
14
  "lint-fix": "yarn lint:eslint --fix",
15
- "lint:eslint": "yarn run -T eslint .",
15
+ "lint:eslint": "node ../../scripts/eslint-repo.mjs .",
16
16
  "lint:types": "yarn run -T tsc",
17
17
  "lint": "yarn run -T run-s --continue-on-error 'lint:*'"
18
18
  },
@@ -34,27 +34,35 @@
34
34
  },
35
35
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
36
36
  "dependencies": {
37
- "@agoric/ertp": "0.17.0",
38
- "@agoric/import-manager": "0.3.12",
39
- "@agoric/internal": "0.4.0",
40
- "@agoric/notifier": "0.7.0",
41
- "@agoric/pola-io": "0.2.0",
42
- "@agoric/store": "0.10.0",
43
- "@agoric/time": "0.4.0",
44
- "@agoric/zoe": "0.27.0",
37
+ "@agoric/client-utils": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
38
+ "@agoric/ertp": "0.17.1-upgrade-23-dev-bd79330.0.bd79330",
39
+ "@agoric/import-manager": "0.3.13-upgrade-23-dev-bd79330.0.bd79330",
40
+ "@agoric/internal": "0.4.1-upgrade-23-dev-bd79330.0.bd79330",
41
+ "@agoric/notifier": "0.7.1-upgrade-23-dev-bd79330.0.bd79330",
42
+ "@agoric/orchestration": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
43
+ "@agoric/pola-io": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
44
+ "@agoric/portfolio-api": "0.2.1-upgrade-23-dev-bd79330.0.bd79330",
45
+ "@agoric/smart-wallet": "0.6.1-upgrade-23-dev-bd79330.0.bd79330",
46
+ "@agoric/store": "0.10.1-upgrade-23-dev-bd79330.0.bd79330",
47
+ "@agoric/time": "0.4.1-upgrade-23-dev-bd79330.0.bd79330",
48
+ "@agoric/zoe": "0.27.1-upgrade-23-dev-bd79330.0.bd79330",
49
+ "@agoric/zone": "0.3.1-upgrade-23-dev-bd79330.0.bd79330",
45
50
  "@endo/base64": "^1.0.12",
46
51
  "@endo/bundle-source": "^4.1.2",
47
52
  "@endo/errors": "^1.2.13",
53
+ "@endo/eventual-send": "^1.3.4",
48
54
  "@endo/far": "^1.1.14",
49
55
  "@endo/marshal": "^1.8.0",
50
56
  "@endo/nat": "^5.1.3",
57
+ "@endo/pass-style": "^1.6.3",
58
+ "@endo/patterns": "^1.7.0",
51
59
  "@endo/promise-kit": "^1.1.13",
52
60
  "@endo/zip": "^1.0.11"
53
61
  },
54
62
  "devDependencies": {
55
- "@agoric/vats": "0.16.0",
63
+ "@agoric/vats": "0.16.1-upgrade-23-dev-bd79330.0.bd79330",
56
64
  "@endo/init": "^1.1.12",
57
- "ava": "^5.3.0",
65
+ "ava": "^6.4.1",
58
66
  "import-meta-resolve": "^4.1.0"
59
67
  },
60
68
  "files": [
@@ -73,7 +81,7 @@
73
81
  "access": "public"
74
82
  },
75
83
  "typeCoverage": {
76
- "atLeast": 83.26
84
+ "atLeast": 84.46
77
85
  },
78
- "gitHead": "0922d0447ab8fae9d2d87415964403330b5ca313"
86
+ "gitHead": "bd79330f78dae2faf9cc3d8b10063567700da07b"
79
87
  }
@@ -4,6 +4,7 @@ import { E } from '@endo/far';
4
4
 
5
5
  /**
6
6
  * @import {InvitationDetails, PaymentPKeywordRecord, Proposal, UserSeat} from '@agoric/zoe';
7
+ * @import {ERef} from '@agoric/vow';
7
8
  */
8
9
 
9
10
  /**
@@ -1,13 +1,20 @@
1
1
  import { Fail } from '@endo/errors';
2
+ import { writeFileAtomic } from '@agoric/internal/src/build-cache.js';
3
+
4
+ /**
5
+ * @import {promises} from 'fs';
6
+ * @import {resolve} from 'path';
7
+ * @import {BundleSourceResult} from '@endo/bundle-source';
8
+ */
2
9
 
3
10
  /**
4
11
  * @param {string} cacheDir
5
- * @param {{ now: typeof Date.now, fs: import('fs').promises, pathResolve: typeof import('path').resolve }} param1
12
+ * @param {{ now: typeof Date.now, fs: promises, pathResolve: typeof resolve, pid?: number }} param1
6
13
  */
7
14
  export const makeCacheAndGetBundleSpec =
8
- (cacheDir, { now, fs, pathResolve }) =>
15
+ (cacheDir, { now, fs, pathResolve, pid = process.pid }) =>
9
16
  /**
10
- * @param {Promise<import('@endo/bundle-source').BundleSourceResult<'endoZipBase64'>>} bundleP
17
+ * @param {Promise<BundleSourceResult<'endoZipBase64'>>} bundleP
11
18
  */
12
19
  async bundleP => {
13
20
  const bundle = await bundleP;
@@ -24,12 +31,13 @@ export const makeCacheAndGetBundleSpec =
24
31
  if (e.code !== 'ENOENT') {
25
32
  throw e;
26
33
  }
27
- // FIXME: We could take a hard dependency on `tmp` here, but is it worth it?
28
- const tmpFile = `${cacheFile}.${now()}`;
29
- await fs.writeFile(tmpFile, JSON.stringify(bundle, null, 2), {
30
- flag: 'wx',
34
+ await writeFileAtomic({
35
+ fs,
36
+ filePath: cacheFile,
37
+ data: JSON.stringify(bundle, null, 2),
38
+ now,
39
+ pid,
31
40
  });
32
- await fs.rename(tmpFile, cacheFile);
33
41
  }
34
42
  return harden({ bundleID, fileName: cacheFile });
35
43
  };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @file Get a promise for a deposit facet without
3
+ * access to all of namesByAddressAdmin.
4
+ */
5
+
6
+ import { E } from '@endo/eventual-send';
7
+
8
+ const trace = (...args) => console.log('---- AttD', ...args);
9
+
10
+ /**
11
+ * @import {DepositFacet} from '@agoric/ertp';
12
+ * @import {BootstrapPowers, PromiseSpaceOf} from '@agoric/vats/src/core/types.js';
13
+ */
14
+ const depositFacetKey = 'depositFacet';
15
+
16
+ /**
17
+ * XXX move this into BootstrapPowers
18
+ * @typedef {PromiseSpaceOf<{
19
+ * getDepositFacet: (addr: string, debugName?: string) => Promise<DepositFacet>
20
+ * }>} AttenuatedDepositPowers
21
+ */
22
+
23
+ /**
24
+ * @param {BootstrapPowers & AttenuatedDepositPowers} powers
25
+ */
26
+ export const produceAttenuatedDeposit = powers => {
27
+ powers.produce.getDepositFacet.reset();
28
+ const { namesByAddress, namesByAddressAdmin } = powers.consume;
29
+
30
+ /**
31
+ *
32
+ * @param {string} addr
33
+ * @param {string} [debugName]
34
+ */
35
+ const getDepositFacet = async (addr, debugName = 'party') => {
36
+ trace('reserve nameHub for', debugName, addr);
37
+ await E(namesByAddressAdmin).reserve(addr);
38
+ trace('lookup depositFacet for', debugName, addr);
39
+ const df = await E(namesByAddress).lookup(addr, depositFacetKey);
40
+ trace('got depositFacet for', debugName, addr);
41
+ return df;
42
+ };
43
+ harden(getDepositFacet);
44
+
45
+ powers.produce.getDepositFacet.resolve(getDepositFacet);
46
+ };
47
+
48
+ export const getManifestForAttenuatedDeposit = () => ({
49
+ manifest: {
50
+ [produceAttenuatedDeposit.name]: {
51
+ consume: { namesByAddress: true, namesByAddressAdmin: true },
52
+ produce: { getDepositFacet: true },
53
+ },
54
+ },
55
+ });
@@ -0,0 +1,187 @@
1
+ import { makeTracer } from '@agoric/internal';
2
+ import { registerChain } from '@agoric/orchestration/src/chain-info.js';
3
+ import { Fail } from '@endo/errors';
4
+ import { E, Far } from '@endo/far';
5
+ import { makeMarshal } from '@endo/marshal';
6
+
7
+ // TODO: refactor overlap with init-chain-info.js in orch pkg
8
+
9
+ /**
10
+ * @import {Remote, ERemote} from '@agoric/internal';
11
+ * @import {ChainInfo} from '@agoric/orchestration';
12
+ * @import {NameHub, NameAdmin} from '@agoric/vats';
13
+ * @typedef {Record<string, { chainInfo: ChainInfo }>} AxelarChainConfigMap
14
+ * @import {ERef} from '@endo/eventual-send';
15
+ * @import {StorageNode} from '@agoric/internal/src/lib-chainStorage.js';
16
+ * @import {PromiseSpaceOf} from '@agoric/vats/src/core/types.js';
17
+ * @import {BootstrapPowers} from '@agoric/vats/src/core/types.js';
18
+ */
19
+
20
+ const trace = makeTracer('ChainInfoCore', true);
21
+
22
+ // chainInfo has no cap data but we need to marshal bigints
23
+ const marshalData = makeMarshal(_val => Fail`data only`);
24
+
25
+ // See also: exos/chain-hub. Consistency is enforced by test.
26
+ export const HubName = {
27
+ Chain: 'chain',
28
+ ChainConnection: 'chainConnection',
29
+ ChainAssets: 'chainAssets',
30
+ };
31
+
32
+ /**
33
+ * Similar to publishAgoricNamesToChainStorage but publishes a node per chain
34
+ * instead of one list of entries
35
+ */
36
+
37
+ /**
38
+ * For each HubName, provide a NameHubKit reflected into vstorage unless there's
39
+ * already an agorcNames key by that name.
40
+ *
41
+ * @param {ERef<NameAdmin>} agoricNamesAdmin
42
+ * @param {ERemote<StorageNode>} agoricNamesNode
43
+ * @param {ERef<NameHub>} agoricNames
44
+ */
45
+ const publishChainInfoToChainStorage = async (
46
+ agoricNamesAdmin,
47
+ agoricNamesNode,
48
+ agoricNames,
49
+ ) => {
50
+ /**
51
+ * @param {string} subpath
52
+ */
53
+ const echoNameUpdates = async subpath => {
54
+ trace('reflecting', subpath, 'from agoricNames to vstorage');
55
+ const chainNamesNode = E(agoricNamesNode).makeChildNode(subpath);
56
+ const { nameAdmin } = await E(agoricNamesAdmin).provideChild(subpath);
57
+
58
+ /**
59
+ * Previous entries, to prevent redundant updates
60
+ *
61
+ * @type {Record<string, string>} chainName => stringified chainInfo
62
+ */
63
+ const prev = {};
64
+
65
+ // XXX cannot be changed until we upgrade vat-agoricNames to allow it
66
+ await E(nameAdmin).onUpdate(
67
+ // XXX will live on the heap in the bootstrap vat. When we upgrade or kill
68
+ // that this handler will sever and vat-agoricNames will need to be upgraded
69
+ // to allow changing the handler, or to use pubsub mechanics instead.
70
+ Far('chain info writer', {
71
+ write(entries) {
72
+ for (const [chainName, info] of entries) {
73
+ const value = JSON.stringify(marshalData.toCapData(info));
74
+ if (prev[chainName] === value) {
75
+ continue;
76
+ }
77
+ const chainNode = E(chainNamesNode).makeChildNode(chainName);
78
+ prev[chainName] = value;
79
+ void E(chainNode)
80
+ .setValue(value)
81
+ .catch(() => delete prev[chainName]);
82
+ }
83
+ },
84
+ }),
85
+ );
86
+ };
87
+ const existingKeys = await E(agoricNames).keys();
88
+ await Promise.all(
89
+ Object.values(HubName)
90
+ .filter(k => !existingKeys.includes(k))
91
+ .map(echoNameUpdates),
92
+ );
93
+ };
94
+
95
+ /**
96
+ * null chainStorage case is vestigial
97
+ *
98
+ * @typedef {{ consume: { chainStorage: Promise<Remote<StorageNode>> } }} ChainStoragePresent
99
+ */
100
+
101
+ /**
102
+ * XXX move this into BootstrapPowers
103
+ * @typedef {PromiseSpaceOf<{
104
+ * chainInfoPublished: unknown
105
+ * }>} ChainInfoPowers
106
+ */
107
+
108
+ /**
109
+ * WARNING: prunes any data that was previously published
110
+ *
111
+ * @param {BootstrapPowers & ChainStoragePresent & ChainInfoPowers} powers
112
+ * @param {{
113
+ * options: {
114
+ * chainInfo?: Record<string, ChainInfo>;
115
+ * axelarConfig: AxelarChainConfigMap;
116
+ * };
117
+ * }} config
118
+ */
119
+ export const publishChainInfo = async (
120
+ {
121
+ consume: { agoricNames, agoricNamesAdmin, chainStorage },
122
+ produce: { chainInfoPublished },
123
+ },
124
+ config,
125
+ ) => {
126
+ const { keys } = Object;
127
+ const { chainInfo = {} } = config.options;
128
+ trace('publishChainInfo', keys(chainInfo));
129
+
130
+ const agoricNamesNode = E(chainStorage).makeChildNode('agoricNames');
131
+
132
+ // Ensure updates go to vstorage
133
+ await publishChainInfoToChainStorage(
134
+ agoricNamesAdmin,
135
+ agoricNamesNode,
136
+ agoricNames,
137
+ );
138
+
139
+ for (const kind of Object.values(HubName)) {
140
+ const hub = E(agoricNames).lookup(kind);
141
+ /** @type {string[]} */
142
+ const oldKeys = await E(hub).keys();
143
+ trace('clearing old', kind, oldKeys);
144
+ if (!oldKeys.length) continue;
145
+
146
+ const admin = E(agoricNamesAdmin).lookupAdmin(kind);
147
+ await Promise.all(oldKeys.map(k => E(admin).delete(k)));
148
+ const node = E(agoricNamesNode).makeChildNode(kind);
149
+ // XXX setValue('') deletes a vstorage key (right?)
150
+ await Promise.all(
151
+ oldKeys.map(k =>
152
+ E(E(node).makeChildNode(k, { sequence: false })).setValue(''),
153
+ ),
154
+ );
155
+ }
156
+
157
+ const handledConnections = new Set();
158
+ for await (const [name, info] of Object.entries(chainInfo)) {
159
+ await registerChain(
160
+ agoricNamesAdmin,
161
+ name,
162
+ info,
163
+ trace,
164
+ handledConnections,
165
+ );
166
+ trace('@@@registered', name, info);
167
+ }
168
+ trace('@@@conn', ...handledConnections);
169
+
170
+ chainInfoPublished.resolve(true);
171
+ trace('publishChainInfo done');
172
+ };
173
+ harden(publishChainInfo);
174
+
175
+ export const getManifestForChainInfo = (_u, { options }) => ({
176
+ manifest: {
177
+ [publishChainInfo.name]: {
178
+ consume: {
179
+ agoricNames: true,
180
+ agoricNamesAdmin: true,
181
+ chainStorage: true,
182
+ },
183
+ produce: { chainInfoPublished: true },
184
+ },
185
+ },
186
+ options,
187
+ });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @import { CoreEvalBuilder, DeployScriptFunction } from '@agoric/deploy-script-support/src/externalTypes.js';
3
+ */
4
+
5
+ import { makeHelpers } from '../helpers.js';
6
+ import { getManifestForDeliverContractControl } from './contract-control.core.js';
7
+
8
+ const sourceSpec = './contract-control.core.js';
9
+
10
+ /**
11
+ * @satisfies {CoreEvalBuilder}
12
+ */
13
+ const defaultProposalBuilder = async () => {
14
+ return harden({
15
+ sourceSpec,
16
+ getManifestCall: [getManifestForDeliverContractControl.name],
17
+ });
18
+ };
19
+
20
+ /** @type {DeployScriptFunction} */
21
+ const build = async (homeP, endowments) => {
22
+ const { writeCoreEval } = await makeHelpers(homeP, endowments);
23
+
24
+ await writeCoreEval('eval-contract-control', () => defaultProposalBuilder());
25
+ };
26
+ harden(build);
27
+ export default build;