From 33a60ec3a0e61fa1d350f7452441dd52601b8c00 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 23 Nov 2025 02:37:26 -0800 Subject: [PATCH] Start adding initial pieces for Exodus support. --- src/lib/vault/vault-worker.ts | 6 +++--- src/lib/wallet/index.ts | 8 ++++---- src/lib/wallet/load.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/vault/vault-worker.ts b/src/lib/vault/vault-worker.ts index faa1ae9..02776b1 100644 --- a/src/lib/vault/vault-worker.ts +++ b/src/lib/vault/vault-worker.ts @@ -15,7 +15,7 @@ export class VaultWorker { #locked: boolean #timeout: number #timer: VaultTimer - #type?: 'BIP-44' | 'BLAKE2b' + #type?: 'BIP-44' | 'BLAKE2b' | 'Exodus' #seed?: ArrayBuffer #mnemonic?: ArrayBuffer #parentPort?: any @@ -181,7 +181,7 @@ export class VaultWorker { if (this.#seed == null) { throw new Error('Wallet seed not found') } - if (this.#type !== 'BIP-44' && this.#type !== 'BLAKE2b') { + if (this.#type !== 'BIP-44' && this.#type !== 'BLAKE2b' && this.#type !== 'Exodus') { throw new Error('Invalid wallet type') } if (typeof index !== 'number') { @@ -614,7 +614,7 @@ export class VaultWorker { // Algorithm used for wallet functions #parseType (action: string, data: { [key: string]: unknown }) { if (['create', 'load', 'unlock'].includes(action)) { - if (data.type !== 'BIP-44' && data.type !== 'BLAKE2b' && data.type !== 'Ledger') { + if (data.type !== 'BIP-44' && data.type !== 'BLAKE2b' && data.type !== 'Exodus' && data.type !== 'Ledger') { throw new TypeError(`Type is required to ${action} wallet`) } } else if (data.type !== undefined) { diff --git a/src/lib/wallet/index.ts b/src/lib/wallet/index.ts index d9a0cbf..fce75ba 100644 --- a/src/lib/wallet/index.ts +++ b/src/lib/wallet/index.ts @@ -23,7 +23,7 @@ import { _unopened } from './unopened' import { _update } from './update' import { _verify } from './verify' -export type WalletType = 'BIP-44' | 'BLAKE2b' | 'Ledger' +export type WalletType = 'BIP-44' | 'BLAKE2b' | 'Exodus' | 'Ledger' /** * Represents a wallet containing numerous Nano accounts derived from a single @@ -88,7 +88,7 @@ export class Wallet { * @param {string} seed - Used to derive child accounts * @returns Wallet in a locked state */ - static async load (type: 'BIP-44' | 'BLAKE2b', password: string, seed: string): Promise + static async load (type: 'BIP-44' | 'BLAKE2b' | 'Exodus', password: string, seed: string): Promise /** * Imports an existing HD wallet by using an entropy value generated using a * cryptographically strong pseudorandom number generator. @@ -99,7 +99,7 @@ export class Wallet { * @param {string} [mnemonicSalt] - Used to alter the seed derived from the mnemonic phrase * @returns Wallet in a locked state */ - static async load (type: 'BIP-44' | 'BLAKE2b', password: string, mnemonicPhrase: string, mnemonicSalt?: string): Promise + static async load (type: 'BIP-44' | 'BLAKE2b' | 'Exodus', password: string, mnemonicPhrase: string, mnemonicSalt?: string): Promise static async load (type: WalletType, password: string, secret: string, mnemonicSalt?: string): Promise { this.#isInternal = true const self = new this(type) @@ -149,7 +149,7 @@ export class Wallet { if (!(this.constructor as typeof Wallet).isInternal) { throw new Error(`Wallet cannot be instantiated directly. Use 'await Wallet.create()' instead.`) } - if (type !== 'BIP-44' && type !== 'BLAKE2b' && type !== 'Ledger') { + if (type !== 'BIP-44' && type !== 'BLAKE2b' && type !== 'Exodus' && type !== 'Ledger') { throw new TypeError('Invalid wallet type', { cause: type }) } this.#id = id ?? this.#id diff --git a/src/lib/wallet/load.ts b/src/lib/wallet/load.ts index fc73b83..3c92977 100644 --- a/src/lib/wallet/load.ts +++ b/src/lib/wallet/load.ts @@ -23,7 +23,7 @@ export async function _load (wallet: Wallet, vault: Vault, password: unknown, se throw new Error('Failed to initialize Ledger wallet', { cause: 'Browser is unsupported' }) } } else { - if (wallet.type !== 'BIP-44' && wallet.type !== 'BLAKE2b') { + if (wallet.type !== 'BIP-44' && wallet.type !== 'BLAKE2b' && wallet.type !== 'Exodus') { throw new TypeError('Invalid wallet type', { cause: wallet.type }) } if (typeof password !== 'string') { -- 2.47.3