-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
137 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
# Axelar Local Dev Sui | ||
# Axelar Local Dev: Sui Integration | ||
|
||
## Running Local Sui Network | ||
|
||
1. Clone the repository | ||
This package allows you to create a local development environment for cross-chain communication using the [Sui](https://sui.io/) protocol. At present, we support general message passing only with EVM chain | ||
|
||
```bash | ||
git clone https://github.com/MystenLabs/sui.git | ||
``` | ||
## Prequisite | ||
|
||
2. cd into sui directory and run the following commmand | ||
You'll have to install `sui` and `sui-test-validator` in your local machine. | ||
|
||
```bash | ||
RUST_LOG="consensus=off" cargo run --bin sui-test-validator | ||
``` | ||
To do this, please follow the guide from Sui [here](https://docs.sui.io/build/sui-local-network#install-sui-from-github) | ||
|
||
> Important: Each time you start the sui-test-validator, the network starts as a new network with no previous data. The local network is not persistent. | ||
> Note: This package has tested against version [devnet-v1.8.1](https://github.com/MystenLabs/sui/releases/tag/devnet-v1.8.1). | ||
``` | ||
OPTIONS: | ||
--epoch-duration-ms <EPOCH_DURATION_MS> | ||
The duration for epochs (defaults to one minute) [default: 60000] | ||
## Running Local Sui Network | ||
|
||
--faucet-port <FAUCET_PORT> | ||
Port to start the Sui faucet on [default: 9123] | ||
To start running local sui network, run the following command. | ||
|
||
--fullnode-rpc-port <FULLNODE_RPC_PORT> | ||
Port to start the Fullnode RPC server on [default: 9000] | ||
``` | ||
RUST_LOG="consensus=off" cargo run --bin sui-test-validator | ||
``` | ||
|
||
See more: https://docs.sui.io/build/install#start-the-local-network | ||
## Usage | ||
|
||
## | ||
1. [Relay Transaction to Sui](./docs/evm_to_sui.md) | ||
2. [Relay Transaction to Evm](./docs/sui_to_evm.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## Relay from Evm to Sui | ||
|
||
```ts | ||
import { createSuiRelayer, RelayerType } from '@axelar-network/axelar-local-dev-sui'; | ||
import { ethers } from 'ethers'; | ||
|
||
// Initialize SuiRelayer and EvmRelayer | ||
const { suiRelayer, suiClient } = await initSui(); | ||
const evmRelayer = new EvmRelayer(); | ||
|
||
// Set SuiRelayer to EvmRelayer to allow relaying transactions to Sui Network. | ||
evmRelayer.setRelayer(RelayerType.sui, suiRelayer); | ||
|
||
// Create Evm network named "Evm1" | ||
const evmNetwork = await createNetwork({ | ||
name: 'Evm1', | ||
}); | ||
|
||
// Deploy a contract on Evm1 | ||
const Executable = require('path/to/contract_json'); | ||
const evmContract = await deployContract(evmNetwork.userWallets[0], Executable, [ | ||
evmNetwork.gateway.address, | ||
evmNetwork.gasService.address, | ||
]); | ||
|
||
// Deploy a module on Sui | ||
const pathToModule = '..'; // Specify a path to your move folder containing `Move.toml` file. | ||
const response = await suiClient.deploy(path.join(__dirname, pathToModule)); | ||
// Tips: You can print the transaction digest from `response` and see deployment details here: https://suiexplorer.com/?network=local | ||
|
||
// ### Execute a function on Evm contract | ||
// We use the [TestExecutable contract](../contracts/TestExecutable.sol) as a reference here. | ||
await evmContract.addSibling('sui', `${response.packages[0].packageId}::hello_world`); | ||
await evmContract.set('sui', 'hello from evm', { | ||
value: 10000000, // hardcoded relayer fee, we don't check for the fee right now, so you can specify any fee | ||
}); | ||
|
||
// Relay the transaction to Sui | ||
await evmRekayer.relay(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## Relay from Sui to Evm | ||
|
||
```ts | ||
import { createSuiRelayer, RelayerType } from '@axelar-network/axelar-local-dev-sui'; | ||
import { ethers } from 'ethers'; | ||
|
||
// Initialize SuiRelayer and EvmRelayer | ||
const { suiRelayer, suiClient } = await initSui(); | ||
const evmRelayer = new EvmRelayer(); | ||
|
||
// Set SuiRelayer to EvmRelayer to allow relaying transactions to Sui Network. | ||
evmRelayer.setRelayer(RelayerType.sui, suiRelayer); | ||
|
||
// Create Evm network named "Evm1" | ||
const evmNetwork = await createNetwork({ | ||
name: 'Evm1', | ||
}); | ||
|
||
// Deploy a contract on Evm1 | ||
const Executable = require('path/to/contract_json'); | ||
const evmContract = await deployContract(evmNetwork.userWallets[0], Executable, [ | ||
evmNetwork.gateway.address, | ||
evmNetwork.gasService.address, | ||
]); | ||
|
||
// Deploy a module on Sui | ||
const pathToModule = '..'; // Specify a path to your move folder containing `Move.toml` file. | ||
const response = await suiClient.deploy(path.join(__dirname, pathToModule)); | ||
// Tips: You can print the transaction digest from `response` and see deployment details here: https://suiexplorer.com/?network=local | ||
|
||
// ### Execute a function on Sui module. | ||
// We use the [hello_world module](./move/sample/sources/hello_world.move) as a reference here. | ||
const tx = new TransactionBlock(); | ||
const payload = ethers.utils.defaultAbiCoder.encode(['string'], ['hello from sui']); | ||
tx.moveCall({ | ||
target: `${response.packages[0].packageId}::hello_world::call`, // Note: use the response object above | ||
arguments: [tx.pure(evmNetwork.name), tx.pure(evmContract.address), tx.pure(payload), tx.pure(1)], | ||
}); | ||
// Send a transaction to Sui network. | ||
await client.execute(tx); | ||
|
||
// Relay the transaction to chain Evm1 | ||
await suiRelayer.relay(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters