Skip to content

Commit

Permalink
feat: add scan_keystores api[R2D2-13481] (#143)
Browse files Browse the repository at this point in the history
* feat: add scan_keystores api

* chore: code optimized

* chore: scan_keystore filter duplicate keystores

* chore: code optimized

* chore: code optimized

* fix: fix scan_keystores api error

* test: fix unit test error

* chore: code optimized

* chore: merge identity wallet account into one accounts

* fix: fix cannot read property identitfier error

* chore: optimize the logic of retrieving legacy keystores

* chore: delete prints code

* fix: fix the error message returned when the wallet does not exist

* fix: fix the issue of deleting EOS when deleting identity wallet

* test: fix unit test error

* fix: fix v3keystore auto recovery error

* test: add scan_keystore test case

* test: add test data

* fix: fix the legacy private keystore identified_chain_types incorrect

* chore: modify indentity wallet return identified_chain_types is null

* chore: code optimized

* chore: optimize the function name

* fix: fix the incorrect identified_chain_types of the eth private key wallet
  • Loading branch information
xiaoguang1010 authored Jan 24, 2025
1 parent 2118a26 commit 2720c52
Show file tree
Hide file tree
Showing 47 changed files with 795 additions and 40 deletions.
19 changes: 19 additions & 0 deletions token-core/tcx-proto/src/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,25 @@ message ScanKeystoresResult {
repeated ImportPrivateKeyResult privateKeyKeystores = 2;
}

message ScannedKeystoresResult {
repeated ScannedKeystore keystores = 1;
}

message ScannedKeystore {
string id = 1;
string name = 2;
string identifier = 3;
string ipfsId = 4;
string source = 5;
int64 createdAt = 6;
repeated AccountResponse accounts = 7;
string migration_status = 8;// This field can have one of three values: "migrated", "unmigrated", or "new".
repeated string identifiedChainTypes = 9;
string identifiedNetwork = 10;
string identifiedCurve = 11;
string sourceFingerprint = 12;
}

message LegacyKeystoreResult {
string id = 1;
string name = 2;
Expand Down
35 changes: 35 additions & 0 deletions token-core/tcx/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,41 @@ pub struct ScanKeystoresResult {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScannedKeystoresResult {
#[prost(message, repeated, tag = "1")]
pub keystores: ::prost::alloc::vec::Vec<ScannedKeystore>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScannedKeystore {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub identifier: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub ipfs_id: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub source: ::prost::alloc::string::String,
#[prost(int64, tag = "6")]
pub created_at: i64,
#[prost(message, repeated, tag = "7")]
pub accounts: ::prost::alloc::vec::Vec<AccountResponse>,
/// This field can have one of three values: "migrated", "unmigrated", or "new".
#[prost(string, tag = "8")]
pub migration_status: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "9")]
pub identified_chain_types: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "10")]
pub identified_network: ::prost::alloc::string::String,
#[prost(string, tag = "11")]
pub identified_curve: ::prost::alloc::string::String,
#[prost(string, tag = "12")]
pub source_fingerprint: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LegacyKeystoreResult {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
Expand Down
3 changes: 3 additions & 0 deletions token-core/tcx/src/filemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ lazy_static! {

pub const WALLET_V1_DIR: &str = "wallets";
pub const WALLET_V2_DIR: &str = "walletsV2";
pub const STATUS_NEW: &str = "new";
pub const STATUS_UNMIGRATED: &str = "unmigrated";
pub const STATUS_MIGRATED: &str = "migrated";

pub fn clean_keystore() {
KEYSTORE_MAP.write().clear()
Expand Down
Loading

0 comments on commit 2720c52

Please sign in to comment.