-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch networks from be (#1564)
- Loading branch information
1 parent
e9cfd99
commit b25b77e
Showing
65 changed files
with
777 additions
and
712 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -20,4 +20,6 @@ anvil*.log | |
|
||
rainbowbx.xpi | ||
|
||
.idea/** | ||
.idea/** | ||
|
||
static/data |
This file contains 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 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 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,107 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const path = require('path'); | ||
|
||
const fs = require('fs-extra'); | ||
|
||
/** | ||
* Fetches data from the GraphQL API and saves it to a JSON file. | ||
*/ | ||
async function fetchData() { | ||
const graphqlQuery = ` | ||
query getNetworks($device: Device!, $includeTestnets: Boolean!) { | ||
networks(device: $device, includeTestnets: $includeTestnets) { | ||
id | ||
name | ||
label | ||
icons { | ||
badgeURL | ||
} | ||
testnet | ||
opStack | ||
defaultExplorer { | ||
url | ||
label | ||
transactionURL | ||
tokenURL | ||
} | ||
defaultRPC { | ||
enabledDevices | ||
url | ||
} | ||
nativeAsset { | ||
address | ||
name | ||
symbol | ||
decimals | ||
iconURL | ||
colors { | ||
primary | ||
fallback | ||
shadow | ||
} | ||
} | ||
nativeWrappedAsset { | ||
address | ||
name | ||
symbol | ||
decimals | ||
iconURL | ||
colors { | ||
primary | ||
fallback | ||
shadow | ||
} | ||
} | ||
enabledServices { | ||
meteorology { | ||
enabled | ||
} | ||
swap { | ||
enabled | ||
} | ||
addys { | ||
approvals | ||
transactions | ||
assets | ||
positions | ||
} | ||
tokenSearch { | ||
enabled | ||
} | ||
nftProxy { | ||
enabled | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await fetch('https://metadata.p.rainbow.me/v1/graph', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | ||
query: graphqlQuery, | ||
variables: { device: 'BX', includeTestnets: true }, | ||
}), | ||
}); | ||
|
||
const { data } = await response.json(); | ||
const filePath = path.join(__dirname, '../static/data/networks.json'); | ||
|
||
await fs.ensureFile(filePath); | ||
await fs.writeJson(filePath, data); | ||
} | ||
|
||
async function main() { | ||
try { | ||
console.log('Fetching networks ...'); | ||
await fetchData(); | ||
console.log('Networks data fetched and available.'); | ||
process.exit(0); | ||
} catch (error) { | ||
console.error('Error fetching networks data:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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,79 @@ | ||
import { | ||
arbitrumNova, | ||
aurora, | ||
avalanche, | ||
blast, | ||
blastSepolia, | ||
boba, | ||
canto, | ||
celo, | ||
classic, | ||
cronos, | ||
degen, | ||
dogechain, | ||
fantom, | ||
filecoin, | ||
harmonyOne, | ||
immutableZkEvm, | ||
kava, | ||
klaytn, | ||
linea, | ||
manta, | ||
mantle, | ||
metis, | ||
mode, | ||
moonbeam, | ||
opBNB, | ||
palm, | ||
pgn, | ||
polygonZkEvm, | ||
pulsechain, | ||
rootstock, | ||
scroll, | ||
zkSync, | ||
} from 'viem/chains'; | ||
|
||
import { ChainId } from '../types/chains'; | ||
|
||
export const customChainIdsToAssetNames: Record<ChainId, string> = { | ||
[arbitrumNova.id]: 'arbitrumnova', | ||
[aurora.id]: 'aurora', | ||
[avalanche.id]: 'avalanchex', | ||
[blast.id]: 'blast', | ||
[blastSepolia.id]: 'blastsepolia', | ||
[boba.id]: 'boba', | ||
[celo.id]: 'celo', | ||
[classic.id]: 'classic', | ||
[cronos.id]: 'cronos', | ||
[degen.id]: 'degen', | ||
[dogechain.id]: 'dogechain', | ||
[fantom.id]: 'fantom', | ||
[filecoin.id]: 'filecoin', | ||
[harmonyOne.id]: 'harmony', | ||
[immutableZkEvm.id]: 'immutablezkevm', | ||
[kava.id]: 'kavaevm', | ||
[klaytn.id]: 'klaytn', | ||
[linea.id]: 'linea', | ||
957: 'lyra', | ||
[manta.id]: 'manta', | ||
[mantle.id]: 'mantle', | ||
[metis.id]: 'metis', | ||
[mode.id]: 'mode', | ||
[moonbeam.id]: 'moonbeam', | ||
[canto.id]: 'nativecanto', | ||
[opBNB.id]: 'opbnb', | ||
[palm.id]: 'palm', | ||
[pgn.id]: 'pgn', | ||
[polygonZkEvm.id]: 'polygonzkevm', | ||
[pulsechain.id]: 'pulsechain', | ||
1380012617: 'rari', | ||
1918988905: 'raritestnet', | ||
690: 'redstone', | ||
17069: 'redstonegarnet', | ||
17001: 'redstoneholesky', | ||
[rootstock.id]: 'rootstock', | ||
31: 'rootstocktestnet', | ||
[scroll.id]: 'scroll', | ||
100: 'xdai', | ||
[zkSync.id]: 'zksync', | ||
}; |
Oops, something went wrong.