Skip to content

Commit cade2f4

Browse files
committed
remove es5class dependency, create typescript src, tests still failing
1 parent 62114f1 commit cade2f4

31 files changed

+3371
-1278
lines changed

.jshintrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
language: node_js
22
node_js:
3-
- "0.10"
3+
- "8"
4+
- "6"
5+
- "5"
46
branches:
57
only:
68
- master
9+
before_script:
10+
- node node_modules/typescript/bin/tsc -p tsconfig.json
711
after_success:
812
- npm run coveralls

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,7 @@ You can additionally set `DEBUG=stratum,jsonrpc` to also see the RPC part in-dep
424424

425425
## Wanna support the development?
426426

427-
`BTC: 1AGseqNAqh44YvYANMcdduDi73WFU3bHQr`
428-
429-
`LTC: LW2kXiquqDu3GfpfBX2xNTSgjVmBPu6g3z`
430-
431-
`DOGE: DUQ9ipuy6oi3AA9jFkkUp5VCnEvYgyYEL9`
432-
433-
`XPM: ARKZ7uVE1YS19HC8jSq5xZGkr6YAzugWBv`
434-
435-
`NXT: 4511725246738523673`
427+
`BTC: 1EAfhxEUu1VsEEAAXk3MtTXK3LCrWDhejj`
436428

437429
```bash
438430
npm star stratum

jsconfig.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"alwaysStrict": true,
4+
"strict": true,
5+
"module": "commonjs",
6+
"lib": [
7+
"es2015",
8+
"es6"
9+
],
10+
"target": "es2015",
11+
"noUnusedLocals": true
12+
},
13+
"typeAcquisition": {
14+
"enable": true
15+
},
16+
"files": [
17+
"lib/base.js",
18+
"lib/client.js",
19+
"lib/daemon.js",
20+
"lib/index.js",
21+
"lib/rpc.js",
22+
"lib/server.js"
23+
]
24+
}

lib/base.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { EventEmitter } from "eventemitter3";
2+
export default class Base extends EventEmitter {
3+
static debug(...msg: any[]): string;
4+
}

lib/base.js

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/base.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/client.d.ts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/// <reference types="node" />
2+
/// <reference types="bluebird" />
3+
import Base from "./base";
4+
import * as net from "net";
5+
import * as q from "bluebird";
6+
/**
7+
* @param {Socket} socket
8+
* @param {Boolean} isServer
9+
* @constructor
10+
*/
11+
export default class Client extends Base {
12+
currentId: number;
13+
socket: net.Socket;
14+
authorized: boolean;
15+
byServer: boolean;
16+
subscription: string;
17+
name: string;
18+
pending: any;
19+
id: string;
20+
lastActivity: number;
21+
constructor(socket?: net.Socket, isServer?: boolean);
22+
/**
23+
* Keep track of idle sockets, update the last activity
24+
*
25+
* @param {Number} [time] Unix Timestamp
26+
*
27+
* @return {this}
28+
*/
29+
setLastActivity(time?: any): this;
30+
/**
31+
* Either emit an event, or fulfill a pending request by id
32+
*/
33+
fullfill(command: any): void;
34+
/**
35+
* Get the current socket IP address
36+
*
37+
* @returns {{port: Number, address: String, family: String}}
38+
*/
39+
address(): {
40+
port: number;
41+
family: string;
42+
address: string;
43+
};
44+
/**
45+
* This method is exposed just for testing purposes
46+
*
47+
* @param {Socket} socket
48+
* @param {Buffer} buffer
49+
* @private
50+
*/
51+
handleData(socket: any, buffer: any): void;
52+
/**
53+
* Destroy the socket and unattach any listeners
54+
*/
55+
destroy(): void;
56+
/**
57+
* Connect to somewhere
58+
*
59+
* @param {Object} opts Where to connect
60+
* @returns {Q.promise}
61+
*/
62+
connect(opts: any): q<{}>;
63+
/**
64+
* Don't use this functions directly, they are called from the server side,
65+
* it's not a client side command, but an answer
66+
*
67+
* @return {Q.promise}
68+
* @private
69+
*/
70+
set_difficulty(args: any): any;
71+
/**
72+
* Don't use this functions directly, they are called from the server side
73+
* it's not a client side command, but an answer
74+
*
75+
* @return {Q.promise}
76+
* @private
77+
*/
78+
notify(args: any): any;
79+
/**
80+
* Send HTTP header
81+
*
82+
* @param {String} hostname
83+
* @param {Number} port
84+
*
85+
* @return {Q.promise}
86+
*/
87+
stratumHttpHeader(hostname: any, port: any): q<{}>;
88+
/**
89+
* Subscribe to the pool
90+
*
91+
* @param {String} [UA] Send the User-Agent
92+
* @returns {Q.promise}
93+
*/
94+
stratumSubscribe(UA: any): q<{}>;
95+
/**
96+
* Asks for authorization
97+
*
98+
* @param {String} user
99+
* @param {String} pass
100+
* @returns {Q.promise}
101+
*/
102+
stratumAuthorize(user: any, pass: any): q<{}>;
103+
/**
104+
* Sends a share
105+
*
106+
* @param {String} worker
107+
* @param {String} job_id
108+
* @param {String} extranonce2
109+
* @param {String} ntime
110+
* @param {String} nonce
111+
* @returns {Q.promise}
112+
*/
113+
stratumSubmit(worker: any, job_id: any, extranonce2: any, ntime: any, nonce: any): q<{}>;
114+
/**
115+
* Send Stratum command
116+
*
117+
* @param {Object} data
118+
* @param {Boolean} bypass Bypass unauthorized
119+
* @param {String} name Call from the server
120+
*
121+
* @returns {Q.promise}
122+
*/
123+
stratumSend(data: any, bypass?: any, name?: any): q<{}>;
124+
/**
125+
* Send raw data to the server
126+
*
127+
* @param {*} data
128+
* @returns {Q.promise}
129+
*/
130+
send(data: any): q<{}>;
131+
static createSocket(socket?: net.Socket): net.Socket;
132+
}

0 commit comments

Comments
 (0)