diff --git a/crates/rooch-framework-tests/src/tests/bitcoin_multisign_validator_tests.rs b/crates/rooch-framework-tests/src/tests/bitcoin_multisign_validator_tests.rs index dc9e24d4dc..ca19957967 100644 --- a/crates/rooch-framework-tests/src/tests/bitcoin_multisign_validator_tests.rs +++ b/crates/rooch-framework-tests/src/tests/bitcoin_multisign_validator_tests.rs @@ -6,14 +6,14 @@ use move_core_types::u256::U256; use moveos_types::module_binding::MoveFunctionCaller; use moveos_types::state::MoveStructType; use moveos_types::transaction::{MoveAction, MoveOSTransaction}; +use rooch_types::bitcoin::bitcoin_multisign_validator::BitcoinMultisignValidatorModule; +use rooch_types::bitcoin::multisign_account::{self, MultisignAccountModule}; use rooch_types::crypto::{RoochKeyPair, RoochSignature}; use rooch_types::framework::auth_payload::{MultisignAuthPayload, SignData}; use rooch_types::framework::auth_validator::BuiltinAuthValidator; use rooch_types::framework::empty::Empty; use rooch_types::framework::gas_coin::GasCoin; use rooch_types::framework::transfer::TransferModule; -use rooch_types::nursery::bitcoin_multisign_validator::BitcoinMultisignValidatorModule; -use rooch_types::nursery::multisign_account::{self, MultisignAccountModule}; use rooch_types::transaction::rooch::RoochTransactionData; use rooch_types::transaction::{Authenticator, RoochTransaction}; diff --git a/crates/rooch-framework-tests/src/tests/multisign_account_tests.rs b/crates/rooch-framework-tests/src/tests/multisign_account_tests.rs index c6c5e227f6..b4bd77c0d5 100644 --- a/crates/rooch-framework-tests/src/tests/multisign_account_tests.rs +++ b/crates/rooch-framework-tests/src/tests/multisign_account_tests.rs @@ -4,8 +4,8 @@ use crate::binding_test; use moveos_types::module_binding::MoveFunctionCaller; use rooch_types::{ + bitcoin::multisign_account::{self, MultisignAccountModule}, crypto::RoochKeyPair, - nursery::multisign_account::{self, MultisignAccountModule}, transaction::RoochTransactionData, }; diff --git a/crates/rooch-types/src/nursery/bitcoin_multisign_validator.rs b/crates/rooch-types/src/bitcoin/bitcoin_multisign_validator.rs similarity index 91% rename from crates/rooch-types/src/nursery/bitcoin_multisign_validator.rs rename to crates/rooch-types/src/bitcoin/bitcoin_multisign_validator.rs index 5bd9368898..f3aa997647 100644 --- a/crates/rooch-types/src/nursery/bitcoin_multisign_validator.rs +++ b/crates/rooch-types/src/bitcoin/bitcoin_multisign_validator.rs @@ -3,7 +3,7 @@ use crate::framework::auth_validator::BuiltinAuthValidator; use anyhow::Result; -use framework_types::addresses::ROOCH_NURSERY_ADDRESS; +use framework_types::addresses::BITCOIN_MOVE_ADDRESS; use move_core_types::{ account_address::AccountAddress, ident_str, identifier::IdentStr, value::MoveValue, }; @@ -26,7 +26,7 @@ impl BitcoinMultisignValidator { } impl MoveStructType for BitcoinMultisignValidator { - const ADDRESS: AccountAddress = ROOCH_NURSERY_ADDRESS; + const ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; const MODULE_NAME: &'static IdentStr = MODULE_NAME; const STRUCT_NAME: &'static IdentStr = ident_str!("BitcoinMultisignValidator"); } @@ -56,7 +56,7 @@ impl<'a> BitcoinMultisignValidatorModule<'a> { } impl<'a> ModuleBinding<'a> for BitcoinMultisignValidatorModule<'a> { - const MODULE_ADDRESS: AccountAddress = ROOCH_NURSERY_ADDRESS; + const MODULE_ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; const MODULE_NAME: &'static IdentStr = MODULE_NAME; fn new(caller: &'a impl MoveFunctionCaller) -> Self diff --git a/crates/rooch-types/src/bitcoin/mod.rs b/crates/rooch-types/src/bitcoin/mod.rs index 66301d507a..a350189eca 100644 --- a/crates/rooch-types/src/bitcoin/mod.rs +++ b/crates/rooch-types/src/bitcoin/mod.rs @@ -24,10 +24,12 @@ use types::BlockHeightHash; pub const MODULE_NAME: &IdentStr = ident_str!("bitcoin"); +pub mod bitcoin_multisign_validator; /// Types mapping from Bitcoin Move types to Rust types /// Module binding for the Framework pub mod brc20; pub mod genesis; +pub mod multisign_account; pub mod network; pub mod ord; pub mod pending_block; diff --git a/crates/rooch-types/src/nursery/multisign_account.rs b/crates/rooch-types/src/bitcoin/multisign_account.rs similarity index 98% rename from crates/rooch-types/src/nursery/multisign_account.rs rename to crates/rooch-types/src/bitcoin/multisign_account.rs index 2a6ac4b5ef..aa404379de 100644 --- a/crates/rooch-types/src/nursery/multisign_account.rs +++ b/crates/rooch-types/src/bitcoin/multisign_account.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::address::BitcoinAddress; -use crate::addresses::ROOCH_NURSERY_ADDRESS; +use crate::addresses::BITCOIN_MOVE_ADDRESS; use anyhow::Result; use bitcoin::key::constants::SCHNORR_PUBLIC_KEY_SIZE; use bitcoin::key::Secp256k1; @@ -150,7 +150,7 @@ impl<'a> MultisignAccountModule<'a> { impl<'a> ModuleBinding<'a> for MultisignAccountModule<'a> { const MODULE_NAME: &'static IdentStr = MODULE_NAME; - const MODULE_ADDRESS: AccountAddress = ROOCH_NURSERY_ADDRESS; + const MODULE_ADDRESS: AccountAddress = BITCOIN_MOVE_ADDRESS; fn new(caller: &'a impl MoveFunctionCaller) -> Self where diff --git a/crates/rooch-types/src/nursery/mod.rs b/crates/rooch-types/src/nursery/mod.rs index bfac11a442..776dcb51d2 100644 --- a/crates/rooch-types/src/nursery/mod.rs +++ b/crates/rooch-types/src/nursery/mod.rs @@ -1,5 +1,2 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 - -pub mod bitcoin_multisign_validator; -pub mod multisign_account; diff --git a/examples/btc_blind_box/sources/blind_box.move b/examples/btc_blind_box/sources/blind_box.move index 91f9644c28..0986c1119e 100644 --- a/examples/btc_blind_box/sources/blind_box.move +++ b/examples/btc_blind_box/sources/blind_box.move @@ -140,7 +140,6 @@ module btc_blind_box::blind_box { #[test(sender=@0x42)] fun test_request_and_claim(sender: &signer) { - rooch_framework::genesis::init_for_test(); bitcoin_move::genesis::init_for_test(); let module_owner = account::create_account_for_testing(@btc_blind_box); diff --git a/examples/btc_holder_coin/sources/holder_coin.move b/examples/btc_holder_coin/sources/holder_coin.move index 3f128f8d43..72435514ac 100644 --- a/examples/btc_holder_coin/sources/holder_coin.move +++ b/examples/btc_holder_coin/sources/holder_coin.move @@ -77,7 +77,6 @@ module btc_holder_coin::holder_coin { #[test] fun test_stake_claim() { - rooch_framework::genesis::init_for_test(); bitcoin_move::genesis::init_for_test(); init(); let seconds = 100; diff --git a/examples/btc_holder_farmer/sources/holder_farmer.move b/examples/btc_holder_farmer/sources/holder_farmer.move index 7101842098..bc86055d14 100644 --- a/examples/btc_holder_farmer/sources/holder_farmer.move +++ b/examples/btc_holder_farmer/sources/holder_farmer.move @@ -538,7 +538,6 @@ module btc_holder_farmer::hold_farmer { #[test(sender=@0x42)] fun test_stake(sender: signer) { - rooch_framework::genesis::init_for_test(); bitcoin_move::genesis::init_for_test(); let admin_cap = object::new_named_object(AdminCap {}); deploy(&sender, 1, 0, 200, b"BTC Holder Coin", b"HDC", 6, &mut admin_cap); diff --git a/frameworks/bitcoin-move/doc/README.md b/frameworks/bitcoin-move/doc/README.md index e1d859dc47..7f2fe6439f 100644 --- a/frameworks/bitcoin-move/doc/README.md +++ b/frameworks/bitcoin-move/doc/README.md @@ -14,7 +14,9 @@ This is the reference documentation of the Bitcoin Move Framework. - [`0x4::bitcoin`](bitcoin.md#0x4_bitcoin) - [`0x4::bitcoin_hash`](bitcoin_hash.md#0x4_bitcoin_hash) +- [`0x4::bitcoin_multisign_validator`](bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator) - [`0x4::genesis`](genesis.md#0x4_genesis) +- [`0x4::multisign_account`](multisign_account.md#0x4_multisign_account) - [`0x4::network`](network.md#0x4_network) - [`0x4::opcode`](opcode.md#0x4_opcode) - [`0x4::ord`](ord.md#0x4_ord) diff --git a/frameworks/bitcoin-move/doc/bitcoin_multisign_validator.md b/frameworks/bitcoin-move/doc/bitcoin_multisign_validator.md new file mode 100644 index 0000000000..d942c08e3a --- /dev/null +++ b/frameworks/bitcoin-move/doc/bitcoin_multisign_validator.md @@ -0,0 +1,106 @@ + + + +# Module `0x4::bitcoin_multisign_validator` + +Bitcoin multisign auth validator + + +- [Struct `BitcoinMultisignValidator`](#0x4_bitcoin_multisign_validator_BitcoinMultisignValidator) +- [Constants](#@Constants_0) +- [Function `auth_validator_id`](#0x4_bitcoin_multisign_validator_auth_validator_id) +- [Function `genesis_init`](#0x4_bitcoin_multisign_validator_genesis_init) +- [Function `init_for_upgrade`](#0x4_bitcoin_multisign_validator_init_for_upgrade) +- [Function `validate`](#0x4_bitcoin_multisign_validator_validate) + + +
use 0x2::hash;
+use 0x2::signer;
+use 0x2::tx_context;
+use 0x3::auth_payload;
+use 0x3::auth_validator;
+use 0x3::auth_validator_registry;
+use 0x3::ecdsa_k1;
+use 0x4::multisign_account;
+
+
+
+
+
+
+## Struct `BitcoinMultisignValidator`
+
+
+
+struct BitcoinMultisignValidator has drop, store
+
+
+
+
+
+
+## Constants
+
+
+
+
+there defines auth validator id for each auth validator
+
+
+const BITCOIN_MULTISIGN_VALIDATOR_ID: u64 = 2;
+
+
+
+
+
+
+
+
+const ErrorGenesisInitError: u64 = 1;
+
+
+
+
+
+
+## Function `auth_validator_id`
+
+
+
+public fun auth_validator_id(): u64
+
+
+
+
+
+
+## Function `genesis_init`
+
+
+
+public(friend) fun genesis_init()
+
+
+
+
+
+
+## Function `init_for_upgrade`
+
+Init function called by upgrade. This module is upgrade after genesis, so we provide this function for upgrade.
+When rest the genesis, we can remove this function.
+
+
+public fun init_for_upgrade()
+
+
+
+
+
+
+## Function `validate`
+
+
+
+public fun validate(authenticator_payload: vector<u8>)
+
diff --git a/frameworks/bitcoin-move/doc/genesis.md b/frameworks/bitcoin-move/doc/genesis.md
index 7b59119e17..045f72e82c 100644
--- a/frameworks/bitcoin-move/doc/genesis.md
+++ b/frameworks/bitcoin-move/doc/genesis.md
@@ -13,6 +13,7 @@
use 0x2::signer;
use 0x2::tx_context;
use 0x4::bitcoin;
+use 0x4::bitcoin_multisign_validator;
use 0x4::network;
use 0x4::ord;
use 0x4::pending_block;
diff --git a/frameworks/rooch-nursery/doc/multisign_account.md b/frameworks/bitcoin-move/doc/multisign_account.md
similarity index 54%
rename from frameworks/rooch-nursery/doc/multisign_account.md
rename to frameworks/bitcoin-move/doc/multisign_account.md
index 9e81a50c05..49c2f7cec9 100644
--- a/frameworks/rooch-nursery/doc/multisign_account.md
+++ b/frameworks/bitcoin-move/doc/multisign_account.md
@@ -1,24 +1,24 @@
-
+
-# Module `0xa::multisign_account`
+# Module `0x4::multisign_account`
Bitcoin multisign account module
-- [Resource `MultisignAccountInfo`](#0xa_multisign_account_MultisignAccountInfo)
-- [Struct `ParticipantInfo`](#0xa_multisign_account_ParticipantInfo)
+- [Resource `MultisignAccountInfo`](#0x4_multisign_account_MultisignAccountInfo)
+- [Struct `ParticipantInfo`](#0x4_multisign_account_ParticipantInfo)
- [Constants](#@Constants_0)
-- [Function `initialize_multisig_account_entry`](#0xa_multisign_account_initialize_multisig_account_entry)
-- [Function `initialize_multisig_account`](#0xa_multisign_account_initialize_multisig_account)
-- [Function `generate_multisign_address`](#0xa_multisign_account_generate_multisign_address)
-- [Function `is_participant`](#0xa_multisign_account_is_participant)
-- [Function `is_participant_via_public_key`](#0xa_multisign_account_is_participant_via_public_key)
-- [Function `is_multisign_account`](#0xa_multisign_account_is_multisign_account)
-- [Function `bitcoin_address`](#0xa_multisign_account_bitcoin_address)
-- [Function `threshold`](#0xa_multisign_account_threshold)
-- [Function `participant_public_key`](#0xa_multisign_account_participant_public_key)
-- [Function `participant_bitcoin_address`](#0xa_multisign_account_participant_bitcoin_address)
+- [Function `initialize_multisig_account_entry`](#0x4_multisign_account_initialize_multisig_account_entry)
+- [Function `initialize_multisig_account`](#0x4_multisign_account_initialize_multisig_account)
+- [Function `generate_multisign_address`](#0x4_multisign_account_generate_multisign_address)
+- [Function `is_participant`](#0x4_multisign_account_is_participant)
+- [Function `is_participant_via_public_key`](#0x4_multisign_account_is_participant_via_public_key)
+- [Function `is_multisign_account`](#0x4_multisign_account_is_multisign_account)
+- [Function `bitcoin_address`](#0x4_multisign_account_bitcoin_address)
+- [Function `threshold`](#0x4_multisign_account_threshold)
+- [Function `participant_public_key`](#0x4_multisign_account_participant_public_key)
+- [Function `participant_bitcoin_address`](#0x4_multisign_account_participant_bitcoin_address)
use 0x1::option;
@@ -33,31 +33,31 @@ Bitcoin multisign account module
use 0x3::address_mapping;
use 0x3::bitcoin_address;
use 0x3::ecdsa_k1;
-use 0x4::opcode;
-use 0x4::script_buf;
-use 0x4::taproot_builder;
+use 0x4::opcode;
+use 0x4::script_buf;
+use 0x4::taproot_builder;
-
+
## Resource `MultisignAccountInfo`
-struct MultisignAccountInfo has store, key
+struct MultisignAccountInfo has store, key
-
+
## Struct `ParticipantInfo`
-struct ParticipantInfo has copy, drop, store
+struct ParticipantInfo has copy, drop, store
@@ -67,142 +67,142 @@ Bitcoin multisign account module
## Constants
-
+
-const ErrorInvalidPublicKey: u64 = 6;
+const ErrorInvalidPublicKey: u64 = 6;
-
+
-const ErrorInvalidThreshold: u64 = 1;
+const ErrorInvalidThreshold: u64 = 1;
-
+
-const ErrorInvalidSignature: u64 = 10;
+const ErrorInvalidSignature: u64 = 10;
-
+
-const BITCOIN_COMPRESSED_PUBLIC_KEY_LEN: u64 = 33;
+const BITCOIN_COMPRESSED_PUBLIC_KEY_LEN: u64 = 33;
-
+
-const ErrorInvalidParticipant: u64 = 3;
+const ErrorInvalidParticipant: u64 = 3;
-
+
-const ErrorInvalidProposal: u64 = 7;
+const ErrorInvalidProposal: u64 = 7;
-
+
-const ErrorInvalidProposalStatus: u64 = 9;
+const ErrorInvalidProposalStatus: u64 = 9;
-
+
-const ErrorMultisignAccountNotFound: u64 = 2;
+const ErrorMultisignAccountNotFound: u64 = 2;
-
+
-const ErrorParticipantAlreadyJoined: u64 = 5;
+const ErrorParticipantAlreadyJoined: u64 = 5;
-
+
-const ErrorParticipantMustHasBitcoinAddress: u64 = 4;
+const ErrorParticipantMustHasBitcoinAddress: u64 = 4;
-
+
-const ErrorProposalAlreadySigned: u64 = 8;
+const ErrorProposalAlreadySigned: u64 = 8;
-
+
-const PROPOSAL_STATUS_APPROVED: u8 = 1;
+const PROPOSAL_STATUS_APPROVED: u8 = 1;
-
+
-const PROPOSAL_STATUS_PENDING: u8 = 0;
+const PROPOSAL_STATUS_PENDING: u8 = 0;
-
+
-const PROPOSAL_STATUS_REJECTED: u8 = 2;
+const PROPOSAL_STATUS_REJECTED: u8 = 2;
-
+
-const X_ONLY_PUBLIC_KEY_LEN: u64 = 32;
+const X_ONLY_PUBLIC_KEY_LEN: u64 = 32;
-
+
## Function `initialize_multisig_account_entry`
@@ -210,67 +210,67 @@ Initialize a taproot multisign account
If the multisign account already exists, we will init the MultisignAccountInfo into the account
-public entry fun initialize_multisig_account_entry(threshold: u64, participant_public_keys: vector<vector<u8>>)
+public entry fun initialize_multisig_account_entry(threshold: u64, participant_public_keys: vector<vector<u8>>)
-
+
## Function `initialize_multisig_account`
-public fun initialize_multisig_account(threshold: u64, participant_public_keys: vector<vector<u8>>): address
+public fun initialize_multisig_account(threshold: u64, participant_public_keys: vector<vector<u8>>): address
-
+
## Function `generate_multisign_address`
-public fun generate_multisign_address(threshold: u64, public_keys: vector<vector<u8>>): bitcoin_address::BitcoinAddress
+public fun generate_multisign_address(threshold: u64, public_keys: vector<vector<u8>>): bitcoin_address::BitcoinAddress
-
+
## Function `is_participant`
-public fun is_participant(multisign_address: address, participant_address: address): bool
+public fun is_participant(multisign_address: address, participant_address: address): bool
-
+
## Function `is_participant_via_public_key`
-public fun is_participant_via_public_key(multisign_address: address, public_key: &vector<u8>): bool
+public fun is_participant_via_public_key(multisign_address: address, public_key: &vector<u8>): bool
-
+
## Function `is_multisign_account`
-public fun is_multisign_account(multisign_address: address): bool
+public fun is_multisign_account(multisign_address: address): bool
-
+
## Function `bitcoin_address`
@@ -281,33 +281,33 @@ If the multisign account already exists, we will init the MultisignAccountInfo i
-
+
## Function `threshold`
-public fun threshold(multisign_address: address): u64
+public fun threshold(multisign_address: address): u64
-
+
## Function `participant_public_key`
-public fun participant_public_key(multisign_address: address, participant_address: address): vector<u8>
+public fun participant_public_key(multisign_address: address, participant_address: address): vector<u8>
-
+
## Function `participant_bitcoin_address`
-public fun participant_bitcoin_address(multisign_address: address, participant_address: address): bitcoin_address::BitcoinAddress
+public fun participant_bitcoin_address(multisign_address: address, participant_address: address): bitcoin_address::BitcoinAddress
diff --git a/frameworks/rooch-nursery/sources/bitcoin_multisign_validator.move b/frameworks/bitcoin-move/sources/bitcoin_multisign_validator.move
similarity index 79%
rename from frameworks/rooch-nursery/sources/bitcoin_multisign_validator.move
rename to frameworks/bitcoin-move/sources/bitcoin_multisign_validator.move
index 6e21d510d1..521c5ccb41 100644
--- a/frameworks/rooch-nursery/sources/bitcoin_multisign_validator.move
+++ b/frameworks/bitcoin-move/sources/bitcoin_multisign_validator.move
@@ -1,15 +1,20 @@
-module rooch_nursery::bitcoin_multisign_validator{
+// Copyright (c) RoochNetwork
+// SPDX-License-Identifier: Apache-2.0
+
+/// Bitcoin multisign auth validator
+module bitcoin_move::bitcoin_multisign_validator{
use std::vector;
use moveos_std::tx_context;
use moveos_std::hash;
+ use moveos_std::signer;
use rooch_framework::ecdsa_k1;
use rooch_framework::auth_validator_registry;
use rooch_framework::auth_validator;
use rooch_framework::auth_payload;
- use rooch_nursery::multisign_account;
+ use bitcoin_move::multisign_account;
- friend rooch_nursery::genesis;
+ friend bitcoin_move::genesis;
const ErrorGenesisInitError: u64 = 1;
@@ -24,10 +29,19 @@ module rooch_nursery::bitcoin_multisign_validator{
}
public(friend) fun genesis_init(){
- let id = auth_validator_registry::register();
+ let system = signer::module_signer();
+ let id = auth_validator_registry::register_by_system(&system);
assert!(id == BITCOIN_MULTISIGN_VALIDATOR_ID, ErrorGenesisInitError);
}
+ /// Init function called by upgrade. This module is upgrade after genesis, so we provide this function for upgrade.
+ /// When rest the genesis, we can remove this function.
+ public fun init_for_upgrade(){
+ if(!auth_validator_registry::is_registered()){
+ genesis_init();
+ }
+ }
+
/// Only validate the authenticator's signature.
fun validate_signatures(signatures: &vector>, public_keys: &vector>, message: vector) {
diff --git a/frameworks/bitcoin-move/sources/genesis.move b/frameworks/bitcoin-move/sources/genesis.move
index 4c3dd661c5..fa19467c3f 100644
--- a/frameworks/bitcoin-move/sources/genesis.move
+++ b/frameworks/bitcoin-move/sources/genesis.move
@@ -10,6 +10,7 @@ module bitcoin_move::genesis{
use bitcoin_move::utxo;
use bitcoin_move::network;
use bitcoin_move::pending_block;
+ use bitcoin_move::bitcoin_multisign_validator;
const ErrorGenesisInit: u64 = 1;
@@ -31,11 +32,13 @@ module bitcoin_move::genesis{
ord::genesis_init(&genesis_account);
bitcoin::genesis_init(&genesis_account, genesis_context.genesis_block_height, genesis_context.genesis_block_hash);
pending_block::genesis_init(genesis_context.reorg_block_count);
+ bitcoin_multisign_validator::genesis_init();
}
#[test_only]
/// init the genesis context for test
public fun init_for_test(){
+ rooch_framework::genesis::init_for_test();
let genesis_account = moveos_std::signer::module_signer();
tx_context::add_attribute_via_system(&genesis_account,
BitcoinGenesisContext{
diff --git a/frameworks/rooch-nursery/sources/multisign_account.move b/frameworks/bitcoin-move/sources/multisign_account.move
similarity index 99%
rename from frameworks/rooch-nursery/sources/multisign_account.move
rename to frameworks/bitcoin-move/sources/multisign_account.move
index 8c59b64833..1cb41ac0db 100644
--- a/frameworks/rooch-nursery/sources/multisign_account.move
+++ b/frameworks/bitcoin-move/sources/multisign_account.move
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
/// Bitcoin multisign account module
-module rooch_nursery::multisign_account{
+module bitcoin_move::multisign_account{
use std::vector;
use std::option;
diff --git a/frameworks/bitcoin-move/tests/bitcoin_test.move b/frameworks/bitcoin-move/tests/bitcoin_test.move
index 4e8f451f4d..522a05fc5b 100644
--- a/frameworks/bitcoin-move/tests/bitcoin_test.move
+++ b/frameworks/bitcoin-move/tests/bitcoin_test.move
@@ -7,7 +7,6 @@ module bitcoin_move::bitcoin_test {
#[test]
fun test_submit_block() {
- rooch_framework::genesis::init_for_test();
bitcoin_move::genesis::init_for_test();
//https://mempool.space/block/00000000b0c5a240b2a61d2e75692224efd4cbecdf6eaf4cc2cf477ca7c270e7
diff --git a/frameworks/rooch-nursery/tests/multisign_account_test.move b/frameworks/bitcoin-move/tests/multisign_account_test.move
similarity index 93%
rename from frameworks/rooch-nursery/tests/multisign_account_test.move
rename to frameworks/bitcoin-move/tests/multisign_account_test.move
index fa1f531b89..6fe3950945 100644
--- a/frameworks/rooch-nursery/tests/multisign_account_test.move
+++ b/frameworks/bitcoin-move/tests/multisign_account_test.move
@@ -1,10 +1,10 @@
-module rooch_nursery::multisign_account_test{
+module bitcoin_move::multisign_account_test{
use std::vector;
use std::string::{utf8};
use rooch_framework::bitcoin_address;
- use rooch_nursery::multisign_account;
- use rooch_nursery::genesis;
+ use bitcoin_move::multisign_account;
+ use bitcoin_move::genesis;
#[test]
public fun test_multisign_account(){
diff --git a/frameworks/rooch-framework/doc/auth_validator_registry.md b/frameworks/rooch-framework/doc/auth_validator_registry.md
index 1ea83f1aa2..e2c92fb154 100644
--- a/frameworks/rooch-framework/doc/auth_validator_registry.md
+++ b/frameworks/rooch-framework/doc/auth_validator_registry.md
@@ -10,13 +10,16 @@
- [Constants](#@Constants_0)
- [Function `genesis_init`](#0x3_auth_validator_registry_genesis_init)
- [Function `register`](#0x3_auth_validator_registry_register)
+- [Function `register_by_system`](#0x3_auth_validator_registry_register_by_system)
- [Function `register_internal`](#0x3_auth_validator_registry_register_internal)
+- [Function `is_registered`](#0x3_auth_validator_registry_is_registered)
- [Function `borrow_validator`](#0x3_auth_validator_registry_borrow_validator)
- [Function `borrow_validator_by_type`](#0x3_auth_validator_registry_borrow_validator_by_type)
use 0x1::string;
use 0x2::account;
+use 0x2::core_addresses;
use 0x2::features;
use 0x2::table;
use 0x2::type_info;
@@ -87,6 +90,7 @@ Init function called by genesis.
## Function `register`
+Register a new validator. This feature not enabled in the mainnet.
#[private_generics(#[ValidatorType])]
@@ -95,6 +99,18 @@ Init function called by genesis.
+
+
+## Function `register_by_system`
+
+Register a new validator by system. This function is only called by system.
+
+
+public fun register_by_system<ValidatorType: store>(system: &signer): u64
+
+
+
+
## Function `register_internal`
@@ -106,6 +122,17 @@ Init function called by genesis.
+
+
+## Function `is_registered`
+
+
+
+public fun is_registered<ValidatorType: store>(): bool
+
+
+
+
## Function `borrow_validator`
diff --git a/frameworks/rooch-framework/sources/auth_validator/auth_validator_registry.move b/frameworks/rooch-framework/sources/auth_validator/auth_validator_registry.move
index 525e0f1994..d4855dc8d4 100644
--- a/frameworks/rooch-framework/sources/auth_validator/auth_validator_registry.move
+++ b/frameworks/rooch-framework/sources/auth_validator/auth_validator_registry.move
@@ -8,7 +8,7 @@ module rooch_framework::auth_validator_registry {
use moveos_std::table::{Self, Table};
use moveos_std::type_table::{Self, TypeTable};
use moveos_std::features;
-
+ use moveos_std::core_addresses;
use rooch_framework::auth_validator::{Self, AuthValidator};
friend rooch_framework::genesis;
@@ -39,11 +39,18 @@ module rooch_framework::auth_validator_registry {
}
#[private_generics(ValidatorType)]
+ /// Register a new validator. This feature not enabled in the mainnet.
public fun register() : u64{
features::ensure_testnet_enabled();
register_internal()
}
+ /// Register a new validator by system. This function is only called by system.
+ public fun register_by_system(system: &signer) : u64{
+ core_addresses::assert_system_reserved(system);
+ register_internal()
+ }
+
public(friend) fun register_internal() : u64{
let type_info = type_info::type_of();
let module_address = type_info::account_address(&type_info);
@@ -70,6 +77,11 @@ module rooch_framework::auth_validator_registry {
id
}
+ public fun is_registered(): bool{
+ let registry = account::borrow_resource(@rooch_framework);
+ type_table::contains>(®istry.validators_with_type)
+ }
+
public fun borrow_validator(id: u64): &AuthValidator {
features::ensure_testnet_enabled();
diff --git a/frameworks/rooch-nursery/doc/README.md b/frameworks/rooch-nursery/doc/README.md
index deb66e1aee..186d6d9d6c 100644
--- a/frameworks/rooch-nursery/doc/README.md
+++ b/frameworks/rooch-nursery/doc/README.md
@@ -12,7 +12,6 @@ This is the reference documentation of the Rooch Nursery Framework.
## Index
-- [`0xa::bitcoin_multisign_validator`](bitcoin_multisign_validator.md#0xa_bitcoin_multisign_validator)
- [`0xa::bitseed`](bitseed.md#0xa_bitseed)
- [`0xa::brc20`](brc20.md#0xa_brc20)
- [`0xa::ethereum`](ethereum.md#0xa_ethereum)
@@ -20,7 +19,6 @@ This is the reference documentation of the Rooch Nursery Framework.
- [`0xa::genesis`](genesis.md#0xa_genesis)
- [`0xa::inscribe_factory`](inscribe_factory.md#0xa_inscribe_factory)
- [`0xa::mint_get_factory`](mint_get_factory.md#0xa_mint_get_factory)
-- [`0xa::multisign_account`](multisign_account.md#0xa_multisign_account)
- [`0xa::multisign_wallet`](multisign_wallet.md#0xa_multisign_wallet)
- [`0xa::tick_info`](tick_info.md#0xa_tick_info)
diff --git a/frameworks/rooch-nursery/doc/bitcoin_multisign_validator.md b/frameworks/rooch-nursery/doc/bitcoin_multisign_validator.md
deleted file mode 100644
index b70a3ba39f..0000000000
--- a/frameworks/rooch-nursery/doc/bitcoin_multisign_validator.md
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-# Module `0xa::bitcoin_multisign_validator`
-
-
-
-- [Struct `BitcoinMultisignValidator`](#0xa_bitcoin_multisign_validator_BitcoinMultisignValidator)
-- [Constants](#@Constants_0)
-- [Function `auth_validator_id`](#0xa_bitcoin_multisign_validator_auth_validator_id)
-- [Function `genesis_init`](#0xa_bitcoin_multisign_validator_genesis_init)
-- [Function `validate`](#0xa_bitcoin_multisign_validator_validate)
-
-
-use 0x2::hash;
-use 0x2::tx_context;
-use 0x3::auth_payload;
-use 0x3::auth_validator;
-use 0x3::auth_validator_registry;
-use 0x3::ecdsa_k1;
-use 0xa::multisign_account;
-
-
-
-
-
-
-## Struct `BitcoinMultisignValidator`
-
-
-
-struct BitcoinMultisignValidator has drop, store
-
-
-
-
-
-
-## Constants
-
-
-
-
-there defines auth validator id for each auth validator
-
-
-const BITCOIN_MULTISIGN_VALIDATOR_ID: u64 = 2;
-
-
-
-
-
-
-
-
-const ErrorGenesisInitError: u64 = 1;
-
-
-
-
-
-
-## Function `auth_validator_id`
-
-
-
-public fun auth_validator_id(): u64
-
-
-
-
-
-
-## Function `genesis_init`
-
-
-
-public(friend) fun genesis_init()
-
-
-
-
-
-
-## Function `validate`
-
-
-
-public fun validate(authenticator_payload: vector<u8>)
-
diff --git a/frameworks/rooch-nursery/doc/genesis.md b/frameworks/rooch-nursery/doc/genesis.md
index d2769ccec8..782a2a96ff 100644
--- a/frameworks/rooch-nursery/doc/genesis.md
+++ b/frameworks/rooch-nursery/doc/genesis.md
@@ -10,7 +10,6 @@
use 0x3::chain_id;
-use 0xa::bitcoin_multisign_validator;
use 0xa::ethereum;
use 0xa::tick_info;
diff --git a/frameworks/rooch-nursery/doc/multisign_wallet.md b/frameworks/rooch-nursery/doc/multisign_wallet.md
index 8e672146cb..e30531cb3d 100644
--- a/frameworks/rooch-nursery/doc/multisign_wallet.md
+++ b/frameworks/rooch-nursery/doc/multisign_wallet.md
@@ -20,7 +20,7 @@ Bitcoin multisign account wallet to manage the multisign tx on Bitcoin and Rooch
use 0x2::signer;
use 0x2::table_vec;
use 0x3::ecdsa_k1;
-use 0xa::multisign_account;
+use 0x4::multisign_account;
diff --git a/frameworks/rooch-nursery/sources/genesis.move b/frameworks/rooch-nursery/sources/genesis.move
index 67adf04431..cc00161a68 100644
--- a/frameworks/rooch-nursery/sources/genesis.move
+++ b/frameworks/rooch-nursery/sources/genesis.move
@@ -5,7 +5,6 @@ module rooch_nursery::genesis {
use rooch_framework::chain_id;
use rooch_nursery::ethereum;
use rooch_nursery::tick_info;
- use rooch_nursery::bitcoin_multisign_validator;
const ErrorInvalidChainId: u64 = 1;
@@ -17,7 +16,6 @@ module rooch_nursery::genesis {
// nursery can running on a local or dev chain or custom chain
assert!(!chain_id::is_test() && !chain_id::is_main(), ErrorInvalidChainId);
ethereum::genesis_init(genesis_account);
- bitcoin_multisign_validator::genesis_init();
tick_info::genesis_init();
}
diff --git a/frameworks/rooch-nursery/sources/multisign_wallet.move b/frameworks/rooch-nursery/sources/multisign_wallet.move
index 080f090016..b1c42a0d86 100644
--- a/frameworks/rooch-nursery/sources/multisign_wallet.move
+++ b/frameworks/rooch-nursery/sources/multisign_wallet.move
@@ -9,7 +9,7 @@ module rooch_nursery::multisign_wallet{
use moveos_std::object;
use moveos_std::table_vec::{Self, TableVec};
use moveos_std::bcs;
- use rooch_nursery::multisign_account;
+ use bitcoin_move::multisign_account;
use rooch_framework::ecdsa_k1;
const PROPOSAL_STATUS_PENDING: u8 = 0;