forked from anoma/namada
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/393 - Add scripts to start local CORS proxies (anoma#394)
* Add scripts to start proxy, update Cosmos env for consistency * Add proxy env to extension, update README.md * SDK & Query must also use proxy if specified
- Loading branch information
Showing
14 changed files
with
409 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P) | ||
|
||
node $SCRIPT_DIR/startProxies.js& | ||
|
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,44 @@ | ||
const { exec } = require('child_process'); | ||
require('dotenv').config(); | ||
|
||
const { | ||
REACT_APP_NAMADA_ALIAS = "Namada", | ||
REACT_APP_NAMADA_URL, | ||
REACT_APP_COSMOS_ALIAS = "Cosmos", | ||
REACT_APP_COSMOS_URL, | ||
REACT_APP_ETH_ALIAS = "Ethereum", | ||
REACT_APP_ETH_URL, | ||
} = process.env; | ||
|
||
const proxyConfigs = [ | ||
{ | ||
alias: REACT_APP_NAMADA_ALIAS, | ||
url: REACT_APP_NAMADA_URL, | ||
proxyPort: 8010, | ||
}, | ||
{ | ||
alias: REACT_APP_COSMOS_ALIAS, | ||
url: REACT_APP_COSMOS_URL, | ||
proxyPort: 8011, | ||
}, | ||
{ | ||
alias: REACT_APP_ETH_ALIAS, | ||
url: REACT_APP_ETH_URL, | ||
proxyPort: 8012, | ||
} | ||
]; | ||
|
||
proxyConfigs.forEach(({ alias, url, proxyPort }) => { | ||
if (url) { | ||
console.log(`Starting local-cors-proxy for ${alias}`) | ||
console.log(`-> ${url} proxied to http://127.0.0.1:${proxyPort}/proxy\n`); | ||
|
||
exec(`lcp --proxyUrl ${url} --port ${proxyPort}`, (error, stdout, stderr) => { | ||
console.log(stdout); | ||
console.log(stderr); | ||
if (error !== null) { | ||
console.log(`exec error: ${error}`) | ||
} | ||
}) | ||
} | ||
}) |
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 |
---|---|---|
|
@@ -11,3 +11,5 @@ export const chains = { | |
[namada.chainId]: namada, | ||
[ethereum.chainId]: ethereum, | ||
}; | ||
|
||
export * from "./types"; |
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,10 @@ | ||
const getProxyURL = (port: number): string => `http://127.0.0.1:${port}/proxy`; | ||
|
||
type ProxiedChains = "namada" | "cosmos" | "ethereum"; | ||
|
||
// Define unique Proxy URLs for each chain: | ||
export const ProxyMappings: Record<ProxiedChains, string> = { | ||
namada: getProxyURL(8010), | ||
cosmos: getProxyURL(8011), | ||
ethereum: getProxyURL(8012), | ||
} |
Oops, something went wrong.