Skip to content

Commit

Permalink
get bridge tokens account (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 authored Oct 5, 2023
1 parent 59f5fbe commit 544ee54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bridge-token-factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ impl BridgeTokenFactory {
self.tokens.iter().collect::<Vec<_>>()
}

/// Return Near accounts ID of all registered tokens
pub fn get_tokens_accounts(&self) -> Vec<String> {
self.tokens
.iter()
.map(|address| format!("{}.{}", address, env::current_account_id()))
.collect::<Vec<_>>()
}

fn set_token_metadata_timestamp(&mut self, token: &String, timestamp: u64) -> Balance {
let initial_storage = env::storage_usage();
self.token_metadata_last_update().insert(&token, &timestamp);
Expand Down Expand Up @@ -728,6 +736,20 @@ mod tests {
bridge_token_factory()
)
);

let mut tokens_accounts = contract.get_tokens_accounts();
assert_eq!(tokens_accounts.len(), 2);
tokens_accounts.sort();

assert_eq!(
tokens_accounts,
[
contract
.get_bridge_token_account_id(uppercase_address.clone())
.to_string(),
format!("{}.{}", token_locker(), bridge_token_factory())
]
);
}

#[test]
Expand Down
Binary file modified res/bridge_token_factory.wasm
Binary file not shown.

0 comments on commit 544ee54

Please sign in to comment.