Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 9, 2024
1 parent 4e3d904 commit 3f26f1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-1e3fcd24cde418b0de533a226a10623001aab2c0dd8221042437c17835c816f8.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-8c549964fafb6eec1d347fe094f506716e54c0ab1a8fe374ec0355f67626f7d2.yml
30 changes: 10 additions & 20 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ClientOptions {
/**
* Defaults to process.env['BLOCKAID_CLIENT_API_KEY'].
*/
apiKey?: string | null | undefined;
apiKey?: string | undefined;

/**
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
Expand Down Expand Up @@ -71,14 +71,14 @@ export interface ClientOptions {

/** API Client for interfacing with the Blockaid API. */
export class Blockaid extends Core.APIClient {
apiKey: string | null;
apiKey: string;

private _options: ClientOptions;

/**
* API Client for interfacing with the Blockaid API.
*
* @param {string | null | undefined} [opts.apiKey=process.env['BLOCKAID_CLIENT_API_KEY']]
* @param {string | undefined} [opts.apiKey=process.env['BLOCKAID_CLIENT_API_KEY'] ?? undefined]
* @param {string} [opts.baseURL=process.env['BLOCKAID_BASE_URL'] ?? https://api.blockaid.io] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
Expand All @@ -89,9 +89,15 @@ export class Blockaid extends Core.APIClient {
*/
constructor({
baseURL = Core.readEnv('BLOCKAID_BASE_URL'),
apiKey = Core.readEnv('BLOCKAID_CLIENT_API_KEY') ?? null,
apiKey = Core.readEnv('BLOCKAID_CLIENT_API_KEY'),
...opts
}: ClientOptions = {}) {
if (apiKey === undefined) {
throw new Errors.BlockaidError(
"The BLOCKAID_CLIENT_API_KEY environment variable is missing or empty; either provide it, or instantiate the Blockaid client with an apiKey option, like new Blockaid({ apiKey: 'My API Key' }).",
);
}

const options: ClientOptions = {
apiKey,
...opts,
Expand Down Expand Up @@ -125,23 +131,7 @@ export class Blockaid extends Core.APIClient {
};
}

protected override validateHeaders(headers: Core.Headers, customHeaders: Core.Headers) {
if (this.apiKey && headers['x-api-key']) {
return;
}
if (customHeaders['x-api-key'] === null) {
return;
}

throw new Error(
'Could not resolve authentication method. Expected the apiKey to be set. Or for the "X-API-Key" headers to be explicitly omitted',
);
}

protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
if (this.apiKey == null) {
return {};
}
return { 'X-API-Key': this.apiKey };
}

Expand Down
10 changes: 10 additions & 0 deletions src/resources/evm/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ export interface TransactionValidation {
*/
result_type: 'Benign' | 'Warning' | 'Malicious';

/**
* A string indicating if the simulation was successful or not.
*/
status: 'Success';

/**
* A textual classification that can be presented to the user explaining the
* reason.
Expand Down Expand Up @@ -621,6 +626,11 @@ export interface TransactionValidationError {
* A string indicating if the transaction is safe to sign or not.
*/
result_type: 'Error';

/**
* A string indicating if the simulation was successful or not.
*/
status: 'Success';
}

export interface UsdDiff {
Expand Down

0 comments on commit 3f26f1e

Please sign in to comment.