Skip to content

Commit

Permalink
use chains.js instead of json (simplify rollup use)
Browse files Browse the repository at this point in the history
  • Loading branch information
clbrge committed Sep 3, 2021
1 parent 70e56d0 commit ce972f6
Show file tree
Hide file tree
Showing 6 changed files with 3,128 additions and 18 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
"email": "<[email protected]>"
},
"scripts": {
"update-chains": "node ./scripts/update-chains.js",
"build": "rollup -c"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@rollup/plugin-json": "^4.1.0",
"eslint-plugin-svelte3": "^3.2.0",
"release-it": "^14.11.5",
"rollup": "^2.56.3",
Expand Down
16 changes: 2 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
//import svelte from 'rollup-plugin-svelte';
//import resolve from '@rollup/plugin-node-resolve';
//import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import pkg from './package.json';

const name = pkg.name
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, m => m.toUpperCase())
.replace(/-\w/g, m => m[1].toUpperCase());

export default [
{
input: "./src/web3-store.js",
output: [
{ file: "dist/index.mjs", format: "es" },
{ file: "dist/index.js", format: "umd", name: "web3store" },
],
plugins: [json()]
]
},
];
]
24 changes: 24 additions & 0 deletions scripts/update-chains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const util = require('util')
const fetch = require('node-fetch')
const { writeFile } = require('fs/promises')

const run = async () => {

const res = await fetch('https://chainid.network/chains.json')

const chains = await res.json()

if (!chains.map( c => c.name ).includes('Ethereum Mainnet')) {
throw new Error('something wrong... check!')
}

await writeFile('./src/chains.js', `
const chains = ${util.inspect(chains, { depth: null, maxArrayLength: null })}
export default chains
`
)

}

run()
Loading

0 comments on commit ce972f6

Please sign in to comment.