diff --git a/.stats.yml b/.stats.yml index 4f6df839..3b60dd02 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 23 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-d50f8cc3899ed84ed3abf5e5c409455b1bba1f4b013eef0ee0a0b24490e6a366.yml +configured_endpoints: 24 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-92f494420e75bd722cd5c25d16c20b2e6d31b2af1a966ff249dcd4011098691e.yml diff --git a/api.md b/api.md index 3a894672..5f4b01af 100644 --- a/api.md +++ b/api.md @@ -200,6 +200,23 @@ Methods: - client.starknet.transaction.report({ ...params }) -> TransactionReportResponse - client.starknet.transaction.scan({ ...params }) -> StarknetTransactionScanResponse +# Sui + +Types: + +- SuiAssetTransferDetailsSchema +- SuiNativeAssetDetailsSchema +- SuiNFTDetailsSchema +- SuiNFTDiffSchema +- SuiTransactionScanRequest +- SuiTransactionScanResponse + +## Transaction + +Methods: + +- client.sui.transaction.scan({ ...params }) -> SuiTransactionScanResponse + # Site Types: diff --git a/src/index.ts b/src/index.ts index 52266a4b..6ee05497 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,6 +110,15 @@ import { StellarTransactionScanRequest, StellarTransactionScanResponse, } from './resources/stellar/stellar'; +import { + Sui, + SuiAssetTransferDetailsSchema, + SuiNFTDetailsSchema, + SuiNFTDiffSchema, + SuiNativeAssetDetailsSchema, + SuiTransactionScanRequest, + SuiTransactionScanResponse, +} from './resources/sui/sui'; const environments = { production: 'https://api.blockaid.io', @@ -256,6 +265,7 @@ export class Blockaid extends Core.APIClient { stellar: API.Stellar = new API.Stellar(this); bitcoin: API.Bitcoin = new API.Bitcoin(this); starknet: API.Starknet = new API.Starknet(this); + sui: API.Sui = new API.Sui(this); site: API.Site = new API.Site(this); scan: API.Scan = new API.Scan(this); token: API.Token = new API.Token(this); @@ -346,6 +356,7 @@ Blockaid.Solana = Solana; Blockaid.Stellar = Stellar; Blockaid.Bitcoin = Bitcoin; Blockaid.Starknet = Starknet; +Blockaid.Sui = Sui; Blockaid.Site = Site; Blockaid.Scan = Scan; Blockaid.Token = Token; @@ -445,6 +456,16 @@ export declare namespace Blockaid { type StarknetTransactionScanResponse as StarknetTransactionScanResponse, }; + export { + Sui as Sui, + type SuiAssetTransferDetailsSchema as SuiAssetTransferDetailsSchema, + type SuiNativeAssetDetailsSchema as SuiNativeAssetDetailsSchema, + type SuiNFTDetailsSchema as SuiNFTDetailsSchema, + type SuiNFTDiffSchema as SuiNFTDiffSchema, + type SuiTransactionScanRequest as SuiTransactionScanRequest, + type SuiTransactionScanResponse as SuiTransactionScanResponse, + }; + export { Site as Site, type SiteScanHitResponse as SiteScanHitResponse, diff --git a/src/resources/index.ts b/src/resources/index.ts index ddb58cde..b53ff59d 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -97,6 +97,15 @@ export { type StellarTransactionScanRequest, type StellarTransactionScanResponse, } from './stellar/stellar'; +export { + Sui, + type SuiAssetTransferDetailsSchema, + type SuiNativeAssetDetailsSchema, + type SuiNFTDetailsSchema, + type SuiNFTDiffSchema, + type SuiTransactionScanRequest, + type SuiTransactionScanResponse, +} from './sui/sui'; export { Token, type TokenReportResponse, diff --git a/src/resources/sui/index.ts b/src/resources/sui/index.ts new file mode 100644 index 00000000..adee5f4c --- /dev/null +++ b/src/resources/sui/index.ts @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + Sui, + type SuiAssetTransferDetailsSchema, + type SuiNativeAssetDetailsSchema, + type SuiNFTDetailsSchema, + type SuiNFTDiffSchema, + type SuiTransactionScanRequest, + type SuiTransactionScanResponse, +} from './sui'; +export { Transaction, type TransactionScanParams } from './transaction'; diff --git a/src/resources/sui/sui.ts b/src/resources/sui/sui.ts new file mode 100644 index 00000000..fa2f45ce --- /dev/null +++ b/src/resources/sui/sui.ts @@ -0,0 +1,529 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as SuiAPI from './sui'; +import * as TransactionAPI from './transaction'; +import { Transaction, TransactionScanParams } from './transaction'; + +export class Sui extends APIResource { + transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client); +} + +export interface SuiAssetTransferDetailsSchema { + /** + * Raw value of the transfer + */ + raw_value: number; + + /** + * Value of the transfer + */ + value: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + + /** + * USD price of the asset + */ + usd_price?: number | null; +} + +export interface SuiNativeAssetDetailsSchema { + /** + * URL of the asset's logo + */ + logo_url: string | null; + + /** + * Decimals of the asset + */ + decimals?: 9; + + /** + * Name of the asset + */ + name?: 'Sui'; + + /** + * Symbol of the asset + */ + symbol?: 'SUI'; + + /** + * Type of the asset (`NATIVE`) + */ + type?: 'NATIVE'; +} + +export interface SuiNFTDetailsSchema { + /** + * The NFT ID + */ + id: string; + + /** + * The NFT's description + */ + description: string; + + /** + * NFT's display name + */ + name: string; + + /** + * The NFT's collection ID + */ + nft_type: string; + + /** + * Type of the asset (`NFT`) + */ + type?: 'NFT'; + + /** + * URL of the nft's image + */ + url?: string | null; +} + +export interface SuiNFTDiffSchema { + /** + * NFT ID of the transfer + */ + id: string; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + + /** + * USD price of the asset + */ + usd_price?: number | null; +} + +export interface SuiTransactionScanRequest { + account_address: string; + + chain: 'mainnet' | 'testnet' | 'devnet'; + + /** + * Metadata + */ + metadata: + | SuiTransactionScanRequest.SuiWalletRequestMetadata + | SuiTransactionScanRequest.SuiInAppRequestMetadata; + + 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 SuiTransactionScanRequest { + export interface SuiWalletRequestMetadata { + /** + * Metadata for wallet requests + */ + type: 'wallet'; + + /** + * URL of the dApp originating the transaction + */ + url: string; + } + + export interface SuiInAppRequestMetadata { + /** + * Metadata for in-app requests + */ + type?: 'in_app'; + } +} + +export interface SuiTransactionScanResponse { + /** + * Simulation result; Only present if simulation option is included in the request + */ + simulation?: + | SuiTransactionScanResponse.SuiSimulationResult + | SuiTransactionScanResponse.SuiSimulationErrorSchema + | null; + + /** + * Validation result; Only present if validation option is included in the request + */ + validation?: + | SuiTransactionScanResponse.SuiValidationResult + | SuiTransactionScanResponse.SuiValidationErrorSchema + | null; +} + +export namespace SuiTransactionScanResponse { + export interface SuiSimulationResult { + /** + * Summary of the actions and asset transfers that were made by the requested + * account address + */ + account_summary: SuiSimulationResult.AccountSummary; + + status: 'Success'; + + /** + * Details of addresses involved in the transaction + */ + address_details?: Array; + + /** + * Mapping between the address of an account to the assets diff during the + * transaction + */ + assets_diffs?: Record< + string, + Array< + | SuiSimulationResult.SuiNativeAssetDiff + | SuiSimulationResult.SuiNFTAssetDiff + | SuiSimulationResult.SuiCoinsAssetDiff + > + >; + } + + export namespace SuiSimulationResult { + /** + * 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.SuiNativeAssetDiff | AccountSummary.SuiNFTAssetDiff | AccountSummary.SuiCoinsAssetDiff + >; + } + + 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 SuiNativeAssetDiff { + asset: SuiAPI.SuiNativeAssetDetailsSchema; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: SuiAPI.SuiAssetTransferDetailsSchema | null; + + /** + * Details of the outgoing transfer + */ + out?: SuiAPI.SuiAssetTransferDetailsSchema | null; + } + + export interface SuiNFTAssetDiff { + asset: SuiAPI.SuiNFTDetailsSchema; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: SuiAPI.SuiNFTDiffSchema | null; + + /** + * Details of the outgoing transfer + */ + out?: SuiAPI.SuiNFTDiffSchema | null; + } + + export interface SuiCoinsAssetDiff { + asset: SuiCoinsAssetDiff.Asset; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: SuiAPI.SuiAssetTransferDetailsSchema | null; + + /** + * Details of the outgoing transfer + */ + out?: SuiAPI.SuiAssetTransferDetailsSchema | null; + } + + export namespace SuiCoinsAssetDiff { + export interface Asset { + /** + * The Coin ID + */ + id: string; + + /** + * Decimals of the asset + */ + decimals: number; + + /** + * The Coin description + */ + description: string; + + /** + * The Coin name + */ + name: string; + + /** + * The Coin's symbol + */ + symbol: string; + + /** + * URL of the asset's logo + */ + logo_url?: string | null; + + /** + * Type of the asset (`COIN`) + */ + type?: 'COIN'; + } + } + } + + export interface AddressDetail { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * Description of the account + */ + description?: string | null; + } + + export interface SuiNativeAssetDiff { + asset: SuiAPI.SuiNativeAssetDetailsSchema; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: SuiAPI.SuiAssetTransferDetailsSchema | null; + + /** + * Details of the outgoing transfer + */ + out?: SuiAPI.SuiAssetTransferDetailsSchema | null; + } + + export interface SuiNFTAssetDiff { + asset: SuiAPI.SuiNFTDetailsSchema; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: SuiAPI.SuiNFTDiffSchema | null; + + /** + * Details of the outgoing transfer + */ + out?: SuiAPI.SuiNFTDiffSchema | null; + } + + export interface SuiCoinsAssetDiff { + asset: SuiCoinsAssetDiff.Asset; + + /** + * The type of the assets in this diff + */ + asset_type: string; + + /** + * Details of the incoming transfer + */ + in?: SuiAPI.SuiAssetTransferDetailsSchema | null; + + /** + * Details of the outgoing transfer + */ + out?: SuiAPI.SuiAssetTransferDetailsSchema | null; + } + + export namespace SuiCoinsAssetDiff { + export interface Asset { + /** + * The Coin ID + */ + id: string; + + /** + * Decimals of the asset + */ + decimals: number; + + /** + * The Coin description + */ + description: string; + + /** + * The Coin name + */ + name: string; + + /** + * The Coin's symbol + */ + symbol: string; + + /** + * URL of the asset's logo + */ + logo_url?: string | null; + + /** + * Type of the asset (`COIN`) + */ + type?: 'COIN'; + } + } + } + + export interface SuiSimulationErrorSchema { + /** + * Error message + */ + error: string; + + status: 'Error'; + } + + export interface SuiValidationResult { + /** + * A textual classification that can be presented to the user explaining the + * reason. + */ + classification: string; + + /** + * A textual description about the validation result + */ + description: string; + + features: Array; + + /** + * A textual description about the reasons the transaction was flagged with + * result_type + */ + reason: string; + + /** + * Verdict of the validation + */ + result_type: 'Benign' | 'Warning' | 'Malicious'; + + status: 'Success'; + } + + export namespace SuiValidationResult { + export interface Feature { + /** + * Address the feature refers to + */ + address: string; + + /** + * Textual description + */ + description: string; + + feature_id: string; + + /** + * Feature Classification + */ + type: 'Benign' | 'Warning' | 'Malicious' | 'Info'; + } + } + + export interface SuiValidationErrorSchema { + /** + * Error message + */ + error: string; + + status: 'Error'; + } +} + +Sui.Transaction = Transaction; + +export declare namespace Sui { + export { + type SuiAssetTransferDetailsSchema as SuiAssetTransferDetailsSchema, + type SuiNativeAssetDetailsSchema as SuiNativeAssetDetailsSchema, + type SuiNFTDetailsSchema as SuiNFTDetailsSchema, + type SuiNFTDiffSchema as SuiNFTDiffSchema, + type SuiTransactionScanRequest as SuiTransactionScanRequest, + type SuiTransactionScanResponse as SuiTransactionScanResponse, + }; + + export { Transaction as Transaction, type TransactionScanParams as TransactionScanParams }; +} diff --git a/src/resources/sui/transaction.ts b/src/resources/sui/transaction.ts new file mode 100644 index 00000000..2e430ed6 --- /dev/null +++ b/src/resources/sui/transaction.ts @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as SuiAPI from './sui'; + +export class Transaction extends APIResource { + /** + * Scan Transaction + */ + scan( + body: TransactionScanParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post('/v0/sui/transaction/scan', { body, ...options }); + } +} + +export interface TransactionScanParams { + account_address: string; + + chain: 'mainnet' | 'testnet' | 'devnet'; + + /** + * Metadata + */ + metadata: TransactionScanParams.SuiWalletRequestMetadata | TransactionScanParams.SuiInAppRequestMetadata; + + 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 SuiWalletRequestMetadata { + /** + * Metadata for wallet requests + */ + type: 'wallet'; + + /** + * URL of the dApp originating the transaction + */ + url: string; + } + + export interface SuiInAppRequestMetadata { + /** + * Metadata for in-app requests + */ + type?: 'in_app'; + } +} + +export declare namespace Transaction { + export { type TransactionScanParams as TransactionScanParams }; +} diff --git a/tests/api-resources/sui/transaction.test.ts b/tests/api-resources/sui/transaction.test.ts new file mode 100644 index 00000000..a11fa28e --- /dev/null +++ b/tests/api-resources/sui/transaction.test.ts @@ -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.sui.transaction.scan({ + account_address: 'account_address', + chain: 'mainnet', + 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.sui.transaction.scan({ + account_address: 'account_address', + chain: 'mainnet', + metadata: { type: 'wallet', url: 'url' }, + transaction: 'transaction', + options: ['validation'], + }); + }); +});