Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed Jul 4, 2023
1 parent 2f53b6f commit a0e28d0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/js/src/switchToPos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ async function doSwitchToPos(wsUrl: string, sudoKeyUri: string): Promise<void> {
.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);
Expand All @@ -127,6 +130,7 @@ async function doSwitchToPos(wsUrl: string, sudoKeyUri: string): Promise<void> {
}
});
});
console.log('switchToPos finished');
} finally {
await api.disconnect();
}
Expand All @@ -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);
});
},
);

0 comments on commit a0e28d0

Please sign in to comment.