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
fix(governance,networks): remove localhost from networks (again) #13321
Changes from 14 commits
e9ca71e
20452b2
97f97d4
1de9ea0
390253c
81a826a
0637571
274beb9
3dbec2c
c5d7b55
d99b561
96f8dd4
2218112
868e12b
afbcaf3
21e5a49
98d35b3
9cac0c0
fea6343
6a299f7
2843e70
5bfebbe
3868027
108e806
d210809
4437330
bcd2c4c
0031f64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import fs from 'fs-extra' | ||
import path from 'path' | ||
|
||
// We use Partial<NetworkConfig> for localhost as we don't have all the information | ||
const defaultLocalhost = { | ||
chain: 'localhost', | ||
description: 'Localhost network.', | ||
featured: false, | ||
fullySubsidizedGas: true, | ||
id: 31337, | ||
isTestNetwork: true, | ||
name: 'Localhost', | ||
nativeCurrency: { | ||
coingecko: 'ethereum', | ||
decimals: 18, | ||
name: 'ETH', | ||
symbol: 'ETH', | ||
}, | ||
provider: 'http://127.0.0.1:8545', | ||
publicLockVersionToDeploy: 13, | ||
publicProvider: 'http://127.0.0.1:8545', | ||
subgraph: { | ||
endpoint: '', | ||
}, | ||
} | ||
|
||
const generateLocalhostNetworkFile = ({ | ||
unlockAddress, | ||
subgraphEnpoint = 'http://localhost:8000/subgraphs/name/testgraph', | ||
}) => { | ||
const localhost = { | ||
...defaultLocalhost, | ||
subgraph: { | ||
endpoint: subgraphEnpoint, | ||
}, | ||
unlockAddress, | ||
} | ||
|
||
// log for debug purposes | ||
console.log(localhost) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you wnat to keep that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes lets keep that one so we have it to debug on CI |
||
|
||
// output to js file | ||
const parsed = `import { NetworkConfig } from '@unlock-protocol/types' | ||
|
||
// We use Partial<NetworkConfig> for localhost as we don't have all the information | ||
export const localhost: Partial<NetworkConfig> = ${JSON.stringify(localhost)} | ||
export default localhost | ||
` | ||
return parsed | ||
} | ||
|
||
const run = async () => { | ||
const [networkInfoPath, subgraphEnpoint] = process.argv.slice(2) | ||
|
||
const networkInfo = await fs.readJSON(networkInfoPath) | ||
const { | ||
localhost: { | ||
Unlock: { address: unlockAddress }, | ||
}, | ||
} = networkInfo | ||
|
||
console.log(networkInfo) | ||
clemsos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
console.log(`Creating localhost file for unlockAddress ${unlockAddress}`) | ||
|
||
if (!unlockAddress) { | ||
throw new Error('Missing unlockAddress arg') | ||
} | ||
|
||
const fileContent = generateLocalhostNetworkFile({ | ||
subgraphEnpoint, | ||
unlockAddress, | ||
}) | ||
|
||
const filePath = path.resolve('./src/networks/localhost.ts') | ||
|
||
await fs.writeFile(filePath, fileContent) | ||
} | ||
run() | ||
.then(() => console.log('done')) | ||
.catch((err) => { | ||
throw err | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './localhost' | ||
export * from './mainnet' | ||
export * from './gnosis' | ||
export * from './polygon' | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# this file is used to create a localhost network file | ||
|
||
# networks file path when running on CI | ||
INFO_FILE_PATH=/home/unlock/networks.json | ||
|
||
# create localhost file in networks package | ||
yarn workspace @unlock-protocol/networks create-localhost "$INFO_FILE_PATH" | ||
yarn workspace @unlock-protocol/networks build | ||
|
||
# rebuild unlock-js to get latest networks package | ||
yarn workspace @unlock-protocol/unlock-js build | ||
|
This file was deleted.
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.
Can you add a quick note in the README how the
localhost
network is different from he other ones?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.
yep added