mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
fix: improve typedefs
Signed-off-by: getlarge <ed@getlarge.eu>
This commit is contained in:
parent
71a231a50a
commit
6aeece49cb
2
types/baseRequest.d.ts
vendored
2
types/baseRequest.d.ts
vendored
@ -26,6 +26,6 @@ declare function handleResponse(res: Response): Response;
|
|||||||
|
|
||||||
export default function baseRequest(
|
export default function baseRequest(
|
||||||
url: string,
|
url: string,
|
||||||
config: RequestConfig = {},
|
config: RequestConfig,
|
||||||
requestTimeout?: number
|
requestTimeout?: number
|
||||||
): Promise<Response>;
|
): Promise<Response>;
|
||||||
|
9
types/connection.d.ts
vendored
9
types/connection.d.ts
vendored
@ -12,7 +12,6 @@ import type {
|
|||||||
TransactionCommon,
|
TransactionCommon,
|
||||||
} from './transaction';
|
} from './transaction';
|
||||||
|
|
||||||
declare const HEADER_BLACKLIST = ['content-type'];
|
|
||||||
declare const DEFAULT_NODE = 'http://localhost:9984/api/v1/';
|
declare const DEFAULT_NODE = 'http://localhost:9984/api/v1/';
|
||||||
declare const DEFAULT_TIMEOUT = 20000; // The default value is 20 seconds
|
declare const DEFAULT_TIMEOUT = 20000; // The default value is 20 seconds
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ export default class Connection {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
nodes: string | InputNode | (string | InputNode)[],
|
nodes: string | InputNode | (string | InputNode)[],
|
||||||
headers: Record<string, string | string[]> = {},
|
headers?: Record<string, string | string[]>,
|
||||||
timeout?: number
|
timeout?: number
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -97,11 +96,11 @@ export default class Connection {
|
|||||||
headers: Record<string, string | string[]>
|
headers: Record<string, string | string[]>
|
||||||
): Node;
|
): Node;
|
||||||
|
|
||||||
static getApiUrls<E = Endpoint>(endpoint: E): EndpointsUrl[E];
|
static getApiUrls<E extends keyof EndpointsUrl>(endpoint: E): EndpointsUrl[E];
|
||||||
|
|
||||||
private _req<E = Endpoint, O = Record<string, any>>(
|
private _req<E extends keyof EndpointsUrl, O = Record<string, any>>(
|
||||||
path: EndpointsUrl[E],
|
path: EndpointsUrl[E],
|
||||||
options: RequestConfig = {}
|
options: RequestConfig
|
||||||
): Promise<O>;
|
): Promise<O>;
|
||||||
|
|
||||||
getBlock(
|
getBlock(
|
||||||
|
4
types/request.d.ts
vendored
4
types/request.d.ts
vendored
@ -17,9 +17,9 @@ export default class Request {
|
|||||||
|
|
||||||
constructor(node: Node);
|
constructor(node: Node);
|
||||||
|
|
||||||
async request<O = Record<string, any>>(
|
request<O = Record<string, any>>(
|
||||||
urlPath: string,
|
urlPath: string,
|
||||||
config: RequestConfig = {},
|
config?: RequestConfig,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
maxBackoffTime?: number
|
maxBackoffTime?: number
|
||||||
): Promise<O>;
|
): Promise<O>;
|
||||||
|
28
types/transaction.d.ts
vendored
28
types/transaction.d.ts
vendored
@ -96,13 +96,23 @@ interface TxTemplate {
|
|||||||
version: '2.0';
|
version: '2.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function DelegateSignFunction(
|
declare type DelegateSignFunction = (
|
||||||
serializedTransaction: string,
|
serializedTransaction: string,
|
||||||
input: TransactionInput,
|
input: TransactionInput,
|
||||||
index?: number
|
index?: number
|
||||||
): string;
|
) => string;
|
||||||
|
|
||||||
|
declare type DelegateSignFunctionAsync = (
|
||||||
|
serializedTransaction: string,
|
||||||
|
input: TransactionInput,
|
||||||
|
index?: number
|
||||||
|
) => Promise<string>;
|
||||||
|
|
||||||
export default class Transaction {
|
export default class Transaction {
|
||||||
|
static serializeTransactionIntoCanonicalString<O = TransactionOperations>(
|
||||||
|
transaction: TransactionCommon<O>
|
||||||
|
): string;
|
||||||
|
|
||||||
static serializeTransactionIntoCanonicalString(
|
static serializeTransactionIntoCanonicalString(
|
||||||
transaction: CreateTransaction | TransferTransaction
|
transaction: CreateTransaction | TransferTransaction
|
||||||
): string;
|
): string;
|
||||||
@ -118,7 +128,7 @@ export default class Transaction {
|
|||||||
|
|
||||||
static makeEd25519Condition(
|
static makeEd25519Condition(
|
||||||
publicKey: string,
|
publicKey: string,
|
||||||
json: boolean = true
|
json?: boolean
|
||||||
): Ed25519Sha256 | Ed25519Sha256JSONCondition;
|
): Ed25519Sha256 | Ed25519Sha256JSONCondition;
|
||||||
|
|
||||||
static makeSha256Condition(preimage: string): PreimageSha256JSONCondition;
|
static makeSha256Condition(preimage: string): PreimageSha256JSONCondition;
|
||||||
@ -132,7 +142,7 @@ export default class Transaction {
|
|||||||
|
|
||||||
static makeSha256Condition(
|
static makeSha256Condition(
|
||||||
preimage: string,
|
preimage: string,
|
||||||
json: boolean = true
|
json?: boolean
|
||||||
): PreimageSha256 | PreimageSha256JSONCondition;
|
): PreimageSha256 | PreimageSha256JSONCondition;
|
||||||
|
|
||||||
static makeThresholdCondition(
|
static makeThresholdCondition(
|
||||||
@ -155,7 +165,7 @@ export default class Transaction {
|
|||||||
static makeThresholdCondition(
|
static makeThresholdCondition(
|
||||||
threshold: number,
|
threshold: number,
|
||||||
subconditions: (string | Fulfillment)[],
|
subconditions: (string | Fulfillment)[],
|
||||||
json: boolean = true
|
json?: boolean
|
||||||
): ThresholdSha256 | ThresholdSha256JSONCondition;
|
): ThresholdSha256 | ThresholdSha256JSONCondition;
|
||||||
|
|
||||||
static makeInputTemplate(
|
static makeInputTemplate(
|
||||||
@ -169,7 +179,7 @@ export default class Transaction {
|
|||||||
| PreimageSha256JSONCondition
|
| PreimageSha256JSONCondition
|
||||||
| ThresholdSha256JSONCondition
|
| ThresholdSha256JSONCondition
|
||||||
| Ed25519Sha256JSONCondition,
|
| Ed25519Sha256JSONCondition,
|
||||||
amount: string = '1'
|
amount?: string
|
||||||
): TransactionOutput;
|
): TransactionOutput;
|
||||||
|
|
||||||
static makeTransactionTemplate(): TxTemplate;
|
static makeTransactionTemplate(): TxTemplate;
|
||||||
@ -207,8 +217,14 @@ export default class Transaction {
|
|||||||
...privateKeys: string[]
|
...privateKeys: string[]
|
||||||
): TransactionCommonSigned<O>;
|
): TransactionCommonSigned<O>;
|
||||||
|
|
||||||
|
|
||||||
static delegateSignTransaction<O = TransactionOperations.CREATE>(
|
static delegateSignTransaction<O = TransactionOperations.CREATE>(
|
||||||
transaction: TransactionCommon<O>,
|
transaction: TransactionCommon<O>,
|
||||||
signFn: DelegateSignFunction
|
signFn: DelegateSignFunction
|
||||||
): TransactionCommonSigned<O>;
|
): TransactionCommonSigned<O>;
|
||||||
|
|
||||||
|
static delegateSignTransactionAsync<O = TransactionOperations.CREATE>(
|
||||||
|
transaction: TransactionCommon<O>,
|
||||||
|
signFn: DelegateSignFunctionAsync
|
||||||
|
): Promise<TransactionCommonSigned<O>>;
|
||||||
}
|
}
|
||||||
|
2
types/transport.d.ts
vendored
2
types/transport.d.ts
vendored
@ -14,7 +14,7 @@ export default class Transport {
|
|||||||
|
|
||||||
pickConnection(): Request;
|
pickConnection(): Request;
|
||||||
|
|
||||||
async forwardRequest<O = Record<string, any>>(
|
forwardRequest<O = Record<string, any>>(
|
||||||
path: string,
|
path: string,
|
||||||
config: RequestConfig
|
config: RequestConfig
|
||||||
): Promise<O>;
|
): Promise<O>;
|
||||||
|
2
types/utils/ccJsonify.d.ts
vendored
2
types/utils/ccJsonify.d.ts
vendored
@ -8,7 +8,7 @@ import type {
|
|||||||
PreimageSha256,
|
PreimageSha256,
|
||||||
ThresholdSha256,
|
ThresholdSha256,
|
||||||
} from 'crypto-conditions';
|
} from 'crypto-conditions';
|
||||||
import type { TypeId } from 'crypto-conditions/types/types';
|
import type { TypeId, TypeName } from 'crypto-conditions/types/types';
|
||||||
|
|
||||||
interface BaseJSONCondition {
|
interface BaseJSONCondition {
|
||||||
details: {
|
details: {
|
||||||
|
Loading…
Reference in New Issue
Block a user