From 390817cc297dbc1555aeae431182dc4dc8fbb3b7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:02:55 +0000 Subject: [PATCH] feat(api): api update (#346) --- .stats.yml | 4 +- api.md | 4 - src/resources/bitcoin/bitcoin.ts | 416 ++++++++++++++++-- src/resources/bitcoin/index.ts | 2 +- src/resources/bitcoin/transaction.ts | 63 +-- .../api-resources/bitcoin/transaction.test.ts | 37 -- 6 files changed, 377 insertions(+), 149 deletions(-) delete mode 100644 tests/api-resources/bitcoin/transaction.test.ts diff --git a/.stats.yml b/.stats.yml index 057bcb15..42a04e63 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 20 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-c50e79bc49d14456290a8db01cefddcd8c5f0f8bc17ae19163784c1e23929708.yml +configured_endpoints: 19 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-57ba1e6bf68e557293babd701bbf3d1b558909f3ad8f0766c3485498e3ab4a2e.yml diff --git a/api.md b/api.md index 79620554..ec33988b 100644 --- a/api.md +++ b/api.md @@ -162,10 +162,6 @@ Types: ## Transaction -Methods: - -- client.bitcoin.transaction.scan({ ...params }) -> BitcoinTransactionScanResponse - # Starknet Types: diff --git a/src/resources/bitcoin/bitcoin.ts b/src/resources/bitcoin/bitcoin.ts index ae9da466..7fc9dc4a 100644 --- a/src/resources/bitcoin/bitcoin.ts +++ b/src/resources/bitcoin/bitcoin.ts @@ -2,7 +2,7 @@ import { APIResource } from '../../resource'; import * as TransactionAPI from './transaction'; -import { Transaction, TransactionScanParams } from './transaction'; +import { Transaction } from './transaction'; export class Bitcoin extends APIResource { transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client); @@ -73,9 +73,13 @@ export interface BitcoinTransactionScanResponse { export namespace BitcoinTransactionScanResponse { export interface BitcoinSimulationResult { - status: 'Success'; + /** + * Summary of the actions and asset transfers that were made by the requested + * account address + */ + account_summary: BitcoinSimulationResult.AccountSummary; - account_summary?: null; + status: 'Success'; /** * Details of addresses involved in the transaction @@ -90,18 +94,354 @@ export namespace BitcoinTransactionScanResponse { string, Array< | BitcoinSimulationResult.BitcoinNativeAssetDiff - | BitcoinSimulationResult.BitcoinOrdinalAssetDiff + | BitcoinSimulationResult.BitcoinInscriptionAssetDiff | BitcoinSimulationResult.BitcoinRunesAssetDiff > >; } export namespace BitcoinSimulationResult { + /** + * Summary of the actions and asset transfers that were made by the requested + * account address + */ + export interface AccountSummary { + /** + * Total USD diff for the requested account address + */ + total_usd_diff: AccountSummary.TotalUsdDiff; + + /** + * Assets diffs of the requested account address + */ + account_assets_diffs?: Array< + | AccountSummary.BitcoinNativeAssetDiff + | AccountSummary.BitcoinInscriptionAssetDiff + | AccountSummary.BitcoinRunesAssetDiff + >; + } + + export namespace AccountSummary { + /** + * Total USD diff for the requested account address + */ + export interface TotalUsdDiff { + /** + * Total incoming USD transfers + */ + in: number; + + /** + * Total outgoing USD transfers + */ + out: number; + + /** + * Total USD transfers + */ + total?: number; + } + + export interface BitcoinNativeAssetDiff { + asset: BitcoinNativeAssetDiff.Asset; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: BitcoinNativeAssetDiff.In | null; + + /** + * Details of the outgoing transfer + */ + out?: BitcoinNativeAssetDiff.Out | null; + } + + export namespace BitcoinNativeAssetDiff { + export interface Asset { + /** + * URL of the asset's logo + */ + logo_url: string | null; + + /** + * Decimals of the asset + */ + decimals?: 8; + + /** + * Name of the asset + */ + name?: 'Bitcoin'; + + /** + * Symbol of the asset + */ + symbol?: 'BTC'; + + /** + * Type of the asset (`NATIVE`) + */ + type?: 'NATIVE'; + } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Raw value of the transfer + */ + raw_value: number; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + + /** + * Details of the outgoing transfer + */ + export interface Out { + /** + * Raw value of the transfer + */ + raw_value: number; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } + + export interface BitcoinInscriptionAssetDiff { + asset: BitcoinInscriptionAssetDiff.Asset; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: BitcoinInscriptionAssetDiff.In | null; + + /** + * Details of the outgoing transfer + */ + out?: BitcoinInscriptionAssetDiff.Out | null; + } + + export namespace BitcoinInscriptionAssetDiff { + export interface Asset { + /** + * The Inscription ID + */ + id: string; + + /** + * Inscription's display name + */ + name: string; + + /** + * The Inscription sat + */ + sat: number; + + /** + * URL of the asset's logo + */ + logo_url?: string | null; + + /** + * Type of the asset (`INSCRIPTION`) + */ + type?: 'INSCRIPTION'; + } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Inscription ID of the transfer + */ + inscription_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + + /** + * Details of the outgoing transfer + */ + export interface Out { + /** + * Inscription ID of the transfer + */ + inscription_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } + + export interface BitcoinRunesAssetDiff { + asset: BitcoinRunesAssetDiff.Asset; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: BitcoinRunesAssetDiff.In | null; + + /** + * Details of the outgoing transfer + */ + out?: BitcoinRunesAssetDiff.Out | null; + } + + export namespace BitcoinRunesAssetDiff { + export interface Asset { + /** + * The Rune ID + */ + id: string; + + /** + * Decimals of the asset + */ + decimals: number; + + /** + * The Rune name + */ + name: string; + + /** + * The Rune spaced name + */ + spaced_name: string; + + /** + * The Rune's symbol + */ + symbol: string; + + /** + * URL of the asset's logo + */ + logo_url?: string | null; + + /** + * Type of the asset (`RUNE`) + */ + type?: 'RUNE'; + } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Raw value of the transfer + */ + raw_value: number; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + + /** + * Details of the outgoing transfer + */ + export interface Out { + /** + * Raw value of the transfer + */ + raw_value: number; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } + } + export interface AddressDetail { /** * Encoded public key of the account */ - account_address: unknown; + account_address: string; /** * Description of the account @@ -163,7 +503,7 @@ export namespace BitcoinTransactionScanResponse { /** * Raw value of the transfer */ - raw_value: string; + raw_value: number; /** * USD price of the asset @@ -188,7 +528,7 @@ export namespace BitcoinTransactionScanResponse { /** * Raw value of the transfer */ - raw_value: string; + raw_value: number; /** * USD price of the asset @@ -207,8 +547,8 @@ export namespace BitcoinTransactionScanResponse { } } - export interface BitcoinOrdinalAssetDiff { - asset: BitcoinOrdinalAssetDiff.Asset; + export interface BitcoinInscriptionAssetDiff { + asset: BitcoinInscriptionAssetDiff.Asset; /** * The type of the assets in this diff @@ -218,30 +558,40 @@ export namespace BitcoinTransactionScanResponse { /** * Details of the incoming transfer */ - in?: BitcoinOrdinalAssetDiff.In | null; + in?: BitcoinInscriptionAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: BitcoinOrdinalAssetDiff.Out | null; + out?: BitcoinInscriptionAssetDiff.Out | null; } - export namespace BitcoinOrdinalAssetDiff { + export namespace BitcoinInscriptionAssetDiff { export interface Asset { /** - * token's name + * The Inscription ID + */ + id: string; + + /** + * Inscription's display name */ name: string; + /** + * The Inscription sat + */ + sat: number; + /** * URL of the asset's logo */ logo_url?: string | null; /** - * Type of the asset (`ORDINAL`) + * Type of the asset (`INSCRIPTION`) */ - type?: 'ORDINAL'; + type?: 'INSCRIPTION'; } /** @@ -249,25 +599,15 @@ export namespace BitcoinTransactionScanResponse { */ export interface In { /** - * Id of the ordinal - */ - id: string; - - /** - * Raw value of the transfer + * Inscription ID of the transfer */ - raw_value: string; + inscription_id: string; /** * USD price of the asset */ usd_price: string; - /** - * Value of the transfer - */ - value: string; - /** * Summarized description of the transfer */ @@ -279,25 +619,15 @@ export namespace BitcoinTransactionScanResponse { */ export interface Out { /** - * Id of the ordinal - */ - id: string; - - /** - * Raw value of the transfer + * Inscription ID of the transfer */ - raw_value: string; + inscription_id: string; /** * USD price of the asset */ usd_price: string; - /** - * Value of the transfer - */ - value: string; - /** * Summarized description of the transfer */ @@ -347,7 +677,7 @@ export namespace BitcoinTransactionScanResponse { spaced_name: string; /** - * token's symbol + * The Rune's symbol */ symbol: string; @@ -369,7 +699,7 @@ export namespace BitcoinTransactionScanResponse { /** * Raw value of the transfer */ - raw_value: string; + raw_value: number; /** * USD price of the asset @@ -394,7 +724,7 @@ export namespace BitcoinTransactionScanResponse { /** * Raw value of the transfer */ - raw_value: string; + raw_value: number; /** * USD price of the asset @@ -490,5 +820,5 @@ export declare namespace Bitcoin { type BitcoinTransactionScanResponse as BitcoinTransactionScanResponse, }; - export { Transaction as Transaction, type TransactionScanParams as TransactionScanParams }; + export { Transaction as Transaction }; } diff --git a/src/resources/bitcoin/index.ts b/src/resources/bitcoin/index.ts index e7c7a49b..d7d1abb6 100644 --- a/src/resources/bitcoin/index.ts +++ b/src/resources/bitcoin/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { Bitcoin, type BitcoinTransactionScanRequest, type BitcoinTransactionScanResponse } from './bitcoin'; -export { Transaction, type TransactionScanParams } from './transaction'; +export { Transaction } from './transaction'; diff --git a/src/resources/bitcoin/transaction.ts b/src/resources/bitcoin/transaction.ts index 970a0096..e26967e8 100644 --- a/src/resources/bitcoin/transaction.ts +++ b/src/resources/bitcoin/transaction.ts @@ -1,66 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; -import * as Core from '../../core'; -import * as BitcoinAPI from './bitcoin'; -export class Transaction extends APIResource { - /** - * Scan Transaction - */ - scan( - body: TransactionScanParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - return this._client.post('/v0/bitcoin/transaction/scan', { body, ...options }); - } -} - -export interface TransactionScanParams { - account_address: string; - - chain: 'bitcoin'; - - /** - * Metadata - */ - metadata: - | TransactionScanParams.BitcoinWalletRequestMetadata - | TransactionScanParams.BitcoinInAppRequestMetadata; - - transaction: string; - - /** - * List of options to include in the response - * - * - `Options.validation`: Include Options.validation output in the response - * - * - `Options.simulation`: Include Options.simulation output in the response - */ - options?: Array<'validation' | 'simulation'>; -} - -export namespace TransactionScanParams { - export interface BitcoinWalletRequestMetadata { - /** - * Metadata for wallet requests - */ - type: 'wallet'; - - /** - * URL of the dApp originating the transaction - */ - url: string; - } - - export interface BitcoinInAppRequestMetadata { - /** - * Metadata for in-app requests - */ - type?: 'in_app'; - } -} - -export declare namespace Transaction { - export { type TransactionScanParams as TransactionScanParams }; -} +export class Transaction extends APIResource {} diff --git a/tests/api-resources/bitcoin/transaction.test.ts b/tests/api-resources/bitcoin/transaction.test.ts deleted file mode 100644 index 16e50953..00000000 --- a/tests/api-resources/bitcoin/transaction.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -// 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({ - account_address: 'account_address', - chain: 'bitcoin', - metadata: { type: 'wallet', url: 'url' }, - transaction: 'transaction', - }); - 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({ - account_address: 'account_address', - chain: 'bitcoin', - metadata: { type: 'wallet', url: 'url' }, - transaction: 'transaction', - options: ['validation'], - }); - }); -});