Skip to content

Commit 2ef1154

Browse files
chadohShaptic
andauthored
Remove contract alias length limit (#2028)
* fix: rm arbitrary alias length limit Does this serve a purpose? Will there be actual problems caused by people (or tooling) creating humongously long aliases? I ran into this limit while incorporating [OpenZeppelin's `fungible-token-interface-example`](https://github.com/OpenZeppelin/stellar-contracts/blob/main/examples/fungible-token-interface/Cargo.toml) into https://github.com/AhaLabs/scaffold-stellar-frontend. The alias is not for human use; it's for tooling. It is generated automatically. But even if people want to create ridiculously long aliases, why should the CLI limit them? Co-authored-by: George <Shaptic@users.noreply.github.com> * chore: fix clippy warning --------- Co-authored-by: George <Shaptic@users.noreply.github.com>
1 parent 247ebf1 commit 2ef1154

File tree

3 files changed

+4
-10
lines changed
  • cmd
    • crates/soroban-test/tests/fixtures/test-wasms/custom_account/src
    • soroban-cli/src/commands/contract/deploy

3 files changed

+4
-10
lines changed

cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl CustomAccountInterface for Contract {
118118
Context::CreateContractWithCtorHostFn(_) | Context::CreateContractHostFn(_) => {
119119
return Err(Error::InvalidContext)
120120
}
121-
};
121+
}
122122
}
123123

124124
// Dummy public key verification check

cmd/soroban-cli/src/commands/contract/deploy/utils.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ use regex::Regex;
22

33
#[derive(thiserror::Error, Debug)]
44
pub enum Error {
5-
#[error(
6-
"alias must be 1-30 chars long, and have only letters, numbers, underscores and dashes"
7-
)]
5+
#[error("alias must have only letters, numbers, underscores and dashes")]
86
InvalidAliasFormat { alias: String },
97
}
108

119
pub fn alias_validator(alias: &str) -> Result<String, Error> {
12-
let regex = Regex::new(r"^[a-zA-Z0-9_-]{1,30}$").unwrap();
10+
let regex = Regex::new(r"^[a-zA-Z0-9_-]+$").unwrap();
1311

1412
if regex.is_match(alias) {
1513
Ok(alias.into())
@@ -46,7 +44,7 @@ mod tests {
4644

4745
#[test]
4846
fn test_alias_validator_with_invalid_inputs() {
49-
let invalid_inputs = ["", "invalid!", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"];
47+
let invalid_inputs = ["", "invalid!", "oh no"];
5048

5149
for input in invalid_inputs {
5250
let result = alias_validator(input);

cmd/soroban-cli/src/commands/contract/deploy/wasm.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ pub enum Error {
112112
Network(#[from] network::Error),
113113
#[error(transparent)]
114114
Wasm(#[from] wasm::Error),
115-
#[error(
116-
"alias must be 1-30 chars long, and have only letters, numbers, underscores and dashes"
117-
)]
118-
InvalidAliasFormat { alias: String },
119115
#[error(transparent)]
120116
Locator(#[from] locator::Error),
121117
#[error(transparent)]

0 commit comments

Comments
 (0)