diff --git a/intro/1-hello-world/.gitignore b/hello-world/1-browser-to-browser/.gitignore similarity index 100% rename from intro/1-hello-world/.gitignore rename to hello-world/1-browser-to-browser/.gitignore diff --git a/intro/1-hello-world/README.md b/hello-world/1-browser-to-browser/README.md similarity index 100% rename from intro/1-hello-world/README.md rename to hello-world/1-browser-to-browser/README.md diff --git a/intro/1-hello-world/aqua/getting-started.aqua b/hello-world/1-browser-to-browser/aqua/getting-started.aqua similarity index 100% rename from intro/1-hello-world/aqua/getting-started.aqua rename to hello-world/1-browser-to-browser/aqua/getting-started.aqua diff --git a/intro/1-hello-world/package-lock.json b/hello-world/1-browser-to-browser/package-lock.json similarity index 100% rename from intro/1-hello-world/package-lock.json rename to hello-world/1-browser-to-browser/package-lock.json diff --git a/intro/1-hello-world/package.json b/hello-world/1-browser-to-browser/package.json similarity index 100% rename from intro/1-hello-world/package.json rename to hello-world/1-browser-to-browser/package.json diff --git a/intro/1-hello-world/public/favicon.ico b/hello-world/1-browser-to-browser/public/favicon.ico similarity index 100% rename from intro/1-hello-world/public/favicon.ico rename to hello-world/1-browser-to-browser/public/favicon.ico diff --git a/intro/1-hello-world/public/index.html b/hello-world/1-browser-to-browser/public/index.html similarity index 100% rename from intro/1-hello-world/public/index.html rename to hello-world/1-browser-to-browser/public/index.html diff --git a/intro/1-hello-world/public/logo192.png b/hello-world/1-browser-to-browser/public/logo192.png similarity index 100% rename from intro/1-hello-world/public/logo192.png rename to hello-world/1-browser-to-browser/public/logo192.png diff --git a/intro/1-hello-world/public/logo512.png b/hello-world/1-browser-to-browser/public/logo512.png similarity index 100% rename from intro/1-hello-world/public/logo512.png rename to hello-world/1-browser-to-browser/public/logo512.png diff --git a/intro/1-hello-world/public/manifest.json b/hello-world/1-browser-to-browser/public/manifest.json similarity index 100% rename from intro/1-hello-world/public/manifest.json rename to hello-world/1-browser-to-browser/public/manifest.json diff --git a/intro/1-hello-world/public/robots.txt b/hello-world/1-browser-to-browser/public/robots.txt similarity index 100% rename from intro/1-hello-world/public/robots.txt rename to hello-world/1-browser-to-browser/public/robots.txt diff --git a/intro/1-hello-world/src/App.scss b/hello-world/1-browser-to-browser/src/App.scss similarity index 100% rename from intro/1-hello-world/src/App.scss rename to hello-world/1-browser-to-browser/src/App.scss diff --git a/intro/1-hello-world/src/App.tsx b/hello-world/1-browser-to-browser/src/App.tsx similarity index 100% rename from intro/1-hello-world/src/App.tsx rename to hello-world/1-browser-to-browser/src/App.tsx diff --git a/intro/1-hello-world/src/_aqua/getting-started.ts b/hello-world/1-browser-to-browser/src/_aqua/getting-started.ts similarity index 100% rename from intro/1-hello-world/src/_aqua/getting-started.ts rename to hello-world/1-browser-to-browser/src/_aqua/getting-started.ts diff --git a/intro/1-hello-world/src/index.css b/hello-world/1-browser-to-browser/src/index.css similarity index 100% rename from intro/1-hello-world/src/index.css rename to hello-world/1-browser-to-browser/src/index.css diff --git a/intro/1-hello-world/src/index.tsx b/hello-world/1-browser-to-browser/src/index.tsx similarity index 100% rename from intro/1-hello-world/src/index.tsx rename to hello-world/1-browser-to-browser/src/index.tsx diff --git a/intro/1-hello-world/src/logo.svg b/hello-world/1-browser-to-browser/src/logo.svg similarity index 100% rename from intro/1-hello-world/src/logo.svg rename to hello-world/1-browser-to-browser/src/logo.svg diff --git a/intro/1-hello-world/src/react-app-env.d.ts b/hello-world/1-browser-to-browser/src/react-app-env.d.ts similarity index 100% rename from intro/1-hello-world/src/react-app-env.d.ts rename to hello-world/1-browser-to-browser/src/react-app-env.d.ts diff --git a/intro/1-hello-world/tsconfig.json b/hello-world/1-browser-to-browser/tsconfig.json similarity index 100% rename from intro/1-hello-world/tsconfig.json rename to hello-world/1-browser-to-browser/tsconfig.json diff --git a/intro/2-marine/.gitignore b/hello-world/2-hosted-services/.gitignore similarity index 100% rename from intro/2-marine/.gitignore rename to hello-world/2-hosted-services/.gitignore diff --git a/intro/2-marine/Cargo.toml b/hello-world/2-hosted-services/Cargo.toml similarity index 100% rename from intro/2-marine/Cargo.toml rename to hello-world/2-hosted-services/Cargo.toml diff --git a/intro/2-marine/Config.toml b/hello-world/2-hosted-services/Config.toml similarity index 100% rename from intro/2-marine/Config.toml rename to hello-world/2-hosted-services/Config.toml diff --git a/intro/2-marine/app_config.json b/hello-world/2-hosted-services/app_config.json similarity index 100% rename from intro/2-marine/app_config.json rename to hello-world/2-hosted-services/app_config.json diff --git a/intro/2-marine/app_config_res.json b/hello-world/2-hosted-services/app_config_res.json similarity index 100% rename from intro/2-marine/app_config_res.json rename to hello-world/2-hosted-services/app_config_res.json diff --git a/intro/2-marine/build.sh b/hello-world/2-hosted-services/build.sh similarity index 100% rename from intro/2-marine/build.sh rename to hello-world/2-hosted-services/build.sh diff --git a/intro/2-marine/src/main.rs b/hello-world/2-hosted-services/src/main.rs similarity index 100% rename from intro/2-marine/src/main.rs rename to hello-world/2-hosted-services/src/main.rs diff --git a/intro/3-hello-world-web3/.gitignore b/hello-world/3-browser-to-service/.gitignore similarity index 100% rename from intro/3-hello-world-web3/.gitignore rename to hello-world/3-browser-to-service/.gitignore diff --git a/intro/3-hello-world-web3/aqua/getting-started.aqua b/hello-world/3-browser-to-service/aqua/getting-started.aqua similarity index 100% rename from intro/3-hello-world-web3/aqua/getting-started.aqua rename to hello-world/3-browser-to-service/aqua/getting-started.aqua diff --git a/intro/3-hello-world-web3/package-lock.json b/hello-world/3-browser-to-service/package-lock.json similarity index 100% rename from intro/3-hello-world-web3/package-lock.json rename to hello-world/3-browser-to-service/package-lock.json diff --git a/intro/3-hello-world-web3/package.json b/hello-world/3-browser-to-service/package.json similarity index 100% rename from intro/3-hello-world-web3/package.json rename to hello-world/3-browser-to-service/package.json diff --git a/intro/3-hello-world-web3/public/favicon.ico b/hello-world/3-browser-to-service/public/favicon.ico similarity index 100% rename from intro/3-hello-world-web3/public/favicon.ico rename to hello-world/3-browser-to-service/public/favicon.ico diff --git a/intro/3-hello-world-web3/public/index.html b/hello-world/3-browser-to-service/public/index.html similarity index 100% rename from intro/3-hello-world-web3/public/index.html rename to hello-world/3-browser-to-service/public/index.html diff --git a/intro/3-hello-world-web3/public/logo192.png b/hello-world/3-browser-to-service/public/logo192.png similarity index 100% rename from intro/3-hello-world-web3/public/logo192.png rename to hello-world/3-browser-to-service/public/logo192.png diff --git a/intro/3-hello-world-web3/public/logo512.png b/hello-world/3-browser-to-service/public/logo512.png similarity index 100% rename from intro/3-hello-world-web3/public/logo512.png rename to hello-world/3-browser-to-service/public/logo512.png diff --git a/intro/3-hello-world-web3/public/manifest.json b/hello-world/3-browser-to-service/public/manifest.json similarity index 100% rename from intro/3-hello-world-web3/public/manifest.json rename to hello-world/3-browser-to-service/public/manifest.json diff --git a/intro/3-hello-world-web3/public/robots.txt b/hello-world/3-browser-to-service/public/robots.txt similarity index 100% rename from intro/3-hello-world-web3/public/robots.txt rename to hello-world/3-browser-to-service/public/robots.txt diff --git a/intro/3-hello-world-web3/src/App.scss b/hello-world/3-browser-to-service/src/App.scss similarity index 100% rename from intro/3-hello-world-web3/src/App.scss rename to hello-world/3-browser-to-service/src/App.scss diff --git a/intro/3-hello-world-web3/src/App.tsx b/hello-world/3-browser-to-service/src/App.tsx similarity index 100% rename from intro/3-hello-world-web3/src/App.tsx rename to hello-world/3-browser-to-service/src/App.tsx diff --git a/intro/3-hello-world-web3/src/_aqua/getting-started.ts b/hello-world/3-browser-to-service/src/_aqua/getting-started.ts similarity index 100% rename from intro/3-hello-world-web3/src/_aqua/getting-started.ts rename to hello-world/3-browser-to-service/src/_aqua/getting-started.ts diff --git a/intro/3-hello-world-web3/src/index.css b/hello-world/3-browser-to-service/src/index.css similarity index 100% rename from intro/3-hello-world-web3/src/index.css rename to hello-world/3-browser-to-service/src/index.css diff --git a/intro/3-hello-world-web3/src/index.tsx b/hello-world/3-browser-to-service/src/index.tsx similarity index 100% rename from intro/3-hello-world-web3/src/index.tsx rename to hello-world/3-browser-to-service/src/index.tsx diff --git a/intro/3-hello-world-web3/src/logo.svg b/hello-world/3-browser-to-service/src/logo.svg similarity index 100% rename from intro/3-hello-world-web3/src/logo.svg rename to hello-world/3-browser-to-service/src/logo.svg diff --git a/intro/3-hello-world-web3/src/react-app-env.d.ts b/hello-world/3-browser-to-service/src/react-app-env.d.ts similarity index 100% rename from intro/3-hello-world-web3/src/react-app-env.d.ts rename to hello-world/3-browser-to-service/src/react-app-env.d.ts diff --git a/intro/3-hello-world-web3/tsconfig.json b/hello-world/3-browser-to-service/tsconfig.json similarity index 100% rename from intro/3-hello-world-web3/tsconfig.json rename to hello-world/3-browser-to-service/tsconfig.json diff --git a/intro/3-hello-world-web3/README.md b/intro/3-hello-world-web3/README.md deleted file mode 100644 index fdf3926..0000000 --- a/intro/3-hello-world-web3/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# Getting Started with Fluence - -This sample project demonstrates how fluence network can be accessed from the browser. As an example it retrieves the timestamp of the current time from the relay node. The project is based on an create-react-app template with slight modifications to integrate Fluence. The primary focus is the integration itself, i.e React could be swapped with a framework of your choice. - -## Getting started - -Run aqua compiler in watch mode: - -```bash -npm run watch-aqua -``` - -Start the application - -```bash -npm start -``` - -The browser window with `localhost:3000` should open - -## How it works - -The application can be split into two main building blocks: the runtime provided by the `@fluencelabs/fluence` package and the compiler for the `Aqua` language. The workflow is as follows: - -1. You write aqua code -2. Aqua gets compiled into the typescript file -3. The typescript is build by the webpack (or any other tool of you choice) into js bunlde. - -## Project structure - -``` -aqua (1) - ┗ getting-started.aqua (3) -node_modules -public -src - ┣ _aqua (2) - ┃ ┗ getting-started.ts (4) - ┣ App.scss - ┣ App.tsx - ┣ index.css - ┣ index.tsx - ┣ logo.svg - ┗ react-app-env.d.ts -package-lock.json -package.json -tsconfig.json -``` - -The project structure is based on the create-react-app template with some minor differences: - -- `aqua` (1) contains the Aqua source code files. The complier picks them up and generate corresponding typescript file. See `getting-started.aqua` (3) and `getting-started.ts` respectively -- `src/_aqua` (2) is where the generated target files are places. The target directory is conveniently placed inside the sources directory which makes it easy to import typescript functions from the application source code - -## npm packages and scripts - -The following npm packages are used: - -- `@fluencelabs/fluence` - is the client for Fluence Network running inside the browser. See https://github.com/fluencelabs/fluence-js for additional information -- `@fluencelabs/fluence-network-environment` - is the maintained list of Fluence networks and nodes to connect to. -- `@fluencelabs/aqua-cli` - is the command line interface for Aqua compiler. See https://github.com/fluencelabs/aqua for more information -- `@fluencelabs/aqua-lib` - Aqua language standard library -- `chokidar-cli` - A tool to watch for aqua file changes and compile them on the fly - -The compilation of aqua code is implemented with these scripts: - -``` -scripts: { -... - "compile-aqua": "aqua-cli -i ./aqua/ -o ./src/_aqua", - "watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\"" -} -... -``` - -The interface is pretty straightforward: you just specify the input and output directories for the compiler. - -## Aqua code - -``` -import "@fluencelabs/aqua-lib/builtin.aqua" - -service HelloWorld("HelloWorld"): (1) - recieveHello(from: PeerId) -> string - -func sayHello(peerId: PeerId, relayPeerId: PeerId) -> string: (2) - on peerId via relayPeerId: - res <- HelloWorld.recieveHello(%init_peer_id%) - <- res - -``` - -The code above defines a function which retrieves the current timestamp from the relay node. The function works as following: - - - -1. The function definition, specifying arguments and return value types - -2. Shift the execution to the peer with id equal to `relayPeerId` - -3. Calls built-in function on the current peer and stores the result into a variable - -4. Returns the result - - - -The function gets compiled into typescript and can be called from the application code (see next section) - -## Application code