Skip to content

Commit

Permalink
build: migrate individual DFX workspaces into single root workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanosdev committed Sep 24, 2024
1 parent e059531 commit dc03f04
Show file tree
Hide file tree
Showing 70 changed files with 1,289 additions and 3,002 deletions.
24 changes: 0 additions & 24 deletions .github/actions/setup-dfx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,8 @@ description: Setup DFX
runs:
using: 'composite'
steps:
- name: Cache DFX
uses: actions/cache@v3
with:
path: /usr/local/bin/dfx
key: dfx-cache-${{ env.dfx_version }}

- name: Install dfx
uses: dfinity/setup-dfx@main
with:
dfx-version: '0.18.0'

- name: Configure DFX
shell: bash
run: |
mkdir -p $HOME/.config/dfx
cat <<EOF >$HOME/.config/dfx/networks.json
{
"local": {
"bind": "127.0.0.1:8080",
"type": "ephemeral",
"replica": {
"subnet_type": "system"
}
}
}
EOF

- name: Run DFX
shell: bash
Expand Down
31 changes: 5 additions & 26 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,11 @@ jobs:
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: DFX prepare Certified Counter
working-directory: examples/certification/certified-counter
run: |
dfx canister create --all
dfx generate backend
- name: DFX prepare HTTP Certification JSON API
working-directory: examples/http-certification/json-api
run: |
dfx canister create backend
dfx generate backend
dfx build backend --check
- name: DFX prepare HTTP Certification Custom Assets
working-directory: examples/http-certification/custom-assets
run: |
dfx canister create backend
dfx generate backend
dfx build backend --check
- name: DFX prepare HTTP Certification Skip Certification
working-directory: examples/http-certification/skip-certification
run: |
dfx canister create backend
dfx generate backend
dfx build backend --check
- name: Build canisters
run: dfx build --check

- name: Generate canister declarations
run: dfx generate

- name: Build NPM packages
run: pnpm build
Expand Down
32 changes: 24 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
.idea
.cargo
.env
target
dist
node_modules
# Various IDEs and Editors
.vscode/
.idea/
**/*~

# Mac OSX temporary files
.DS_Store
/tmp
pkg
**/.DS_Store

# DFX
.dfx/
.env

# Rust
.cargo/
target/

# NPM
node_modules/

# Other build files
declarations/
dist/
tmp/
pkg/
15 changes: 1 addition & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
resolver = "2"

