Skip to content

Commit

Permalink
Change class-name flag back to contract-name
Browse files Browse the repository at this point in the history
  • Loading branch information
cwkang1998 committed Nov 13, 2024
1 parent 0b8f0f7 commit 9ced501
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions crates/sncast/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use starknet::core::types::ContractClass;
use starknet::core::utils::get_selector_from_name;
use starknet::providers::Provider;
use starknet_commands::account::list::print_account_list;
use starknet_types_core::felt::Felt;
use starknet_commands::verify::Verify;
use starknet_types_core::felt::Felt;
use tokio::runtime::Runtime;

mod starknet_commands;
Expand Down Expand Up @@ -625,7 +625,7 @@ async fn run_async_command(
let result = starknet_commands::verify::verify(
verify.contract_address_or_class_hash.contract_address,
verify.contract_address_or_class_hash.class_hash,
verify.class_name,
verify.contract_name,
verify.verifier,
verify.network,
verify.confirm_verification,
Expand Down
6 changes: 3 additions & 3 deletions crates/sncast/src/starknet_commands/verify/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ pub trait VerificationInterface {
workspace_dir: Utf8PathBuf,
contract_address: Option<Felt>,
class_hash: Option<Felt>,
class_name: String,
contract_name: String,
) -> Result<VerifyResponse> {
let file_data = read_workspace_files(workspace_dir)?;
let source_code = serde_json::Value::Object(file_data);
let payload = VerificationPayload {
class_name,
contract_name,
contract_address,
class_hash,
source_code,
Expand All @@ -88,7 +88,7 @@ pub trait VerificationInterface {

#[derive(Serialize, Debug)]
pub struct VerificationPayload {
pub class_name: String,
pub contract_name: String,
pub contract_address: Option<Felt>,
pub class_hash: Option<Felt>,
pub source_code: serde_json::Value,
Expand Down
12 changes: 6 additions & 6 deletions crates/sncast/src/starknet_commands/verify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ pub struct Verify {
#[clap(flatten)]
pub contract_address_or_class_hash: ContractAddressOrClassHashGroup,

/// Class name of the contract to be verified.
/// Name of the contract that is being verified
#[clap(short, long)]
pub class_name: String,
pub contract_name: String,

/// Verification provider to be used
#[clap(short, long, value_enum)]
Expand Down Expand Up @@ -96,7 +96,7 @@ fn get_verifier(
pub async fn verify(
contract_address: Option<Felt>,
class_hash: Option<Felt>,
class_name: String,
contract_name: String,
verifier: Verifier,
network: Network,
confirm_verification: bool,
Expand All @@ -116,8 +116,8 @@ pub async fn verify(
}
}

if !artifacts.contains_key(&class_name) {
return Err(anyhow!("Contract named '{class_name}' was not found"));
if !artifacts.contains_key(&contract_name) {
return Err(anyhow!("Contract named '{contract_name}' was not found"));
}

// Build JSON Payload for the verification request
Expand All @@ -132,7 +132,7 @@ pub async fn verify(
workspace_dir.to_path_buf(),
contract_address,
class_hash,
class_name,
contract_name,
)
.await
}
26 changes: 13 additions & 13 deletions crates/sncast/tests/e2e/verify/voyager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn test_happy_case() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"voyager",
Expand Down Expand Up @@ -86,7 +86,7 @@ async fn test_happy_case_class_hash() {
"verify",
"--class-hash",
MAP_CONTRACT_CLASS_HASH_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"voyager",
Expand Down Expand Up @@ -138,7 +138,7 @@ async fn test_failed_verification() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"voyager",
Expand Down Expand Up @@ -174,7 +174,7 @@ async fn test_verification_abort() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"nonexistent",
"--verifier",
"voyager",
Expand Down Expand Up @@ -207,7 +207,7 @@ async fn test_wrong_contract_name_passed() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"nonexistent",
"--verifier",
"voyager",
Expand Down Expand Up @@ -238,7 +238,7 @@ async fn test_no_class_hash_or_contract_address_provided() {
"--accounts-file",
ACCOUNT_FILE_PATH,
"verify",
"--class-name",
"--contract-name",
"Map",
"--verifier",
"voyager",
Expand All @@ -257,7 +257,7 @@ async fn test_no_class_hash_or_contract_address_provided() {
error: the following required arguments were not provided:
<--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>
Usage: sncast verify --class-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>
Usage: sncast verify --contract-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>
For more information, try '--help'."
),
Expand All @@ -276,7 +276,7 @@ async fn test_both_class_hash_or_contract_address_provided() {
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-hash",
MAP_CONTRACT_CLASS_HASH_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"voyager",
Expand All @@ -293,7 +293,7 @@ async fn test_both_class_hash_or_contract_address_provided() {
formatdoc!(
r"
error: the argument '--contract-address <CONTRACT_ADDRESS>' cannot be used with '--class-hash <CLASS_HASH>'
Usage: sncast verify --class-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>"
Usage: sncast verify --contract-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>"
),
);
}
Expand Down Expand Up @@ -324,7 +324,7 @@ async fn test_happy_case_with_confirm_verification_flag() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"voyager",
Expand Down Expand Up @@ -377,7 +377,7 @@ async fn test_happy_case_specify_package() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"supercomplexcode",
"--verifier",
"voyager",
Expand Down Expand Up @@ -431,7 +431,7 @@ async fn test_worskpaces_package_specified_virtual_fibonacci() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"FibonacciContract",
"--verifier",
"voyager",
Expand Down Expand Up @@ -469,7 +469,7 @@ async fn test_worskpaces_package_no_contract() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"nonexistent",
"--verifier",
"voyager",
Expand Down
26 changes: 13 additions & 13 deletions crates/sncast/tests/e2e/verify/walnut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn test_happy_case() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"walnut",
Expand Down Expand Up @@ -86,7 +86,7 @@ async fn test_happy_case_class_hash() {
"verify",
"--class-hash",
MAP_CONTRACT_CLASS_HASH_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"walnut",
Expand Down Expand Up @@ -138,7 +138,7 @@ async fn test_failed_verification() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"walnut",
Expand Down Expand Up @@ -174,7 +174,7 @@ async fn test_verification_abort() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"nonexistent",
"--verifier",
"walnut",
Expand Down Expand Up @@ -207,7 +207,7 @@ async fn test_wrong_contract_name_passed() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"nonexistent",
"--verifier",
"walnut",
Expand Down Expand Up @@ -238,7 +238,7 @@ async fn test_no_class_hash_or_contract_address_provided() {
"--accounts-file",
ACCOUNT_FILE_PATH,
"verify",
"--class-name",
"--contract-name",
"Map",
"--verifier",
"walnut",
Expand All @@ -257,7 +257,7 @@ async fn test_no_class_hash_or_contract_address_provided() {
error: the following required arguments were not provided:
<--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>
Usage: sncast verify --class-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>
Usage: sncast verify --contract-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>
For more information, try '--help'."
),
Expand All @@ -276,7 +276,7 @@ async fn test_both_class_hash_or_contract_address_provided() {
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-hash",
MAP_CONTRACT_CLASS_HASH_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"walnut",
Expand All @@ -293,7 +293,7 @@ async fn test_both_class_hash_or_contract_address_provided() {
formatdoc!(
r"
error: the argument '--contract-address <CONTRACT_ADDRESS>' cannot be used with '--class-hash <CLASS_HASH>'
Usage: sncast verify --class-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>"
Usage: sncast verify --contract-name <CLASS_NAME> --verifier <VERIFIER> --network <NETWORK> <--contract-address <CONTRACT_ADDRESS>|--class-hash <CLASS_HASH>>"
),
);
}
Expand Down Expand Up @@ -324,7 +324,7 @@ async fn test_happy_case_with_confirm_verification_flag() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"Map",
"--verifier",
"walnut",
Expand Down Expand Up @@ -377,7 +377,7 @@ async fn test_happy_case_specify_package() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"supercomplexcode",
"--verifier",
"walnut",
Expand Down Expand Up @@ -431,7 +431,7 @@ async fn test_worskpaces_package_specified_virtual_fibonacci() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"FibonacciContract",
"--verifier",
"walnut",
Expand Down Expand Up @@ -469,7 +469,7 @@ async fn test_worskpaces_package_no_contract() {
"verify",
"--contract-address",
MAP_CONTRACT_ADDRESS_SEPOLIA,
"--class-name",
"--contract-name",
"nonexistent",
"--verifier",
"walnut",
Expand Down
2 changes: 1 addition & 1 deletion design_documents/contract_verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The `verify` command will perform following actions:

#### Parameters

#### `--class-name`
#### `--contract-name`

Required.
Name of the contract to be submitted for verification.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/appendix/sncast/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Conflicts with: `--contract-address`

The class hash of the contract that is to be verified.

## `--class-name <CLASS NAME>`
## `--contract-name <CONTRACT_NAME>`
Required.

The name of the contract class. The contract name is the part after the `mod` keyword in your contract file.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/starknet/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Then run:
$ sncast \
verify \
--contract-address 0x8448a68b5ea1affc45e3fd4b8b480ea36a51dc34e337a16d2567d32d0c6f8b \
--class-name SimpleBalance \
--contract-name SimpleBalance \
--verifier walnut \
--network sepolia

Expand Down

0 comments on commit 9ced501

Please sign in to comment.