Skip to content

Commit f2b60d0

Browse files
JSHan94beer-1
andauthored
fix vesting_store_seed to use @initia_std (#68)
* fix vesting_store_seed to use @initia_std * use type_name * change import * change to private * recompile vip contracts * fix movefmt --------- Co-authored-by: beer-1 <[email protected]>
1 parent c297d31 commit f2b60d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4339
-3936
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ build-go: prebuild-go
8282

8383
fmt:
8484
cargo fmt
85+
8586
move-fmt: install-move-fmt
86-
cargo fmt
87+
movefmt
88+
8789
install-move-fmt:
8890
cargo install --git https://github.com/movebit/movefmt --branch develop movefmt
91+
8992
update-bindings:
9093
cp libmovevm/bindings.h api
9194
cp libcompiler/bindings_compiler.h api

crates/e2e-move-tests/src/tests/args.data/pack/sources/hello.move

+7-8
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ module 0xCAFE::test {
4949
find_hello_in_option_msgs(&msgs);
5050

5151
let msg = vector::borrow(&msgs, i);
52-
let str_msg =
53-
if (option::is_some(msg)) {
54-
*option::borrow(msg)
55-
} else {
56-
string::utf8(vector::empty())
57-
};
52+
let str_msg = if (option::is_some(msg)) {
53+
*option::borrow(msg)
54+
} else {
55+
string::utf8(vector::empty())
56+
};
5857

5958
hi(sender, str_msg);
6059
}
@@ -89,8 +88,8 @@ module 0xCAFE::test {
8988
move_to(sender,
9089
ModuleData<String> { state: *vector::borrow(vector::borrow(&msgs, i), j) });
9190
} else {
92-
borrow_global_mut<ModuleData<String>>(addr).state = *vector::borrow(vector::borrow(
93-
&msgs, i), j);
91+
borrow_global_mut<ModuleData<String>>(addr).state = *vector::borrow(
92+
vector::borrow(&msgs, i), j);
9493
}
9594
}
9695

crates/e2e-move-tests/src/tests/std_coin.data/pack/sources/StdCoin.move

+9-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ module 0x2::StdCoin {
1313
}
1414

1515
entry fun init(sender: &signer) {
16-
let (mint, burn, freeze) =
17-
coin::initialize(sender,
18-
option::none(),
19-
string::utf8(b"Std Coin"),
20-
string::utf8(b"STDC"),
21-
8,
22-
string::utf8(b""),
23-
string::utf8(b""),);
16+
let (mint, burn, freeze) = coin::initialize(
17+
sender,
18+
option::none(),
19+
string::utf8(b"Std Coin"),
20+
string::utf8(b"STDC"),
21+
8,
22+
string::utf8(b""),
23+
string::utf8(b""),
24+
);
2425

2526
move_to(sender, CapStore { burn, freeze, mint });
2627
}

precompile/binaries/stdlib/vip.mv

359 Bytes
Binary file not shown.
10 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

precompile/modules/initia_stdlib/sources/account.move

