Handle diffs in apiReturn
This commit is contained in:
parent
93c2ea1d23
commit
d64efbd6a0
@ -307,30 +307,22 @@ export default class Services {
|
|||||||
// Save process to storage
|
// Save process to storage
|
||||||
try {
|
try {
|
||||||
await this.saveProcess(updatedProcess.commitment_tx, updatedProcess.current_process);
|
await this.saveProcess(updatedProcess.commitment_tx, updatedProcess.current_process);
|
||||||
await this.saveDiffs(updatedProcess.new_diffs);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((updatedProcess as any).new_state) {
|
if (updatedProcess.new_diffs.length != 0) {
|
||||||
this.currentProcess = updatedProcess.commitment_tx;
|
|
||||||
|
|
||||||
this.getUpdateProposals(this.currentProcess!);
|
|
||||||
|
|
||||||
await this.evaluatePendingUpdates();
|
|
||||||
} else if (updatedProcess.modified_state) {
|
|
||||||
// We added validation tokens
|
|
||||||
// We check if the state is now valid
|
|
||||||
// If enough validation tokens we shoot a commit msg to the relay
|
|
||||||
const [previous_state, new_state] = updatedProcess.modified_state;
|
|
||||||
const init_commitment = updatedProcess.commitment_tx;
|
|
||||||
try {
|
try {
|
||||||
const apiReturn = this.sdkClient.evaluate_state(init_commitment, null, JSON.stringify(new_state));
|
this.saveDiffs(updatedProcess.new_diffs);
|
||||||
await this.handleApiReturn(apiReturn);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updatedProcess.modified_state) {
|
||||||
|
// For now it can only mean we added a validation token to an existing state
|
||||||
|
// Not sure what action to take
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apiReturn.commit_to_send) {
|
if (apiReturn.commit_to_send) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user