-
Notifications
You must be signed in to change notification settings - Fork 13
[TASK-14052] Prod release 105 #1121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a913608
feat: handle send link claims to bank account for peanut users (#1078)
kushagrasarathe 35a7a15
remove duplicate debounce code and use `useDebounce` hook instead (#1…
Zishan-7 ee6e749
Landing page v2.1 (#1089)
Zishan-7 03878b0
[TASK-13186] refactor: use networkName instead of axelarChainName (#1…
jjramirezn 6adb9c3
fix: onramp currency (#1096)
Zishan-7 a65bddd
fix: stretched favicon (#1099)
Zishan-7 be50ecb
[TASK-13971] fix: scientific notation in eip681 parsing (#1097)
jjramirezn 9e8197d
pull iban hotfix (#1100)
Zishan-7 e92923c
fix: claim flow bugs (#1102)
kushagrasarathe d4bcddf
Fix back button not working on /profile (#1101)
Zishan-7 8e51429
fix: send link claims to us bank accounts (#1108)
kushagrasarathe d6d974b
Sync Landing page changes (#1111)
Zishan-7 57a2de2
fix: us bank claims after kyc for logged in users (#1112)
kushagrasarathe 0a5ac02
fix: trim account form inputs for spaces (#1114)
kushagrasarathe 46200bf
[TASK-14107] fix: don't allow claiming on xChain if route is not foun…
jjramirezn 71ee857
feat: handle redirect uri when on unsupported browsers (#1117)
kushagrasarathe 90a20e1
remove animation (#1118)
Zishan-7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| // Compare Bridge vs Frankfurter (and optionally local /api/exchange-rate) rates | ||
| // Usage examples: | ||
| // node scripts/compare-rates.mjs | ||
| // node scripts/compare-rates.mjs --pairs USD:EUR,USD:MXN --api http://localhost:3000/api/exchange-rate | ||
| // BRIDGE_API_KEY=xxx node scripts/compare-rates.mjs | ||
|
|
||
| import { readFileSync } from 'fs' | ||
| import { resolve } from 'path' | ||
|
|
||
| // Load .env files | ||
| function loadEnv() { | ||
| const envFiles = ['.env.local', '.env'] | ||
| for (const file of envFiles) { | ||
| try { | ||
| const envPath = resolve(file) | ||
| const envContent = readFileSync(envPath, 'utf8') | ||
| envContent.split('\n').forEach((line) => { | ||
| const trimmed = line.trim() | ||
| if (trimmed && !trimmed.startsWith('#')) { | ||
| const [key, ...valueParts] = trimmed.split('=') | ||
| if (key && valueParts.length > 0) { | ||
| const value = valueParts.join('=').replace(/^["']|["']$/g, '') | ||
| if (!process.env[key]) { | ||
| process.env[key] = value | ||
| } | ||
| } | ||
| } | ||
| }) | ||
| console.log(`Loaded environment from ${file}`) | ||
| break | ||
| } catch (e) { | ||
| // File doesn't exist, continue to next | ||
| } | ||
| } | ||
| } | ||
|
|
||
| loadEnv() | ||
|
|
||
| const DEFAULT_PAIRS = [ | ||
| ['USD', 'EUR'], | ||
| ['USD', 'MXN'], | ||
| ['USD', 'BRL'], | ||
| ['EUR', 'USD'], | ||
| ['EUR', 'GBP'], | ||
| ] | ||
|
|
||
| const params = process.argv.slice(2) | ||
| const pairsArg = getArg('--pairs') | ||
| const apiArg = getArg('--api') | ||
|
|
||
| const PAIRS = pairsArg ? pairsArg.split(',').map((p) => p.split(':').map((s) => s.trim().toUpperCase())) : DEFAULT_PAIRS | ||
|
|
||
| const BRIDGE_API_KEY = process.env.BRIDGE_API_KEY | ||
|
|
||
| function getArg(name) { | ||
| const i = params.indexOf(name) | ||
| if (i === -1) return null | ||
| return params[i + 1] || null | ||
| } | ||
|
|
||
| async function fetchBridge(from, to) { | ||
| if (!BRIDGE_API_KEY) { | ||
| return { error: 'Missing BRIDGE_API_KEY' } | ||
| } | ||
| const url = `https://api.bridge.xyz/v0/exchange_rates?from=${from.toLowerCase()}&to=${to.toLowerCase()}` | ||
| const res = await fetch(url, { | ||
| method: 'GET', | ||
| headers: { 'Api-Key': BRIDGE_API_KEY }, | ||
| }) | ||
| if (!res.ok) { | ||
| return { error: `${res.status} ${res.statusText}` } | ||
| } | ||
| const data = await res.json() | ||
| const { midmarket_rate, buy_rate, sell_rate } = data || {} | ||
| return { midmarket_rate, buy_rate, sell_rate } | ||
| } | ||
|
|
||
| async function fetchFrankfurter(from, to) { | ||
| const url = `https://api.frankfurter.app/latest?from=${from}&to=${to}` | ||
| const res = await fetch(url, { method: 'GET' }) | ||
| if (!res.ok) { | ||
| return { error: `${res.status} ${res.statusText}` } | ||
| } | ||
| const data = await res.json() | ||
| const rate = data?.rates?.[to] | ||
| return { rate, rate_995: typeof rate === 'number' ? rate * 0.995 : undefined } | ||
| } | ||
|
|
||
| async function fetchLocalApi(from, to) { | ||
| if (!apiArg) return {} | ||
| try { | ||
| const url = `${apiArg}?from=${from}&to=${to}` | ||
| const res = await fetch(url, { method: 'GET' }) | ||
| if (!res.ok) { | ||
| return { error: `${res.status} ${res.statusText}` } | ||
| } | ||
| const data = await res.json() | ||
| return { rate: data?.rate } | ||
| } catch (error) { | ||
| return { error: `Connection failed: ${error.message}` } | ||
| } | ||
| } | ||
|
|
||
| function fmt(n, digits = 6) { | ||
| return typeof n === 'number' && Number.isFinite(n) ? n.toFixed(digits) : '-' | ||
| } | ||
|
|
||
| function bps(a, b) { | ||
| if (typeof a !== 'number' || typeof b !== 'number' || !Number.isFinite(a) || !Number.isFinite(b) || b === 0) | ||
| return '-' | ||
| const rel = (a / b - 1) * 10000 | ||
| return `${rel.toFixed(1)} bps` | ||
| } | ||
|
|
||
| async function run() { | ||
| console.log('Comparing rates...') | ||
| if (!BRIDGE_API_KEY) { | ||
| console.warn('Warning: BRIDGE_API_KEY not set. Bridge calls will be skipped or return errors.') | ||
| } | ||
| if (apiArg) { | ||
| console.log(`Also querying local API: ${apiArg}`) | ||
| } | ||
|
|
||
| for (const [from, to] of PAIRS) { | ||
| const [bridge, frankData, local] = await Promise.all([ | ||
| fetchBridge(from, to).catch((e) => ({ error: e?.message || String(e) })), | ||
| fetchFrankfurter(from, to).catch((e) => ({ error: e?.message || String(e) })), | ||
| fetchLocalApi(from, to).catch((e) => ({ error: e?.message || String(e) })), | ||
| ]) | ||
|
|
||
| const bridgeBuy = bridge?.buy_rate ? Number(bridge.buy_rate) : undefined | ||
| const bridgeMid = bridge?.midmarket_rate ? Number(bridge.midmarket_rate) : undefined | ||
| const bridgeSell = bridge?.sell_rate ? Number(bridge.sell_rate) : undefined | ||
| const frank = typeof frankData?.rate === 'number' ? frankData.rate : undefined | ||
| const frank995 = typeof frankData?.rate_995 === 'number' ? frankData.rate_995 : undefined | ||
| const localRate = typeof local?.rate === 'number' ? local.rate : undefined | ||
|
|
||
| console.log(`\nPair: ${from} -> ${to}`) | ||
| console.table([ | ||
| { | ||
| source: 'Bridge', | ||
| buy: fmt(bridgeBuy), | ||
| mid: fmt(bridgeMid), | ||
| sell: fmt(bridgeSell), | ||
| note: bridge?.error || '', | ||
| }, | ||
| { | ||
| source: 'Frankfurter', | ||
| rate: fmt(frank), | ||
| rate_995: fmt(frank995), | ||
| note: frankData?.error || '', | ||
| }, | ||
| { | ||
| source: 'Local API', | ||
| rate: fmt(localRate), | ||
| note: local?.error || '', | ||
| }, | ||
| ]) | ||
|
|
||
| // Delta analysis table | ||
| console.log(`\nDelta Analysis for ${from} -> ${to}:`) | ||
| console.table([ | ||
| { | ||
| comparison: 'Mid vs Frankfurt', | ||
| delta: bps(bridgeMid, frank), | ||
| }, | ||
| { | ||
| comparison: 'Mid vs Frankfurt×0.995', | ||
| delta: bps(bridgeMid, frank995), | ||
| }, | ||
| { | ||
| comparison: 'Sell vs Frankfurt×0.995', | ||
| delta: bps(bridgeSell, frank995), | ||
| }, | ||
| { | ||
| comparison: 'Sell vs Mid', | ||
| delta: bps(bridgeSell, bridgeMid), | ||
| }, | ||
| { | ||
| comparison: 'Buy vs Mid', | ||
| delta: bps(bridgeBuy, bridgeMid), | ||
| }, | ||
| { | ||
| comparison: 'Local vs Frankfurt×0.995', | ||
| delta: bps(localRate, frank995), | ||
| }, | ||
| ]) | ||
| } | ||
| } | ||
|
|
||
| run().catch((e) => { | ||
| console.error(e) | ||
| process.exit(1) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsound cast for networkName risks undefined at runtime — derive and set explicitly
{ ...(chain as ISquidChain & { networkName: string }), tokens: [] }trusts that SDK chains already includenetworkName. If the SDK doesn’t yet ship this field, downstream UI readingchain.networkNamewill renderundefined.Set
networkNameexplicitly with safe fallbacks:export const getSquidChainsAndTokens = unstable_cache( async (): Promise< Record<string, interfaces.ISquidChain & { networkName: string; tokens: interfaces.ISquidToken[] }> > => { const [chains, tokens] = await Promise.all([getSquidChainsCache(), getSquidTokensCache()]) - const chainsById = chains.reduce< - Record<string, interfaces.ISquidChain & { networkName: string; tokens: interfaces.ISquidToken[] }> - >((acc, chain) => { - acc[chain.chainId] = { ...(chain as interfaces.ISquidChain & { networkName: string }), tokens: [] } - return acc - }, {}) + const chainsById = chains.reduce< + Record<string, interfaces.ISquidChain & { networkName: string; tokens: interfaces.ISquidToken[] }> + >((acc, chain) => { + const anyChain = chain as any + const networkName: string = + anyChain.networkName ?? + anyChain.axelarChainName ?? // legacy field seen in prior codebase + anyChain.name ?? + String(chain.chainId) + acc[chain.chainId] = { ...(chain as interfaces.ISquidChain), networkName, tokens: [] } + return acc + }, {})📝 Committable suggestion
🤖 Prompt for AI Agents