Skip to content

Commit

Permalink
fix: resolve translation between solidity and javascript issues
Browse files Browse the repository at this point in the history
  • Loading branch information
zcstarr committed Sep 28, 2023
1 parent eb3e212 commit 515581f
Show file tree
Hide file tree
Showing 34 changed files with 2,341 additions and 82 deletions.
21 changes: 15 additions & 6 deletions contracts/TinyHops.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ contract TinyHops {
}
}
workflowIdToOwner[workflowIdCounter] = msg.sender;

emit WorkflowAdded(workflowId, msg.sender);
return workflowId;
}

Expand Down Expand Up @@ -312,13 +312,24 @@ contract TinyHops {
uint256 workflowId,
uint256 workflowIndex
) internal {
console.log("next step");
Workflow storage workflow = workflowIdToWorkflow[workflowId];

uint256 numEntries = workflow.entries[workflowIndex].length;
for (uint256 i = 0; i < numEntries; i = i + 1) {
// This will also throw on underflow must have non zero balance at all times
updateBalance(workflowId, workflow.entries[workflowIndex][i].cost);
console.log("past cost");

console.log("apply variable");
console.log(
LibTinyHopsTemplateResolver.applyVariables(
workflow.entries[workflowIndex][i].params,
workflowIdToResultCid[workflowId]
)
);

console.log("past apply variable");
uint256 jobId = remoteContractInstance
.runModuleWithDefaultMediators{
value: workflow.entries[workflowIndex][i].cost
Expand Down Expand Up @@ -362,11 +373,7 @@ contract TinyHops {

function getWorkFlowResults(
uint256 workflowId
)
public
view
returns (uint256[] memory, string[] memory, string[] memory params)
{
) public view returns (uint256[] memory, string[] memory, string[] memory) {
Workflow storage workflow = workflowIdToWorkflow[workflowId];
uint256 numEntries = 0;
for (uint256 i = 0; i < workflow.entries.length; i++) {
Expand Down Expand Up @@ -448,6 +455,8 @@ contract TinyHops {

// This must be implemented in order to receive the job results back!
function receiveJobResults(uint256 _jobID, string calldata _cid) public {
console.log("jobId", _jobID);
console.log("cid", _cid);
uint256 workflowId = _updateStepStatus(
_jobID,
_cid,
Expand Down
15 changes: 10 additions & 5 deletions example.thops.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
{
"$schema": "./schema.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"version": "v0.0.1",
"steps": [
{
"stepDesc": "First cow say",
"stepName": "cows say",
"stepId": "1",
"stepModule": {
"cost": "5",
"cmd": "cowsay:v0.0.1",
"params": "{{stepName:2}} helloworld"
"params": "hello world"
}
},
[{
"stepDesc": "First cow say",
"stepName": "cows say",
"stepId": "2",
"stepModule": {
"cost": "5",
"cmd": "cowsay:v0.0.1",
"params": "{{stepName:2}} hello parallel world {stepId:1}"
"params": "parallel job 0 hello parallel world {{stepId:1}}"
}
},
{
"stepDesc": "First cow say",
"stepName": "cows say",
"stepId": "3",
"stepModule": {
"cost": "5",
"cmd": "cowsay:v0.0.1",
"params": "{{stepName:2}} hello parallel world {stepId:1}"
"params": "parallel job 1 hello parallel world {{stepId:1}}"
}
}],
{
"stepDesc": "last cow say",
"stepName": "lastcowsay",
"stepId": "4",
"stepModule": {
"cost": "5",
"cmd": "cowsay:v0.0.1",
"params": "{{stepName:4}} hello parallel world {stepId:2} {stepId:3}"
"params": "We got all the parallel {{stepId:2}}, {{stepId:3}} worlds "
}
}
]
Expand Down
16 changes: 16 additions & 0 deletions hardhat-scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint prefer-const: "off" */

import "@nomicfoundation/hardhat-ethers";

async function main() {
const [deployer] = await ethers.getSigners();
const tinyHops = ethers.getContractFactory("TinyHops");
const customModicum = ethers.getContractFactory("CustomModicum");
const contract = await ethers.deployContract("CustomModicum", { });
await contract.waitForDeployment();
console.log("the addr", contract.target);
const tinyHopsContract = await ethers.deployContract("TinyHops", [contract.target]);
await tinyHopsContract.waitForDeployment();
console.log("tiny hops addr", tinyHopsContract.target);
}
main()
6 changes: 6 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ const config: HardhatUserConfig = {
gas: "auto",
accounts: [PRIV_KEY],
chainId: 1337
},
lilypad2: {
url: "http://testnetv2.arewehotshityet.com:8545",
gas: "auto",
accounts: [PRIV_KEY],
chainId: 1337
}

}
Expand Down
Loading

0 comments on commit 515581f

Please sign in to comment.