@xelis/sdk 0.6.1 → 0.8.0
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/create_esm_pkg.js +13 -0
- package/dist/cjs/config.js +38 -0
- package/dist/cjs/daemon/rpc.js +143 -0
- package/dist/cjs/daemon/types.js +74 -0
- package/dist/cjs/daemon/websocket.js +236 -0
- package/dist/cjs/lib/rpc.js +89 -0
- package/dist/cjs/lib/types.js +2 -0
- package/dist/cjs/lib/websocket.js +283 -0
- package/dist/cjs/react/daemon.js +176 -0
- package/dist/cjs/wallet/rpc.js +131 -0
- package/dist/cjs/wallet/types.js +29 -0
- package/dist/cjs/wallet/websocket.js +92 -0
- package/dist/cjs/xswd/types.js +9 -0
- package/dist/cjs/xswd/websocket.js +38 -0
- package/dist/esm/config.js +35 -0
- package/dist/esm/daemon/rpc.js +140 -0
- package/{daemon → dist/esm/daemon}/types.js +13 -3
- package/dist/esm/daemon/websocket.js +233 -0
- package/dist/esm/lib/rpc.js +86 -0
- package/dist/esm/lib/websocket.js +277 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react/daemon.js +144 -0
- package/dist/esm/wallet/rpc.js +128 -0
- package/{wallet → dist/esm/wallet}/types.js +1 -0
- package/dist/esm/wallet/websocket.js +89 -0
- package/dist/esm/xswd/websocket.js +35 -0
- package/{daemon → dist/types/daemon}/rpc.d.ts +17 -15
- package/{daemon → dist/types/daemon}/types.d.ts +127 -47
- package/{daemon → dist/types/daemon}/websocket.d.ts +20 -16
- package/{wallet → dist/types/wallet}/rpc.d.ts +9 -5
- package/{wallet → dist/types/wallet}/types.d.ts +26 -0
- package/{wallet → dist/types/wallet}/websocket.d.ts +7 -5
- package/jest.config.js +6 -0
- package/package.json +12 -3
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +17 -0
- package/tsconfig.types.json +8 -0
- package/config.js +0 -25
- package/daemon/rpc.js +0 -113
- package/daemon/websocket.js +0 -159
- package/lib/rpc.js +0 -38
- package/lib/websocket.js +0 -202
- package/react/daemon.js +0 -82
- package/wallet/rpc.js +0 -55
- package/wallet/websocket.js +0 -60
- package/xswd/websocket.js +0 -16
- /package/{lib → dist/esm/lib}/types.js +0 -0
- /package/{xswd → dist/esm/xswd}/types.js +0 -0
- /package/{config.d.ts → dist/types/config.d.ts} +0 -0
- /package/{lib → dist/types/lib}/rpc.d.ts +0 -0
- /package/{lib → dist/types/lib}/types.d.ts +0 -0
- /package/{lib → dist/types/lib}/websocket.d.ts +0 -0
- /package/{react → dist/types/react}/daemon.d.ts +0 -0
- /package/{xswd → dist/types/xswd}/types.d.ts +0 -0
- /package/{xswd → dist/types/xswd}/websocket.d.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { WS as BaseWS } from '../lib/websocket';
|
|
17
|
+
import { DaemonMethods } from '../daemon/websocket';
|
|
18
|
+
import { WalletMethods } from '../wallet/websocket';
|
|
19
|
+
var WS = /** @class */ (function (_super) {
|
|
20
|
+
__extends(WS, _super);
|
|
21
|
+
function WS() {
|
|
22
|
+
var _this = _super.call(this) || this;
|
|
23
|
+
_this.timeout = 0;
|
|
24
|
+
_this.daemon = new DaemonMethods(_this, "node.");
|
|
25
|
+
_this.wallet = new WalletMethods(_this, "wallet.");
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
WS.prototype.authorize = function (app) {
|
|
29
|
+
var data = JSON.stringify(app);
|
|
30
|
+
return this.call("", {}, data);
|
|
31
|
+
};
|
|
32
|
+
return WS;
|
|
33
|
+
}(BaseWS));
|
|
34
|
+
export { WS };
|
|
35
|
+
export default WS;
|
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Block, TopoHeightRangeParams, GetInfoResult, HeightRangeParams, GetBalanceResult, P2PStatusResult, GetBalanceParams, GetBalanceAtTopoHeightParams, GetAccountsParams, GetBlockAtTopoHeightParams, GetBlockByHashParams, GetBlocksAtHeightParams, GetTopBlockParams, GetNonceResult, GetNonceParams, GetAccountHistoryParams, AccounHistory, DevFee, DiskSize, HasBalanceParams, HasBalanceResult, AssetData, IsTxExecutedInBlockParams, GetAssetParams, GetPeersResult, GetBlockTemplateResult, VersionedBalance, VersionedNonce, GetNonceAtTopoheightParams, HasNonceParams, HasNonceResult, TransactionResponse } from './types';
|
|
2
2
|
import { RPC as BaseRPC } from '../lib/rpc';
|
|
3
3
|
export declare class RPC extends BaseRPC {
|
|
4
4
|
getVersion(): Promise<import("../lib/types").RPCResponse<string>>;
|
|
5
|
-
getInfo(): Promise<import("../lib/types").RPCResponse<GetInfoResult>>;
|
|
6
5
|
getHeight(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
7
6
|
getTopoHeight(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
8
7
|
getStableHeight(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
9
|
-
getBlockTemplate(address: string): Promise<import("../lib/types").RPCResponse<
|
|
8
|
+
getBlockTemplate(address: string): Promise<import("../lib/types").RPCResponse<GetBlockTemplateResult>>;
|
|
10
9
|
getBlockAtTopoHeight(params: GetBlockAtTopoHeightParams): Promise<import("../lib/types").RPCResponse<Block>>;
|
|
11
10
|
getBlocksAtHeight(params: GetBlocksAtHeightParams): Promise<import("../lib/types").RPCResponse<Block[]>>;
|
|
12
11
|
getBlockByHash(params: GetBlockByHashParams): Promise<import("../lib/types").RPCResponse<Block>>;
|
|
13
12
|
getTopBlock(params: GetTopBlockParams): Promise<import("../lib/types").RPCResponse<Block>>;
|
|
14
|
-
|
|
13
|
+
submitBlock(blockTemplate: string): Promise<import("../lib/types").RPCResponse<boolean>>;
|
|
15
14
|
getBalance(params: GetBalanceParams): Promise<import("../lib/types").RPCResponse<GetBalanceResult>>;
|
|
16
15
|
hasBalance(params: HasBalanceParams): Promise<import("../lib/types").RPCResponse<HasBalanceResult>>;
|
|
17
|
-
getBalanceAtTopoHeight(params: GetBalanceAtTopoHeightParams): Promise<import("../lib/types").RPCResponse<
|
|
16
|
+
getBalanceAtTopoHeight(params: GetBalanceAtTopoHeightParams): Promise<import("../lib/types").RPCResponse<VersionedBalance>>;
|
|
17
|
+
getInfo(): Promise<import("../lib/types").RPCResponse<GetInfoResult>>;
|
|
18
|
+
getNonce(params: GetNonceParams): Promise<import("../lib/types").RPCResponse<GetNonceResult>>;
|
|
19
|
+
hasNonce(params: HasNonceParams): Promise<import("../lib/types").RPCResponse<HasNonceResult>>;
|
|
20
|
+
getNonceAtTopoheight(params: GetNonceAtTopoheightParams): Promise<import("../lib/types").RPCResponse<VersionedNonce>>;
|
|
18
21
|
getAsset(params: GetAssetParams): Promise<import("../lib/types").RPCResponse<AssetData>>;
|
|
19
22
|
getAssets(): Promise<import("../lib/types").RPCResponse<string[]>>;
|
|
20
|
-
countTransactions(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
21
23
|
countAssets(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
22
24
|
countAccounts(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
23
|
-
|
|
25
|
+
countTransactions(): Promise<import("../lib/types").RPCResponse<number>>;
|
|
26
|
+
submitTransaction(hexData: string): Promise<import("../lib/types").RPCResponse<boolean>>;
|
|
27
|
+
getTransaction(hash: string): Promise<import("../lib/types").RPCResponse<TransactionResponse>>;
|
|
24
28
|
p2pStatus(): Promise<import("../lib/types").RPCResponse<P2PStatusResult>>;
|
|
29
|
+
getPeers(): Promise<import("../lib/types").RPCResponse<GetPeersResult>>;
|
|
30
|
+
getMemPool(): Promise<import("../lib/types").RPCResponse<TransactionResponse[]>>;
|
|
31
|
+
getTips(): Promise<import("../lib/types").RPCResponse<string[]>>;
|
|
25
32
|
getDAGOrder(params: TopoHeightRangeParams): Promise<import("../lib/types").RPCResponse<string[]>>;
|
|
26
|
-
getMemPool(): Promise<import("../lib/types").RPCResponse<Transaction[]>>;
|
|
27
|
-
getTransaction(hash: string): Promise<import("../lib/types").RPCResponse<Transaction>>;
|
|
28
|
-
getTransactions(txHashes: string[]): Promise<import("../lib/types").RPCResponse<Transaction[]>>;
|
|
29
33
|
getBlocksRangeByTopoheight(params: TopoHeightRangeParams): Promise<import("../lib/types").RPCResponse<Block[]>>;
|
|
30
34
|
getBlocksRangeByHeight(params: HeightRangeParams): Promise<import("../lib/types").RPCResponse<Block[]>>;
|
|
31
|
-
|
|
32
|
-
submitBlock(blockTemplate: string): Promise<import("../lib/types").RPCResponse<boolean>>;
|
|
33
|
-
submitTransaction(hexData: string): Promise<import("../lib/types").RPCResponse<boolean>>;
|
|
35
|
+
getTransactions(txHashes: string[]): Promise<import("../lib/types").RPCResponse<TransactionResponse[]>>;
|
|
34
36
|
getAccountHistory(params: GetAccountHistoryParams): Promise<import("../lib/types").RPCResponse<AccounHistory[]>>;
|
|
35
37
|
getAccountAssets(address: string): Promise<import("../lib/types").RPCResponse<string[]>>;
|
|
36
|
-
|
|
38
|
+
getAccounts(params: GetAccountsParams): Promise<import("../lib/types").RPCResponse<string[]>>;
|
|
39
|
+
isTxExecutedInBlock(params: IsTxExecutedInBlockParams): Promise<import("../lib/types").RPCResponse<boolean>>;
|
|
37
40
|
getDevFeeThresholds(): Promise<import("../lib/types").RPCResponse<DevFee[]>>;
|
|
38
41
|
getSizeOnDisk(): Promise<import("../lib/types").RPCResponse<DiskSize>>;
|
|
39
|
-
isTxExecutedInBlock(params: IsTxExecutedInBlockParams): Promise<import("../lib/types").RPCResponse<boolean>>;
|
|
40
42
|
}
|
|
41
43
|
export default RPC;
|
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
export interface GetInfoResult {
|
|
2
|
+
average_block_time: number;
|
|
3
|
+
block_reward: number;
|
|
2
4
|
block_time_target: number;
|
|
3
|
-
difficulty: number;
|
|
4
|
-
height: number;
|
|
5
|
-
mempool_size: number;
|
|
6
5
|
circulating_supply: number;
|
|
6
|
+
difficulty: string;
|
|
7
|
+
height: number;
|
|
7
8
|
maximum_supply: number;
|
|
9
|
+
mempool_size: number;
|
|
10
|
+
network: string;
|
|
11
|
+
pruned_topoheight?: number;
|
|
8
12
|
stableheight: number;
|
|
9
13
|
top_block_hash: string;
|
|
10
|
-
version: string;
|
|
11
|
-
network: string;
|
|
12
14
|
topoheight: number;
|
|
15
|
+
version: string;
|
|
13
16
|
}
|
|
14
17
|
export interface Block {
|
|
15
|
-
block_type: string;
|
|
16
|
-
cumulative_difficulty: number;
|
|
17
|
-
supply: number;
|
|
18
|
-
difficulty: number;
|
|
19
|
-
reward: number;
|
|
20
|
-
extra_nonce: string;
|
|
21
18
|
hash: string;
|
|
19
|
+
topoheight?: number;
|
|
20
|
+
block_type: BlockType;
|
|
21
|
+
difficulty: string;
|
|
22
|
+
supply?: number;
|
|
23
|
+
reward?: number;
|
|
24
|
+
cumulative_difficulty: string;
|
|
25
|
+
total_fees?: number;
|
|
26
|
+
total_size_in_bytes: number;
|
|
27
|
+
version: number;
|
|
28
|
+
tips: string[];
|
|
29
|
+
timestamp: number;
|
|
22
30
|
height: number;
|
|
23
|
-
miner: string;
|
|
24
31
|
nonce: number;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
total_fees: number;
|
|
28
|
-
total_size_in_bytes: number;
|
|
29
|
-
transactions?: Transaction[];
|
|
32
|
+
extra_nonce: string;
|
|
33
|
+
miner: string;
|
|
30
34
|
txs_hashes: string[];
|
|
31
|
-
|
|
35
|
+
transactions?: Transaction[];
|
|
32
36
|
}
|
|
33
37
|
export interface GetBalanceParams {
|
|
34
38
|
address: string;
|
|
@@ -43,17 +47,35 @@ export interface GetNonceParams {
|
|
|
43
47
|
address: string;
|
|
44
48
|
topoheight: number;
|
|
45
49
|
}
|
|
46
|
-
export interface
|
|
50
|
+
export interface VersionedNonce {
|
|
47
51
|
nonce: number;
|
|
48
|
-
previous_topoheight
|
|
52
|
+
previous_topoheight?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface GetNonceResult {
|
|
55
|
+
version: VersionedNonce;
|
|
56
|
+
topoheight: number;
|
|
57
|
+
}
|
|
58
|
+
export interface GetNonceAtTopoheightParams {
|
|
59
|
+
address: string;
|
|
49
60
|
topoheight: number;
|
|
50
61
|
}
|
|
51
|
-
export interface
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
export interface EncryptedBalance {
|
|
63
|
+
commitment: number[];
|
|
64
|
+
handle: number[];
|
|
65
|
+
}
|
|
66
|
+
export declare enum BalanceType {
|
|
67
|
+
Input = "input",
|
|
68
|
+
Output = "output",
|
|
69
|
+
Both = "both"
|
|
70
|
+
}
|
|
71
|
+
export interface VersionedBalance {
|
|
72
|
+
balance_type: BalanceType;
|
|
73
|
+
final_balance: EncryptedBalance;
|
|
74
|
+
output_balance?: EncryptedBalance;
|
|
75
|
+
previous_topoheight?: number;
|
|
54
76
|
}
|
|
55
77
|
export interface GetBalanceResult {
|
|
56
|
-
version:
|
|
78
|
+
version: VersionedBalance;
|
|
57
79
|
topoheight: number;
|
|
58
80
|
}
|
|
59
81
|
export interface P2PStatusResult {
|
|
@@ -76,20 +98,22 @@ export interface RPCEventResult {
|
|
|
76
98
|
event: string;
|
|
77
99
|
}
|
|
78
100
|
export type PeerPeers = {
|
|
79
|
-
[
|
|
101
|
+
[addr: string]: `In` | `Out` | `Both`;
|
|
80
102
|
};
|
|
81
103
|
export interface Peer {
|
|
82
104
|
id: number;
|
|
83
105
|
addr: string;
|
|
84
|
-
|
|
106
|
+
local_port: number;
|
|
107
|
+
tag?: string;
|
|
85
108
|
version: string;
|
|
86
109
|
top_block_hash: string;
|
|
87
110
|
topoheight: number;
|
|
88
111
|
height: number;
|
|
89
112
|
last_ping: number;
|
|
90
|
-
pruned_topoheight
|
|
113
|
+
pruned_topoheight?: number;
|
|
91
114
|
peers: PeerPeers;
|
|
92
|
-
cumulative_difficulty:
|
|
115
|
+
cumulative_difficulty: string;
|
|
116
|
+
connected_on: number;
|
|
93
117
|
}
|
|
94
118
|
export interface BlockOrdered {
|
|
95
119
|
topoheight: number;
|
|
@@ -100,31 +124,66 @@ export interface BlockOrphaned {
|
|
|
100
124
|
block_hash: string;
|
|
101
125
|
old_topoheight: number;
|
|
102
126
|
}
|
|
127
|
+
export interface StableHeightChanged {
|
|
128
|
+
previous_stable_height: number;
|
|
129
|
+
new_stable_height: number;
|
|
130
|
+
}
|
|
131
|
+
export interface Proof {
|
|
132
|
+
Y_0: number[];
|
|
133
|
+
Y_1: number[];
|
|
134
|
+
z_r: number[];
|
|
135
|
+
z_x: number[];
|
|
136
|
+
}
|
|
137
|
+
export interface EqProof {
|
|
138
|
+
Y_0: number[];
|
|
139
|
+
Y_1: number[];
|
|
140
|
+
Y_2: number[];
|
|
141
|
+
z_r: number[];
|
|
142
|
+
z_s: number[];
|
|
143
|
+
z_x: number[];
|
|
144
|
+
}
|
|
103
145
|
export interface Transfer {
|
|
104
|
-
amount: number;
|
|
105
146
|
asset: string;
|
|
147
|
+
destination: string;
|
|
106
148
|
extra_data?: any;
|
|
107
|
-
|
|
149
|
+
commitment: number[];
|
|
150
|
+
sender_handle: number[];
|
|
151
|
+
receiver_handle: number[];
|
|
152
|
+
ct_validity_proof: Proof;
|
|
153
|
+
}
|
|
154
|
+
export interface Burn {
|
|
155
|
+
asset: string;
|
|
156
|
+
amount: number;
|
|
108
157
|
}
|
|
109
158
|
export interface TransactionData {
|
|
110
159
|
transfers: Transfer[];
|
|
111
|
-
burn:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
160
|
+
burn: Burn;
|
|
161
|
+
}
|
|
162
|
+
export interface SourceCommitment {
|
|
163
|
+
commitment: number[];
|
|
164
|
+
proof: EqProof;
|
|
165
|
+
asset: string;
|
|
166
|
+
}
|
|
167
|
+
export interface Reference {
|
|
168
|
+
hash: string;
|
|
169
|
+
topoheight: number;
|
|
119
170
|
}
|
|
120
171
|
export interface Transaction {
|
|
121
172
|
hash: string;
|
|
122
|
-
|
|
173
|
+
version: number;
|
|
174
|
+
source: string;
|
|
123
175
|
data: TransactionData;
|
|
124
176
|
fee: number;
|
|
125
177
|
nonce: number;
|
|
126
|
-
|
|
178
|
+
source_commitments: SourceCommitment[];
|
|
179
|
+
range_proof: number[];
|
|
127
180
|
signature: string;
|
|
181
|
+
reference: Reference;
|
|
182
|
+
}
|
|
183
|
+
export interface TransactionResponse extends Transaction {
|
|
184
|
+
blocks: string[];
|
|
185
|
+
executed_in_block: string;
|
|
186
|
+
in_mempool: boolean;
|
|
128
187
|
first_seen?: number;
|
|
129
188
|
}
|
|
130
189
|
export interface GetAccountsParams {
|
|
@@ -156,7 +215,6 @@ export interface GetAccountHistoryParams {
|
|
|
156
215
|
}
|
|
157
216
|
export interface AccounHistory {
|
|
158
217
|
topoheight: number;
|
|
159
|
-
block_timestamp: number;
|
|
160
218
|
hash: string;
|
|
161
219
|
mining?: {
|
|
162
220
|
reward: number;
|
|
@@ -165,11 +223,12 @@ export interface AccounHistory {
|
|
|
165
223
|
amount: number;
|
|
166
224
|
};
|
|
167
225
|
outgoing?: {
|
|
168
|
-
|
|
226
|
+
to: string;
|
|
169
227
|
};
|
|
170
228
|
incoming?: {
|
|
171
|
-
|
|
229
|
+
from: string;
|
|
172
230
|
};
|
|
231
|
+
block_timestamp: number;
|
|
173
232
|
}
|
|
174
233
|
export interface PeerPeerListUpdated {
|
|
175
234
|
peer_id: number;
|
|
@@ -203,6 +262,9 @@ export interface HasBalanceParams {
|
|
|
203
262
|
export interface HasBalanceResult {
|
|
204
263
|
exists: boolean;
|
|
205
264
|
}
|
|
265
|
+
export interface HasNonceResult {
|
|
266
|
+
exists: boolean;
|
|
267
|
+
}
|
|
206
268
|
export interface IsTxExecutedInBlockParams {
|
|
207
269
|
tx_hash: string;
|
|
208
270
|
block_hash: string;
|
|
@@ -210,12 +272,26 @@ export interface IsTxExecutedInBlockParams {
|
|
|
210
272
|
export interface GetAssetParams {
|
|
211
273
|
asset: string;
|
|
212
274
|
}
|
|
275
|
+
export interface GetPeersResult {
|
|
276
|
+
peers: Peer[];
|
|
277
|
+
total_peers: number;
|
|
278
|
+
hidden_peers: number;
|
|
279
|
+
}
|
|
213
280
|
export declare enum BlockType {
|
|
214
281
|
Sync = "Sync",
|
|
215
282
|
Normal = "Normal",
|
|
216
283
|
Side = "Side",
|
|
217
284
|
Orphaned = "Orphaned"
|
|
218
285
|
}
|
|
286
|
+
export interface GetBlockTemplateResult {
|
|
287
|
+
template: string;
|
|
288
|
+
height: number;
|
|
289
|
+
difficulty: number;
|
|
290
|
+
}
|
|
291
|
+
export interface HasNonceParams {
|
|
292
|
+
address: string;
|
|
293
|
+
topoheight?: number;
|
|
294
|
+
}
|
|
219
295
|
export declare enum RPCMethod {
|
|
220
296
|
GetVersion = "get_version",
|
|
221
297
|
GetInfo = "get_info",
|
|
@@ -228,6 +304,8 @@ export declare enum RPCMethod {
|
|
|
228
304
|
GetBlockByHash = "get_block_by_hash",
|
|
229
305
|
GetTopBlock = "get_top_block",
|
|
230
306
|
GetNonce = "get_nonce",
|
|
307
|
+
GetNonceAtTopoheight = "get_nonce_at_topoheight",
|
|
308
|
+
HasNonce = "has_nonce",
|
|
231
309
|
GetBalance = "get_balance",
|
|
232
310
|
HasBalance = "has_balance",
|
|
233
311
|
GetBalanceAtTopoHeight = "get_balance_at_topoheight",
|
|
@@ -256,15 +334,17 @@ export declare enum RPCMethod {
|
|
|
256
334
|
}
|
|
257
335
|
export declare enum RPCEvent {
|
|
258
336
|
NewBlock = "new_block",
|
|
337
|
+
BlockOrdered = "block_ordered",
|
|
338
|
+
BlockOrphaned = "block_orphaned",
|
|
339
|
+
StableHeightChanged = "stable_height_changed",
|
|
340
|
+
TransactionOrphaned = "transaction_orphaned",
|
|
259
341
|
TransactionAddedInMempool = "transaction_added_in_mempool",
|
|
260
342
|
TransactionExecuted = "transaction_executed",
|
|
261
|
-
BlockOrdered = "block_ordered",
|
|
262
343
|
TransactionSCResult = "transaction_sc_result",
|
|
263
344
|
NewAsset = "new_asset",
|
|
264
345
|
PeerConnected = "peer_connected",
|
|
265
346
|
PeerDisconnected = "peer_disconnected",
|
|
266
|
-
PeerStateUpdated = "peer_state_updated",
|
|
267
347
|
PeerPeerListUpdated = "peer_peer_list_updated",
|
|
268
|
-
|
|
269
|
-
|
|
348
|
+
PeerStateUpdated = "peer_state_updated",
|
|
349
|
+
PeerPeerDisconnected = "peer_peer_disconnected"
|
|
270
350
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageEvent } from 'ws';
|
|
2
|
-
import { Block, GetInfoResult,
|
|
2
|
+
import { Block, GetInfoResult, GetPeersResult, RPCEventResult, TopoHeightRangeParams, P2PStatusResult, GetBalanceAtTopoHeightParams, GetBalanceResult, HeightRangeParams, BlockOrdered, GetBalanceParams, GetAccountsParams, GetBlockAtTopoHeightParams, GetBlockByHashParams, GetBlocksAtHeightParams, GetTopBlockParams, GetNonceParams, GetNonceResult, GetAccountHistoryParams, AccounHistory, Peer, PeerPeerListUpdated, PeerPeerDisconnected, DevFee, DiskSize, AssetWithData, AssetData, GetAssetParams, HasBalanceParams, HasBalanceResult, IsTxExecutedInBlockParams, BlockOrphaned, VersionedBalance, StableHeightChanged, HasNonceResult, HasNonceParams, TransactionResponse } from './types';
|
|
3
3
|
import { WS as BaseWS } from '../lib/websocket';
|
|
4
4
|
export declare class DaemonMethods {
|
|
5
5
|
ws: BaseWS;
|
|
@@ -8,8 +8,8 @@ export declare class DaemonMethods {
|
|
|
8
8
|
listenEvent<T>(event: string, onData: (msgEvent: MessageEvent, data?: T, err?: Error) => void): Promise<() => Promise<void>>;
|
|
9
9
|
dataCall<T>(method: string, params?: any): Promise<T>;
|
|
10
10
|
onNewBlock(onData: (msgEvent: MessageEvent, data?: Block & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
11
|
-
onTransactionAddedInMempool(onData: (msgEvent: MessageEvent, data?:
|
|
12
|
-
onTransactionExecuted(onData: (msgEvent: MessageEvent, data?:
|
|
11
|
+
onTransactionAddedInMempool(onData: (msgEvent: MessageEvent, data?: TransactionResponse & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
12
|
+
onTransactionExecuted(onData: (msgEvent: MessageEvent, data?: TransactionResponse & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
13
13
|
onBlockOrdered(onData: (msgEvent: MessageEvent, data?: BlockOrdered & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
14
14
|
onPeerConnected(onData: (msgEvent: MessageEvent, data?: Peer & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
15
15
|
onPeerDisconnected(onData: (msgEvent: MessageEvent, data?: number & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
@@ -18,8 +18,9 @@ export declare class DaemonMethods {
|
|
|
18
18
|
onPeerStateUpdated(onData: (msgEvent: MessageEvent, data?: Peer & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
19
19
|
onNewAsset(onData: (msgEvent: MessageEvent, data?: AssetWithData & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
20
20
|
onBlockOrphaned(onData: (msgEvent: MessageEvent, data?: BlockOrphaned & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
21
|
+
onTransactionOrphaned(onData: (msgEvent: MessageEvent, data?: TransactionResponse & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
22
|
+
onStableHeightChanged(onData: (msgEvent: MessageEvent, data?: StableHeightChanged & RPCEventResult, err?: Error) => void): Promise<() => Promise<void>>;
|
|
21
23
|
getVersion(): Promise<string>;
|
|
22
|
-
getInfo(): Promise<GetInfoResult>;
|
|
23
24
|
getHeight(): Promise<number>;
|
|
24
25
|
getTopoHeight(): Promise<number>;
|
|
25
26
|
getStableHeight(): Promise<number>;
|
|
@@ -28,31 +29,34 @@ export declare class DaemonMethods {
|
|
|
28
29
|
getBlocksAtHeight(params: GetBlocksAtHeightParams): Promise<Block[]>;
|
|
29
30
|
getBlockByHash(params: GetBlockByHashParams): Promise<Block>;
|
|
30
31
|
getTopBlock(params: GetTopBlockParams): Promise<Block>;
|
|
31
|
-
|
|
32
|
+
submitBlock(blockTemplate: string): Promise<boolean>;
|
|
32
33
|
getBalance(params: GetBalanceParams): Promise<GetBalanceResult>;
|
|
33
34
|
hasBalance(params: HasBalanceParams): Promise<HasBalanceResult>;
|
|
34
|
-
getBalanceAtTopoHeight(params: GetBalanceAtTopoHeightParams): Promise<
|
|
35
|
+
getBalanceAtTopoHeight(params: GetBalanceAtTopoHeightParams): Promise<VersionedBalance>;
|
|
36
|
+
getInfo(): Promise<GetInfoResult>;
|
|
37
|
+
getNonce(params: GetNonceParams): Promise<GetNonceResult>;
|
|
38
|
+
hasNonce(params: HasNonceParams): Promise<HasNonceResult>;
|
|
35
39
|
getAsset(params: GetAssetParams): Promise<AssetData>;
|
|
36
40
|
getAssets(): Promise<string[]>;
|
|
41
|
+
countAssets(): Promise<number>;
|
|
42
|
+
countAccounts(): Promise<number>;
|
|
37
43
|
countTransactions(): Promise<number>;
|
|
38
|
-
|
|
44
|
+
submitTransaction(hexData: string): Promise<boolean>;
|
|
45
|
+
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
39
46
|
p2pStatus(): Promise<P2PStatusResult>;
|
|
47
|
+
getPeers(): Promise<GetPeersResult>;
|
|
48
|
+
getMemPool(): Promise<TransactionResponse[]>;
|
|
49
|
+
getTips(): Promise<string[]>;
|
|
40
50
|
getDAGOrder(params: TopoHeightRangeParams): Promise<string[]>;
|
|
41
|
-
getMemPool(): Promise<Transaction[]>;
|
|
42
|
-
getTransaction(hash: string): Promise<Transaction>;
|
|
43
|
-
getTransactions(txHashes: string[]): Promise<Transaction[]>;
|
|
44
51
|
getBlocksRangeByTopoheight(params: TopoHeightRangeParams): Promise<Block[]>;
|
|
45
52
|
getBlocksRangeByHeight(params: HeightRangeParams): Promise<Block[]>;
|
|
46
|
-
|
|
47
|
-
submitBlock(blockTemplate: string): Promise<boolean>;
|
|
48
|
-
submitTransaction(hexData: string): Promise<boolean>;
|
|
49
|
-
countAccounts(): Promise<number>;
|
|
53
|
+
getTransactions(txHashes: string[]): Promise<TransactionResponse[]>;
|
|
50
54
|
getAccountHistory(params: GetAccountHistoryParams): Promise<AccounHistory[]>;
|
|
51
55
|
getAccountAssets(address: string): Promise<string[]>;
|
|
52
|
-
|
|
56
|
+
getAccounts(params: GetAccountsParams): Promise<string[]>;
|
|
57
|
+
isTxExecutedInBlock(params: IsTxExecutedInBlockParams): Promise<boolean>;
|
|
53
58
|
getDevFeeThresholds(): Promise<DevFee[]>;
|
|
54
59
|
getSizeOnDisk(): Promise<DiskSize>;
|
|
55
|
-
isTxExecutedInBlock(params: IsTxExecutedInBlockParams): Promise<boolean>;
|
|
56
60
|
}
|
|
57
61
|
export declare class WS extends BaseWS {
|
|
58
62
|
methods: DaemonMethods;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GetAddressParams, SplitAddressParams, SplitAddressResult, BuildTransactionParams, BuildTransactionResult, ListTransactionParams } from './types';
|
|
1
|
+
import { GetAssetParams, HasBalanceResult, TransactionData } from '../daemon/types';
|
|
2
|
+
import { GetAddressParams, SplitAddressParams, SplitAddressResult, BuildTransactionParams, BuildTransactionResult, ListTransactionParams, Signature, TransactionEntry } from './types';
|
|
3
3
|
import { RPC as BaseRPC } from '../lib/rpc';
|
|
4
4
|
import { RPCResponse } from '../lib/types';
|
|
5
5
|
export declare class RPC extends BaseRPC {
|
|
@@ -7,17 +7,21 @@ export declare class RPC extends BaseRPC {
|
|
|
7
7
|
constructor(endpoint: string, username: string, password: string);
|
|
8
8
|
post<T>(method: string, params?: any): Promise<RPCResponse<T>>;
|
|
9
9
|
getVersion(): Promise<RPCResponse<string>>;
|
|
10
|
+
getNetwork(): Promise<RPCResponse<string>>;
|
|
10
11
|
getNonce(): Promise<RPCResponse<number>>;
|
|
11
12
|
getTopoheight(): Promise<RPCResponse<number>>;
|
|
12
13
|
getAddress(params?: GetAddressParams): Promise<RPCResponse<string>>;
|
|
13
|
-
rescan(): Promise<RPCResponse<void>>;
|
|
14
14
|
splitAddress(params: SplitAddressParams): Promise<RPCResponse<SplitAddressResult>>;
|
|
15
|
+
rescan(): Promise<RPCResponse<void>>;
|
|
15
16
|
getBalance(asset?: string): Promise<RPCResponse<number>>;
|
|
17
|
+
hasBalance(asset?: string): Promise<RPCResponse<HasBalanceResult>>;
|
|
16
18
|
getTrackedAssets(): Promise<RPCResponse<string[]>>;
|
|
17
19
|
getAssetPrecision(params: GetAssetParams): Promise<RPCResponse<number>>;
|
|
18
|
-
getTransaction(hash: string): Promise<RPCResponse<
|
|
20
|
+
getTransaction(hash: string): Promise<RPCResponse<TransactionEntry>>;
|
|
19
21
|
buildTransaction(params: BuildTransactionParams): Promise<RPCResponse<BuildTransactionResult>>;
|
|
20
|
-
listTransactions(params?: ListTransactionParams): Promise<RPCResponse<
|
|
22
|
+
listTransactions(params?: ListTransactionParams): Promise<RPCResponse<TransactionEntry[]>>;
|
|
21
23
|
isOnline(): Promise<RPCResponse<boolean>>;
|
|
24
|
+
signData(data: any): Promise<RPCResponse<Signature>>;
|
|
25
|
+
estimateFees(txData: TransactionData): Promise<RPCResponse<number>>;
|
|
22
26
|
}
|
|
23
27
|
export default RPC;
|
|
@@ -27,6 +27,31 @@ export interface ListTransactionParams {
|
|
|
27
27
|
accept_coinbase?: boolean;
|
|
28
28
|
accept_burn?: boolean;
|
|
29
29
|
}
|
|
30
|
+
export interface Signature {
|
|
31
|
+
s: number[];
|
|
32
|
+
e: number[];
|
|
33
|
+
}
|
|
34
|
+
export interface TxCoinbase {
|
|
35
|
+
reward: number;
|
|
36
|
+
}
|
|
37
|
+
export interface TxBurn {
|
|
38
|
+
asset: string;
|
|
39
|
+
amount: number;
|
|
40
|
+
}
|
|
41
|
+
export interface TxIncoming {
|
|
42
|
+
from: string;
|
|
43
|
+
transfers: any;
|
|
44
|
+
}
|
|
45
|
+
export interface TxOutgoing {
|
|
46
|
+
transfers: any;
|
|
47
|
+
fees: number;
|
|
48
|
+
nonce: number;
|
|
49
|
+
}
|
|
50
|
+
export interface TransactionEntry {
|
|
51
|
+
hash: string;
|
|
52
|
+
topoheight: number;
|
|
53
|
+
entry: TxCoinbase | TxBurn | TxIncoming | TxOutgoing;
|
|
54
|
+
}
|
|
30
55
|
export declare enum RPCMethod {
|
|
31
56
|
GetVersion = "get_version",
|
|
32
57
|
GetNetwork = "get_network",
|
|
@@ -36,6 +61,7 @@ export declare enum RPCMethod {
|
|
|
36
61
|
SplitAddress = "split_address",
|
|
37
62
|
Rescan = "rescan",
|
|
38
63
|
GetBalance = "get_balance",
|
|
64
|
+
HasBalance = "has_balance",
|
|
39
65
|
GetTrackedAssets = "get_tracked_assets",
|
|
40
66
|
GetAssetPrecision = "get_asset_precision",
|
|
41
67
|
GetTransaction = "get_transaction",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WS as BaseWS } from '../lib/websocket';
|
|
2
|
-
import { GetAssetParams,
|
|
3
|
-
import { BuildTransactionParams, BuildTransactionResult, GetAddressParams, ListTransactionParams, SplitAddressParams, SplitAddressResult } from './types';
|
|
2
|
+
import { GetAssetParams, TransactionData } from '../daemon/types';
|
|
3
|
+
import { BuildTransactionParams, BuildTransactionResult, GetAddressParams, ListTransactionParams, SplitAddressParams, SplitAddressResult, Signature, TransactionEntry } from './types';
|
|
4
4
|
export declare class WalletMethods {
|
|
5
5
|
ws: BaseWS;
|
|
6
6
|
prefix: string;
|
|
@@ -11,15 +11,17 @@ export declare class WalletMethods {
|
|
|
11
11
|
getNonce(): Promise<number>;
|
|
12
12
|
getTopoheight(): Promise<number>;
|
|
13
13
|
getAddress(params?: GetAddressParams): Promise<string>;
|
|
14
|
-
rescan(): Promise<void>;
|
|
15
14
|
splitAddress(params: SplitAddressParams): Promise<SplitAddressResult>;
|
|
15
|
+
rescan(): Promise<void>;
|
|
16
16
|
getBalance(asset?: string): Promise<number>;
|
|
17
17
|
getTrackedAssets(): Promise<string[]>;
|
|
18
18
|
getAssetPrecision(params: GetAssetParams): Promise<number>;
|
|
19
|
-
getTransaction(hash: string): Promise<
|
|
19
|
+
getTransaction(hash: string): Promise<TransactionEntry>;
|
|
20
20
|
buildTransaction(params: BuildTransactionParams): Promise<BuildTransactionResult>;
|
|
21
|
-
listTransactions(params?: ListTransactionParams): Promise<
|
|
21
|
+
listTransactions(params?: ListTransactionParams): Promise<TransactionEntry[]>;
|
|
22
22
|
isOnline(): Promise<boolean>;
|
|
23
|
+
signData(data: any): Promise<Signature>;
|
|
24
|
+
estimateFees(txData: TransactionData): Promise<number>;
|
|
23
25
|
}
|
|
24
26
|
export declare class WS extends BaseWS {
|
|
25
27
|
methods: WalletMethods;
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.8.0",
|
|
3
3
|
"name": "@xelis/sdk",
|
|
4
4
|
"description": "Xelis software development kit for JS",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./*": {
|
|
7
|
+
"types": "./dist/types/*.d.ts",
|
|
8
|
+
"require": "./dist/cjs/*.js",
|
|
9
|
+
"import": "./dist/esm/*.js",
|
|
10
|
+
"default": "./dist/esm/*.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
5
13
|
"repository": {
|
|
6
14
|
"type": "git",
|
|
7
15
|
"url": "git+https://github.com/xelis-project/xelis-js-sdk"
|
|
@@ -9,8 +17,9 @@
|
|
|
9
17
|
"homepage": "https://github.com/xelis-project/xelis-js-sdk#readme",
|
|
10
18
|
"scripts": {
|
|
11
19
|
"test": "jest",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
20
|
+
"compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
|
|
21
|
+
"clean": "rm -rf ./dist",
|
|
22
|
+
"build": "npm run clean && npm run compile && node create_esm_pkg.js"
|
|
14
23
|
},
|
|
15
24
|
"devDependencies": {
|
|
16
25
|
"@types/jest": "^29.4.0",
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"jsx": "react",
|
|
4
|
+
"moduleResolution": "node",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"./src/**/*"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"node_modules",
|
|
15
|
+
"**/*.spec.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|