-
Notifications
You must be signed in to change notification settings - Fork 1
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
Enable specifying api key in config #18
Changes from all commits
1c39536
5a3f513
d4f1f01
06ab9a8
56b9e54
9bc5814
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 |
---|---|---|
|
@@ -59,7 +59,8 @@ | |
}, | ||
"scripts": { | ||
"prepublishOnly": "npm run build", | ||
"test": "npm run test:browser && mocha --exit", | ||
"test": "npm run test:browser && npm run test:mocha", | ||
"test:mocha": "mocha --exit", | ||
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. I added this command to make it easier for devs to just run the mocha tests since the browser tests take so long. |
||
"test:browser": "npx playwright install --with-deps && PW_TS_ESM_ON=true playwright test", | ||
"test:browser-show-report": "npx playwright show-report", | ||
"test:ci": "npm run coverage", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import fs from "node:fs"; | ||
import { type WaitableTransactionReceipt } from "../registry/utils.js"; | ||
import { type FetchConfig } from "../validator/client/index.js"; | ||
import { type ChainName, getBaseUrl } from "./chains.js"; | ||
import { type Signer, type ExternalProvider, getSigner } from "./ethers.js"; | ||
|
||
export interface ReadConfig { | ||
baseUrl: string; | ||
aliases?: AliasesNameMap; | ||
apiKey?: string; | ||
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. The usage is now:
|
||
} | ||
|
||
export interface SignerConfig { | ||
|
@@ -98,3 +100,16 @@ export function jsonFileAliases(filepath: string): AliasesNameMap { | |
}, | ||
}; | ||
} | ||
|
||
export function prepReadConfig(config: Partial<ReadConfig>): FetchConfig { | ||
const conf: FetchConfig = {}; | ||
if (config.apiKey) { | ||
conf.init = { | ||
headers: { | ||
"Api-Key": config.apiKey, | ||
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. This is the bulk of the logic. Take the |
||
}, | ||
}; | ||
} | ||
|
||
return { ...config, ...conf }; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { type Signal } from "../helpers/await.js"; | ||
import { type Signal } from "../helpers/index.js"; | ||
import { type FetchConfig, type Paths, getFetcher } from "./client/index.js"; | ||
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. unrelated cleanup |
||
import { hoistApiError } from "./errors.js"; | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
"HTTP": { | ||
"Port": "8081", | ||
"RateLimInterval": "1s", | ||
"MaxRequestPerInterval": 10 | ||
"MaxRequestPerInterval": 10, | ||
"APIKey": "foo" | ||
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. Keeping the tests simple for the time being. The api key is always going to be "foo" As an aside in regard to the api key implementation in the validator... Since the key is a fixed config value we should probably ensure the value is only ever used on the server side of the Studio. 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. Vercel makes it hard to expose secrets to the client. By default all env vars are server side only. You have to opt in to exposing them to the client by prefixing the env var name with |
||
}, | ||
"Gateway": { | ||
"ExternalURIPrefix": "http://localhost:8081", | ||
|
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.
Not related to this PR, but lerna and nx handle the need to build (or not) before running the test. Having this written into the test command was causing issues.