-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade Errors for struct enum functions (#20151)
## Description Add struct, enum and function errors to upgrade errors, leaves out type params to give it, it's own PR. ## Test plan snapshots --- ## Release notes no effect until enabled 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: - [ ] REST API:
- Loading branch information
1 parent
cfb8268
commit 961cd5c
Showing
26 changed files
with
1,583 additions
and
56 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/enum_errors_v1/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
77 changes: 77 additions & 0 deletions
77
crates/sui/src/unit_tests/fixtures/upgrade_errors/enum_errors_v1/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
|
||
public enum EnumAddAbility has copy { // add drop | ||
A, | ||
} | ||
|
||
public enum EnumRemoveAbility has copy, drop { | ||
A, | ||
} | ||
|
||
public enum EnumAddAndRemoveAbility has copy, drop { | ||
A, | ||
} | ||
|
||
public enum EnumAddVariant { | ||
A, | ||
// B, to be added | ||
} | ||
|
||
public enum EnumRemoveVariant { | ||
A, | ||
B, // to be removed | ||
} | ||
|
||
public enum EnumChangeVariant { | ||
A, | ||
B, // to be changed to C | ||
} | ||
|
||
public enum EnumChangeAndAddVariant { | ||
A, | ||
B, // to be changed to C | ||
// D, to be added | ||
} | ||
|
||
public enum EnumChangeAndRemoveVariant { | ||
A, | ||
B, // to be changed to C | ||
C, // to be removed | ||
} | ||
|
||
public enum EnumAddAbilityWithTypes has copy { // add drop | ||
A { a: u8 }, | ||
} | ||
|
||
public enum EnumRemoveAbilityWithTypes has copy, drop { | ||
A { a: u8 }, | ||
} | ||
|
||
public enum EnumAddVariantWithTypes { | ||
A { a: u8 }, | ||
// B { b: u8 }, to be added | ||
} | ||
|
||
public enum EnumRemoveVariantWithTypes { | ||
A { a: u8 }, | ||
B { b: u8 }, // to be removed | ||
} | ||
|
||
public enum EnumChangeVariantWithTypes { | ||
A { a: u8 }, | ||
B { b: u8 }, // to be changed to C | ||
} | ||
|
||
public enum EnumChangeAndAddVariantWithTypes { | ||
A { a: u8 }, | ||
B { b: u8 }, // to be changed to C | ||
// D { d: u8 }, to be added | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/enum_errors_v2/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
79 changes: 79 additions & 0 deletions
79
crates/sui/src/unit_tests/fixtures/upgrade_errors/enum_errors_v2/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
|
||
public enum EnumAddAbility has copy, drop { // add drop | ||
A, | ||
} | ||
|
||
public enum EnumRemoveAbility has copy { // drop removed | ||
A, | ||
} | ||
|
||
public enum EnumAddAndRemoveAbility has copy, store { | ||
A, | ||
} | ||
|
||
public enum EnumAddVariant { | ||
A, | ||
B, // added | ||
} | ||
|
||
public enum EnumRemoveVariant { | ||
A, | ||
// B, removed | ||
} | ||
|
||
public enum EnumChangeVariant { | ||
A, | ||
C, // changed from B | ||
} | ||
|
||
public enum EnumChangeAndAddVariant { | ||
A, | ||
C, // to be changed to C | ||
D // added | ||
} | ||
|
||
public enum EnumChangeAndRemoveVariant { | ||
A, | ||
C, // changed to C | ||
// removed C, | ||
} | ||
|
||
// with types | ||
public enum EnumAddAbilityWithTypes has copy, drop { // drop added | ||
A { a: u8 }, | ||
} | ||
|
||
public enum EnumRemoveAbilityWithTypes has copy { // drop removed | ||
A { a: u8 }, | ||
} | ||
|
||
public enum EnumAddVariantWithTypes { | ||
A { a: u8 }, | ||
B { b: u8 }, // added | ||
} | ||
|
||
public enum EnumRemoveVariantWithTypes { | ||
A { a: u8 }, | ||
// B { b: u8 }, removed | ||
} | ||
|
||
public enum EnumChangeVariantWithTypes { | ||
A { a: u8 }, | ||
C { b: u8 }, // changed to C | ||
} | ||
|
||
public enum EnumChangeAndAddVariantWithTypes { | ||
A { a: u8 }, | ||
C { b: u8 }, // to be changed to C | ||
D { d: u8 }, // added | ||
} | ||
|
||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/function_errors_v1/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
28 changes: 28 additions & 0 deletions
28
.../sui/src/unit_tests/fixtures/upgrade_errors/function_errors_v1/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
public fun func_with_wrong_param(a: u64): u64 { | ||
0 | ||
} | ||
|
||
public fun func_with_wrong_return(): u64 { | ||
0 | ||
} | ||
|
||
public fun func_with_wrong_param_and_return(a: u64): u64 { | ||
0 | ||
} | ||
|
||
public fun func_with_wrong_param_length(a: u64, b: u64): u64 { | ||
0 | ||
} | ||
|
||
public fun func_with_wrong_return_length(): (u64, u64) { | ||
(0,0) | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/function_errors_v2/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
33 changes: 33 additions & 0 deletions
33
.../sui/src/unit_tests/fixtures/upgrade_errors/function_errors_v2/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
// changed argument from u64 to u32 | ||
public fun func_with_wrong_param(a: u32): u64 { | ||
0 | ||
} | ||
|
||
// changed return type from u64 to u32 | ||
public fun func_with_wrong_return(): u32 { | ||
0 | ||
} | ||
|
||
// changed argument from u64 to u32 and return type from u64 to u32 | ||
public fun func_with_wrong_param_and_return(a: u32): u32 { | ||
0 | ||
} | ||
|
||
// removed second argument | ||
public fun func_with_wrong_param_length(a: u64): u64 { | ||
0 | ||
} | ||
|
||
// changed return type from (u64, u64) to u64 | ||
public fun func_with_wrong_return_length(): u64 { | ||
0 | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/struct_errors_v1/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
37 changes: 37 additions & 0 deletions
37
...es/sui/src/unit_tests/fixtures/upgrade_errors/struct_errors_v1/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
|
||
// ability mismatch | ||
public struct AddExtraAbility {} | ||
public struct RemoveAbility has copy, drop {} | ||
public struct AddAndRemoveAbility has copy, drop {} | ||
public struct RemoveMultipleAbilities has copy, drop, store {} | ||
public struct AddMultipleAbilities {} | ||
|
||
|
||
// field mismatch | ||
public struct AddField {} | ||
// remove field | ||
public struct RemoveField { | ||
a: u64, | ||
b: u64, // remove this field | ||
} | ||
|
||
// change field name | ||
public struct ChangeFieldName { | ||
a: u64, | ||
b: u64, // change this field name to c | ||
} | ||
|
||
// change field type | ||
public struct ChangeFieldType { | ||
a: u64, | ||
b: u64, // change this field type to u32 | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
crates/sui/src/unit_tests/fixtures/upgrade_errors/struct_errors_v2/Move.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "upgrades" | ||
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move | ||
|
||
[addresses] | ||
upgrades = "0x0" |
39 changes: 39 additions & 0 deletions
39
...es/sui/src/unit_tests/fixtures/upgrade_errors/struct_errors_v2/sources/UpgradeErrors.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/// Module: UpgradeErrors | ||
|
||
#[allow(unused_field)] | ||
module upgrades::upgrades { | ||
|
||
// ability mismatch | ||
public struct AddExtraAbility has copy {} // added copy | ||
public struct RemoveAbility has drop {} // removed copy | ||
public struct AddAndRemoveAbility has drop, store {} // remove copy, add store | ||
public struct RemoveMultipleAbilities has drop {} // remove copy, store | ||
public struct AddMultipleAbilities has drop, copy {} | ||
|
||
// field mismatch | ||
public struct AddField { | ||
a: u64, | ||
b: u64, | ||
} | ||
// remove field | ||
public struct RemoveField { | ||
a: u64, | ||
// b removed here | ||
} | ||
|
||
// change field name | ||
public struct ChangeFieldName { | ||
a: u64, | ||
c: u64, // changed from b to c | ||
} | ||
|
||
// change field type | ||
public struct ChangeFieldType { | ||
a: u64, | ||
b: u32, // changed to u32 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.