]> zoso.dev Git - libnemo.git/commitdiff
Pass postMessage as handler instead of calling it after ckd.
authorChris Duncan <chris@zoso.dev>
Mon, 11 Nov 2024 10:01:03 +0000 (02:01 -0800)
committerChris Duncan <chris@zoso.dev>
Mon, 11 Nov 2024 10:01:03 +0000 (02:01 -0800)
src/lib/ckd.ts

index 4da80fd378f794ad59ec0a67061250fa203d0d54..e7ae52e6e3230c9fc240b0a434ebcf28d12fe08c 100644 (file)
@@ -13,24 +13,23 @@ import type { Ledger } from './ledger.js'
 * @param {number} index - Index of the account
 * @returns {Promise<Account>}
 */
-onmessage = async (event) => {
+onmessage = (event) => {
        let result = null
        const { type, seed, index } = event.data
        switch (type) {
                case 'bip44': {
-                       result = await ckdBip44(seed, index)
+                       result = ckdBip44(seed, index).then(postMessage)
                        break
                }
                case 'blake2b': {
-                       result = await ckdBlake2b(seed, index)
+                       result = ckdBlake2b(seed, index).then(postMessage)
                        break
                }
                case 'ledger': {
-                       result = await ckdLedger(seed, index)
+                       result = ckdLedger(seed, index).then(postMessage)
                        break
                }
        }
-       postMessage(result)
 }
 
 /**