Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Aug 15, 2024
1 parent 93f5685 commit f241723
Show file tree
Hide file tree
Showing 8 changed files with 234 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: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-1f2d42249c93ad113b4057a44678005f58994a6fdddd84db017fae00c68fad87.yml
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-c2bb157c4a6c656e82f0321865ffccd9de49cdbe9ac878bd8c412a8ea71c89b7.yml
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ Methods:

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

# Bitcoin

## Transaction

Types:

- <code><a href="./src/resources/bitcoin/transaction.ts">TransactionScanResponse</a></code>

Methods:

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

# Site

Types:
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class Blockaid extends Core.APIClient {
evm: API.Evm = new API.Evm(this);
solana: API.Solana = new API.Solana(this);
stellar: API.Stellar = new API.Stellar(this);
bitcoin: API.Bitcoin = new API.Bitcoin(this);
site: API.Site = new API.Site(this);
token: API.Token = new API.Token(this);
tokenBulk: API.TokenBulk = new API.TokenBulk(this);
Expand Down Expand Up @@ -255,6 +256,8 @@ export namespace Blockaid {
export import StellarTransactionScanRequest = API.StellarTransactionScanRequest;
export import StellarTransactionScanResponse = API.StellarTransactionScanResponse;

export import Bitcoin = API.Bitcoin;

export import Site = API.Site;
export import SiteScanHitResponse = API.SiteScanHitResponse;
export import SiteScanMissResponse = API.SiteScanMissResponse;
Expand Down
14 changes: 14 additions & 0 deletions src/resources/bitcoin/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../resource';
import * as TransactionAPI from './transaction';

export class Bitcoin extends APIResource {
transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client);
}

export namespace Bitcoin {
export import Transaction = TransactionAPI.Transaction;
export import TransactionScanResponse = TransactionAPI.TransactionScanResponse;
export import TransactionScanParams = TransactionAPI.TransactionScanParams;
}
4 changes: 4 additions & 0 deletions src/resources/bitcoin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Bitcoin } from './bitcoin';
export { TransactionScanResponse, TransactionScanParams, Transaction } from './transaction';
161 changes: 161 additions & 0 deletions src/resources/bitcoin/transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TransactionAPI from './transaction';

export class Transaction extends APIResource {
/**
* Scan Transaction
*/
scan(body: TransactionScanParams, options?: Core.RequestOptions): Core.APIPromise<TransactionScanResponse> {
return this._client.post('/v0/bitcoin/transaction/scan', { body, ...options });
}
}

export interface TransactionScanResponse {
/**
* Simulation result; Only present if simulation option is included in the request
*/
simulation?:
| TransactionScanResponse.BitcoinSimulationSchema
| TransactionScanResponse.BitcoinSimulationErrorSchema
| null;
}

export namespace TransactionScanResponse {
export interface BitcoinSimulationSchema {
/**
* A dictionary describing the assets differences as a result of this transaction
* for every involved address
*/
assets_diffs: Record<string, Array<BitcoinSimulationSchema.AssetsDiff>>;

status?: 'Success';
}

export namespace BitcoinSimulationSchema {
export interface AssetsDiff {
/**
* Description of the asset for the current diff
*/
asset: AssetsDiff.Asset;

/**
* The assets received by the address
*/
in?: Array<AssetsDiff.In>;

/**
* The assets sent by the address
*/
out?: Array<AssetsDiff.Out>;
}

export namespace AssetsDiff {
/**
* Description of the asset for the current diff
*/
export interface Asset {
chain_name: string;

decimals: number;

logo_url: string;

name: string;

symbol: string;

type: 'NATIVE' | 'RUNE';

id?: string;

spaced_name?: string;
}

export interface In {
raw_value?: string;

summary?: string;

usd_price?: string;

value?: string;
}

export interface Out {
raw_value?: string;

summary?: string;

usd_price?: string;

value?: string;
}
}
}

export interface BitcoinSimulationErrorSchema {
/**
* Error message
*/
error: string;

status?: 'Error';
}
}

export interface TransactionScanParams {
/**
* List of options to include in the response
*
* - `simulation`: Include simulation output in the response
*/
options: Array<'simulation'>;

/**
* The transaction encoded as a hex string
*/
transaction: string;

chain?: 'bitcoin';

/**
* Metadata
*/
metadata?:
| TransactionScanParams.BitcoinInAppRequestMetadata
| TransactionScanParams.BitcoinWalletRequestMetadata;

/**
* Allows simulating mined transactions where the UTXOs have already been spent
*/
skip_utxo_check?: boolean;
}

export namespace TransactionScanParams {
export interface BitcoinInAppRequestMetadata {
/**
* Metadata for in-app requests
*/
type: 'in_app';
}

export interface BitcoinWalletRequestMetadata {
/**
* Metadata for wallet requests
*/
type: 'wallet';

/**
* URL of the dApp that originated the transaction
*/
url: string;
}
}

export namespace Transaction {
export import TransactionScanResponse = TransactionAPI.TransactionScanResponse;
export import TransactionScanParams = TransactionAPI.TransactionScanParams;
}
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export {
UsdDiff,
Evm,
} from './evm/evm';
export { Bitcoin } from './bitcoin/bitcoin';
export {
SiteScanHitResponse,
SiteScanMissResponse,
Expand Down
37 changes: 37 additions & 0 deletions tests/api-resources/bitcoin/transaction.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

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

describe('resource transaction', () => {
test('scan: only required params', async () => {
const responsePromise = client.bitcoin.transaction.scan({
options: ['simulation'],
transaction:
'0100000001194ebd43f14daef7ea1479a5b694e0cbfe8f036bf8b3debaffb9e7e217b3abf70100000000ffffffff0200e1f505000000001976a9143ec6c3ed8dfc3ceabcc1cbdb0c5aef4e2d02873c88acdf84448f0c00000017a914e8a4c2bc45640654bb0b915f98c5e72508cff3768700000000',
});
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 client.bitcoin.transaction.scan({
options: ['simulation'],
transaction:
'0100000001194ebd43f14daef7ea1479a5b694e0cbfe8f036bf8b3debaffb9e7e217b3abf70100000000ffffffff0200e1f505000000001976a9143ec6c3ed8dfc3ceabcc1cbdb0c5aef4e2d02873c88acdf84448f0c00000017a914e8a4c2bc45640654bb0b915f98c5e72508cff3768700000000',
chain: 'bitcoin',
metadata: { type: 'in_app' },
skip_utxo_check: true,
});
});
});

0 comments on commit f241723

Please sign in to comment.