Skip to content

Commit

Permalink
chore(examples): Replace Rococo for Paseo (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
bee344 authored Oct 15, 2024
1 parent 8c5fd1d commit c20c024
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 111 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/lib/*
**/src/*.{d.ts, js.map}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ For example, those looking to construct a transaction offline on Polkadot would

#### Published

- [@substrate/txwrapper-polkadot](modules/txwrapper_polkadot_src.html) Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Rococo, Westend, Asset Hub Polkadot and Asset Hub Kusama.
- [@substrate/txwrapper-polkadot](modules/txwrapper_polkadot_src.html) Helper functions for offline transaction generation for polkadot relay and system chains; specifically the following chains: Polkadot, Kusama, Paseo, Westend, Asset Hub Polkadot and Asset Hub Kusama.
- [@substrate/txwrapper-core](modules/txwrapper_core_src.html) The essentials for creating a chain specific txwrapper lib.
- [@substrate/txwrapper-registry](modules/txwrapper_registry_src.html) Registry creation support, catering to chains with types in [@polkadot/apps-config](https://github.com/polkadot-js/apps/tree/master/packages/apps-config/README.md).
- [@substrate/txwrapper-substrate](modules/txwrapper_substrate_src.html) Selected dispatchables of Substrate pallets, to be re-exported by txwrappers (e.g. @substrate/txwrapper-polkadot).
Expand Down
5 changes: 4 additions & 1 deletion packages/txwrapper-examples/assetHubKusama/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

## Testnet setup

1) First you need to download the binaries for the [node](https://github.com/paritytech/polkadot-sdk/releases): polkadot, polkadot-parachain, polkadot-prepare-worker and polkadot-execute-worker, and place them in the `zombienet/bin/` directory.
1) First you need to clone the repo for the [node](https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2409) and build the binaries, with `features=fast-runtime` in order to shorten the session duration: polkadot, polkadot-parachain, polkadot-prepare-worker and polkadot-execute-worker, and place them in the `zombienet/bin/` directory.

2) You will also need the zombienet executable for your os, which you can download [here](https://github.com/paritytech/zombienet/releases), and place it in the `zombienet` folder.

3) Run the test network from the root of this project with the command `./zombienet/<your-os-zombienet-executable> -p native spawn ./zombienet/config/medium-network.toml | tee zombienet.log`

## Create a Liquidity Pool

4) Now you need to create the asset in the Asset Hub that we'll use in this example via [`polkadot-js/apss`](https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9933), with `assetId = 1` and `decimals = 0`, and mint some to `Alice`.

5) Then you can create a Liquidity Pool with that asset and the chain's native asset:

![](media/poolCreation.png)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ async function main(): Promise<void> {
* }
*/
const nonce = await rpcToLocalNode('account_nextIndex', [alice.address]);
// MultiLocation of the Asset backed by a Liquidity Pool used to pay the fees
/**
* This is the Location of the asset that we'll use to pay the fees.
* It must have a Liquidity Pool against the chain's Native Token.
*/
const asset = {
parents: 0,
interior: {
Expand Down
47 changes: 5 additions & 42 deletions packages/txwrapper-examples/assetHubPolkadot/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,16 @@
# Asset Hub Polkadot/Asset Hub Kusama Sufficient Asset Example:

Note: this example uses the substrate chain `trappist-rococo` which serves as a wrapper for a Asset Hub Polkadot/Asset Hub Kusama environment
Note: this example uses the substrate chain `Paseo Asset Hub` which serves as a wrapper for a Asset Hub Polkadot/Asset Hub Kusama environment

## How to construct a transaction using a sufficient asset to pay fees in `txwrapper-core`

## Get Started

1) Clone & build Trappist
1) First you need to clone the repo for the [node](https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2409) and build the binaries, with `features=fast-runtime` in order to shorten the session duration: polkadot, polkadot-parachain, polkadot-prepare-worker and polkadot-execute-worker, and place them in the `zombienet/bin/` directory.

```bash
git clone -b xcm-demo --depth 1 https://github.com/paritytech/trappist
cd trappist && cargo build –-release
cp ./target/release/trappist-collator ./bin
```

2) Clone & build Polkadot

```bash
git clone -b release-v0.9.23 --depth 1 https://github.com/paritytech/polkadot
cd polkadot && cargo build –-release
cp ./target/release/polkadot ../trappist/bin
```

3) Clone & build Cumulus (*)

```bash
git clone -b xcm-demo --depth 1 https://github.com/stiiifff/cumulus-asset-fees
cd cumulus-asset-fees && cargo build –-release
cp ./target/release/polkadot-parachain ../trappist/bin/polkadot-collator
cp ./target/release/parachain-collator ../trappist/bin
```

4) Install zombienet utility: download the latest binary for your operating system at `https://github.com/paritytech/zombienet/releases`

