tsc: fix utils
This commit is contained in:
@@ -10,6 +10,7 @@ import { io } from 'socket.io-client';
|
||||
import { schnorr } from '@noble/curves/secp256k1';
|
||||
import { bytesToHex } from '@noble/hashes/utils';
|
||||
import hashjs from 'hash.js';
|
||||
// @ts-ignore:next-line
|
||||
import { getPublicKey, relayInit } from 'nostr-tools';
|
||||
|
||||
const bip39 = require('bip39');
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
finishEvent,
|
||||
generatePrivateKey,
|
||||
getPublicKey,
|
||||
// @ts-ignore:next-line
|
||||
relayInit
|
||||
} from 'nostr-tools';
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import isObject from 'lodash/isObject';
|
||||
import transform from 'lodash/transform';
|
||||
|
||||
// change responses from camel-case to snake-case
|
||||
const snakeize = (obj) =>
|
||||
transform(obj, (acc, value, key, target) => {
|
||||
const snakeKey = isArray(target) ? key : snakeCase(key);
|
||||
const snakeize = (obj: any) =>
|
||||
transform(obj, (acc: any, value, key, target) => {
|
||||
const snakeKey = isArray(target) ? key : snakeCase(key.toString());
|
||||
acc[snakeKey] = isObject(value) ? snakeize(value) : value;
|
||||
});
|
||||
|
||||
|
||||
@@ -104,15 +104,15 @@ describe('ErrorUtils', () => {
|
||||
});
|
||||
|
||||
it('Return string if error is sent as a string', () => {
|
||||
expect(errorToUserFriendly('Payment timed out', false)).toEqual(
|
||||
'Payment timed out'
|
||||
);
|
||||
expect(
|
||||
errorToUserFriendly(new Error('Payment timed out'), false)
|
||||
).toEqual('Payment timed out');
|
||||
});
|
||||
|
||||
it('Handles PascalCased LSP error messages', () => {
|
||||
expect(
|
||||
errorToUserFriendly(
|
||||
'ChannelExpiryBlocksTooHighInCreateOrderRequest',
|
||||
new Error('ChannelExpiryBlocksTooHighInCreateOrderRequest'),
|
||||
false
|
||||
)
|
||||
).toEqual('Channel expiry blocks too high in create order request');
|
||||
|
||||
@@ -8,9 +8,11 @@ import {
|
||||
export const LndMobileEventEmitter =
|
||||
Platform.OS == 'android'
|
||||
? DeviceEventEmitter
|
||||
: new NativeEventEmitter(NativeModules.LndMobile);
|
||||
: // @ts-ignore:next-line
|
||||
new NativeEventEmitter(NativeModules.LndMobile);
|
||||
|
||||
export const LndMobileToolsEventEmitter =
|
||||
Platform.OS == 'android'
|
||||
? DeviceEventEmitter
|
||||
: new NativeEventEmitter(NativeModules.LndMobileTools);
|
||||
: // @ts-ignore:next-line
|
||||
new NativeEventEmitter(NativeModules.LndMobileTools);
|
||||
|
||||
@@ -8,6 +8,8 @@ import DeviceInfo from 'react-native-device-info';
|
||||
|
||||
import { generateSecureRandom } from 'react-native-securerandom';
|
||||
import NetInfo from '@react-native-community/netinfo';
|
||||
|
||||
// @ts-ignore:next-line
|
||||
import Ping from 'react-native-ping';
|
||||
|
||||
import Log from '../lndmobile/log';
|
||||
@@ -46,12 +48,14 @@ const NEUTRINO_PERSISTENT_FILTER_THRESHOLD = 400000000;
|
||||
export const LndMobileEventEmitter =
|
||||
Platform.OS == 'android'
|
||||
? DeviceEventEmitter
|
||||
: new NativeEventEmitter(NativeModules.LndMobile);
|
||||
: // @ts-ignore:next-line
|
||||
new NativeEventEmitter(NativeModules.LndMobile);
|
||||
|
||||
export const LndMobileToolsEventEmitter =
|
||||
Platform.OS == 'android'
|
||||
? DeviceEventEmitter
|
||||
: new NativeEventEmitter(NativeModules.LndMobileTools);
|
||||
: // @ts-ignore:next-line
|
||||
new NativeEventEmitter(NativeModules.LndMobileTools);
|
||||
|
||||
export function checkLndStreamErrorResponse(
|
||||
name: string,
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ class NFCUtils {
|
||||
let str = '';
|
||||
|
||||
for (let index = 0; index < count; ) {
|
||||
const ch = data[index++];
|
||||
let ch = data[index++];
|
||||
if (ch & 0x80) {
|
||||
const extra = extraByteMap[(ch >> 3) & 0x07];
|
||||
let extra = extraByteMap[(ch >> 3) & 0x07];
|
||||
if (!(ch & 0x40) || !extra || index + extra > count) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-3
@@ -9,9 +9,10 @@ const goToBlockExplorer = (
|
||||
const { settings } = stores.settingsStore;
|
||||
const { privacy } = settings;
|
||||
const custom = privacy && privacy.defaultBlockExplorer === 'Custom';
|
||||
const host = custom
|
||||
? privacy.customBlockExplorer
|
||||
: (privacy && privacy.defaultBlockExplorer) || 'mempool.space';
|
||||
const host =
|
||||
custom && privacy.customBlockExplorer
|
||||
? privacy.customBlockExplorer
|
||||
: (privacy && privacy.defaultBlockExplorer) || 'mempool.space';
|
||||
const network =
|
||||
stores.nodeInfoStore.nodeInfo.isTestNet || testnet ? 'testnet/' : '';
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import BackendUtils from './BackendUtils';
|
||||
|
||||
// Nostr
|
||||
import { DEFAULT_NOSTR_RELAYS } from '../stores/SettingsStore';
|
||||
// @ts-ignore:next-line
|
||||
import { relayInit, nip05, nip19 } from 'nostr-tools';
|
||||
import ContactUtils from './ContactUtils';
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { CheckBox, Icon } from 'react-native-elements';
|
||||
import EncryptedStorage from 'react-native-encrypted-storage';
|
||||
// @ts-ignore:next-line
|
||||
import { relayInit, nip05, nip19 } from 'nostr-tools';
|
||||
import { StackNavigationProp } from '@react-navigation/stack';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user