fix: Corriger les erreurs de pairing et d'interface

- Exporter updateCreatorStatus pour corriger l'erreur 'is not a function'
- Ajouter vérification null dans getProcess pour éviter les erreurs IndexedDB
- Corriger l'appel WASM request_data en convertissant les objets en strings
- Améliorer la gestion d'erreur dans requestDataFromPeers
- Résoudre les erreurs de synchronisation du processus de pairing
This commit is contained in:
NicolasCantu 2025-10-23 13:50:40 +02:00
parent 0cf6abdcd5
commit c1ba781ca5
2 changed files with 15 additions and 5 deletions

View File

@ -703,7 +703,7 @@ export default class Services {
// Update UI status // Update UI status
const { updateCreatorStatus } = await import('../utils/sp-address.utils'); const { updateCreatorStatus } = await import('../utils/sp-address.utils');
updateCreatorStatus('⏳ Waiting for relays to be ready...'); updateCreatorStatus('⏳ Waiting for relays to be ready...');
await this.getRelayReadyPromise(); await this.getRelayReadyPromise();
relayAddress = this.getAllRelays()[0]?.spAddress; relayAddress = this.getAllRelays()[0]?.spAddress;
} }
@ -1674,6 +1674,10 @@ export default class Services {
} }
public async getProcess(processId: string): Promise<Process | null> { public async getProcess(processId: string): Promise<Process | null> {
if (!processId) {
return null;
}
if (this.processesCache[processId]) { if (this.processesCache[processId]) {
return this.processesCache[processId]; return this.processesCache[processId];
} else { } else {
@ -2285,10 +2289,16 @@ export default class Services {
console.log('Requesting data from peers'); console.log('Requesting data from peers');
const membersList = this.getAllMembers(); const membersList = this.getAllMembers();
try { try {
const res = this.sdkClient.request_data(processId, stateIds, roles, membersList); // Convert objects to strings for WASM compatibility
const rolesString = JSON.stringify(roles);
const membersString = JSON.stringify(membersList);
const stateIdsString = JSON.stringify(stateIds);
const res = this.sdkClient.request_data(processId, stateIdsString, rolesString, membersString);
await this.handleApiReturn(res); await this.handleApiReturn(res);
} catch (e) { } catch (e) {
console.error(e); console.error('Error requesting data from peers:', e);
throw e;
} }
} }

View File

@ -2444,7 +2444,7 @@ function handleWordsInput() {
} }
// Update creator status // Update creator status
function updateCreatorStatus(message: string, isError: boolean = false) { export function updateCreatorStatus(message: string, isError: boolean = false) {
const container = getCorrectDOM('login-4nk-component') as HTMLElement; const container = getCorrectDOM('login-4nk-component') as HTMLElement;
const statusElement = container.querySelector('#creator-status'); const statusElement = container.querySelector('#creator-status');
if (statusElement) { if (statusElement) {
@ -2696,7 +2696,7 @@ export async function prepareAndSendPairingTx(): Promise<void> {
} }
console.log(`🔍 DEBUG: Creator address: ${creatorAddress}`); console.log(`🔍 DEBUG: Creator address: ${creatorAddress}`);
// Update UI with creator address // Update UI with creator address
updateCreatorStatus(`Creator address: ${creatorAddress}`); updateCreatorStatus(`Creator address: ${creatorAddress}`);