Skip to content

Commit

Permalink
Merge pull request #112 from gnosisguild/sp/task-fix
Browse files Browse the repository at this point in the history
add file input for publishing data
  • Loading branch information
samepant authored Sep 24, 2024
2 parents 4ca16ba + 38069ca commit 4156ff3
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions packages/evm/tasks/enclave.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from "fs";
import { task, types } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

Expand Down Expand Up @@ -220,7 +221,8 @@ task("e3:activate", "Activate an E3 program")

task("e3:publishInput", "Publish input for an E3 program")
.addParam("e3Id", "Id of the E3 program")
.addParam("data", "data to publish")
.addOptionalParam("data", "data to publish")
.addOptionalParam("dataFile", "file containing data to publish")
.setAction(async function (taskArguments: TaskArguments, hre) {
const enclave = await hre.deployments.get("Enclave");

Expand All @@ -229,10 +231,14 @@ task("e3:publishInput", "Publish input for an E3 program")
enclave.address,
);

const tx = await enclaveContract.publishInput(
taskArguments.e3Id,
taskArguments.data,
);
let data = taskArguments.data;

if (taskArguments.dataFile) {
const file = fs.readFileSync(taskArguments.dataFile);
data = file.toString();
}

const tx = await enclaveContract.publishInput(taskArguments.e3Id, data);

console.log("Publishing input... ", tx.hash);
await tx.wait();
Expand All @@ -242,7 +248,8 @@ task("e3:publishInput", "Publish input for an E3 program")

task("e3:publishCiphertext", "Publish ciphertext output for an E3 program")
.addParam("e3Id", "Id of the E3 program")
.addParam("data", "data to publish")
.addOptionalParam("data", "data to publish")
.addOptionalParam("dataFile", "file containing data to publish")
.addParam("proof", "proof to publish")
.setAction(async function (taskArguments: TaskArguments, hre) {
const enclave = await hre.deployments.get("Enclave");
Expand All @@ -252,9 +259,16 @@ task("e3:publishCiphertext", "Publish ciphertext output for an E3 program")
enclave.address,
);

let data = taskArguments.data;

if (taskArguments.dataFile) {
const file = fs.readFileSync(taskArguments.dataFile);
data = file.toString();
}

const tx = await enclaveContract.publishCiphertextOutput(
taskArguments.e3Id,
taskArguments.data,
data,
taskArguments.proof,
);

Expand All @@ -266,7 +280,8 @@ task("e3:publishCiphertext", "Publish ciphertext output for an E3 program")

task("e3:publishPlaintext", "Publish plaintext output for an E3 program")
.addParam("e3Id", "Id of the E3 program")
.addParam("data", "data to publish")
.addOptionalParam("data", "data to publish")
.addOptionalParam("dataFile", "file containing data to publish")
.addParam("proof", "proof to publish")
.setAction(async function (taskArguments: TaskArguments, hre) {
const enclave = await hre.deployments.get("Enclave");
Expand All @@ -276,9 +291,16 @@ task("e3:publishPlaintext", "Publish plaintext output for an E3 program")
enclave.address,
);

let data = taskArguments.data;

if (taskArguments.dataFile) {
const file = fs.readFileSync(taskArguments.dataFile);
data = file.toString();
}

const tx = await enclaveContract.publishPlaintextOutput(
taskArguments.e3Id,
taskArguments.data,
data,
taskArguments.proof,
);

Expand Down

0 comments on commit 4156ff3

Please sign in to comment.