-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(move): 2024 syntax update #47
Conversation
Code Coverage SummaryClick to see the summary
Click to see the extended report
|
@@ -149,7 +149,7 @@ module abi::abi { | |||
while (i < 32) { | |||
let exp = ((31 - i) * 8 as u8); | |||
let byte = (var >> exp & 255 as u8); | |||
*self.bytes.borrow_mut(i + pos) = byte; | |||
*&mut self.bytes[i + pos] = byte; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
@@ -42,7 +42,7 @@ module its::discovery { | |||
public fun register_transaction(self: &mut ITS, discovery: &mut RelayerDiscovery) { | |||
self.set_relayer_discovery_id(discovery); | |||
let mut arg = vector[0]; | |||
vector::append(&mut arg, bcs::to_bytes(&object::id(self))); | |||
arg.append(bcs::to_bytes(&object::id(self))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arg.append(bcs::to_bytes(&object::id(self))); | |
arg.append(object::id(self).to_bytes()); |
@@ -88,7 +88,7 @@ module its::discovery { | |||
|
|||
if (data.is_empty()) { | |||
let mut arg = vector[0]; | |||
vector::append(&mut arg, address::to_bytes(object::id_address(self))); | |||
arg.append(address::to_bytes(object::id_address(self))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arg.append(address::to_bytes(object::id_address(self))); | |
arg.append(object::id_address(self).to_bytes()); |
@@ -137,7 +137,7 @@ module its::discovery { | |||
|
|||
fun get_deploy_interchain_token_tx(self: &ITS, reader: &mut AbiReader): Transaction { | |||
let mut arg = vector[0]; | |||
vector::append(&mut arg, address::to_bytes(object::id_address(self))); | |||
arg.append(address::to_bytes(object::id_address(self))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same everywhere
@@ -138,7 +138,7 @@ module its::its { | |||
} | |||
|
|||
public(package) fun coin_data_mut<T>(self: &mut ITS, token_id: TokenId): &mut CoinData<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of these mut functions aren't needed anymore since you can borrow_mut directly. For e.g. this helper is only used in the above method, and you can use the &mut ... there directly
@@ -138,7 +138,7 @@ module its::its { | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look into #[syntax(index)]
. See example for a table here
https://github.com/MystenLabs/sui/blob/main/crates/sui-framework/packages/sui-framework/sources/table.move#L56
@@ -90,7 +90,7 @@ module its::token_id { | |||
let coin_info = coin_info::from_info<String>(name, symbol, decimals); | |||
let mut vec = address::to_bytes(address::from_u256(PREFIX_SUI_TOKEN_ID)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -35,7 +35,7 @@ module test::test { | |||
let mut arg = vector::singleton<u8>(2); | |||
arguments.push_back(arg); | |||
arg = vector::singleton<u8>(0); | |||
vector::append(&mut arg, address::to_bytes(object::id_address(singleton))); | |||
arg.append(address::to_bytes(object::id_address(singleton))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
AXE-4126
sui::coin::withdraw(&mut c, 10)
->c.withdraw(10)
x.borrow(i)
->&x[i]