rooch-network / rooch

VApp Container with Move Language
https://rooch.network
Apache License 2.0
128 stars 54 forks source link

[Bitcoin] Atomic state binding #1429

Closed jolestar closed 3 weeks ago

jolestar commented 2 months ago

Provide functions for binding L2 state to L1(UTXO, Inscription)

module bitcoin_move::utxo{
  #[private_generics(S)]
  public fun add_temp_state<S: store+drop>(utxo: &mut Object<UTXO>, state: S);

  #[private_generics(S)]
  public fun remove_temp_state<S: store+drop>(utxo: &mut Object<UTXO>): S;
}

image

When the UTXO is spent, the Temporary Area states will be cleared.

module bitcoin_move::ord{
   #[private_generics(S)]
   public fun add_temp_state<S: drop>(inscription: &mut Object<Inscription>, state: S);

   #[private_generics(S)]
   public fun remove_temp_state<S: drop>(inscription: &mut Object<Inscription>): S;

   #[private_generics(S)]
   public fun add_permanent_state<S: store>(inscription: &mut Object<Inscription>, state: S);

   #[private_generics(S)]
   public fun remove_permanent_state<S: store>(inscription: &mut Object<Inscription>): S;
}

image

When the Inscription transfers, the Temporary Area states will be cleared, and the Permanent Area state will be kept.

jolestar commented 3 weeks ago

1608