Skip to content

Commit

Permalink
hotfix(katana): account generations (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Nov 19, 2024
1 parent 89de0ab commit 2eb7fe8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ serde = "1"
serde_json = "1"
thiserror = "1.0.32"
url = "2.2.2"
rand = "0.8.4"
starknet = "0.12.0"
19 changes: 13 additions & 6 deletions cli/src/command/deployments/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use std::str::FromStr;
use anyhow::Result;
use clap::Args;
use katana_primitives::contract::ContractAddress;
use katana_primitives::genesis::allocation::GenesisAccountAlloc;
use katana_primitives::genesis::allocation::{
DevAllocationsGenerator, DevGenesisAccount, GenesisAccount,
};
use katana_primitives::genesis::allocation::{DevAllocationsGenerator, GenesisAccountAlloc};
use katana_primitives::genesis::allocation::{DevGenesisAccount, GenesisAccount};
use katana_primitives::genesis::Genesis;
use slot::graphql::deployments::katana_accounts::KatanaAccountsDeploymentConfig::KatanaConfig;
use slot::graphql::deployments::{katana_accounts::*, KatanaAccounts};
Expand Down Expand Up @@ -69,8 +67,15 @@ impl AccountsArgs {
print_genesis_accounts(accounts_vec.iter().map(|(a, b)| (a, b)), None);
}
None => {
let accounts = DevAllocationsGenerator::new(10)
.with_seed(parse_seed(&config.seed))
// NOTICE: This is implementation assume that the Katana instance is configured with the default seed and total number of accounts. If not, the
// generated addresses will be different from the ones in the Katana instance. This is rather a hack until `slot` can return the addresses directly (or
// at least the exact configurations of the instance).

let seed = "0";
let total_accounts = 10;

let accounts = DevAllocationsGenerator::new(total_accounts)
.with_seed(parse_seed(seed))
.generate();

let mut genesis = Genesis::default();
Expand Down Expand Up @@ -127,6 +132,8 @@ ACCOUNTS SEED
}
}

// Mimic how Katana parse the seed to generate the predeployed accounts
// https://github.com/dojoengine/dojo/blob/85c0b025f108bd1ed64a5b35cfb574f61545a0ff/crates/katana/cli/src/utils.rs#L24-L34
fn parse_seed(seed: &str) -> [u8; 32] {
let seed = seed.as_bytes();

Expand Down

0 comments on commit 2eb7fe8

Please sign in to comment.