mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-08-27 07:41:11 +00:00
feat: first scenario implemented
This commit is contained in:
@@ -103,12 +103,8 @@ impl NodeCore {
|
||||
|
||||
let genesis_block = client.get_block(genesis_id.genesis_id).await?.block;
|
||||
|
||||
let initial_accounts_ser = client.get_initial_testnet_accounts().await?;
|
||||
let initial_accounts: Vec<Account> =
|
||||
initial_accounts_ser.into_iter().map(Into::into).collect();
|
||||
|
||||
let (mut storage, mut chain_height) = NodeChainStore::new(config.clone(), genesis_block)?;
|
||||
for acc in initial_accounts {
|
||||
for acc in config.clone().initial_accounts {
|
||||
storage.acc_map.insert(acc.address, acc);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,3 +46,11 @@ pub struct SequencerRpcResponse {
|
||||
pub result: serde_json::Value,
|
||||
pub id: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
///Helperstruct for account serialization
|
||||
pub struct AccountInitialData {
|
||||
///Hex encoded `AccountAddress`
|
||||
pub addr: String,
|
||||
pub balance: u64,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use accounts::account_core::{Account, AccountForSerialization};
|
||||
use accounts::account_core::Account;
|
||||
use anyhow::Result;
|
||||
use common::rpc_primitives::requests::{
|
||||
GetBlockDataRequest, GetBlockDataResponse, GetGenesisIdRequest, GetGenesisIdResponse,
|
||||
GetInitialTestnetAccountsRequest, RegisterAccountRequest, RegisterAccountResponse,
|
||||
GetAccountBalanceRequest, GetAccountBalanceResponse, GetBlockDataRequest, GetBlockDataResponse, GetGenesisIdRequest, GetGenesisIdResponse, GetInitialTestnetAccountsRequest, RegisterAccountRequest, RegisterAccountResponse
|
||||
};
|
||||
use common::transaction::Transaction;
|
||||
use common::{SequencerClientError, SequencerRpcError};
|
||||
@@ -11,6 +10,7 @@ use reqwest::Client;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::config::NodeConfig;
|
||||
use crate::sequencer_client::json::AccountInitialData;
|
||||
|
||||
pub mod json;
|
||||
|
||||
@@ -69,6 +69,21 @@ impl SequencerClient {
|
||||
Ok(resp_deser)
|
||||
}
|
||||
|
||||
pub async fn get_account_balance(
|
||||
&self,
|
||||
address: String,
|
||||
) -> Result<GetAccountBalanceResponse, SequencerClientError> {
|
||||
let block_req = GetAccountBalanceRequest { address };
|
||||
|
||||
let req = serde_json::to_value(block_req)?;
|
||||
|
||||
let resp = self.call_method_with_payload("get_account_balance", req).await?;
|
||||
|
||||
let resp_deser = serde_json::from_value(resp)?;
|
||||
|
||||
Ok(resp_deser)
|
||||
}
|
||||
|
||||
pub async fn send_tx(
|
||||
&self,
|
||||
transaction: Transaction,
|
||||
@@ -124,7 +139,7 @@ impl SequencerClient {
|
||||
|
||||
pub async fn get_initial_testnet_accounts(
|
||||
&self,
|
||||
) -> Result<Vec<AccountForSerialization>, SequencerClientError> {
|
||||
) -> Result<Vec<AccountInitialData>, SequencerClientError> {
|
||||
let acc_req = GetInitialTestnetAccountsRequest {};
|
||||
|
||||
let req = serde_json::to_value(acc_req).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user