Skip to content

Commit

Permalink
[denylist v2] Added migration function. Additional tests. Fix test_sc…
Browse files Browse the repository at this point in the history
…enario. (#18523)

## Description 

- Added functions to migrate v1 to v2 
- Added more tests
- Fixed disable global pause 
- Fixed test scenario caching 

## Test plan 

- new tests 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
  • Loading branch information
tnowacki authored Jul 8, 2024
1 parent 02def7a commit afe6d26
Show file tree
Hide file tree
Showing 19 changed files with 677 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ processed 14 tasks
init:
A: object(0,0), B: object(0,1)

task 1 'publish'. lines 12-34:
task 1 'publish'. lines 12-35:
created: object(1,0), object(1,1), object(1,2), object(1,3), object(1,4), object(1,5)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 18316000, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'view-object'. lines 36-36:
task 2 'view-object'. lines 37-37:
1,0::regulated_coin

task 3 'view-object'. lines 38-38:
task 3 'view-object'. lines 39-39:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::Coin<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -25,7 +25,7 @@ Contents: sui::coin::Coin<test::regulated_coin::REGULATED_COIN> {
},
}

task 4 'view-object'. lines 40-40:
task 4 'view-object'. lines 41-41:
Owner: Immutable
Version: 2
Contents: sui::coin::CoinMetadata<test::regulated_coin::REGULATED_COIN> {
Expand Down Expand Up @@ -88,7 +88,7 @@ Contents: sui::coin::CoinMetadata<test::regulated_coin::REGULATED_COIN> {
},
}

task 5 'view-object'. lines 42-42:
task 5 'view-object'. lines 43-43:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::DenyCap<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -99,7 +99,7 @@ Contents: sui::coin::DenyCap<test::regulated_coin::REGULATED_COIN> {
},
}

task 6 'view-object'. lines 44-44:
task 6 'view-object'. lines 45-45:
Owner: Immutable
Version: 2
Contents: sui::coin::RegulatedCoinMetadata<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -116,7 +116,7 @@ Contents: sui::coin::RegulatedCoinMetadata<test::regulated_coin::REGULATED_COIN>
},
}

task 7 'view-object'. lines 46-48:
task 7 'view-object'. lines 47-49:
Owner: Immutable
Version: 2
Contents: sui::coin::TreasuryCap<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -130,27 +130,27 @@ Contents: sui::coin::TreasuryCap<test::regulated_coin::REGULATED_COIN> {
},
}

task 8 'run'. lines 49-51:
task 8 'run'. lines 50-52:
created: object(8,0)
mutated: object(0,0), object(1,1)
gas summary: computation_cost: 1000000, storage_cost: 3936800, storage_rebate: 2437776, non_refundable_storage_fee: 24624

task 9 'run'. lines 52-54:
task 9 'run'. lines 53-55:
created: object(9,0), object(9,1)
mutated: object(_), 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,3)
gas summary: computation_cost: 1000000, storage_cost: 11415200, storage_rebate: 2723688, non_refundable_storage_fee: 27512

task 10 'transfer-object'. lines 55-57:
task 10 'transfer-object'. lines 56-58:
Error: Error checking transaction input objects: AddressDeniedForCoin { address: @B, coin_type: "object(1,0)::regulated_coin::REGULATED_COIN" }

task 11 'run'. lines 58-60:
task 11 'run'. lines 59-61:
Error: Error checking transaction input objects: AddressDeniedForCoin { address: @B, coin_type: "object(1,0)::regulated_coin::REGULATED_COIN" }

task 12 'run'. lines 61-63:
task 12 'run'. lines 62-64:
mutated: object(_), 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,3), object(9,1)
deleted: object(9,0)
gas summary: computation_cost: 1000000, storage_cost: 9522800, storage_rebate: 11301048, non_refundable_storage_fee: 114152

task 13 'transfer-object'. lines 64-64:
task 13 'transfer-object'. lines 65-65:
mutated: object(0,1), object(8,0)
gas summary: computation_cost: 1000000, storage_cost: 2462400, storage_rebate: 1459656, non_refundable_storage_fee: 14744
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//# init --accounts A B --addresses test=0x0

