fix confirm breaking and not going to process page

This commit is contained in:
AnisHADJARAB 2024-10-17 12:39:42 +00:00
parent 3573b0d415
commit 65bfe1cd21

View File

@ -12,6 +12,7 @@ export default class Routing {
private currentPrd: any; private currentPrd: any;
private currentOutpoint?: string; private currentOutpoint?: string;
private constructor() {} private constructor() {}
private paired_addresses: string[] = [];
// Method to access the singleton instance of Services // Method to access the singleton instance of Services
public static async getInstance(): Promise<Routing> { public static async getInstance(): Promise<Routing> {
@ -51,9 +52,8 @@ export default class Routing {
// We take all the addresses except our own // We take all the addresses except our own
const local_address = this.sdkClient.get_address(); const local_address = this.sdkClient.get_address();
console.log("🚀 ~ Routing ~ openConfirmationModal ~ pcd:", pcd) console.log("🚀 ~ Routing ~ openConfirmationModal ~ pcd:", pcd)
let paired_addresses: string[] = [];
for (const address of members[0]['sp_addresses']) { for (const address of members[0]['sp_addresses']) {
if (address !== local_address) { paired_addresses.push(address) } if (address !== local_address) { this.paired_addresses.push(address) }
} }
let html = confirmationModalHtml; let html = confirmationModalHtml;
// html = html.replace('{{device1}}', members[0]['sp_addresses'][0]); // html = html.replace('{{device1}}', members[0]['sp_addresses'][0]);
@ -75,7 +75,7 @@ export default class Routing {
window.onclick = (event) => { window.onclick = (event) => {
const modal = document.getElementById('modal'); const modal = document.getElementById('modal');
if (event.target === modal) { if (event.target === modal) {
this.confirmPairing(paired_addresses); this.confirmPairing();
} }
} }
} }
@ -90,7 +90,7 @@ export default class Routing {
if (modal) modal.style.display = 'none'; if (modal) modal.style.display = 'none';
} }
async confirmPairing(paired_addresses: string[]) { async confirmPairing() {
const service = await Services.getInstance() const service = await Services.getInstance()
const modal = document.getElementById('modal') const modal = document.getElementById('modal')
// console.log("🚀 ~ Routing ~ confirm ~ prd:", prd) // console.log("🚀 ~ Routing ~ confirm ~ prd:", prd)
@ -100,7 +100,8 @@ export default class Routing {
const commitmentOutpoint = `${emptyTxid}:${U32_MAX}`; const commitmentOutpoint = `${emptyTxid}:${U32_MAX}`;
// We take the paired device(s) from the contract // We take the paired device(s) from the contract
this.sdkClient.pair_device(commitmentOutpoint, paired_addresses) this.sdkClient.pair_device(commitmentOutpoint, this.paired_addresses)
this.paired_addresses = []
service.injectProcessListPage(); service.injectProcessListPage();
} }