@@ -16,7 +16,7 @@ use crate::state::{CanisterApi, init_version_and_config, with_canister_state};
1616use candid:: Principal ;
1717use ic_canister_log:: { export as export_logs, log} ;
1818use ic_cdk:: api:: call:: call;
19- use ic_cdk:: { init, inspect_message, post_upgrade, query, update} ;
19+ use ic_cdk:: { api :: msg_caller , init, inspect_message, post_upgrade, query, update} ;
2020use ic_http_types:: { HttpRequest , HttpResponse , HttpResponseBuilder } ;
2121use ic_nns_constants:: REGISTRY_CANISTER_ID ;
2222use rate_limits_api:: {
@@ -34,7 +34,7 @@ const REPLICATED_QUERY_METHOD: &str = "get_config";
3434#[ inspect_message]
3535fn inspect_message ( ) {
3636 // In order for this hook to succeed, accept_message() must be invoked.
37- let caller_id: Principal = ic_cdk :: api :: caller ( ) ;
37+ let caller_id: Principal = msg_caller ( ) ;
3838 let called_method = ic_cdk:: api:: call:: method_name ( ) ;
3939
4040 let ( has_full_access, has_full_read_access) = with_canister_state ( |state| {
@@ -109,7 +109,7 @@ fn post_upgrade(init_arg: InitArg) {
109109/// The response includes the config containing all rate-limit rules and the JSON schema version needed for decoding the rules.
110110#[ query]
111111fn get_config ( version : Option < Version > ) -> GetConfigResponse {
112- let caller_id = ic_cdk :: api :: caller ( ) ;
112+ let caller_id = msg_caller ( ) ;
113113 let response = with_canister_state ( |state| {
114114 let access_resolver = AccessLevelResolver :: new ( caller_id, state. clone ( ) ) ;
115115 let formatter = ConfigConfidentialityFormatter ;
@@ -122,7 +122,7 @@ fn get_config(version: Option<Version>) -> GetConfigResponse {
122122/// Retrieves a specific rate-limit rule by its ID, applying confidentiality formatting, based on caller's access level and rule's confidentiality status
123123#[ query]
124124fn get_rule_by_id ( rule_id : RuleId ) -> GetRuleByIdResponse {
125- let caller_id = ic_cdk :: api :: caller ( ) ;
125+ let caller_id = msg_caller ( ) ;
126126 let response = with_canister_state ( |state| {
127127 let access_resolver = AccessLevelResolver :: new ( caller_id, state. clone ( ) ) ;
128128 let formatter = RuleConfidentialityFormatter ;
@@ -135,7 +135,7 @@ fn get_rule_by_id(rule_id: RuleId) -> GetRuleByIdResponse {
135135/// Retrieves all rate-limit rules associated with a specific incident ID, applying confidentiality formatting, based on caller's access level and rule's confidentiality status
136136#[ query]
137137fn get_rules_by_incident_id ( incident_id : IncidentId ) -> GetRulesByIncidentIdResponse {
138- let caller_id = ic_cdk :: api :: caller ( ) ;
138+ let caller_id = msg_caller ( ) ;
139139 let response = with_canister_state ( |state| {
140140 let access_resolver = AccessLevelResolver :: new ( caller_id, state. clone ( ) ) ;
141141 let formatter = RuleConfidentialityFormatter ;
@@ -151,7 +151,7 @@ fn get_rules_by_incident_id(incident_id: IncidentId) -> GetRulesByIncidentIdResp
151151/// This update method includes authorization check and metrics collection.
152152#[ update]
153153fn add_config ( config : InputConfig ) -> AddConfigResponse {
154- let caller_id = ic_cdk :: api :: caller ( ) ;
154+ let caller_id = msg_caller ( ) ;
155155 let current_time = ic_cdk:: api:: time ( ) ;
156156 with_canister_state ( |state| {
157157 let access_resolver = AccessLevelResolver :: new ( caller_id, state. clone ( ) ) ;
@@ -169,7 +169,7 @@ fn add_config(config: InputConfig) -> AddConfigResponse {
169169/// making them viewable by the public. It includes authorization check and metrics collection.
170170#[ update]
171171fn disclose_rules ( args : DiscloseRulesArg ) -> DiscloseRulesResponse {
172- let caller_id = ic_cdk :: api :: caller ( ) ;
172+ let caller_id = msg_caller ( ) ;
173173 let disclose_time = ic_cdk:: api:: time ( ) ;
174174 with_canister_state ( |state| {
175175 let access_resolver = AccessLevelResolver :: new ( caller_id, state. clone ( ) ) ;
0 commit comments