Skip to content

Commit

Permalink
chore: Run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bojidar-bg committed Dec 14, 2024
1 parent 42e5051 commit 6d971e0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"lint": "eslint pkg/**/*.\\{ts,js\\} test/**/*.\\{ts,js\\} --ignore-pattern **/*.config.ts",
"fmt": "eslint --fix pkg/**/*.\\{ts,js\\} test/**/*.\\{ts,js\\} --ignore-pattern **/*.config.ts",
"fmt": "eslint --fix pkg/**/*.\\{ts,js\\} test/**/*.\\{ts,js\\} storage/**/*.\\{ts,js,tsx\\} --ignore-pattern **/*.config.ts",
"build-contracts": "forge build --root contracts",
"build-tpodserver": "docker build -t comradecoop/apocryph/server:latest . --target server",
"build-p2p-helper": "docker build -t comradecoop/apocryph/p2p-helper:latest . --target p2p-helper",
Expand Down
12 changes: 6 additions & 6 deletions storage/frontend/src/ActionPopButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useState } from 'react'
import { ReactNode, useState } from 'react'
import './ActionPopButton.css'

interface ActionPopButton {
className?: string,
children: any,
onClick: () => any,
popText?: any,
children: ReactNode,
onClick: () => unknown,
popText?: string,
disabled?: boolean,
}

Expand All @@ -15,11 +15,11 @@ function ActionPopButton(props: ActionPopButton) {
return (
<button
className={"action-pop-button " + (animating ? 'action-pop-animate ' : '') + (props.className || '')}
onClick={_ => {
onClick={() => {
setAnimating(true)
props.onClick()
}}
onAnimationEnd={_ => {
onAnimationEnd={() => {
// https://stackoverflow.com/a/34700273
setAnimating(false)
}}
Expand Down
6 changes: 3 additions & 3 deletions storage/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function App() {
const decimals = 18
const priceGbSec = parseUnits('0.000004', decimals)
const [ funds, setFunds ] = useState<bigint>(() => BigInt(durationMultiplier) * amountGb * priceGbSec / oneGb)
const [existingDeposit, setExistingDeposit] = useState<bigint | undefined>(undefined)
const [depositInProgress, setDepositInProgress] = useState(false)
const [depositError, setDepositError] = useState('')
const [ existingDeposit, setExistingDeposit ] = useState<bigint | undefined>(undefined)
const [ depositInProgress, setDepositInProgress ] = useState(false)
const [ depositError, setDepositError ] = useState('')
const [ showExamples, setShowExamples ] = useState(false)
const [ siweToken, setSiweToken ] = useState<string>()
const [ profitText, setProfitText ] = useState<string>("Ok?")
Expand Down
4 changes: 2 additions & 2 deletions storage/frontend/src/BlurUpdatedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ function BlurUpdatedInput<T>(props: BlurUpdatedInputProps<T>) {
setValueString(e.target.value)
props.onChange(props.parse(e.target.value))
}}
onFocus={_ => {
onFocus={() => {
setValueString(props.stringify(props.value))
setFocused(true)
}}
onBlur={_ => {
onBlur={() => {
setFocused(false)
setValueString("")
}}/>
Expand Down
9 changes: 5 additions & 4 deletions storage/frontend/src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function getStorageChannelId(address: Address) {
}

export function watchAvailableFunds(publicClient: PublicClient, accountAddress: Address, callback: (available?: bigint, reserved?: bigint) => void): Unsubscribe {
let channelId = getStorageChannelId(accountAddress)
const channelId = getStorageChannelId(accountAddress)
async function refresh() {
callback(undefined, undefined) // We are refreshing, blur out
const channelInfo = await publicClient.readContract({
Expand All @@ -44,7 +44,7 @@ export function watchAvailableFunds(publicClient: PublicClient, accountAddress:
abi: paymentV2Abi,
address: paymentV2Address,
args: { channelId: channelId },
onLogs(_logs) {
onLogs() {
refresh()
}
})
Expand Down Expand Up @@ -133,7 +133,8 @@ export async function depositFunds(publicClient: PublicClient, walletClient: Wal
const shouldUnreserve = (withdrawAmount > available - reserved)
if (shouldUnreserve) {
const storageAuthorization = await paymentV2.read.channelAuthorizations([channelId, storageSystemAddress])
let [storageReserved, , storageUnlockAt, ] = storageAuthorization
const storageReserved = storageAuthorization[0]
let storageUnlockAt = storageAuthorization[2]
const currentTime = (await publicClient.getBlock()).timestamp
const shouldUnlock = storageUnlockAt == 0n
if (shouldUnlock) {
Expand All @@ -145,7 +146,7 @@ export async function depositFunds(publicClient: PublicClient, walletClient: Wal
storageUnlockAt = updatedStorageAuthorization[2]
}
if (currentTime < storageUnlockAt) {
let unlockDate = new Date(Number(storageUnlockAt) * 1000)
const unlockDate = new Date(Number(storageUnlockAt) * 1000)
throw new TransientError(`Storage system authorization is currenly being unlocked; please wait until ${unlockDate} before continuing with the withdrawal.`)
}
// NOTE: Could also leave a leftoverReservation = withdrawAmount - (available - reserved + storageReserved)
Expand Down

0 comments on commit 6d971e0

Please sign in to comment.