Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: typescript definitions #284

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
747 changes: 346 additions & 401 deletions index.d.ts

Large diffs are not rendered by default.

1,777 changes: 1,594 additions & 183 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"prepublishOnly": "npm run build",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "npm run test:node && npm run test:browser",
"test": "npm run test:types && npm run test:node && npm run test:browser",
"test:node": "mocha $NODE_DEBUG_OPTION --no-timeout --recursive",
"test:browser": "karma start ./karma.conf.js --single-run",
"test:types": "npx tsd",
"coverage": "nyc mocha --recursive",
"build": "webpack",
"pretty": "npx prettier --write ."
Expand All @@ -21,7 +22,8 @@
"docs",
"examples",
"lib",
"typings"
"typings",
"index.d.ts"
],
"contributors": [
{
Expand Down Expand Up @@ -120,28 +122,30 @@
},
"homepage": "https://github.com/dashevo/dashcore-lib",
"dependencies": {
"@dashevo/bls": "~1.2.9",
"@dashevo/x11-hash-js": "^1.0.2",
"@types/node": "^12.12.47",
"bloom-filter": "^0.2.0",
"@dashevo/bls": "~1.2.9",
"bn.js": "^4.12.0",
"bs58": "=4.0.1",
"elliptic": "^6.5.4",
"inherits": "=2.0.1",
"lodash": "^4.17.20",
"ripemd160": "^2.0.2",
"tsd": "^0.28.1",
"unorm": "^1.6.0"
},
"devDependencies": {
"@types/bloom-filter": "^0.2.1",
"assert-browserify": "^2.0.0",
"brfs-node-15": "^2.0.3",
"buffer": "^6.0.3",
"chai": "^4.2.0",
"crypto-browserify": "^3.12.0",
"eslint": "^7.27.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"karma": "^6.3.3",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
Expand Down
56 changes: 56 additions & 0 deletions test-d/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Ensure exports of basic types
import type {
Address,
BloomFilter,
HDPrivateKey,
HDPublicKey,
Message,
Network,
Opcode,
PrivateKey,
PublicKey,
Unit,
URI,
InstantLock,
Block,
BlockHeader,
MerkleBlock,
PartialMerkleTree,
BufferWriter,
BufferReader,
ChainLock,
BN,
Point,
Signature,
Hash,
QuorumEntry,
SimplifiedMNList,
SimplifiedMNListDiff,
SimplifiedMNListEntry,
SimplifiedMNListStore,
GovObject,
Proposal,
Trigger,
Mnemonic,
Script,
Input,
MultiSigInput,
MultiSigScriptHashInput,
AbstractPayload,
CoinbasePayload,
CommitmentTxPayload,
ProRegTxPayload,
ProUpRegTxPayload,
ProUpRevTxPayload,
ProUpServTxPayload,
SubTxCloseAccountPayload,
SubTxRegisterPayload,
SubTxResetKeyPayload,
SubTxTopupPayload,
SubTxTransitionPayload,
Output,
Transaction,
TransactionSignature,
UnspentOutput,
ChainLockSigMessage
} from "..";
6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true
},
"include": ["typings/**/*.ts"]
}
4 changes: 2 additions & 2 deletions typings/HDPrivateKey.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ export class HDPrivateKey {
* @param {string|Buffer} data - the serialized private key
* @param {string|Network=} network - optional, if present, checks that the
* network provided matches the network serialized.
* @return {InvalidArgument|null}
* @return {Error|null}
*/
// @ts-ignore
static getSerializedError(
data: string | Buffer,
network: string | Network
): InvalidArgument | null;
): Error | null;

/**
* Generate a private key from a seed, as described in BIP32
Expand Down
2 changes: 1 addition & 1 deletion typings/Opcode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Opcode {
* @param {Opcode} opcode
* @returns true if opcode is one of OP_0, OP_1, ..., OP_16
*/
static isSmallIntOp(opcode): Boolean;
static isSmallIntOp(opcode: Opcode): Boolean;

/**
* @returns map of the available opcodes
Expand Down
2 changes: 1 addition & 1 deletion typings/block/Block.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class Block {
*/
toObject(): {
header: BlockHeader.toObjectParams;
transactions: Transaction.toObject[];
transactions: any[];
};

/**
Expand Down
2 changes: 1 addition & 1 deletion typings/chainlock/ChainLock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class ChainLock {
* @param {BufferWriter} [br] - an object with all properties of chainlock
* @return {BufferWriter}
*/
toBufferWriter(br?): BufferWriter;
toBufferWriter(br?: BufferWriter): BufferWriter;

