@xelis/sdk 0.5.11 → 0.5.12
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/README.md +4 -4
- package/config/nodes.d.ts +0 -6
- package/config/nodes.js +5 -8
- package/daemon/types.d.ts +22 -10
- package/daemon/types.js +11 -9
- package/daemon/websocket.d.ts +2 -1
- package/daemon/websocket.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,11 +15,11 @@ Import library and start working :).
|
|
|
15
15
|
Use http/rpc connection.
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
import {
|
|
18
|
+
import { TESTNET_NODE_RPC } from '@xelis/sdk/config/nodes'
|
|
19
19
|
import DaemonRPC from '@xelis/sdk/daemon/rpc'
|
|
20
20
|
|
|
21
21
|
const main = async () => {
|
|
22
|
-
const daemonRPC = new DaemonRPC(
|
|
22
|
+
const daemonRPC = new DaemonRPC(TESTNET_NODE_RPC)
|
|
23
23
|
const info = await daemonRPC.getInfo()
|
|
24
24
|
console.log(info)
|
|
25
25
|
}
|
|
@@ -30,12 +30,12 @@ main()
|
|
|
30
30
|
Use websocket connection.
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
|
-
import {
|
|
33
|
+
import { TESTNET_NODE_WS } from '@xelis/sdk/config/nodes'
|
|
34
34
|
import DaemonWS from '@xelis/sdk/daemon/websocket'
|
|
35
35
|
|
|
36
36
|
const main = async () => {
|
|
37
37
|
const daemonWS = new DaemonWS()
|
|
38
|
-
await daemonWS.connect(
|
|
38
|
+
await daemonWS.connect(TESTNET_NODE_WS)
|
|
39
39
|
const info = await daemonWS.getInfo()
|
|
40
40
|
console.log(info)
|
|
41
41
|
}
|
package/config/nodes.d.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
export declare const NODE_URL = "node.xelis.io";
|
|
2
2
|
export declare const TESTNET_NODE_URL = "testnet-node.xelis.io";
|
|
3
|
-
export declare const DEV_NODE_URL = "dev-node.xelis.io";
|
|
4
3
|
export declare const NODE_RPC: string;
|
|
5
4
|
export declare const TESTNET_NODE_RPC: string;
|
|
6
|
-
export declare const DEV_NODE_RPC: string;
|
|
7
5
|
export declare const NODE_WS: string;
|
|
8
6
|
export declare const TESTNET_NODE_WS: string;
|
|
9
|
-
export declare const DEV_NODE_WS: string;
|
|
10
7
|
declare const _default: {
|
|
11
8
|
NODE_URL: string;
|
|
12
9
|
TESTNET_NODE_URL: string;
|
|
13
|
-
DEV_NODE_URL: string;
|
|
14
10
|
NODE_RPC: string;
|
|
15
11
|
TESTNET_NODE_RPC: string;
|
|
16
|
-
DEV_NODE_RPC: string;
|
|
17
12
|
NODE_WS: string;
|
|
18
13
|
TESTNET_NODE_WS: string;
|
|
19
|
-
DEV_NODE_WS: string;
|
|
20
14
|
};
|
|
21
15
|
export default _default;
|
package/config/nodes.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export const NODE_URL = `node.xelis.io`;
|
|
2
2
|
export const TESTNET_NODE_URL = `testnet-node.xelis.io`;
|
|
3
|
-
export const DEV_NODE_URL = `dev-node.xelis.io`;
|
|
4
3
|
export const NODE_RPC = `https://${NODE_URL}/json_rpc`;
|
|
5
4
|
export const TESTNET_NODE_RPC = `https://${TESTNET_NODE_URL}/json_rpc`;
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const TESTNET_NODE_WS = `wss://${TESTNET_NODE_URL}/ws`;
|
|
9
|
-
export const DEV_NODE_WS = `wss://${DEV_NODE_URL}/ws`;
|
|
5
|
+
export const NODE_WS = `wss://${NODE_URL}/json_rpc`;
|
|
6
|
+
export const TESTNET_NODE_WS = `wss://${TESTNET_NODE_URL}/json_rpc`;
|
|
10
7
|
export default {
|
|
11
|
-
NODE_URL, TESTNET_NODE_URL,
|
|
12
|
-
NODE_RPC, TESTNET_NODE_RPC,
|
|
13
|
-
NODE_WS, TESTNET_NODE_WS
|
|
8
|
+
NODE_URL, TESTNET_NODE_URL,
|
|
9
|
+
NODE_RPC, TESTNET_NODE_RPC,
|
|
10
|
+
NODE_WS, TESTNET_NODE_WS
|
|
14
11
|
};
|
package/daemon/types.d.ts
CHANGED
|
@@ -75,6 +75,9 @@ export interface HeightRangeParams {
|
|
|
75
75
|
export interface RPCEventResult {
|
|
76
76
|
event: string;
|
|
77
77
|
}
|
|
78
|
+
export type PeerPeers = {
|
|
79
|
+
[ip: string]: `In` | `Out` | `Both`;
|
|
80
|
+
};
|
|
78
81
|
export interface Peer {
|
|
79
82
|
id: number;
|
|
80
83
|
addr: string;
|
|
@@ -85,7 +88,7 @@ export interface Peer {
|
|
|
85
88
|
height: number;
|
|
86
89
|
last_ping: number;
|
|
87
90
|
pruned_topoheight: number;
|
|
88
|
-
peers:
|
|
91
|
+
peers: PeerPeers;
|
|
89
92
|
cumulative_difficulty: number;
|
|
90
93
|
}
|
|
91
94
|
export interface BlockOrdered {
|
|
@@ -180,6 +183,13 @@ export interface DiskSize {
|
|
|
180
183
|
size_bytes: number;
|
|
181
184
|
size_formatted: string;
|
|
182
185
|
}
|
|
186
|
+
export interface AssetData {
|
|
187
|
+
asset: string;
|
|
188
|
+
data: {
|
|
189
|
+
topoheight: number;
|
|
190
|
+
decimals: number;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
183
193
|
export declare enum RPCMethod {
|
|
184
194
|
GetVersion = "get_version",
|
|
185
195
|
GetInfo = "get_info",
|
|
@@ -216,13 +226,15 @@ export declare enum RPCMethod {
|
|
|
216
226
|
GetSizeOnDisk = "get_size_on_disk"
|
|
217
227
|
}
|
|
218
228
|
export declare enum RPCEvent {
|
|
219
|
-
NewBlock = "
|
|
220
|
-
TransactionAddedInMempool = "
|
|
221
|
-
TransactionExecuted = "
|
|
222
|
-
BlockOrdered = "
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
PeerStateUpdated = "
|
|
229
|
+
NewBlock = "new_block",
|
|
230
|
+
TransactionAddedInMempool = "transaction_added_in_mempool",
|
|
231
|
+
TransactionExecuted = "transaction_executed",
|
|
232
|
+
BlockOrdered = "block_ordered",
|
|
233
|
+
TransactionSCResult = "transaction_sc_result",
|
|
234
|
+
NewAsset = "new_asset",
|
|
235
|
+
PeerConnected = "peer_connected",
|
|
236
|
+
PeerDisconnected = "peer_disconnected",
|
|
237
|
+
PeerStateUpdated = "peer_state_updated",
|
|
238
|
+
PeerPeerListUpdated = "peer_peer_list_updated",
|
|
239
|
+
PeerPeerDisconnected = "peer_peer_disconnected"
|
|
228
240
|
}
|
package/daemon/types.js
CHANGED
|
@@ -36,13 +36,15 @@ export var RPCMethod;
|
|
|
36
36
|
})(RPCMethod || (RPCMethod = {}));
|
|
37
37
|
export var RPCEvent;
|
|
38
38
|
(function (RPCEvent) {
|
|
39
|
-
RPCEvent["NewBlock"] = "
|
|
40
|
-
RPCEvent["TransactionAddedInMempool"] = "
|
|
41
|
-
RPCEvent["TransactionExecuted"] = "
|
|
42
|
-
RPCEvent["BlockOrdered"] = "
|
|
43
|
-
RPCEvent["
|
|
44
|
-
RPCEvent["
|
|
45
|
-
RPCEvent["
|
|
46
|
-
RPCEvent["
|
|
47
|
-
RPCEvent["PeerStateUpdated"] = "
|
|
39
|
+
RPCEvent["NewBlock"] = "new_block";
|
|
40
|
+
RPCEvent["TransactionAddedInMempool"] = "transaction_added_in_mempool";
|
|
41
|
+
RPCEvent["TransactionExecuted"] = "transaction_executed";
|
|
42
|
+
RPCEvent["BlockOrdered"] = "block_ordered";
|
|
43
|
+
RPCEvent["TransactionSCResult"] = "transaction_sc_result";
|
|
44
|
+
RPCEvent["NewAsset"] = "new_asset";
|
|
45
|
+
RPCEvent["PeerConnected"] = "peer_connected";
|
|
46
|
+
RPCEvent["PeerDisconnected"] = "peer_disconnected";
|
|
47
|
+
RPCEvent["PeerStateUpdated"] = "peer_state_updated";
|
|
48
|
+
RPCEvent["PeerPeerListUpdated"] = "peer_peer_list_updated";
|
|
49
|
+
RPCEvent["PeerPeerDisconnected"] = "peer_peer_disconnected";
|
|
48
50
|
})(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, DevFee, DiskSize } 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, AssetData } 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>>;
|
|
@@ -11,6 +11,7 @@ declare class WS extends BaseWS {
|
|
|
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
13
|
onPeerStateUpdated(onData: (msgEvent: MessageEvent, data?: Peer & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
14
|
+
onNewAsset(onData: (msgEvent: MessageEvent, data?: AssetData & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
14
15
|
getVersion(): Promise<string>;
|
|
15
16
|
getInfo(): Promise<GetInfoResult>;
|
|
16
17
|
getHeight(): Promise<number>;
|
package/daemon/websocket.js
CHANGED
|
@@ -28,6 +28,9 @@ class WS extends BaseWS {
|
|
|
28
28
|
onPeerStateUpdated(onData) {
|
|
29
29
|
return this.listenEvent(RPCEvent.PeerStateUpdated, onData);
|
|
30
30
|
}
|
|
31
|
+
onNewAsset(onData) {
|
|
32
|
+
return this.listenEvent(RPCEvent.NewAsset, onData);
|
|
33
|
+
}
|
|
31
34
|
getVersion() {
|
|
32
35
|
return this.dataCall(RPCMethod.GetVersion);
|
|
33
36
|
}
|
package/package.json
CHANGED