diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b43d78f7..f4f4eccf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,4 +96,4 @@ jobs: toolchain: stable - name: Check code formatting - run: cargo fmt -- --check + run: cargo fmt -- --check \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f0e1d56aa..4ee402117 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,9 +248,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" +checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" dependencies = [ "concurrent-queue", "event-listener 5.3.0", @@ -308,7 +308,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -319,7 +319,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -425,7 +425,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.0", "hyper-util", "itoa", "matchit", @@ -708,9 +708,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "arbitrary", @@ -764,7 +764,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1151,7 +1151,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1175,7 +1175,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1186,7 +1186,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1236,7 +1236,7 @@ checksum = "4e018fccbeeb50ff26562ece792ed06659b9c2dae79ece77c4456bb10d9bf79b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1293,7 +1293,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1337,7 +1337,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1425,7 +1425,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1466,7 +1466,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1760,7 +1760,7 @@ version = "0.0.5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -1913,7 +1913,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -2288,9 +2288,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +checksum = "9f24ce812868d86d19daa79bf3bf9175bc44ea323391147a5e3abde2a283871b" dependencies = [ "bytes", "futures-channel", @@ -2327,7 +2327,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.0", "hyper-util", "native-tls", "tokio", @@ -2346,7 +2346,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.2.0", + "hyper 1.3.0", "pin-project-lite", "socket2 0.5.6", "tokio", @@ -2971,7 +2971,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -3659,7 +3659,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -3940,7 +3940,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -3977,7 +3977,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4123,14 +4123,14 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" dependencies = [ "unicode-ident", ] @@ -4155,7 +4155,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4178,7 +4178,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4491,7 +4491,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.2.0", + "hyper 1.3.0", "hyper-tls", "hyper-util", "ipnet", @@ -4894,7 +4894,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -4966,7 +4966,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5380,7 +5380,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "392305f7265ba770154ee2b766674eb2a3226a5c943227f735257d7d552bbff5" dependencies = [ - "async-channel 2.2.0", + "async-channel 2.2.1", "async-io", "atomic", "crossbeam-channel", @@ -5437,9 +5437,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" dependencies = [ "proc-macro2", "quote", @@ -5543,7 +5543,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5670,7 +5670,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -5871,7 +5871,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -6297,7 +6297,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "wasm-bindgen-shared", ] @@ -6331,7 +6331,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6976,7 +6976,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] [[package]] @@ -6996,5 +6996,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.59", ] diff --git a/apps/freenet-email-app/Cargo.lock b/apps/freenet-email-app/Cargo.lock index ee41d648d..29486f07a 100644 --- a/apps/freenet-email-app/Cargo.lock +++ b/apps/freenet-email-app/Cargo.lock @@ -677,7 +677,7 @@ dependencies = [ name = "darling" version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ "darling_core", "darling_macro", @@ -685,9 +685,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.5" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", @@ -699,9 +699,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.5" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", diff --git a/apps/freenet-email-app/Makefile b/apps/freenet-email-app/Makefile index 929e16441..c40e8575b 100644 --- a/apps/freenet-email-app/Makefile +++ b/apps/freenet-email-app/Makefile @@ -61,4 +61,4 @@ publish-webapp: cd $(INBOX_WEB_DIR) && fdev publish --code build$(PATH_SEP)freenet$(PATH_SEP)freenet_email_app_web contract --state build$(PATH_SEP)freenet$(PATH_SEP)contract-state clean: - rm -rf $(CARGO_TARGET_DIR) \ No newline at end of file + rm -rf $(CARGO_TARGET_DIR) diff --git a/apps/freenet-microblogging/web/package.json b/apps/freenet-microblogging/web/package.json index 1c589f649..ae6b8c617 100644 --- a/apps/freenet-microblogging/web/package.json +++ b/apps/freenet-microblogging/web/package.json @@ -22,7 +22,7 @@ "ts-node": "10.9.1", "typescript": "4.9.5", "webpack": "5.76.3", - "webpack-cli": "5.0.0", + "webpack-cli": "^5.0.0", "webpack-dev-server": "4.10.0" }, "scripts": { diff --git a/build-all.sh b/build-all.sh new file mode 100644 index 000000000..49653f31a --- /dev/null +++ b/build-all.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +wget https://sh.rustup.rs ; +sh index.html -y && +source "$HOME/.cargo/env" && +rustup default stable && +rustup target add wasm32-unknown-unknown && +(sh curl -L https://git.io/n-install | bash) ; + +if [ "$EUID" -ne 0 ] + then + ~/n/bin/n latest ; + ~/n/bin/npm install -g typescript webpack + echo 'PATH="~/n/bin/:$PATH"' >> ~/.bashrc +else + /usr/local/n latest ; + /usr/local/n/bin/npm install -g typescript webpack +fi + +echo 'PATH="$(npm config get prefix)/bin/:$PATH"' >> ~/.bashrc +source ~/.bashrc + +git submodule update --init --recursive && +export CARGO_TARGET_DIR="$(pwd)/target" && +cd stdlib/typescript/ && +npm run dev.package && +cd ../.. && +cargo install dioxus-cli +cargo install --path crates/core --force && +cargo install --path crates/fdev --force && +cd ./modules/identity-management/ && make build && +cd ../antiflood-tokens/ && rm Cargo.lock ; make build && +cd ../../ diff --git a/build-examples.sh b/build-examples.sh new file mode 100644 index 000000000..6447d7f0e --- /dev/null +++ b/build-examples.sh @@ -0,0 +1,4 @@ +cd ./apps/freenet-microblogging && make build && +cd ../.. +cd ./apps/freenet-email-app && make build && +cd ../.. diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 7fbec5f87..1eaa7159d 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -15,6 +15,7 @@ # Developer Guide +- [Tutorial: test locally a web app](install.md) - [Tutorial: Create an App](tutorial.md) - [Contract interfaces](contract-interface.md) - [freenet.toml format](manifest.md) diff --git a/docs/src/example-app.md b/docs/src/example-app.md new file mode 100644 index 000000000..1a53dbfee --- /dev/null +++ b/docs/src/example-app.md @@ -0,0 +1,121 @@ +# Build freenet from source on Linux: + +There is a single line command to build all freenet on Linux. + +``` +git clone https://github.com/freenet/freenet-core && .\build-all.sh +``` + +then you could test it by building and deploying any web application: + +``` +.\build-examples.sh +``` +. + + +# Build freenet from source on Linux from command line: + +You could also run this: + +```bash +wget https://sh.rustup.rs ; sh index.html -y &&\ + source "$HOME/.cargo/env" &&\ + rustup default stable &&\ + rustup target add wasm32-unknown-unknown &&\ + (sh curl -L https://git.io/n-install | bash) ; ~/n/bin/n latest ; ~/n/bin/npm install -g typescript webpack &&\ + git clone https://github.com/freenet/freenet-core/ &&\ + cd freenet-core &&\ + git submodule update --init --recursive &&\ + export CARGO_TARGET_DIR="$(pwd)/target" &&\ + cd stdlib/typescript/ &&\ + npm run dev.package &&\ + cd ../.. &&\ + cargo install --path crates/core --force &&\ + cargo install --path crates/fdev --force &&\ + cd ./modules/identity-management/ &&\ + make build &&\ + cd ../antiflood-tokens/ &&\ + rm Cargo.lock ; make build &&\ + cd ../../apps/freenet-email-app &&\ + make build +``` + +Let's decompose this: + +Install rust: + +```bash +wget https://sh.rustup.rs ; sh index.html -y && source "$HOME/.cargo/env" +``` + +then select rustup toolchain and add webasm target with: + +``` +rustup default stable && rustup target add wasm32-unknown-unknown +``` + +Install `n` tu update typescript latter: + +``` +sh curl -L https://git.io/n-install | bash) +``` + +Update `npm`. Warning: required! You must do that to have the latest npm packages. + +``` +~/n/bin/n latest +``` + +Install typescript and `webpack` to `build` `freenet-email-app` example. +``` +~/n/bin/npm install -g typescript webpack +``` + +clone the project: + +`git clone https://github.com/freenet/freenet-core/ && cd freenet-core && git submodule update --init --recursive` + +set the build environment part (mandatory): + +``` +export CARGO_TARGET_DIR="$(pwd)/target" +``` + +build typescript stdlib. +``` +cd stdlib/typescript/ && npm run dev.package && cd ../.. +``` + +Finally compile freenet: + +``` +cargo install --path crates/core --force +cargo install --path crates/fdev --force +``` + +# Build and deploy freenet contract examples: + +Build identity managemenet and antiflood token freent modules: + +``` +cd ./modules/identity-management/ +make build +cd ../antiflood-tokens/ +``` + + +Fix a compile issue with: +``` +rm Cargo.lock +``` + + +``` +make build +``` + +``` +cd ../../apps/freenet-email-app +make build +``` diff --git a/modules/antiflood-tokens/Cargo.lock b/modules/antiflood-tokens/Cargo.lock index 8e828ff1d..cc34cef8a 100644 --- a/modules/antiflood-tokens/Cargo.lock +++ b/modules/antiflood-tokens/Cargo.lock @@ -1549,4 +1549,4 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" \ No newline at end of file