From 113ff6954b16f6cdd95c8b106a0ec712bd2cd237 Mon Sep 17 00:00:00 2001 From: Ivan Frolov Date: Fri, 29 Nov 2024 21:02:01 -0500 Subject: [PATCH] feat: added `get_token_id` method on NEAR chain --- .../src/near_bridge_client.rs | 19 +++++++++++++++++++ .../omni-connector/src/omni_connector.rs | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/bridge-sdk/bridge-clients/near-bridge-client/src/near_bridge_client.rs b/bridge-sdk/bridge-clients/near-bridge-client/src/near_bridge_client.rs index 6be48ee..72d3752 100644 --- a/bridge-sdk/bridge-clients/near-bridge-client/src/near_bridge_client.rs +++ b/bridge-sdk/bridge-clients/near-bridge-client/src/near_bridge_client.rs @@ -434,6 +434,25 @@ impl NearBridgeClient { Ok(()) } + pub async fn get_token_id(&self, token_address: OmniAddress) -> Result { + let endpoint = self.endpoint()?; + let token_id = self.token_locker_id_as_account_id()?; + + let response = near_rpc_client::view( + endpoint, + token_id, + "get_token_id".to_string(), + serde_json::json!({ + "address": token_address + }), + ) + .await?; + + let token_id = serde_json::from_slice::(&response)?; + + Ok(token_id) + } + pub async fn extract_transfer_log( &self, transaction_hash: CryptoHash, diff --git a/bridge-sdk/connectors/omni-connector/src/omni_connector.rs b/bridge-sdk/connectors/omni-connector/src/omni_connector.rs index 045a205..f78f28e 100644 --- a/bridge-sdk/connectors/omni-connector/src/omni_connector.rs +++ b/bridge-sdk/connectors/omni-connector/src/omni_connector.rs @@ -171,6 +171,11 @@ impl OmniConnector { .await } + pub async fn near_get_token_id(&self, token_address: OmniAddress) -> Result { + let near_bridge_client = self.near_bridge_client()?; + near_bridge_client.get_token_id(token_address).await + } + pub async fn init_transfer(&self, init_transfer_args: InitTransferArgs) -> Result { match init_transfer_args { InitTransferArgs::NearInitTransfer {