heyitaki 0ecc427d6f docker: build CLI in shared image 2 年之前
..
devnet 760db3c810 sui: redesign Wormhole and Token Bridge contracts 2 年之前
examples 760db3c810 sui: redesign Wormhole and Token Bridge contracts 2 年之前
scripts ed733f8e73 sdk/js: add Sui support 2 年之前
testing 760db3c810 sui: redesign Wormhole and Token Bridge contracts 2 年之前
token_bridge d7e9a0b2dd sui: update testnet Sui addresses 2 年之前
wormhole d7e9a0b2dd sui: update testnet Sui addresses 2 年之前
.gitignore 760db3c810 sui: redesign Wormhole and Token Bridge contracts 2 年之前
Docker.md 0ecc427d6f docker: build CLI in shared image 2 年之前
Dockerfile 0ecc427d6f docker: build CLI in shared image 2 年之前
Dockerfile.base 0ecc427d6f docker: build CLI in shared image 2 年之前
Makefile 0ecc427d6f docker: build CLI in shared image 2 年之前
NOTES.md 760db3c810 sui: redesign Wormhole and Token Bridge contracts 2 年之前
README.md 760db3c810 sui: redesign Wormhole and Token Bridge contracts 2 年之前

README.md

Wormhole on Sui

This folder contains the reference implementation of the Wormhole cross-chain messaging protocol smart contracts on the Sui blockchain, implemented in the Move programming language.

Project structure

The project is laid out as follows:

  • wormhole the core messaging layer
  • token_bridge the asset transfer layer
  • coin a template for creating Wormhole wrapped coins

Installation

Make sure your Cargo version is at least 1.65.0 and then follow the steps below:

Prerequisites

Install the Sui CLI. This tool is used to compile the contracts and run the tests.

cargo install --locked --git https://github.com/MystenLabs/sui.git --rev 09b2081498366df936abae26eea4b2d5cafb2788 sui sui-faucet

Some useful Sui CLI commands are

  • sui start to spin up a local network
  • rpc-server to start a server for handling rpc calls
  • sui-faucet to start a faucet for requesting funds from active-address

Next, install the worm CLI tool by running

wormhole/clients/js $ make install

worm is the swiss army knife for interacting with wormhole contracts on all supported chains, and generating signed messages (VAAs) for testing.

As an optional, but recommended step, install the move-analyzer Language Server (LSP):

cargo install --git https://github.com/move-language/move.git move-analyzer --branch main --features "address32"

This installs the LSP backend which is then supported by most popular editors such as emacs, vim, and even vscode.

For emacs, you may need to add the following to your config file: ```lisp ;; Move (define-derived-mode move-mode rust-mode "Move" :group 'move-mode) (add-to-list 'auto-mode-alist '("\\.move\\'" . move-mode)) (with-eval-after-load 'lsp-mode (add-to-list 'lsp-language-id-configuration '(move-mode . "move")) (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection "move-analyzer") :activation-fn (lsp-activate-on "move") :server-id 'move-analyzer))) ```

Building & running tests

The project uses a simple make-based build system for building and running tests. Running make test in this directory will run the tests for each contract. If you only want to run the tests for, say, the token bridge contract, then you can run make test in the token_bridge directory, or run make -C token_bridge test from this directory.

Additionally, make test-docker runs the tests in a docker container which is set up with all the necessary dependencies. This is the command that runs in CI.

Running a local validator and deploying the contracts to it

Simply run

worm start-validator sui

which will start a local sui validator with an RPC endpoint at 0.0.0.0:9000 and the faucet endpoint at 0.0.0.0:5003/gas. Note that the faucet takes a few (~10) seconds to come up, so only proceed when you see the following:

Faucet is running.  Faucet endpoint: 0.0.0.0:5003/gas

Once the validator is running, the contracts are ready to deploy. In the scripts directory, run

scripts $ ./deploy.sh devnet

This will deploy the core contract and the token bridge.

When you make a change to the contract, you can simply restart the validator and run the deploy script again.

Implementation notes / coding practices

In this section, we describe some of the implementation design decisions and coding practices we converged on along the way. Note that the coding guidelines are prescriptive rather than descriptive, and the goal is for the contracts to ultimately follow these, but they might not during earlier development phases.

TODO