Skip to content

Commit

Permalink
Merge pull request #1912 from demergent-labs/new_command
Browse files Browse the repository at this point in the history
add hello_world_candid_rpc example
  • Loading branch information
lastmjs authored Jul 17, 2024
2 parents 510608a + c288b26 commit 2bfa902
Show file tree
Hide file tree
Showing 22 changed files with 10,917 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
"examples/bitcoin_psbt",
"examples/ckbtc",
"examples/hello_world",
"examples/hello_world_candid_rpc",
"property_tests/tests/blob",
"property_tests/tests/bool",
"property_tests/tests/canister_methods/http_request",
Expand Down Expand Up @@ -150,6 +151,7 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/motoko_examples/threshold_ecdsa",
"tests/end_to_end/candid_rpc/class_syntax/motoko_examples/whoami",
"tests/end_to_end/candid_rpc/class_syntax/new",
"tests/end_to_end/candid_rpc/class_syntax/new_candid_rpc",
"tests/end_to_end/candid_rpc/class_syntax/notify_raw",
"tests/end_to_end/candid_rpc/class_syntax/null_example",
"tests/end_to_end/candid_rpc/class_syntax/optional_types",
Expand Down
4 changes: 4 additions & 0 deletions examples/hello_world_candid_rpc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.azle
.dfx
dfx_generated
node_modules
84 changes: 84 additions & 0 deletions examples/hello_world_candid_rpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Azle Hello World

- [Installation](#installation)
- [Deployment](#deployment)

Azle helps you to build secure decentralized/replicated servers in TypeScript or JavaScript on [ICP](https://internetcomputer.org/). The current replication factor is [13-40 times](https://dashboard.internetcomputer.org/subnets).

Please remember that Azle is in beta and thus it may have unknown security vulnerabilities due to the following:

- Azle is built with various software packages that have not yet reached maturity
- Azle does not yet have multiple independent security reviews/audits
- Azle does not yet have many live, successful, continuously operating applications deployed to ICP

## Installation

> Windows is only supported through a Linux virtual environment of some kind, such as [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)
You will need [Node.js 20](#nodejs-20) and [dfx](#dfx) to develop ICP applications with Azle:

### Node.js 20

It's recommended to use nvm to install Node.js 20:

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
```

Restart your terminal and then run:

```bash
nvm install 20
```

Check that the installation went smoothly by looking for clean output from the following command:

```bash
node --version
```

### dfx

Install the dfx command line tools for managing ICP applications:

```bash
DFX_VERSION=0.21.0 sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
```

Check that the installation went smoothly by looking for clean output from the following command:

```bash
dfx --version
```

## Deployment

To create and deploy a simple sample application called `hello_world`:

```bash
# create a new default project called hello_world
npx azle new hello_world
cd hello_world
```

```bash
# install all npm dependencies including azle
npm install
```

```bash
# install the azle dfx extension
npx azle install-dfx-extension
```

```bash
# start up a local ICP replica
dfx start --clean
```

In a separate terminal in the `hello_world` directory:

```bash
# deploy your canister
dfx deploy
```
13 changes: 13 additions & 0 deletions examples/hello_world_candid_rpc/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"canisters": {
"hello_world": {
"type": "azle",
"main": "src/index.ts",
"candid_gen": "automatic",
"declarations": {
"output": "test/dfx_generated/hello_world",
"node_compatibility": true
}
}
}
}
10 changes: 10 additions & 0 deletions examples/hello_world_candid_rpc/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.ts$': 'ts-jest',
'^.+\\.js$': 'ts-jest'
},
transformIgnorePatterns: ['/node_modules/(?!(azle)/)'] // Make sure azle is transformed
};
Loading

0 comments on commit 2bfa902

Please sign in to comment.