Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into polkadot-v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp committed Mar 1, 2024
2 parents 160a30b + 8be20aa commit 5e76e2a
Show file tree
Hide file tree
Showing 10 changed files with 38,745 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ members = [
"precompiles/proxy",
"precompiles/preimage",
"precompiles/jobs",
"tangle-subxt"
# "relayer-gadget",
# "relayer-gadget/cli",
]
Expand Down
1 change: 1 addition & 0 deletions node/src/chainspec/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub fn tangle_mainnet_config(chain_id: u64) -> Result<ChainSpec, String> {
mainnet::get_edgeware_genesis_balance_distribution(),
mainnet::get_leaderboard_balance_distribution(),
mainnet::get_substrate_balance_distribution(),
mainnet::get_polkadot_validator_distribution(),
]),
// Genesis investor / team distribution (pallet-balances + pallet-vesting)
combine_distributions(vec![
Expand Down
998 changes: 998 additions & 0 deletions node/src/distributions/data/polkadot_validator_addresses.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions node/src/distributions/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ pub fn get_discord_list() -> Vec<H160> {
read_contents_to_evm_accounts("node/src/distributions/data/discord_evm_addresses.json")
}

pub fn get_polkadot_validator_address_list() -> Vec<AccountId32> {
read_contents_to_substrate_accounts_list(
"node/src/distributions/data/polkadot_validator_addresses.json",
)
}

pub const ONE_TOKEN: u128 = UNIT;
pub const TOTAL_SUPPLY: u128 = 100_000_000 * ONE_TOKEN;
pub const ONE_PERCENT_TOTAL_SUPPLY: u128 = TOTAL_SUPPLY / 100;
Expand Down Expand Up @@ -310,6 +316,21 @@ pub fn get_foundation_balance_distribution() -> Vec<(MultiAddress, u128, u64, u6
compute_balance_distribution_with_cliff_and_vesting(vec![foundation_account])
}

pub fn get_polkadot_validator_distribution() -> DistributionResult {
let list = get_polkadot_validator_address_list();
let endowment = ONE_PERCENT_TOTAL_SUPPLY / list.len() as u128;
let polkadot_validator_dist: Vec<(MultiAddress, u128)> = list
.into_iter()
.map(|address| (MultiAddress::Native(address), endowment))
.collect();
get_distribution_for(
polkadot_validator_dist,
Some(StatementKind::Regular),
ONE_MONTH_BLOCKS,
TWO_YEARS_BLOCKS,
)
}

pub fn compute_balance_distribution_with_cliff_and_vesting(
investor_accounts: Vec<(MultiAddress, u128)>,
) -> Vec<(MultiAddress, u128, u64, u64, u128)> {
Expand Down
29 changes: 29 additions & 0 deletions tangle-subxt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "tangle-subxt"
version ={ workspace = true }
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[dependencies]
parity-scale-codec = { workspace = true, optional = true }
scale-info = { workspace = true, optional = true }
subxt = { version = "0.31.0", optional = true }
subxt-metadata = { version = "0.31.0", optional = true }
subxt-codegen = { version = "0.31.0", optional = true }
serde_json = "1"
syn = { version = "2", features = ["full", "parsing"], optional = true }


[features]
default = [
"subxt",
"subxt-codegen",
"subxt-metadata",
"parity-scale-codec",
"scale-info",
"syn"
]

33 changes: 33 additions & 0 deletions tangle-subxt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<h1 align="center">Tangle-Subxt</h1>

<p align="center">
<strong>Rust interface to interact with tangle node via RPC</strong>
<br />
</p>

<br />

### Downloading metadata from a Substrate node

Use the [`subxt-cli`](https://lib.rs/crates/subxt-cli) tool to download the metadata for your target runtime from a node.

1. Install:
```bash
cargo install subxt-cli
```

2. To Save the metadata of `tangle`:
Run the release build of the `tangle` node, then on another terminal run:

```bash
subxt metadata -f bytes > ./metadata/tangle-runtime.scale
```

3. Generating the subxt code from the metadata:

```bash
subxt codegen --file metadata/tangle-runtime.scale > src/tangle_runtime.rs
```



Binary file added tangle-subxt/metadata/tangle-runtime.scale
Binary file not shown.
14 changes: 14 additions & 0 deletions tangle-subxt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![deny(
trivial_casts,
trivial_numeric_casts,
stable_features,
non_shorthand_field_patterns,
renamed_and_removed_lints,
unsafe_code,
clippy::exhaustive_enums
)]
#![allow(clippy::all, clippy::exhaustive_enums)]
pub mod tangle_runtime;
pub use parity_scale_codec;
pub use scale_info;
pub use subxt;
Loading

0 comments on commit 5e76e2a

Please sign in to comment.