Skip to content

Commit

Permalink
feat: add extra events (#228)
Browse files Browse the repository at this point in the history
* feat: add extra events

* Fix typo

* Fix typo
  • Loading branch information
karim-en authored Feb 5, 2025
1 parent f663eb4 commit 4f5587a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
20 changes: 20 additions & 0 deletions near/omni-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,17 @@ impl Contract {
attached_deposit >= required_deposit,
"ERROR: The deposit is not sufficient to cover the storage."
);

env::log_str(
&OmniBridgeEvent::BindTokenEvent {
token_id: deploy_token.token,
token_address: deploy_token.token_address,
decimals: deploy_token.decimals,
origin_decimals: deploy_token.origin_decimals,
}
.to_log_string(),
);

attached_deposit.saturating_sub(required_deposit)
}

Expand Down Expand Up @@ -1280,6 +1291,15 @@ impl Contract {
"ERROR: The deposit is not sufficient to cover the storage."
);

env::log_str(
&OmniBridgeEvent::DeployTokenEvent {
token_id: token_id.clone(),
token_address: token_address.clone(),
metadata: metadata.clone(),
}
.to_log_string(),
);

ext_deployer::ext(deployer)
.with_static_gas(DEPLOY_TOKEN_GAS)
.with_attached_deposit(storage::BRIDGE_TOKEN_INIT_BALANCE)
Expand Down
2 changes: 1 addition & 1 deletion near/omni-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ pub fn stringify<T: std::fmt::Display>(item: T) -> String {
}

#[near(serializers=[json])]
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct BasicMetadata {
pub name: String,
pub symbol: String,
Expand Down
15 changes: 13 additions & 2 deletions near/omni-types/src/near_events.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use near_sdk::near;
use near_sdk::serde_json::json;
use near_sdk::{near, AccountId};

use crate::mpc_types::SignatureResponse;
use crate::{MetadataPayload, TransferMessage, TransferMessagePayload};
use crate::{BasicMetadata, MetadataPayload, OmniAddress, TransferMessage, TransferMessagePayload};

#[near(serializers=[json])]
#[derive(Clone, Debug)]
Expand All @@ -27,6 +27,17 @@ pub enum OmniBridgeEvent {
ClaimFeeEvent {
transfer_message: TransferMessage,
},
DeployTokenEvent {
token_id: AccountId,
token_address: OmniAddress,
metadata: BasicMetadata,
},
BindTokenEvent {
token_id: AccountId,
token_address: OmniAddress,
decimals: u8,
origin_decimals: u8,
},
}

impl OmniBridgeEvent {
Expand Down

0 comments on commit 4f5587a

Please sign in to comment.