Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add version and commit query calls #53

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions core/ic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/ic/src/tera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ic-kit = "0.4.8"
sha3 = "0.9.1"
hex = "0.4.3"
serde = "1.0.130"
git-version = "0.3.5"
serde_bytes = "0.11.5"
num-bigint = "0.4.3"

Expand Down
1 change: 1 addition & 0 deletions core/ic/src/tera/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pub mod messages;
pub mod nonce;
pub mod send_message;
pub mod store_message;
pub mod version;
17 changes: 17 additions & 0 deletions core/ic/src/tera/src/api/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use candid::candid_method;
use ic_cdk_macros::query;

use super::admin::is_authorized;
use crate::tera::{CURRENT_COMMIT, VERSION};

#[query(name = "get_version", guard = "is_authorized")]
#[candid_method(query, rename = "get_version")]
fn get_version() -> &'static str {
VERSION.with(|v| v.to_owned())
}

#[query(name = "get_current_commit", guard = "is_authorized")]
#[candid_method(query, rename = "get_current_commit")]
fn get_current_commit() -> &'static str {
CURRENT_COMMIT.with(|c| c.to_owned())
}
3 changes: 3 additions & 0 deletions core/ic/src/tera/src/tera.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::common::types::{Nonce, NonceBytes, OutgoingMessage, OutgoingMessagePair};
use candid::{CandidType, Deserialize, Nat, Principal};
use git_version::git_version;
use ic_kit::ic::caller;
use sha2::{Digest, Sha256};
use std::{
Expand All @@ -9,6 +10,8 @@ use std::{

thread_local! {
pub static STATE: TerabetiaState = TerabetiaState::default();
pub static VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub static CURRENT_COMMIT: &'static str = git_version!(args = ["--always", "--exclude", "*"], fallback = "unknown");
}

#[derive(CandidType, Deserialize, Default)]
Expand Down
2 changes: 2 additions & 0 deletions core/ic/src/tera/tera.did
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ type StoreMessageResponse = variant { Ok : CallResult; Err : text };
service : {
authorize : (principal) -> ();
consume_message : (principal, vec nat8, vec nat) -> (ConsumeMessageResponse);
get_current_commit : () -> (text) query;
get_messages : () -> (vec OutgoingMessagePair) query;
get_nonces : () -> (vec nat) query;
get_version : () -> (text) query;
remove_messages : (vec OutgoingMessagePair) -> (ConsumeMessageResponse);
send_message : (principal, vec nat) -> (SendMessageResponse);
store_message : (principal, principal, nat, vec nat) -> (
Expand Down
29 changes: 29 additions & 0 deletions eth_bridge/ic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions eth_bridge/ic/src/eth_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ candid = "0.7.4"
ic-cdk-macros = "0.4"
hex = "0.4.3"
sha3 = "0.9.1"
git-version = "0.3.5"
async-trait = "0.1.51"
serde = "1.0.130"
serde_bytes = "0.11.5"
Expand Down
2 changes: 2 additions & 0 deletions eth_bridge/ic/src/eth_proxy/eth_proxy.did
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ service : {
get_all : (principal) -> (vec ClaimableMessage) query;
get_all_token_balance : () -> (Result_1);
get_balance : (principal) -> (opt nat);
get_current_commit : () -> (text) query;
get_version : () -> (text) query;
handle_message : (principal, nat, vec nat) -> (Result);
mint : (nat, vec nat) -> (Result);
remove_claimable : (principal, nat) -> (Result_2);
Expand Down
1 change: 1 addition & 0 deletions eth_bridge/ic/src/eth_proxy/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ mod handle_message;
mod init;
mod mint;
mod upgrade;
mod version;
mod withdraw;
16 changes: 16 additions & 0 deletions eth_bridge/ic/src/eth_proxy/src/api/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use ic_kit::{candid::candid_method, macros::query};

use super::admin::is_authorized;
use crate::proxy::{CURRENT_COMMIT, VERSION};

#[query(name = "get_version", guard = "is_authorized")]
#[candid_method(query, rename = "get_version")]
fn get_version() -> &'static str {
VERSION.with(|v| v.to_owned())
}

#[query(name = "get_current_commit", guard = "is_authorized")]
#[candid_method(query, rename = "get_current_commit")]
fn get_current_commit() -> &'static str {
CURRENT_COMMIT.with(|c| c.to_owned())
}
3 changes: 3 additions & 0 deletions eth_bridge/ic/src/eth_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, ops::AddAssign};

use git_version::git_version;
use ic_cdk::export::candid::{Nat, Principal};
use ic_kit::ic;

Expand All @@ -14,6 +15,8 @@ pub const WETH_ADDRESS_ETH: &str = "0x2e130e57021bb4dfb95eb4dd0dd8cfceb936148a";

thread_local! {
pub static STATE: ProxyState = ProxyState::default();
pub static VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub static CURRENT_COMMIT: &'static str = git_version!(args = ["--always", "--exclude", "*"], fallback = "unknown");
}

impl ProxyState {
Expand Down
30 changes: 30 additions & 0 deletions magic_bridge/ic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions magic_bridge/ic/src/dip20_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ic-cdk-macros = "0.4"
hex = "0.4.3"
sha3 = "0.9.1"
async-trait = "0.1.51"
git-version = "0.3.5"
serde = "1.0.130"
serde_bytes = "0.11.5"
num-bigint = "0.4.3"
2 changes: 2 additions & 0 deletions magic_bridge/ic/src/dip20_proxy/dip20_proxy.did
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ service : {
claimable_get_all : (principal) -> (vec ClaimableMessage) query;
get_all_token_balance : () -> (Result_1);
get_balance : (principal) -> (opt nat);
get_current_commit : () -> (text) query;
get_version : () -> (text) query;
handle_message : (principal, nat, vec nat) -> (Result);
mint : (principal, nat, vec nat) -> (Result);
remove_claimable : (principal, principal, nat) -> (Result_2);
Expand Down
1 change: 1 addition & 0 deletions magic_bridge/ic/src/dip20_proxy/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ mod handle_message;
mod init;
mod mint;
mod upgrade;
mod version;
mod withdraw;
16 changes: 16 additions & 0 deletions magic_bridge/ic/src/dip20_proxy/src/api/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use ic_kit::{candid::candid_method, macros::query};

use super::admin::is_authorized;
use crate::proxy::{CURRENT_COMMIT, VERSION};

#[query(name = "get_version", guard = "is_authorized")]
#[candid_method(query, rename = "get_version")]
fn get_version() -> &'static str {
VERSION.with(|v| v.to_owned())
}

#[query(name = "get_current_commit", guard = "is_authorized")]
#[candid_method(query, rename = "get_current_commit")]
fn get_current_commit() -> &'static str {
CURRENT_COMMIT.with(|c| c.to_owned())
}
3 changes: 3 additions & 0 deletions magic_bridge/ic/src/dip20_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, ops::AddAssign};

use git_version::git_version;
use ic_cdk::export::candid::{Nat, Principal};
use ic_kit::ic;

Expand All @@ -14,6 +15,8 @@ pub const ERC20_ADDRESS_ETH: &str = "0x8CA1651eadeF97D3aC36c25DAE4A552c1368F27d"

thread_local! {
pub static STATE: ProxyState = ProxyState::default();
pub static VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub static CURRENT_COMMIT: &'static str = git_version!(args = ["--always", "--exclude", "*"], fallback = "unknown");
}

impl ProxyState {
Expand Down
1 change: 1 addition & 0 deletions magic_bridge/ic/src/magic_bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ic-kit = "0.4.4"
ic-cdk = "0.4.0"
serde = "1.0.133"
ic-cdk-macros = "0.3"
git-version = "0.3.5"
serde_cbor = "0.11.2"
serde_bytes = "0.11.5"
assert-panic = "1.0.1"
Expand Down
2 changes: 2 additions & 0 deletions magic_bridge/ic/src/magic_bridge/magic_bridge.did
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ service : {
flush_failed_registrations : () -> ();
get_all : () -> (vec record { principal; principal }) query;
get_canister : (principal) -> (opt principal) query;
get_current_commit : () -> (text) query;
get_failed_registrations : () -> (
vec record { principal; record { CreateCanisterParam; nat8 } },
) query;
get_version : () -> (text) query;
upgrade_code : (principal, TokenType) -> (Result_1);
}
1 change: 1 addition & 0 deletions magic_bridge/ic/src/magic_bridge/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ mod init;
mod inspect_message;
mod install;
mod upgrade;
mod version;
16 changes: 16 additions & 0 deletions magic_bridge/ic/src/magic_bridge/src/api/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use ic_kit::{candid::candid_method, macros::query};

use super::admin::is_authorized;
use crate::magic::{CURRENT_COMMIT, VERSION};

#[query(name = "get_version", guard = "is_authorized")]
#[candid_method(query, rename = "get_version")]
fn get_version() -> &'static str {
VERSION.with(|v| v.to_owned())
}

#[query(name = "get_current_commit", guard = "is_authorized")]
#[candid_method(query, rename = "get_current_commit")]
fn get_current_commit() -> &'static str {
CURRENT_COMMIT.with(|c| c.to_owned())
}
3 changes: 3 additions & 0 deletions magic_bridge/ic/src/magic_bridge/src/magic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::factory::CreateCanisterParam;
use crate::types::*;
use git_version::git_version;
use ic_kit::candid::{CandidType, Deserialize};
use ic_kit::interfaces::management::{
CanisterStatus, CanisterStatusResponse, DeleteCanister, DepositCycles, StartCanister,
Expand All @@ -14,6 +15,8 @@ use std::str;

thread_local! {
pub static STATE: MagicState = MagicState::default();
pub static VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub static CURRENT_COMMIT: &'static str = git_version!(args = ["--always", "--exclude", "*"], fallback = "unknown");
}

#[derive(CandidType, Deserialize, Default)]
Expand Down