diff --git a/scripts/js/src/switchToPos.ts b/scripts/js/src/switchToPos.ts index a06b8a6488..d91f6231d8 100644 --- a/scripts/js/src/switchToPos.ts +++ b/scripts/js/src/switchToPos.ts @@ -111,9 +111,12 @@ async function doSwitchToPos(wsUrl: string, sudoKeyUri: string): Promise { .sudoUncheckedWeight(callback, overrideWeight) .signAndSend(keyring, { nonce: -1 }, (result) => { const finish = (fn: () => void) => { + console.log('finish called'); unsubscribe .then((unsub) => { + console.log('unsubscribing'); unsub(); + console.log('unsubscribed'); fn(); }) .catch(reject); @@ -127,6 +130,7 @@ async function doSwitchToPos(wsUrl: string, sudoKeyUri: string): Promise { } }); }); + console.log('switchToPos finished'); } finally { await api.disconnect(); } @@ -142,9 +146,10 @@ const inputSudoKeyUri = process.argv[3]; const waitNBlocks = process.argv[4] ? parseInt(process.argv[4].trim(), 10) : 0; const preSwitch = waitNBlocks > 0 ? waitBlocks(inputWsUrl, waitNBlocks) : Promise.resolve(); -preSwitch - .then(() => doSwitchToPos(inputWsUrl, inputSudoKeyUri)) - .catch((reason) => { +preSwitch.then( + () => doSwitchToPos(inputWsUrl, inputSudoKeyUri), + (reason) => { console.error(reason); process.exit(1); - }); + }, +);