From 1ad5f36e8451733d3bce71fda0e6cb44c11295e3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:22:39 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#91) --- .stats.yml | 2 +- api.md | 30 + src/index.ts | 8 + src/resources/index.ts | 8 + src/resources/solana/address.ts | 75 +++ src/resources/solana/index.ts | 12 + src/resources/solana/message.ts | 728 +++++++++++++++++++++ src/resources/solana/solana.ts | 107 +++ tests/api-resources/solana/address.test.ts | 33 + tests/api-resources/solana/message.test.ts | 41 ++ 10 files changed, 1043 insertions(+), 1 deletion(-) create mode 100644 src/resources/solana/address.ts create mode 100644 src/resources/solana/index.ts create mode 100644 src/resources/solana/message.ts create mode 100644 src/resources/solana/solana.ts create mode 100644 tests/api-resources/solana/address.test.ts create mode 100644 tests/api-resources/solana/message.test.ts diff --git a/.stats.yml b/.stats.yml index ad96084..30599f2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 10 +configured_endpoints: 12 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-f88dc435e11134e1b575820cd27672e8e6c42b53abef807cb8d0d4851a64c86b.yml diff --git a/api.md b/api.md index ca0a9e2..fb01449 100644 --- a/api.md +++ b/api.md @@ -77,6 +77,36 @@ Methods: - client.evm.postTransactionBulk.scan({ ...params }) -> PostTransactionBulkScanResponse +# Solana + +Types: + +- AssetTransferDetailsSchema +- CnftDetailsSchema +- NativeSolDetailsSchema +- SplFungibleTokenDetailsSchema +- SplNonFungibleTokenDetailsSchema + +## Message + +Types: + +- MessageScanResponse + +Methods: + +- client.solana.message.scan({ ...params }) -> MessageScanResponse + +## Address + +Types: + +- AddressScanResponse + +Methods: + +- client.solana.address.scan({ ...params }) -> AddressScanResponse + # Stellar Types: diff --git a/src/index.ts b/src/index.ts index e01bdca..d32705f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -120,6 +120,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); site: API.Site = new API.Site(this); token: API.Token = new API.Token(this); @@ -210,6 +211,13 @@ export namespace Blockaid { export import TransactionValidationError = API.TransactionValidationError; export import UsdDiff = API.UsdDiff; + export import Solana = API.Solana; + export import AssetTransferDetailsSchema = API.AssetTransferDetailsSchema; + export import CnftDetailsSchema = API.CnftDetailsSchema; + export import NativeSolDetailsSchema = API.NativeSolDetailsSchema; + export import SplFungibleTokenDetailsSchema = API.SplFungibleTokenDetailsSchema; + export import SplNonFungibleTokenDetailsSchema = API.SplNonFungibleTokenDetailsSchema; + export import Stellar = API.Stellar; export import StellarAssetContractDetailsSchema = API.StellarAssetContractDetailsSchema; export import StellarAssetTransferDetailsSchema = API.StellarAssetTransferDetailsSchema; diff --git a/src/resources/index.ts b/src/resources/index.ts index 46933c8..2a570d3 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -30,6 +30,14 @@ export { UsdDiff, Evm, } from './evm/evm'; +export { + AssetTransferDetailsSchema, + CnftDetailsSchema, + NativeSolDetailsSchema, + SplFungibleTokenDetailsSchema, + SplNonFungibleTokenDetailsSchema, + Solana, +} from './solana/solana'; export { SiteScanHitResponse, SiteScanMissResponse, SiteScanResponse, SiteScanParams, Site } from './site'; export { StellarAssetContractDetailsSchema, diff --git a/src/resources/solana/address.ts b/src/resources/solana/address.ts new file mode 100644 index 0000000..f194bef --- /dev/null +++ b/src/resources/solana/address.ts @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '@blockaid/client/resource'; +import * as Core from '@blockaid/client/core'; +import * as AddressAPI from '@blockaid/client/resources/solana/address'; + +export class Address extends APIResource { + /** + * Gets an address and returns a full security assessment indicating weather or not + * this address is malicious as well as textual reasons of why the address was + * flagged that way. + */ + scan(body: AddressScanParams, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post('/v0/solana/address/scan', { body, ...options }); + } +} + +export interface AddressScanResponse { + /** + * Features about the result + */ + features: Array; + + /** + * An enumeration. + */ + result_type: 'Malicious' | 'Warning' | 'Benign'; +} + +export namespace AddressScanResponse { + export interface Feature { + /** + * Description of the feature + */ + description: string; + + /** + * ID of the feature + */ + feature_id: string; + + /** + * An enumeration. + */ + type: 'Malicious' | 'Warning' | 'Benign' | 'Info'; + } +} + +export interface AddressScanParams { + /** + * Encoded public key + */ + address: string; + + metadata: AddressScanParams.Metadata; + + /** + * Chain to scan the transaction on + */ + chain?: string; +} + +export namespace AddressScanParams { + export interface Metadata { + /** + * URL of the dApp related to the address + */ + url: string; + } +} + +export namespace Address { + export import AddressScanResponse = AddressAPI.AddressScanResponse; + export import AddressScanParams = AddressAPI.AddressScanParams; +} diff --git a/src/resources/solana/index.ts b/src/resources/solana/index.ts new file mode 100644 index 0000000..438533a --- /dev/null +++ b/src/resources/solana/index.ts @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { AddressScanResponse, AddressScanParams, Address } from './address'; +export { + AssetTransferDetailsSchema, + CnftDetailsSchema, + NativeSolDetailsSchema, + SplFungibleTokenDetailsSchema, + SplNonFungibleTokenDetailsSchema, + Solana, +} from './solana'; +export { MessageScanResponse, MessageScanParams, Message } from './message'; diff --git a/src/resources/solana/message.ts b/src/resources/solana/message.ts new file mode 100644 index 0000000..be56a68 --- /dev/null +++ b/src/resources/solana/message.ts @@ -0,0 +1,728 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '@blockaid/client/resource'; +import * as Core from '@blockaid/client/core'; +import * as MessageAPI from '@blockaid/client/resources/solana/message'; +import * as SolanaAPI from '@blockaid/client/resources/solana/solana'; + +export class Message extends APIResource { + /** + * Scan Messages + */ + scan(body: MessageScanParams, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post('/v0/solana/message/scan', { body, ...options }); + } +} + +export interface MessageScanResponse { + /** + * Encoding of the public keys + */ + encoding?: string; + + /** + * Error message if the simulation failed + */ + error?: string | null; + + /** + * Summary of the result + */ + result?: MessageScanResponse.Result | null; +} + +export namespace MessageScanResponse { + /** + * Summary of the result + */ + export interface Result { + /** + * Transaction validation result + */ + validation: Result.Validation; + + /** + * Transaction simulation result + */ + simulation?: Result.Simulation | null; + } + + export namespace Result { + /** + * Transaction validation result + */ + export interface Validation { + /** + * A list of features about this transaction explaining the validation + */ + features: Array; + + /** + * An enumeration. + */ + reason: + | '' + | 'shared_state_in_bulk' + | 'unknown_profiter' + | 'unfair_trade' + | 'transfer_farming' + | 'writable_accounts_farming' + | 'native_ownership_change' + | 'spl_token_ownership_change' + | 'exposure_farming' + | 'known_attacker' + | 'invalid_signature' + | 'other'; + + /** + * An enumeration. + */ + verdict: 'Benign' | 'Warning' | 'Malicious'; + } + + /** + * Transaction simulation result + */ + export interface Simulation { + /** + * Summary of the requested account address + */ + account_summary: Simulation.AccountSummary; + + /** + * Summary of the accounts involved in the transaction simulation + */ + accounts_details: Array< + | Simulation.SystemAccountDetailsSchema + | Simulation.TokenAccountDetailsSchema + | Simulation.FungibleMintAccountDetailsSchema + | Simulation.NonFungibleMintAccountDetailsSchema + | Simulation.ProgramAccountDetailsSchema + | Simulation.PdaAccountSchema + | Simulation.CnftMintAccountDetailsSchema + >; + + /** + * Summary of the assets involved in the transaction simulation + */ + assets_diff: Record< + string, + Array< + | Simulation.NativeSolDiffSchema + | Simulation.SplFungibleTokenDiffSchema + | Simulation.SplNonFungibleTokenDiffSchema + | Simulation.CnftDiffSchema + > + >; + + /** + * Summary of ownership changes; By account address + */ + assets_ownership_diff: Record< + string, + Array< + | Simulation.NativeSolOwnershipDiffSchema + | Simulation.SplTokenOwnershipDiffSchema + | Simulation.StakedSolWithdrawAuthorityDiffSchema + > + >; + + /** + * Summary of the delegations, by account address + */ + delegations: Record>; + } + + export namespace Simulation { + /** + * Summary of the requested account address + */ + export interface AccountSummary { + /** + * Total USD diff for the requested account address + */ + total_usd_diff: AccountSummary.TotalUsdDiff; + + /** + * Assets diff of the requested account address + */ + account_assets_diff?: Array< + | AccountSummary.NativeSolDiffSchema + | AccountSummary.SplFungibleTokenDiffSchema + | AccountSummary.SplNonFungibleTokenDiffSchema + | AccountSummary.CnftDiffSchema + >; + + /** + * Delegated assets of the requested account address + */ + account_delegations?: Array; + + /** + * Account ownerships diff of the requested account address + */ + account_ownerships_diff?: Array< + | AccountSummary.NativeSolOwnershipDiffSchema + | AccountSummary.SplTokenOwnershipDiffSchema + | AccountSummary.StakedSolWithdrawAuthorityDiffSchema + >; + } + + 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 NativeSolDiffSchema { + asset: SolanaAPI.NativeSolDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface SplFungibleTokenDiffSchema { + asset: SolanaAPI.SplFungibleTokenDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface SplNonFungibleTokenDiffSchema { + asset: SolanaAPI.SplNonFungibleTokenDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface CnftDiffSchema { + asset: SolanaAPI.CnftDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface AccountDelegation { + asset: + | SolanaAPI.SplFungibleTokenDetailsSchema + | SolanaAPI.SplNonFungibleTokenDetailsSchema + | SolanaAPI.CnftDetailsSchema; + + /** + * The delegate's address + */ + delegate: string; + + /** + * Details of the delegation + */ + delegation: SolanaAPI.AssetTransferDetailsSchema; + } + + export interface NativeSolOwnershipDiffSchema { + asset: SolanaAPI.NativeSolDetailsSchema; + + /** + * The owner post the transaction + */ + post_owner: string; + + /** + * Incoming transfers of the asset + */ + in_?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * Details of the moved value + */ + out?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * The owner prior to the transaction + */ + pre_owner?: string | null; + } + + export interface SplTokenOwnershipDiffSchema { + asset: SolanaAPI.SplFungibleTokenDetailsSchema | SolanaAPI.SplNonFungibleTokenDetailsSchema; + + /** + * The owner post the transaction + */ + post_owner: string; + + /** + * Incoming transfers of the asset + */ + in_?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * Details of the moved value + */ + out?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * The owner prior to the transaction + */ + pre_owner?: string | null; + } + + export interface StakedSolWithdrawAuthorityDiffSchema { + /** + * The owner post the transaction + */ + post_owner: string; + + asset?: StakedSolWithdrawAuthorityDiffSchema.Asset; + + /** + * Incoming transfers of the asset + */ + in_?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * Details of the moved value + */ + out?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * The owner prior to the transaction + */ + pre_owner?: string | null; + } + + export namespace StakedSolWithdrawAuthorityDiffSchema { + export interface Asset { + decimals?: number; + + /** + * Type of the asset (`"STAKED_SOL"`) + */ + type?: string; + } + } + } + + export interface SystemAccountDetailsSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + + type?: 'SYSTEM_ACCOUNT'; + } + + export interface TokenAccountDetailsSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * Encoded public key of the mint + */ + mint_address: string; + + /** + * Encoded public key of the owner + */ + owner_address: string; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + + type?: 'TOKEN_ACCOUNT'; + } + + export interface FungibleMintAccountDetailsSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * Name of the mint + */ + name: string; + + /** + * Symbol of the mint + */ + symbol: string; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + + /** + * Logo of the mint + */ + logo?: string; + + type?: 'FUNGIBLE_MINT_ACCOUNT'; + } + + export interface NonFungibleMintAccountDetailsSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * Name of the mint + */ + name: string; + + /** + * Symbol of the mint + */ + symbol: string; + + /** + * URI of the mint + */ + uri: string; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + + /** + * Logo of the mint + */ + logo?: string; + + type?: 'NON_FUNGIBLE_MINT_ACCOUNT'; + } + + export interface ProgramAccountDetailsSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + type: 'PROGRAM' | 'NATIVE_PROGRAM'; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + } + + export interface PdaAccountSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * The address of the owning program + */ + owner: string; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + + type?: 'PDA'; + } + + export interface CnftMintAccountDetailsSchema { + /** + * Encoded public key of the account + */ + account_address: string; + + /** + * Name of the mint + */ + name: string; + + /** + * Symbol of the mint + */ + symbol: string; + + /** + * URI of the mint + */ + uri: string; + + /** + * Whether the account had been written to during the simulation + */ + was_written_to: boolean; + + /** + * Description of the account + */ + description?: string | null; + + /** + * Logo of the mint + */ + logo?: string; + + type?: 'CNFT_MINT_ACCOUNT'; + } + + export interface NativeSolDiffSchema { + asset: SolanaAPI.NativeSolDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface SplFungibleTokenDiffSchema { + asset: SolanaAPI.SplFungibleTokenDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface SplNonFungibleTokenDiffSchema { + asset: SolanaAPI.SplNonFungibleTokenDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface CnftDiffSchema { + asset: SolanaAPI.CnftDetailsSchema; + + /** + * Incoming transfers of the asset + */ + in?: SolanaAPI.AssetTransferDetailsSchema | null; + + out?: SolanaAPI.AssetTransferDetailsSchema | null; + } + + export interface NativeSolOwnershipDiffSchema { + asset: SolanaAPI.NativeSolDetailsSchema; + + /** + * The owner post the transaction + */ + post_owner: string; + + /** + * Incoming transfers of the asset + */ + in_?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * Details of the moved value + */ + out?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * The owner prior to the transaction + */ + pre_owner?: string | null; + } + + export interface SplTokenOwnershipDiffSchema { + asset: SolanaAPI.SplFungibleTokenDetailsSchema | SolanaAPI.SplNonFungibleTokenDetailsSchema; + + /** + * The owner post the transaction + */ + post_owner: string; + + /** + * Incoming transfers of the asset + */ + in_?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * Details of the moved value + */ + out?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * The owner prior to the transaction + */ + pre_owner?: string | null; + } + + export interface StakedSolWithdrawAuthorityDiffSchema { + /** + * The owner post the transaction + */ + post_owner: string; + + asset?: StakedSolWithdrawAuthorityDiffSchema.Asset; + + /** + * Incoming transfers of the asset + */ + in_?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * Details of the moved value + */ + out?: SolanaAPI.AssetTransferDetailsSchema | null; + + /** + * The owner prior to the transaction + */ + pre_owner?: string | null; + } + + export namespace StakedSolWithdrawAuthorityDiffSchema { + export interface Asset { + decimals?: number; + + /** + * Type of the asset (`"STAKED_SOL"`) + */ + type?: string; + } + } + + export interface Delegation { + asset: + | SolanaAPI.SplFungibleTokenDetailsSchema + | SolanaAPI.SplNonFungibleTokenDetailsSchema + | SolanaAPI.CnftDetailsSchema; + + /** + * The delegate's address + */ + delegate: string; + + /** + * Details of the delegation + */ + delegation: SolanaAPI.AssetTransferDetailsSchema; + } + } + } +} + +export interface MessageScanParams { + /** + * Encoded public key of the account to simulate the transaction on + */ + account_address: string; + + metadata: MessageScanParams.Metadata; + + /** + * Transactions to scan + */ + transactions: Array; + + /** + * Chain to scan the transaction on + */ + chain?: string; + + /** + * Encoding of the transaction and public keys + */ + encoding?: string; + + /** + * The RPC method used by dApp to propose the transaction + */ + method?: string; +} + +export namespace MessageScanParams { + export interface Metadata { + /** + * URL of the dApp that originated the transaction + */ + url?: string | null; + } +} + +export namespace Message { + export import MessageScanResponse = MessageAPI.MessageScanResponse; + export import MessageScanParams = MessageAPI.MessageScanParams; +} diff --git a/src/resources/solana/solana.ts b/src/resources/solana/solana.ts new file mode 100644 index 0000000..2fffded --- /dev/null +++ b/src/resources/solana/solana.ts @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '@blockaid/client/resource'; +import * as SolanaAPI from '@blockaid/client/resources/solana/solana'; +import * as AddressAPI from '@blockaid/client/resources/solana/address'; +import * as MessageAPI from '@blockaid/client/resources/solana/message'; + +export class Solana extends APIResource { + message: MessageAPI.Message = new MessageAPI.Message(this._client); + address: AddressAPI.Address = new AddressAPI.Address(this._client); +} + +export interface AssetTransferDetailsSchema { + /** + * Raw value of the transfer + */ + raw_value: number; + + /** + * Value of the transfer + */ + value: number; + + /** + * Summarized description of the transfer + */ + summary?: string | null; + + /** + * USD price of the asset + */ + usd_price?: number | null; +} + +export interface CnftDetailsSchema { + address: string; + + decimals: number; + + name: string; + + symbol: string; + + logo?: string; + + /** + * Type of the asset (`"CNFT"`) + */ + type?: string; +} + +export interface NativeSolDetailsSchema { + decimals?: number; + + /** + * Type of the asset (`"SOL"`) + */ + type?: string; +} + +export interface SplFungibleTokenDetailsSchema { + address: string; + + decimals: number; + + name: string; + + symbol: string; + + logo?: string; + + /** + * Type of the asset (`"TOKEN"`) + */ + type?: string; +} + +export interface SplNonFungibleTokenDetailsSchema { + address: string; + + name: string; + + symbol: string; + + decimals?: number; + + logo?: string; + + /** + * Type of the asset (`"NFT"`) + */ + type?: string; +} + +export namespace Solana { + export import AssetTransferDetailsSchema = SolanaAPI.AssetTransferDetailsSchema; + export import CnftDetailsSchema = SolanaAPI.CnftDetailsSchema; + export import NativeSolDetailsSchema = SolanaAPI.NativeSolDetailsSchema; + export import SplFungibleTokenDetailsSchema = SolanaAPI.SplFungibleTokenDetailsSchema; + export import SplNonFungibleTokenDetailsSchema = SolanaAPI.SplNonFungibleTokenDetailsSchema; + export import Message = MessageAPI.Message; + export import MessageScanResponse = MessageAPI.MessageScanResponse; + export import MessageScanParams = MessageAPI.MessageScanParams; + export import Address = AddressAPI.Address; + export import AddressScanResponse = AddressAPI.AddressScanResponse; + export import AddressScanParams = AddressAPI.AddressScanParams; +} diff --git a/tests/api-resources/solana/address.test.ts b/tests/api-resources/solana/address.test.ts new file mode 100644 index 0000000..6323789 --- /dev/null +++ b/tests/api-resources/solana/address.test.ts @@ -0,0 +1,33 @@ +// 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 address', () => { + test('scan: only required params', async () => { + const responsePromise = blockaid.solana.address.scan({ + address: '2ojv9BAiHUrvsm9gxDe7fJSzbNZSJcxZvf8dqmWGHG8S', + metadata: { url: 'https://example.com' }, + }); + 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.solana.address.scan({ + address: '2ojv9BAiHUrvsm9gxDe7fJSzbNZSJcxZvf8dqmWGHG8S', + metadata: { url: 'https://example.com' }, + chain: 'mainnet', + }); + }); +}); diff --git a/tests/api-resources/solana/message.test.ts b/tests/api-resources/solana/message.test.ts new file mode 100644 index 0000000..be4e254 --- /dev/null +++ b/tests/api-resources/solana/message.test.ts @@ -0,0 +1,41 @@ +// 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 message', () => { + test('scan: only required params', async () => { + const responsePromise = blockaid.solana.message.scan({ + account_address: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY', + metadata: {}, + transactions: [ + 'vxBNpvao9QJmLKXUThbbjRnxm3ufu4Wku97kHd5a67FDjSqeHwcPrBKTjAHp4ECr61eWwoxvUEVTuuWX65P9bCNDJrTJpX64vjdtpHA8cogA4C92Ubj813wUUA8Ey4Bvcrdj5c1bSTCv27zKyx1AHWDepVVoS5ZV2Sb3Nuw8RGrmjsZgU3hvPzE9hRBosY25Xpbyqo4b3Vr1BLfrVRBqsz7PvB74APZ7dHxfH49Xb2edrFS2DZ84SwtsZYLyTGF5wtZ6WHWiZN3ixjKGMAh5NLNmT9imKMBgtxuTMAw', + ], + }); + 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.solana.message.scan({ + account_address: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY', + metadata: { url: 'https://example.com' }, + transactions: [ + 'vxBNpvao9QJmLKXUThbbjRnxm3ufu4Wku97kHd5a67FDjSqeHwcPrBKTjAHp4ECr61eWwoxvUEVTuuWX65P9bCNDJrTJpX64vjdtpHA8cogA4C92Ubj813wUUA8Ey4Bvcrdj5c1bSTCv27zKyx1AHWDepVVoS5ZV2Sb3Nuw8RGrmjsZgU3hvPzE9hRBosY25Xpbyqo4b3Vr1BLfrVRBqsz7PvB74APZ7dHxfH49Xb2edrFS2DZ84SwtsZYLyTGF5wtZ6WHWiZN3ixjKGMAh5NLNmT9imKMBgtxuTMAw', + ], + chain: 'mainnet', + encoding: 'base58', + method: 'signAndSendTransaction', + }); + }); +});