Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jun 23, 2024
1 parent 2fe2c29 commit 5278cd7
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .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-11c3cc7e2c6dfdbb74ce960248f3c699de8e471595f0bb081f8d2e2da3012417.yml
configured_endpoints: 9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-721caa3b8b8fa19838e91b0b4aa8abc9d4e6694b5f2d14c072a70b3bb9fdafb3.yml
16 changes: 16 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ Methods:

- <code title="post /v0/evm/user-operation/scan">client.evm.userOperation.<a href="./src/resources/evm/user-operation.ts">scan</a>({ ...params }) -> TransactionScanResponse</code>

## PostTransaction

Methods:

- <code title="post /v0/evm/post-transaction/scan">client.evm.postTransaction.<a href="./src/resources/evm/post-transaction.ts">scan</a>({ ...params }) -> TransactionScanResponse</code>

## PostTransactionBulk

Types:

- <code><a href="./src/resources/evm/post-transaction-bulk.ts">PostTransactionBulkScanResponse</a></code>

Methods:

- <code title="post /v0/evm/post-transaction-bulk/scan">client.evm.postTransactionBulk.<a href="./src/resources/evm/post-transaction-bulk.ts">scan</a>({ ...params }) -> PostTransactionBulkScanResponse</code>

# Site

Types:
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 @@ -3,6 +3,8 @@
import { APIResource } from '@blockaid/client/resource';
import * as EvmAPI from '@blockaid/client/resources/evm/evm';
import * as JsonRpcAPI from '@blockaid/client/resources/evm/json-rpc';
import * as PostTransactionAPI from '@blockaid/client/resources/evm/post-transaction';
import * as PostTransactionBulkAPI from '@blockaid/client/resources/evm/post-transaction-bulk';
import * as TransactionAPI from '@blockaid/client/resources/evm/transaction';
import * as TransactionBulkAPI from '@blockaid/client/resources/evm/transaction-bulk';
import * as TransactionRawAPI from '@blockaid/client/resources/evm/transaction-raw';
Expand All @@ -14,6 +16,9 @@ export class Evm extends APIResource {
transactionBulk: TransactionBulkAPI.TransactionBulk = new TransactionBulkAPI.TransactionBulk(this._client);
transactionRaw: TransactionRawAPI.TransactionRaw = new TransactionRawAPI.TransactionRaw(this._client);
userOperation: UserOperationAPI.UserOperation = new UserOperationAPI.UserOperation(this._client);
postTransaction: PostTransactionAPI.PostTransaction = new PostTransactionAPI.PostTransaction(this._client);
postTransactionBulk: PostTransactionBulkAPI.PostTransactionBulk =
new PostTransactionBulkAPI.PostTransactionBulk(this._client);
}

