Skip to content

Commit

Permalink
[types] Migrate module bindings from rooch-framework to rooch-types (#…
Browse files Browse the repository at this point in the history
…623)

* [types] Move module bindings from rooch-framework to rooch-types

* fixup
  • Loading branch information
jolestar authored Aug 14, 2023
1 parent 11110ba commit 45f0f35
Show file tree
Hide file tree
Showing 23 changed files with 202 additions and 217 deletions.
6 changes: 3 additions & 3 deletions crates/rooch-executor/src/actor/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ use moveos_types::transaction::FunctionCall;
use moveos_types::transaction::TransactionExecutionInfo;
use moveos_types::transaction::VerifiedMoveOSTransaction;
use moveos_types::tx_context::TxContext;
use rooch_framework::bindings::address_mapping::AddressMapping;
use rooch_framework::bindings::auth_validator::AuthValidatorCaller;
use rooch_framework::bindings::transaction_validator::TransactionValidator;
use rooch_genesis::RoochGenesis;
use rooch_store::RoochStore;
use rooch_types::address::MultiChainAddress;
use rooch_types::framework::address_mapping::AddressMapping;
use rooch_types::framework::auth_validator::AuthValidatorCaller;
use rooch_types::framework::auth_validator::TxValidateResult;
use rooch_types::framework::transaction_validator::TransactionValidator;
use rooch_types::transaction::AuthenticatorInfo;
use rooch_types::transaction::{AbstractTransaction, TransactionSequenceMapping};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use moveos_types::transaction::MoveAction;
use rooch_framework::bindings::empty::Empty;
use rooch_key::keystore::{AccountKeystore, InMemKeystore};
use rooch_types::framework::empty::Empty;
use rooch_types::{
crypto::BuiltinScheme,
transaction::{rooch::RoochTransactionData, AbstractTransaction},
Expand All @@ -15,7 +15,7 @@ use crate::binding_test;
fn test_validate() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let ecdsa_k1_recoverable_validator = binding_test
.as_module_bundle::<rooch_framework::bindings::ecdsa_k1_recoverable_validator::EcdsaK1RecoverableValidator>(
.as_module_bundle::<rooch_types::framework::ecdsa_k1_recoverable_validator::EcdsaK1RecoverableValidator>(
);

let keystore = InMemKeystore::new_ecdsa_recoverable_insecure_for_tests(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use moveos_types::transaction::MoveAction;
use rooch_framework::bindings::empty::Empty;
use rooch_key::keystore::{AccountKeystore, InMemKeystore};
use rooch_types::framework::empty::Empty;
use rooch_types::{
crypto::BuiltinScheme,
transaction::{rooch::RoochTransactionData, AbstractTransaction},
Expand All @@ -15,7 +15,7 @@ use crate::binding_test;
fn test_validate() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let ecdsa_k1_validator = binding_test
.as_module_bundle::<rooch_framework::bindings::ecdsa_k1_validator::EcdsaK1Validator>(
.as_module_bundle::<rooch_types::framework::ecdsa_k1_validator::EcdsaK1Validator>(
);

let keystore = InMemKeystore::new_ecdsa_insecure_for_tests(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use moveos_types::transaction::MoveAction;
use rooch_framework::bindings::empty::Empty;
use rooch_key::keystore::{AccountKeystore, InMemKeystore};
use rooch_types::framework::empty::Empty;
use rooch_types::{
crypto::BuiltinScheme,
transaction::{rooch::RoochTransactionData, AbstractTransaction},
Expand All @@ -15,8 +15,7 @@ use crate::binding_test;
fn test_validate() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let ed25519_validator = binding_test
.as_module_bundle::<rooch_framework::bindings::ed25519_validator::Ed25519Validator>(
);
.as_module_bundle::<rooch_types::framework::ed25519_validator::Ed25519Validator>();

let keystore = InMemKeystore::new_ed25519_insecure_for_tests(1);
let sender = keystore.addresses()[0];
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-framework-tests/src/tests/empty_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use moveos_types::tx_context::TxContext;
#[test]
fn test_empty() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let empty = binding_test.as_module_bundle::<rooch_framework::bindings::empty::Empty>();
let empty = binding_test.as_module_bundle::<rooch_types::framework::empty::Empty>();
let ctx = TxContext::random_for_testing_only();
empty.empty(&ctx).unwrap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use moveos_types::transaction::MoveAction;
use rooch_framework::bindings::empty::Empty;
use rooch_key::keystore::{AccountKeystore, InMemKeystore};
use rooch_types::framework::empty::Empty;
use rooch_types::{
crypto::BuiltinScheme,
transaction::{rooch::RoochTransactionData, AbstractTransaction},
Expand All @@ -15,8 +15,7 @@ use crate::binding_test;
fn test_validate() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let schnorr_validator = binding_test
.as_module_bundle::<rooch_framework::bindings::schnorr_validator::SchnorrValidator>(
);
.as_module_bundle::<rooch_types::framework::schnorr_validator::SchnorrValidator>();

let keystore = InMemKeystore::new_schnorr_insecure_for_tests(1);
let sender = keystore.addresses()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use moveos_types::{module_binding::ModuleBundle, transaction::MoveAction};
use rooch_framework::{bindings::empty::Empty, ROOCH_FRAMEWORK_ADDRESS};
use rooch_key::keystore::{AccountKeystore, InMemKeystore};
use rooch_types::{addresses::ROOCH_FRAMEWORK_ADDRESS, framework::empty::Empty};
use rooch_types::{
crypto::BuiltinScheme,
framework::session_key::SessionScope,
Expand All @@ -15,7 +15,9 @@ use crate::binding_test;
#[test]
fn test_validate_ed25519() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let transaction_validator = binding_test.as_module_bundle::<rooch_framework::bindings::transaction_validator::TransactionValidator>();
let transaction_validator = binding_test
.as_module_bundle::<rooch_types::framework::transaction_validator::TransactionValidator>(
);

let keystore = InMemKeystore::new_ed25519_insecure_for_tests(1);
let sender = keystore.addresses()[0];
Expand All @@ -36,7 +38,9 @@ fn test_validate_ed25519() {
#[test]
fn test_validate_ecdsa() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let transaction_validator = binding_test.as_module_bundle::<rooch_framework::bindings::transaction_validator::TransactionValidator>();
let transaction_validator = binding_test
.as_module_bundle::<rooch_types::framework::transaction_validator::TransactionValidator>(
);

let keystore = InMemKeystore::new_ecdsa_insecure_for_tests(1);
let sender = keystore.addresses()[0];
Expand All @@ -57,7 +61,9 @@ fn test_validate_ecdsa() {
#[test]
fn test_validate_ecdsa_recoverable() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let transaction_validator = binding_test.as_module_bundle::<rooch_framework::bindings::transaction_validator::TransactionValidator>();
let transaction_validator = binding_test
.as_module_bundle::<rooch_types::framework::transaction_validator::TransactionValidator>(
);

let keystore = InMemKeystore::new_ecdsa_recoverable_insecure_for_tests(1);
let sender = keystore.addresses()[0];
Expand All @@ -78,7 +84,9 @@ fn test_validate_ecdsa_recoverable() {
#[test]
fn test_validate_schnorr() {
let binding_test = binding_test::RustBindingTest::new().unwrap();
let transaction_validator = binding_test.as_module_bundle::<rooch_framework::bindings::transaction_validator::TransactionValidator>();
let transaction_validator = binding_test
.as_module_bundle::<rooch_types::framework::transaction_validator::TransactionValidator>(
);

let keystore = InMemKeystore::new_schnorr_insecure_for_tests(1);
let sender = keystore.addresses()[0];
Expand Down Expand Up @@ -113,22 +121,21 @@ fn test_session_key_ed25519() {
);
let expiration_time = 100;
let max_inactive_interval = 100;
let action =
rooch_framework::bindings::session_key::SessionKeyModule::create_session_key_action(
auth_key.clone(),
BuiltinScheme::Ed25519,
session_scope.clone(),
expiration_time,
max_inactive_interval,
);
let action = rooch_types::framework::session_key::SessionKeyModule::create_session_key_action(
auth_key.clone(),
BuiltinScheme::Ed25519,
session_scope.clone(),
expiration_time,
max_inactive_interval,
);
let tx_data = RoochTransactionData::new(sender, sequence_number, action);
let tx = keystore
.sign_transaction(&sender, tx_data, BuiltinScheme::Ed25519)
.unwrap();
binding_test.execute(tx).unwrap();

let session_key_module =
binding_test.as_module_bundle::<rooch_framework::bindings::session_key::SessionKeyModule>();
binding_test.as_module_bundle::<rooch_types::framework::session_key::SessionKeyModule>();
let session_key_option = session_key_module
.get_session_key(sender.into(), auth_key)
.unwrap();
Expand Down
64 changes: 0 additions & 64 deletions crates/rooch-framework/src/bindings/auth_validator.rs

This file was deleted.

12 changes: 0 additions & 12 deletions crates/rooch-framework/src/bindings/mod.rs

This file was deleted.

89 changes: 0 additions & 89 deletions crates/rooch-framework/src/bindings/session_key.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/rooch-framework/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

pub mod bindings;
pub mod natives;

pub use rooch_types::addresses::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::ROOCH_FRAMEWORK_ADDRESS;
use crate::address::{MultiChainAddress, RoochAddress};
use crate::addresses::ROOCH_FRAMEWORK_ADDRESS;
use anyhow::Result;
use move_core_types::{account_address::AccountAddress, ident_str, identifier::IdentStr};
use moveos_types::{
Expand All @@ -11,7 +12,6 @@ use moveos_types::{
transaction::FunctionCall,
tx_context::TxContext,
};
use rooch_types::address::{MultiChainAddress, RoochAddress};

/// Rust bindings for RoochFramework address_mapping module
pub struct AddressMapping<'a> {
Expand Down
Loading

0 comments on commit 45f0f35

Please sign in to comment.