//# publish --sender A
#[allow(deprecated_usage)]
module test::regulated_coin {
use sui::coin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ processed 16 tasks
init:
A: object(0,0)

task 1 'publish'. lines 9-54:
task 1 'publish'. lines 9-56:
created: object(1,0), object(1,1), object(1,2), object(1,3), object(1,4), object(1,5), object(1,6), object(1,7), object(1,8), object(1,9), object(1,10)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 33082800, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'view-object'. lines 56-56:
task 2 'view-object'. lines 58-58:
1,0::{first_coin, second_coin}

task 3 'view-object'. lines 58-58:
task 3 'view-object'. lines 60-60:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::Coin<test::first_coin::FIRST_COIN> {
Expand All @@ -25,7 +25,7 @@ Contents: sui::coin::Coin<test::first_coin::FIRST_COIN> {
},
}

task 4 'view-object'. lines 60-60:
task 4 'view-object'. lines 62-62:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::Coin<test::second_coin::SECOND_COIN> {
Expand All @@ -39,7 +39,7 @@ Contents: sui::coin::Coin<test::second_coin::SECOND_COIN> {
},
}

task 5 'view-object'. lines 62-62:
task 5 'view-object'. lines 64-64:
Owner: Immutable
Version: 2
Contents: sui::coin::CoinMetadata<test::first_coin::FIRST_COIN> {
Expand Down Expand Up @@ -102,7 +102,7 @@ Contents: sui::coin::CoinMetadata<test::first_coin::FIRST_COIN> {
},
}

task 6 'view-object'. lines 64-64:
task 6 'view-object'. lines 66-66:
Owner: Immutable
Version: 2
Contents: sui::coin::CoinMetadata<test::second_coin::SECOND_COIN> {
Expand Down Expand Up @@ -165,7 +165,7 @@ Contents: sui::coin::CoinMetadata<test::second_coin::SECOND_COIN> {
},
}

task 7 'view-object'. lines 66-66:
task 7 'view-object'. lines 68-68:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::DenyCap<test::first_coin::FIRST_COIN> {
Expand All @@ -176,7 +176,7 @@ Contents: sui::coin::DenyCap<test::first_coin::FIRST_COIN> {
},
}

task 8 'view-object'. lines 68-68:
task 8 'view-object'. lines 70-70:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::DenyCap<test::second_coin::SECOND_COIN> {
Expand All @@ -187,7 +187,7 @@ Contents: sui::coin::DenyCap<test::second_coin::SECOND_COIN> {
},
}

task 9 'view-object'. lines 70-70:
task 9 'view-object'. lines 72-72:
Owner: Immutable
Version: 2
Contents: sui::coin::RegulatedCoinMetadata<test::first_coin::FIRST_COIN> {
Expand All @@ -204,7 +204,7 @@ Contents: sui::coin::RegulatedCoinMetadata<test::first_coin::FIRST_COIN> {
},
}

task 10 'view-object'. lines 72-72:
task 10 'view-object'. lines 74-74:
Owner: Immutable
Version: 2
Contents: sui::coin::RegulatedCoinMetadata<test::second_coin::SECOND_COIN> {
Expand All @@ -221,7 +221,7 @@ Contents: sui::coin::RegulatedCoinMetadata<test::second_coin::SECOND_COIN> {
},
}

task 11 'view-object'. lines 74-74:
task 11 'view-object'. lines 76-76:
Owner: Immutable
Version: 2
Contents: sui::coin::TreasuryCap<test::first_coin::FIRST_COIN> {
Expand All @@ -235,7 +235,7 @@ Contents: sui::coin::TreasuryCap<test::first_coin::FIRST_COIN> {
},
}

task 12 'view-object'. lines 76-78:
task 12 'view-object'. lines 78-80:
Owner: Immutable
Version: 2
Contents: sui::coin::TreasuryCap<test::second_coin::SECOND_COIN> {
Expand All @@ -249,14 +249,14 @@ Contents: sui::coin::TreasuryCap<test::second_coin::SECOND_COIN> {
},
}

task 13 'run'. lines 79-81:
task 13 'run'. lines 81-83:
created: object(13,0), object(13,1)
mutated: object(_), 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,5)
gas summary: computation_cost: 1000000, storage_cost: 11293600, storage_rebate: 2663496, non_refundable_storage_fee: 26904

