From 45ee7d31c58799e084230eacc28436356e810343 Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Tue, 27 Aug 2024 12:21:57 -0400 Subject: [PATCH 1/7] fix: redirect to --skip-faucet and link to faucet ui --- .movement/config.yaml | 9 +++++++++ crates/aptos/src/common/init.rs | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .movement/config.yaml diff --git a/.movement/config.yaml b/.movement/config.yaml new file mode 100644 index 0000000000000..bf18da9708b1a --- /dev/null +++ b/.movement/config.yaml @@ -0,0 +1,9 @@ +--- +profiles: + default: + network: Testnet + private_key: "0x533ec968be7481004693402410fc5d4a623a668218506c1443f3225fb2d10c2b" + public_key: "0x8980d4eebfd2ebd08e7a886bf6fcbb229767a1cc10a24eb2599322a1ef2a0152" + account: 0779feaacef83fcee0f6e4816c0ec8e1c46668aceced78b4469808ddf6809798 + rest_url: "https://aptos.testnet.suzuka.movementlabs.xyz/v1/" + faucet_url: "https://faucet.testnet.suzuka.movementlabs.xyz/" diff --git a/crates/aptos/src/common/init.rs b/crates/aptos/src/common/init.rs index fc5f10b0f9639..38018db63a196 100644 --- a/crates/aptos/src/common/init.rs +++ b/crates/aptos/src/common/init.rs @@ -121,6 +121,8 @@ impl CliCommand<()> for InitTool { if input.is_empty() { eprintln!("No network given, using devnet..."); Network::Devnet + } else if input.eq_ignore_ascii_case("testnet") && self.skip_faucet { + Network::Testnet } else { Network::from_str(input)? } @@ -349,7 +351,9 @@ impl CliCommand<()> for InitTool { .profile_name() .unwrap_or(DEFAULT_PROFILE); eprintln!( - "\n---\nMovement CLI is now set up for account {} as profile {}!\n See the account here: {}\n Run `movement --help` for more information about commands", + "\n---\nMovement CLI is now set up for account {} as profile {}!\n See the account here: {}\n + Run `movement --help` for more information about commands. \n + Visit https://faucet.movementlabs.xyz to use the testnet faucet.", address, profile_name, explorer_account_link(address, Some(network)) @@ -465,7 +469,11 @@ impl FromStr for Network { fn from_str(s: &str) -> Result { Ok(match s.to_lowercase().trim() { // "mainnet" => Self::Mainnet, - "testnet" => Self::Testnet, + "testnet" => { + return Err(CliError::CommandArgumentError(format!( + "To use testnet, run `movement init --skip-faucet`, follow the prompts to create an account address, then visit the faucet UI at https://faucet.movementlabs.xyz to fund the account." + ))); + }, "devnet" => Self::Devnet, "local" => Self::Local, "custom" => Self::Custom, From 89ffadf7db9a79c8b87094ddf9845cff2d72ff7d Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Tue, 27 Aug 2024 12:35:48 -0400 Subject: [PATCH 2/7] fix: delete .movement/config.yaml --- .movement/config.yaml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .movement/config.yaml diff --git a/.movement/config.yaml b/.movement/config.yaml deleted file mode 100644 index bf18da9708b1a..0000000000000 --- a/.movement/config.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -profiles: - default: - network: Testnet - private_key: "0x533ec968be7481004693402410fc5d4a623a668218506c1443f3225fb2d10c2b" - public_key: "0x8980d4eebfd2ebd08e7a886bf6fcbb229767a1cc10a24eb2599322a1ef2a0152" - account: 0779feaacef83fcee0f6e4816c0ec8e1c46668aceced78b4469808ddf6809798 - rest_url: "https://aptos.testnet.suzuka.movementlabs.xyz/v1/" - faucet_url: "https://faucet.testnet.suzuka.movementlabs.xyz/" From 8daa93581c9334e4ef6ad4df96578194d7eca7f6 Mon Sep 17 00:00:00 2001 From: Philippe Delrieu Date: Thu, 29 Aug 2024 10:32:37 +0200 Subject: [PATCH 3/7] remove panic in write_set_change grpc convertion (#63) --- .../indexer-grpc-fullnode/src/convert.rs | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs index 677a49ec40518..4b17ee47fa347 100644 --- a/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs +++ b/ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs @@ -330,29 +330,32 @@ pub fn convert_write_set_change(change: &WriteSetChange) -> transaction::WriteSe )), }, WriteSetChange::DeleteTableItem(delete_table_item) => { - let data = delete_table_item.data.as_ref().unwrap_or_else(|| { - panic!( - "Could not extract data from DeletedTableItem '{:?}' with handle '{:?}'", - delete_table_item, - delete_table_item.handle.to_string() - ) - }); + let data = delete_table_item.data.as_ref(); + // .unwrap_or_else(|| { + // panic!( + // "Could not extract data from DeletedTableItem '{:?}' with handle '{:?}'", + // delete_table_item, + // delete_table_item.handle.to_string() + // ) + // }); transaction::WriteSetChange { r#type: transaction::write_set_change::Type::DeleteTableItem as i32, - change: Some(transaction::write_set_change::Change::DeleteTableItem( - transaction::DeleteTableItem { - state_key_hash: convert_hex_string_to_bytes( - &delete_table_item.state_key_hash, - ), - handle: delete_table_item.handle.to_string(), - key: delete_table_item.key.to_string(), - data: Some(transaction::DeleteTableData { - key: data.key.to_string(), - key_type: data.key_type.clone(), - }), - }, - )), + change: data.map(|data| { + transaction::write_set_change::Change::DeleteTableItem( + transaction::DeleteTableItem { + state_key_hash: convert_hex_string_to_bytes( + &delete_table_item.state_key_hash, + ), + handle: delete_table_item.handle.to_string(), + key: delete_table_item.key.to_string(), + data: Some(transaction::DeleteTableData { + key: data.key.to_string(), + key_type: data.key_type.clone(), + }), + }, + ) + }), } }, WriteSetChange::WriteModule(write_module) => transaction::WriteSetChange { @@ -374,10 +377,11 @@ pub fn convert_write_set_change(change: &WriteSetChange) -> transaction::WriteSe r#type: Some(convert_move_struct_tag(&write_resource.data.typ)), type_str: write_resource.data.typ.to_string(), data: serde_json::to_string(&write_resource.data.data).unwrap_or_else(|_| { - panic!( - "Could not convert move_resource data to json '{:?}'", - write_resource.data - ) + "{}".to_string() + // panic!( + // "Could not convert move_resource data to json '{:?}'", + // write_resource.data + // ) }), }, )), From 3da1e8eb48cb5bcb5345297cbb6268be05964b27 Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Wed, 4 Sep 2024 07:36:43 -0400 Subject: [PATCH 4/7] Remove problematic testnet interruption Replaced with instruction during choose network prompt. --- crates/aptos/src/common/init.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/aptos/src/common/init.rs b/crates/aptos/src/common/init.rs index 38018db63a196..2275379f9f3dc 100644 --- a/crates/aptos/src/common/init.rs +++ b/crates/aptos/src/common/init.rs @@ -114,7 +114,7 @@ impl CliCommand<()> for InitTool { network } else { eprintln!( - "Choose network from [devnet, testnet, local, custom | defaults to devnet]" + "Choose network from [devnet, testnet, local, custom | defaults to devnet]. For testnet, start over and run movement init --skip-faucet" ); let input = read_line("network")?; let input = input.trim(); @@ -469,11 +469,7 @@ impl FromStr for Network { fn from_str(s: &str) -> Result { Ok(match s.to_lowercase().trim() { // "mainnet" => Self::Mainnet, - "testnet" => { - return Err(CliError::CommandArgumentError(format!( - "To use testnet, run `movement init --skip-faucet`, follow the prompts to create an account address, then visit the faucet UI at https://faucet.movementlabs.xyz to fund the account." - ))); - }, + "testnet" => Self::Testnet, "devnet" => Self::Devnet, "local" => Self::Local, "custom" => Self::Custom, From 93e0d8417f01e25504d39ad13e23cd14fe8ed22d Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Fri, 6 Sep 2024 08:05:55 -0400 Subject: [PATCH 5/7] fix: return testnet error after let network block --- crates/aptos/src/common/init.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/aptos/src/common/init.rs b/crates/aptos/src/common/init.rs index 2275379f9f3dc..8f9ade65ebb46 100644 --- a/crates/aptos/src/common/init.rs +++ b/crates/aptos/src/common/init.rs @@ -121,13 +121,15 @@ impl CliCommand<()> for InitTool { if input.is_empty() { eprintln!("No network given, using devnet..."); Network::Devnet - } else if input.eq_ignore_ascii_case("testnet") && self.skip_faucet { - Network::Testnet } else { Network::from_str(input)? } }; + if network == Network::Testnet && !self.skip_faucet { + return Err("For testnet, start over and run movement init --skip-faucet"); + } + // Ensure the config contains the network used profile_config.network = Some(network); From 0546b34de9a92d9895339ea4418cab50ef33f8b1 Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Sat, 7 Sep 2024 08:21:02 -0400 Subject: [PATCH 6/7] Fix error return format in init.rs We were returning ` return Err( "For testnet, start over and run movement init --skip-faucet");` which compiled locally for me, but I noticed it caused CI to fail [this job](https://github.com/movementlabsxyz/movement/pull/506) with error ``` Compiling aptos-node v0.0.0-main (/home/runner/actions-runner/_work/movement/movement/aptos-core/aptos-node) error[E0308]: mismatched types --> crates/aptos/src/common/init.rs:130:24 | 130 | return Err("For testnet, start over and run movement init --skip-faucet"); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `CliError`, found `&str` | | | arguments to this enum variant are incorrect | help: the type constructed contains `&'static str` due to the type of the argument passed --> crates/aptos/src/common/init.rs:130:20 | 130 | return Err("For testnet, start over and run movement init --skip-faucet"); | ^^^^-------------------------------------------------------------^ | | | this argument influences the type of `Err` ``` It looks like we need to specify the arg type, hence this fix. --- crates/aptos/src/common/init.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/aptos/src/common/init.rs b/crates/aptos/src/common/init.rs index 8f9ade65ebb46..2ddc4eccb42b1 100644 --- a/crates/aptos/src/common/init.rs +++ b/crates/aptos/src/common/init.rs @@ -127,7 +127,9 @@ impl CliCommand<()> for InitTool { }; if network == Network::Testnet && !self.skip_faucet { - return Err("For testnet, start over and run movement init --skip-faucet"); + return Err(CliError::UnexpectedError(format!( + "For testnet, start over and run movement init --skip-faucet" + ))); } // Ensure the config contains the network used From 481786dc68dc2ff5b8a02f654220d5a68a5a433b Mon Sep 17 00:00:00 2001 From: Andy Golay Date: Sat, 7 Sep 2024 17:30:58 -0400 Subject: [PATCH 7/7] Update crates/aptos/src/common/init.rs Co-authored-by: Mikhail Zabaluev --- crates/aptos/src/common/init.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/aptos/src/common/init.rs b/crates/aptos/src/common/init.rs index 2ddc4eccb42b1..e9459b5f49207 100644 --- a/crates/aptos/src/common/init.rs +++ b/crates/aptos/src/common/init.rs @@ -127,7 +127,7 @@ impl CliCommand<()> for InitTool { }; if network == Network::Testnet && !self.skip_faucet { - return Err(CliError::UnexpectedError(format!( + return Err(CliError::CommandArgumentError(format!( "For testnet, start over and run movement init --skip-faucet" ))); }