@devtion/actions 0.0.0-7140596 → 0.0.0-92056fa

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/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @module @p0tion/actions
3
- * @version 1.0.5
2
+ * @module @devtion/actions
3
+ * @version 1.0.6
4
4
  * @file A set of actions and helpers for CLI commands
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
@@ -17,7 +17,7 @@ import crypto from 'crypto';
17
17
  import blake from 'blakejs';
18
18
  import { utils } from 'ffjavascript';
19
19
  import winston from 'winston';
20
- import { S3Client, HeadObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
20
+ import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
21
21
  import { pipeline, Readable } from 'stream';
22
22
  import { promisify } from 'util';
23
23
  import { initializeApp } from 'firebase/app';
@@ -1091,42 +1091,34 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1091
1091
  circuitArtifacts.push({
1092
1092
  artifacts: artifacts
1093
1093
  });
1094
- const r1csPath = artifacts.r1csStoragePath;
1095
- const wasmPath = artifacts.wasmStoragePath;
1096
1094
  // where we storing the r1cs downloaded
1097
1095
  const localR1csPath = `./${circuitData.name}.r1cs`;
1096
+ // where we storing the wasm downloaded
1097
+ const localWasmPath = `./${circuitData.name}.wasm`;
1098
1098
  // check that the artifacts exist in S3
1099
1099
  // we don't need any privileges to download this
1100
1100
  // just the correct region
1101
- const s3 = new S3Client({ region: artifacts.region });
1102
- try {
1103
- await s3.send(new HeadObjectCommand({
1104
- Bucket: artifacts.bucket,
1105
- Key: r1csPath
1106
- }));
1107
- }
1108
- catch (error) {
1109
- throw new Error(`The r1cs file (${r1csPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1110
- }
1111
- try {
1112
- await s3.send(new HeadObjectCommand({
1113
- Bucket: artifacts.bucket,
1114
- Key: wasmPath
1115
- }));
1116
- }
1117
- catch (error) {
1118
- throw new Error(`The wasm file (${wasmPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1119
- }
1101
+ const s3 = new S3Client({
1102
+ region: artifacts.region,
1103
+ credentials: undefined
1104
+ });
1120
1105
  // download the r1cs to extract the metadata
1121
1106
  const command = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath });
1122
1107
  const response = await s3.send(command);
1123
1108
  const streamPipeline = promisify(pipeline);
1124
1109
  if (response.$metadata.httpStatusCode !== 200)
1125
- throw new Error("There was an error while trying to download the r1cs file. Please check that the file has the correct permissions (public) set.");
1110
+ throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1126
1111
  if (response.Body instanceof Readable)
1127
1112
  await streamPipeline(response.Body, fs.createWriteStream(localR1csPath));
1128
1113
  // extract the metadata from the r1cs
1129
1114
  const metadata = getR1CSInfo(localR1csPath);
1115
+ // download wasm too to ensure it's available
1116
+ const wasmCommand = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.wasmStoragePath });
1117
+ const wasmResponse = await s3.send(wasmCommand);
1118
+ if (wasmResponse.$metadata.httpStatusCode !== 200)
1119
+ throw new Error(`There was an error while trying to download the wasm file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1120
+ if (wasmResponse.Body instanceof Readable)
1121
+ await streamPipeline(wasmResponse.Body, fs.createWriteStream(localWasmPath));
1130
1122
  // validate that the circuit hash and template links are valid
1131
1123
  const template = circuitData.template;
1132
1124
  const URLMatch = template.source.match(urlPattern);
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @module @p0tion/actions
3
- * @version 1.0.5
2
+ * @module @devtion/actions
3
+ * @version 1.0.6
4
4
  * @file A set of actions and helpers for CLI commands
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
@@ -1093,42 +1093,34 @@ const parseCeremonyFile = async (path, cleanup = false) => {
1093
1093
  circuitArtifacts.push({
1094
1094
  artifacts: artifacts
1095
1095
  });
1096
- const r1csPath = artifacts.r1csStoragePath;
1097
- const wasmPath = artifacts.wasmStoragePath;
1098
1096
  // where we storing the r1cs downloaded
1099
1097
  const localR1csPath = `./${circuitData.name}.r1cs`;
1098
+ // where we storing the wasm downloaded
1099
+ const localWasmPath = `./${circuitData.name}.wasm`;
1100
1100
  // check that the artifacts exist in S3
1101
1101
  // we don't need any privileges to download this
1102
1102
  // just the correct region
1103
- const s3 = new clientS3.S3Client({ region: artifacts.region });
1104
- try {
1105
- await s3.send(new clientS3.HeadObjectCommand({
1106
- Bucket: artifacts.bucket,
1107
- Key: r1csPath
1108
- }));
1109
- }
1110
- catch (error) {
1111
- throw new Error(`The r1cs file (${r1csPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1112
- }
1113
- try {
1114
- await s3.send(new clientS3.HeadObjectCommand({
1115
- Bucket: artifacts.bucket,
1116
- Key: wasmPath
1117
- }));
1118
- }
1119
- catch (error) {
1120
- throw new Error(`The wasm file (${wasmPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`);
1121
- }
1103
+ const s3 = new clientS3.S3Client({
1104
+ region: artifacts.region,
1105
+ credentials: undefined
1106
+ });
1122
1107
  // download the r1cs to extract the metadata
1123
1108
  const command = new clientS3.GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath });
1124
1109
  const response = await s3.send(command);
1125
1110
  const streamPipeline = util.promisify(stream.pipeline);
1126
1111
  if (response.$metadata.httpStatusCode !== 200)
1127
- throw new Error("There was an error while trying to download the r1cs file. Please check that the file has the correct permissions (public) set.");
1112
+ throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1128
1113
  if (response.Body instanceof stream.Readable)
