-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AccountAbstraction] Implement SessionKey (#582)
- Loading branch information
Showing
34 changed files
with
1,502 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,39 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::Result; | ||
use moveos::moveos::MoveOS; | ||
use anyhow::{bail, Result}; | ||
use move_core_types::vm_status::KeptVMStatus; | ||
use moveos_store::MoveOSStore; | ||
use moveos_types::module_binding::{ModuleBundle, MoveFunctionCaller}; | ||
use rooch_genesis::RoochGenesis; | ||
use rooch_executor::actor::executor::ExecutorActor; | ||
use rooch_store::RoochStore; | ||
use rooch_types::transaction::AbstractTransaction; | ||
|
||
pub struct RustBindingTest { | ||
moveos: MoveOS, | ||
executor: ExecutorActor, | ||
} | ||
|
||
impl RustBindingTest { | ||
pub fn new() -> Result<Self> { | ||
let moveos_store = MoveOSStore::mock_moveos_store().unwrap(); | ||
let genesis: &RoochGenesis = &rooch_genesis::ROOCH_GENESIS; | ||
|
||
let mut moveos = MoveOS::new(moveos_store, genesis.all_natives(), genesis.config.clone())?; | ||
if moveos.state().is_genesis() { | ||
moveos.init_genesis(genesis.genesis_txs())?; | ||
} | ||
Ok(Self { moveos }) | ||
let moveos_store = MoveOSStore::mock_moveos_store()?; | ||
let rooch_store = RoochStore::mock_rooch_store(); | ||
let executor = ExecutorActor::new(moveos_store, rooch_store)?; | ||
Ok(Self { executor }) | ||
} | ||
|
||
pub fn as_module_bundle<'a, M: ModuleBundle<'a>>(&'a self) -> M { | ||
self.moveos.as_module_bundle::<M>() | ||
self.executor.moveos().as_module_bundle::<M>() | ||
} | ||
|
||
pub fn execute<T: AbstractTransaction>(&mut self, tx: T) -> Result<()> { | ||
let verified_tx = self.executor.validate(tx)?; | ||
let execute_result = self.executor.execute(verified_tx)?; | ||
if execute_result.transaction_info.status != KeptVMStatus::Executed { | ||
bail!( | ||
"tx should success, error: {:?}", | ||
execute_result.transaction_info.status | ||
); | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.