feat: sync and update with all changes from fork (#720)

* feat: sync and update with all changes from fork
* refactor: extract clipboard copy logic into custom hook
* fix: correct spelling of DEFAULT_REFRESH_FREQUENCY_MS in Stamps and WalletBalance providers
* refactor(ui-tests): replace fixed sleeps with condition-based waits
* fix: handle null values for size and granteeCount in infoGroups
* fix(lint): add newline at end of file in useClipboardCopy hook
* fix(ui-tests): page.goto URL
* refactor: update import paths for useClipboardCopy

---------

Co-authored-by: Ferenc Sárai <sarai.ferenc@gmail.com>
This commit is contained in:
Bálint Ujvári
2026-03-02 11:34:39 +01:00
committed by GitHub
parent b0f00a624a
commit 519c411db0
303 changed files with 16609 additions and 29415 deletions
+11 -12
View File
@@ -1,7 +1,8 @@
import { PrivateKey } from '@ethersphere/bee-js'
import { Bytes, PrivateKey } from '@ethersphere/bee-js'
import { FileInfo, FileStatus } from '@solarpunkltd/file-manager-lib'
import { keccak256 } from '@ethersproject/keccak256'
import { toUtf8Bytes } from '@ethersproject/strings'
import React from 'react'
import { LocalStorageKeys } from '../../../utils/localStorage'
import { lifetimeAdjustments } from '../constants/stamps'
export function getDaysLeft(expiryDate: Date): number {
@@ -83,19 +84,17 @@ export function getFileId(fi: FileInfo): string {
return fi.topic.toString()
}
export const KEY_STORAGE = 'privateKey'
export function getSigner(input: string): PrivateKey {
const normalized = input.trim().toLowerCase()
const hash = keccak256(toUtf8Bytes(normalized))
const privateKeyHex = hash.slice(2)
const inputBytes = Bytes.fromUtf8(normalized)
const privateKeyHex = Bytes.keccak256(inputBytes).toHex()
return new PrivateKey(privateKeyHex)
}
export function getSignerPk(): PrivateKey | undefined {
try {
const fromLocalPk = localStorage.getItem(KEY_STORAGE)
const fromLocalPk = localStorage.getItem(LocalStorageKeys.fmPrivateKey)
if (!fromLocalPk) {
// eslint-disable-next-line no-console
@@ -107,24 +106,24 @@ export function getSignerPk(): PrivateKey | undefined {
return new PrivateKey(fromLocalPk)
} catch (err) {
// eslint-disable-next-line no-console
console.error(`Private key error in localStorage under key "${KEY_STORAGE}": `, err)
console.error(`Private key error in localStorage under key "${LocalStorageKeys.fmPrivateKey}": `, err)
return undefined
}
}
export function setSignerPk(pk: string): void {
localStorage.setItem(KEY_STORAGE, pk)
localStorage.setItem(LocalStorageKeys.fmPrivateKey, pk)
}
export function removeSignerPk(): void {
localStorage.removeItem(KEY_STORAGE)
localStorage.removeItem(LocalStorageKeys.fmPrivateKey)
}
export const capitalizeFirstLetter = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
export const safeSetState =
<T>(ref: React.MutableRefObject<boolean>, setter: React.Dispatch<React.SetStateAction<T>>) =>
<T>(ref: React.RefObject<boolean>, setter: React.Dispatch<React.SetStateAction<T>>) =>
(value: React.SetStateAction<T>) => {
if (ref.current) setter(value)
}