## Run Local Zombienet test nodes

5) Copy the zombienet binary in the root directory of the Trappist repository, and then launch the local environment. Example:

bash
```
./zombienet-macos -p native spawn xcm-playground.toml | tee zombienet.log
```

6) Open the `Trappist Local` node in `Polkadot.js` apps: Once the various test nodes have been started, open a browser window with the Polkadot.js apps for the node you wish to use (e.g. check the ws port for `trappist-collator01` in the zombienet console output and provide it as a custom port in polkadot.js).

Mac: cat zombienet.log | grep -Eo 'https://polkadot.js.org/apps/.+' | xargs open -a /Applications/Google\ Chrome.app
Linux: cat zombienet.log | grep -Eo 'https://polkadot.js.org/apps/.+' | xargs google-chrome
2) You will also need the zombienet executable for your os, which you can download [here](https://github.com/paritytech/zombienet/releases), and place it in the `zombienet` folder.

Alternatively, use the direct link given in zombienets console output: (example direct link output: https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:54303#/explorer. Note: your ws port will be different.)
3) Run the test network from the root of this project with the command `./zombienet/<your-os-zombienet-executable> -p native spawn ./zombienet/config/medium-network.toml | tee zombienet.log`

## Create a test Asset in Polkadot.js Apps

Expand All @@ -68,7 +31,7 @@ Note for this step: If an `orange` icon appears in the top right after submittin
10) Install dependencies and build the JS target

```bash
# from this repos root directory run
# from this repo\'s root directory run
yarn install && yarn build

# change to the examples directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function main(): Promise<void> {
const alice = keyring.addFromUri('//Alice', { name: 'Alice' }, 'sr25519');
console.log(
"Alice's SS58-Encoded Address:",
deriveAddress(alice.publicKey, PolkadotSS58Format.westend),
deriveAddress(alice.publicKey, PolkadotSS58Format.polkadot),
);

// Construct a balance transfer transaction offline.
Expand Down Expand Up @@ -66,12 +66,30 @@ async function main(): Promise<void> {
* ```
*/
const registry = getRegistry({
chainName: 'trappist-rococo',
chainName: 'statemint',
specName,
specVersion,
metadataRpc,
});

/**
* This is the Location of the asset that we'll use to pay the fees.
* It must have a Liquidity Pool against the chain's Native Token.
*/
const asset = {
parents: 0,
interior: {
X2: [
{
palletInstance: 50,
},
{
generalIndex: 6543,
},
],
},
};

