Skip to content

Commit b7c608f

Browse files
committed
Merge branch 'develop' into staging
2 parents d7c4775 + 3a25d7e commit b7c608f

File tree

22 files changed

+319
-30
lines changed

22 files changed

+319
-30
lines changed

Diff for: .github/workflows/publishable-packages.yml

+24-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,26 @@ on:
1515
value: ${{ jobs.publishable-packages.outputs.publishable-packages }}
1616

1717
jobs:
18+
check-env-files:
19+
name: Check for .env files
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v3
24+
25+
- name: Check for .env files
26+
id: check-env-files
27+
run: |
28+
echo "Checking for .env files recursively, excluding node_modules..."
29+
if find . -path './node_modules' -prune -o -type f -name '*.env' -print | grep '.env'; then
30+
echo "Error: .env files are detected in the repository. Aborting."
31+
exit 1
32+
fi
33+
shell: bash
34+
1835
publishable-packages:
1936
runs-on: ubuntu-latest
37+
needs: check-env-files
2038
outputs:
2139
publishable-packages: ${{ steps.publishable-packages.outputs.publishable_packages }}
2240
steps:
@@ -39,32 +57,32 @@ jobs:
3957
# Extract changed directories from output, removing the 'package/' prefix
4058
# Example: packages/hop-node,packages/v2-explorer-backend,packages/frontend
4159
modified_dirs="${{ steps.modified-dirs.outputs.all_changed_files }}"
42-
60+
4361
# Read input package names, compare with modified directories
4462
# Example: packages/hop-node,packages/v2-explorer-backend
4563
IFS=":"
4664
read -a input_packages <<< "${{ inputs.package-names }}"
4765
publishable_packages=""
48-
66+
4967
for package in "${input_packages[@]}"; do
5068
package_path="packages/$package"
51-
69+
5270
# Skip packages not modified
5371
if [[ $modified_dirs != *"$package_path"* ]]; then
5472
continue
5573
fi
56-
74+
5775
# On the production branch, publish only if there's a version change
5876
if [ "${{ github.ref_name }}" == "production" ]; then
5977
version_changed=$(git diff HEAD^ HEAD -- "${package_path}/package.json" | grep '"version":' || true)
6078
if [ -z "$version_changed" ]; then
6179
continue
6280
fi
6381
fi
64-
82+
6583
publishable_packages+="$package,"
6684
done
67-
85+
6886
# Strip the trailing comma
6987
# Example: packages/hop-node,packages/v2-explorer-backend
7088
publishable_packages="${publishable_packages%,}"

Diff for: packages/explorer-backend/scripts/refresh_pending.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1+
require('dotenv').config()
12
const wait = require('wait')
23

