@@ -12,7 +12,6 @@ import { HwDeviceStatuses } from '../domains/Wallet';
1212import WalletAddress from '../domains/WalletAddress' ;
1313import { toJS } from '../../../common/utils/helper' ;
1414import {
15- HW_SHELLEY_CONFIG,
1615 SHELLEY_PURPOSE_INDEX ,
1716 ADA_COIN_TYPE ,
1817 MINIMAL_TREZOR_FIRMWARE_VERSION ,
@@ -21,6 +20,7 @@ import {
2120 isHardwareWalletSupportEnabled ,
2221 isTrezorEnabled ,
2322 isLedgerEnabled ,
23+ getHardwareWalletsNetworkConfig ,
2424} from '../config/hardwareWalletsConfig' ;
2525import { TIME_TO_LIVE } from '../config/txnsConfig' ;
2626import {
@@ -160,6 +160,9 @@ const useCardanoAppInterval = (
160160 addressVerification
161161 ) ;
162162
163+ const { network, isDev } = global . environment ;
164+ const hardwareWalletsNetworkConfig = getHardwareWalletsNetworkConfig ( network ) ;
165+
163166export default class HardwareWalletsStore extends Store {
164167 @observable selectCoinsRequest : Request < CoinSelectionsResponse > = new Request (
165168 this . api . ada . selectCoins
@@ -262,7 +265,7 @@ export default class HardwareWalletsStore extends Store {
262265
263266 initLedger = async ( ) => {
264267 logger . debug (
265- `[HW-DEBUG] HWStore - initLedger() | isHardwareWalletSupportEnabled=${isHardwareWalletSupportEnabled} isLedgerEnabled=${isLedgerEnabled}`
268+ `[HW-DEBUG] HWStore - initLedger() | isHardwareWalletSupportEnabled=${ isHardwareWalletSupportEnabled . toString ( ) } isLedgerEnabled=${ isLedgerEnabled . toString ( ) } `
266269 ) ;
267270 if ( isHardwareWalletSupportEnabled && isLedgerEnabled ) {
268271 logger . debug ( '[HW-DEBUG] HWStore - start ledger' ) ;
@@ -1131,7 +1134,6 @@ export default class HardwareWalletsStore extends Store {
11311134 }) => {
11321135 logger.debug('[HW-DEBUG] - VERIFY Address');
11331136 const { address, path, isTrezor } = params;
1134- const { isMainnet } = this.environment;
11351137
11361138 this.hwDeviceStatus = HwDeviceStatuses.VERIFYING_ADDRESS;
11371139 this.tempAddressToVerify = params;
@@ -1142,12 +1144,8 @@ export default class HardwareWalletsStore extends Store {
11421144 addressType: AddressType.BASE,
11431145 spendingPathStr: address.spendingPath,
11441146 stakingPathStr: ` $ { SHELLEY_PURPOSE_INDEX } '/ ${ADA_COIN_TYPE } '/ 0 '/ 2 / 0 `,
1145- networkId: isMainnet
1146- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.networkId
1147- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.networkId,
1148- protocolMagic: isMainnet
1149- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.protocolMagic
1150- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.protocolMagic,
1147+ networkId: hardwareWalletsNetworkConfig.networkId,
1148+ protocolMagic: hardwareWalletsNetworkConfig.protocolMagic,
11511149 });
11521150
11531151 if (derivedAddress === address.id) {
@@ -1239,7 +1237,6 @@ export default class HardwareWalletsStore extends Store {
12391237 }) => {
12401238 logger.debug('[HW-DEBUG] - SHOW Address');
12411239 const { address, path, isTrezor } = params;
1242- const { isMainnet } = this.environment;
12431240
12441241 try {
12451242 await showAddressChannel.request({
@@ -1248,12 +1245,8 @@ export default class HardwareWalletsStore extends Store {
12481245 addressType: AddressType.BASE,
12491246 spendingPathStr: address.spendingPath,
12501247 stakingPathStr: ` $ { SHELLEY_PURPOSE_INDEX } '/ ${ADA_COIN_TYPE } '/ 0 '/ 2 / 0 `,
1251- networkId: isMainnet
1252- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.networkId
1253- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.networkId,
1254- protocolMagic: isMainnet
1255- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.protocolMagic
1256- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.protocolMagic,
1248+ networkId: hardwareWalletsNetworkConfig.networkId,
1249+ protocolMagic: hardwareWalletsNetworkConfig.protocolMagic,
12571250 });
12581251 runInAction(
12591252 'HardwareWalletsStore:: Address show process finished',
@@ -1818,7 +1811,6 @@ export default class HardwareWalletsStore extends Store {
18181811 const fee = formattedAmountToLovelace(flatFee.toString());
18191812 const ttl = this._getTtl();
18201813 const absoluteSlotNumber = this._getAbsoluteSlotNumber();
1821- const { isMainnet } = this.environment;
18221814
18231815 try {
18241816 const signedTransaction = await signTransactionTrezorChannel.request({
@@ -1827,12 +1819,8 @@ export default class HardwareWalletsStore extends Store {
18271819 fee: fee.toString(),
18281820 ttl: ttl.toString(),
18291821 validityIntervalStartStr: absoluteSlotNumber.toString(),
1830- networkId: isMainnet
1831- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.networkId
1832- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.networkId,
1833- protocolMagic: isMainnet
1834- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.trezorProtocolMagic
1835- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.trezorProtocolMagic,
1822+ networkId: hardwareWalletsNetworkConfig.networkId,
1823+ protocolMagic: hardwareWalletsNetworkConfig.protocolMagic,
18361824 certificates: certificatesData,
18371825 withdrawals: withdrawalsData,
18381826 devicePath: recognizedDevicePath,
@@ -2061,7 +2049,6 @@ export default class HardwareWalletsStore extends Store {
20612049
20622050 const fee = formattedAmountToLovelace ( flatFee . toString ( ) ) ;
20632051 const ttl = this . _getTtl ( ) ;
2064- const { isMainnet } = this.environment;
20652052
20662053 let unsignedTxAuxiliaryData = null ;
20672054 if ( this . votingData ) {
@@ -2089,12 +2076,8 @@ export default class HardwareWalletsStore extends Store {
20892076 fee : fee . toString ( ) ,
20902077 ttl : ttl . toString ( ) ,
20912078 validityIntervalStartStr : null ,
2092- networkId: isMainnet
2093- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.networkId
2094- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.networkId,
2095- protocolMagic: isMainnet
2096- ? HW_SHELLEY_CONFIG.NETWORK.MAINNET.protocolMagic
2097- : HW_SHELLEY_CONFIG.NETWORK.TESTNET.protocolMagic,
2079+ networkId : hardwareWalletsNetworkConfig . networkId ,
2080+ protocolMagic : hardwareWalletsNetworkConfig . protocolMagic ,
20982081 certificates : certificatesData ,
20992082 withdrawals : withdrawalsData ,
21002083 signingMode : TransactionSigningMode . ORDINARY_TRANSACTION ,
@@ -2715,7 +2698,7 @@ export default class HardwareWalletsStore extends Store {
27152698
27162699 // For testing / development ONLY
27172700 _resetHardwareWallets = async ( ) => {
2718- if (global.environment. isDev) {
2701+ if ( isDev ) {
27192702 await Promise . all (
27202703 this . stores . wallets . all . map ( async ( wallet ) => {
27212704 if ( wallet . isHardwareWallet ) {
0 commit comments