Skip to content

Commit

Permalink
feat: Initial distribution setup
Browse files Browse the repository at this point in the history
  • Loading branch information
1xstj committed Jan 11, 2024
1 parent 4387d9e commit 2cc5ea1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 20 deletions.
21 changes: 11 additions & 10 deletions node/src/chainspec/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ pub fn local_mainnet_config(chain_id: u64) -> Result<ChainSpec, String> {
properties.insert("tokenDecimals".into(), 18u32.into());
properties.insert("ss58Format".into(), tangle_primitives::MAINNET_SS58_PREFIX.into());

let endowment: Balance = 10_000_000 * UNIT;

Ok(ChainSpec::from_genesis(
"Local Tangle Mainnet",
"local-tangle-mainnet",
Expand All @@ -109,12 +111,12 @@ pub fn local_mainnet_config(chain_id: u64) -> Result<ChainSpec, String> {
],
// Endowed accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
(get_account_id_from_seed::<sr25519::Public>("Alice"), endowment),
(get_account_id_from_seed::<sr25519::Public>("Bob"), endowment),
(get_account_id_from_seed::<sr25519::Public>("Charlie"), endowment),
(get_account_id_from_seed::<sr25519::Public>("Alice//stash"), endowment),
(get_account_id_from_seed::<sr25519::Public>("Bob//stash"), endowment),
(get_account_id_from_seed::<sr25519::Public>("Charlie//stash"), endowment),
],
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand Down Expand Up @@ -166,7 +168,7 @@ pub fn tangle_mainnet_config(chain_id: u64) -> Result<ChainSpec, String> {
// Initial validators
get_initial_authorities(),
// Endowed accounts
vec![],
vec![mainnet::get_treasury_balance(), mainnet::get_foundation_balance()],
// Sudo account
get_root_key(),
// EVM chain ID
Expand Down Expand Up @@ -204,13 +206,12 @@ pub fn tangle_mainnet_config(chain_id: u64) -> Result<ChainSpec, String> {
fn mainnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(AccountId, BabeId, GrandpaId, ImOnlineId)>,
endowed_accounts: Vec<AccountId>,
endowed_accounts: Vec<(AccountId, Balance)>,
root_key: AccountId,
chain_id: u64,
genesis_airdrop: DistributionResult,
genesis_non_airdrop: Vec<(MultiAddress, u128, u64, u64, u128)>,
) -> RuntimeGenesisConfig {
const ENDOWMENT: Balance = 10_000_000 * UNIT;
// stakers: all validators and nominators.
let stakers = initial_authorities
.iter()
Expand Down Expand Up @@ -242,7 +243,7 @@ fn mainnet_genesis(
balances: genesis_non_airdrop
.iter()
.map(|(x, y, _, _, _)| (x.clone().to_account_id_32(), *y))
.chain(endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)))
.chain(endowed_accounts.into_iter())
.collect(),
},
vesting: VestingConfig {
Expand Down
4 changes: 4 additions & 0 deletions node/src/distributions/data/webb_investor_distributions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"5FTwaz65zTMaBcW6vddcmSuyJR4paQkw8w7ZKPMGr4bWrwpj": 1000000000000000,
"5CX31Aw4yEF4sSgr65WQDMCBn97f3K98VL4kMq64aBt3HFu7": 1000000000000000
}
4 changes: 4 additions & 0 deletions node/src/distributions/data/webb_team_distributions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"5FTwaz65zTMaBcW6vddcmSuyJR4paQkw8w7ZKPMGr4bWrwpj": 1000000000000000,
"5CX31Aw4yEF4sSgr65WQDMCBn97f3K98VL4kMq64aBt3HFu7": 1000000000000000
}
45 changes: 35 additions & 10 deletions node/src/distributions/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
//
// You should have received a copy of the GNU General Public License
// along with Tangle. If not, see <http://www.gnu.org/licenses/>.
use std::str::FromStr;
use tangle_primitives::types::BlockNumber;
use tangle_runtime::UNIT;

use super::testnet::{get_git_root, read_contents, read_contents_to_evm_accounts};
use pallet_airdrop_claims::{EthereumAddress, MultiAddress, StatementKind};
use sp_core::H160;
use sp_runtime::AccountId32;
use std::collections::BTreeMap;
use sp_runtime::{traits::AccountIdConversion, AccountId32};
use std::{collections::BTreeMap, str::FromStr};
use tangle_primitives::types::BlockNumber;
use tangle_runtime::UNIT;
use tangle_testnet_runtime::{AccountId, Balance, ExistentialDeposit};

/// The contents of the file should be a map of accounts to balances.
Expand Down Expand Up @@ -68,6 +66,16 @@ fn get_edgeware_snapshot_list() -> BTreeMap<AccountId32, f64> {
)
}

fn get_team_balance_distribution_list() -> BTreeMap<AccountId32, f64> {
read_contents_to_substrate_accounts("node/src/distributions/data/webb_team_distribution.json")
}

fn get_investor_balance_distribution_list() -> BTreeMap<AccountId32, f64> {
read_contents_to_substrate_accounts(
"node/src/distributions/data/webb_investor_distribution.json",
)
}

pub fn get_discord_list() -> Vec<H160> {
read_contents_to_evm_accounts("node/src/distributions/data/discord_evm_addresses.json")
}
Expand Down Expand Up @@ -178,17 +186,34 @@ pub fn get_substrate_balance_distribution() -> DistributionResult {
}

pub fn get_investor_balance_distribution() -> Vec<(MultiAddress, u128, u64, u64, u128)> {
// TODO : Read from actual investor file
let investor_accounts: Vec<(MultiAddress, u128)> = vec![];
let investor_accounts: Vec<(MultiAddress, u128)> = get_investor_balance_distribution_list()
.into_iter()
.map(|(address, balance)| (MultiAddress::Native(address), balance as u128))
.collect();
compute_balance_distribution_with_cliff_and_vesting(investor_accounts)
}

pub fn get_team_balance_distribution() -> Vec<(MultiAddress, u128, u64, u64, u128)> {
// TODO : Read from actual team file
let team_accounts: Vec<(MultiAddress, u128)> = vec![];
let team_accounts: Vec<(MultiAddress, u128)> = get_team_balance_distribution_list()
.into_iter()
.map(|(address, balance)| (MultiAddress::Native(address), balance as u128))
.collect();
compute_balance_distribution_with_cliff_and_vesting(team_accounts)
}

pub fn get_treasury_balance() -> (AccountId, u128) {
let pallet_id = tangle_primitives::treasury::TREASURY_PALLET_ID;
let acc: AccountId = pallet_id.into_account_truncating();
(acc, UNIT * 100_000)
}

pub fn get_foundation_balance() -> (AccountId, u128) {
// TODO : Setup foundation account here
let pallet_id = tangle_primitives::treasury::TREASURY_PALLET_ID;
let acc: AccountId = pallet_id.into_account_truncating();
(acc, UNIT * 100_000)
}

pub fn compute_balance_distribution_with_cliff_and_vesting(
investor_accounts: Vec<(MultiAddress, u128)>,
) -> Vec<(MultiAddress, u128, u64, u64, u128)> {
Expand Down

0 comments on commit 2cc5ea1

Please sign in to comment.