Skip to content

Commit

Permalink
Rename files to match main exported interface
Browse files Browse the repository at this point in the history
The convention is such that if a file's main purpose is to define a
interface/type by a class or factory function, then the file name
should match the name of that interface.

So, we remove "make" from file names, and we make some changes to
interface type names to match the file name.
  • Loading branch information
samholmes committed Apr 8, 2024
1 parent d089927 commit 1e3d9d9
Show file tree
Hide file tree
Showing 47 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/bch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/bitcoincash'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/bsv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/bitcoinsv'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/btc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/bitcoin'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
EdgeWalletInfo
} from 'edge-core-js/types'

import { makeUtxoEngine } from '../utxobased/engine/makeUtxoEngine'
import { asUtxoUserSettings } from '../utxobased/engine/types'
import { makeCurrencyTools } from './makeCurrencyTools'
import { makeEngineEmitter } from './makeEngineEmitter'
import { makePluginState } from './pluginState'
import { makeUtxoEngine } from '../utxobased/engine/UtxoEngine'
import { makeCurrencyTools } from './CurrencyTools'
import { makeEngineEmitter } from './EngineEmitter'
import { makePluginState } from './PluginState'
import { EngineConfig, PluginInfo } from './types'

export function makeCurrencyPlugin(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from 'edge-core-js/types'
import { EventEmitter } from 'events'

import { SubscribeAddressResponse } from '../utxobased/network/BlockBookAPI'
import { SubscribeAddressResponse } from '../utxobased/network/blockbookApi'

export declare interface EngineEmitter {
emit: ((
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EdgeLog } from 'edge-core-js/types'
import { makeMemlet } from 'memlet'

import AwaitLock from '../utxobased/engine/await-lock'
import { EngineEmitter, EngineEvent } from './makeEngineEmitter'
import { EngineEmitter, EngineEvent } from './EngineEmitter'
import { asLocalWalletMetadata, LocalWalletMetadata } from './types'
import { removeItem } from './utils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { Disklet } from 'disklet'
import { EdgeIo, EdgeLog } from 'edge-core-js/types'
import { makeMemlet } from 'memlet'

import { UtxoEngineState } from '../utxobased/engine/makeUtxoEngineState'
import { UtxoUserSettings } from '../utxobased/engine/types'
import { UtxoEngineState } from '../utxobased/engine/UtxoEngineState'
import {
asServerCache,
ServerCache,
ServerList,
ServerScores
} from './serverScores'
} from './ServerScores'

// Info server endpoint to getting ServerListInfo data
const serverListInfoUrl = 'https://info1.edge.app/v1/blockBook/'
// The filename for ServerInfoCache data (see serverScores.ts)
// Perhaps this should be in serverScores.ts file, but that'll take some refactoring
// The filename for ServerInfoCache data (see ServerScores.ts)
// Perhaps this should be in ServerScores.ts file, but that'll take some refactoring
const SERVER_CACHE_FILE = 'serverCache.json'

// ServerListInfo data structure from info server and saved to disk
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/common/plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import * as wif from 'wif'
import { asIUTXO, IProcessorTransaction, IUTXO } from '../utxobased/db/types'
import { ScriptTemplates } from '../utxobased/info/scriptTemplates/types'
import { UtxoPicker } from '../utxobased/keymanager/utxopicker'
import { EngineEmitter } from './makeEngineEmitter'
import { PluginState } from './pluginState'
import { EngineEmitter } from './EngineEmitter'
import { PluginState } from './PluginState'

export type CurrencyFormat = ReturnType<typeof asCurrencyFormat>
export const asCurrencyFormat = asValue('bip32', 'bip44', 'bip49', 'bip84')
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/common/utxobased/db/Models/ProcessorTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import BN from 'bn.js'
import { EdgeTransaction, JsonObject } from 'edge-core-js/types'

import { PluginInfo } from '../../../plugin/types'
import { UTXOPluginWalletTools } from '../../engine/makeUtxoWalletTools'
import { UtxoTxOtherParams } from '../../engine/types'
import { Processor } from '../makeProcessor'
import { UtxoWalletTools } from '../../engine/UtxoWalletTools'
import { Processor } from '../Processor'
import { IProcessorTransaction } from '../types'

export const fromEdgeTransaction = (
Expand Down Expand Up @@ -54,7 +54,7 @@ export const fromEdgeTransaction = (
interface ToEdgeTransactionArgs {
walletId: string
tx: IProcessorTransaction
walletTools: UTXOPluginWalletTools
walletTools: UtxoWalletTools
processor: Processor
pluginInfo: PluginInfo
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { makeMemlet } from 'memlet'

import { unixTime } from '../../../util/unixTime'
import { AddressPath, ChangePath } from '../../plugin/types'
import { makeBaselets } from './makeBaselets'
import { makeBaselets } from './Baselets'
import { addressPathToPrefix, TxIdByDate } from './Models/baselet'
import {
IAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/common/utxobased/db/util/utxo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
BIP43PurposeTypeEnum,
ScriptTypeEnum
} from '../../keymanager/keymanager'
import { Processor } from '../makeProcessor'
import { Processor } from '../Processor'
import { IProcessorTransaction, IUTXO } from '../types'

export const utxoFromProcessorTransactionInput = async (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { EdgeLog, EdgeTransaction } from 'edge-core-js/types'
import { parse } from 'uri-js'

import { EngineEmitter, EngineEvent } from '../../plugin/makeEngineEmitter'
import { PluginState } from '../../plugin/pluginState'
import { EngineEmitter, EngineEvent } from '../../plugin/EngineEmitter'
import { PluginState } from '../../plugin/PluginState'
import { PluginInfo } from '../../plugin/types'
import { removeItem } from '../../plugin/utils'
import { SafeWalletInfo } from '../keymanager/cleaners'
import { BlockBook, makeBlockBook } from '../network/BlockBook'
import { SubscribeAddressResponse } from '../network/BlockBookAPI'
import { SubscribeAddressResponse } from '../network/blockbookApi'
import Deferred from '../network/Deferred'
import { SocketEmitter, SocketEvent } from '../network/MakeSocketEmitter'
import { WsTask } from '../network/Socket'
import { SocketEmitter, SocketEvent } from '../network/SocketEmitter'
import { pushUpdate, removeIdFromQueue } from '../network/socketQueue'
import { MAX_CONNECTIONS, NEW_CONNECTIONS } from './constants'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import {
import { filterUndefined } from '../../../util/filterUndefined'
import { unixTime } from '../../../util/unixTime'
import { makeFees } from '../../fees/makeFees'
import { EngineEmitter, EngineEvent } from '../../plugin/makeEngineEmitter'
import { makeMetadata } from '../../plugin/makeMetadata'
import { EngineEmitter, EngineEvent } from '../../plugin/EngineEmitter'
import { makeMetadata } from '../../plugin/Metadata'
import { EngineConfig, TxOptions } from '../../plugin/types'
import { upgradeMemos } from '../../upgradeMemos'
import { makeProcessor } from '../db/makeProcessor'
import {
fromEdgeTransaction,
toEdgeTransaction
} from '../db/Models/ProcessorTransaction'
import { makeProcessor } from '../db/Processor'
import { IProcessorTransaction, IUTXO } from '../db/types'
import { utxoFromProcessorTransactionInput } from '../db/util/utxo'
import {
Expand All @@ -47,8 +47,6 @@ import {
} from '../keymanager/keymanager'
import { asMaybeInsufficientFundsErrorPlus } from '../keymanager/types'
import { transactionSizeFromHex } from '../keymanager/utxopicker/utils'
import { makeUtxoEngineState, transactionChanged } from './makeUtxoEngineState'
import { makeUtxoWalletTools } from './makeUtxoWalletTools'
import { createPayment, getPaymentDetails, sendPayment } from './paymentRequest'
import {
asUtxoSignMessageOtherParams,
Expand All @@ -63,6 +61,8 @@ import {
pathToPurposeType,
sumUtxos
} from './utils'
import { makeUtxoEngineState, transactionChanged } from './UtxoEngineState'
import { makeUtxoWalletTools } from './UtxoWalletTools'

export async function makeUtxoEngine(
config: EngineConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
EdgeTransaction
} from 'edge-core-js/types'

import { EngineEmitter, EngineEvent } from '../../plugin/makeEngineEmitter'
import { PluginState } from '../../plugin/pluginState'
import { EngineEmitter, EngineEvent } from '../../plugin/EngineEmitter'
import { PluginState } from '../../plugin/PluginState'
import {
AddressPath,
ChangePath,
Expand All @@ -18,8 +18,8 @@ import {
PluginInfo
} from '../../plugin/types'
import { removeItem } from '../../plugin/utils'
import { Processor } from '../db/makeProcessor'
import { toEdgeTransaction } from '../db/Models/ProcessorTransaction'
import { Processor } from '../db/Processor'
import {
IAddress,
IProcessorTransaction,
Expand All @@ -42,19 +42,19 @@ import {
transactionMessage,
transactionMessageSpecific,
TransactionResponse
} from '../network/BlockBookAPI'
} from '../network/blockbookApi'
import Deferred from '../network/Deferred'
import { WsTask } from '../network/Socket'
import AwaitLock from './await-lock'
import { BLOCKBOOK_TXS_PER_PAGE, CACHE_THROTTLE } from './constants'
import { makeServerStates, ServerStates } from './makeServerStates'
import { UTXOPluginWalletTools } from './makeUtxoWalletTools'
import { makeServerStates, ServerStates } from './ServerStates'
import {
getFormatSupportedBranches,
getScriptTypeFromPurposeType,
pathToPurposeType,
validScriptPubkeyFromAddress
} from './utils'
import { UtxoWalletTools } from './UtxoWalletTools'

export interface UtxoEngineState {
processedPercent: number
Expand Down Expand Up @@ -86,7 +86,7 @@ export interface UtxoEngineState {
}

export interface UtxoEngineStateConfig extends EngineConfig {
walletTools: UTXOPluginWalletTools
walletTools: UtxoWalletTools
walletInfo: SafeWalletInfo
processor: Processor
}
Expand Down Expand Up @@ -513,7 +513,7 @@ export function makeUtxoEngineState(
interface CommonArgs {
pluginInfo: PluginInfo
walletInfo: SafeWalletInfo
walletTools: UTXOPluginWalletTools
walletTools: UtxoWalletTools
processor: Processor
emitter: EngineEmitter
taskCache: TaskCache
Expand Down Expand Up @@ -686,7 +686,7 @@ interface TransactionChangedArgs {
walletId: string
tx: IProcessorTransaction
emitter: EngineEmitter
walletTools: UTXOPluginWalletTools
walletTools: UtxoWalletTools
pluginInfo: PluginInfo
processor: Processor
}
Expand Down Expand Up @@ -1079,7 +1079,7 @@ const updateTransactions = (
}

interface DeriveScriptAddressArgs {
walletTools: UTXOPluginWalletTools
walletTools: UtxoWalletTools
engineInfo: EngineInfo
processor: Processor
format: CurrencyFormat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface WalletToolsConfig {
publicKey: PublicKey
}

export interface UTXOPluginWalletTools {
export interface UtxoWalletTools {
getPubkey: (args: AddressPath) => string

getScriptPubkey: (args: AddressPath) => ScriptPubkeyReturn
Expand Down Expand Up @@ -96,14 +96,14 @@ interface SignMessageArgs {

export function makeUtxoWalletTools(
config: WalletToolsConfig
): UTXOPluginWalletTools {
): UtxoWalletTools {
const { pluginInfo, publicKey } = config
const { engineInfo } = pluginInfo
const { name: coin } = pluginInfo.coinInfo

const xpubKeys = publicKey.publicKeys

const fns: UTXOPluginWalletTools = {
const fns: UtxoWalletTools = {
getPubkey(args: AddressPath): string {
if (xpubKeys[args.format] == null) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/common/utxobased/engine/util/getOwnUtxosFromTx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EngineInfo } from '../../../plugin/types'
import { Processor } from '../../db/makeProcessor'
import { Processor } from '../../db/Processor'
import { IProcessorTransaction, IUTXO } from '../../db/types'
import { BIP43PurposeTypeEnum } from '../../keymanager/keymanager'
import { getScriptTypeFromPurposeType, pathToPurposeType } from '../utils'
Expand Down
6 changes: 3 additions & 3 deletions src/common/utxobased/network/BlockBook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Cleaner } from 'cleaners'
import { EdgeLog, EdgeTransaction } from 'edge-core-js/types'

import { EngineEmitter, EngineEvent } from '../../plugin/makeEngineEmitter'
import { EngineEmitter, EngineEvent } from '../../plugin/EngineEmitter'
import {
addressMessage,
AddressResponse,
Expand All @@ -20,10 +20,10 @@ import {
SubscribeNewBlockResponse,
transactionMessage,
TransactionResponse
} from './BlockBookAPI'
} from './blockbookApi'
import Deferred from './Deferred'
import { SocketEmitter } from './MakeSocketEmitter'
import { makeSocket, OnQueueSpaceCB } from './Socket'
import { SocketEmitter } from './SocketEmitter'

export type WatchAddressesCB = (
response: SubscribeAddressResponse
Expand Down
2 changes: 1 addition & 1 deletion src/common/utxobased/network/Socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { EdgeLog } from 'edge-core-js/types'

import { removeItem } from '../../plugin/utils'
import Deferred from './Deferred'
import { SocketEmitter, SocketEvent } from './MakeSocketEmitter'
import { setupWS } from './nodejsWS'
import { SocketEmitter, SocketEvent } from './SocketEmitter'
import { pushUpdate, removeIdFromQueue } from './socketQueue'
import { InnerSocket, InnerSocketCallbacks, ReadyState } from './types'
import { setupBrowser } from './windowWS'
Expand Down
2 changes: 1 addition & 1 deletion src/firo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/zcoin'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/ftc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/feathercoin'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCorePlugins } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { all } from './common/utxobased/info/all'

const plugins: EdgeCorePlugins = {}
Expand Down
2 changes: 1 addition & 1 deletion src/ltc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/litecoin'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/tbch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/bitcoincashtestnet'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/tbtc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/bitcointestnet'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
2 changes: 1 addition & 1 deletion src/tbtg.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EdgeCorePluginOptions, EdgeCurrencyPlugin } from 'edge-core-js/types'

import { makeCurrencyPlugin } from './common/plugin/makeCurrencyPlugin'
import { makeCurrencyPlugin } from './common/plugin/CurrencyPlugin'
import { info } from './common/utxobased/info/bitcoingoldtestnet'

const plugin = (options: EdgeCorePluginOptions): EdgeCurrencyPlugin =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { before, describe, it } from 'mocha'

import edgeCorePlugins from '../../../src/index'
import { testLog } from '../../util/testLog'
import { fixtures } from './currencyPlugin.fixtures/index'
import { fixtures } from './CurrencyPlugin.fixtures/index'

describe('currencyPlugins.spec', () => {
for (const fixture of fixtures) {
Expand Down
Loading

0 comments on commit 1e3d9d9

Please sign in to comment.