Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(governance,networks): remove localhost from networks (again) (#13321
- Loading branch information
Showing
22 changed files
with
239 additions
and
104 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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dist | ||
build | ||
build | ||
src/networks/localhost.ts |
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,73 @@ | ||
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 on CI | ||
console.log(localhost) | ||
|
||
// 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 [unlockAddress, subgraphEnpoint] = process.argv.slice(2) | ||
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 | ||
}) |
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,19 @@ | ||
import fs from 'fs-extra' | ||
|
||
// this is used to read a network | ||
const run = async () => { | ||
const [networkInfoPath] = process.argv.slice(2) | ||
const networkInfo = await fs.readJSON(networkInfoPath) | ||
const { | ||
localhost: { | ||
Unlock: { address: unlockAddress }, | ||
}, | ||
} = networkInfo | ||
return unlockAddress | ||
} | ||
|
||
run() | ||
.then((unlockAddress) => console.log(unlockAddress)) | ||
.catch((err) => { | ||
throw err | ||
}) |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './localhost' | ||
export * from './mainnet' | ||
export * from './gnosis' | ||
export * from './polygon' | ||
|
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
Oops, something went wrong.