export interface AddressAssetExposure {
Expand Down Expand Up @@ -674,4 +679,9 @@ export namespace Evm {
export import TransactionRawScanParams = TransactionRawAPI.TransactionRawScanParams;
export import UserOperation = UserOperationAPI.UserOperation;
export import UserOperationScanParams = UserOperationAPI.UserOperationScanParams;
export import PostTransaction = PostTransactionAPI.PostTransaction;
export import PostTransactionScanParams = PostTransactionAPI.PostTransactionScanParams;
export import PostTransactionBulk = PostTransactionBulkAPI.PostTransactionBulk;
export import PostTransactionBulkScanResponse = PostTransactionBulkAPI.PostTransactionBulkScanResponse;
export import PostTransactionBulkScanParams = PostTransactionBulkAPI.PostTransactionBulkScanParams;
}
6 changes: 6 additions & 0 deletions src/resources/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export {
Evm,
} from './evm';
export { JsonRpcScanParams, JsonRpc } from './json-rpc';
export {
PostTransactionBulkScanResponse,
PostTransactionBulkScanParams,
PostTransactionBulk,
} from './post-transaction-bulk';
export { PostTransactionScanParams, PostTransaction } from './post-transaction';
export { TransactionBulkScanResponse, TransactionBulkScanParams, TransactionBulk } from './transaction-bulk';
export { TransactionRawScanParams, TransactionRaw } from './transaction-raw';
export { TransactionScanParams, Transaction } from './transaction';
Expand Down
84 changes: 84 additions & 0 deletions src/resources/evm/post-transaction-bulk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@blockaid/client/core';
import { APIResource } from '@blockaid/client/resource';
import * as PostTransactionBulkAPI from '@blockaid/client/resources/evm/post-transaction-bulk';
import * as EvmAPI from '@blockaid/client/resources/evm/evm';

export class PostTransactionBulk extends APIResource {
/**
* Scan transactions that were already executed on chain, returns validation with
* features indicating address poisoning entites and malicious operators.
*/
scan(
body: PostTransactionBulkScanParams,
options?: Core.RequestOptions,
): Core.APIPromise<PostTransactionBulkScanResponse> {
return this._client.post('/v0/evm/post-transaction-bulk/scan', { body, ...options });
}
}

export type PostTransactionBulkScanResponse = Array<EvmAPI.TransactionScanResponse>;

export interface PostTransactionBulkScanParams {
/**
* The chain name or chain ID
*/
chain: EvmAPI.TransactionScanSupportedChain | (string & {});

/**
* Transaction bulk parameters
*/
data: Array<PostTransactionBulkScanParams.Data>;

/**
* Object of additional information to validate against.
*/
metadata: EvmAPI.Metadata;

/**
* List of one or both of options for the desired output. "simulation" - include
* simulation output in your response. "validation" - include security validation
* of the transaction in your response. Default is ["validation"]
*/
options?: Array<'validation' | 'simulation' | 'gas_estimation' | 'events'>;
}

export namespace PostTransactionBulkScanParams {
export interface Data {
/**
* The source address of the transaction in hex string format
*/
from: string;

/**
* The encoded call data of the transaction in hex string format
*/
data?: string;

/**
* The gas required for the transaction in hex string format.
*/
gas?: string;

/**
* The gas price for the transaction in hex string format.
*/
gas_price?: string;

/**
* The destination address of the transaction in hex string format
*/
to?: string;

/**
* The value of the transaction in Wei in hex string format
*/
value?: string;
}
}

export namespace PostTransactionBulk {
export import PostTransactionBulkScanResponse = PostTransactionBulkAPI.PostTransactionBulkScanResponse;
export import PostTransactionBulkScanParams = PostTransactionBulkAPI.PostTransactionBulkScanParams;
}
53 changes: 53 additions & 0 deletions src/resources/evm/post-transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@blockaid/client/core';
import { APIResource } from '@blockaid/client/resource';
import * as PostTransactionAPI from '@blockaid/client/resources/evm/post-transaction';
import * as EvmAPI from '@blockaid/client/resources/evm/evm';

export class PostTransaction extends APIResource {
/**
* Scan a transaction that was already executed on chain, returns validation with
* features indicating address poisoning entites and malicious operators.
*/
scan(
body: PostTransactionScanParams,
options?: Core.RequestOptions,
): Core.APIPromise<EvmAPI.TransactionScanResponse> {
return this._client.post('/v0/evm/post-transaction/scan', { body, ...options });
}
}

export interface PostTransactionScanParams {
/**
* The chain name or chain ID
*/
chain: EvmAPI.TransactionScanSupportedChain | (string & {});

data: PostTransactionScanParams.Data;

/**
* Object of additional information to validate against.
*/
metadata: EvmAPI.Metadata;

/**
* list of one or both of options for the desired output. "simulation" - include
* simulation output in your response. "validation" - include security validation
* of the transaction in your response. Default is ["validation"]
*/
options?: Array<'validation' | 'simulation' | 'gas_estimation' | 'events'>;
}

export namespace PostTransactionScanParams {
export interface Data {
/**
* The transaction hash to scan
*/
tx_hash: string;
}
}

export namespace PostTransaction {
export import PostTransactionScanParams = PostTransactionAPI.PostTransactionScanParams;
}
38 changes: 38 additions & 0 deletions tests/api-resources/evm/post-transaction-bulk.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import Blockaid from '@blockaid/client';
import { Response } from 'node-fetch';

const blockaid = new Blockaid({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource postTransactionBulk', () => {
test('scan: only required params', async () => {
const responsePromise = blockaid.evm.postTransactionBulk.scan({
chain: 'ethereum',
data: [{ from: 'string' }, { from: 'string' }],
metadata: { domain: 'string' },
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('scan: required and optional params', async () => {
const response = await blockaid.evm.postTransactionBulk.scan({
chain: 'ethereum',
data: [
{ from: 'string', to: 'string', data: 'string', value: 'string', gas: 'string', gas_price: 'string' },
{ from: 'string', to: 'string', data: 'string', value: 'string', gas: 'string', gas_price: 'string' },
],
metadata: { domain: 'string' },
options: ['validation', 'simulation'],
});
});
});
35 changes: 35 additions & 0 deletions tests/api-resources/evm/post-transaction.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import Blockaid from '@blockaid/client';
import { Response } from 'node-fetch';

const blockaid = new Blockaid({
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource postTransaction', () => {
test('scan: only required params', async () => {
const responsePromise = blockaid.evm.postTransaction.scan({
chain: 'ethereum',
data: { tx_hash: '0xc01780dadc107754b331250b4797606949cb3d0087facc0a737122d5e973c83c' },
metadata: { domain: 'string' },
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('scan: required and optional params', async () => {
const response = await blockaid.evm.postTransaction.scan({
chain: 'ethereum',
data: { tx_hash: '0xc01780dadc107754b331250b4797606949cb3d0087facc0a737122d5e973c83c' },
metadata: { domain: 'string' },
options: ['validation', 'simulation'],
});
});
});

0 comments on commit 5278cd7

Please sign in to comment.