Skip to content

Commit

Permalink
remove ipfs scheme restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb committed Jan 26, 2024
1 parent 33984ac commit b1aa252
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
5 changes: 3 additions & 2 deletions contracts/minters/base-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ pub fn execute_mint_sender(
));
};

let parsed_token_uri = Url::parse(&token_uri)?;
if parsed_token_uri.scheme() != "ipfs" {
// Token URI must be a valid URL (ipfs, https, etc.)
let res = Url::parse(&token_uri);
if res.is_err() {
return Err(ContractError::InvalidTokenURI {});
}

Expand Down
5 changes: 3 additions & 2 deletions contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ pub fn instantiate(
.as_ref()
.map(|uri| uri.trim().to_string())
.map_or_else(|| Err(ContractError::InvalidBaseTokenURI {}), Ok)?;

if Url::parse(&base_token_uri)?.scheme() != "ipfs" {
// Token URI must be a valid URL (ipfs, https, etc.)
let res = Url::parse(&base_token_uri);
if res.is_err() {
return Err(ContractError::InvalidBaseTokenURI {});
}

Expand Down
7 changes: 3 additions & 4 deletions contracts/minters/vending-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ pub fn instantiate(

// sanitize base token uri
let mut base_token_uri = msg.init_msg.base_token_uri.trim().to_string();
// Check that base_token_uri is a valid IPFS uri
let parsed_token_uri = Url::parse(&base_token_uri)?;
if parsed_token_uri.scheme() != "ipfs" {
// Token URI must be a valid URL (ipfs, https, etc.)
let Ok(parsed_token_uri) = Url::parse(&base_token_uri) else {
return Err(ContractError::InvalidBaseTokenURI {});
}
};
base_token_uri = parsed_token_uri.to_string();

let genesis_time = Timestamp::from_nanos(GENESIS_MINT_START_TIME);
Expand Down
8 changes: 4 additions & 4 deletions contracts/minters/vending-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ pub fn instantiate(

// sanitize base token uri
let mut base_token_uri = msg.init_msg.base_token_uri.trim().to_string();
// Check that base_token_uri is a valid IPFS uri
let parsed_token_uri = Url::parse(&base_token_uri)?;
if parsed_token_uri.scheme() != "ipfs" {

// Token URI must be a valid URL (ipfs, https, etc.)
let Ok(parsed_token_uri) = Url::parse(&base_token_uri) else {
return Err(ContractError::InvalidBaseTokenURI {});
}
};
base_token_uri = parsed_token_uri.to_string();

let genesis_time = Timestamp::from_nanos(GENESIS_MINT_START_TIME);
Expand Down
7 changes: 3 additions & 4 deletions contracts/minters/vending-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ pub fn instantiate(

// sanitize base token uri
let mut base_token_uri = msg.init_msg.base_token_uri.trim().to_string();
// Check that base_token_uri is a valid IPFS uri
let parsed_token_uri = Url::parse(&base_token_uri)?;
if parsed_token_uri.scheme() != "ipfs" {
// Token URI must be a valid URL (ipfs, https, etc.)
let Ok(parsed_token_uri) = Url::parse(&base_token_uri) else {
return Err(ContractError::InvalidBaseTokenURI {});
}
};
base_token_uri = parsed_token_uri.to_string();

let genesis_time = Timestamp::from_nanos(GENESIS_MINT_START_TIME);
Expand Down

0 comments on commit b1aa252

Please sign in to comment.