+22-24
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,10 @@ module initia_std::account {
134134
#[test]
135135
public fun test_create_account() {
136136
// base account
137-
let bob =
138-
create_address(
139-
x"0000000000000000000000000000000000000000000000000000000000000b0b");
140-
let carol =
141-
create_address(
142-
x"00000000000000000000000000000000000000000000000000000000000ca501");
137+
let bob = create_address(
138+
x"0000000000000000000000000000000000000000000000000000000000000b0b");
139+
let carol = create_address(
140+
x"00000000000000000000000000000000000000000000000000000000000ca501");
143141
assert!(!exists_at(bob), 0);
144142
assert!(!exists_at(carol), 1);
145143

@@ -156,19 +154,17 @@ module initia_std::account {
156154
assert!(carol_account_num == get_account_number(carol), 7);
157155

158156
// object account
159-
let dan =
160-
create_address(
161-
x"000000000000000000000000000000000000000000000000000000000000da17");
157+
let dan = create_address(
158+
x"000000000000000000000000000000000000000000000000000000000000da17");
162159
assert!(!exists_at(dan), 8);
163160
let dan_object_account_num = create_object_account(dan);
164161
assert!(dan_object_account_num == get_account_number(dan), 9);
165162
assert!(is_object_account(dan), 10);
166163
assert!(exists_at(dan), 11);
167164

168165
// table account
169-
let erin =
170-
create_address(
171-
x"00000000000000000000000000000000000000000000000000000000000e5117");
166+
let erin = create_address(
167+
x"00000000000000000000000000000000000000000000000000000000000e5117");
172168
assert!(!exists_at(erin), 12);
173169
let erin_table_account_num = create_table_account(erin);
174170
assert!(erin_table_account_num == get_account_number(erin), 13);
@@ -178,16 +174,14 @@ module initia_std::account {
178174

179175
#[test]
180176
public fun test_create_address() {
181-
let bob =
182-
create_address(
183-
x"0000000000000000000000000000000000000000000000000000000000000b0b");
184-
let carol =
185-
create_address(
186-
x"00000000000000000000000000000000000000000000000000000000000ca501");
187-
assert!(bob
188-
== @0x0000000000000000000000000000000000000000000000000000000000000b0b, 0);
189-
assert!(carol
190-
== @0x00000000000000000000000000000000000000000000000000000000000ca501, 1);
177+
let bob = create_address(
178+
x"0000000000000000000000000000000000000000000000000000000000000b0b");
179+
let carol = create_address(
180+
x"00000000000000000000000000000000000000000000000000000000000ca501");
181+
assert!(bob == @0x0000000000000000000000000000000000000000000000000000000000000b0b,
182+
0);
183+
assert!(carol ==
184+
@0x00000000000000000000000000000000000000000000000000000000000ca501, 1);
191185
}
192186

193187
#[test(new_address = @0x42)]
@@ -240,14 +234,18 @@ module initia_std::account {
240234

241235
#[test(new_address = @0x42)]
242236
#[expected_failure(abort_code = 0x80064, location = Self)]
243-
public fun test_create_table_account_already_exists(new_address: address) {
237+
public fun test_create_table_account_already_exists(
238+
new_address: address
239+
) {
244240
create_table_account(new_address);
245241
create_table_account(new_address);
246242
}
247243

248244
#[test(new_address = @0x42)]
249245
#[expected_failure(abort_code = 0x80064, location = Self)]
250-
public fun test_create_object_account_already_exists(new_address: address) {
246+
public fun test_create_object_account_already_exists(
247+
new_address: address
248+
) {
251249
create_table_account(new_address);
252250
create_object_account(new_address);
253251
}

precompile/modules/initia_stdlib/sources/address.move

+4-6
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ module initia_std::address {
4343
#[test]
4444
fun test_to_string() {
4545
let addr = @0x123abc;
46-
let addr_str =
47-
string::utf8(
48-
b"0x0000000000000000000000000000000000000000000000000000000000123abc");
46+
let addr_str = string::utf8(
47+
b"0x0000000000000000000000000000000000000000000000000000000000123abc");
4948
assert!(to_string(addr) == addr_str, 0)
5049
}
5150

5251
#[test]
5352
fun test_from_string() {
5453
let addr = @0x908def;
55-
let addr_str =
56-
string::utf8(
57-
b"0x0000000000000000000000000000000000000000000000000000000000908def");
54+
let addr_str = string::utf8(
55+
b"0x0000000000000000000000000000000000000000000000000000000000908def");
5856
assert!(from_string(addr_str) == addr, 0)
5957
}
6058

precompile/modules/initia_stdlib/sources/code.move

+9-7
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ module initia_std::code {
106106
error::permission_denied(EINVALID_CHAIN_OPERATOR));
107107

108108
let metadata_table = table::new<String, ModuleMetadata>();
109-
vector::for_each_ref(&module_ids,
109+
vector::for_each_ref(
110+
&module_ids,
110111
|module_id| {
111112
table::add<String, ModuleMetadata>(&mut metadata_table, *module_id,
112113
ModuleMetadata { upgrade_policy: UPGRADE_POLICY_COMPATIBLE, });
@@ -143,7 +144,8 @@ module initia_std::code {
143144

144145
// duplication check
145146
let module_ids_set = simple_map::create<String, bool>();
146-
vector::for_each_ref(&module_ids,
147+
vector::for_each_ref(
148+
&module_ids,
147149
|module_id| {
148150
assert!(!simple_map::contains_key(&module_ids_set, module_id),
149151
error::invalid_argument(EDUPLICATE_MODULE_ID));
@@ -164,15 +166,15 @@ module initia_std::code {
164166

165167
// Check upgradability
166168
let metadata_table = &mut borrow_global_mut<MetadataStore>(addr).metadata;
167-
vector::for_each_ref(&module_ids,
169+
vector::for_each_ref(
170+
&module_ids,
168171
|module_id| {
169172
if (table::contains<String, ModuleMetadata>(metadata_table, *module_id)) {
170-
let metadata =
171-
table::borrow_mut<String, ModuleMetadata>(metadata_table, *module_id);
173+
let metadata = table::borrow_mut<String, ModuleMetadata>(metadata_table, *module_id);
172174
assert!(metadata.upgrade_policy < UPGRADE_POLICY_IMMUTABLE,
173175
error::invalid_argument(EUPGRADE_IMMUTABLE));
174-
assert!(can_change_upgrade_policy_to(metadata.upgrade_policy,
175-
upgrade_policy),
176+
assert!(
177+
can_change_upgrade_policy_to(metadata.upgrade_policy, upgrade_policy),
176178
error::invalid_argument(EUPGRADE_WEAKER_POLICY));
177179

178180
metadata.upgrade_policy = upgrade_policy;

precompile/modules/initia_stdlib/sources/coin.move

+27-26
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ module initia_std::coin {
6060
icon_uri: String,
6161
project_uri: String,
6262
): (MintCapability, BurnCapability, FreezeCapability) {
63-
let (mint_cap, burn_cap, freeze_cap, _) =
64-
initialize_and_generate_extend_ref(creator, maximum_supply, name, symbol,
65-
decimals, icon_uri, project_uri,);
63+
let (mint_cap, burn_cap, freeze_cap, _) = initialize_and_generate_extend_ref(creator,
64+
maximum_supply, name, symbol, decimals, icon_uri, project_uri,);
6665

6766
(mint_cap, burn_cap, freeze_cap)
6867
}
@@ -77,16 +76,18 @@ module initia_std::coin {
7776
project_uri: String,
7877
): (MintCapability, BurnCapability, FreezeCapability, ExtendRef) {
7978
// create object for fungible asset metadata
80-
let constructor_ref =
81-
&object::create_named_object(creator, *string::bytes(&symbol), false);
79+
let constructor_ref = &object::create_named_object(creator, *string::bytes(&symbol),
80+
false);
8281

83-
primary_fungible_store::create_primary_store_enabled_fungible_asset(constructor_ref,
82+
primary_fungible_store::create_primary_store_enabled_fungible_asset(
83+
constructor_ref,
8484
maximum_supply,
8585
name,
8686
symbol,
8787
decimals,
8888
icon_uri,
89-
project_uri,);
89+
project_uri,
90+
);
9091

9192
let mint_ref = fungible_asset::generate_mint_ref(constructor_ref);
9293
let burn_ref = fungible_asset::generate_burn_ref(constructor_ref);
@@ -286,14 +287,14 @@ module initia_std::coin {
286287

287288
#[view]
288289
public fun denom_to_metadata(denom: String): Object<Metadata> {
289-
let addr =
290-
if (string::length(&denom) > 5 && &b"move/" == string::bytes(&string::sub_string(&denom, 0, 5))) {
291-
let len = string::length(&denom);
292-
let hex_string = string::sub_string(&denom, 5, len);
293-
from_bcs::to_address(hex::decode_string(&hex_string))
294-
} else {
295-
metadata_address(@initia_std, denom)
296-
};
290+
let addr = if (string::length(&denom) > 5 && &b"move/" == string::bytes(
291+
&string::sub_string(&denom, 0, 5))) {
292+
let len = string::length(&denom);
293+
let hex_string = string::sub_string(&denom, 5, len);
294+
from_bcs::to_address(hex::decode_string(&hex_string))
295+
} else {
296+
metadata_address(@initia_std, denom)
297+
};
297298

298299
object::address_to_object(addr)
299300
}
@@ -302,16 +303,17 @@ module initia_std::coin {
302303
fun initialized_coin(account: &signer, symbol: String,)
303304
: (BurnCapability, FreezeCapability,
304305
MintCapability) {
305-
let (mint_cap, burn_cap, freeze_cap, _) =
306-
initialize_and_generate_extend_ref(account,
307-
std::option::none(),
308-
string::utf8(b""),
309-
symbol,
310-
6,
311-
string::utf8(b""),
312-
string::utf8(b""),);
306+
let (mint_cap, burn_cap, freeze_cap, _) = initialize_and_generate_extend_ref(
307+
account,
308+
std::option::none(),
309+
string::utf8(b""),
310+
symbol,
311+
6,
312+
string::utf8(b""),
313+
string::utf8(b""),
314+
);
313315

314-
return(burn_cap, freeze_cap, mint_cap)
316+
return (burn_cap, freeze_cap, mint_cap)
315317
}
316318

317319
#[test(chain = @0x1, not_chain = @0x2)]
@@ -320,8 +322,7 @@ module initia_std::coin {
320322
initialized_coin(&chain, string::utf8(b"INIT"));
321323
initialized_coin(&not_chain, string::utf8(b"INIT"));
322324
let metadata = metadata(std::signer::address_of(&chain), string::utf8(b"INIT"));
323-
let metadata_ =
324-
metadata(std::signer::address_of(&not_chain), string::utf8(b"INIT"));
325+
let metadata_ = metadata(std::signer::address_of(&not_chain), string::utf8(b"INIT"));
325326
let denom = metadata_to_denom(metadata);
326327
let denom_ = metadata_to_denom(metadata_);
327328
let metadata_from_denom = denom_to_metadata(denom);

precompile/modules/initia_stdlib/sources/comparator.move

+4-8
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,13 @@ module initia_std::comparator {
121121
vector::push_back(&mut value0_1, 5);
122122
vector::push_back(&mut value0_1, 1);
123123

124-
let base =
125-
Complex { value0: value0_0, value1: 13, value2: 41, };
124+
let base = Complex { value0: value0_0, value1: 13, value2: 41, };
126125

127-
let other_0 =
128-
Complex { value0: value0_1, value1: 13, value2: 41, };
126+
let other_0 = Complex { value0: value0_1, value1: 13, value2: 41, };
129127

130-
let other_1 =
131-
Complex { value0: copy value0_0, value1: 14, value2: 41, };
128+
let other_1 = Complex { value0: copy value0_0, value1: 14, value2: 41, };
132129

133-
let other_2 =
134-
Complex { value0: value0_0, value1: 13, value2: 42, };
130+
let other_2 = Complex { value0: value0_0, value1: 13, value2: 42, };
135131

136132
assert!(is_equal(&compare(&base, &base)), 0);
137133
assert!(is_smaller_than(&compare(&base, &other_0)), 1);

0 commit comments

Comments
 (0)