Skip to content

Commit

Permalink
upgrade migrate signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Dec 16, 2024
1 parent c690b4b commit e23e6cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions move/axelar_gateway/sources/gateway.move
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ entry fun rotate_signers(
/// This function should only be called once
/// (checks should be made on versioned to ensure this)
/// It upgrades the version control to the new version control.
entry fun migrate(self: &mut Gateway) {
self.inner.load_value_mut<Gateway_v0>().migrate(version_control());
entry fun migrate(self: &mut Gateway, _: &OwnerCap, data: vector<u8>) {
self.inner.load_value_mut<Gateway_v0>().migrate(version_control(), data);
}

entry fun allow_function(
Expand Down
7 changes: 6 additions & 1 deletion move/axelar_gateway/sources/versioned/gateway_v0.move
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const ENewerMessage: vector<u8> =
const ECannotMigrateTwice: vector<u8> =
b"attempting to migrate a even though migration is complete";

#[error]
const ENoDataAllowedOnMigrate: vector<u8> =
b"no data should be passed to migrate to this version";

// -----
// Types
// -----
Expand Down Expand Up @@ -79,8 +83,9 @@ public(package) fun version_control(self: &Gateway_v0): &VersionControl {
&self.version_control
}

public(package) fun migrate(self: &mut Gateway_v0, mut version_control: VersionControl) {
public(package) fun migrate(self: &mut Gateway_v0, mut version_control: VersionControl, data: vector<u8>) {
assert!(self.version_control.allowed_functions().length() == version_control.allowed_functions().length() - 1, ECannotMigrateTwice );
assert!(data.length() == 0, ENoDataAllowedOnMigrate);
self.version_control = version_control;
}

Expand Down

0 comments on commit e23e6cf

Please sign in to comment.