Skip to content

Commit

Permalink
fix: resolved PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Nov 30, 2024
1 parent 78f4be3 commit e8a5150
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions contracts/icp/context-config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ impl ReprBytes for ICContextIdentity {
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
pub struct ICContextId(pub Identity);
pub struct ICContextId(Identity);

impl ICContextId {
pub fn new(bytes: [u8; 32]) -> Self {
Self(Identity(bytes))
}

pub fn as_bytes(&self) -> [u8; 32] {
self.0.as_bytes()
}
}

impl ReprBytes for ICContextId {
Expand All @@ -117,7 +121,7 @@ impl ReprBytes for ICContextId {
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct ICApplicationId(pub Identity);
pub struct ICApplicationId(Identity);

impl ICApplicationId {
pub fn new(bytes: [u8; 32]) -> Self {
Expand All @@ -143,7 +147,7 @@ impl ReprBytes for ICApplicationId {
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct ICBlobId(pub Identity);
pub struct ICBlobId(Identity);

impl ICBlobId {
pub fn new(bytes: [u8; 32]) -> Self {
Expand Down Expand Up @@ -296,8 +300,8 @@ impl<T> CandidType for Phantom<T> {

#[derive(CandidType, Deserialize, Debug, Clone)]
pub struct ICPSigned<T> {
pub payload: Vec<u8>,
pub signature: Vec<u8>,
payload: Vec<u8>,
signature: Vec<u8>,
_phantom: Phantom<T>,
}

Expand Down
14 changes: 7 additions & 7 deletions contracts/icp/context-config/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn test_mutate_success_cases() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: current_time,
};

Expand Down Expand Up @@ -144,7 +144,7 @@ fn test_member_management() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: get_time_nanos(&pic),
};

Expand Down Expand Up @@ -309,7 +309,7 @@ fn test_capability_management() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: get_time_nanos(&pic),
};

Expand Down Expand Up @@ -529,7 +529,7 @@ fn test_application_update() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: get_time_nanos(&pic),
};

Expand Down Expand Up @@ -739,7 +739,7 @@ fn test_edge_cases() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: get_time_nanos(&pic),
};

Expand Down Expand Up @@ -888,7 +888,7 @@ fn test_timestamp_scenarios() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: current_time,
};

Expand Down Expand Up @@ -962,7 +962,7 @@ fn test_concurrent_operations() {
},
},
}),
signer_id: ICSignerId::new(context_id.0.as_bytes()),
signer_id: ICSignerId::new(context_id.as_bytes()),
timestamp_ms: get_time_nanos(&pic),
};

Expand Down

0 comments on commit e8a5150

Please sign in to comment.