From 4d2a2c5054271b43099a178835f4eff64640c0b6 Mon Sep 17 00:00:00 2001 From: Enrique A Date: Thu, 9 Jan 2025 11:04:08 -0300 Subject: [PATCH] Upgrade to 1.4.1 --- CHANGELOG.md | 4 ++++ src/modules/trezor.module.ts | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c9daf6..3510727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.4.1](https://github.com/Creit-Tech/Stellar-Wallets-Kit/compare/v1.4.0...v1.4.1) (2025-01-09) +### Fix +- Make the Trezor module to work with Webpack projects + ### [1.4.0](https://github.com/Creit-Tech/Stellar-Wallets-Kit/compare/v1.3.0...v1.4.0) (2024-12-20) ### Add - Add Trezor wallets support diff --git a/src/modules/trezor.module.ts b/src/modules/trezor.module.ts index 8c4160b..7743e2c 100644 --- a/src/modules/trezor.module.ts +++ b/src/modules/trezor.module.ts @@ -19,6 +19,9 @@ import { StellarSelectorModal } from '../components/selector-modal/stellar-selec export const TREZOR_ID = 'TREZOR'; export class TrezorModule implements ModuleInterface { + TrezorConnect: typeof TrezorConnect = + 'default' in TrezorConnect ? (TrezorConnect.default as typeof TrezorConnect) : TrezorConnect; + private _isAvailable: boolean = false; moduleType: ModuleType = ModuleType.HW_WALLET; @@ -29,7 +32,7 @@ export class TrezorModule implements ModuleInterface { productIcon: string = 'https://stellar.creit.tech/wallet-icons/trezor.png'; constructor(params: ITrezorModuleParams) { - TrezorConnect.init({ + this.TrezorConnect.init({ manifest: { appUrl: params.appUrl, email: params.email, @@ -74,7 +77,7 @@ export class TrezorModule implements ModuleInterface { const result = await this.openAccountSelector(); return { address: result.publicKey }; } else { - const result = await TrezorConnect.stellarGetAddress({ path: mnemonicPath, showOnTrezor: false }); + const result = await this.TrezorConnect.stellarGetAddress({ path: mnemonicPath, showOnTrezor: false }); if (!result.success) { throw parseError(new Error(result.payload.error)); } @@ -99,7 +102,7 @@ export class TrezorModule implements ModuleInterface { showOnTrezor: false, })); - const result = await TrezorConnect.stellarGetAddress({ bundle }); + const result = await this.TrezorConnect.stellarGetAddress({ bundle }); if (!result.success) { throw parseError(new Error(result.payload.error)); } @@ -177,7 +180,7 @@ export class TrezorModule implements ModuleInterface { let account: string; if (opts?.path) { mnemonicPath = opts.path; - const result = await TrezorConnect.stellarGetAddress({ path: mnemonicPath, showOnTrezor: false }); + const result = await this.TrezorConnect.stellarGetAddress({ path: mnemonicPath, showOnTrezor: false }); if (!result.success) { throw new Error(result.payload.error); } @@ -192,7 +195,7 @@ export class TrezorModule implements ModuleInterface { mnemonicPath = await firstValueFrom(mnemonicPath$); if (!mnemonicPath) throw parseError(new Error('There is no path available, please call the `getAddress` method first.')); - const result = await TrezorConnect.stellarGetAddress({ path: mnemonicPath, showOnTrezor: false }); + const result = await this.TrezorConnect.stellarGetAddress({ path: mnemonicPath, showOnTrezor: false }); if (!result.success) { throw new Error(result.payload.error); } @@ -204,7 +207,7 @@ export class TrezorModule implements ModuleInterface { const tx: Transaction = new Transaction(xdr, network); const parsedTx = transformTransaction(mnemonicPath, tx); - const result = await TrezorConnect.stellarSignTransaction(parsedTx); + const result = await this.TrezorConnect.stellarSignTransaction(parsedTx); if (!result.success) { throw parseError(new Error(result.payload.error));