From 5bbf0d33f51bc9ccdc1b2817d95bb751c51de26a Mon Sep 17 00:00:00 2001 From: Sosthene Date: Sat, 30 Nov 2024 23:28:51 +0100 Subject: [PATCH] Handle modified states --- src/services/service.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/services/service.ts b/src/services/service.ts index 097d6ad..baf3413 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -321,12 +321,24 @@ export default class Services { throw e; } - if (updatedProcess.modified_state || updatedProcess.new_state) { + if (updatedProcess.new_state) { 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 { + const apiReturn = this.sdkClient.evaluate_state(init_commitment, null, JSON.stringify(new_state)); + await this.handleApiReturn(apiReturn); + } catch (e) { + throw e + } } }