1129
1114
  await streamPipeline(response.Body, fs.createWriteStream(localR1csPath));
1130
1115
  // extract the metadata from the r1cs
1131
1116
  const metadata = getR1CSInfo(localR1csPath);
1117
+ // download wasm too to ensure it's available
1118
+ const wasmCommand = new clientS3.GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.wasmStoragePath });
1119
+ const wasmResponse = await s3.send(wasmCommand);
1120
+ if (wasmResponse.$metadata.httpStatusCode !== 200)
1121
+ throw new Error(`There was an error while trying to download the wasm file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`);
1122
+ if (wasmResponse.Body instanceof stream.Readable)
1123
+ await streamPipeline(wasmResponse.Body, fs.createWriteStream(localWasmPath));
1132
1124
  // validate that the circuit hash and template links are valid
1133
1125
  const template = circuitData.template;
1134
1126
  const URLMatch = template.source.match(urlPattern);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/helpers/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAW,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAErC,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,EACH,eAAe,EACf,YAAY,EAGZ,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EAGpB,MAAM,gBAAgB,CAAA;AAmBvB;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,SAAgB,MAAM,YAAW,OAAO,KAAW,QAAQ,iBAAiB,CAoOzG,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,iBAAkB,MAAM,UAAU,MAAM,KAAG,MAgBtF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,gBAAiB,MAAM,WAAW,MAAM,WAUxF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,MASlD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,wBAAyB,MAAM,KAAG,MACH,CAAA;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,MAEsC,CAAA;A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AAO,MAAM,qCAAqC,sBAC3B,SAAS,YAClB,MAAM,oBAAoB,CAAC,cACzB,MAAM,iBACH,MAAM,4BACK,MAAM,YAAY,CAAC,yBACtB,MAAM,gBACf,MAAM,gBACN,OAAO,KACtB,QAAQ,MAAM,CA2DhB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,aAAc,MAAM,UAAS,QAAQ,aAAa,CAAC,OAAO,CAAC,KAAY,MAQvG,CAAA;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,kBACX,MAAM,UACb,MAAM,UACN,MAAM,YACJ,YAAY,KACvB,MAYF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,sBAAuB,MAAM,KAAG,eA0IvD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAY,MAAM,KAAG,MAA0D,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtion/actions",
3
- "version": "0.0.0-7140596",
3
+ "version": "0.0.0-92056fa",
4
4
  "description": "A set of actions and helpers for CLI commands",
5
5
  "repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
6
6
  "homepage": "https://github.com/privacy-scaling-explorations/p0tion",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "5f4dde47fdee59378296f3581ce9c7ce01676083"
86
+ "gitHead": "9ecb8d55d49edf248244fdd83e06deb20036c340"
87
87
  }
@@ -87,34 +87,19 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
87
87
  circuitArtifacts.push({
88
88
  artifacts: artifacts
89
89
  })
90
- const r1csPath = artifacts.r1csStoragePath
91
- const wasmPath = artifacts.wasmStoragePath
92
90
 
93
91
  // where we storing the r1cs downloaded
94
92
  const localR1csPath = `./${circuitData.name}.r1cs`
93
+ // where we storing the wasm downloaded
94
+ const localWasmPath = `./${circuitData.name}.wasm`
95
95
 
96
96
  // check that the artifacts exist in S3
97
97
  // we don't need any privileges to download this
98
98
  // just the correct region
99
- const s3 = new S3Client({region: artifacts.region})
100
-
101
- try {
102
- await s3.send(new HeadObjectCommand({
103
- Bucket: artifacts.bucket,
104
- Key: r1csPath
105
- }))
106
- } catch (error: any) {
107
- throw new Error(`The r1cs file (${r1csPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`)
108
- }
109
-
110
- try {
111
- await s3.send(new HeadObjectCommand({
112
- Bucket: artifacts.bucket,
113
- Key: wasmPath
114
- }))
115
- } catch (error: any) {
116
- throw new Error(`The wasm file (${wasmPath}) seems to not exist. Please ensure this is correct and that the object is publicly available.`)
117
- }
99
+ const s3 = new S3Client({
100
+ region: artifacts.region,
101
+ credentials: undefined
102
+ })
118
103
 
119
104
  // download the r1cs to extract the metadata
120
105
  const command = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.r1csStoragePath })
@@ -122,7 +107,7 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
122
107
  const streamPipeline = promisify(pipeline)
123
108
 
124
109
  if (response.$metadata.httpStatusCode !== 200)
125
- throw new Error("There was an error while trying to download the r1cs file. Please check that the file has the correct permissions (public) set.")
110
+ throw new Error(`There was an error while trying to download the r1cs file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`)
126
111
 
127
112
  if (response.Body instanceof Readable)
128
113
  await streamPipeline(response.Body, fs.createWriteStream(localR1csPath))
@@ -130,6 +115,16 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
130
115
  // extract the metadata from the r1cs
131
116
  const metadata = getR1CSInfo(localR1csPath)
132
117
 
118
+ // download wasm too to ensure it's available
119
+ const wasmCommand = new GetObjectCommand({ Bucket: artifacts.bucket, Key: artifacts.wasmStoragePath })
120
+ const wasmResponse = await s3.send(wasmCommand)
121
+
122
+ if (wasmResponse.$metadata.httpStatusCode !== 200)
123
+ throw new Error(`There was an error while trying to download the wasm file for circuit ${circuitData.name}. Please check that the file has the correct permissions (public) set.`)
124
+
125
+ if (wasmResponse.Body instanceof Readable)
126
+ await streamPipeline(wasmResponse.Body, fs.createWriteStream(localWasmPath))
127
+
133
128
  // validate that the circuit hash and template links are valid
134
129
  const template = circuitData.template
135
130