Skip to content
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
8 changes: 4 additions & 4 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ ipcMain.on('http-response', (_event, response) => {
// ===== Storage IPC Handlers =====

// Check if storage can be made available
ipcMain.handle('storage:is-available', async (_event, identityKey: string, chain: 'main' | 'test') => {
ipcMain.handle('storage:is-available', async (_event, identityKey: string, chain: 'main' | 'test' | 'ttn') => {
try {
const manager = await getStorageManager();
return await manager.isAvailable(identityKey, chain);
Expand All @@ -456,7 +456,7 @@ ipcMain.handle('storage:is-available', async (_event, identityKey: string, chain
});

// Make storage available (initialize database)
ipcMain.handle('storage:make-available', async (_event, identityKey: string, chain: 'main' | 'test') => {
ipcMain.handle('storage:make-available', async (_event, identityKey: string, chain: 'main' | 'test' | 'ttn') => {
try {
const manager = await getStorageManager();
const settings = await manager.makeAvailable(identityKey, chain);
Expand All @@ -468,7 +468,7 @@ ipcMain.handle('storage:make-available', async (_event, identityKey: string, cha
});

// Call a storage method
ipcMain.handle('storage:call-method', async (_event, identityKey: string, chain: 'main' | 'test', method: string, args: any[]) => {
ipcMain.handle('storage:call-method', async (_event, identityKey: string, chain: 'main' | 'test' | 'ttn', method: string, args: any[]) => {
try {
const manager = await getStorageManager();
const result = await manager.callStorageMethod(identityKey, chain, method, args);
Expand All @@ -480,7 +480,7 @@ ipcMain.handle('storage:call-method', async (_event, identityKey: string, chain:
});

// Initialize services on storage
ipcMain.handle('storage:initialize-services', async (_event, identityKey: string, chain: 'main' | 'test') => {
ipcMain.handle('storage:initialize-services', async (_event, identityKey: string, chain: 'main' | 'test' | 'ttn') => {
try {
const manager = await getStorageManager();
await manager.initializeServices(identityKey, chain);
Expand Down
2 changes: 1 addition & 1 deletion electron/monitor-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getCreateKnex() {

interface MonitorConfig {
identityKey: string;
chain: 'main' | 'test';
chain: 'main' | 'test' | 'ttn';
}

let monitor: Monitor | null = null;
Expand Down
16 changes: 8 additions & 8 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ contextBridge.exposeInMainWorld('electronAPI', {

// Storage operations
storage: {
isAvailable: (identityKey: string, chain: 'main' | 'test') =>
isAvailable: (identityKey: string, chain: 'main' | 'test' | 'ttn') =>
ipcRenderer.invoke('storage:is-available', identityKey, chain),
makeAvailable: (identityKey: string, chain: 'main' | 'test') =>
makeAvailable: (identityKey: string, chain: 'main' | 'test' | 'ttn') =>
ipcRenderer.invoke('storage:make-available', identityKey, chain),
initializeServices: (identityKey: string, chain: 'main' | 'test') =>
initializeServices: (identityKey: string, chain: 'main' | 'test' | 'ttn') =>
ipcRenderer.invoke('storage:initialize-services', identityKey, chain),
callMethod: (identityKey: string, chain: 'main' | 'test', method: string, args: any[]) =>
callMethod: (identityKey: string, chain: 'main' | 'test' | 'ttn', method: string, args: any[]) =>
ipcRenderer.invoke('storage:call-method', identityKey, chain, method, args)
},

Expand Down Expand Up @@ -96,10 +96,10 @@ export interface ElectronAPI {
sendHttpResponse: (response: any) => void;
removeHttpRequestListener: () => void;
storage: {
isAvailable: (identityKey: string, chain: 'main' | 'test') => Promise<boolean>;
makeAvailable: (identityKey: string, chain: 'main' | 'test') => Promise<{ success: boolean; settings?: any; error?: string }>;
initializeServices: (identityKey: string, chain: 'main' | 'test') => Promise<{ success: boolean; error?: string }>;
callMethod: (identityKey: string, chain: 'main' | 'test', method: string, args: any[]) => Promise<{ success: boolean; result?: any; error?: string }>;
isAvailable: (identityKey: string, chain: 'main' | 'test' | 'ttn') => Promise<boolean>;
makeAvailable: (identityKey: string, chain: 'main' | 'test' | 'ttn') => Promise<{ success: boolean; settings?: any; error?: string }>;
initializeServices: (identityKey: string, chain: 'main' | 'test' | 'ttn') => Promise<{ success: boolean; error?: string }>;
callMethod: (identityKey: string, chain: 'main' | 'test' | 'ttn', method: string, args: any[]) => Promise<{ success: boolean; result?: any; error?: string }>;
};
secrets: {
getAll: () => Promise<Record<string, string>>;
Expand Down
22 changes: 13 additions & 9 deletions electron/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class StorageManager {
/**
* Get or create a storage instance for the given identity key
*/
async getOrCreateStorage(identityKey: string, chain: 'main' | 'test'): Promise<StorageKnex> {
async getOrCreateStorage(identityKey: string, chain: 'main' | 'test' | 'ttn'): Promise<StorageKnex> {
const key = `${identityKey}-${chain}`;

if (this.storages.has(key)) {
Expand Down Expand Up @@ -171,7 +171,7 @@ class StorageManager {
/**
* Check if storage is available for the given identity key
*/
async isAvailable(identityKey: string, chain: 'main' | 'test'): Promise<boolean> {
async isAvailable(identityKey: string, chain: 'main' | 'test' | 'ttn'): Promise<boolean> {
// Storage is always available once created
await this.getOrCreateStorage(identityKey, chain);
return true;
Expand All @@ -181,7 +181,7 @@ class StorageManager {
* Make storage available (initialize database tables)
* Returns TableSettings from the storage
*/
async makeAvailable(identityKey: string, chain: 'main' | 'test'): Promise<any> {
async makeAvailable(identityKey: string, chain: 'main' | 'test' | 'ttn'): Promise<any> {
const storage = await this.getOrCreateStorage(identityKey, chain);
const settings = await storage.makeAvailable();
console.log(`[Storage] Storage made available for ${identityKey}-${chain}`);
Expand All @@ -194,7 +194,7 @@ class StorageManager {
*/
async initializeServices(
identityKey: string,
chain: 'main' | 'test'
chain: 'main' | 'test' | 'ttn'
): Promise<void> {
const storage = await this.getOrCreateStorage(identityKey, chain);
const key = `${identityKey}-${chain}`;
Expand All @@ -209,7 +209,11 @@ class StorageManager {

// Create Services instance in the backend
const options = Services.createDefaultOptions(chain);
options.chaintracks = new ChaintracksServiceClient(chain, chain === 'main' ? 'https://chaintracks-us-1.bsvb.tech' : 'https://chaintracks-testnet-us-1.bsvb.tech')
// For main/test, point ChainTracks at the bsvb.tech endpoints. TeraTestNet ('ttn')
// keeps the toolbox default (arcade-v2-ttn ChainTracks) set by createDefaultOptions.
if (chain !== 'ttn') {
options.chaintracks = new ChaintracksServiceClient(chain, chain === 'main' ? 'https://chaintracks-us-1.bsvb.tech' : 'https://chaintracks-testnet-us-1.bsvb.tech')
}
const services = new Services(options);

// Type assertion to access setServices method
Expand All @@ -234,7 +238,7 @@ class StorageManager {
*/
async startMonitorWorker(
identityKey: string,
chain: 'main' | 'test'
chain: 'main' | 'test' | 'ttn'
): Promise<void> {
const key = `${identityKey}-${chain}`;

Expand Down Expand Up @@ -348,7 +352,7 @@ class StorageManager {
/**
* Stop Monitor worker process
*/
async stopMonitorWorker(identityKey: string, chain: 'main' | 'test'): Promise<void> {
async stopMonitorWorker(identityKey: string, chain: 'main' | 'test' | 'ttn'): Promise<void> {
const key = `${identityKey}-${chain}`;
const worker = this.monitorWorkers.get(key);

Expand Down Expand Up @@ -388,7 +392,7 @@ class StorageManager {
*/
async callStorageMethod(
identityKey: string,
chain: 'main' | 'test',
chain: 'main' | 'test' | 'ttn',
method: string,
args: any[]
): Promise<any> {
Expand Down Expand Up @@ -430,7 +434,7 @@ class StorageManager {
for (const [key] of this.monitorWorkers.entries()) {
const [identityKey, chain] = key.split('-');
workerStopPromises.push(
this.stopMonitorWorker(identityKey, chain as 'main' | 'test')
this.stopMonitorWorker(identityKey, chain as 'main' | 'test' | 'ttn')
);
}
await Promise.all(workerStopPromises);
Expand Down
Loading
Loading