Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Rename cartesi-dex to order-book and update with latest features
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarolyi committed May 10, 2022
1 parent 8b63cac commit 271e112
Show file tree
Hide file tree
Showing 37 changed files with 5,813 additions and 2,057 deletions.
4 changes: 4 additions & 0 deletions order-book/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config
contracts/node_modules
frontend-console
server
2 changes: 2 additions & 0 deletions order-book/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
machine
.vscode
14 changes: 10 additions & 4 deletions order-book/contracts/Dockerfile → order-book/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ FROM node:16-buster-slim

# install git
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
git \
build-essential git python3 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

# copy machine
WORKDIR /app/machine
COPY machine .

# build to bring node_modules
COPY ["package.json", "yarn.lock", "./"]
WORKDIR /app/contracts
COPY ["contracts/package.json", "contracts/yarn.lock", "./"]
RUN yarn install --non-interactive

# build app
COPY . .
COPY contracts .
RUN yarn install --non-interactive

# expose hardhat node port
EXPOSE 8545

WORKDIR /app/contracts
ENTRYPOINT ["npx", "hardhat"]
CMD ["node"]
CMD ["node"]
101 changes: 59 additions & 42 deletions order-book/README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions order-book/config/indexer-config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[polling_config]
[indexer_config]

# unique session identifier for machine manager
session_id = "default_rollups_id"
Expand All @@ -15,4 +15,4 @@ interval = 10
# end points
postgres_endpoint = "postgres://postgres:password@database/postgres"
state_server_endpoint = "http://state_server:50051"
mm_endpoint = "http://server_manager:5001"
mm_endpoint = "http://server_manager:5001"
2 changes: 1 addition & 1 deletion order-book/config/sf-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ genesis_block = "0x1"
query_limit_error_codes = [-32005]

# number of blocks (depth) before considering state finalized
safety_margin = 1
safety_margin = 0
Binary file removed order-book/contracts/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion order-book/contracts/.dockerignore

This file was deleted.

2 changes: 2 additions & 0 deletions order-book/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.yalc
cache
coverage
deployments/localhost
deployments/*/solcInputs/*.json
dist
export/abi/localhost.json
node_modules
yalc.lock
1 change: 1 addition & 0 deletions order-book/contracts/config/.dapprc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"inputDuration": 86400,
"challengePeriod": 604800,
"inputLog2Size": 25,
"feePerClaim": "1000000000000000000",
"validators": "0,1,2"
}
3 changes: 2 additions & 1 deletion order-book/contracts/config/polygon_mumbai/.dapprc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"inputDuration": 86400,
"challengePeriod": 604800,
"inputLog2Size": 25,
"validators": "0"
"feePerClaim": "100000000000000000000",
"validators": "0x18930e8a66a1DbE21D00581216789AAB7460Afd0"
}
26 changes: 24 additions & 2 deletions order-book/contracts/deploy/01_rollups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

import fs from "fs";
import path from "path";
import { DeployFunction } from "hardhat-deploy/types";
import { cosmiconfig } from "cosmiconfig";
import { CreateArgs } from "@cartesi/hardhat-rollups";

const explorer = cosmiconfig("dapp");

/**
* Returns the hash of a stored Cartesi Machine as hex string
* @param directory directory containing a stored Cartesi Machine
* @returns hash of the machine as hex string
*/
const hash = (directory: string): string => {
const filename = path.join(directory, "hash");
if (!fs.existsSync(filename)) {
throw new Error(`file ${filename} not found`);
}
return "0x" + fs.readFileSync(filename).toString("hex");
};

const func: DeployFunction = async ({ network, run }) => {
// search for DApp configuration, starting from 'config/{network}' and traversing up
const configResult = await explorer.search(`config/${network.name}`);
Expand All @@ -24,9 +40,15 @@ const func: DeployFunction = async ({ network, run }) => {
}

console.log(`dapp configuration loaded from ${configResult.filepath}`);
const config = configResult.config as CreateArgs;

// read machine hash
config.templateHash = hash("../machine");

// deploy Rollups smart contracts
await run("rollups:create", configResult.config);
console.log("deploying contracts with the following configuration:");
console.log(config);
await run("rollups:create", config);
};

export default func;
export default func;
1 change: 1 addition & 0 deletions order-book/contracts/deployments/polygon_mumbai/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
80001
109 changes: 109 additions & 0 deletions order-book/contracts/deployments/polygon_mumbai/CartesiDApp.json

Large diffs are not rendered by default.

Loading

0 comments on commit 271e112

Please sign in to comment.