-
Notifications
You must be signed in to change notification settings - Fork 177
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
Global cast configuration #2689
base: master
Are you sure you want to change the base?
Conversation
3d2e58e
to
65830c0
Compare
docs/src/projects/configuration.md
Outdated
#### Interaction between Local and Global profiles | ||
|
||
Interaction between global and local config is based on the overriding mechanism, the local config will be used to override | ||
the global profile of the same name or in case it is not defined to override the default global profile. | ||
|
||
If `--profile` is not provided, the default profile from the local (if present) and global configuration will be used. | ||
|
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.
I wonder if we can add a little example, just to have a better illustration of how this mechanism works? Wdyt?
if !global_config_dir.exists() { | ||
fs::create_dir_all(&global_config_dir)?; | ||
} |
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.
I don't think we should be recursively creating this path. Let's only created a dir for starknet-foundry and if home/config dir is missing let's throw an error.
So use https://doc.rust-lang.org/beta/std/fs/fn.create_dir.html instead
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.
Why not? I suppose that .config
dir is intended for use by tools, and we should create it if is not present
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.
Seems bit weird to me to create those.
But cc @THenry14 to verify
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.
my understading is that create_dir_all
corresponds to mkdir -p
, which should be used in our case 👍
docs/src/projects/configuration.md
Outdated
### Global configuration | ||
|
||
Since version 0.34.0 `sncast` will use the global configuration to combine configuration from local configs. | ||
Global configuration file is usual [`snfoundry.toml`](https://foundry-rs.github.io/starknet-foundry/appendix/snfoundry-toml.html), but placed in specific directory. |
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.
We don't need this, these are the docs for latest version.
docs/src/projects/configuration.md
Outdated
#### Interaction between Local and Global profiles | ||
|
||
Interaction between global and local config is based on the overriding mechanism, the local config will be used to override | ||
the global profile of the same name or in case it is not defined to override the default global profile. | ||
|
||
If `--profile` is not provided, the default profile from the local (if present) and global configuration will be used. |
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.
This needs to be written in simpler terms, so it's obvious what overrides what and in which cases.
@@ -1,3 +1,4 @@ | |||
pub const EXPECTED_RPC_VERSION: &str = "0.7.0"; | |||
pub const RPC_URL_VERSION: &str = "v0_7"; | |||
pub const SNFORGE_TEST_FILTER: &str = "SNFORGE_TEST_FILTER"; | |||
pub const FREE_RPC_PROVIDER_URL: &str = "https://free-rpc.nethermind.io/sepolia-juno/v0_7"; |
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.
nit: Do we really want to hardcode a link to an external node in the template? This might require updates in the future. I suggest sticking with the previous devnet address http://127.0.0.1:5050
.
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.
I suppose that it will be convenient for the user to have ready sepolia URL defined.
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.
Although it might be convenient for some users I still don't think we should include it in the template. If you add it here you are kind of responsible for it to work, which means extra effort to maintain it and potentially dealing with related support questions.
macro_rules! clone_field { | ||
($global_config:expr, $local_config:expr, $default_config:expr, $field:ident) => { | ||
if $local_config.$field != $default_config.$field { | ||
$local_config.$field.clone() | ||
} else { | ||
$global_config.$field.clone() | ||
} | ||
}; | ||
} |
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.
I like having new macros, however in this case I think it just could be a function :ccc
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.
Do we really want to introduce such an ugly function instead of this beautiful macro?
fn clone_filed<T: PartialEq + Clone>(global: &T, local: &T, default: &T) -> T {
if *local != *default {
local.clone()
} else {
global.clone()
}
}
**Glossary:** | ||
|
||
- **A:** Global configuration file containing the profiles `default` and `testnet`. | ||
- **B:** Local configuration file containing the profiles `default` and `mainnet`. | ||
|
||
In any directory in the file system, a user can run the `sncast` command using the `default` and `testnet` profiles, | ||
because they are located in global config. | ||
If no profiles are explicitly specified, the `default` profile from the global configuration file will be used. | ||
|
||
When running `sncast` from the `opus magnum` directory, there is a configuration file in the parent directory (B). | ||
This setup allows for the use of the following profiles: `default`, `testnet`, and `mainnet`. If the `mainnet` profile is specified, | ||
the configuration from the local file will be used to override the global `default` profile, as the `mainnet` profile does not exist in the global configuration. |
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.
It's a nice example but maybe show a shortened contents of A and B instead?
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.
In the commands account add
and account import
there is --add-profile
flag. After introducing the global config it would be nice to explicitly mention that the created profile will be added to a local config if exists, or to change this logic. This can be done in this PR or a separate one, but it should be completed before the next release.
@@ -24,6 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
- You can skip `--name` flag when using `account import` - a default name will be generated. | |||
- Addresses outputted when calling `sncast account create`, `sncast deploy` and `sncast declare` are now padded to 64 characters length and prefixed with `0x0` | |||
- Globally available configuration to store profiles to share between projects. | |||
- Missing fields in `show-config` command, `block_explorer` and `show_explorer_links`. | |||
- Default free sepolia testnet RPC URL for any `sncast` command. |
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.
Even if we decide to add it, which I am strongly against, what is the point of mentioning this in the changelog?
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.
I suppose that it is a significant change. It changes the expected behavior from the older version. Isn't it proper to mention here?
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.
I see now that this also applies to the default CastConfig
. I thought it was only for the template. That makes it even worse, but in such a case it should be added to the changelog.
Co-authored-by: Artur Michałek <52135326+cptartur@users.noreply.github.com>
Closes #2221
Introduced changes
show-config
commandsnfoundry.toml
docsChecklist
CHANGELOG.md