task 14 'transfer-object'. lines 82-84:
task 14 'transfer-object'. lines 84-86:
Error: Error checking transaction input objects: AddressDeniedForCoin { address: @A, coin_type: "object(1,0)::first_coin::FIRST_COIN" }

task 15 'transfer-object'. lines 85-85:
task 15 'transfer-object'. lines 87-87:
mutated: object(0,0), object(1,2)
gas summary: computation_cost: 1000000, storage_cost: 2416800, storage_rebate: 2392632, non_refundable_storage_fee: 24168
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//# init --accounts A --addresses test=0x0

//# publish --sender A
#[allow(deprecated_usage)]
module test::first_coin {
use sui::coin;

Expand All @@ -30,6 +31,7 @@ module test::first_coin {
}
}

#[allow(deprecated_usage)]
module test::second_coin {
use sui::coin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ processed 13 tasks
init:
A: object(0,0)

task 1 'publish'. lines 8-46:
task 1 'publish'. lines 8-47:
created: object(1,0), object(1,1), object(1,2), object(1,3), object(1,4), object(1,5), object(1,6)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 21766400, storage_rebate: 0, non_refundable_storage_fee: 0

task 2 'view-object'. lines 48-48:
task 2 'view-object'. lines 49-49:
Owner: Account Address ( A )
Version: 2
Contents: test::regulated_coin::Wallet {
Expand All @@ -19,10 +19,10 @@ Contents: test::regulated_coin::Wallet {
},
}

task 3 'view-object'. lines 50-50:
task 3 'view-object'. lines 51-51:
1,1::regulated_coin

task 4 'view-object'. lines 52-52:
task 4 'view-object'. lines 53-53:
Owner: Account Address ( fake(1,0) )
Version: 2
Contents: sui::coin::Coin<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -36,7 +36,7 @@ Contents: sui::coin::Coin<test::regulated_coin::REGULATED_COIN> {
},
}

task 5 'view-object'. lines 54-54:
task 5 'view-object'. lines 55-55:
Owner: Immutable
Version: 2
Contents: sui::coin::CoinMetadata<test::regulated_coin::REGULATED_COIN> {
Expand Down Expand Up @@ -99,7 +99,7 @@ Contents: sui::coin::CoinMetadata<test::regulated_coin::REGULATED_COIN> {
},
}

task 6 'view-object'. lines 56-56:
task 6 'view-object'. lines 57-57:
Owner: Account Address ( A )
Version: 2
Contents: sui::coin::DenyCap<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -110,7 +110,7 @@ Contents: sui::coin::DenyCap<test::regulated_coin::REGULATED_COIN> {
},
}

task 7 'view-object'. lines 58-58:
task 7 'view-object'. lines 59-59:
Owner: Immutable
Version: 2
Contents: sui::coin::RegulatedCoinMetadata<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -127,7 +127,7 @@ Contents: sui::coin::RegulatedCoinMetadata<test::regulated_coin::REGULATED_COIN>
},
}

task 8 'view-object'. lines 60-62:
task 8 'view-object'. lines 61-63:
Owner: Immutable
Version: 2
Contents: sui::coin::TreasuryCap<test::regulated_coin::REGULATED_COIN> {
Expand All @@ -141,19 +141,19 @@ Contents: sui::coin::TreasuryCap<test::regulated_coin::REGULATED_COIN> {
},
}

task 9 'run'. lines 63-65:
task 9 'run'. lines 64-66:
created: object(9,0), object(9,1)
mutated: object(_), 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,4)
gas summary: computation_cost: 1000000, storage_cost: 11415200, storage_rebate: 2723688, non_refundable_storage_fee: 27512

task 10 'run'. lines 66-68:
task 10 'run'. lines 67-69:
Error: Error checking transaction input objects: AddressDeniedForCoin { address: @A, coin_type: "object(1,1)::regulated_coin::REGULATED_COIN" }

task 11 'run'. lines 69-71:
task 11 'run'. lines 70-72:
mutated: object(_), 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,4), object(9,1)
deleted: object(9,0)
gas summary: computation_cost: 1000000, storage_cost: 9522800, storage_rebate: 11301048, non_refundable_storage_fee: 114152

task 12 'run'. lines 72-72:
task 12 'run'. lines 73-73:
mutated: object(0,0), object(1,0), object(1,2)
gas summary: computation_cost: 1000000, storage_cost: 3807600, storage_rebate: 3769524, non_refundable_storage_fee: 38076
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//# init --accounts A --addresses test=0x0

//# publish --sender A
#[allow(deprecated_usage)]
module test::regulated_coin {
use sui::coin;
use sui::coin::Coin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 9

task 15 'run'. lines 113-115:
mutated: 0x0000000000000000000000000000000000000000000000000000000000000403, object(0,0), object(1,3), object(5,1)
gas summary: computation_cost: 1000000, storage_cost: 6665200, storage_rebate: 6591024, non_refundable_storage_fee: 66576
gas summary: computation_cost: 1000000, storage_cost: 6657600, storage_rebate: 6591024, non_refundable_storage_fee: 66576

task 16 'run'. lines 116-118:
mutated: object(0,0)
Expand Down
37 changes: 37 additions & 0 deletions crates/sui-framework/docs/sui-framework/coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tokens and coins. <code><a href="../sui-framework/coin.md#0x2_coin_Coin">Coin</a
- [Function `destroy_zero`](#0x2_coin_destroy_zero)
- [Function `create_currency`](#0x2_coin_create_currency)
- [Function `create_regulated_currency_v2`](#0x2_coin_create_regulated_currency_v2)
- [Function `migrate_regulated_currency_to_v2`](#0x2_coin_migrate_regulated_currency_to_v2)
- [Function `mint`](#0x2_coin_mint)
- [Function `mint_balance`](#0x2_coin_mint_balance)
- [Function `burn`](#0x2_coin_burn)
Expand Down Expand Up @@ -926,6 +927,42 @@ type, ensuring that there's only one <code><a href="../sui-framework/coin.md#0x2



</details>

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

## Function `migrate_regulated_currency_to_v2`



<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_migrate_regulated_currency_to_v2">migrate_regulated_currency_to_v2</a>&lt;T&gt;(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">deny_list::DenyList</a>, cap: <a href="../sui-framework/coin.md#0x2_coin_DenyCap">coin::DenyCap</a>&lt;T&gt;, allow_global_pause: bool, ctx: &<b>mut</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="../sui-framework/coin.md#0x2_coin_DenyCapV2">coin::DenyCapV2</a>&lt;T&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/coin.md#0x2_coin_migrate_regulated_currency_to_v2">migrate_regulated_currency_to_v2</a>&lt;T&gt;(
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<b>mut</b> DenyList,
cap: <a href="../sui-framework/coin.md#0x2_coin_DenyCap">DenyCap</a>&lt;T&gt;,
allow_global_pause: bool,
ctx: &<b>mut</b> TxContext,
): <a href="../sui-framework/coin.md#0x2_coin_DenyCapV2">DenyCapV2</a>&lt;T&gt; {
<b>let</b> <a href="../sui-framework/coin.md#0x2_coin_DenyCap">DenyCap</a> { id } = cap;
<a href="../sui-framework/object.md#0x2_object_delete">object::delete</a>(id);
<b>let</b> ty = <a href="../move-stdlib/type_name.md#0x1_type_name_get_with_original_ids">type_name::get_with_original_ids</a>&lt;T&gt;().into_string().into_bytes();
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.migrate_v1_to_v2(<a href="../sui-framework/coin.md#0x2_coin_DENY_LIST_COIN_INDEX">DENY_LIST_COIN_INDEX</a>, ty, ctx);
<a href="../sui-framework/coin.md#0x2_coin_DenyCapV2">DenyCapV2</a> {
id: <a href="../sui-framework/object.md#0x2_object_new">object::new</a>(ctx),
allow_global_pause,
}
}
</code></pre>



</details>

<a name="0x2_coin_mint"></a>
Expand Down
Loading

0 comments on commit afe6d26

Please sign in to comment.