wip: WithdrawDialog migrated to Tauri IPC

This commit is contained in:
binarybaron 2024-08-09 19:46:58 +02:00
parent 47821cbe79
commit 3d16ff6d5c
No known key found for this signature in database
GPG key ID: 99B75D3E1476A26E
118 changed files with 1779 additions and 1868 deletions

View file

@ -12,21 +12,21 @@ export function piconerosToXmr(piconeros: number): number {
export function isXmrAddressValid(address: string, stagenet: boolean) {
const re = stagenet
? '[57][0-9AB][1-9A-HJ-NP-Za-km-z]{93}'
: '[48][0-9AB][1-9A-HJ-NP-Za-km-z]{93}';
? "[57][0-9AB][1-9A-HJ-NP-Za-km-z]{93}"
: "[48][0-9AB][1-9A-HJ-NP-Za-km-z]{93}";
return new RegExp(`(?:^${re}$)`).test(address);
}
export function isBtcAddressValid(address: string, testnet: boolean) {
const re = testnet
? '(tb1)[a-zA-HJ-NP-Z0-9]{25,49}'
: '(bc1)[a-zA-HJ-NP-Z0-9]{25,49}';
? "(tb1)[a-zA-HJ-NP-Z0-9]{25,49}"
: "(bc1)[a-zA-HJ-NP-Z0-9]{25,49}";
return new RegExp(`(?:^${re}$)`).test(address);
}
export function getBitcoinTxExplorerUrl(txid: string, testnet: boolean) {
return `https://blockchair.com/bitcoin${
testnet ? '/testnet' : ''
testnet ? "/testnet" : ""
}/transaction/${txid}`;
}

View file

@ -1,5 +1,5 @@
import { createHash } from 'crypto';
import { createHash } from "crypto";
export function sha256(data: string): string {
return createHash('md5').update(data).digest('hex');
return createHash("md5").update(data).digest("hex");
}

View file

@ -1,7 +1,5 @@
import pino from 'pino';
import pino from "pino";
export default pino(
{
level: 'trace',
}
);
export default pino({
level: "trace",
});

View file

@ -1,9 +1,9 @@
import { Multiaddr } from 'multiaddr';
import semver from 'semver';
import { ExtendedProviderStatus, Provider } from 'models/apiModel';
import { isTestnet } from 'store/config';
import { Multiaddr } from "multiaddr";
import semver from "semver";
import { ExtendedProviderStatus, Provider } from "models/apiModel";
import { isTestnet } from "store/config";
const MIN_ASB_VERSION = '0.12.0';
const MIN_ASB_VERSION = "0.12.0";
export function providerToConcatenatedMultiAddr(provider: Provider) {
return new Multiaddr(provider.multiAddr)

View file

@ -1,4 +1,4 @@
import { CliLog, isCliLog } from 'models/cliModel';
import { CliLog, isCliLog } from "models/cliModel";
/*
Extract btc amount from string
@ -8,7 +8,7 @@ Output: 0.001
*/
export function extractAmountFromUnitString(text: string): number | null {
if (text != null) {
const parts = text.split(' ');
const parts = text.split(" ");
if (parts.length === 2) {
const amount = Number.parseFloat(parts[0]);
return amount;
@ -19,13 +19,13 @@ export function extractAmountFromUnitString(text: string): number | null {
// E.g 2021-12-29 14:25:59.64082 +00:00:00
export function parseDateString(str: string): number {
const parts = str.split(' ').slice(0, -1);
const parts = str.split(" ").slice(0, -1);
if (parts.length !== 2) {
throw new Error(
`Date string does not consist solely of date and time Str: ${str} Parts: ${parts}`,
);
}
const wholeString = parts.join(' ');
const wholeString = parts.join(" ");
const date = Date.parse(wholeString);
if (Number.isNaN(date)) {
throw new Error(
@ -38,9 +38,9 @@ export function parseDateString(str: string): number {
export function getLinesOfString(data: string): string[] {
return data
.toString()
.replace('\r\n', '\n')
.replace('\r', '\n')
.split('\n')
.replace("\r\n", "\n")
.replace("\r", "\n")
.split("\n")
.filter((l) => l.length > 0);
}
@ -61,5 +61,5 @@ export function getLogsFromRawFileString(rawFileData: string): CliLog[] {
}
export function logsToRawString(logs: (CliLog | string)[]): string {
return logs.map((l) => JSON.stringify(l)).join('\n');
return logs.map((l) => JSON.stringify(l)).join("\n");
}

View file

@ -1,4 +1,4 @@
import { ExtendedProviderStatus } from 'models/apiModel';
import { ExtendedProviderStatus } from "models/apiModel";
export function sortProviderList(list: ExtendedProviderStatus[]) {
return list.concat().sort((firstEl, secondEl) => {