/**
* Creates a copy of ChainLock
Expand Down
50 changes: 50 additions & 0 deletions typings/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export type LLMQ_TYPES = {
// 50 members, 30 (60%) threshold, one per hour (24 blocks)
LLMQ_TYPE_50_60: 1,

// 400 members, 240 (60%) threshold, one every 12 hours (288 blocks)
LLMQ_TYPE_400_60: 2,

// 400 members, 340 (85%) threshold, one every 24 hours (576 blocks)
LLMQ_TYPE_400_85: 3,

// 100 members, 67 (67%) threshold, one every 24 hours (576 blocks)
LLMQ_TYPE_100_67: 4,

// 60 members, 45 (75%) threshold, one every 12 hours
LLMQ_TYPE_60_75: 5,

// 25 members, 67 (67%) threshold, one per hour
LLMQ_TYPE_25_67: 6,

// 3 members, 2 (66%) threshold, one per hour (24 blocks)
// Params might differ when -llmqtestparams is used
LLMQ_TYPE_LLMQ_TEST: 100,

// 12 members, 6 (60%) threshold, one per hour (24 blocks)
// Params might differ when -llmqdevnetparams is used
LLMQ_TYPE_LLMQ_DEVNET: 101,

// 3 members, 2 (66%) threshold, one per hour.
// Params might differ when -llmqtestparams is used
LLMQ_TYPE_TEST_V17: 102,

// 4 members, 2 (66%) threshold, one per hour.
// Params might differ when -llmqtestparams is used
LLMQ_TYPE_TEST_DIP0024: 103,

// 3 members, 2 (66%) threshold, one per hour.
// Params might differ when -llmqtestinstantsendparams is used
LLMQ_TYPE_TEST_INSTANTSEND: 104,

// 8 members, 4 (50%) threshold, one per hour.
// Params might differ when -llmqdevnetparams is used
// for devnets only. rotated version (v2) for devnets
LLMQ_DEVNET_DIP0024: 105,
// for testing only
// 3 members, 2 (67%) threshold, one per hour.
LLMQ_TEST_PLATFORM: 106,
// for devnet testing only
// 12 members, 8 (67%) threshold, one per hour
LLMQ_DEVNET_PLATFORM: 107,
}
2 changes: 1 addition & 1 deletion typings/deterministicmnlist/SimplifiedMNList.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SimplifiedMNListDiff } from './SimplifiedMNListDiff';
import { SimplifiedMNListEntry } from './SimplifiedMNListEntry';
import { QuorumEntry } from './QuorumEntry';
import * as constants from 'constants';
import * as constants from '../constants';

export class SimplifiedMNList {
constructor(arg?: Buffer | any | string);
Expand Down
2 changes: 1 addition & 1 deletion typings/instantlock/instantlock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class InstantLock {
* @param {SimplifiedMNListStore} smlStore - used to reconstruct quorum lists
* @returns {Promise<Boolean>} - returns the result of the verification
*/
verify(smlStore): Promise<boolean>;
verify(smlStore: SimplifiedMNListStore): Promise<boolean>;

/**
* Validate InstantLock structure
Expand Down
5 changes: 3 additions & 2 deletions typings/transaction/Transaction.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Output } from './Output';
import { Signature } from '../crypto/Signature';
import { AbstractPayload } from './payload/AbstractPayload';
import { bitcore } from '../bitcore';
import { TransactionSignature } from './TransactionSignature';

export namespace Transaction {
/**
Expand Down Expand Up @@ -363,7 +364,7 @@ export class Transaction {
*/
sortInputs(sortingFunction: (...params: any[]) => any): Transaction;

removeInput(txId, outputIndex): void;
removeInput(txId: number | string, outputIndex: number): void;

/**
* Sign the transaction using one or more private keys.
Expand Down Expand Up @@ -410,7 +411,7 @@ export class Transaction {
* @param signature
* @return {Boolean}
*/
isValidSignature(signature): boolean;
isValidSignature(signature: TransactionSignature): boolean;

/**
* @returns {bool} whether the signature is valid for this transaction input
Expand Down
2 changes: 1 addition & 1 deletion typings/transaction/input/MultiSigInput.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PublicKey from '../../PublicKey';
import { PublicKey } from '../../PublicKey';
import { Input } from './Input';
import { TransactionSignature } from '../TransactionSignature';
import { Transaction } from '../Transaction';
Expand Down
2 changes: 2 additions & 0 deletions typings/transaction/payload/SubTxResetKeyPayload.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PrivateKey } from '../../PrivateKey';

/**
* @typedef {Object} SubTxResetKeyPayloadJSON
* @property {number} version - payload version
Expand Down