members = [
"examples/response-verification/rust",
"examples/certification/certified-counter/src/backend",
"examples/http-certification/json-api/src/backend",
"examples/http-certification/assets/src/backend",
"examples/http-certification/custom-assets/src/backend",
"examples/http-certification/json-api/src/backend",
"examples/http-certification/skip-certification/src/backend",
"packages/ic-asset-certification",
"packages/ic-cbor",
Expand All @@ -26,7 +25,6 @@ members = [
# https://github.com/rust-lang/cargo/issues/9406
# includes all members except those that must be compiled to WASM
default-members = [
"examples/response-verification/rust",
"packages/ic-asset-certification",
"packages/ic-cbor",
"packages/ic-certification",
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ The `ic-response-verification` and `@dfinity/response-verification` packages enc

- [`ic-response-verificaiton` source code](./packages/ic-response-verification/README.md)
- [`@dfinity/response-verification` source code](./packages/ic-response-verification-wasm/README.md)
- [Example project that verifies responses in NodeJS](./examples/response-verification/nodejs/README.md)
- [Example project that verifies responses in Rust](./examples/response-verification/rust/README.md)
- [Example project that verifies responses in the browser](./examples/response-verification/web/README.md)
- [Usage example in the `ic-http-gateway` library](https://github.com/dfinity/http-gateway/tree/main/packages/ic-http-gateway)

## Miscellaneous Projects

Expand Down
93 changes: 93 additions & 0 deletions dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"dfx": "0.23.0",
"output_env_file": ".env",
"version": 1,
"networks": {
"local": {
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
},
"canisters": {
"certification_certified_counter_backend": {
"type": "rust",
"candid": "examples/certification/certified-counter/src/backend/backend.did",
"package": "certification_certified_counter_backend",
"declarations": {
"bindings": ["js", "ts"],
"output": "examples/certification/certified-counter/src/declarations"
},
"gzip": true,
"shrink": true,
"optimize": "cycles"
},
"certification_certified_counter_frontend": {
"type": "assets",
"dependencies": ["certification_certified_counter_backend"],
"source": ["examples/certification/certified-counter/src/frontend/dist"],
"build": "pnpm -F certification-certified-counter-frontend build",
"declarations": {
"bindings": []
},
"gzip": true,
"shrink": true,
"optimize": "cycles"
},
"http_certification_assets_backend": {
"type": "custom",
"candid": "examples/http-certification/assets/src/backend/backend.did",
"wasm": "target/wasm32-unknown-unknown/release/http_certification_assets_backend.wasm",
"build": [
"pnpm -F http-certification-assets-frontend build",
"cargo build --target wasm32-unknown-unknown --release -p http_certification_assets_backend --locked"
],
"declarations": {
"bindings": ["ts", "js"],
"output": "examples/http-certification/assets/src/declarations"
},
"gzip": true,
"shrink": true,
"optimize": "cycles"
},
"http_certification_custom_assets_backend": {
"type": "custom",
"candid": "examples/http-certification/custom-assets/src/backend/backend.did",
"wasm": "target/wasm32-unknown-unknown/release/http_certification_custom_assets_backend.wasm",
"build": [
"pnpm -F http-certification-custom-assets-frontend build",
"cargo build --target wasm32-unknown-unknown --release -p http_certification_custom_assets_backend --locked"
],
"declarations": {
"bindings": ["ts", "js"],
"output": "examples/http-certification/custom-assets/src/declarations"
},
"gzip": true,
"shrink": true,
"optimize": "cycles"
},
"http_certification_json_api_backend": {
"type": "rust",
"package": "http_certification_json_api_backend",
"candid": "examples/http-certification/json-api/src/backend/backend.did",
"declarations": {
"bindings": ["ts", "js"],
"output": "examples/http-certification/json-api/src/declarations"
},
"gzip": true,
"shrink": true,
"optimize": "cycles"
},
"http_certification_skip_certification_backend": {
"type": "rust",
"package": "http_certification_skip_certification_backend",
"candid": "examples/http-certification/skip-certification/src/backend/backend.did",
"declarations": {
"bindings": ["ts", "js"],
"output": "examples/http-certification/skip-certification/src/declarations"
},
"gzip": true,
"shrink": true,
"optimize": "cycles"
}
}
}
21 changes: 0 additions & 21 deletions examples/certification/certified-counter/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions examples/certification/certified-counter/dfx.json

This file was deleted.

43 changes: 0 additions & 43 deletions examples/certification/certified-counter/package.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "certified_counter_backend"
name = "certification_certified_counter_backend"
version = "0.1.0"
edition = "2021"

Expand All @@ -10,8 +10,7 @@ crate-type = ["cdylib"]
anyhow.workspace = true
candid.workspace = true
ic-cdk.workspace = true
ic-cdk-macros.workspace = true
ic-certification.workspace = true
ic-certification = { workspace = true, features = ["serde"] }
serde.workspace = true
serde_cbor.workspace = true
sha2.workspace = true
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use ic_cdk::export::candid::CandidType;
use candid::CandidType;
use ic_cdk::*;
use ic_certification::{AsHashTree, RbTree};
use serde::Serialize;
use sha2::{Digest, Sha256};
use std::cell::*;

thread_local! {
static COUNTER: Cell<u32> = Cell::new(0);
static TREE: RefCell<RbTree<&'static str, Vec<u8>>> = RefCell::new(RbTree::new());
}

use sha2::{Digest, Sha256};

pub fn hash(data: &[u8]) -> [u8; 32] {
let mut hasher = Sha256::new();
hasher.update(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"match": "**/*",
"security_policy": "hardened",
"headers": {
"content-security-policy": "default-src 'self'; form-action 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests; block-all-mixed-content; script-src 'self' 'unsafe-eval'; connect-src 'self' http://localhost:8000",
"cross-origin-embedder-policy": "require-corp"
}
}
]
Loading

0 comments on commit dc03f04

Please sign in to comment.