Update generation of typescript documentation from golang types

This commit is contained in:
Martin Boehm 2023-04-12 23:24:47 +02:00
parent c836bdff1f
commit 41a2c5472b
4 changed files with 19 additions and 18 deletions

View File

@ -230,7 +230,7 @@ type EthereumSpecific struct {
Error string `json:"error,omitempty"` Error string `json:"error,omitempty"`
Nonce uint64 `json:"nonce"` Nonce uint64 `json:"nonce"`
GasLimit *big.Int `json:"gasLimit"` GasLimit *big.Int `json:"gasLimit"`
GasUsed *big.Int `json:"gasUsed"` GasUsed *big.Int `json:"gasUsed,omitempty"`
GasPrice *Amount `json:"gasPrice"` GasPrice *Amount `json:"gasPrice"`
Data string `json:"data,omitempty"` Data string `json:"data,omitempty"`
ParsedData *bchain.EthereumParsedInputData `json:"parsedData,omitempty"` ParsedData *bchain.EthereumParsedInputData `json:"parsedData,omitempty"`

View File

@ -12,7 +12,7 @@ export interface EthereumInternalTransfer {
type: number; type: number;
from: string; from: string;
to: string; to: string;
value?: string; value: string;
} }
export interface EthereumParsedInputParam { export interface EthereumParsedInputParam {
type: string; type: string;
@ -30,9 +30,9 @@ export interface EthereumSpecific {
status: number; status: number;
error?: string; error?: string;
nonce: number; nonce: number;
gasLimit?: string; gasLimit: number;
gasUsed?: string; gasUsed?: number;
gasPrice?: string; gasPrice: string;
data?: string; data?: string;
parsedData?: EthereumParsedInputData; parsedData?: EthereumParsedInputData;
internalTransfers?: EthereumInternalTransfer[]; internalTransfers?: EthereumInternalTransfer[];
@ -93,7 +93,7 @@ export interface Tx {
blockTime: number; blockTime: number;
size?: number; size?: number;
vsize?: number; vsize?: number;
value?: string; value: string;
valueIn?: string; valueIn?: string;
fees?: string; fees?: string;
hex?: string; hex?: string;
@ -105,7 +105,7 @@ export interface Tx {
} }
export interface FeeStats { export interface FeeStats {
txCount: number; txCount: number;
totalFeesSat?: string; totalFeesSat: string;
averageFeePerKb: number; averageFeePerKb: number;
decilesFeePerKb: number[]; decilesFeePerKb: number[];
} }
@ -139,10 +139,10 @@ export interface Address {
totalPages?: number; totalPages?: number;
itemsOnPage?: number; itemsOnPage?: number;
address: string; address: string;
balance?: string; balance: string;
totalReceived?: string; totalReceived?: string;
totalSent?: string; totalSent?: string;
unconfirmedBalance?: string; unconfirmedBalance: string;
unconfirmedTxs: number; unconfirmedTxs: number;
txs: number; txs: number;
nonTokenTxs?: number; nonTokenTxs?: number;
@ -164,7 +164,7 @@ export interface Address {
export interface Utxo { export interface Utxo {
txid: string; txid: string;
vout: number; vout: number;
value?: string; value: string;
height?: number; height?: number;
confirmations: number; confirmations: number;
address?: string; address?: string;
@ -175,9 +175,9 @@ export interface Utxo {
export interface BalanceHistory { export interface BalanceHistory {
time: number; time: number;
txs: number; txs: number;
received?: string; received: string;
sent?: string; sent: string;
sentToSelf?: string; sentToSelf: string;
rates?: { [key: string]: number }; rates?: { [key: string]: number };
txid?: string; txid?: string;
} }
@ -268,8 +268,8 @@ export interface BlockbookInfo {
about: string; about: string;
} }
export interface SystemInfo { export interface SystemInfo {
blockbook?: BlockbookInfo; blockbook: BlockbookInfo;
backend?: BackendInfo; backend: BackendInfo;
} }
export interface FiatTicker { export interface FiatTicker {
ts?: number; ts?: number;
@ -290,6 +290,7 @@ export interface WsReq {
| 'getAccountInfo' | 'getAccountInfo'
| 'getInfo' | 'getInfo'
| 'getBlockHash' | 'getBlockHash'
| 'getBlock'
| 'getAccountUtxo' | 'getAccountUtxo'
| 'getBalanceHistory' | 'getBalanceHistory'
| 'getTransaction' | 'getTransaction'

View File

@ -18,7 +18,7 @@ func main() {
t.ManageType(api.Amount{}, typescriptify.TypeOptions{TSType: "string"}) t.ManageType(api.Amount{}, typescriptify.TypeOptions{TSType: "string"})
t.ManageType([]api.Amount{}, typescriptify.TypeOptions{TSType: "string[]"}) t.ManageType([]api.Amount{}, typescriptify.TypeOptions{TSType: "string[]"})
t.ManageType(big.Int{}, typescriptify.TypeOptions{TSType: "string"}) t.ManageType(big.Int{}, typescriptify.TypeOptions{TSType: "number"})
t.ManageType(time.Time{}, typescriptify.TypeOptions{TSType: "string", TSDoc: "Time in ISO 8601 YYYY-MM-DDTHH:mm:ss.sssZd"}) t.ManageType(time.Time{}, typescriptify.TypeOptions{TSType: "string", TSDoc: "Time in ISO 8601 YYYY-MM-DDTHH:mm:ss.sssZd"})
// API - REST and Websocket // API - REST and Websocket
@ -57,7 +57,7 @@ func main() {
t.Add(server.WsFiatRatesForTimestampsReq{}) t.Add(server.WsFiatRatesForTimestampsReq{})
t.Add(server.WsFiatRatesTickersListReq{}) t.Add(server.WsFiatRatesTickersListReq{})
err := t.ConvertToFile("blockbook-api.d.ts") err := t.ConvertToFile("blockbook-api.ts")
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }

View File

@ -4,7 +4,7 @@ import "encoding/json"
type WsReq struct { type WsReq struct {
ID string `json:"id"` ID string `json:"id"`
Method string `json:"method" ts_type:"'getAccountInfo' | 'getInfo' | 'getBlockHash' | 'getAccountUtxo' | 'getBalanceHistory' | 'getTransaction' | 'getTransactionSpecific' | 'estimateFee' | 'sendTransaction' | 'subscribeNewBlock' | 'unsubscribeNewBlock' | 'subscribeNewTransaction' | 'unsubscribeNewTransaction' | 'subscribeAddresses' | 'unsubscribeAddresses' | 'subscribeFiatRates' | 'unsubscribeFiatRates' | 'ping' | 'getCurrentFiatRates' | 'getFiatRatesForTimestamps' | 'getFiatRatesTickersList'"` Method string `json:"method" ts_type:"'getAccountInfo' | 'getInfo' | 'getBlockHash'| 'getBlock' | 'getAccountUtxo' | 'getBalanceHistory' | 'getTransaction' | 'getTransactionSpecific' | 'estimateFee' | 'sendTransaction' | 'subscribeNewBlock' | 'unsubscribeNewBlock' | 'subscribeNewTransaction' | 'unsubscribeNewTransaction' | 'subscribeAddresses' | 'unsubscribeAddresses' | 'subscribeFiatRates' | 'unsubscribeFiatRates' | 'ping' | 'getCurrentFiatRates' | 'getFiatRatesForTimestamps' | 'getFiatRatesTickersList'"`
Params json.RawMessage `json:"params" ts_type:"any"` Params json.RawMessage `json:"params" ts_type:"any"`
} }