Skip to content

Commit

Permalink
feat(sui-genesis-builder): migrate Alias Outputs (#163)
Browse files Browse the repository at this point in the history
* feat(sui-genesis-builder): store TypeOrigin of native tokens

While creating foundries now maps the `(ObjectID, TypeOrigin)` to the
`TokenId`.

* refactor(sui-genesis-builder): split stardust::types module

* feat(sui-genesis-builder): add unlock types

* feat(sui-genesis-builder): add BasicOutput type

* refactor(sui-genesis-builder): use OutputHeader while creating outputs

* feat(sui-genesis-builder): implement stardust::migration::Executor::create_basic_objects

* fixup! feat(sui-genesis-builder): implement stardust::migration::Executor::create_basic_objects

* fixup! fixup! feat(sui-genesis-builder): implement stardust::migration::Executor::create_basic_objects

* feat(sui-genesis-builder): fix native-token object ids during migration

* fixup! fixup! fixup! feat(sui-genesis-builder): implement stardust::migration::Executor::create_basic_objects

* fix(sui-genesis-builder): correct BasicOutput::type_ module and name

Co-authored-by: Philipp Gackstatter <[email protected]>

* fix(sui-genesis-builder): load packages and input objects correctly

* fix(sui-genesis-builder): dummy transfer Bag object

* Implement move data model in Rust

* Execute alias creation transaction

* Fix dependencies during PTB execution

* Fix alias tags, extend test

* Add TODO for dynamic object field

* Expose `attach_alias` function

* Fix outstanding alias migration TODOs

* Prettify alias migration test

* `cargo fmt` the genesis builder

* Make state controller non-optional

* Move alias migration test to separate file

* Cleanup alias migration test

* Add zeroized check and simplify match statement

* Add non-zeroed alias id test

* Use to_genesis_object approach

* Use fresh_id as the alias output ID

* Compute version of aliases via `lamport_timestamp`

* Move crate-level migration test to module

---------

Co-authored-by: Konstantinos Demartinos <[email protected]>
  • Loading branch information
PhilippGackstatter and kodemartin authored May 16, 2024
1 parent cc296a3 commit 69889b6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions crates/sui-framework/docs/stardust/alias.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ have to be received via this object once extracted from <code>AliasOutput</code>
This is the AliasID from Stardust.
</dd>
<dt>
<code>legacy_state_controller: <a href="../move-stdlib/option.md#0x1_option_Option">option::Option</a>&lt;<b>address</b>&gt;</code>
<code>legacy_state_controller: <b>address</b></code>
</dt>
<dd>
The last State Controller address assigned before the migration.
Expand Down Expand Up @@ -138,7 +138,7 @@ Destroy the <code><a href="alias.md#0x107a_alias_Alias">Alias</a></code> object,
Get the Alias's <code>legacy_state_controller</code>.


<pre><code><b>public</b> <b>fun</b> <a href="alias.md#0x107a_alias_legacy_state_controller">legacy_state_controller</a>(self: &<a href="alias.md#0x107a_alias_Alias">alias::Alias</a>): &<a href="../move-stdlib/option.md#0x1_option_Option">option::Option</a>&lt;<b>address</b>&gt;
<pre><code><b>public</b> <b>fun</b> <a href="alias.md#0x107a_alias_legacy_state_controller">legacy_state_controller</a>(self: &<a href="alias.md#0x107a_alias_Alias">alias::Alias</a>): &<b>address</b>
</code></pre>


Expand All @@ -147,7 +147,7 @@ Get the Alias's <code>legacy_state_controller</code>.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="alias.md#0x107a_alias_legacy_state_controller">legacy_state_controller</a>(self: &<a href="alias.md#0x107a_alias_Alias">Alias</a>): &Option&lt;<b>address</b>&gt; {
<pre><code><b>public</b> <b>fun</b> <a href="alias.md#0x107a_alias_legacy_state_controller">legacy_state_controller</a>(self: &<a href="alias.md#0x107a_alias_Alias">Alias</a>): &<b>address</b> {
&self.legacy_state_controller
}
</code></pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module stardust::alias {
id: UID,

/// The last State Controller address assigned before the migration.
legacy_state_controller: Option<address>,
legacy_state_controller: address,
/// A counter increased by 1 every time the alias was state transitioned.
state_index: u32,
/// State metadata that can be used to store additional information.
Expand Down Expand Up @@ -47,7 +47,7 @@ module stardust::alias {
// === Public-Mutative Functions ===

/// Get the Alias's `legacy_state_controller`.
public fun legacy_state_controller(self: &Alias): &Option<address> {
public fun legacy_state_controller(self: &Alias): &address {
&self.legacy_state_controller
}

Expand Down Expand Up @@ -92,7 +92,7 @@ module stardust::alias {

#[test_only]
public fun create_for_testing(
legacy_state_controller: Option<address>,
legacy_state_controller: address,
state_index: u32,
state_metadata: Option<vector<u8>>,
sender: Option<address>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module stardust::alias_tests {

let alias = alias::create_for_testing(
// legacy state controller
option::some(owner),
owner,
// state index
0,
// state metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module stardust::address_unlock_condition_tests {

let alias = alias::create_for_testing(
// legacy state controller
option::some(owner),
owner,
// state index
0,
// state metadata
Expand Down

0 comments on commit 69889b6

Please sign in to comment.