Skip to content

Prepare cli for Fuel merge to support contract import#24

Merged
DZakh merged 5 commits into
mainfrom
dz/fuel-contract-import
Jun 12, 2024
Merged

Prepare cli for Fuel merge to support contract import#24
DZakh merged 5 commits into
mainfrom
dz/fuel-contract-import

Conversation

@DZakh

@DZakh DZakh commented Jun 11, 2024

Copy link
Copy Markdown
Member
  • Add clap types for contract import (not connected until the contract import feature is finished)
  • Create modules for evm and fuel to store ecosystem related code
  • Added address type for Fuel

@DZakh DZakh marked this pull request as draft June 11, 2024 07:53
@DZakh DZakh changed the title Fuel contract import Prepare cli for Fuel merge to support contract import Jun 11, 2024
@DZakh DZakh requested a review from JonoPrest June 11, 2024 09:04
@DZakh DZakh marked this pull request as ready for review June 11, 2024 09:04
Comment on lines -36 to -37
//Allowing dead code for these implementations since they function as library methods
#[allow(dead_code)]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not relevant for hyperindex

Comment on lines -47 to -54
pub fn to_upper_hex_string(&self) -> String {
encode_upper_prefixed(self.0)
}

pub fn to_lower_hex_string(&self) -> String {
encode_prefixed(self.0)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were not used

@@ -0,0 +1,87 @@
use anyhow::{Context, Error, Result};
use ethers::{abi::AbiEncode, types::H256};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works like this for now, later I'll replace with a type from fuels

@DZakh

DZakh commented Jun 11, 2024

Copy link
Copy Markdown
Member Author

I want to keep PRs small and easy to review, so I'll work on the next part of the feature in another one.

@DZakh

DZakh commented Jun 11, 2024

Copy link
Copy Markdown
Member Author

The PR doesn't include any braking changes, only internal refactoring. Can be safely merged in the v1 branch

Comment thread codegenerator/cli/src/cli_args/clap_definitions.rs Outdated
@JonoPrest

Copy link
Copy Markdown
Collaborator

Nice Dmitry! Will look and review properly in the morning 👍🏼

Comment on lines +134 to +137
Fuel {
#[command(subcommand)]
init_flow: Option<FuelInitFlow>,
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's a neat trick!


#[derive(Args, Debug, Default, Clone)]
pub struct LocalImportArgs {
pub struct EvmLocalImportArgs {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably namespace these structs inside a module if we are going to add more ecosystems. All good for now to name at the type level though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I didn't think of it. I'll do in the next PR

Comment on lines +250 to +268
#[derive(Args, Debug, Default, Clone)]
pub struct FuelContractImportArgs {
///Choose to import a contract from a local abi or
///using get values from an explorer using a contract address
#[command(subcommand)]
pub local_or_explorer: Option<FuelLocalOrExplorerImport>,

///Contract address to generate the config from
#[arg(global = true, short, long)]
pub contract_address: Option<fuel::address::Address>,

///If selected, prompt will not ask for additional contracts/addresses/networks
#[arg(long, action)]
pub single_contract: bool,

///If selected, prompt will not ask to confirm selection of events on a contract
#[arg(long, action)]
pub all_events: bool,
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to make these structs generic and just change parameters?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in the future, but currently Fuel doesn't have explorer, so it's difficult to generalize

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @DZakh 👍🏼, obviously a bit of code duplication but I assume you are planning to remove the duplicate address.rs file etc. going forward and maybe reuse some of the types in CLI if they can be?

@DZakh DZakh merged commit 81f8566 into main Jun 12, 2024
@DZakh

DZakh commented Jun 12, 2024

Copy link
Copy Markdown
Member Author

remove the duplicate address.rs

I actually didn't plan to remove the duplicate, since these are different types. Do you think we should store both Evm and Fuel addresses in a single Address type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants