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
@ -892,10 +892,14 @@ export default class Services {
|
|||||||
|
|
||||||
await this.getTokensFromFaucet();
|
await this.getTokensFromFaucet();
|
||||||
|
|
||||||
const members = this.getAllMembers();
|
const membersObj = this.getAllMembers();
|
||||||
console.log('🔍 DEBUG: Members for create_new_process:', members);
|
console.log('🔍 DEBUG: Members for create_new_process:', membersObj);
|
||||||
console.log('🔍 DEBUG: Members type:', typeof members);
|
console.log('🔍 DEBUG: Members type:', typeof membersObj);
|
||||||
console.log('🔍 DEBUG: Members keys:', Object.keys(members));
|
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(
|
const result = this.sdkClient.create_new_process(
|
||||||
encodedPrivateData,
|
encodedPrivateData,
|
||||||
@ -944,7 +948,7 @@ export default class Services {
|
|||||||
encodedPrivateData,
|
encodedPrivateData,
|
||||||
roles,
|
roles,
|
||||||
encodedPublicData,
|
encodedPublicData,
|
||||||
this.getAllMembers()
|
Object.values(this.getAllMembers())
|
||||||
);
|
);
|
||||||
if (result.updated_process) {
|
if (result.updated_process) {
|
||||||
await this.checkConnections(result.updated_process.current_process);
|
await this.checkConnections(result.updated_process.current_process);
|
||||||
@ -965,7 +969,7 @@ export default class Services {
|
|||||||
await this.checkConnections(process);
|
await this.checkConnections(process);
|
||||||
}
|
}
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
throw new Error(`Failed to create prd update: ${e}`);
|
throw new Error(`Failed to create prd update: ${e}`);
|
||||||
}
|
}
|
||||||
@ -977,7 +981,7 @@ export default class Services {
|
|||||||
throw new Error('Unknown process');
|
throw new Error('Unknown process');
|
||||||
}
|
}
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
throw new Error(`Failed to create response prd: ${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');
|
throw new Error('Failed to get process from db');
|
||||||
}
|
}
|
||||||
try {
|
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) {
|
if (result.updated_process) {
|
||||||
await this.checkConnections(result.updated_process.current_process);
|
await this.checkConnections(result.updated_process.current_process);
|
||||||
return result;
|
return result;
|
||||||
@ -1045,7 +1049,7 @@ export default class Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async parseCipher(message: string) {
|
async parseCipher(message: string) {
|
||||||
const membersList = this.getAllMembers();
|
const membersList = Object.values(this.getAllMembers());
|
||||||
const processes = await this.getProcesses();
|
const processes = await this.getProcesses();
|
||||||
try {
|
try {
|
||||||
// console.log('parsing new cipher');
|
// console.log('parsing new cipher');
|
||||||
@ -1076,7 +1080,7 @@ export default class Services {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const membersList = this.getAllMembers();
|
const membersList = Object.values(this.getAllMembers());
|
||||||
try {
|
try {
|
||||||
// Does the transaction spend the tip of a process?
|
// Does the transaction spend the tip of a process?
|
||||||
const prevouts = this.sdkClient.get_prevouts(parsedMsg.transaction);
|
const prevouts = this.sdkClient.get_prevouts(parsedMsg.transaction);
|
||||||
@ -2475,7 +2479,7 @@ export default class Services {
|
|||||||
roles: Record<string, RoleDefinition>[]
|
roles: Record<string, RoleDefinition>[]
|
||||||
) {
|
) {
|
||||||
console.log('Requesting data from peers');
|
console.log('Requesting data from peers');
|
||||||
const membersList = this.getAllMembers();
|
const membersList = Object.values(this.getAllMembers());
|
||||||
try {
|
try {
|
||||||
// Convert objects to strings for WASM compatibility
|
// Convert objects to strings for WASM compatibility
|
||||||
const rolesString = JSON.stringify(roles);
|
const rolesString = JSON.stringify(roles);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user