mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 19:12:20 +08:00
Merge pull request #28475 from danwbyrne/wif
adds typings for the 'wif' package
This commit is contained in:
27
types/wif/index.d.ts
vendored
Normal file
27
types/wif/index.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for wif 2.0
|
||||
// Project: https://github.com/bitcoinjs/wif
|
||||
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
export interface WIFReturn {
|
||||
readonly version: number;
|
||||
readonly privateKey: Buffer;
|
||||
readonly compressed: boolean;
|
||||
}
|
||||
|
||||
export function decodeRaw(buffer: Buffer, version?: number): WIFReturn;
|
||||
export function decode(string: string, version: number): WIFReturn;
|
||||
|
||||
export function encodeRaw(
|
||||
version: number,
|
||||
privateKey: Buffer,
|
||||
compressed: boolean
|
||||
): Buffer;
|
||||
|
||||
export function encode(
|
||||
version: number | WIFReturn,
|
||||
privateKey: Buffer,
|
||||
compressed: boolean
|
||||
): Buffer;
|
||||
19
types/wif/tsconfig.json
Normal file
19
types/wif/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"wif-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/wif/tslint.json
Normal file
3
types/wif/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
16
types/wif/wif-tests.ts
Normal file
16
types/wif/wif-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import wif = require('wif');
|
||||
|
||||
const testString = 'test';
|
||||
const testBuffer = Buffer.from(testString);
|
||||
|
||||
// $ExpectType WIFReturn
|
||||
wif.decodeRaw(testBuffer);
|
||||
// $ExpectType WIFReturn
|
||||
wif.decodeRaw(testBuffer, 0);
|
||||
// $ExpectType WIFReturn
|
||||
wif.decode(testString, 0);
|
||||
|
||||
// $ExpectType Buffer
|
||||
wif.encodeRaw(1, testBuffer, true);
|
||||
// $ExpectType Buffer
|
||||
wif.encode(1, testBuffer, true);
|
||||
Reference in New Issue
Block a user