Skip to content

Commit 353caca

Browse files
authored
chore: merge main into chore/inline-dependencies, resolve conflicts
1 parent cff98da commit 353caca

5 files changed

Lines changed: 196 additions & 231 deletions

File tree

package-lock.json

Lines changed: 2 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@
147147
"overrides": {
148148
"axios@<0.31.0": ">=0.31.0"
149149
}
150-
}
150+
}

src/tor/client.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ import { join } from 'path'
66
import { createLogger } from '../factories/logger-factory'
77
import { TorConfig } from '../@types/tor'
88

9-
109
const debug = createLogger('tor-client')
1110

1211
const getPrivateKeyFile = () => {
13-
return join(
14-
process.env.NOSTR_CONFIG_DIR ?? join(homedir(), '.nostr'),
15-
'v3_onion_private_key'
16-
)
12+
return join(process.env.NOSTR_CONFIG_DIR ?? join(homedir(), '.nostr'), 'v3_onion_private_key')
1713
}
1814

1915
export const createTorConfig = (): TorConfig => {
@@ -102,9 +98,9 @@ export const getTorClient = async () => {
10298
if (config.host !== undefined) {
10399
debug('connecting')
104100
client = new TorClient(config)
105-
try{
101+
try {
106102
await client.connect()
107-
}catch(_error){
103+
} catch (_error) {
108104
client = undefined
109105
}
110106
debug('connected')
@@ -115,16 +111,12 @@ export const getTorClient = async () => {
115111
}
116112
export const closeTorClient = async () => {
117113
if (client) {
118-
119114
await client.quit()
120115
client = undefined
121116
}
122117
}
123118

124-
export const addOnion = async (
125-
port: number,
126-
host?: string
127-
): Promise<string> => {
119+
export const addOnion = async (port: number, host?: string): Promise<string> => {
128120
let privateKey = null
129121
const path = getPrivateKeyFile()
130122

@@ -150,10 +142,10 @@ export const addOnion = async (
150142

151143
await writeFile(path, hiddenService.PrivateKey, 'utf8')
152144
return hiddenService.ServiceID!
153-
}else{
145+
} else {
154146
throw new Error(JSON.stringify(hiddenService))
155147
}
156-
}else{
148+
} else {
157149
throw new Error('not connect')
158150
}
159151
}

src/utils/transform.ts

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
import { always, applySpec, cond, equals, ifElse, is, isNil, multiply, path, pathSatisfies, pipe, prop, propSatisfies, T } from 'ramda'
1+
import {
2+
always,
3+
applySpec,
4+
cond,
5+
equals,
6+
ifElse,
7+
is,
8+
isNil,
9+
multiply,
10+
path,
11+
pathSatisfies,
12+
pipe,
13+
prop,
14+
propSatisfies,
15+
T,
16+
} from 'ramda'
217

318
import { Invoice, InvoiceStatus, InvoiceUnit } from '../@types/invoice'
419
import { User } from '../@types/user'
@@ -144,21 +159,9 @@ export const fromZebedeeInvoice = applySpec<Invoice>({
144159
description: prop('description'),
145160
unit: prop('unit'),
146161
status: prop('status'),
147-
expiresAt: ifElse(
148-
propSatisfies(is(String), 'expiresAt'),
149-
pipe(prop('expiresAt'), toDate),
150-
always(null),
151-
),
152-
confirmedAt: ifElse(
153-
propSatisfies(is(String), 'confirmedAt'),
154-
pipe(prop('confirmedAt'), toDate),
155-
always(null),
156-
),
157-
createdAt: ifElse(
158-
propSatisfies(is(String), 'createdAt'),
159-
pipe(prop('createdAt'), toDate),
160-
always(null),
161-
),
162+
expiresAt: ifElse(propSatisfies(is(String), 'expiresAt'), pipe(prop('expiresAt'), toDate), always(null)),
163+
confirmedAt: ifElse(propSatisfies(is(String), 'confirmedAt'), pipe(prop('confirmedAt'), toDate), always(null)),
164+
createdAt: ifElse(propSatisfies(is(String), 'createdAt'), pipe(prop('createdAt'), toDate), always(null)),
162165
rawResponse: toJSON,
163166
})
164167

@@ -184,21 +187,13 @@ export const fromNodelessInvoice = applySpec<Invoice>({
184187
expiresAt: ifElse(
185188
propSatisfies(is(String), 'expiresAt'),
186189
pipe(prop('expiresAt'), toDate),
187-
ifElse(
188-
propSatisfies(is(String), 'createdAt'),
189-
pipe(prop('createdAt'), toDate, addTime(15 * 60000)),
190-
always(null),
191-
),
190+
ifElse(propSatisfies(is(String), 'createdAt'), pipe(prop('createdAt'), toDate, addTime(15 * 60000)), always(null)),
192191
),
193192
confirmedAt: cond([
194193
[propSatisfies(is(String), 'paidAt'), pipe(prop('paidAt'), toDate)],
195194
[T, always(null)],
196195
]),
197-
createdAt: ifElse(
198-
propSatisfies(is(String), 'createdAt'),
199-
pipe(prop('createdAt'), toDate),
200-
always(null),
201-
),
196+
createdAt: ifElse(propSatisfies(is(String), 'createdAt'), pipe(prop('createdAt'), toDate), always(null)),
202197
// rawResponse: toJSON,
203198
})
204199

@@ -208,14 +203,10 @@ export const fromOpenNodeInvoice = applySpec<Invoice>({
208203
bolt11: ifElse(
209204
pathSatisfies(is(String), ['lightning_invoice', 'payreq']),
210205
path(['lightning_invoice', 'payreq']),
211-
path(['lightning', 'payreq'])
206+
path(['lightning', 'payreq']),
212207
),
213208
amountRequested: pipe(
214-
ifElse(
215-
propSatisfies(is(Number), 'amount'),
216-
prop('amount'),
217-
prop('price'),
218-
) as () => number,
209+
ifElse(propSatisfies(is(Number), 'amount'), prop('amount'), prop('price')) as () => number,
219210
toBigInt,
220211
),
221212
description: prop('description'),
@@ -234,7 +225,10 @@ export const fromOpenNodeInvoice = applySpec<Invoice>({
234225
expiresAt: pipe(
235226
cond([
236227
[pathSatisfies(is(String), ['lightning', 'expires_at']), path(['lightning', 'expires_at'])],
237-
[pathSatisfies(is(Number), ['lightning_invoice', 'expires_at']), pipe(path(['lightning_invoice', 'expires_at']), multiply(1000))],
228+
[
229+
pathSatisfies(is(Number), ['lightning_invoice', 'expires_at']),
230+
pipe(path(['lightning_invoice', 'expires_at']), multiply(1000)),
231+
],
238232
]),
239233
toDate,
240234
),
@@ -243,11 +237,7 @@ export const fromOpenNodeInvoice = applySpec<Invoice>({
243237
[T, always(null)],
244238
]),
245239
createdAt: pipe(
246-
ifElse(
247-
propSatisfies(is(Number), 'created_at'),
248-
pipe(prop('created_at'), multiply(1000)),
249-
prop('created_at'),
250-
),
240+
ifElse(propSatisfies(is(Number), 'created_at'), pipe(prop('created_at'), multiply(1000)), prop('created_at')),
251241
toDate,
252242
),
253243
rawResponse: toJSON,

0 commit comments

Comments
 (0)