Skip to content

Commit

Permalink
Merge branch 'staging' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Feb 12, 2025
2 parents b12d85d + 5f1f198 commit f808b25
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 16 deletions.
67 changes: 67 additions & 0 deletions packages/explorer-backend/scripts/bonder_balance_checker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const ethers = require('ethers')
const chalk = require('chalk')

class BalanceChecker {
constructor (rpcUrl, addresses) {
this.provider = new ethers.providers.JsonRpcProvider(rpcUrl)
this.addresses = addresses
}

async fetchBalances () {
const balancePromises = this.addresses.map(async ({ label, address }) => {
const balanceBigInt = await this.provider.getBalance(address)
const balance = ethers.utils.formatEther(balanceBigInt)
return { label, address, balance }
})

const balanceData = await Promise.all(balancePromises)
return balanceData
}

displayTable (balanceData) {
console.log(chalk.bold('Address Balances on Ethereum:'))
console.log('+---------+------------------------------------------+-----------+')
console.log('| Label | Address | Balance |')
console.log('+---------+------------------------------------------+-----------+')

balanceData.forEach(({ label, address, balance }) => {
let color
const numericBalance = parseFloat(balance)
if (numericBalance < 0.01) {
color = chalk.red
} else if (numericBalance < 0.5) {
color = chalk.yellow
} else {
color = chalk.green // Green text for balances >= 0.5 ETH
}

console.log(
`| ${color(label.padEnd(7))} | ${color(address)} | ${color(balance.padStart(9) + ' ETH')} |`
)
console.log('+---------+------------------------------------------+-----------+')
})
}
}

const ethereumRpcUrl = 'https://1rpc.io/eth'
const addresses = [
{ label: 'USDC', address: '0xAb46D6A0c7971E79506a373E1b3bD4E0240d3AFF' }, // relayer
{ label: 'USDT', address: '0x698d6c5475e95aa821b4ed4913831b96f6680ec9' },
{ label: 'MATIC', address: '0xd8781ca9163e9f132a4d8392332e64115688013a' },
{ label: 'DAI', address: '0x10720f58Cf4A22fa540ff10430fD967d2ef102de' },
{ label: 'ETH', address: '0x710bDa329b2a6224E4B44833DE30F38E7f81d564' },
{ label: 'HOP', address: '0x881296Edcb252080bd476c464cEB521d08df7631' },
{ label: 'SNX', address: '0x547d28cDd6A69e3366d6aE3EC39543F09Bd09417' },
{ label: 'sUSD', address: '0x547d28cDd6A69e3366d6aE3EC39543F09Bd09417' },
{ label: 'rETH', address: '0xD38B96277df34F1f7ac5965F86016E7d02c4Ca94' },
{ label: 'MAGIC', address: '0xa251E7519cbCf76e33D4672d2218e3CbcCEB6d60' },
]

async function main() {
const balanceChecker = new BalanceChecker(ethereumRpcUrl, addresses)

const balances = await balanceChecker.fetchBalances()
balanceChecker.displayTable(balances)
}

main().catch(console.error)
15 changes: 15 additions & 0 deletions packages/explorer-backend/scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "scripts",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"chalk": "^3.0.0"
}
}
7 changes: 5 additions & 2 deletions packages/explorer-backend/scripts/refresh_pending.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require('dotenv').config()
const wait = require('wait')

