Skip to content

Commit

Permalink
Merge pull request #51 from l-monninger/main
Browse files Browse the repository at this point in the history
chore: tidying up weeks 1 and 2; providing disclaimers.
  • Loading branch information
l-monninger authored Nov 14, 2023
2 parents 2a9d2a8 + 727ef4f commit 0de5958
Show file tree
Hide file tree
Showing 40 changed files with 686 additions and 601 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/maintainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=amd64 mvlbs/m1
FROM mvlbs/m1

# Install dependencies
RUN apt-get update && apt-get install -y \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/movement/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=amd64 mvlbs/m1
FROM mvlbs/m1

# Install Rust

Expand Down
10 changes: 10 additions & 0 deletions book/book/Prologue.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ <h1 id="building-with-movement"><a class="header" href="#building-with-movement"
<p align="center">
<small color="gray">The Movement logo</small>
</p>
<div align="center">
<hr />
<h3 id="-important-update-in-progress-"><a class="header" href="#-important-update-in-progress-">🚧🚧🚧 <strong>Important Update In Progress</strong> 🚧🚧🚧</a></h3>
<p>We are actively working on a new edition of this booklet in response to changes in our audience and to address issues stemming from the outdated nature of the original guide.</p>
<ul>
<li><strong>Weeks 1 &amp; 2</strong>: Existing content remains useful. We are enhancing these sections with more in-depth material specific to the <strong>Aptos Framework</strong>.</li>
<li><strong>Weeks 3 &amp; 4</strong>: Stay tuned! We will soon add comprehensive content covering <strong>Sui Move</strong> and unique features of the <strong>Movement ecosystem</strong>, including <strong>MEVM</strong>.</li>
</ul>
<hr />
</div>
<p>Welcome to <em>Building with Movement</em>! Over the course of this booklet, we will be addressing topics related to developing for the Movement blockchain.</p>
<p>This booklet was originally developed for a month-long hackathon, and so has content covering four weeks. While we think this pacing is nice, the book is concise enough to do in far less time and resumable enough to spread out over more time.</p>
<p>By the end of this book, you will have the skills to build for the Movement blockchain and the contextual awareness to understand its advantages.</p>
Expand Down
10 changes: 10 additions & 0 deletions book/book/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ <h1 id="building-with-movement"><a class="header" href="#building-with-movement"
<p align="center">
<small color="gray">The Movement logo</small>
</p>
<div align="center">
<hr />
<h3 id="-important-update-in-progress-"><a class="header" href="#-important-update-in-progress-">🚧🚧🚧 <strong>Important Update In Progress</strong> 🚧🚧🚧</a></h3>
<p>We are actively working on a new edition of this booklet in response to changes in our audience and to address issues stemming from the outdated nature of the original guide.</p>
<ul>
<li><strong>Weeks 1 &amp; 2</strong>: Existing content remains useful. We are enhancing these sections with more in-depth material specific to the <strong>Aptos Framework</strong>.</li>
<li><strong>Weeks 3 &amp; 4</strong>: Stay tuned! We will soon add comprehensive content covering <strong>Sui Move</strong> and unique features of the <strong>Movement ecosystem</strong>, including <strong>MEVM</strong>.</li>
</ul>
<hr />
</div>
<p>Welcome to <em>Building with Movement</em>! Over the course of this booklet, we will be addressing topics related to developing for the Movement blockchain.</p>
<p>This booklet was originally developed for a month-long hackathon, and so has content covering four weeks. While we think this pacing is nice, the book is concise enough to do in far less time and resumable enough to spread out over more time.</p>
<p>By the end of this book, you will have the skills to build for the Movement blockchain and the contextual awareness to understand its advantages.</p>
Expand Down
397 changes: 207 additions & 190 deletions book/book/print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion book/book/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion book/book/searchindex.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion book/book/week_1/Basic_move_syntax.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h2 id="allocation-and-the-move-memory-model"><a class="header" href="#allocatio
<p>While function ownership in Move is similar to Rust, it is less permissive and closer to being purely linear--restricting the set of possible borrows.</p>
<h2 id="expressions-and-control-flow"><a class="header" href="#expressions-and-control-flow">Expressions and Control Flow</a></h2>
<h3 id="expressions"><a class="header" href="#expressions">Expressions</a></h3>
<p>Move use a similar expression-orientation to Rusts. Block returns are possible. </p>
<p>Move uses a similar expression-orientation to Rust. Expressions are evaluated to produce a value. Expressions can be used in many places, including:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>fun eight() : u8 {
Expand Down Expand Up @@ -269,6 +269,7 @@ <h2 id="resources-references-and-mutation"><a class="header" href="#resources-re
<h2 id="misc-syntax"><a class="header" href="#misc-syntax">Misc. syntax</a></h2>
<ul>
<li>The <code>public</code> keyword in Move indicates that a function can be invoked from outside the current module.</li>
<li>The <code>entry</code> keyword is used to declare functions that can be called via the RPC.</li>
<li>The <code>native</code> keyword is used to declare functions that are implemented in the blockchain runtime or in an external module.</li>
<li>There are VM specific directives; in Movement we will address <code>#[inline]</code>, <code>#[view]</code>, <code>#[test_only]</code>, and <code>#[test]</code>.</li>
</ul>
Expand Down
53 changes: 30 additions & 23 deletions book/book/week_1/Debugging_basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ <h1 class="menu-title"></h1>
<main>
<h1 id="debugging-basic-smart-contracts"><a class="header" href="#debugging-basic-smart-contracts">Debugging Basic Smart Contracts</a></h1>
<p>This section introduces a few basic smart contracts from this repository as a starting point for programming activites.</p>
<h2 id="-helloworld"><a class="header" href="#-helloworld">💻 HelloWorld</a></h2>
<p>Is a very simple program for <code>MoveVM</code>. You can find it at <code>examples/move/hello_world</code>. </p>
<h2 id="-hello_world"><a class="header" href="#-hello_world">💻 <code>hello_world</code></a></h2>
<p>This very simple program for <code>Movement Move VM</code>. You can find it at <code>examples/movement/hello_world</code> prints values to debug console. Note the differences in encodings between the <code>b&quot;&quot;</code> and <code>string::utf8</code> versions of the string.</p>
<blockquote>
<p>Learnings leveraged:</p>
<ul>
Expand All @@ -165,38 +165,45 @@ <h2 id="-helloworld"><a class="header" href="#-helloworld">💻 HelloWorld</a><
</blockquote>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>script {
use std::debug;
// use std::vector;
fun debug_script(account : signer) {

// Encode the &quot;Hello, world!&quot; as a byte string.
let hello = b&quot;Hello, world!&quot;;

// Print the byte string as a vector&lt;u8&gt; by passing a reference to the byte string.
debug::print&lt;vector&lt;u8&gt;&gt;(&amp;hello);

</span>module hello_world::hello_world {

use std::string;
use std::signer;
use aptos_std::debug;


#[test(account = @0x1)]
public entry fun hello_world(account: signer) {
let addr = signer::address_of(&amp;account);
debug::print&lt;address&gt;(&amp;addr);
let message = b&quot;Hello, world!&quot;;
debug::print(&amp;message);
let str_message = string::utf8(message);
debug::print(&amp;str_message);
}

}
<span class="boring">}</span></code></pre></pre>
<p>To run...</p>
<pre><code class="language-bash">move sandbox run sources/hello_world_script.move --signers 0xf
<p>To test run...</p>
<pre><code class="language-bash">move move run
&gt; [debug] @0x1
&gt; [debug] 0x48656c6c6f2c20776f726c6421
&gt; [debug] &quot;Hello, world!&quot;
</code></pre>
<p>Double-check the output hex...</p>
<p>If you want to double-check the output hex...</p>
<pre><code class="language-bash">echo 48656c6c6f2c20776f726c6421 | xxd -r - p
</code></pre>
<h2 id="-fib"><a class="header" href="#-fib">💻 Fib</a></h2>
<p>The obligatory Move program that computes the <em>nth</em> Fibonacci number. We will refer to this later when we do 💻 MulticontractFib. You can find it and instructions to run it <code>examples/move/fib</code>. </p>
<h2 id="-fib"><a class="header" href="#-fib">💻 <code>fib</code></a></h2>
<p>The obligatory Move program that computes the <em>nth</em> Fibonacci number. We will refer to this later when we do 💻 MulticontractFib. You can find it and instructions to run it <code>examples/movement/fib</code>. </p>
<blockquote>
<p>Learnings leveraged:</p>
<ul>
<li>Basic Move syntax</li>
<li>Byte strings</li>
<li>Move recursion.</li>
</ul>
</blockquote>
<h2 id="-datastructures"><a class="header" href="#-datastructures">💻 DataStructures</a></h2>
<p>From scratch implementation of a priority queue, a couple variations of a hash map, and a binary tree. This may be a useful reference point for building more challenging projects that require custom data strucures. You can find it at <code>examples/move/data_structures</code>. </p>
<h2 id="-data_structures"><a class="header" href="#-data_structures">💻 <code>data_structures</code></a></h2>
<p>From scratch implementation of a priority queue, a couple variations of a hash map, and a binary tree. This may be a useful reference point for building more challenging projects that require custom data strucures. You can find it at <code>examples/movement/data_structures</code>. </p>
<blockquote>
<p>Learnings leveraged:</p>
<ul>
Expand All @@ -206,8 +213,8 @@ <h2 id="-datastructures"><a class="header" href="#-datastructures">💻 DataStr
<li>Move idioms</li>
</ul>
</blockquote>
<h2 id="-resourceroulette"><a class="header" href="#-resourceroulette">💻 ResourceRoulette</a></h2>
<p>A game of roulette on MoveVM. Place your address on an element in the vector. Contains methods <code>public fun bid</code> and <code>public fun spin</code>. Receive a payout if you placed your address on the correct cell. You can find it and instructions to run it at <code>examples/move/resource_roulette</code>. </p>
<h2 id="-resource_roulette"><a class="header" href="#-resource_roulette">💻 <code>resource_roulette</code></a></h2>
<p>A game of roulette on MoveVM. Place your address on an element in the vector. Contains methods <code>public fun bid</code> and <code>public fun spin</code>. Receive a payout if you placed your address on the correct cell. You can find it and instructions to run it at <code>examples/movement/resource_roulette</code>. </p>
<blockquote>
<p>Learnings leveraged:</p>
<ul>
Expand Down
29 changes: 14 additions & 15 deletions book/book/week_1/Developer_setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,47 +157,46 @@ <h1 id="developer-setup"><a class="header" href="#developer-setup">Developer Set
<h2 id="the-move-ecosystem"><a class="header" href="#the-move-ecosystem">The Move ecosystem</a></h2>
<p>The budding Move ecosystem sports a variety of developer friendly tools. As we list off tools that will be relevant to this booklet, keep in mind that there are number of projects we have not included.</p>
<h3 id="virtual-machines"><a class="header" href="#virtual-machines">Virtual machines</a></h3>
<p>As previously discussed, there are several virtual machine implementations available for Move development--each of with is paired with particular blockchain. Besides the <code>Movement VM</code>, the most well-known Move virtual machines are <code>Move VM</code>, <code>Aptos VM</code>, and <code>Sui VM</code></p>
<p>As previously discussed, there are several popular virtual machine implementations available for Move development--each of with is paired with particular blockchain. Besides the <code>Movement VM</code>, the most well-known Move virtual machines are <code>Move VM</code>, <code>Aptos VM</code>, and <code>Sui VM</code></p>
<p>We provide a comparison of these different virtual machines in our <a href="https://docs.movementlabs.xyz/#what-is-move">docs</a>. </p>
<p>When selecting a virtual machine for development its important to consider performance, ease of use, and stability. <code>Aptos VM</code> built upon the original and stable <code>Move VM</code> to provide an improved developer experience. The <code>Movement VM</code> builds upon <code>Aptos VM</code> to provide improved performance.</p>
<p>When selecting a virtual machine for development it's important to consider performance, ease of use, and stability. <code>Aptos VM</code> built upon the original and stable <code>Move VM</code> to provide an improved developer experience. The <code>Movement VM</code> builds upon <code>Aptos VM</code> to provide improved performance.</p>
<h3 id="clis"><a class="header" href="#clis">CLIs</a></h3>
<p>There are three CLIs worth note in the Move language development space. All support building, testing, deploying, and running smart contracts.</p>
<p>There are three CLIs worthy of note in the Move language development space. All support building, testing, deploying, and running smart contracts.</p>
<ul>
<li><a href="https://github.com/move-language/move/tree/main/language/tools/move-cli"><code>move</code></a>: the original CLI for Move development. </li>
<li><code>aptos</code>: the CLI for Aptos development.</li>
<li><a href="https://movement.gitbook.io/english/developers/developer-tools/movement-cli"><code>movement</code></a>: our very own CLI.</li>
<li><a href="https://aptos.dev/tools/aptos-cli/install-cli/"><code>aptos</code></a>: the CLI for Aptos development.</li>
<li><a href="https://docs.movementlabs.xyz/developers/developer-tools/movement-cli"><code>movement</code></a>: our very own CLI which is currently compatible with the Aptos CLI.</li>
</ul>
<p>In this booklet we will be working with <code>move</code> and <code>movement</code>. </p>
<p>In this booklet we will be working with <code>movement</code>. If you ever need help working with <code>movement</code> you can run <code>movement --help</code> or <code>movement &lt;command&gt; --help</code> for more information.</p>
<h3 id="package-managers"><a class="header" href="#package-managers">Package managers</a></h3>
<p>Move has a package manager, <a href="https://www.movey.net/">movey</a>. However, generally we will recommend adding dependencies directly to your <code>Move.toml</code> file. </p>
<p>You can manage Move dependencies by adding them directly to your <code>Move.toml</code> file. </p>
<pre><code class="language-toml">[package]
name = &quot;hello_world&quot;
version = &quot;0.0.0&quot;

[dependencies]
# MoveNursery = { git = &quot;https://github.com/move-language/move.git&quot;, subdir = &quot;language/move-stdlib/nursery&quot;, rev = &quot;main&quot; }
MovementFramework = { git = &quot;https://github.com/movemntdev/movement-subnet.git&quot;, subdir = &quot;vm/aptos-vm/aptos-move/aptos-framework&quot;, rev = &quot;main&quot; }
AptosFramework = { git = &quot;https://github.com/movemntdev/aptos-core.git&quot;, subdir = &quot;aptos-vm/aptos-move/aptos-framework&quot;, rev = &quot;testnet&quot; }

[addresses]
std = &quot;0x1&quot;
hello_blockchain = &quot;_&quot;
</code></pre>
<p>Our version of the AptosFramework is slightly different from the upstream at https://github.com/aptos-labas/aptos-core.git. Please be mindful that, while our goal is to support the latest version of the Aptos Framework, we may occasionally lag behind the upstream--resulting in incompatibilities.</p>
<h3 id="ide"><a class="header" href="#ide">IDE</a></h3>
<p>There are several useful development enviroments for Move. This book will be geared towards using VsCode because of the its developer container features and its <a href="https://marketplace.visualstudio.com/items?itemName=move.move-analyzer">Move analyzer</a>. However, syntax highlighting has been implemented for other IDEs including <a href="https://github.com/rvmelkonian/move.vim">Vim</a>.</p>
<h2 id="our-setup"><a class="header" href="#our-setup">Our Setup</a></h2>
<p>We'll be using the <code>move</code> and <code>movement</code> CLIs; no package manager; and VsCode most-often running the <code>movement-dev</code> Docker container from <a href="public.ecr.aws/c4i6k4r8/movement-dev">public.ecr.aws/c4i6k4r8/movement-dev</a>.</p>
<p>We'll be using the <code>move</code> and <code>movement</code> CLIs; no package manager; and VsCode most-often running the <code>movement-dev</code> Docker container from (mvlbs/m1)[https://hub.docker.com/repository/docker/mvlbs/m1/general].</p>
<p>To get started...</p>
<ol>
<li>Clone the repo from which this book originates: https://github.com/movemntdev/movement-hack</li>
<li>Open the repo in VsCode.</li>
<li>Based on the advice provided for a given project, reopen the repo in one of <code>move</code>, <code>movement-dev</code>, <code>anchor</code>, or <code>solidity</code> <a href="https://code.visualstudio.com/docs/devcontainers/containers">devcontainers</a>.</li>
<li>Reopen the directory using the movement <a href="https://code.visualstudio.com/docs/devcontainers/containers">devcontainer</a>.</li>
</ol>
<p>Alternatively, when working with <code>movement-dev</code> you may:</p>
<pre><code>docker image pull public.ecr.aws/c4i6k4r8/movement-dev
docker run -it -v &quot;$(pwd):/workspace&quot; public.ecr.aws/c4i6k4r8/movement-dev /bin/bash
<pre><code>docker image pull mvlbs/m1
docker run -it -v &quot;$(pwd):/workspace&quot; mvlbs/m1 /bin/bash
</code></pre>
<p>We will also occasionally use Rust and Python to complete various programming examples.</p>
<p>We will also discuss using our proxy service with the JavaScript. The <code>movement-dev</code> developer container provides an easy start place for this alternative means of interacting with the <a href="https://docs.movementlabs.xyz/develop/get-started/deploy-and-interact-with-contract">subnet</a>.</p>
<p>We will also occasionally use Rust, TypeScript, and Python to complete various programming examples.</p>

</main>

Expand Down
Loading

0 comments on commit 0de5958

Please sign in to comment.