Skip to content

Commit

Permalink
[LW-10570] Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomislavhoracek committed May 28, 2024
1 parent ab4905a commit a202af5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions source/renderer/app/stores/HardwareWalletsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default class HardwareWalletsStore extends Store {
@observable
transportDevice: TransportDevice | null | undefined = null;
@observable
signedTransaction: string | null | undefined = null;
signedTx: string | null | undefined = null;
@observable
isTransactionPending = false;
@observable
Expand Down Expand Up @@ -2652,7 +2652,7 @@ export default class HardwareWalletsStore extends Store {
const signedTx = await getTxCBOR(txBody, txWitnesses, txAuxiliaryData);
runInAction('HardwareWalletsStore:: set Transaction verified', () => {
this.hwDeviceStatus = HwDeviceStatuses.VERIFYING_TRANSACTION_SUCCEEDED;
this.signedTx = signedTx; // TODO - change flag name
this.signedTx = signedTx;
this.activeDevicePath = null;
});
} catch (error) {
Expand Down
19 changes: 14 additions & 5 deletions source/renderer/app/utils/dataSerialization.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// addr_test1qrujg5s2ws0ntmrgykm8ecfwx5n3xgt4zc0hzpg5ek5l78u8558mf5hyh6j38p9zmdmrdphndlls6p3jq3f702ms2awsj5gd95

import { map } from 'lodash';
import blakejs from 'blakejs';
import { encode } from 'borc';
import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
Expand All @@ -10,6 +9,7 @@ import {
groupTokensByPolicyId,
} from './hardwareWalletUtils';

import type { AddressStyle } from '../api/addresses/types';
import type {
CoinSelectionInput,
CoinSelectionWithdrawal,
Expand Down Expand Up @@ -167,7 +167,7 @@ export const toTxOutputAssets = (assets: CoinSelectionAssetsType) => {
const assetMap = new Map<Buffer, number>();

// @ts-ignore ts-migrate(2769) FIXME: No overload matches this call.
_.map(tokens, (token) => {
map(tokens, (token) => {
// @ts-ignore ts-migrate(2339) FIXME: Property 'assetName' does not exist on type 'unkno... Remove this comment to see the full error message
assetMap.set(Buffer.from(token.assetName, 'hex'), token.quantity);
});
Expand Down Expand Up @@ -217,7 +217,7 @@ export const toTxWithdrawal = (withdrawals: Array<CoinSelectionWithdrawal>) => {
function encodeCBOR(encoder: any) {
const withdrawalMap = new Map();

_.map(withdrawals, (withdrawal) => {
map(withdrawals, (withdrawal) => {
const rewardAccount = utils.bech32_decodeAddress(withdrawal.stakeAddress);
const coin = withdrawal.amount.quantity;
withdrawalMap.set(rewardAccount, coin);
Expand Down Expand Up @@ -340,7 +340,16 @@ export const toTxBody = ({
withdrawals,
txAuxiliaryData,
txAuxiliaryDataHash,
}: TxBodyType) => {
}: {
txInputs: Array<TxInputType>;
txOutputs: Array<TxOutputType>;
txAuxiliaryData?: TxAuxiliaryData;
txAuxiliaryDataHash?: string;
fee: number;
ttl: number;
certificates: Array<Certificate | null | undefined>;
withdrawals: TxWithdrawalsType | null | undefined;
}) => {
const txFee = toTxFee(fee);
const txTtl = toTxTtl(ttl);
const txCerts = certificates;
Expand Down
1 change: 1 addition & 0 deletions source/renderer/app/utils/hardwareWalletUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash';
import { bech32 } from 'bech32';
import { str_to_path } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
import { HexString } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/types/internal';
import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
import { deriveXpubChannel } from '../ipc/getHardwareWalletChannel';
import { HARDENED } from '../config/hardwareWalletsConfig';
Expand Down
1 change: 1 addition & 0 deletions source/renderer/app/utils/shelleyLedger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
CoinSelectionWithdrawal,
CoinSelectionAssetsType,
} from '../api/transactions/types';
import { TxAuxiliaryData } from './dataSerialization';

export const toTokenBundle = (assets: CoinSelectionAssetsType) => {
const tokenObject = groupTokensByPolicyId(assets);
Expand Down

0 comments on commit a202af5

Please sign in to comment.