Skip to content

Commit

Permalink
[framework] UTXO and AuthPayload break changes (#2531)
Browse files Browse the repository at this point in the history
* [rooch_framework] AuthPayload break changes

* [bitcoin-move] Refactor UTXO event and BitcoinUTXOStore

* reset framework v8

* fixup
  • Loading branch information
jolestar authored Aug 29, 2024
1 parent a1e3c3d commit e5fc913
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 269 deletions.
6 changes: 2 additions & 4 deletions crates/rooch-types/src/bitcoin/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ use serde::{Deserialize, Serialize};
pub const MODULE_NAME: &IdentStr = ident_str!("utxo");

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BitcoinUTXOStore {
pub next_tx_index: u64,
}
pub struct BitcoinUTXOStore {}

impl BitcoinUTXOStore {
pub fn object_id() -> ObjectID {
Expand All @@ -31,7 +29,7 @@ impl BitcoinUTXOStore {
let id = Self::object_id();
let mut metadata = ObjectMeta::genesis_meta(id, BitcoinUTXOStore::type_tag());
metadata.to_shared();
ObjectState::new_with_struct(metadata, Self { next_tx_index: 0 })
ObjectState::new_with_struct(metadata, Self {})
.expect("Create BitcoinUTXOStore Object should success")
}
}
Expand Down
51 changes: 0 additions & 51 deletions frameworks/bitcoin-move/doc/bitcoin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
- [Struct `UTXONotExistsEvent`](#0x4_bitcoin_UTXONotExistsEvent)
- [Struct `RepeatCoinbaseTxEvent`](#0x4_bitcoin_RepeatCoinbaseTxEvent)
- [Resource `BitcoinBlockStore`](#0x4_bitcoin_BitcoinBlockStore)
- [Struct `SpendUTXOEvent`](#0x4_bitcoin_SpendUTXOEvent)
- [Struct `ReceiveUTXOEvent`](#0x4_bitcoin_ReceiveUTXOEvent)
- [Constants](#@Constants_0)
- [Function `genesis_init`](#0x4_bitcoin_genesis_init)
- [Function `get_tx`](#0x4_bitcoin_get_tx)
Expand All @@ -22,17 +20,12 @@
- [Function `get_latest_block`](#0x4_bitcoin_get_latest_block)
- [Function `get_bitcoin_time`](#0x4_bitcoin_get_bitcoin_time)
- [Function `contains_header`](#0x4_bitcoin_contains_header)
- [Function `unpack_spend_utxo_event`](#0x4_bitcoin_unpack_spend_utxo_event)
- [Function `unpack_receive_utxo_event`](#0x4_bitcoin_unpack_receive_utxo_event)


<pre><code><b>use</b> <a href="">0x1::option</a>;
<b>use</b> <a href="">0x1::string</a>;
<b>use</b> <a href="">0x1::vector</a>;
<b>use</b> <a href="">0x2::address</a>;
<b>use</b> <a href="">0x2::bcs</a>;
<b>use</b> <a href="">0x2::event</a>;
<b>use</b> <a href="">0x2::event_queue</a>;
<b>use</b> <a href="">0x2::object</a>;
<b>use</b> <a href="">0x2::signer</a>;
<b>use</b> <a href="">0x2::simple_multimap</a>;
Expand Down Expand Up @@ -84,28 +77,6 @@



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

## Struct `SpendUTXOEvent`



<pre><code><b>struct</b> <a href="bitcoin.md#0x4_bitcoin_SpendUTXOEvent">SpendUTXOEvent</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



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

## Struct `ReceiveUTXOEvent`



<pre><code><b>struct</b> <a href="bitcoin.md#0x4_bitcoin_ReceiveUTXOEvent">ReceiveUTXOEvent</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



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

## Constants
Expand Down Expand Up @@ -291,25 +262,3 @@ Get the bitcoin time in seconds

<pre><code><b>public</b> <b>fun</b> <a href="bitcoin.md#0x4_bitcoin_contains_header">contains_header</a>(block_header: &<a href="types.md#0x4_types_Header">types::Header</a>): bool
</code></pre>



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

## Function `unpack_spend_utxo_event`



<pre><code><b>public</b> <b>fun</b> <a href="bitcoin.md#0x4_bitcoin_unpack_spend_utxo_event">unpack_spend_utxo_event</a>(<a href="">event</a>: <a href="bitcoin.md#0x4_bitcoin_SpendUTXOEvent">bitcoin::SpendUTXOEvent</a>): (<b>address</b>, <b>address</b>, <a href="_Option">option::Option</a>&lt;<b>address</b>&gt;, u64)
</code></pre>



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

## Function `unpack_receive_utxo_event`



<pre><code><b>public</b> <b>fun</b> <a href="bitcoin.md#0x4_bitcoin_unpack_receive_utxo_event">unpack_receive_utxo_event</a>(<a href="">event</a>: <a href="bitcoin.md#0x4_bitcoin_ReceiveUTXOEvent">bitcoin::ReceiveUTXOEvent</a>): (<b>address</b>, <a href="_Option">option::Option</a>&lt;<b>address</b>&gt;, <b>address</b>, u64)
</code></pre>
128 changes: 54 additions & 74 deletions frameworks/bitcoin-move/doc/utxo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
- [Resource `UTXO`](#0x4_utxo_UTXO)
- [Struct `UTXOSeal`](#0x4_utxo_UTXOSeal)
- [Struct `SealOut`](#0x4_utxo_SealOut)
- [Struct `SpendUTXOEvent`](#0x4_utxo_SpendUTXOEvent)
- [Struct `ReceiveUTXOEvent`](#0x4_utxo_ReceiveUTXOEvent)
- [Resource `BitcoinUTXOStore`](#0x4_utxo_BitcoinUTXOStore)
- [Struct `CreatingUTXOEvent`](#0x4_utxo_CreatingUTXOEvent)
- [Struct `RemovingUTXOEvent`](#0x4_utxo_RemovingUTXOEvent)
- [Constants](#@Constants_0)
- [Function `genesis_init`](#0x4_utxo_genesis_init)
- [Function `borrow_utxo_store`](#0x4_utxo_borrow_utxo_store)
- [Function `borrow_mut_utxo_store`](#0x4_utxo_borrow_mut_utxo_store)
- [Function `next_tx_index`](#0x4_utxo_next_tx_index)
- [Function `update_next_tx_index`](#0x4_utxo_update_next_tx_index)
- [Function `new`](#0x4_utxo_new)
- [Function `mock_utxo`](#0x4_utxo_mock_utxo)
- [Function `derive_utxo_id`](#0x4_utxo_derive_utxo_id)
Expand All @@ -25,12 +23,10 @@
- [Function `vout`](#0x4_utxo_vout)
- [Function `exists_utxo`](#0x4_utxo_exists_utxo)
- [Function `borrow_utxo`](#0x4_utxo_borrow_utxo)
- [Function `seal`](#0x4_utxo_seal)
- [Function `has_seal`](#0x4_utxo_has_seal)
- [Function `get_seals`](#0x4_utxo_get_seals)
- [Function `remove_seals`](#0x4_utxo_remove_seals)
- [Function `remove_seals_internal`](#0x4_utxo_remove_seals_internal)
- [Function `add_seal`](#0x4_utxo_add_seal)
- [Function `add_seal_internal`](#0x4_utxo_add_seal_internal)
- [Function `transfer`](#0x4_utxo_transfer)
- [Function `take`](#0x4_utxo_take)
- [Function `remove`](#0x4_utxo_remove)
Expand All @@ -45,11 +41,15 @@
- [Function `borrow_mut_temp_state`](#0x4_utxo_borrow_mut_temp_state)
- [Function `remove_temp_state`](#0x4_utxo_remove_temp_state)
- [Function `check_utxo_input`](#0x4_utxo_check_utxo_input)
- [Function `unpack_spend_utxo_event`](#0x4_utxo_unpack_spend_utxo_event)
- [Function `unpack_receive_utxo_event`](#0x4_utxo_unpack_receive_utxo_event)


<pre><code><b>use</b> <a href="">0x1::string</a>;
<pre><code><b>use</b> <a href="">0x1::option</a>;
<b>use</b> <a href="">0x1::string</a>;
<b>use</b> <a href="">0x2::address</a>;
<b>use</b> <a href="">0x2::bag</a>;
<b>use</b> <a href="">0x2::event</a>;
<b>use</b> <a href="">0x2::event_queue</a>;
<b>use</b> <a href="">0x2::object</a>;
<b>use</b> <a href="">0x2::simple_multimap</a>;
<b>use</b> <a href="">0x2::type_info</a>;
Expand Down Expand Up @@ -93,38 +93,45 @@ The UTXO Object



<a name="0x4_utxo_BitcoinUTXOStore"></a>
<a name="0x4_utxo_SpendUTXOEvent"></a>

## Resource `BitcoinUTXOStore`
## Struct `SpendUTXOEvent`

Event emitted when a UTXO is spent
In the Bitcoin UTXO model, there's no inherent concept of sender and receiver.
However, for simplifying payment scenarios, we define sender and receiver as follows:
- Sender: The address of the first input UTXO that can be identified
- Receiver: The address of each output UTXO that can be identified


<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_BitcoinUTXOStore">BitcoinUTXOStore</a> <b>has</b> key
<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_SpendUTXOEvent">SpendUTXOEvent</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



<a name="0x4_utxo_CreatingUTXOEvent"></a>
<a name="0x4_utxo_ReceiveUTXOEvent"></a>

## Struct `CreatingUTXOEvent`
## Struct `ReceiveUTXOEvent`

TODO break remove the CreatingUTXOEvent and RemovingUTXOEvent
Event for creating UTXO
Event emitted when a UTXO is received
In the Bitcoin UTXO model, there's no inherent concept of sender and receiver.
However, for simplifying payment scenarios, we define sender and receiver as follows:
- Sender: The address of the first input UTXO that can be identified
- Receiver: The address of each output UTXO that can be identified


<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_CreatingUTXOEvent">CreatingUTXOEvent</a> <b>has</b> <b>copy</b>, drop, store
<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_ReceiveUTXOEvent">ReceiveUTXOEvent</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



<a name="0x4_utxo_RemovingUTXOEvent"></a>
<a name="0x4_utxo_BitcoinUTXOStore"></a>

## Struct `RemovingUTXOEvent`
## Resource `BitcoinUTXOStore`

Event for remove UTXO


<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_RemovingUTXOEvent">RemovingUTXOEvent</a> <b>has</b> <b>copy</b>, drop, store
<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_BitcoinUTXOStore">BitcoinUTXOStore</a> <b>has</b> key
</code></pre>


Expand Down Expand Up @@ -185,28 +192,6 @@ Event for remove UTXO



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

## Function `next_tx_index`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="utxo.md#0x4_utxo_next_tx_index">next_tx_index</a>(): u64
</code></pre>



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

## Function `update_next_tx_index`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="utxo.md#0x4_utxo_update_next_tx_index">update_next_tx_index</a>(next_tx_index: u64)
</code></pre>



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

## Function `new`
Expand Down Expand Up @@ -298,21 +283,6 @@ Get the UTXO's vout



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

## Function `seal`

This function is deprecated
We can not provide a public function to seal UTXO now,
Maybe we can provide a new way to seal UTXO in the future


<pre><code>#[private_generics(#[T])]
<b>public</b> <b>fun</b> <a href="utxo.md#0x4_utxo_seal">seal</a>&lt;T&gt;(_utxo: &<b>mut</b> <a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>, _seal_obj: &<a href="_Object">object::Object</a>&lt;T&gt;)
</code></pre>



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

## Function `has_seal`
Expand All @@ -335,18 +305,6 @@ Maybe we can provide a new way to seal UTXO in the future



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

## Function `remove_seals`



<pre><code>#[private_generics(#[T])]
<b>public</b> <b>fun</b> <a href="utxo.md#0x4_utxo_remove_seals">remove_seals</a>&lt;T&gt;(<a href="utxo.md#0x4_utxo">utxo</a>: &<b>mut</b> <a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>): <a href="">vector</a>&lt;<a href="_ObjectID">object::ObjectID</a>&gt;
</code></pre>



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

## Function `remove_seals_internal`
Expand All @@ -358,13 +316,13 @@ Maybe we can provide a new way to seal UTXO in the future



<a name="0x4_utxo_add_seal"></a>
<a name="0x4_utxo_add_seal_internal"></a>

## Function `add_seal`
## Function `add_seal_internal`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="utxo.md#0x4_utxo_add_seal">add_seal</a>(<a href="utxo.md#0x4_utxo">utxo</a>: &<b>mut</b> <a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>, utxo_seal: <a href="utxo.md#0x4_utxo_UTXOSeal">utxo::UTXOSeal</a>)
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="utxo.md#0x4_utxo_add_seal_internal">add_seal_internal</a>(<a href="utxo.md#0x4_utxo">utxo</a>: &<b>mut</b> <a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>, utxo_seal: <a href="utxo.md#0x4_utxo_UTXOSeal">utxo::UTXOSeal</a>)
</code></pre>


Expand All @@ -375,7 +333,7 @@ Maybe we can provide a new way to seal UTXO in the future



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="">transfer</a>(utxo_obj: <a href="_Object">object::Object</a>&lt;<a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>&gt;, <b>to</b>: <b>address</b>)
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="">transfer</a>(utxo_obj: <a href="_Object">object::Object</a>&lt;<a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>&gt;, sender: <a href="_Option">option::Option</a>&lt;<b>address</b>&gt;, receiver: <b>address</b>)
</code></pre>


Expand Down Expand Up @@ -523,3 +481,25 @@ Maybe we can provide a new way to seal UTXO in the future

<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="utxo.md#0x4_utxo_check_utxo_input">check_utxo_input</a>(): bool
</code></pre>



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

## Function `unpack_spend_utxo_event`



<pre><code><b>public</b> <b>fun</b> <a href="utxo.md#0x4_utxo_unpack_spend_utxo_event">unpack_spend_utxo_event</a>(<a href="">event</a>: <a href="utxo.md#0x4_utxo_SpendUTXOEvent">utxo::SpendUTXOEvent</a>): (<b>address</b>, <b>address</b>, <a href="_Option">option::Option</a>&lt;<b>address</b>&gt;, u64)
</code></pre>



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

## Function `unpack_receive_utxo_event`



<pre><code><b>public</b> <b>fun</b> <a href="utxo.md#0x4_utxo_unpack_receive_utxo_event">unpack_receive_utxo_event</a>(<a href="">event</a>: <a href="utxo.md#0x4_utxo_ReceiveUTXOEvent">utxo::ReceiveUTXOEvent</a>): (<b>address</b>, <a href="_Option">option::Option</a>&lt;<b>address</b>&gt;, <b>address</b>, u64)
</code></pre>
Loading

0 comments on commit e5fc913

Please sign in to comment.