4+
const rateLimitToken = process.env.RATE_LIMIT_TOKEN
5+
const token = process.argv[2] ?? ''
6+
console.log('rateLimitToken set', !!rateLimitToken)
7+
console.log('token', token)
8+
39
async function main () {
410
let page = 0
511
while (true) {
612
page++
713
if (page === 2) {
814
break
915
}
10-
const url0 = `https://explorer-api.hop.exchange/v1/transfers?page=${page}&bonded=pending`
16+
const url0 = `https://explorer-api.hop.exchange/v1/transfers?page=${page}&bonded=pending&rate_limit_token=${rateLimitToken}&token=${token}`
1117
const response0 = await fetch(url0)
1218
const json0 = await response0.json()
1319
const transferIds = json0.data.map(transfer => transfer.transferId)
1420
console.log(transferIds.length)
1521
for (const transferId of transferIds) {
16-
const url = `https://explorer-api.hop.exchange/v1/transfers?transferId=${transferId}&refresh=true`
22+
const url = `https://explorer-api.hop.exchange/v1/transfers?transferId=${transferId}&refresh=true&rate_limit_token=${rateLimitToken}`
1723

1824
console.log(url)
1925

2026
const response = await fetch(url)
2127
const data = await response.json()
2228
// console.log(data)
23-
await wait(3000)
29+
await wait(100)
2430
}
2531
}
2632
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
copy(Array.from(document.querySelectorAll('.transferId a'))
2+
.map(element => element.getAttribute('data-clipboard-text')).filter(Boolean)
3+
.join(','))

Diff for: packages/explorer-backend/src/TransferStats.ts

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export class TransferStats {
167167

168168
this.trackRecentTransferBonds({ lookbackMinutes: 30, pollIntervalMs: 2 * 60 * 1000 }),
169169
this.trackRecentTransferBonds({ lookbackMinutes: 240, pollIntervalMs: 60 * 60 * 1000, initialDelayMs: 20 * 60 * 1000 }),
170+
this.trackRecentTransferBonds({ lookbackMinutes: 960, pollIntervalMs: 2 * 60 * 60 * 1000, initialDelayMs: 30 * 60 * 1000 }),
170171

171172
this.trackDailyTransfers({ days: this.days, offsetDays: this.offsetDays })
172173
]

Diff for: packages/explorer-backend/src/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const isGoerli = network === 'goerli'
1010
export const port = Number(process.env.PORT || 8000)
1111
export const ipRateLimitReqPerSec = Number(process.env.IP_RATE_LIMIT_REQ_PER_SEC || 100)
1212
export const ipRateLimitWindowMs = Number(process.env.IP_RATE_LIMIT_WINDOW_MS || 1 * 1000)
13+
export const rateLimitToken = process.env.RATE_LIMIT_TOKEN || ''
1314
export const postgresConfig = {
1415
user: process.env.POSTGRES_USER,
1516
host: process.env.POSTGRES_HOST,

Diff for: packages/explorer-backend/src/rateLimit.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import rateLimit from 'express-rate-limit'
2-
import { ipRateLimitReqPerSec, ipRateLimitWindowMs } from './config'
2+
import { ipRateLimitReqPerSec, ipRateLimitWindowMs, rateLimitToken } from './config'
33

44
export const ipRateLimitMiddleware = rateLimit({
55
windowMs: ipRateLimitWindowMs,
@@ -8,5 +8,16 @@ export const ipRateLimitMiddleware = rateLimit({
88
keyGenerator: (req: any) => {
99
// console.log('ip:', req.ip, req.url)
1010
return req.ip
11+
},
12+
skip: (req) => {
13+
if (!rateLimitToken) {
14+
return false
15+
}
16+
17+
if (!req.query.rate_limit_token) {
18+
return false
19+
}
20+
21+
return req.query.rate_limit_token === rateLimitToken
1122
}
1223
})

Diff for: packages/explorer-backend/src/theGraph.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export async function fetchTransferFromL1CompletedsByRecipient (chain: string, r
589589
const data = await queryFetch(url, query, {
590590
recipient
591591
})
592-
let events = data.events || []
592+
const events = data.events || []
593593

594594
return events
595595
} catch (err) {

Diff for: packages/explorer-backend/src/utils/getSlugFromChainId.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { network, networks } from '../config'
1+
import { networks } from '../config'
22

33
const getSlugFromChainIdMap:any = {}
44

Diff for: packages/explorer-frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hop-protocol/explorer-frontend",
3-
"version": "0.0.2",
3+
"version": "0.0.4",
44
"author": "Authereum Labs, Inc.",
55
"license": "MIT",
66
"private": true,

Diff for: packages/explorer-frontend/pages/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ const Index: NextPage = (props: any) => {
13531353
</Tooltip>
13541354
{(x.timestamp < (Date.now()/1000) - (24 * 60 * 60)) && (
13551355
<Box ml={2}>
1356-
<Link href={`${appBaseUrl}/#/withdraw?transferId=${x.transferId}`} target="_blank" rel="noreferrer noopener">Withdraw</Link>
1356+
<Link href={`${appBaseUrl}/#/withdraw?transferId=${x.token === 'USDC' ? x.transactionHash : x.transferId}`} target="_blank" rel="noreferrer noopener">Withdraw</Link>
13571357
</Box>
13581358
)}
13591359
</span>
@@ -1364,7 +1364,7 @@ const Index: NextPage = (props: any) => {
13641364
<span>Pending</span>
13651365
{(x.timestamp < (Date.now()/1000) - (24 * 60 * 60)) && (
13661366
<Box ml={2}>
1367-
<Link href={`${appBaseUrl}/#/withdraw?transferId=${x.transferId}`} target="_blank" rel="noreferrer noopener">Withdraw ↗</Link>
1367+
<Link href={`${appBaseUrl}/#/withdraw?transferId=${x.token === 'USDC' ? x.transactionHash : x.transferId}`} target="_blank" rel="noreferrer noopener">Withdraw ↗</Link>
13681368
</Box>
13691369
)}
13701370
</span>

Diff for: packages/frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hop-protocol/frontend",
3-
"version": "0.0.27",
3+
"version": "0.0.29",
44
"description": "Hop Protocol Frontend",
55
"author": "Authereum Labs, Inc.",
66
"license": "MIT",

Diff for: packages/frontend/public/commit-transfers/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script>window.location.href='../#/commit-transfers'+window.location.search</script>

Diff for: packages/frontend/src/AppRoutes.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const Convert = lazy(() => import(/* webpackChunkName: "Convert" */ '#pages/Conv
1212
const Stats = lazy(() => import(/* webpackChunkName: "Stats" */ '#pages/Stats/index.js'))
1313
const Withdraw = lazy(() => import(/* webpackChunkName: "Withdraw" */ '#pages/Withdraw/index.js'))
1414
const Relay = lazy(() => import(/* webpackChunkName: "Relay" */ '#pages/Relay/index.js'))
15+
const CommitTransfers = lazy(() => import(/* webpackChunkName: "CommitTransfers" */ '#pages/CommitTransfers/index.js'))
1516
const Faucet = lazy(() => import(/* webpackChunkName: "Faucet" */ '#pages/Faucet/index.js'))
1617
const Health = lazy(() => import(/* webpackChunkName: "Health" */ '#pages/Health/index.js'))
1718
const Rewards = lazy(() => import(/* webpackChunkName: "Rewards" */ '#pages/Rewards/index.js'))
@@ -61,6 +62,7 @@ const AppRoutes: FC = () => {
6162
<Route path="/rewards" element={<Rewards />} />
6263
<Route path="/withdraw" element={<Withdraw />} />
6364
<Route path="/relay" element={<Relay />} />
65+
<Route path="/commit-transfers" element={<CommitTransfers />} />
6466
<Route path="/health" element={<Health />} />
6567
<Route path="/faucet" element={<Faucet />} />
6668
<Route path="/claim/*" element={<Claim />} />

0 commit comments

Comments
 (0)