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
+20 -19
View File
@@ -1,25 +1,26 @@
import { BZZ, DAI, EthAddress } from '@ethersphere/bee-js'
import { providers, Wallet } from 'ethers'
import { estimateNativeTransferTransactionCost, Rpc } from './rpc'
import { JsonRpcProvider, Wallet } from 'ethers'
import { estimateNativeTransferTransactionCost, RPC } from './rpc'
export class WalletAddress {
private constructor(
public address: string,
public bzz: BZZ,
public dai: DAI,
public provider: providers.JsonRpcProvider,
public provider: JsonRpcProvider,
) {}
static async make(address: string, provider: providers.JsonRpcProvider): Promise<WalletAddress> {
const bzz = await Rpc._eth_getBalanceERC20(address, provider)
const dai = await Rpc._eth_getBalance(address, provider)
static async make(address: string, provider: JsonRpcProvider): Promise<WalletAddress> {
const bzz = await RPC._eth_getBalanceERC20(address, provider)
const dai = await RPC._eth_getBalance(address, provider)
return new WalletAddress(address, bzz, dai, provider)
}
public async refresh(): Promise<WalletAddress> {
this.bzz = await Rpc._eth_getBalanceERC20(this.address, this.provider)
this.dai = await Rpc._eth_getBalance(this.address, this.provider)
this.bzz = await RPC._eth_getBalanceERC20(this.address, this.provider)
this.dai = await RPC._eth_getBalance(this.address, this.provider)
return this
}
@@ -33,43 +34,43 @@ export class ResolvedWallet {
public wallet: Wallet,
public bzz: BZZ,
public dai: DAI,
public provider: providers.JsonRpcProvider,
public provider: JsonRpcProvider,
) {
this.address = wallet.address
this.privateKey = wallet.privateKey
}
static async make(privateKeyOrWallet: string | Wallet, provider: providers.JsonRpcProvider): Promise<ResolvedWallet> {
static async make(privateKeyOrWallet: string | Wallet, provider: JsonRpcProvider): Promise<ResolvedWallet> {
const wallet =
typeof privateKeyOrWallet === 'string' ? new Wallet(privateKeyOrWallet, provider) : privateKeyOrWallet
const address = wallet.address
const bzz = await Rpc._eth_getBalanceERC20(address, provider)
const dai = await Rpc._eth_getBalance(address, provider)
const bzz = await RPC._eth_getBalanceERC20(address, provider)
const dai = await RPC._eth_getBalance(address, provider)
return new ResolvedWallet(wallet, bzz, dai, provider)
}
public async refresh(): Promise<ResolvedWallet> {
this.bzz = await Rpc._eth_getBalanceERC20(this.address, this.provider)
this.dai = await Rpc._eth_getBalance(this.address, this.provider)
this.bzz = await RPC._eth_getBalanceERC20(this.address, this.provider)
this.dai = await RPC._eth_getBalance(this.address, this.provider)
return this
}
public async transfer(destination: EthAddress | string, jsonRpcProvider: string): Promise<void> {
public async transfer(destination: EthAddress | string, jsonRpcProviderUrl: string): Promise<void> {
if (this.bzz.gt(BZZ.fromDecimalString('0.05'))) {
await Rpc.sendBzzTransaction(this.privateKey, destination, this.bzz, jsonRpcProvider)
await RPC.sendBzzTransaction(this.privateKey, destination, this.bzz, jsonRpcProviderUrl)
await this.refresh()
}
const { gasPrice, totalCost } = await estimateNativeTransferTransactionCost(this.privateKey, jsonRpcProvider)
const { gasPrice, totalCost } = await estimateNativeTransferTransactionCost(this.privateKey, jsonRpcProviderUrl)
if (this.dai.gt(totalCost)) {
await Rpc.sendNativeTransaction(
await RPC.sendNativeTransaction(
this.privateKey,
destination,
this.dai.minus(totalCost),
jsonRpcProvider,
jsonRpcProviderUrl,
gasPrice,
)
await this.refresh()