Skip to content

Commit

Permalink
fix: removed expiration from contract
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Dec 1, 2023
1 parent 6fcca08 commit 76386b4
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 46 deletions.
4 changes: 0 additions & 4 deletions src/deferred/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,12 @@ impl Deferred {
data.value,
data.seller,
data.installments,
&data.expiration,
)?;

// make contract
let contract = Contract {
buyers: data.buyers,
currency: data.currency,
expiration: data.expiration,
id: data.id.clone(),
initial_value: data.value,
properties: data.properties,
Expand Down Expand Up @@ -577,7 +575,6 @@ mod test {
let contract = ContractRegistration {
buyers: vec![caller()],
currency: "EUR".to_string(),
expiration: "2040-01-01".to_string(),
id: 1.into(),
installments: 10,
properties: vec![],
Expand All @@ -600,7 +597,6 @@ mod test {
let contract = ContractRegistration {
buyers: vec![caller()],
currency: "EUR".to_string(),
expiration: "2040-01-01".to_string(),
id: 1.into(),
installments: 10,
properties: vec![],
Expand Down
32 changes: 0 additions & 32 deletions src/deferred/src/app/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ impl Inspect {
value: u64,
seller: Principal,
installments: u64,
expiration: &str,
) -> DeferredResult<()> {
if !Self::inspect_is_custodian(caller) && !Self::inspect_is_agent(caller) {
return Err(DeferredError::Unauthorized);
Expand All @@ -159,15 +158,6 @@ impl Inspect {
));
}

// check if expiration is YYYY-MM-DD and is not in the past
match crate::utils::parse_date(expiration) {
Ok(timestamp) if timestamp < crate::utils::time() => {
return Err(DeferredError::Token(TokenError::InvalidExpirationDate));
}
Ok(_) => {}
Err(_) => return Err(DeferredError::Token(TokenError::InvalidExpirationDate)),
}

Ok(())
}

Expand Down Expand Up @@ -423,7 +413,6 @@ mod test {
100,
Principal::management_canister(),
25,
"2040-01-01"
)
.is_err());
}
Expand All @@ -440,7 +429,6 @@ mod test {
100,
Principal::management_canister(),
25,
"2040-01-01"
)
.is_err());
}
Expand All @@ -455,22 +443,6 @@ mod test {
110,
Principal::management_canister(),
25,
"2040-01-01"
)
.is_err());
}

#[test]
fn test_should_inspect_contract_register_invalid_expiration_date() {
let caller = crate::utils::caller();
assert!(RolesManager::set_custodians(vec![caller]).is_ok());
assert!(Inspect::inspect_register_contract(
caller,
&1.into(),
100,
Principal::management_canister(),
25,
"2020-01-01"
)
.is_err());
}
Expand All @@ -485,7 +457,6 @@ mod test {
100,
Principal::management_canister(),
25,
"2040-01-01"
)
.is_err());
}
Expand All @@ -500,7 +471,6 @@ mod test {
100,
Principal::management_canister(),
25,
"2040-01-01"
)
.is_ok());
}
Expand All @@ -515,7 +485,6 @@ mod test {
100,
Principal::anonymous(),
25,
"2040-01-01"
)
.is_err());
}
Expand All @@ -530,7 +499,6 @@ mod test {
100,
Principal::management_canister(),
25,
"2040-01-01"
)
.is_ok());
}
Expand Down
1 change: 0 additions & 1 deletion src/deferred/src/app/storage/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ mod test {
seller,
buyers: vec![Principal::anonymous()],
tokens: vec![],
expiration: "2040-06-01".to_string(),
installments: 2,
is_signed: false,
initial_value: 250_000,
Expand Down
1 change: 0 additions & 1 deletion src/deferred/src/app/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn mock_contract(id: u64, installments: u64) -> Contract {
seller: caller(),
buyers: vec![Principal::management_canister()],
tokens: vec![],
expiration: "2040-06-01".to_string(),
installments,
is_signed: false,
initial_value: 250_000,
Expand Down
1 change: 0 additions & 1 deletion src/deferred/src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ fn inspect_message_impl() {
data.value,
data.seller,
data.installments,
&data.expiration,
)
.is_ok()
}
Expand Down
7 changes: 0 additions & 7 deletions src/did/src/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ pub enum TokenError {
TokenIsBurned(TokenIdentifier),
#[error("the provided contract value is not a multiple of the number of installments")]
ContractValueIsNotMultipleOfInstallments,
#[error("the provided expiration date is invalid. It must have syntax YYYY-MM-DD")]
InvalidExpirationDate,
#[error("the provided contract has no seller")]
ContractHasNoSeller,
}
Expand All @@ -88,8 +86,6 @@ pub struct Contract {
pub seller: Principal,
/// Contract buyers. Those who must pay
pub buyers: Vec<Principal>,
/// Contract expiration date
pub expiration: String,
/// Tokens associated to the contract, by id
pub tokens: Vec<TokenIdentifier>,
/// Number of installments
Expand Down Expand Up @@ -212,7 +208,6 @@ pub struct ContractRegistration {
pub r#type: ContractType,
pub seller: Principal,
pub buyers: Vec<Principal>,
pub expiration: String,
pub value: u64,
pub currency: String,
pub installments: u64,
Expand Down Expand Up @@ -322,7 +317,6 @@ mod test {
)
.unwrap(),
],
expiration: "2021-12-31".to_string(),
installments: 2,
is_signed: true,
tokens: vec![TokenIdentifier::from(1), TokenIdentifier::from(2)],
Expand All @@ -340,7 +334,6 @@ mod test {
assert_eq!(contract.id, decoded_contract.id);
assert_eq!(contract.seller, decoded_contract.seller);
assert_eq!(contract.buyers, decoded_contract.buyers);
assert_eq!(contract.expiration, decoded_contract.expiration);
assert_eq!(contract.tokens, decoded_contract.tokens);
assert_eq!(contract.properties, decoded_contract.properties);
assert_eq!(contract.value, decoded_contract.value);
Expand Down

0 comments on commit 76386b4

Please sign in to comment.