Skip to content

Commit

Permalink
fix: expiration in contract is now mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Aug 10, 2024
1 parent 3988a3b commit 9c44551
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 90 deletions.
2 changes: 1 addition & 1 deletion integration-tests/tests/http/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn init_contract(env: &TestEnv) -> ID {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
24 changes: 12 additions & 12 deletions integration-tests/tests/inspect/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn test_should_inspect_update_contract_property() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -180,7 +180,7 @@ fn test_should_inspect_update_contract_property_is_not_authorized() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -242,7 +242,7 @@ fn test_should_inspect_update_contract_property_bad_key() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -298,7 +298,7 @@ fn test_should_inspect_update_contract_buyers() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -365,7 +365,7 @@ fn test_should_inspect_update_contract_buyers_not_seller() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -415,7 +415,7 @@ fn test_should_inspect_register_contract() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -463,7 +463,7 @@ fn test_should_inspect_register_contract_unauthorized() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -506,7 +506,7 @@ fn test_should_inspect_register_contract_no_sellers() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -552,7 +552,7 @@ fn test_should_inspect_register_contract_installments_not_multiple() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -598,7 +598,7 @@ fn test_should_inspect_register_contract_expired() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: Some("2021-01-01".to_string()),
expiration: "2021-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -666,7 +666,7 @@ fn test_should_inspect_sign_contract() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down Expand Up @@ -717,7 +717,7 @@ fn test_should_inspect_burn() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/use_case/buy_marketplace_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn setup_contract_marketplace(env: &TestEnv) -> ID {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/use_case/close_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn test_as_agent_i_should_close_contract_after_expiration() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: Some(expiration),
expiration,
};
let deposit = registration_data.deposit.clone();
// value_icp : value_fiat = x : 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn test_as_seller_i_can_set_the_contract_buyers() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/use_case/register_agency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn test_should_register_agency_and_be_able_to_create_contract() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/use_case/register_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_as_agency_i_can_register_contract() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
let deposit_value_icp = registration_data.deposit.value_icp;
// approve deposit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_as_seller_i_can_set_the_contract_buyers() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/use_case/register_sell_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn test_as_seller_i_can_register_a_sell_contract() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};

let expected_token_value = (registration_data.value - registration_data.deposit.value_fiat)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/use_case/reserve_reward_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn test_should_reserve_a_reward_pool_on_ekoke() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn test_should_update_contract_property() {
),
],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
// approve deposit
crate::helper::contract_deposit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn test_as_seller_i_should_withdraw_contract_deposit_after_being_paid() {
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
expiration: "2050-01-01".to_string(),
};
let deposit_value_icp = registration_data.deposit.value_icp;
// approve deposit
Expand Down
4 changes: 2 additions & 2 deletions src/declarations/deferred/deferred.did
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Contract = record {
properties : vec record { text; GenericValue };
deposit : Deposit;
sellers : vec Seller;
expiration : opt text;
expiration : text;
tokens : vec nat;
currency : text;
installments : nat64;
Expand All @@ -81,7 +81,7 @@ type ContractRegistration = record {
properties : vec record { text; GenericValue };
deposit : Deposit;
sellers : vec Seller;
expiration : opt text;
expiration : text;
currency : text;
installments : nat64;
buyers : Buyers;
Expand Down
4 changes: 2 additions & 2 deletions src/declarations/deferred/deferred.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface Contract {
'properties' : Array<[string, GenericValue]>,
'deposit' : Deposit,
'sellers' : Array<Seller>,
'expiration' : [] | [string],
'expiration' : string,
'tokens' : Array<bigint>,
'currency' : string,
'installments' : bigint,
Expand All @@ -90,7 +90,7 @@ export interface ContractRegistration {
'properties' : Array<[string, GenericValue]>,
'deposit' : Deposit,
'sellers' : Array<Seller>,
'expiration' : [] | [string],
'expiration' : string,
'currency' : string,
'installments' : bigint,
'buyers' : Buyers,
Expand Down
4 changes: 2 additions & 2 deletions src/declarations/deferred/deferred.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export const idlFactory = ({ IDL }) => {
'properties' : IDL.Vec(IDL.Tuple(IDL.Text, GenericValue)),
'deposit' : Deposit,
'sellers' : IDL.Vec(Seller),
'expiration' : IDL.Opt(IDL.Text),
'expiration' : IDL.Text,
'tokens' : IDL.Vec(IDL.Nat),
'currency' : IDL.Text,
'installments' : IDL.Nat64,
Expand Down Expand Up @@ -357,7 +357,7 @@ export const idlFactory = ({ IDL }) => {
'properties' : IDL.Vec(IDL.Tuple(IDL.Text, GenericValue)),
'deposit' : Deposit,
'sellers' : IDL.Vec(Seller),
'expiration' : IDL.Opt(IDL.Text),
'expiration' : IDL.Text,
'currency' : IDL.Text,
'installments' : IDL.Nat64,
'buyers' : Buyers,
Expand Down
4 changes: 2 additions & 2 deletions src/deferred/deferred.did
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Contract = record {
properties : vec record { text; GenericValue };
deposit : Deposit;
sellers : vec Seller;
expiration : opt text;
expiration : text;
tokens : vec nat;
currency : text;
installments : nat64;
Expand All @@ -81,7 +81,7 @@ type ContractRegistration = record {
properties : vec record { text; GenericValue };
deposit : Deposit;
sellers : vec Seller;
expiration : opt text;
expiration : text;
currency : text;
installments : nat64;
buyers : Buyers;
Expand Down
8 changes: 4 additions & 4 deletions src/deferred/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl Deferred {
&data.sellers,
&data.buyers,
data.installments,
data.expiration.as_deref(),
&data.expiration,
)?;

let next_contract_id = ContractStorage::next_contract_id();
Expand Down Expand Up @@ -797,7 +797,7 @@ mod test {
quota: 100,
}],
value: 100,
expiration: Some("2048-01-01".to_string()),
expiration: "2048-01-01".to_string(),
};

assert_eq!(Deferred::register_contract(contract).await.unwrap(), 0_u64);
Expand Down Expand Up @@ -836,7 +836,7 @@ mod test {
quota: 100,
}],
value: 100,
expiration: Some("2048-01-01".to_string()),
expiration: "2048-01-01".to_string(),
};
assert_eq!(Deferred::register_contract(contract).await.unwrap(), 0_u64);
assert!(Deferred::sign_contract(0_u64.into()).await.is_ok());
Expand Down Expand Up @@ -1322,7 +1322,7 @@ mod test {
quota: 100,
}],
value: 100,
expiration: Some("2048-01-01".to_string()),
expiration: "2048-01-01".to_string(),
};

assert_eq!(Deferred::register_contract(contract).await.unwrap(), 0_u64);
Expand Down
Loading

0 comments on commit 9c44551

Please sign in to comment.