Fix WebAssembly members parameter type error
**Motivations :** - WebAssembly expects array (sequence) but was receiving object (map) for members parameter - Error: 'invalid type: map, expected a sequence at line 1 column 86' **Modifications :** - Convert getAllMembers() object to array using Object.values() before passing to WebAssembly - Fixed in createProcess, createPrdUpdate, createResponsePrd, validateState, parseCipher, parseNewTx, requestData - Added debug logging for members array length **Pages affectées :** - src/services/service.ts
This commit is contained in:
parent
bf68677d3a
commit
8af1fd055d
@ -583,7 +583,7 @@ async function handleMainPairing(): Promise<void> {
|
||||
|
||||
} catch (error) {
|
||||
console.error('Pairing failed:', error);
|
||||
|
||||
|
||||
if (mainStatus) {
|
||||
mainStatus.innerHTML = '<span style="color: var(--info-color)">⏳ Waiting for user to validate secure key access...</span>';
|
||||
}
|
||||
|
||||
@ -892,10 +892,14 @@ export default class Services {
|
||||
|
||||
await this.getTokensFromFaucet();
|
||||
|
||||
const members = this.getAllMembers();
|
||||
console.log('🔍 DEBUG: Members for create_new_process:', members);
|
||||
console.log('🔍 DEBUG: Members type:', typeof members);
|
||||
console.log('🔍 DEBUG: Members keys:', Object.keys(members));
|
||||
const membersObj = this.getAllMembers();
|
||||
console.log('🔍 DEBUG: Members for create_new_process:', membersObj);
|
||||
console.log('🔍 DEBUG: Members type:', typeof membersObj);
|
||||
console.log('🔍 DEBUG: Members keys:', Object.keys(membersObj));
|
||||
|
||||
// Convert object to array for WebAssembly
|
||||
const members = Object.values(membersObj);
|
||||
console.log('🔍 DEBUG: Members array length:', members.length);
|
||||
|
||||
const result = this.sdkClient.create_new_process(
|
||||
encodedPrivateData,
|
||||
@ -944,7 +948,7 @@ export default class Services {
|
||||
encodedPrivateData,
|
||||
roles,
|
||||
encodedPublicData,
|
||||
this.getAllMembers()
|
||||
Object.values(this.getAllMembers())
|
||||
);
|
||||
if (result.updated_process) {
|
||||
await this.checkConnections(result.updated_process.current_process);
|
||||
@ -965,7 +969,7 @@ export default class Services {
|
||||
await this.checkConnections(process);
|
||||
}
|
||||
try {
|
||||
return this.sdkClient.create_update_message(process, stateId, this.getAllMembers());
|
||||
return this.sdkClient.create_update_message(process, stateId, Object.values(this.getAllMembers()));
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to create prd update: ${e}`);
|
||||
}
|
||||
@ -977,7 +981,7 @@ export default class Services {
|
||||
throw new Error('Unknown process');
|
||||
}
|
||||
try {
|
||||
return this.sdkClient.create_response_prd(process, stateId, this.getAllMembers());
|
||||
return this.sdkClient.create_response_prd(process, stateId, Object.values(this.getAllMembers()));
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to create response prd: ${e}`);
|
||||
}
|
||||
@ -989,7 +993,7 @@ export default class Services {
|
||||
throw new Error('Failed to get process from db');
|
||||
}
|
||||
try {
|
||||
const result = this.sdkClient.validate_state(process, stateId, this.getAllMembers());
|
||||
const result = this.sdkClient.validate_state(process, stateId, Object.values(this.getAllMembers()));
|
||||
if (result.updated_process) {
|
||||
await this.checkConnections(result.updated_process.current_process);
|
||||
return result;
|
||||
@ -1045,7 +1049,7 @@ export default class Services {
|
||||
}
|
||||
|
||||
async parseCipher(message: string) {
|
||||
const membersList = this.getAllMembers();
|
||||
const membersList = Object.values(this.getAllMembers());
|
||||
const processes = await this.getProcesses();
|
||||
try {
|
||||
// console.log('parsing new cipher');
|
||||
@ -1076,7 +1080,7 @@ export default class Services {
|
||||
return;
|
||||
}
|
||||
|
||||
const membersList = this.getAllMembers();
|
||||
const membersList = Object.values(this.getAllMembers());
|
||||
try {
|
||||
// Does the transaction spend the tip of a process?
|
||||
const prevouts = this.sdkClient.get_prevouts(parsedMsg.transaction);
|
||||
@ -2475,7 +2479,7 @@ export default class Services {
|
||||
roles: Record<string, RoleDefinition>[]
|
||||
) {
|
||||
console.log('Requesting data from peers');
|
||||
const membersList = this.getAllMembers();
|
||||
const membersList = Object.values(this.getAllMembers());
|
||||
try {
|
||||
// Convert objects to strings for WASM compatibility
|
||||
const rolesString = JSON.stringify(roles);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user