From 319bc69256c3b78bb85fbc5a920d268ced13e969 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 19:14:10 +0000 Subject: [PATCH] feat(api): manual updates (#314) --- .stats.yml | 2 +- api.md | 17 +- src/index.ts | 26 +- src/resources/bitcoin/bitcoin.ts | 10 +- src/resources/bitcoin/index.ts | 8 +- src/resources/bitcoin/transaction.ts | 83 +++ src/resources/index.ts | 13 +- src/resources/starknet/index.ts | 13 +- src/resources/starknet/starknet.ts | 77 +- src/resources/starknet/transaction.ts | 679 +++++++++++++++++- src/resources/stellar/index.ts | 12 +- src/resources/stellar/stellar.ts | 59 +- src/resources/stellar/transaction.ts | 463 +++++++++++- .../api-resources/bitcoin/transaction.test.ts | 23 + .../starknet/transaction.test.ts | 23 + .../api-resources/stellar/transaction.test.ts | 23 + 16 files changed, 1321 insertions(+), 210 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0bcc787e..75064ee7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 19 +configured_endpoints: 22 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-9074805d4822d26da6e3f769edeb3bb4294de7586358fa0a4901990a405ab1e9.yml diff --git a/api.md b/api.md index d35b281b..b18549b8 100644 --- a/api.md +++ b/api.md @@ -134,19 +134,16 @@ Methods: # Stellar -Types: - -- StellarAssetContractDetailsSchema -- StellarAssetTransferDetailsSchema - ## Transaction Types: +- TransactionReportResponse - TransactionScanResponse Methods: +- client.stellar.transaction.report({ ...params }) -> TransactionReportResponse - client.stellar.transaction.scan({ ...params }) -> TransactionScanResponse # Bitcoin @@ -155,28 +152,26 @@ Methods: Types: +- TransactionReportResponse - TransactionScanResponse Methods: +- client.bitcoin.transaction.report({ ...params }) -> TransactionReportResponse - client.bitcoin.transaction.scan({ ...params }) -> TransactionScanResponse # Starknet -Types: - -- StarknetErc1155Diff -- StarknetErc20Diff -- StarknetErc721Diff - ## Transaction Types: +- TransactionReportResponse - TransactionScanResponse Methods: +- client.starknet.transaction.report({ ...params }) -> TransactionReportResponse - client.starknet.transaction.scan({ ...params }) -> TransactionScanResponse # Site diff --git a/src/index.ts b/src/index.ts index 0eafdf11..b12339db 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,17 +81,8 @@ import { TxScanRequestSchema, ValidationFeature, } from './resources/solana/solana'; -import { - Starknet, - StarknetErc1155Diff, - StarknetErc20Diff, - StarknetErc721Diff, -} from './resources/starknet/starknet'; -import { - Stellar, - StellarAssetContractDetailsSchema, - StellarAssetTransferDetailsSchema, -} from './resources/stellar/stellar'; +import { Starknet } from './resources/starknet/starknet'; +import { Stellar } from './resources/stellar/stellar'; const environments = { production: 'https://api.blockaid.io', @@ -392,20 +383,11 @@ export declare namespace Blockaid { type ValidationFeature as ValidationFeature, }; - export { - Stellar as Stellar, - type StellarAssetContractDetailsSchema as StellarAssetContractDetailsSchema, - type StellarAssetTransferDetailsSchema as StellarAssetTransferDetailsSchema, - }; + export { Stellar as Stellar }; export { Bitcoin as Bitcoin }; - export { - Starknet as Starknet, - type StarknetErc1155Diff as StarknetErc1155Diff, - type StarknetErc20Diff as StarknetErc20Diff, - type StarknetErc721Diff as StarknetErc721Diff, - }; + export { Starknet as Starknet }; export { Site as Site, diff --git a/src/resources/bitcoin/bitcoin.ts b/src/resources/bitcoin/bitcoin.ts index e6ba4f57..e77dbbcd 100644 --- a/src/resources/bitcoin/bitcoin.ts +++ b/src/resources/bitcoin/bitcoin.ts @@ -2,7 +2,13 @@ import { APIResource } from '../../resource'; import * as TransactionAPI from './transaction'; -import { Transaction, TransactionScanParams, TransactionScanResponse } from './transaction'; +import { + Transaction, + TransactionReportParams, + TransactionReportResponse, + TransactionScanParams, + TransactionScanResponse, +} from './transaction'; export class Bitcoin extends APIResource { transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client); @@ -13,7 +19,9 @@ Bitcoin.Transaction = Transaction; export declare namespace Bitcoin { export { Transaction as Transaction, + type TransactionReportResponse as TransactionReportResponse, type TransactionScanResponse as TransactionScanResponse, + type TransactionReportParams as TransactionReportParams, type TransactionScanParams as TransactionScanParams, }; } diff --git a/src/resources/bitcoin/index.ts b/src/resources/bitcoin/index.ts index 5692cbb7..e259b401 100644 --- a/src/resources/bitcoin/index.ts +++ b/src/resources/bitcoin/index.ts @@ -1,4 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { Bitcoin } from './bitcoin'; -export { Transaction, type TransactionScanResponse, type TransactionScanParams } from './transaction'; +export { + Transaction, + type TransactionReportResponse, + type TransactionScanResponse, + type TransactionReportParams, + type TransactionScanParams, +} from './transaction'; diff --git a/src/resources/bitcoin/transaction.ts b/src/resources/bitcoin/transaction.ts index 09d0ba87..7054426e 100644 --- a/src/resources/bitcoin/transaction.ts +++ b/src/resources/bitcoin/transaction.ts @@ -4,6 +4,16 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; export class Transaction extends APIResource { + /** + * Report Transaction + */ + report( + body: TransactionReportParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post('/v0/bitcoin/transaction/report', { body, ...options }); + } + /** * Scan Transaction */ @@ -12,6 +22,8 @@ export class Transaction extends APIResource { } } +export type TransactionReportResponse = number; + export interface TransactionScanResponse { /** * Simulation result; Only present if simulation option is included in the request @@ -441,6 +453,75 @@ export namespace TransactionScanResponse { } } +export interface TransactionReportParams { + details: string; + + event: 'should_be_malicious' | 'should_be_benign'; + + report: + | TransactionReportParams.BitcoinAppealRequestID + | TransactionReportParams.BitcoinAppealTransactionDataReport; +} + +export namespace TransactionReportParams { + export interface BitcoinAppealRequestID { + id: string; + + type?: 'request_id'; + } + + export interface BitcoinAppealTransactionDataReport { + params: BitcoinAppealTransactionDataReport.Params; + + type?: 'params'; + } + + export namespace BitcoinAppealTransactionDataReport { + export interface Params { + account_address: string; + + chain: 'bitcoin'; + + /** + * Metadata + */ + metadata: Params.BitcoinWalletRequestMetadata | Params.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 Params { + 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 interface TransactionScanParams { account_address: string; @@ -488,7 +569,9 @@ export namespace TransactionScanParams { export declare namespace Transaction { export { + type TransactionReportResponse as TransactionReportResponse, type TransactionScanResponse as TransactionScanResponse, + type TransactionReportParams as TransactionReportParams, type TransactionScanParams as TransactionScanParams, }; } diff --git a/src/resources/index.ts b/src/resources/index.ts index 8beaaa19..0e60defe 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -68,17 +68,8 @@ export { type TxScanRequestSchema, type ValidationFeature, } from './solana/solana'; -export { - Starknet, - type StarknetErc1155Diff, - type StarknetErc20Diff, - type StarknetErc721Diff, -} from './starknet/starknet'; -export { - Stellar, - type StellarAssetContractDetailsSchema, - type StellarAssetTransferDetailsSchema, -} from './stellar/stellar'; +export { Starknet } from './starknet/starknet'; +export { Stellar } from './stellar/stellar'; export { Token, type TokenReportResponse, diff --git a/src/resources/starknet/index.ts b/src/resources/starknet/index.ts index 40596a5a..f0a05636 100644 --- a/src/resources/starknet/index.ts +++ b/src/resources/starknet/index.ts @@ -1,9 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export { Starknet } from './starknet'; export { - Starknet, - type StarknetErc1155Diff, - type StarknetErc20Diff, - type StarknetErc721Diff, -} from './starknet'; -export { Transaction, type TransactionScanResponse, type TransactionScanParams } from './transaction'; + Transaction, + type TransactionReportResponse, + type TransactionScanResponse, + type TransactionReportParams, + type TransactionScanParams, +} from './transaction'; diff --git a/src/resources/starknet/starknet.ts b/src/resources/starknet/starknet.ts index a3a33651..e680c4bc 100644 --- a/src/resources/starknet/starknet.ts +++ b/src/resources/starknet/starknet.ts @@ -2,85 +2,26 @@ import { APIResource } from '../../resource'; import * as TransactionAPI from './transaction'; -import { Transaction, TransactionScanParams, TransactionScanResponse } from './transaction'; +import { + Transaction, + TransactionReportParams, + TransactionReportResponse, + TransactionScanParams, + TransactionScanResponse, +} from './transaction'; export class Starknet extends APIResource { transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client); } -export interface StarknetErc1155Diff { - /** - * Token ID of the transfer - */ - token_id: string; - - /** - * USD price of the asset - */ - usd_price: string; - - /** - * Value of the transfer - */ - value: number; - - /** - * Summarized description of the transfer - */ - summary?: string | null; -} - -export interface StarknetErc20Diff { - /** - * 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 StarknetErc721Diff { - /** - * Token ID of the transfer - */ - token_id: string; - - /** - * USD price of the asset - */ - usd_price: string; - - /** - * Summarized description of the transfer - */ - summary?: string | null; -} - Starknet.Transaction = Transaction; export declare namespace Starknet { - export { - type StarknetErc1155Diff as StarknetErc1155Diff, - type StarknetErc20Diff as StarknetErc20Diff, - type StarknetErc721Diff as StarknetErc721Diff, - }; - export { Transaction as Transaction, + type TransactionReportResponse as TransactionReportResponse, type TransactionScanResponse as TransactionScanResponse, + type TransactionReportParams as TransactionReportParams, type TransactionScanParams as TransactionScanParams, }; } diff --git a/src/resources/starknet/transaction.ts b/src/resources/starknet/transaction.ts index 6b2a999b..ce8bd5b2 100644 --- a/src/resources/starknet/transaction.ts +++ b/src/resources/starknet/transaction.ts @@ -2,9 +2,18 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; -import * as StarknetAPI from './starknet'; export class Transaction extends APIResource { + /** + * Report Transaction + */ + report( + body: TransactionReportParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post('/v0/starknet/transaction/report', { body, ...options }); + } + /** * Scan Transactions */ @@ -13,6 +22,8 @@ export class Transaction extends APIResource { } } +export type TransactionReportResponse = number; + export interface TransactionScanResponse { /** * Simulation result; Only present if simulation option is included in the request @@ -162,7 +173,7 @@ export namespace TransactionScanResponse { */ approval: string; - exposure: Array; + exposure: Array; /** * Expiration date of the approval @@ -174,6 +185,30 @@ export namespace TransactionScanResponse { */ summary?: string | null; } + + export namespace Spenders { + export interface Exposure { + /** + * 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 StarknetErc721Exposure { @@ -214,7 +249,7 @@ export namespace TransactionScanResponse { } export interface Spenders { - exposure: Array; + exposure: Array; /** * Whether `setApprovalForAll` was invoked @@ -226,6 +261,25 @@ export namespace TransactionScanResponse { */ summary?: string | null; } + + export namespace Spenders { + export interface Exposure { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } } export interface StarknetErc1155Exposure { @@ -266,7 +320,7 @@ export namespace TransactionScanResponse { } export interface Spenders { - exposure: Array; + exposure: Array; /** * Whether `setApprovalForAll` was invoked @@ -278,6 +332,30 @@ export namespace TransactionScanResponse { */ summary?: string | null; } + + export namespace Spenders { + export interface Exposure { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } } /** @@ -311,12 +389,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StarknetAPI.StarknetErc20Diff | null; + in?: StarknetErc20AssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StarknetAPI.StarknetErc20Diff | null; + out?: StarknetErc20AssetDiff.Out | null; } export namespace StarknetErc20AssetDiff { @@ -351,6 +429,56 @@ export namespace TransactionScanResponse { */ type?: 'ERC20'; } + + /** + * 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 StarknetErc721AssetDiff { @@ -364,12 +492,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StarknetAPI.StarknetErc721Diff | null; + in?: StarknetErc721AssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StarknetAPI.StarknetErc721Diff | null; + out?: StarknetErc721AssetDiff.Out | null; } export namespace StarknetErc721AssetDiff { @@ -399,6 +527,46 @@ export namespace TransactionScanResponse { */ type?: 'ERC721'; } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Token ID of the transfer + */ + token_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 { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } } export interface StarknetErc1155AssetDiff { @@ -412,12 +580,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StarknetAPI.StarknetErc1155Diff | null; + in?: StarknetErc1155AssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StarknetAPI.StarknetErc1155Diff | null; + out?: StarknetErc1155AssetDiff.Out | null; } export namespace StarknetErc1155AssetDiff { @@ -447,6 +615,56 @@ export namespace TransactionScanResponse { */ type?: 'ERC1155'; } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + + /** + * Details of the outgoing transfer + */ + export interface Out { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } } } @@ -473,12 +691,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StarknetAPI.StarknetErc20Diff | null; + in?: StarknetErc20AssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StarknetAPI.StarknetErc20Diff | null; + out?: StarknetErc20AssetDiff.Out | null; } export namespace StarknetErc20AssetDiff { @@ -513,6 +731,56 @@ export namespace TransactionScanResponse { */ type?: 'ERC20'; } + + /** + * 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 StarknetErc721AssetDiff { @@ -526,12 +794,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StarknetAPI.StarknetErc721Diff | null; + in?: StarknetErc721AssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StarknetAPI.StarknetErc721Diff | null; + out?: StarknetErc721AssetDiff.Out | null; } export namespace StarknetErc721AssetDiff { @@ -561,6 +829,46 @@ export namespace TransactionScanResponse { */ type?: 'ERC721'; } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Token ID of the transfer + */ + token_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 { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } } export interface StarknetErc1155AssetDiff { @@ -574,12 +882,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StarknetAPI.StarknetErc1155Diff | null; + in?: StarknetErc1155AssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StarknetAPI.StarknetErc1155Diff | null; + out?: StarknetErc1155AssetDiff.Out | null; } export namespace StarknetErc1155AssetDiff { @@ -609,6 +917,56 @@ export namespace TransactionScanResponse { */ type?: 'ERC1155'; } + + /** + * Details of the incoming transfer + */ + export interface In { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + + /** + * Details of the outgoing transfer + */ + export interface Out { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } } export interface StarknetErc20Exposure { @@ -659,7 +1017,7 @@ export namespace TransactionScanResponse { */ approval: string; - exposure: Array; + exposure: Array; /** * Expiration date of the approval @@ -671,6 +1029,30 @@ export namespace TransactionScanResponse { */ summary?: string | null; } + + export namespace Spenders { + export interface Exposure { + /** + * 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 StarknetErc721Exposure { @@ -711,7 +1093,7 @@ export namespace TransactionScanResponse { } export interface Spenders { - exposure: Array; + exposure: Array; /** * Whether `setApprovalForAll` was invoked @@ -723,6 +1105,25 @@ export namespace TransactionScanResponse { */ summary?: string | null; } + + export namespace Spenders { + export interface Exposure { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } } export interface StarknetErc1155Exposure { @@ -763,7 +1164,7 @@ export namespace TransactionScanResponse { } export interface Spenders { - exposure: Array; + exposure: Array; /** * Whether `setApprovalForAll` was invoked @@ -775,6 +1176,30 @@ export namespace TransactionScanResponse { */ summary?: string | null; } + + export namespace Spenders { + export interface Exposure { + /** + * Token ID of the transfer + */ + token_id: string; + + /** + * USD price of the asset + */ + usd_price: string; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + } + } } } @@ -846,6 +1271,220 @@ export namespace TransactionScanResponse { } } +export interface TransactionReportParams { + details: string; + + event: 'should_be_malicious' | 'should_be_benign'; + + report: + | TransactionReportParams.StarknetAppealRequestID + | TransactionReportParams.StarknetAppealTransactionDataReport; +} + +export namespace TransactionReportParams { + export interface StarknetAppealRequestID { + id: string; + + type?: 'request_id'; + } + + export interface StarknetAppealTransactionDataReport { + params: StarknetAppealTransactionDataReport.Params; + + type?: 'params'; + } + + export namespace StarknetAppealTransactionDataReport { + export interface Params { + account_address: string; + + /** + * The chain name or chain ID + */ + chain: 'mainnet' | 'sepolia' | 'sepolia_integration' | (string & {}); + + /** + * Metadata + */ + metadata: Params.StarknetWalletRequestMetadata | Params.StarknetInAppRequestMetadata; + + transaction: + | Params.StarknetInvokeV1TransactionSchema + | Params.StarknetInvokeV3TransactionSchema + | Params.StarknetDeployAccountV1TransactionSchema + | Params.StarknetDeployAccountV3TransactionSchema; + + /** + * Optional block number or tag context for the simulation + */ + block_number?: string | null; + + /** + * 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 Params { + export interface StarknetWalletRequestMetadata { + /** + * Metadata for wallet requests + */ + type: 'wallet'; + + /** + * URL of the dApp originating the transaction + */ + url: string; + } + + export interface StarknetInAppRequestMetadata { + /** + * Metadata for in-app requests + */ + type?: 'in_app'; + } + + export interface StarknetInvokeV1TransactionSchema { + /** + * The maximum fee that the sender is willing to pay. + */ + max_fee: string; + + /** + * The nonce of the transaction. + */ + nonce: string; + + /** + * The address of the sender. + */ + sender_address: string; + + /** + * The version of the transaction. + */ + version: 1; + + /** + * The arguments that are passed to the validate and execute functions. + */ + calldata?: Array; + } + + export interface StarknetInvokeV3TransactionSchema { + /** + * The arguments that are passed to the validate and execute functions. + */ + calldata: Array; + + /** + * The id of the chain to which the transaction is sent. + */ + chain_id: string; + + /** + * The nonce of the transaction. + */ + nonce: string; + + /** + * The address of the sender. + */ + sender_address: string; + + /** + * The version of the transaction. + */ + version: 3; + + /** + * For future use. Currently this value is always empty. + */ + account_deployment_data?: Array; + + /** + * The nonce data availability mode. + */ + nonce_data_availability_mode?: 0; + + /** + * For future use. Currently this value is always empty. + */ + paymaster_data?: Array; + } + + export interface StarknetDeployAccountV1TransactionSchema { + /** + * The hash of the contract class. + */ + class_hash: string; + + /** + * The arguments that are passed to the constructor function. + */ + constructor_calldata: Array; + + /** + * The salt of the contract address. + */ + contract_address_salt: string; + + /** + * The maximum fee that the sender is willing to pay. + */ + max_fee: string; + + /** + * The nonce of the transaction. + */ + nonce: string; + + /** + * The version of the transaction. + */ + version: 1; + } + + export interface StarknetDeployAccountV3TransactionSchema { + /** + * The hash of the contract class. + */ + class_hash: string; + + /** + * The arguments that are passed to the constructor function. + */ + constructor_calldata: Array; + + /** + * The salt of the contract address. + */ + contract_address_salt: string; + + /** + * The maximum fee that the sender is willing to pay. + */ + max_fee: string; + + /** + * The nonce of the transaction. + */ + nonce: string; + + /** + * The version of the transaction. + */ + version: 3; + } + } + } +} + export interface TransactionScanParams { account_address: string; @@ -1038,7 +1677,9 @@ export namespace TransactionScanParams { export declare namespace Transaction { export { + type TransactionReportResponse as TransactionReportResponse, type TransactionScanResponse as TransactionScanResponse, + type TransactionReportParams as TransactionReportParams, type TransactionScanParams as TransactionScanParams, }; } diff --git a/src/resources/stellar/index.ts b/src/resources/stellar/index.ts index 80722a0c..66f5663d 100644 --- a/src/resources/stellar/index.ts +++ b/src/resources/stellar/index.ts @@ -1,8 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export { Stellar } from './stellar'; export { - Stellar, - type StellarAssetContractDetailsSchema, - type StellarAssetTransferDetailsSchema, -} from './stellar'; -export { Transaction, type TransactionScanResponse, type TransactionScanParams } from './transaction'; + Transaction, + type TransactionReportResponse, + type TransactionScanResponse, + type TransactionReportParams, + type TransactionScanParams, +} from './transaction'; diff --git a/src/resources/stellar/stellar.ts b/src/resources/stellar/stellar.ts index 497d7ee5..a2e48da1 100644 --- a/src/resources/stellar/stellar.ts +++ b/src/resources/stellar/stellar.ts @@ -2,67 +2,26 @@ import { APIResource } from '../../resource'; import * as TransactionAPI from './transaction'; -import { Transaction, TransactionScanParams, TransactionScanResponse } from './transaction'; +import { + Transaction, + TransactionReportParams, + TransactionReportResponse, + TransactionScanParams, + TransactionScanResponse, +} from './transaction'; export class Stellar extends APIResource { transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client); } -export interface StellarAssetContractDetailsSchema { - /** - * Address of the asset's contract - */ - address: string; - - /** - * Asset code - */ - name: string; - - /** - * Asset symbol - */ - symbol: string; - - /** - * Type of the asset (`CONTRACT`) - */ - type?: 'CONTRACT'; -} - -export interface StellarAssetTransferDetailsSchema { - /** - * 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; -} - Stellar.Transaction = Transaction; export declare namespace Stellar { - export { - type StellarAssetContractDetailsSchema as StellarAssetContractDetailsSchema, - type StellarAssetTransferDetailsSchema as StellarAssetTransferDetailsSchema, - }; - export { Transaction as Transaction, + type TransactionReportResponse as TransactionReportResponse, type TransactionScanResponse as TransactionScanResponse, + type TransactionReportParams as TransactionReportParams, type TransactionScanParams as TransactionScanParams, }; } diff --git a/src/resources/stellar/transaction.ts b/src/resources/stellar/transaction.ts index d297eacc..eb81e4bd 100644 --- a/src/resources/stellar/transaction.ts +++ b/src/resources/stellar/transaction.ts @@ -2,9 +2,18 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; -import * as StellarAPI from './stellar'; export class Transaction extends APIResource { + /** + * Report Transaction + */ + report( + body: TransactionReportParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post('/v0/stellar/transaction/report', { body, ...options }); + } + /** * Scan Transaction */ @@ -13,6 +22,8 @@ export class Transaction extends APIResource { } } +export type TransactionReportResponse = number; + export interface TransactionScanResponse { /** * Simulation result; Only present if simulation option is included in the request @@ -308,12 +319,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StellarAPI.StellarAssetTransferDetailsSchema | null; + in?: StellarLegacyAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StellarAPI.StellarAssetTransferDetailsSchema | null; + out?: StellarLegacyAssetDiff.Out | null; } export namespace StellarLegacyAssetDiff { @@ -343,6 +354,56 @@ export namespace TransactionScanResponse { */ type?: 'ASSET'; } + + /** + * 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 StellarNativeAssetDiff { @@ -356,12 +417,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StellarAPI.StellarAssetTransferDetailsSchema | null; + in?: StellarNativeAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StellarAPI.StellarAssetTransferDetailsSchema | null; + out?: StellarNativeAssetDiff.Out | null; } export namespace StellarNativeAssetDiff { @@ -376,10 +437,60 @@ export namespace TransactionScanResponse { */ 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 StellarContractAssetDiff { - asset: StellarAPI.StellarAssetContractDetailsSchema; + asset: StellarContractAssetDiff.Asset; /** * The type of the assets in this diff @@ -389,12 +500,86 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StellarAPI.StellarAssetTransferDetailsSchema | null; + in?: StellarContractAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StellarAPI.StellarAssetTransferDetailsSchema | null; + out?: StellarContractAssetDiff.Out | null; + } + + export namespace StellarContractAssetDiff { + export interface Asset { + /** + * Address of the asset's contract + */ + address: string; + + /** + * Asset code + */ + name: string; + + /** + * Asset symbol + */ + symbol: string; + + /** + * Type of the asset (`CONTRACT`) + */ + type?: 'CONTRACT'; + } + + /** + * 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; + } } } @@ -435,12 +620,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StellarAPI.StellarAssetTransferDetailsSchema | null; + in?: StellarLegacyAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StellarAPI.StellarAssetTransferDetailsSchema | null; + out?: StellarLegacyAssetDiff.Out | null; } export namespace StellarLegacyAssetDiff { @@ -470,6 +655,56 @@ export namespace TransactionScanResponse { */ type?: 'ASSET'; } + + /** + * 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 StellarNativeAssetDiff { @@ -483,12 +718,12 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StellarAPI.StellarAssetTransferDetailsSchema | null; + in?: StellarNativeAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StellarAPI.StellarAssetTransferDetailsSchema | null; + out?: StellarNativeAssetDiff.Out | null; } export namespace StellarNativeAssetDiff { @@ -503,10 +738,60 @@ export namespace TransactionScanResponse { */ 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 StellarContractAssetDiff { - asset: StellarAPI.StellarAssetContractDetailsSchema; + asset: StellarContractAssetDiff.Asset; /** * The type of the assets in this diff @@ -516,12 +801,86 @@ export namespace TransactionScanResponse { /** * Details of the incoming transfer */ - in?: StellarAPI.StellarAssetTransferDetailsSchema | null; + in?: StellarContractAssetDiff.In | null; /** * Details of the outgoing transfer */ - out?: StellarAPI.StellarAssetTransferDetailsSchema | null; + out?: StellarContractAssetDiff.Out | null; + } + + export namespace StellarContractAssetDiff { + export interface Asset { + /** + * Address of the asset's contract + */ + address: string; + + /** + * Asset code + */ + name: string; + + /** + * Asset symbol + */ + symbol: string; + + /** + * Type of the asset (`CONTRACT`) + */ + type?: 'CONTRACT'; + } + + /** + * 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 StellarLegacyAssetExposure { @@ -740,6 +1099,78 @@ export namespace TransactionScanResponse { } } +export interface TransactionReportParams { + details: string; + + event: 'should_be_malicious' | 'should_be_benign'; + + report: + | TransactionReportParams.StellarAppealRequestID + | TransactionReportParams.StellarAppealTransactionDataReport; +} + +export namespace TransactionReportParams { + export interface StellarAppealRequestID { + id: string; + + type?: 'request_id'; + } + + export interface StellarAppealTransactionDataReport { + params: StellarAppealTransactionDataReport.Params; + + type?: 'params'; + } + + export namespace StellarAppealTransactionDataReport { + export interface Params { + account_address: string; + + /** + * A CAIP-2 chain ID or a Stellar network name + */ + chain: 'pubnet' | 'futurenet' | 'testnet'; + + /** + * Metadata + */ + metadata: Params.StellarWalletRequestMetadata | Params.StellarInAppRequestMetadata; + + 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 Params { + export interface StellarWalletRequestMetadata { + /** + * Metadata for wallet requests + */ + type: 'wallet'; + + /** + * URL of the dApp originating the transaction + */ + url: string; + } + + export interface StellarInAppRequestMetadata { + /** + * Metadata for in-app requests + */ + type?: 'in_app'; + } + } + } +} + export interface TransactionScanParams { account_address: string; @@ -790,7 +1221,9 @@ export namespace TransactionScanParams { export declare namespace Transaction { export { + type TransactionReportResponse as TransactionReportResponse, type TransactionScanResponse as TransactionScanResponse, + type TransactionReportParams as TransactionReportParams, type TransactionScanParams as TransactionScanParams, }; } diff --git a/tests/api-resources/bitcoin/transaction.test.ts b/tests/api-resources/bitcoin/transaction.test.ts index 16e50953..55196b47 100644 --- a/tests/api-resources/bitcoin/transaction.test.ts +++ b/tests/api-resources/bitcoin/transaction.test.ts @@ -9,6 +9,29 @@ const client = new Blockaid({ }); describe('resource transaction', () => { + test('report: only required params', async () => { + const responsePromise = client.bitcoin.transaction.report({ + details: 'details', + event: 'should_be_malicious', + report: { id: 'id' }, + }); + 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('report: required and optional params', async () => { + const response = await client.bitcoin.transaction.report({ + details: 'details', + event: 'should_be_malicious', + report: { id: 'id', type: 'request_id' }, + }); + }); + test('scan: only required params', async () => { const responsePromise = client.bitcoin.transaction.scan({ account_address: 'account_address', diff --git a/tests/api-resources/starknet/transaction.test.ts b/tests/api-resources/starknet/transaction.test.ts index cdd0d343..92070907 100644 --- a/tests/api-resources/starknet/transaction.test.ts +++ b/tests/api-resources/starknet/transaction.test.ts @@ -9,6 +9,29 @@ const client = new Blockaid({ }); describe('resource transaction', () => { + test('report: only required params', async () => { + const responsePromise = client.starknet.transaction.report({ + details: 'details', + event: 'should_be_malicious', + report: { id: 'id' }, + }); + 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('report: required and optional params', async () => { + const response = await client.starknet.transaction.report({ + details: 'details', + event: 'should_be_malicious', + report: { id: 'id', type: 'request_id' }, + }); + }); + test('scan: only required params', async () => { const responsePromise = client.starknet.transaction.scan({ account_address: '0x62a2959fa6502b30cbfb51199fbbe72e72ee4f5a86ec754b4172c7d7beb6ff4', diff --git a/tests/api-resources/stellar/transaction.test.ts b/tests/api-resources/stellar/transaction.test.ts index 529fd3d5..3cb0f617 100644 --- a/tests/api-resources/stellar/transaction.test.ts +++ b/tests/api-resources/stellar/transaction.test.ts @@ -9,6 +9,29 @@ const client = new Blockaid({ }); describe('resource transaction', () => { + test('report: only required params', async () => { + const responsePromise = client.stellar.transaction.report({ + details: 'details', + event: 'should_be_malicious', + report: { id: 'id' }, + }); + 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('report: required and optional params', async () => { + const response = await client.stellar.transaction.report({ + details: 'details', + event: 'should_be_malicious', + report: { id: 'id', type: 'request_id' }, + }); + }); + test('scan: only required params', async () => { const responsePromise = client.stellar.transaction.scan({ account_address: 'GDPMFLKUGASUTWBN2XGYYKD27QGHCYH4BUFUTER4L23INYQ4JHDWFOIE',