Skip to content

Commit

Permalink
feat: restricted attributes (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso authored Apr 12, 2024
1 parent 5fee5e0 commit f736341
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 95 deletions.
17 changes: 16 additions & 1 deletion docs/canisters/deferred.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
- [increment\_contract\_value](#increment_contract_value)
- [update\_contract\_buyers](#update_contract_buyers)
- [update\_contract\_property](#update_contract_property)
- [admin\_set\_ekoke\_ledger\_canister](#admin_set_ekoke_reward_pool_canister)
- [update\_restricted\_contract\_property](#update_restricted_contract_property)
- [get\_restricted\_contract\_properties](#get_restricted_contract_properties)
- [admin\_set\_ekoke\_reward\_pool\_canister](#admin_set_ekoke_reward_pool_canister)
- [admin\_set\_marketplace\_canister](#admin_set_marketplace_canister)
- [admin\_set\_role](#admin_set_role)
- [admin\_remove\_role](#admin_remove_role)
Expand Down Expand Up @@ -63,6 +65,7 @@ A Contract is identified by the following properties
- **reward**: the reward of EKOKE token given to a NFT buyer
- **expiration**: contract expiration with syntax `YYYY-MM-DD`.
- **properties**: contract properties and metadata
- **restricted_properties**: contract restricted properties

## Roles

Expand Down Expand Up @@ -127,6 +130,18 @@ Change a contract property.

Can be called by Agent, Custodian or seller.

### update_restricted_contract_property

Create or change a contract restricted property.

Can be called by Agent, Custodian or seller.

### get_restricted_contract_properties

Get the restricted contract properties.

The properties returned are those only accessible to the caller

### admin_set_ekoke_reward_pool_canister

Update ekoke ledger canister principal
Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/http/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fn init_contract(env: &TestEnv) -> ID {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};
// call register
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/tests/inspect/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ fn test_should_inspect_update_contract_property() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -156,6 +157,7 @@ fn test_should_inspect_update_contract_property_is_not_authorized() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -204,6 +206,7 @@ fn test_should_inspect_update_contract_property_bad_key() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -246,6 +249,7 @@ fn test_should_inspect_update_contract_buyers() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -299,6 +303,7 @@ fn test_should_inspect_update_contract_buyers_not_seller() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -335,6 +340,7 @@ fn test_should_inspect_register_contract() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -369,6 +375,7 @@ fn test_should_inspect_register_contract_unauthorized() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -398,6 +405,7 @@ fn test_should_inspect_register_contract_no_sellers() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -430,6 +438,7 @@ fn test_should_inspect_register_contract_installments_not_multiple() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -462,6 +471,7 @@ fn test_should_inspect_register_contract_expired() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: Some("2021-01-01".to_string()),
};

Expand Down Expand Up @@ -516,6 +526,7 @@ fn test_should_inspect_sign_contract() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down Expand Up @@ -553,6 +564,7 @@ fn test_should_inspect_burn() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/use_case/buy_marketplace_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ fn setup_contract_marketplace(env: &TestEnv) -> ID {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};
// call register
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn test_as_seller_i_can_set_the_contract_buyers() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/use_case/register_agency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn test_should_register_agency_and_be_able_to_create_contract() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fn test_as_seller_i_can_set_the_contract_buyers() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/use_case/register_sell_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn test_as_seller_i_can_register_a_sell_contract() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down
1 change: 1 addition & 0 deletions integration-tests/tests/use_case/reserve_reward_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn test_should_reserve_a_reward_pool_on_ekoke() {
"contract:address".to_string(),
GenericValue::TextContent("via roma 10".to_string()),
)],
restricted_properties: vec![],
expiration: None,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn test_should_update_contract_property() {
GenericValue::TextContent("Gino Valle".to_string()),
),
],
restricted_properties: vec![],
expiration: None,
};

Expand Down
40 changes: 18 additions & 22 deletions src/declarations/deferred/deferred.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface Contract {
'type' : ContractType,
'is_signed' : boolean,
'agency' : [] | [Agency],
'restricted_properties' : Array<[string, RestrictedProperty]>,
'properties' : Array<[string, GenericValue]>,
'sellers' : Array<Seller>,
'expiration' : [] | [string],
Expand All @@ -65,6 +66,7 @@ export interface Contract {
export interface ContractRegistration {
'value' : bigint,
'type' : ContractType,
'restricted_properties' : Array<[string, RestrictedProperty]>,
'properties' : Array<[string, GenericValue]>,
'sellers' : Array<Seller>,
'expiration' : [] | [string],
Expand Down Expand Up @@ -115,7 +117,7 @@ export type GenericValue = { 'Nat64Content' : bigint } |
{ 'FloatContent' : number } |
{ 'Int16Content' : number } |
{ 'BlobContent' : Uint8Array | number[] } |
{ 'NestedContent' : Vec } |
{ 'NestedContent' : Array<[string, GenericValue]> } |
{ 'Principal' : Principal } |
{ 'TextContent' : string };
export interface HttpRequest {
Expand Down Expand Up @@ -158,6 +160,13 @@ export type RejectionCode = { 'NoError' : null } |
{ 'Unknown' : null } |
{ 'SysFatal' : null } |
{ 'CanisterReject' : null };
export interface RestrictedProperty {
'value' : GenericValue,
'access_list' : Array<RestrictionLevel>,
}
export type RestrictionLevel = { 'Buyer' : null } |
{ 'Seller' : null } |
{ 'Agent' : null };
export type Result = { 'Ok' : null } |
{ 'Err' : DeferredError };
export type Result_1 = { 'Ok' : bigint } |
Expand Down Expand Up @@ -267,27 +276,6 @@ export interface TxEvent {
'details' : Array<[string, GenericValue]>,
'caller' : Principal,
}
export type Vec = Array<
[
string,
{ 'Nat64Content' : bigint } |
{ 'Nat32Content' : number } |
{ 'BoolContent' : boolean } |
{ 'Nat8Content' : number } |
{ 'Int64Content' : bigint } |
{ 'IntContent' : bigint } |
{ 'NatContent' : bigint } |
{ 'Nat16Content' : number } |
{ 'Int32Content' : number } |
{ 'Int8Content' : number } |
{ 'FloatContent' : number } |
{ 'Int16Content' : number } |
{ 'BlobContent' : Uint8Array | number[] } |
{ 'NestedContent' : Vec } |
{ 'Principal' : Principal } |
{ 'TextContent' : string },
]
>;
export interface _SERVICE {
'admin_register_agency' : ActorMethod<[Principal, Agency], undefined>,
'admin_remove_role' : ActorMethod<[Principal, Role], Result>,
Expand All @@ -301,6 +289,10 @@ export interface _SERVICE {
'cycles' : ActorMethod<[], bigint>,
'get_agencies' : ActorMethod<[], Array<Agency>>,
'get_contract' : ActorMethod<[bigint], [] | [Contract]>,
'get_restricted_contract_properties' : ActorMethod<
[bigint],
[] | [Array<[string, RestrictedProperty]>]
>,
'get_signed_contracts' : ActorMethod<[], Array<bigint>>,
'get_token' : ActorMethod<[bigint], [] | [TokenInfo]>,
'get_unsigned_contracts' : ActorMethod<[], Array<bigint>>,
Expand Down Expand Up @@ -343,6 +335,10 @@ export interface _SERVICE {
[bigint, string, GenericValue],
Result
>,
'update_restricted_contract_property' : ActorMethod<
[bigint, string, RestrictedProperty],
Result
>,
}
export declare const idlFactory: IDL.InterfaceFactory;
export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[];
Loading

0 comments on commit f736341

Please sign in to comment.