const apiBaseUrl = 'https://explorer-api.hop.exchange'
// const apiBaseUrl = 'http://localhost:8000'
const rateLimitToken = process.env.RATE_LIMIT_TOKEN
const token = process.argv[2] ?? ''
console.log('rateLimitToken set', !!rateLimitToken)
Expand All @@ -13,13 +15,14 @@ async function main () {
if (page === 2) {
break
}
const url0 = `https://explorer-api.hop.exchange/v1/transfers?page=${page}&bonded=pending&rate_limit_token=${rateLimitToken}&token=${token}`
const url0 = `${apiBaseUrl}/v1/transfers?page=${page}&bonded=pending&rate_limit_token=${rateLimitToken}&token=${token}`
const response0 = await fetch(url0)
const json0 = await response0.json()
const transferIds = json0.data.map(transfer => transfer.transferId)
// const transferIds = json0.data.map(transfer => transfer.transactionHash)
console.log(transferIds.length)
for (const transferId of transferIds) {
const url = `https://explorer-api.hop.exchange/v1/transfers?transferId=${transferId}&refresh=true&rate_limit_token=${rateLimitToken}`
const url = `${apiBaseUrl}/v1/transfers?transferId=${transferId}&refresh=true&rate_limit_token=${rateLimitToken}`

console.log(url)

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hop-protocol/frontend",
"version": "0.0.31",
"version": "0.0.32",
"description": "Hop Protocol Frontend",
"author": "Authereum Labs, Inc.",
"license": "MIT",
Expand Down
9 changes: 9 additions & 0 deletions packages/frontend/src/assets/logos/twitter-x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions packages/frontend/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import Typography from '@mui/material/Typography'
import discord from '../../assets/logos/discord.svg?react' // eslint-disable-line n/no-missing-import
import github from '../../assets/logos/github.svg?react' // eslint-disable-line n/no-missing-import
import medium from '../../assets/logos/medium.svg?react' // eslint-disable-line n/no-missing-import
import twitter from '../../assets/logos/twitter.svg?react' // eslint-disable-line n/no-missing-import
import twitter from '../../assets/logos/twitter-x.svg?react' // eslint-disable-line n/no-missing-import
import { StyledLink } from '#components/Link/StyledLink.js'
import { SvgImg } from '#components/ui/SvgImg.js'
import {
careersUrl,
discordUrl,
docsUrl,
faqUrl,
Expand Down Expand Up @@ -130,11 +129,6 @@ export const Footer = () => {
<Typography variant="subtitle2">Forum</Typography>
</StyledLink>
</Box>
<Box ml={'1.6rem'}>
<StyledLink href={careersUrl} opacity={0.6}>
<Typography variant="subtitle2">Careers</Typography>
</StyledLink>
</Box>
</Box>
</Box>
)
Expand Down
7 changes: 5 additions & 2 deletions packages/frontend/src/pages/Relay/Relay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ export const Relay: FC = () => {
console.log('receipt', receipt)
} catch (err: any) {
console.error(err)
throw new Error(`Failed to relay commit transfer tx on ${l1Network.slug}. Error: ${err.message}. You may need to wait a few more hours to relay this transfer.`)
if ([ChainSlug.Arbitrum, ChainSlug.Nova, ChainSlug.Optimism].includes(selectedNetwork?.slug as ChainSlug)) {
throw new Error(`Failed to relay commit transfer tx on ${l1Network.name}. You may need to wait until the challenge period on ${selectedNetwork.name} (~7 days after the commit tx) has ended to relay this transfer. Your funds are safe. Error: ${err.message}. `)
}
throw new Error(`Failed to relay commit transfer tx on ${l1Network.name}. You may need to wait a few more hours to relay this transfer. Your funds are safe. Error: ${err.message}. `)
}
setLoading(false)
resolve(null)
Expand Down Expand Up @@ -294,7 +297,7 @@ export const Relay: FC = () => {
</Box>
{commitTxHashForTransferId && (
<Box className={styles.notice} mb={2}>
<Alert severity="info">Found commit tx hash:<br /><br /><strong>{commitTxHashForTransferId}</strong><br /><br />This is the hash that is used to prove/finalize the exit transaction.</Alert>
<Alert severity="info">Found commit tx hash:<br /><br /><strong>{commitTxHashForTransferId}</strong><br /><br />This is the hash that is used to {selectedNetwork?.slug === ChainSlug.Optimism ? 'prove/finalize' : 'finalize'} the exit transaction.</Alert>
</Box>
)}
{commitInfoMsg && (
Expand Down
2 changes: 1 addition & 1 deletion packages/stats-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hop-protocol/stats-worker",
"version": "0.0.21",
"version": "0.0.22",
"description": "Hop Protocol Stats Worker",
"author": "Authereum Labs, Inc.",
"license": "MIT",
Expand Down
8 changes: 5 additions & 3 deletions packages/stats-worker/src/data/bonder_profits.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
},
"ETH": {
"0x710bDa329b2a6224E4B44833DE30F38E7f81d564": {
"totalStaked": "4723.44",
"totalStaked": "4473.44",
"initialCanonicalAmounts": {},
"initialNativeAmounts": {
"ETH": {
Expand Down Expand Up @@ -282,7 +282,8 @@
"2024-09-07": ["100.00", "112.50"],
"2024-10-25": ["1200.00", "200.00"],
"2024-11-04": "425.00",
"2024-11-13": ["100.00", "100.00", "100.00", "441.67"]
"2024-11-13": ["100.00", "100.00", "100.00", "441.67"],
"2025-01-08": "250.00"
},
"unstakedEthAmounts": {},
"restakedProfits": {},
Expand All @@ -304,7 +305,8 @@
"2024-10-23": "5.8",
"2024-10-25": "1290.00",
"2024-11-04": "425.00",
"2024-11-13": "741.67"
"2024-11-13": "741.67",
"2025-01-08": "300.00"
}
}
},
Expand Down

0 comments on commit f808b25

Please sign in to comment.