-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): OpenAPI spec update via Stainless API (#169)
- Loading branch information
1 parent
93f5685
commit f241723
Showing
8 changed files
with
234 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 17 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-1f2d42249c93ad113b4057a44678005f58994a6fdddd84db017fae00c68fad87.yml | ||
configured_endpoints: 18 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-c2bb157c4a6c656e82f0321865ffccd9de49cdbe9ac878bd8c412a8ea71c89b7.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import { APIResource } from '../../resource'; | ||
import * as TransactionAPI from './transaction'; | ||
|
||
export class Bitcoin extends APIResource { | ||
transaction: TransactionAPI.Transaction = new TransactionAPI.Transaction(this._client); | ||
} | ||
|
||
export namespace Bitcoin { | ||
export import Transaction = TransactionAPI.Transaction; | ||
export import TransactionScanResponse = TransactionAPI.TransactionScanResponse; | ||
export import TransactionScanParams = TransactionAPI.TransactionScanParams; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
export { Bitcoin } from './bitcoin'; | ||
export { TransactionScanResponse, TransactionScanParams, Transaction } from './transaction'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import { APIResource } from '../../resource'; | ||
import * as Core from '../../core'; | ||
import * as TransactionAPI from './transaction'; | ||
|
||
export class Transaction extends APIResource { | ||
/** | ||
* Scan Transaction | ||
*/ | ||
scan(body: TransactionScanParams, options?: Core.RequestOptions): Core.APIPromise<TransactionScanResponse> { | ||
return this._client.post('/v0/bitcoin/transaction/scan', { body, ...options }); | ||
} | ||
} | ||
|
||
export interface TransactionScanResponse { | ||
/** | ||
* Simulation result; Only present if simulation option is included in the request | ||
*/ | ||
simulation?: | ||
| TransactionScanResponse.BitcoinSimulationSchema | ||
| TransactionScanResponse.BitcoinSimulationErrorSchema | ||
| null; | ||
} | ||
|
||
export namespace TransactionScanResponse { | ||
export interface BitcoinSimulationSchema { | ||
/** | ||
* A dictionary describing the assets differences as a result of this transaction | ||
* for every involved address | ||
*/ | ||
assets_diffs: Record<string, Array<BitcoinSimulationSchema.AssetsDiff>>; | ||
|
||
status?: 'Success'; | ||
} | ||
|
||
export namespace BitcoinSimulationSchema { | ||
export interface AssetsDiff { | ||
/** | ||
* Description of the asset for the current diff | ||
*/ | ||
asset: AssetsDiff.Asset; | ||
|
||
/** | ||
* The assets received by the address | ||
*/ | ||
in?: Array<AssetsDiff.In>; | ||
|
||
/** | ||
* The assets sent by the address | ||
*/ | ||
out?: Array<AssetsDiff.Out>; | ||
} | ||
|
||
export namespace AssetsDiff { | ||
/** | ||
* Description of the asset for the current diff | ||
*/ | ||
export interface Asset { | ||
chain_name: string; | ||
|
||
decimals: number; | ||
|
||
logo_url: string; | ||
|
||
name: string; | ||
|
||
symbol: string; | ||
|
||
type: 'NATIVE' | 'RUNE'; | ||
|
||
id?: string; | ||
|
||
spaced_name?: string; | ||
} | ||
|
||
export interface In { | ||
raw_value?: string; | ||
|
||
summary?: string; | ||
|
||
usd_price?: string; | ||
|
||
value?: string; | ||
} | ||
|
||
export interface Out { | ||
raw_value?: string; | ||
|
||
summary?: string; | ||
|
||
usd_price?: string; | ||
|
||
value?: string; | ||
} | ||
} | ||
} | ||
|
||
export interface BitcoinSimulationErrorSchema { | ||
/** | ||
* Error message | ||
*/ | ||
error: string; | ||
|
||
status?: 'Error'; | ||
} | ||
} | ||
|
||
export interface TransactionScanParams { | ||
/** | ||
* List of options to include in the response | ||
* | ||
* - `simulation`: Include simulation output in the response | ||
*/ | ||
options: Array<'simulation'>; | ||
|
||
/** | ||
* The transaction encoded as a hex string | ||
*/ | ||
transaction: string; | ||
|
||
chain?: 'bitcoin'; | ||
|
||
/** | ||
* Metadata | ||
*/ | ||
metadata?: | ||
| TransactionScanParams.BitcoinInAppRequestMetadata | ||
| TransactionScanParams.BitcoinWalletRequestMetadata; | ||
|
||
/** | ||
* Allows simulating mined transactions where the UTXOs have already been spent | ||
*/ | ||
skip_utxo_check?: boolean; | ||
} | ||
|
||
export namespace TransactionScanParams { | ||
export interface BitcoinInAppRequestMetadata { | ||
/** | ||
* Metadata for in-app requests | ||
*/ | ||
type: 'in_app'; | ||
} | ||
|
||
export interface BitcoinWalletRequestMetadata { | ||
/** | ||
* Metadata for wallet requests | ||
*/ | ||
type: 'wallet'; | ||
|
||
/** | ||
* URL of the dApp that originated the transaction | ||
*/ | ||
url: string; | ||
} | ||
} | ||
|
||
export namespace Transaction { | ||
export import TransactionScanResponse = TransactionAPI.TransactionScanResponse; | ||
export import TransactionScanParams = TransactionAPI.TransactionScanParams; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import Blockaid from '@blockaid/client'; | ||
import { Response } from 'node-fetch'; | ||
|
||
const client = new Blockaid({ | ||
apiKey: 'My API Key', | ||
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', | ||
}); | ||
|
||
describe('resource transaction', () => { | ||
test('scan: only required params', async () => { | ||
const responsePromise = client.bitcoin.transaction.scan({ | ||
options: ['simulation'], | ||
transaction: | ||
'0100000001194ebd43f14daef7ea1479a5b694e0cbfe8f036bf8b3debaffb9e7e217b3abf70100000000ffffffff0200e1f505000000001976a9143ec6c3ed8dfc3ceabcc1cbdb0c5aef4e2d02873c88acdf84448f0c00000017a914e8a4c2bc45640654bb0b915f98c5e72508cff3768700000000', | ||
}); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('scan: required and optional params', async () => { | ||
const response = await client.bitcoin.transaction.scan({ | ||
options: ['simulation'], | ||
transaction: | ||
'0100000001194ebd43f14daef7ea1479a5b694e0cbfe8f036bf8b3debaffb9e7e217b3abf70100000000ffffffff0200e1f505000000001976a9143ec6c3ed8dfc3ceabcc1cbdb0c5aef4e2d02873c88acdf84448f0c00000017a914e8a4c2bc45640654bb0b915f98c5e72508cff3768700000000', | ||
chain: 'bitcoin', | ||
metadata: { type: 'in_app' }, | ||
skip_utxo_check: true, | ||
}); | ||
}); | ||
}); |