Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update codegen #87

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions scripts/fund-dev-accounts/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# Funding Dev Accounts

As Pop Network uses the Relay chain token as the native token, the dev accounts (alice, bob, etc) are not funded on Pop Network by default.
Therefore, after network launch there needs to be a reserve transfer from the Relay chain to the dev accounts on Pop Network.
This script performs these reserve transfers to fund the dev accounts from the Relay chain.
As Pop Network uses the Relay chain token as the native token, the dev accounts (alice, bob, etc) are intentionally not
funded on Pop Network by default. Therefore, after network launch there needs to be a reserve transfer from the Relay
chain to these accounts on Pop Network. This script performs these reserve transfers to fund the dev accounts from the
Relay chain.

## Running the script

1. Spin up a Polkadot Network locally with Pop Network running
2. In the `main.rs` file change:
- the `PARA_ID` to the paraId of Pop Network e.g. `9090`
- change the `relay_api` port number to the port number of the Relay chain running on your machine
- change the `pop_api` port number to the port number of Pop Network running on your machince
3. Run the script
2. Run the script

```
```shell
cargo run
```

### Troubleshooting

Pop Network is ongoing constant new updates and features to its runtime. It is common for the metadata to be out-dated.
Therefore if you run this script and get the following errro:
```
Pop Network is ongoing constant new updates and features to its runtime. It is common for the metadata to be outdated.
Therefore if you run this script and get the following error:

```shell
cargo run
Compiling fund-dev-accounts v0.0.0 (/Users/bruno/src/pop-node/scripts/fund-dev-accounts)
Finished dev [unoptimized + debuginfo] target(s) in 7.21s
Expand All @@ -31,16 +29,16 @@ Error: Metadata(IncompatibleCodegen)

It means you will need to update the metadata.

You can do so by running:
You can do so by running the follow commands within `scripts/fund-dev-accounts`:

```
subxt codegen --url ws://127.0.0.1:58043 | rustfmt > rococo_interface.rs
subxt codegen --url ws://127.0.0.1:58051 | rustfmt > pop_interface.rs
subxt codegen --url ws://127.0.0.1:8833 | rustfmt > rococo_interface.rs
subxt codegen --url ws://127.0.0.1:9944 | rustfmt > pop_interface.rs
```

In this example, `58043` is the port number of the Relay chain and `58051` is the port number of Pop Network.
Once the metadata has been updated, re-run the script:

Once the metadata has been updated, re-run your script:
```
```shell
cargo run
```

11 changes: 9 additions & 2 deletions scripts/fund-dev-accounts/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ use subxt_signer::sr25519::{dev, Keypair};

use std::time::Duration;

// subxt codegen --url ws://localhost:8833 | rustfmt > paseo_interface.rs
#[cfg(feature = "paseo")]
mod paseo_interface;

// subxt codegen --url ws://localhost:8833 | rustfmt > rococo_interface.rs
#[cfg(not(feature = "paseo"))]
mod rococo_interface;

// subxt codegen --url ws://localhost:9944 | rustfmt > pop_interface.rs
mod pop_interface;

const PARA_ID: u32 = 4385;

#[cfg(not(feature = "paseo"))]
mod relay {
use super::*;
pub(crate) use crate::rococo_interface::api as runtime;

const PARA_ID: u32 = 4385;

pub(crate) type RuntimeCall = runtime::runtime_types::rococo_runtime::RuntimeCall;
pub(crate) const UNIT: u128 = 1_000_000_000_000;

Expand Down Expand Up @@ -73,6 +78,8 @@ mod relay {
use super::*;
pub(crate) use crate::paseo_interface::api as runtime;

const PARA_ID: u32 = 4001;

pub(crate) type RuntimeCall = runtime::runtime_types::paseo_runtime::RuntimeCall;
pub(crate) const UNIT: u128 = 10_000_000_000;

Expand Down
Loading
Loading