pass membersList as argument when needed

This commit is contained in:
NicolasCantu 2025-03-26 14:43:27 +01:00
parent 455fe53fe2
commit 2601418aaf

View File

@ -512,7 +512,6 @@ export default class Services {
// We should check that we have the right to change the roles here, or maybe it's better leave it to the wasm // We should check that we have the right to change the roles here, or maybe it's better leave it to the wasm
console.log('Provided new roles:', JSON.stringify(roles)); console.log('Provided new roles:', JSON.stringify(roles));
} }
console.log(roles);
let members = new Set(); let members = new Set();
for (const role of Object.values(roles)) { for (const role of Object.values(roles)) {
for (const member of role.members) { for (const member of role.members) {
@ -521,9 +520,10 @@ export default class Services {
} }
console.log(members); console.log(members);
await this.checkConnections([...members]); await this.checkConnections([...members]);
const membersList = this.getAllMembers();
try { try {
console.log(process); console.log(process);
return this.sdkClient.update_process(process, new_state, roles, {}); return this.sdkClient.update_process(process, newState, roles, publicData, membersList);
} catch (e) { } catch (e) {
throw new Error(`Failed to update process: ${e}`); throw new Error(`Failed to update process: ${e}`);
} }
@ -532,7 +532,7 @@ export default class Services {
// Create prd update for current process and update // Create prd update for current process and update
public createPrdUpdate(processId: string, stateId: string): ApiReturn { public createPrdUpdate(processId: string, stateId: string): ApiReturn {
try { try {
return this.sdkClient.create_update_message(processId, stateId); return this.sdkClient.create_update_message(process, stateId, this.getAllMembers());
} catch (e) { } catch (e) {
throw new Error(`Failed to create prd update: ${e}`); throw new Error(`Failed to create prd update: ${e}`);
} }
@ -544,7 +544,7 @@ export default class Services {
} }
try { try {
return this.sdkClient.create_response_prd(this.currentProcess, pcdMerkleRoot); return this.sdkClient.create_response_prd(process, pcdMerkleRoot, this.getAllMembers());
} catch (e) { } catch (e) {
throw e; throw e;
} }
@ -556,7 +556,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 {
return this.sdkClient.validate_state(process, stateId); return this.sdkClient.validate_state(process, stateId, this.getAllMembers());
} catch (e) { } catch (e) {
throw new Error(`Failed to create prd response: ${e}`); throw new Error(`Failed to create prd response: ${e}`);
} }
@ -606,9 +606,10 @@ export default class Services {
} }
async parseCipher(message: string) { async parseCipher(message: string) {
const membersList = this.getAllMembers();
try { try {
// console.log('parsing new cipher'); // console.log('parsing new cipher');
const apiReturn = this.sdkClient.parse_cipher(message); const apiReturn = this.sdkClient.parse_cipher(message, membersList);
console.log('🚀 ~ Services ~ parseCipher ~ apiReturn:', apiReturn); console.log('🚀 ~ Services ~ parseCipher ~ apiReturn:', apiReturn);
await this.handleApiReturn(apiReturn); await this.handleApiReturn(apiReturn);
@ -625,8 +626,9 @@ export default class Services {
} }
async parseNewTx(tx: string) { async parseNewTx(tx: string) {
const membersList = this.getAllMembers();
try { try {
const parsedTx = this.sdkClient.parse_new_tx(tx, 0); const parsedTx = this.sdkClient.parse_new_tx(tx, 0, membersList);
if (parsedTx) { if (parsedTx) {
try { try {
await this.handleApiReturn(parsedTx); await this.handleApiReturn(parsedTx);
@ -1433,8 +1435,9 @@ export default class Services {
public async requestDataFromPeers(processId: string, stateIds: string[], roles: Record<string, RoleDefinition>[]) { public async requestDataFromPeers(processId: string, stateIds: string[], roles: Record<string, RoleDefinition>[]) {
console.log('Requesting data from peers'); console.log('Requesting data from peers');
console.log(roles); console.log(roles);
const membersList = this.getAllMembers();
try { try {
const res = this.sdkClient.request_data(processId, stateIds, roles); const res = this.sdkClient.request_data(processId, stateIds, roles, membersList);
await this.handleApiReturn(res); await this.handleApiReturn(res);
} catch (e) { } catch (e) {
console.error(e); console.error(e);