@agoric/deploy-script-support 0.10.4-dev-fb6a3e0.0 → 0.10.4-dev-46061c3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/deploy-script-support",
3
- "version": "0.10.4-dev-fb6a3e0.0+fb6a3e0",
3
+ "version": "0.10.4-dev-46061c3.0+46061c3",
4
4
  "description": "Helpers and other support for writing deploy scripts",
5
5
  "type": "module",
6
6
  "main": "src/helpers.js",
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
36
36
  "dependencies": {
37
- "@agoric/ertp": "0.16.3-dev-fb6a3e0.0+fb6a3e0",
38
- "@agoric/import-manager": "0.3.12-dev-fb6a3e0.0+fb6a3e0",
39
- "@agoric/internal": "0.3.3-dev-fb6a3e0.0+fb6a3e0",
40
- "@agoric/notifier": "0.6.3-dev-fb6a3e0.0+fb6a3e0",
41
- "@agoric/store": "0.9.3-dev-fb6a3e0.0+fb6a3e0",
42
- "@agoric/time": "0.3.3-dev-fb6a3e0.0+fb6a3e0",
43
- "@agoric/zoe": "0.26.3-dev-fb6a3e0.0+fb6a3e0",
37
+ "@agoric/ertp": "0.16.3-dev-46061c3.0+46061c3",
38
+ "@agoric/import-manager": "0.3.12-dev-46061c3.0+46061c3",
39
+ "@agoric/internal": "0.3.3-dev-46061c3.0+46061c3",
40
+ "@agoric/notifier": "0.6.3-dev-46061c3.0+46061c3",
41
+ "@agoric/store": "0.9.3-dev-46061c3.0+46061c3",
42
+ "@agoric/time": "0.3.3-dev-46061c3.0+46061c3",
43
+ "@agoric/zoe": "0.26.3-dev-46061c3.0+46061c3",
44
44
  "@endo/base64": "^1.0.9",
45
45
  "@endo/bundle-source": "^3.5.1",
46
46
  "@endo/errors": "^1.2.9",
@@ -51,7 +51,7 @@
51
51
  "@endo/zip": "^1.0.9"
52
52
  },
53
53
  "devDependencies": {
54
- "@agoric/vats": "0.15.2-dev-fb6a3e0.0+fb6a3e0",
54
+ "@agoric/vats": "0.15.2-dev-46061c3.0+46061c3",
55
55
  "@endo/init": "^1.1.8",
56
56
  "ava": "^5.3.0",
57
57
  "import-meta-resolve": "^2.2.1"
@@ -74,5 +74,5 @@
74
74
  "typeCoverage": {
75
75
  "atLeast": 83.71
76
76
  },
77
- "gitHead": "fb6a3e0102deabc5e57eb0511e2208bc3b415d27"
77
+ "gitHead": "46061c3ad3267fb9642309a5c8287dc01ef9c5dc"
78
78
  }
package/src/helpers.js CHANGED
@@ -20,6 +20,7 @@ import { installInPieces } from './installInPieces.js';
20
20
  import { makeWriteCoreEval } from './writeCoreEvalParts.js';
21
21
 
22
22
  export * from '@agoric/internal/src/node/createBundles.js';
23
+ export { parseScriptArgs } from './parseCoreEvalArgs.js';
23
24
 
24
25
  // These are also hard-coded in lib-wallet.js.
25
26
  // TODO: Add methods to the wallet to access these without hard-coding
@@ -0,0 +1,36 @@
1
+ /**
2
+ * To customize proposals for multiple environments, we pass the "variant"
3
+ * identifier in scriptArgs. The variant must match a knownVariant.
4
+ *
5
+ * @param {import('./externalTypes.js').DeployScriptEndownments} endowments
6
+ * @param {string} name a name to use in error messages or Usage suggestions.
7
+ * @param {string[]} knownVariants
8
+ */
9
+ export const parseScriptArgs = async (endowments, name, knownVariants) => {
10
+ const { scriptArgs } = endowments;
11
+ // const variantOrConfig = scriptArgs?.[0];
12
+ const variantOrConfig =
13
+ scriptArgs && scriptArgs.length > 0 ? scriptArgs : undefined;
14
+
15
+ console.log(`${name}`, variantOrConfig);
16
+
17
+ const Usage = `agoric run ${name}.js ${[...knownVariants, '<json-config>'].join(' | ')}`;
18
+ const opts = {};
19
+
20
+ if (typeof variantOrConfig === 'string') {
21
+ if (variantOrConfig[0] === '{') {
22
+ try {
23
+ opts.config = JSON.parse(variantOrConfig);
24
+ } catch (err) {
25
+ throw Error(`Failed to parse config argument ${variantOrConfig}`);
26
+ }
27
+ } else {
28
+ opts.variant = variantOrConfig;
29
+ }
30
+ } else {
31
+ console.error(Usage);
32
+ throw Error(Usage);
33
+ }
34
+
35
+ return opts;
36
+ };