Skip to content

Commit

Permalink
chore: use update instead of query for get_messages method (#51)
Browse files Browse the repository at this point in the history
* use update instead of query for get_messages method

* remove query from tera candid js in aws
  • Loading branch information
fcavazzoli committed Sep 5, 2022
1 parent 65b3c17 commit cef259f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/aws/src/libs/dfinity/idls/tera/tera.did.ts
Expand Up @@ -27,7 +27,7 @@ export default ({ IDL }: { IDL: any }) => {
[ConsumeMessageResponse],
[],
),
get_messages: IDL.Func([], [IDL.Vec(OutgoingMessagePair)], ['query']),
get_messages: IDL.Func([], [IDL.Vec(OutgoingMessagePair)], []),
get_nonces: IDL.Func([], [IDL.Vec(IDL.Nat)], ['query']),
remove_messages: IDL.Func(
[IDL.Vec(OutgoingMessagePair)],
Expand Down
6 changes: 3 additions & 3 deletions core/ic/src/tera/src/api/messages.rs
@@ -1,5 +1,5 @@
use candid::candid_method;
use ic_cdk_macros::{query, update};
use ic_cdk_macros::update;

use super::admin::is_authorized;
use crate::{
Expand All @@ -13,8 +13,8 @@ fn remove_messages(messages: Vec<OutgoingMessagePair>) -> RemoveMessagesResponse
STATE.with(|s| RemoveMessagesResponse(s.remove_messages(messages)))
}

#[query(name = "get_messages", guard = "is_authorized")]
#[candid_method(query, rename = "get_messages")]
#[update(name = "get_messages", guard = "is_authorized")]
#[candid_method(update, rename = "get_messages")]
fn get_messages() -> Vec<OutgoingMessagePair> {
STATE.with(|s| s.get_messages())
}
Expand Down
2 changes: 1 addition & 1 deletion core/ic/src/tera/tera.did
Expand Up @@ -7,7 +7,7 @@ type StoreMessageResponse = variant { Ok : CallResult; Err : text };
service : {
authorize : (principal) -> ();
consume_message : (principal, vec nat8, vec nat) -> (ConsumeMessageResponse);
get_messages : () -> (vec OutgoingMessagePair) query;
get_messages : () -> (vec OutgoingMessagePair);
get_nonces : () -> (vec nat) query;
remove_messages : (vec OutgoingMessagePair) -> (ConsumeMessageResponse);
send_message : (principal, vec nat) -> (SendMessageResponse);
Expand Down

0 comments on commit cef259f

Please sign in to comment.