/**
* Now we can create our `balances.transferKeepAlive` unsigned tx. The following
* function takes the above data as arguments, so it can be performed offline
Expand All @@ -93,8 +111,8 @@ async function main(): Promise<void> {
dest: { id: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty' }, // Bob
},
{
address: deriveAddress(alice.publicKey, PolkadotSS58Format.westend),
assetId: 1, // id of sufficient asset used to pay for fees
address: deriveAddress(alice.publicKey, PolkadotSS58Format.polkadot),
assetId: asset,
blockHash,
blockNumber: registry
.createType('BlockNumber', block.header.number)
Expand Down
6 changes: 3 additions & 3 deletions packages/txwrapper-examples/foreignAssets/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Asset Hub Kusama Foreign Asset Example

Note: this example uses the substrate chain `Asset Hub Rococo` which serves as a wrapper for a Asset Hub Polkadot/Asset Hub Kusama environment
Note: this example uses the substrate chain `Paseo Asset Hub` which serves as a wrapper for a Asset Hub Polkadot/Asset Hub Kusama environment

## How to construct a foreign asset transfer

Expand All @@ -9,7 +9,7 @@ Note: this example uses the substrate chain `Asset Hub Rococo` which serves as a
1) Clone & build Polkadot

```bash
git clone https://github.com/paritytech/polkadot-sdk
git clone https://github.com/paritytech/polkadot-sdk/tree/polkadot-stable2409
cd polkadot-sdk
cargo build --release --features fast-runtime --bin polkadot
cargo build --release --features fast-runtime --bin polkadot-prepare-worker
Expand All @@ -30,7 +30,7 @@ Note: this example uses the substrate chain `Asset Hub Rococo` which serves as a
bash

```
./zombienet/zombienet-linux-x64 -p native spawn ./zombienet/config/asset-hub.toml | tee zombienet.log
./zombienet/<your-os-zombienet-executable> -p native spawn ./zombienet/config/medium-network.toml | tee zombienet.log
```

## Construct and mock an example foreign asset transfer transaction in Txwrapper-Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function main(): Promise<void> {
const alice = keyring.addFromUri('//Alice', { name: 'Alice' }, 'sr25519');
console.log(
"Alice's SS58-Encoded Address:",
deriveAddress(alice.publicKey, PolkadotSS58Format.westend),
deriveAddress(alice.publicKey, PolkadotSS58Format.polkadot),
);

// Construct a balance transfer transaction offline.
Expand Down Expand Up @@ -66,7 +66,7 @@ async function main(): Promise<void> {
* ```
*/
const registry = getRegistry({
chainName: 'Rococo Asset Hub',
chainName: 'asset-hub-paseo',
specName,
specVersion,
metadataRpc,
Expand All @@ -91,10 +91,10 @@ async function main(): Promise<void> {
{
amount: '10000000000000',
target: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', // Bob
id: { parents: 1, interior: { X1: { Parachain: 1836 } } },
id: { parents: 1, interior: { X1: { Parachain: 3369 } } },
},
{
address: deriveAddress(alice.publicKey, PolkadotSS58Format.westend),
address: deriveAddress(alice.publicKey, PolkadotSS58Format.polkadot),
blockHash,
blockNumber: registry
.createType('BlockNumber', block.header.number)
Expand Down
4 changes: 2 additions & 2 deletions packages/txwrapper-polkadot/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<br /><br />

<h1 align="center">@substrate/txwrapper-polkadot</h1>
<h4 align="center">Helper functions for Polkadot, Kusama, Rococo and Westend offline transaction generation.</h4>
<h4 align="center">Helper functions for Polkadot, Kusama, Paseo and Westend offline transaction generation.</h4>

<p align="center">
<a href="https://www.npmjs.com/package/@substrate/txwrapper-polkadot">
Expand All @@ -19,7 +19,7 @@

# About

Txwrapper library for polkadot relay and system chains; specifically Polkadot, Kusama, Rococo, Westend, Asset Hub Polkadot and Asset Hub Kusama.
Txwrapper library for polkadot relay and system chains; specifically Polkadot, Kusama, Paseo, Westend, Asset Hub Polkadot and Asset Hub Kusama.

Note: not all methods available apply to all supported chains. To check what methods are supported by a chain consult the pallets included in chain's runtime.

Expand Down
2 changes: 1 addition & 1 deletion packages/txwrapper-polkadot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@substrate/txwrapper-polkadot",
"version": "7.5.1",
"author": "Parity Technologies <[email protected]>",
"description": "Helper functions for Polkadot, Kusama, Rococo and Westend offline transaction generation.",
"description": "Helper functions for Polkadot, Kusama, Paseo and Westend offline transaction generation.",
"license": "Apache-2.0",
"main": "lib/index.js",
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/txwrapper-polkadot/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Helper functions for Polkadot, Kusama, Rococo and Westend offline transaction generation.
* Helper functions for Polkadot, Kusama, Paseo and Westend offline transaction generation.
*
* @module txwrapper-polkadot
*/
Expand All @@ -14,7 +14,7 @@ import { methods as substrateMethods } from '@substrate/txwrapper-substrate';

import * as polkadotMethods from './methods';

// Export methods of pallets included in the Polkadot, Kusama, Westend, Rococo,
// Export methods of pallets included in the Polkadot, Kusama, Westend, Paseo,
// Asset Hub Polkadot and Asset Hub Kusama runtimes.
// Note: in the future this may also include methods defined within this package
// that do not exist in Substrate.
Expand Down
107 changes: 107 additions & 0 deletions zombienet/config/asset-hub-paseo-local.plain.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions zombienet/config/asset-hub.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[relaychain]
default_command = "./bin/polkadot"
default_command = "../polkadot"
default_args = [ "-lparachain=debug" ]
chain = "rococo-local"
chain_spec_path = "./paseo-local.plain.json"

[[relaychain.nodes]]
name = "alice"
Expand All @@ -27,17 +27,17 @@ chain = "rococo-local"
[[parachains]]
id = 1000
addToGenesis = true
chain = "asset-hub-rococo-local"
chain_spec_path = "./asset-hub-paseo-local.plain.json"
cumulus_based = true

[[parachains.collators]]
name = "rockmint-collator01"
command = "./bin/polkadot-parachain"
name = "paseo-asset-hub-collator01"
command = "../polkadot-parachain"
args = ["--log=xcm=trace,pallet-assets=trace"]
ws_port = 9933

[[parachains.collators]]
name = "rockmint-collator02"
command = "./bin/polkadot-parachain"
name = "paseo-asset-hub-collator02"
command = "../polkadot-parachain"
ws_port = 9911
args = ["--log=xcm=trace,pallet-assets=trace"]
43 changes: 0 additions & 43 deletions zombienet/config/medium-network.toml

This file was deleted.

196 changes: 196 additions & 0 deletions zombienet/config/paseo-local.plain.json

Large diffs are not rendered by default.

0 comments on commit c20c024

Please sign in to comment.