@xelis/sdk 0.5.9 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/daemon/rpc.d.ts +3 -1
- package/daemon/rpc.js +6 -0
- package/daemon/types.d.ts +17 -4
- package/daemon/types.js +3 -0
- package/daemon/websocket.d.ts +4 -1
- package/daemon/websocket.js +9 -0
- package/lib/websocket.js +4 -0
- package/package.json +2 -2
package/daemon/rpc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Balance, Block, TopoHeightRangeParams, GetInfoResult, HeightRangeParams, GetLastBalanceResult, P2PStatusResult, Transaction, GetLastBalanceParams, GetBalanceAtTopoHeightParams, GetAccountsParams, GetBlockAtTopoHeightParams, GetBlockByHashParams, GetBlocksAtHeightParams, GetTopBlockParams, GetNonceResult, GetNonceParams, GetAccountHistoryParams, AccounHistory, Peer } from './types';
|
|
1
|
+
import { Balance, Block, TopoHeightRangeParams, GetInfoResult, HeightRangeParams, GetLastBalanceResult, P2PStatusResult, Transaction, GetLastBalanceParams, GetBalanceAtTopoHeightParams, GetAccountsParams, GetBlockAtTopoHeightParams, GetBlockByHashParams, GetBlocksAtHeightParams, GetTopBlockParams, GetNonceResult, GetNonceParams, GetAccountHistoryParams, AccounHistory, Peer, DevFee, DiskSize } from './types';
|
|
2
2
|
import { RPC as BaseRPC } from '../lib/rpc';
|
|
3
3
|
declare class RPC extends BaseRPC {
|
|
4
4
|
getVersion(): Promise<import("../lib/types").RPCResponse<string>>;
|
|
@@ -32,5 +32,7 @@ declare class RPC extends BaseRPC {
|
|
|
32
32
|
getAccountHistory(params: GetAccountHistoryParams): Promise<import("../lib/types").RPCResponse<AccounHistory[]>>;
|
|
33
33
|
getAccountAssets(address: string): Promise<import("../lib/types").RPCResponse<string[]>>;
|
|
34
34
|
getPeers(): Promise<import("../lib/types").RPCResponse<Peer[]>>;
|
|
35
|
+
getDevFeeThresholds(): Promise<import("../lib/types").RPCResponse<DevFee[]>>;
|
|
36
|
+
getSizeOnDisk(): Promise<import("../lib/types").RPCResponse<DiskSize>>;
|
|
35
37
|
}
|
|
36
38
|
export default RPC;
|
package/daemon/rpc.js
CHANGED
|
@@ -94,5 +94,11 @@ class RPC extends BaseRPC {
|
|
|
94
94
|
getPeers() {
|
|
95
95
|
return this.post(RPCMethod.GetPeers);
|
|
96
96
|
}
|
|
97
|
+
getDevFeeThresholds() {
|
|
98
|
+
return this.post(RPCMethod.GetDevFeeThresholds);
|
|
99
|
+
}
|
|
100
|
+
getSizeOnDisk() {
|
|
101
|
+
return this.post(RPCMethod.GetSizeOnDisk);
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
104
|
export default RPC;
|
package/daemon/types.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export interface GetInfoResult {
|
|
|
3
3
|
difficulty: number;
|
|
4
4
|
height: number;
|
|
5
5
|
mempool_size: number;
|
|
6
|
-
|
|
6
|
+
circulating_supply: number;
|
|
7
|
+
maximum_supply: number;
|
|
7
8
|
stableheight: number;
|
|
8
|
-
|
|
9
|
+
top_block_hash: string;
|
|
9
10
|
version: string;
|
|
10
11
|
network: string;
|
|
11
12
|
topoheight: number;
|
|
@@ -117,6 +118,7 @@ export interface Transaction {
|
|
|
117
118
|
nonce: number;
|
|
118
119
|
owner: string;
|
|
119
120
|
signature: string;
|
|
121
|
+
first_seen?: number;
|
|
120
122
|
}
|
|
121
123
|
export interface GetAccountsParams {
|
|
122
124
|
skip?: number;
|
|
@@ -170,6 +172,14 @@ export interface PeerPeerDisconnected {
|
|
|
170
172
|
peer_id: number;
|
|
171
173
|
peer_addr: string;
|
|
172
174
|
}
|
|
175
|
+
export interface DevFee {
|
|
176
|
+
fee_percentage: number;
|
|
177
|
+
height: number;
|
|
178
|
+
}
|
|
179
|
+
export interface DiskSize {
|
|
180
|
+
size_bytes: number;
|
|
181
|
+
size_formatted: string;
|
|
182
|
+
}
|
|
173
183
|
export declare enum RPCMethod {
|
|
174
184
|
GetVersion = "get_version",
|
|
175
185
|
GetInfo = "get_info",
|
|
@@ -201,7 +211,9 @@ export declare enum RPCMethod {
|
|
|
201
211
|
CountAccounts = "count_accounts",
|
|
202
212
|
GetAccountHistory = "get_account_history",
|
|
203
213
|
GetAccountAssets = "get_account_assets",
|
|
204
|
-
GetPeers = "get_peers"
|
|
214
|
+
GetPeers = "get_peers",
|
|
215
|
+
GetDevFeeThresholds = "get_dev_fee_thresholds",
|
|
216
|
+
GetSizeOnDisk = "get_size_on_disk"
|
|
205
217
|
}
|
|
206
218
|
export declare enum RPCEvent {
|
|
207
219
|
NewBlock = "NewBlock",
|
|
@@ -211,5 +223,6 @@ export declare enum RPCEvent {
|
|
|
211
223
|
PeerConnected = "PeerConnected",
|
|
212
224
|
PeerDisconnected = "PeerDisconnected",
|
|
213
225
|
PeerPeerListUpdated = "PeerPeerListUpdated",
|
|
214
|
-
PeerPeerDisconnected = "PeerPeerDisconnected"
|
|
226
|
+
PeerPeerDisconnected = "PeerPeerDisconnected",
|
|
227
|
+
PeerStateUpdated = "PeerStateUpdated"
|
|
215
228
|
}
|
package/daemon/types.js
CHANGED
|
@@ -31,6 +31,8 @@ export var RPCMethod;
|
|
|
31
31
|
RPCMethod["GetAccountHistory"] = "get_account_history";
|
|
32
32
|
RPCMethod["GetAccountAssets"] = "get_account_assets";
|
|
33
33
|
RPCMethod["GetPeers"] = "get_peers";
|
|
34
|
+
RPCMethod["GetDevFeeThresholds"] = "get_dev_fee_thresholds";
|
|
35
|
+
RPCMethod["GetSizeOnDisk"] = "get_size_on_disk";
|
|
34
36
|
})(RPCMethod || (RPCMethod = {}));
|
|
35
37
|
export var RPCEvent;
|
|
36
38
|
(function (RPCEvent) {
|
|
@@ -42,4 +44,5 @@ export var RPCEvent;
|
|
|
42
44
|
RPCEvent["PeerDisconnected"] = "PeerDisconnected";
|
|
43
45
|
RPCEvent["PeerPeerListUpdated"] = "PeerPeerListUpdated";
|
|
44
46
|
RPCEvent["PeerPeerDisconnected"] = "PeerPeerDisconnected";
|
|
47
|
+
RPCEvent["PeerStateUpdated"] = "PeerStateUpdated";
|
|
45
48
|
})(RPCEvent || (RPCEvent = {}));
|
package/daemon/websocket.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageEvent } from 'ws';
|
|
2
|
-
import { Block, GetInfoResult, RPCEventResult, Transaction, TopoHeightRangeParams, P2PStatusResult, Balance, GetBalanceAtTopoHeightParams, GetLastBalanceResult, HeightRangeParams, BlockOrdered, GetLastBalanceParams, GetAccountsParams, GetBlockAtTopoHeightParams, GetBlockByHashParams, GetBlocksAtHeightParams, GetTopBlockParams, GetNonceParams, GetNonceResult, GetAccountHistoryParams, AccounHistory, Peer, PeerPeerListUpdated, PeerPeerDisconnected } from './types';
|
|
2
|
+
import { Block, GetInfoResult, RPCEventResult, Transaction, TopoHeightRangeParams, P2PStatusResult, Balance, GetBalanceAtTopoHeightParams, GetLastBalanceResult, HeightRangeParams, BlockOrdered, GetLastBalanceParams, GetAccountsParams, GetBlockAtTopoHeightParams, GetBlockByHashParams, GetBlocksAtHeightParams, GetTopBlockParams, GetNonceParams, GetNonceResult, GetAccountHistoryParams, AccounHistory, Peer, PeerPeerListUpdated, PeerPeerDisconnected, DevFee, DiskSize } from './types';
|
|
3
3
|
import { WS as BaseWS } from '../lib/websocket';
|
|
4
4
|
declare class WS extends BaseWS {
|
|
5
5
|
onNewBlock(onData: (msgEvent: MessageEvent, data?: Block & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
@@ -10,6 +10,7 @@ declare class WS extends BaseWS {
|
|
|
10
10
|
onPeerDisconnected(onData: (msgEvent: MessageEvent, data?: number & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
11
11
|
onPeerPeerListUpdated(onData: (msgEvent: MessageEvent, data?: PeerPeerListUpdated & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
12
12
|
onPeerPeerDisconnected(onData: (msgEvent: MessageEvent, data?: PeerPeerDisconnected & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
13
|
+
onPeerStateUpdated(onData: (msgEvent: MessageEvent, data?: Peer & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
13
14
|
getVersion(): Promise<string>;
|
|
14
15
|
getInfo(): Promise<GetInfoResult>;
|
|
15
16
|
getHeight(): Promise<number>;
|
|
@@ -40,5 +41,7 @@ declare class WS extends BaseWS {
|
|
|
40
41
|
getAccountHistory(params: GetAccountHistoryParams): Promise<AccounHistory[]>;
|
|
41
42
|
getAccountAssets(address: string): Promise<string[]>;
|
|
42
43
|
getPeers(): Promise<Peer[]>;
|
|
44
|
+
getDevFeeThresholds(): Promise<DevFee[]>;
|
|
45
|
+
getSizeOnDisk(): Promise<DiskSize>;
|
|
43
46
|
}
|
|
44
47
|
export default WS;
|
package/daemon/websocket.js
CHANGED
|
@@ -25,6 +25,9 @@ class WS extends BaseWS {
|
|
|
25
25
|
onPeerPeerDisconnected(onData) {
|
|
26
26
|
return this.listenEvent(RPCEvent.PeerPeerDisconnected, onData);
|
|
27
27
|
}
|
|
28
|
+
onPeerStateUpdated(onData) {
|
|
29
|
+
return this.listenEvent(RPCEvent.PeerStateUpdated, onData);
|
|
30
|
+
}
|
|
28
31
|
getVersion() {
|
|
29
32
|
return this.dataCall(RPCMethod.GetVersion);
|
|
30
33
|
}
|
|
@@ -115,5 +118,11 @@ class WS extends BaseWS {
|
|
|
115
118
|
getPeers() {
|
|
116
119
|
return this.dataCall(RPCMethod.GetPeers);
|
|
117
120
|
}
|
|
121
|
+
getDevFeeThresholds() {
|
|
122
|
+
return this.dataCall(RPCMethod.GetDevFeeThresholds);
|
|
123
|
+
}
|
|
124
|
+
getSizeOnDisk() {
|
|
125
|
+
return this.dataCall(RPCMethod.GetSizeOnDisk);
|
|
126
|
+
}
|
|
118
127
|
}
|
|
119
128
|
export default WS;
|
package/lib/websocket.js
CHANGED
|
@@ -145,6 +145,10 @@ export class WS {
|
|
|
145
145
|
}
|
|
146
146
|
call(method, params) {
|
|
147
147
|
return new Promise((resolve, reject) => {
|
|
148
|
+
if (!this.socket)
|
|
149
|
+
return reject(new Error(`Socket is not initialized.`));
|
|
150
|
+
if (this.socket.readyState !== WebSocket.OPEN)
|
|
151
|
+
return reject(new Error(`Can't send msg. Socket is not opened.`));
|
|
148
152
|
const { data, id } = this.createRequestMethod(method, params);
|
|
149
153
|
let timeoutId = null;
|
|
150
154
|
const onMessage = (msgEvent) => {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.5.
|
|
2
|
+
"version": "0.5.11",
|
|
3
3
|
"name": "@xelis/sdk",
|
|
4
4
|
"description": "Xelis software development kit for JS",
|
|
5
5
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"homepage": "https://github.com/xelis-project/xelis-js-sdk#readme",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "jest",
|
|
12
|
-
"build": "rm -
|
|
12
|
+
"build": "rm -rf ./dist && npx tsc --declaration && cp package.json ./dist && cp README.md ./dist",
|
|
13
13
|
"publish": "cd ./dist && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|