Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wolverineks committed Feb 10, 2023
1 parent 9e3b10f commit fbc1ec8
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/yoroi-wallets/cardano/CardanoWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../../legacy/networks'
import {IsLockedError, nonblockingSynchronize, synchronize} from '../../legacy/promise'
import type {WalletMeta} from '../../legacy/state'
import {makeMemosManager, MemosManager} from '../memosManager'
import {makeMemosManager, MemosManager} from '../memos'
import {YoroiStorage} from '../storage'
import type {
AccountStateResponse,
Expand Down
1 change: 1 addition & 0 deletions src/yoroi-wallets/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './cardano'
export * from './encryption/encryption'
export * from './hwWallet'
export * from './utils'
export * from './walletManager'
1 change: 1 addition & 0 deletions src/yoroi-wallets/memos/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './memosManager'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AsyncStorage from '@react-native-async-storage/async-storage'

import {storage as rootStorage} from '../storage'
import {makeMemosManager} from './memosManager'
import {storage as rootStorage} from './storage'

describe('memos manager', () => {
beforeEach(() => AsyncStorage.clear())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {YoroiStorage} from './storage'
import * as parsing from './utils/parsing'
import {YoroiStorage} from '../storage'
import {isString, parseString} from '../utils/parsing'

export const makeMemosManager = async (storage: YoroiStorage) => {
const getMemos = () =>
storage
.getAllKeys()
.then((keys) => storage.multiGet(keys, parsing.parseString))
.then((keys) => storage.multiGet(keys, parseString))
.then(filterCorruptEntries)
.then((tuples) => Object.fromEntries(tuples))

Expand Down Expand Up @@ -34,7 +34,7 @@ export const makeMemosManager = async (storage: YoroiStorage) => {
}

const filterCorruptEntries = (tuples: [string, string | undefined][]) => {
return tuples.filter((tuple): tuple is [string, string] => parsing.isString(tuple[1]))
return tuples.filter((tuple): tuple is [string, string] => isString(tuple[1]))
}

export type MemosManager = Awaited<ReturnType<typeof makeMemosManager>>
6 changes: 6 additions & 0 deletions src/yoroi-wallets/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './amountUtils'
export * from './parsing'
export * from './timeUtils'
export * from './utils'
export * from './validators'
export * from './versioning'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Quantity, YoroiAmount, YoroiAmounts, YoroiEntries, YoroiEntry} from './types'
import {RawUtxo} from './types/other'
import {Amounts, Entries, Quantities, Utxos} from './utils'
import {Quantity, YoroiAmount, YoroiAmounts, YoroiEntries, YoroiEntry} from '../types'
import {RawUtxo} from '../types/other'
import {Amounts, Entries, Quantities, Utxos} from '.'

describe('Quantities', () => {
it('sum', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BigNumber from 'bignumber.js'

import {Quantity, TokenId, YoroiAmount, YoroiAmounts, YoroiEntries, YoroiEntry} from './types'
import {RawUtxo} from './types/other'
import {Quantity, RawUtxo, TokenId, YoroiAmount, YoroiAmounts, YoroiEntries, YoroiEntry} from '../types'

export const Entries = {
first: (entries: YoroiEntries): YoroiEntry => {
Expand Down
1 change: 1 addition & 0 deletions src/yoroi-wallets/walletManager/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './walletManager'
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-unused-labels */
import AsyncStorage from '@react-native-async-storage/async-storage'

import {isYoroiWallet} from './cardano'
import {parseSafe} from './utils/parsing'
import {WalletManager} from './walletManager'
import {isYoroiWallet} from '../cardano'
import {parseSafe} from '../utils/parsing'
import {WalletManager} from '.'

describe('walletMananger', () => {
beforeEach(() => AsyncStorage.clear())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import ExtendableError from 'es6-error'
import uuid from 'uuid'

import {makeWalletEncryptedStorage} from '../auth'
import {Keychain} from '../auth/Keychain'
import type {HWDeviceInfo} from '../legacy/ledgerUtils'
import {Logger} from '../legacy/logging'
import type {WalletMeta} from '../legacy/state'
import {isWalletMeta, migrateWalletMetas, parseWalletMeta} from '../Storage/migrations/walletMeta'
import {CardanoWallet, isYoroiWallet, NetworkId, WalletImplementationId, YoroiWallet} from './cardano'
import {storage, YoroiStorage} from './storage'
import {WALLET_IMPLEMENTATION_REGISTRY} from './types/other'
import {parseSafe} from './utils/parsing'
import {makeWalletEncryptedStorage} from '../../auth'
import {Keychain} from '../../auth/Keychain'
import {HWDeviceInfo} from '../../legacy/ledgerUtils'
import {Logger} from '../../legacy/logging'
import {WalletMeta} from '../../legacy/state'
import {isWalletMeta, migrateWalletMetas, parseWalletMeta} from '../../Storage/migrations/walletMeta'
import {CardanoWallet, isYoroiWallet, NetworkId, WalletImplementationId, YoroiWallet} from '../cardano'
import {storage, YoroiStorage} from '../storage'
import {WALLET_IMPLEMENTATION_REGISTRY} from '../types'
import {parseSafe} from '../utils'

export class WalletClosed extends ExtendableError {}

Expand Down

0 comments on commit fbc1ec8

Please sign in to comment.