Skip to content

Commit

Permalink
Merge branch 'master' into mraszyk/pic
Browse files Browse the repository at this point in the history
  • Loading branch information
mraszyk committed Jan 10, 2025
2 parents 46e358c + 0c27b54 commit 17d525b
Show file tree
Hide file tree
Showing 80 changed files with 1,889 additions and 2,205 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/motoko/hello_cycles/ @dfinity/languages
/motoko/ic-pos/ @dfinity/growth
/motoko/icrc2-swap/ @dfinity/growth
/motoko/internet_identity_integration/ @dfinity/gix
/motoko/internet_identity_integration/ @dfinity/identity
/motoko/life/ @dfinity/languages
/motoko/minimal-counter-dapp/ @dfinity/growth
/motoko/parallel_calls/ @dfinity/languages
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/provision-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ set -ex
pushd /tmp

# Install Node.
wget --output-document install-node.sh "https://deb.nodesource.com/setup_14.x"
sudo bash install-node.sh
wget --output-document nodesource_setup.sh "https://deb.nodesource.com/setup_lts.x"
sudo bash nodesource_setup.sh
sudo apt-get install --yes nodejs
rm install-node.sh
rm nodesource_setup.sh

# Install DFINITY SDK.
wget --output-document install-dfx.sh "https://raw.githubusercontent.com/dfinity/sdk/master/public/install-dfxvm.sh"
DFX_VERSION=${DFX_VERSION:=0.24.3} DFXVM_INIT_YES=true bash install-dfx.sh
rm install-dfx.sh
echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH
echo "$HOME/.local/share/dfx/bin" >>$GITHUB_PATH
source "$HOME/.local/share/dfx/env"
dfx cache install
# check the current ic-commit found in the main branch, check if it differs from the one in this PR branch
# if so, update the dfx cache with the latest ic artifacts
if [ -f "${GITHUB_WORKSPACE}/.ic-commit" ]; then
stable_sha=$(curl https://raw.githubusercontent.com/dfinity/examples/master/.ic-commit)
current_sha=$(sed <"$GITHUB_WORKSPACE/.ic-commit" 's/#.*$//' | sed '/^$/d')
arch="x86_64-linux"
if [ "$current_sha" != "$stable_sha" ]; then
export current_sha
export arch
sh "$GITHUB_WORKSPACE/.github/workflows/update-dfx-cache.sh"
fi
stable_sha=$(curl https://raw.githubusercontent.com/dfinity/examples/master/.ic-commit)
current_sha=$(sed <"$GITHUB_WORKSPACE/.ic-commit" 's/#.*$//' | sed '/^$/d')
arch="x86_64-linux"
if [ "$current_sha" != "$stable_sha" ]; then
export current_sha
export arch
sh "$GITHUB_WORKSPACE/.github/workflows/update-dfx-cache.sh"
fi
fi

# Install ic-repl
Expand All @@ -47,14 +47,14 @@ rustup target add wasm32-unknown-unknown

# Install matchers
matchers_version=1.2.0
curl -fsSLO "https://github.com/kritzcreek/motoko-matchers/archive/refs/tags/v${matchers_version}.tar.gz"
curl -fsSLO "https://github.com/kritzcreek/motoko-matchers/archive/refs/tags/v${matchers_version}.tar.gz"
tar -xzf "v${matchers_version}.tar.gz" --directory "$(dfx cache show)"
rm "v${matchers_version}.tar.gz"
mv "$(dfx cache show)/motoko-matchers-${matchers_version}" "$(dfx cache show)/motoko-matchers"

# Install wasmtime
wasmtime_version=0.33.1
curl -fsSLO "https://github.com/bytecodealliance/wasmtime/releases/download/v${wasmtime_version}/wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz"
curl -fsSLO "https://github.com/bytecodealliance/wasmtime/releases/download/v${wasmtime_version}/wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz"
mkdir -p "${HOME}/bin"
tar -xf "wasmtime-v${wasmtime_version}-x86_64-linux.tar.xz" --directory "${HOME}/bin/"
mv "${HOME}/bin/wasmtime-v${wasmtime_version}-x86_64-linux/wasmtime" "${HOME}/bin/wasmtime"
Expand All @@ -66,13 +66,13 @@ cargo install --path wasi2ic --root "${HOME}"

# Install wasm-opt
version=117
curl -fsSLO "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_${version}-x86_64-linux.tar.gz"
curl -fsSLO "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_${version}-x86_64-linux.tar.gz"
tar -xzf "binaryen-version_${version}-x86_64-linux.tar.gz" --directory "${HOME}/" --strip-components 1
rm "binaryen-version_${version}-x86_64-linux.tar.gz"

# Set environment variables.
echo "$HOME/bin" >> $GITHUB_PATH
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
echo "$HOME/bin" >>$GITHUB_PATH
echo "$HOME/.cargo/bin" >>$GITHUB_PATH

# Exit temporary directory.
popd
4 changes: 3 additions & 1 deletion .github/workflows/rust-threshold-schnorr-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Provision Darwin
run: bash .github/workflows/provision-darwin.sh
run: |
bash .github/workflows/provision-darwin.sh
brew install llvm
- name: Provision PocketIC
run: bash .github/workflows/provision-pocket-ic-server.sh
- name: Rust Threshold Schnorr Darwin
Expand Down
2 changes: 1 addition & 1 deletion archive/motoko/dip721-nft-container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Using this management canister address, we can construct its principal and set t

## NFT sample code tutorial

### Prerequisites
## Prerequisites

- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
- [x] Download and install [git.](https://git-scm.com/downloads)
Expand Down
2 changes: 1 addition & 1 deletion archive/motoko/hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This example demonstrates a dead simple dapp consisting of two canister smart co

This example is based on the default project created by running `dfx new hello`.

### Prerequisites
## Prerequisites
This example requires an installation of:
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
- [x] Install `node.js` (to build the web frontend).
Expand Down
5 changes: 3 additions & 2 deletions archive/motoko/persistent-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This example covers:
## Installation
This example project can be cloned, installed, and deployed locally, for learning and testing purposes. The instructions are based on running the example on either macOS or Linux, but when using WSL2 on Windows, the instructions will be the same.

### Prerequisites
## Prerequisites
This example requires an installation of:

- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
Expand All @@ -33,7 +33,8 @@ This example requires an installation of:

Begin by opening a terminal window.

### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:


```bash
cd examples/motoko/persistent-storage
Expand Down
26 changes: 10 additions & 16 deletions motoko/basic_bitcoin/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
---
keywords: [advanced, motoko, bitcoin, bitcoin integration, btc]
---

# Basic Bitcoin

[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/basic_bitcoin)

## Overview
This tutorial will walk you through how to deploy a sample [canister smart contract](https://wiki.internetcomputer.org/wiki/Canister_smart_contract) **that can send and receive Bitcoin** on the Internet Computer.

## Architecture
Expand All @@ -21,22 +14,23 @@ For a deeper understanding of the ICP < > BTC integration, see the [Bitcoin inte

## Prerequisites

* [x] Install the [IC
SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx). For local testing, `dfx >= 0.22.0` is required.
- [x] Install the [IC
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`

> [!WARNING]
> This example is designed to be deployed on the mainnet. It will return errors when deployed locally; these errors are expected.
:::info
This example is designed to be deployed on the mainnet. It will return errors when deployed locally; these errors are expected.
:::
Begin by opening a terminal window.

## Step 1: Building and deploying sample code
## Step 1: Setup the project environment

### Clone the smart contract
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:

To clone and build the smart contract in **Motoko**:

```bash
git clone https://github.com/dfinity/examples
cd examples/motoko/basic_bitcoin
dfx start --background
```

### Install MOPS
Expand Down
27 changes: 12 additions & 15 deletions motoko/basic_dao/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
---
keywords: [advanced, motoko, dao, decentralized organization, decentralized org]
---

# Basic DAO

[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/basic_dao)

This sample project demonstrates a basic [decentralized autonomous organization](https://en.wikipedia.org/wiki/Decentralized_autonomous_organization) (DAO) that can be deployed to the [Internet Computer](https://github.com/dfinity/ic). The basic DAO sample code is available in [Motoko](https://github.com/dfinity/examples/tree/master/motoko/basic_dao) and [Rust](https://github.com/dfinity/examples/tree/master/rust/basic_dao). You can see a quick introduction on [YouTube](https://youtu.be/3IcYlieA-EE).

## Overview

A `basic_dao` can be initialized with a set of accounts: mappings from principal IDs to a number of tokens. Account owners can query their account balance by calling `account_balance` and transfer tokens to other accounts by calling `transfer`. Anyone can call `list_accounts` to view all accounts.

Account owners can submit proposals by calling `submit_proposal`. A proposal specifies a canister, method, and arguments for this method. Account owners can cast votes (either `Yes` or `No`) on a proposal by calling `vote`. The amount of votes cast is equal to the amount of tokens the account owner has. If enough `Yes` votes are cast, `basic_dao` will execute the proposal by calling the proposal’s given method with the given args against the given canister. If enough `No` votes are cast, the proposal is not executed, and is instead marked as `Rejected`.
Expand All @@ -19,30 +11,35 @@ This workflow is demonstrated below.

View the [canister service definition](https://github.com/dfinity/examples/blob/master/rust/basic_dao/src/basic_dao/src/basic_dao.did) for more details.

### Prerequisites
This example requires an installation of:
## Prerequisites

- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
- [x] Install the [IC
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
- [x] To run the test scripts, you need to download [ic-repl](https://github.com/chenyan2002/ic-repl/releases).
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`

Begin by opening a terminal window.

### Step 1: Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the command:
## Step 1: Setup the project environment

Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:


```bash
cd examples/motoko/basic_dao
dfx start --background
```

### Step 2: Create test identities with the commands:
## Step 2: Create identities

Create test identities with the commands:

```bash
dfx identity new Alice --disable-encryption; dfx identity use Alice; export ALICE=$(dfx identity get-principal);
dfx identity new Bob --disable-encryption; dfx identity use Bob; export BOB=$(dfx identity get-principal);
```

### Step 3: Deploy `basic_dao` with initial test accounts.
## Step 3: Deploy `basic_dao` with initial test accounts

```bash
dfx deploy --argument "(record {
Expand All @@ -57,7 +54,7 @@ dfx deploy --argument "(record {
})"
```

### Step 4: Run the ic-repl test scripts:
## Step 4: Run the `ic-repl` test scripts:

```bash
ic-repl tests/account.test.sh
Expand Down
48 changes: 23 additions & 25 deletions motoko/canister_logs/README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
---
keywords: [beginner, motoko, canister logs, logging]
---

# Canister logs

[View this sample's code on GitHub](https://github.com/dfinity/examples/tree/master/motoko/canister_logs)

## Prerequisites
This example requires an installation of:

- [x] DFX version 0.19.0 or newer
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/).
- [x] Download the following project files from GitHub: `git clone https://github.com/dfinity/examples/`
- [x] Install the [IC
SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install). For local testing, `dfx >= 0.22.0` is required.
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`

You will need to have 3 terminal windows:
- Terminal A: Running a DFX instance and separating its output from anything else
- Terminal B: Deploying a canister and seeing its output
- Terminal C: Reading logs interactively
## Step 1: Setup project environment

Navigate into the folder containing the project's files and start a local instance of the replica with the command:

### Step 1: Navigate into the folder containing the project's files and start a local instance of the replica with the command:
```shell
dfx start --clean
```

You will need to have 3 terminal windows:
- Terminal A: Running a `dfx` instance and separating its output from anything else.
- Terminal B: Deploying a canister and seeing its output.
- Terminal C: Reading logs interactively.

```shell
# Terminal A -- for running DFX and separating its output from anything else.
$ cd examples/motoko/canister_logs
$ dfx start --clean
cd examples/motoko/canister_logs

# Terminal B -- for deploying the canister and calling its methods.
$ cd examples/motoko/canister_logs
cd examples/motoko/canister_logs

# Terminal C -- for polling logs.
$ cd examples/motoko/canister_logs
cd examples/motoko/canister_logs
```

### Step 2: Deploy the canister:
## Step 2: Deploy the canister

```shell
# Terminal B
$ dfx deploy
dfx deploy
```

### Step 3: Check canister logs:
## Step 3: Check canister logs

Expect to see logs from timer traps.

Expand All @@ -52,7 +50,7 @@ $ dfx canister logs CanisterLogs
[3. 2024-05-23T08:32:31.836721763Z]: [TRAP]: timer trap
```

### Step 4: Call `print` method and check the logs:
## Step 4: Call `print` method and check the logs

```shell
# Terminal B
Expand All @@ -70,7 +68,7 @@ $ dfx canister logs CanisterLogs
...
```

### Step 5: Start constantly polling logs:
## Step 5: Start constantly polling logs

In order not to call `dfx canister logs CanisterLogs` after every canister call in a separate terminal window/pane C start a script that will constantly poll logs:

Expand All @@ -86,7 +84,7 @@ $ ./poll_logs.sh
...
```

### Step 6: Call `print`, `trap` and other canister methods:
## Step 6: Call `print`, `trap` and other canister methods

```shell
# Terminal B
Expand Down
Loading

0 comments on commit 17d525b

Please sign in to comment.