Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[framework] multisign_account graduate from nursery #2467

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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");
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions crates/rooch-types/src/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions crates/rooch-types/src/nursery/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

pub mod bitcoin_multisign_validator;
pub mod multisign_account;
1 change: 0 additions & 1 deletion examples/btc_blind_box/sources/blind_box.move
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion examples/btc_holder_coin/sources/holder_coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion examples/btc_holder_farmer/sources/holder_farmer.move
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions frameworks/bitcoin-move/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
106 changes: 106 additions & 0 deletions frameworks/bitcoin-move/doc/bitcoin_multisign_validator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

<a name="0x4_bitcoin_multisign_validator"></a>

# 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)


<pre><code><b>use</b> <a href="">0x2::hash</a>;
<b>use</b> <a href="">0x2::signer</a>;
<b>use</b> <a href="">0x2::tx_context</a>;
<b>use</b> <a href="">0x3::auth_payload</a>;
<b>use</b> <a href="">0x3::auth_validator</a>;
<b>use</b> <a href="">0x3::auth_validator_registry</a>;
<b>use</b> <a href="">0x3::ecdsa_k1</a>;
<b>use</b> <a href="multisign_account.md#0x4_multisign_account">0x4::multisign_account</a>;
</code></pre>



<a name="0x4_bitcoin_multisign_validator_BitcoinMultisignValidator"></a>

## Struct `BitcoinMultisignValidator`



<pre><code><b>struct</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_BitcoinMultisignValidator">BitcoinMultisignValidator</a> <b>has</b> drop, store
</code></pre>



<a name="@Constants_0"></a>

## Constants


<a name="0x4_bitcoin_multisign_validator_BITCOIN_MULTISIGN_VALIDATOR_ID"></a>

there defines auth validator id for each auth validator


<pre><code><b>const</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_BITCOIN_MULTISIGN_VALIDATOR_ID">BITCOIN_MULTISIGN_VALIDATOR_ID</a>: u64 = 2;
</code></pre>



<a name="0x4_bitcoin_multisign_validator_ErrorGenesisInitError"></a>



<pre><code><b>const</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_ErrorGenesisInitError">ErrorGenesisInitError</a>: u64 = 1;
</code></pre>



<a name="0x4_bitcoin_multisign_validator_auth_validator_id"></a>

## Function `auth_validator_id`



<pre><code><b>public</b> <b>fun</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_auth_validator_id">auth_validator_id</a>(): u64
</code></pre>



<a name="0x4_bitcoin_multisign_validator_genesis_init"></a>

## Function `genesis_init`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_genesis_init">genesis_init</a>()
</code></pre>



<a name="0x4_bitcoin_multisign_validator_init_for_upgrade"></a>

## 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.


<pre><code><b>public</b> <b>fun</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_init_for_upgrade">init_for_upgrade</a>()
</code></pre>



<a name="0x4_bitcoin_multisign_validator_validate"></a>

## Function `validate`



<pre><code><b>public</b> <b>fun</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator_validate">validate</a>(authenticator_payload: <a href="">vector</a>&lt;u8&gt;)
</code></pre>
1 change: 1 addition & 0 deletions frameworks/bitcoin-move/doc/genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<b>use</b> <a href="">0x2::signer</a>;
<b>use</b> <a href="">0x2::tx_context</a>;
<b>use</b> <a href="bitcoin.md#0x4_bitcoin">0x4::bitcoin</a>;
<b>use</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator">0x4::bitcoin_multisign_validator</a>;
<b>use</b> <a href="network.md#0x4_network">0x4::network</a>;
<b>use</b> <a href="ord.md#0x4_ord">0x4::ord</a>;
<b>use</b> <a href="pending_block.md#0x4_pending_block">0x4::pending_block</a>;
Expand Down
Loading
Loading