Skip to content

Commit

Permalink
begin vault
Browse files Browse the repository at this point in the history
  • Loading branch information
BitHighlander committed Jan 25, 2025
1 parent b896929 commit a7937f4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
13 changes: 8 additions & 5 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"builder-util": "^25.0.0-alpha.6",
"crypto": "^1.0.1",
"dotenv-cli": "^7.4.1",
"sqlite3": "^5.1.7",
"web3": "^4.0.1"
}
}
1 change: 1 addition & 0 deletions packages/keepkey-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"secp256k1": "^4.0.3",
"semver": "^7.3.8",
"source-map-support": "^0.5.21",
"sqlite3": "^5.1.7",
"sudo-prompt": "^9.2.1",
"swagger-ui-dist": "^4.15.5",
"swagger-ui-express": "^4.6.0",
Expand Down
32 changes: 25 additions & 7 deletions packages/keepkey-sdk-server/src/auth/apiContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import { isEqual } from 'lodash'
import type { SdkClient } from './sdkClient'
const horribleAccountsHack = new WeakMap<KeepKeyHDWallet, Record<string, BIP32Path>>()

//@TODO get web3 providers

//serve web3 provider

//maintain network context from renderer selections
// @ts-ignore
// import sqlite3 from 'sqlite3'

export class ApiContext {
readonly sdkClient: SdkClient
Expand All @@ -21,6 +18,7 @@ export class ApiContext {
readonly accounts: Record<string, BIP32Path>
readonly path: string
api: Pioneer
sql: any

protected constructor(sdkClient: SdkClient, accounts: Record<string, BIP32Path>, path: string) {
this.sdkClient = sdkClient
Expand All @@ -29,10 +27,31 @@ export class ApiContext {
this.accounts = accounts
this.path = path
this.api = new Pioneer('https://pioneers.dev/spec/swagger.json', { queryKey: 'kkdesktop:1' })

// // Use the callback signature (err: Error | null) => void
// this.sql = new sqlite3.Database('./keepkey-vault.sqlite3', (err: Error | null) => {
// if (err) {
// console.error('Failed to connect to SQLite database:', err.message)
// }
// })
//
// // Create a table if it doesn't exist yet
// this.sql.run(
// `
// CREATE TABLE IF NOT EXISTS accounts (
// address TEXT PRIMARY KEY,
// addressNList TEXT NOT NULL
// )
// `,
// (err: Error | null) => {
// if (err) {
// console.error('Failed to create accounts table:', err.message)
// }
// }
// )
}

static async create(sdkClient: SdkClient, path: string): Promise<ApiContext> {
// TODO: something something database something
if (!horribleAccountsHack.has(sdkClient.wallet)) {
horribleAccountsHack.set(sdkClient.wallet, {})
}
Expand All @@ -55,6 +74,5 @@ export class ApiContext {
throw new Error('conflicting account entry already present')
}
this.accounts[address] = addressNList
// TODO: something something database something
}
}
1 change: 0 additions & 1 deletion packages/keepkey-sdk-server/src/controllers/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class VaultController extends ApiController {
@OperationId('getVaults')
public async getVaults(): Promise<Pubkey[]> {
try {

return [];
} catch (error: any) {
throw new Error(`Failed to retrieve pubkeys: ${error.message}`);
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19739,6 +19739,7 @@ __metadata:
secp256k1: "npm:^4.0.3"
semver: "npm:^7.3.8"
source-map-support: "npm:^0.5.21"
sqlite3: "npm:^5.1.7"
sudo-prompt: "npm:^9.2.1"
swagger-ui-dist: "npm:^4.15.5"
swagger-ui-express: "npm:^4.6.0"
Expand Down Expand Up @@ -19769,6 +19770,7 @@ __metadata:
dotenv-cli: "npm:^7.4.1"
eslint: "npm:^8.28.0"
prettier: "npm:^2.3.2"
sqlite3: "npm:^5.1.7"
typescript: "npm:^4.7.0"
web3: "npm:^4.0.1"
yaml-sort: "npm:^1.2.1"
Expand Down

0 comments on commit a7937f4

Please sign in to comment.