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

remove polybase #210

Merged
merged 1 commit into from
Dec 9, 2023
Merged
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
4 changes: 0 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: replace polybase namespace
run: |
mkdir -p src-tauri/configs
echo -n "${{ secrets.POLYBASE_NAMESPACE }}" > src-tauri/configs/polybase.namespace
- name: setup node
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test-on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: replace polybase namespace
run: |
mkdir -p src-tauri/configs
echo -n "${{ secrets.POLYBASE_NAMESPACE }}" > src-tauri/configs/polybase.namespace
- name: setup node
uses: actions/setup-node@v3
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ dist-ssr
.vscode/

.local/
src-tauri/configs/polybase.namespace
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
2. Support Binance, OKX and Gate.io. How to create api key: [Binance](https://www.binance.com/en-BH/support/faq/how-to-create-api-360002502072), [OKX](https://use.autoview.com/hc/en-us/articles/360004576632-OKEx-Creating-an-API), [Gate.io](https://www.gate.io/help/guide/common/17521/how-to-utilize-api)
3. Support BTC, ETH ( ERC20 Tokens ), BNB ( ERC20 Tokens ), SOL and Doge ( Base Users ).
4. Support dozens of charts to analyze data such as wallet proportion, proportion of each currency asset, changes, etc.
5. Support Cloud Sync, users can sync their data to cloud and restore it on another device.
5. Support Data backup and restore. Users can export data to local files and import them to other devices, or share them between multi devices by cloud drive ( e.g. iCloud ).

## Pro Users

Expand All @@ -47,16 +47,10 @@
![sc3](./images/demo/sc3.jpg)
![sc4](./images/demo/sc4.jpg)

## Cloud Sync

Track3 use [Polybase](https://polybase.xyz/) to sync data. Polybase is a decentralized database powered by zero knowledge proofs, with attributes of a blockchain and the speed & privacy of a database.

### Notice

**All your data is private, only you can access it. And track3 will never sync your configurations into cloud, they are always stored locally with encryption. So your wallet addresses and api keys are totally safe.**

But currently track3 are using polybase testnet, so your data may be lost on cloud, but this will not affect your local data.

## Known Issues

- [ ] Cannot list assets in earn wallet in OKX
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
},
"dependencies": {
"@aptabase/tauri": "^0.2.0",
"@polybase/client": "^0.6.6",
"@polybase/eth": "^0.6.6",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
13 changes: 7 additions & 6 deletions src-tauri/migrations/init/cloud_sync_up.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CREATE TABLE IF NOT EXISTS "cloud_sync" (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
publicKey TEXT NOT NULL,
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX IF NOT EXISTS unique_public_key ON cloud_sync (publicKey);
-- Deprecated: do not support cloud sync anymore
-- CREATE TABLE IF NOT EXISTS "cloud_sync" (
-- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
-- publicKey TEXT NOT NULL,
-- updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
-- );
-- CREATE UNIQUE INDEX IF NOT EXISTS unique_public_key ON cloud_sync (publicKey);
2 changes: 2 additions & 0 deletions src-tauri/migrations/v04t05/cloud_sync_down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- TODO: execute it when upgrade to v0.5
DROP TABLE IF EXISTS cloud_sync;
23 changes: 0 additions & 23 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@ fn md5(data: String) -> Result<String, String> {
Ok(format!("{:x}", digest))
}

#[cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
#[tauri::command]
async fn get_polybase_namespace(handle: tauri::AppHandle) -> Result<String, String> {
let ns = fs::read_to_string(
handle
.path_resolver()
.resource_dir()
.unwrap()
.as_path()
.join("configs/polybase.namespace"),
);

match ns {
// remove \n
Ok(ns) => Ok(ns.replace("\n", "")),
Err(e) => Err(format!("get polybase namespace error: {:?}", e)),
}
}

#[cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
Expand Down Expand Up @@ -248,7 +226,6 @@ fn main() {
encrypt,
decrypt,
md5,
get_polybase_namespace,
download_coins_logos,
open_debank_window_in_background,
close_debank_window,
Expand Down
43 changes: 40 additions & 3 deletions src-tauri/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ pub fn init_sqlite_tables(app_version: String, app_dir: &Path, resource_dir: &Pa
fs::read_to_string(resource_dir.join("migrations/init/configuration_up.sql")).unwrap();
let assets_v2 =
fs::read_to_string(resource_dir.join("migrations/init/assets_v2_up.sql")).unwrap();
let cloud_sync =
fs::read_to_string(resource_dir.join("migrations/init/cloud_sync_up.sql")).unwrap();
let currency_rates_sync =
fs::read_to_string(resource_dir.join("migrations/init/currency_rates_up.sql")).unwrap();
let asset_actions =
Expand All @@ -51,7 +49,6 @@ pub fn init_sqlite_tables(app_version: String, app_dir: &Path, resource_dir: &Pa
let mut conn = SqliteConnection::connect(&sqlite_path).await.unwrap();
conn.execute(configuration.as_str()).await.unwrap();
conn.execute(assets_v2.as_str()).await.unwrap();
conn.execute(cloud_sync.as_str()).await.unwrap();
conn.execute(currency_rates_sync.as_str()).await.unwrap();
conn.execute(asset_actions.as_str()).await.unwrap();

Expand Down Expand Up @@ -525,3 +522,43 @@ impl Migration for V3TV4 {
});
}
}

// todo: enable it when v0.5 is ready
pub struct V4TV5 {
app_dir: String,
resource_dir: String,
}

impl Migration for V4TV5 {
fn new(app_dir: String, resource_dir: String) -> Self {
V4TV5 {
app_dir,
resource_dir,
}
}

fn need_to_run(&self, previous_version: &str) -> Result<bool, Box<dyn std::error::Error>> {
let res = version::compare(previous_version, "0.5.0").unwrap_or(-1) > 0;
println!("check if from v0.4 to v0.5 in rust, {:?}", res);
return Ok(res);
}

fn migrate(&self) {
let app_dir = Path::new(&self.app_dir);
let resource_dir = Path::new(&self.resource_dir);
println!("migrate from v0.4 to v0.5");
let sqlite_path = get_sqlite_file_path(app_dir);
let cloud_sync_down =
fs::read_to_string(resource_dir.join("migrations/v04t05/cloud_sync_down.sql"))
.unwrap();

let rt = Runtime::new().unwrap();
rt.block_on(async move {
println!("migrate from v0.4 to v0.5 in tokio spawn");
let mut conn = SqliteConnection::connect(&sqlite_path).await.unwrap();
conn.execute(cloud_sync_down.as_str()).await.unwrap();
conn.close().await.unwrap();
println!("migrate from v0.4 to v0.5 in tokio spawn done");
});
}
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"providerShortName": null,
"signingIdentity": null
},
"resources": ["migrations/**/*", "configs/**/*"],
"resources": ["migrations/**/*"],
"shortDescription": "",
"targets": "all",
"windows": {
Expand Down
Loading
Loading