-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: api mode with vercel deployment
- Loading branch information
1 parent
25ae4c8
commit 20e692b
Showing
7 changed files
with
105 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
shopt -s dotglob | ||
|
||
mkdir public | ||
cp -r chains public | ||
|
||
exit 0 |
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,9 @@ | ||
import { default as writeFile } from "./utils/useWriteFile.mjs"; | ||
import { default as chainList } from "./utils/useChainList.mjs"; | ||
import { default as chainListFeatured } from "./utils/useChainListFeatured.mjs"; | ||
|
||
writeFile(JSON.stringify(chainList(true)), "./public/mainnet/chains.json"); | ||
writeFile(JSON.stringify(chainListFeatured(true)), "./public/mainnet/featured-chains.json"); | ||
|
||
writeFile(JSON.stringify(chainList(false)), "./public/testnet/chains.json"); | ||
writeFile(JSON.stringify(chainListFeatured(false)), "./public/testnet/featured-chains.json"); |
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,35 @@ | ||
import * as fs from "fs"; | ||
import { default as loadJson } from "./useLoadJson.mjs"; | ||
|
||
export default function (isMainnet) { | ||
const env = isMainnet ? 'mainnets' : 'testnets'; | ||
const files = fs.readdirSync(`./chains/${env}`).sort() | ||
const data = {}; | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
if (["protocol.schema.json", "_template"].includes(files[i])) { | ||
continue; | ||
} | ||
|
||
const { | ||
name, | ||
chainName, | ||
logo_URIs, | ||
denomUpper, | ||
coinGeckoId, | ||
isExplorerEnabled, | ||
isFeatured, | ||
} = loadJson(`./../../chains/${env}/${files[i]}/chain.json`); | ||
|
||
data[name] = { | ||
chainName, | ||
logo_URIs, | ||
denomUpper, | ||
coinGeckoId, | ||
isExplorerEnabled, | ||
isFeatured, | ||
} | ||
} | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as fs from "fs"; | ||
import {default as loadJson} from "./useLoadJson.mjs"; | ||
|
||
export default function (isMainnet) { | ||
const env = isMainnet ? 'mainnets' : 'testnets'; | ||
const files = fs.readdirSync(`./chains/${env}`).sort(); | ||
const data = []; | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
if (["protocol.schema.json", "_template"].includes(files[i])) { | ||
continue; | ||
} | ||
|
||
const { | ||
name, | ||
chainName, | ||
logo_URIs, | ||
denomUpper, | ||
coinGeckoId, | ||
isExplorerEnabled, | ||
isFeatured, | ||
} = loadJson(`./../../chains/${env}/${files[i]}/chain.json`); | ||
|
||
if (isFeatured) { | ||
data[name] = { | ||
chainName, | ||
logo_URIs, | ||
denomUpper, | ||
coinGeckoId, | ||
isExplorerEnabled, | ||
isFeatured | ||
}; | ||
} | ||
} | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as fs from "fs"; | ||
|
||
export default function (path) { | ||
return JSON.parse(fs.readFileSync(new URL(path, import.meta.url))); | ||
} |
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,9 @@ | ||
import * as fs from "fs"; | ||
|
||
export default function (content, path) { | ||
fs.writeFile(path, content, (err) => { | ||
if (err) { | ||
console.error(err); | ||
} | ||
}); | ||
}; |