@xelis/sdk 0.11.44 → 0.12.1
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/dist/cjs/address/index.spec.js +34 -0
- package/dist/cjs/daemon/rpc.js +17 -2
- package/dist/cjs/daemon/rpc.spec.js +640 -0
- package/dist/cjs/daemon/types.js +8 -3
- package/dist/cjs/daemon/websocket.js +16 -1
- package/dist/cjs/daemon/websocket.spec.js +103 -0
- package/dist/cjs/data/element.spec.js +67 -0
- package/dist/cjs/rpc/parse_json/parse_json.spec.js +24 -0
- package/dist/cjs/wallet/rpc.js +24 -0
- package/dist/cjs/wallet/rpc.spec.js +270 -0
- package/dist/cjs/wallet/types.js +10 -1
- package/dist/cjs/wallet/websocket.js +26 -2
- package/dist/cjs/wallet/websocket.spec.js +20 -0
- package/dist/cjs/xswd/websocket.spec.js +34 -0
- package/dist/esm/address/index.spec.js +29 -0
- package/dist/esm/daemon/rpc.js +17 -2
- package/dist/esm/daemon/rpc.spec.js +635 -0
- package/dist/esm/daemon/types.js +8 -3
- package/dist/esm/daemon/websocket.js +16 -1
- package/dist/esm/daemon/websocket.spec.js +98 -0
- package/dist/esm/data/element.spec.js +65 -0
- package/dist/esm/rpc/parse_json/parse_json.spec.js +19 -0
- package/dist/esm/wallet/rpc.js +24 -0
- package/dist/esm/wallet/rpc.spec.js +265 -0
- package/dist/esm/wallet/types.js +10 -1
- package/dist/esm/wallet/websocket.js +26 -2
- package/dist/esm/wallet/websocket.spec.js +15 -0
- package/dist/esm/xswd/websocket.spec.js +29 -0
- package/dist/types/address/index.spec.d.ts +1 -0
- package/dist/types/daemon/rpc.d.ts +7 -2
- package/dist/types/daemon/rpc.spec.d.ts +1 -0
- package/dist/types/daemon/types.d.ts +56 -4
- package/dist/types/daemon/websocket.d.ts +8 -9
- package/dist/types/daemon/websocket.spec.d.ts +1 -0
- package/dist/types/data/element.spec.d.ts +1 -0
- package/dist/types/rpc/parse_json/parse_json.spec.d.ts +1 -0
- package/dist/types/wallet/rpc.d.ts +8 -0
- package/dist/types/wallet/rpc.spec.d.ts +1 -0
- package/dist/types/wallet/types.d.ts +46 -1
- package/dist/types/wallet/websocket.d.ts +12 -0
- package/dist/types/wallet/websocket.spec.d.ts +1 -0
- package/dist/types/xswd/websocket.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const await_to_js_1 = require("await-to-js");
|
|
7
|
+
const config_1 = require("../config");
|
|
8
|
+
const rpc_1 = __importDefault(require("./rpc"));
|
|
9
|
+
describe('DaemonRPC', () => {
|
|
10
|
+
const daemon = new rpc_1.default(config_1.MAINNET_NODE_RPC);
|
|
11
|
+
let realAddress;
|
|
12
|
+
let realContract;
|
|
13
|
+
let realBlockHash;
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
// Fetch real data from the daemon for dependent tests
|
|
16
|
+
const [err1, accounts] = await (0, await_to_js_1.to)(daemon.getAccounts({ maximum: 1 }));
|
|
17
|
+
if (!err1 && accounts && accounts.length > 0) {
|
|
18
|
+
realAddress = accounts[0];
|
|
19
|
+
}
|
|
20
|
+
const [err2, contracts] = await (0, await_to_js_1.to)(daemon.getContracts({ maximum: 1 }));
|
|
21
|
+
if (!err2 && contracts && contracts.length > 0) {
|
|
22
|
+
realContract = contracts[0];
|
|
23
|
+
}
|
|
24
|
+
const [err3, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
25
|
+
if (!err3 && topBlock) {
|
|
26
|
+
realBlockHash = topBlock.hash;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
test('getVersion', async () => {
|
|
30
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getVersion());
|
|
31
|
+
expect(err).toBeNull();
|
|
32
|
+
expect(res).toBeDefined();
|
|
33
|
+
console.log('Version:', res);
|
|
34
|
+
});
|
|
35
|
+
test('getHeight', async () => {
|
|
36
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getHeight());
|
|
37
|
+
expect(err).toBeNull();
|
|
38
|
+
expect(res).toBeGreaterThan(0);
|
|
39
|
+
console.log('Height:', res);
|
|
40
|
+
});
|
|
41
|
+
test('getTopoheight', async () => {
|
|
42
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTopoheight());
|
|
43
|
+
expect(err).toBeNull();
|
|
44
|
+
expect(res).toBeGreaterThan(0);
|
|
45
|
+
console.log('Topoheight:', res);
|
|
46
|
+
});
|
|
47
|
+
test('getPrunedTopoheight', async () => {
|
|
48
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getPrunedTopoheight());
|
|
49
|
+
expect(err).toBeNull();
|
|
50
|
+
console.log('Pruned topoheight:', res);
|
|
51
|
+
});
|
|
52
|
+
test('getInfo', async () => {
|
|
53
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getInfo());
|
|
54
|
+
expect(err).toBeNull();
|
|
55
|
+
expect(res).toBeDefined();
|
|
56
|
+
expect(res.height).toBeGreaterThan(0);
|
|
57
|
+
expect(res.version).toBeDefined();
|
|
58
|
+
console.log('Info:', res);
|
|
59
|
+
});
|
|
60
|
+
test('getDifficulty', async () => {
|
|
61
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getDifficulty());
|
|
62
|
+
expect(err).toBeNull();
|
|
63
|
+
expect(res).toBeDefined();
|
|
64
|
+
expect(res.difficulty).toBeDefined();
|
|
65
|
+
console.log('Difficulty:', res);
|
|
66
|
+
});
|
|
67
|
+
test('getTips', async () => {
|
|
68
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTips());
|
|
69
|
+
expect(err).toBeNull();
|
|
70
|
+
expect(Array.isArray(res)).toBe(true);
|
|
71
|
+
console.log('Tips count:', res?.length);
|
|
72
|
+
});
|
|
73
|
+
test('getDevFeeThresholds', async () => {
|
|
74
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getDevFeeThresholds());
|
|
75
|
+
expect(err).toBeNull();
|
|
76
|
+
expect(Array.isArray(res)).toBe(true);
|
|
77
|
+
console.log('Dev fee thresholds:', res);
|
|
78
|
+
});
|
|
79
|
+
test('getSizeOnDisk', async () => {
|
|
80
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getSizeOnDisk());
|
|
81
|
+
expect(err).toBeNull();
|
|
82
|
+
expect(res).toBeDefined();
|
|
83
|
+
expect(res.size_bytes).toBeGreaterThan(0);
|
|
84
|
+
console.log('Size on disk:', res);
|
|
85
|
+
});
|
|
86
|
+
test('getStableHeight', async () => {
|
|
87
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getStableHeight());
|
|
88
|
+
expect(err).toBeNull();
|
|
89
|
+
expect(res).toBeGreaterThan(0);
|
|
90
|
+
console.log('Stable height:', res);
|
|
91
|
+
});
|
|
92
|
+
test('getStableTopoheight', async () => {
|
|
93
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getStableTopoheight());
|
|
94
|
+
expect(err).toBeNull();
|
|
95
|
+
expect(res).toBeGreaterThan(0);
|
|
96
|
+
console.log('Stable topoheight:', res);
|
|
97
|
+
});
|
|
98
|
+
test('getHardForks', async () => {
|
|
99
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getHardForks());
|
|
100
|
+
expect(err).toBeNull();
|
|
101
|
+
expect(Array.isArray(res)).toBe(true);
|
|
102
|
+
console.log('Hard forks:', res);
|
|
103
|
+
});
|
|
104
|
+
test('getTopBlock', async () => {
|
|
105
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
106
|
+
expect(err).toBeNull();
|
|
107
|
+
expect(res).toBeDefined();
|
|
108
|
+
expect(res.hash).toBeDefined();
|
|
109
|
+
console.log('Top block:', res.hash);
|
|
110
|
+
});
|
|
111
|
+
test('getTopBlock with txs', async () => {
|
|
112
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTopBlock({ include_txs: true }));
|
|
113
|
+
expect(err).toBeNull();
|
|
114
|
+
expect(res).toBeDefined();
|
|
115
|
+
expect(res.transactions).toBeDefined();
|
|
116
|
+
console.log('Top block txs:', res.transactions?.length);
|
|
117
|
+
});
|
|
118
|
+
test('getAssets', async () => {
|
|
119
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAssets({ maximum: 5 }));
|
|
120
|
+
expect(err).toBeNull();
|
|
121
|
+
expect(Array.isArray(res)).toBe(true);
|
|
122
|
+
console.log('Assets:', res);
|
|
123
|
+
});
|
|
124
|
+
test('countAssets', async () => {
|
|
125
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.countAssets());
|
|
126
|
+
expect(err).toBeNull();
|
|
127
|
+
expect(res).toBeGreaterThan(0);
|
|
128
|
+
console.log('Asset count:', res);
|
|
129
|
+
});
|
|
130
|
+
test('countTransactions', async () => {
|
|
131
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.countTransactions());
|
|
132
|
+
expect(err).toBeNull();
|
|
133
|
+
expect(res).toBeGreaterThan(0);
|
|
134
|
+
console.log('Tx count:', res);
|
|
135
|
+
});
|
|
136
|
+
test('countAccounts', async () => {
|
|
137
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.countAccounts());
|
|
138
|
+
expect(err).toBeNull();
|
|
139
|
+
expect(res).toBeGreaterThan(0);
|
|
140
|
+
console.log('Account count:', res);
|
|
141
|
+
});
|
|
142
|
+
test('countContracts', async () => {
|
|
143
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.countContracts());
|
|
144
|
+
expect(err).toBeNull();
|
|
145
|
+
expect(res).toBeGreaterThanOrEqual(0);
|
|
146
|
+
console.log('Contract count:', res);
|
|
147
|
+
});
|
|
148
|
+
test('p2pStatus', async () => {
|
|
149
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.p2pStatus());
|
|
150
|
+
expect(err).toBeNull();
|
|
151
|
+
expect(res).toBeDefined();
|
|
152
|
+
expect(res.peer_count).toBeGreaterThanOrEqual(0);
|
|
153
|
+
console.log('P2P status:', res);
|
|
154
|
+
});
|
|
155
|
+
test('getPeers', async () => {
|
|
156
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getPeers());
|
|
157
|
+
expect(err).toBeNull();
|
|
158
|
+
expect(res).toBeDefined();
|
|
159
|
+
expect(res.total_peers).toBeGreaterThanOrEqual(0);
|
|
160
|
+
console.log('Peers:', res);
|
|
161
|
+
});
|
|
162
|
+
test('getMempool', async () => {
|
|
163
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getMemPool({ maximum: 5 }));
|
|
164
|
+
expect(err).toBeNull();
|
|
165
|
+
expect(res).toBeDefined();
|
|
166
|
+
console.log('Mempool total:', res?.total);
|
|
167
|
+
});
|
|
168
|
+
test('getMempoolSummary', async () => {
|
|
169
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getMempoolSummary({ maximum: 5 }));
|
|
170
|
+
expect(err).toBeNull();
|
|
171
|
+
expect(res).toBeDefined();
|
|
172
|
+
console.log('Mempool summary total:', res?.total);
|
|
173
|
+
});
|
|
174
|
+
test('getEstimatedFeeRates', async () => {
|
|
175
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getEstimatedFeeRates());
|
|
176
|
+
expect(err).toBeNull();
|
|
177
|
+
expect(res).toBeDefined();
|
|
178
|
+
expect(res.low).toBeGreaterThan(0);
|
|
179
|
+
console.log('Fee rates:', res);
|
|
180
|
+
});
|
|
181
|
+
test('getEstimatedFeePerKB', async () => {
|
|
182
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getEstimatedFeePerKB());
|
|
183
|
+
expect(err).toBeNull();
|
|
184
|
+
expect(res).toBeDefined();
|
|
185
|
+
expect(res.fee_per_kb).toBeGreaterThan(0);
|
|
186
|
+
console.log('Fee per KB:', res);
|
|
187
|
+
});
|
|
188
|
+
test('getDAGOrder', async () => {
|
|
189
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getDAGOrder({ start_topoheight: 0, end_topoheight: 10 }));
|
|
190
|
+
expect(err).toBeNull();
|
|
191
|
+
expect(Array.isArray(res)).toBe(true);
|
|
192
|
+
console.log('DAG order count:', res?.length);
|
|
193
|
+
});
|
|
194
|
+
test('getBlocksRangeByTopoheight', async () => {
|
|
195
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBlocksRangeByTopoheight({ start_topoheight: 0, end_topoheight: 2 }));
|
|
196
|
+
expect(err).toBeNull();
|
|
197
|
+
expect(Array.isArray(res)).toBe(true);
|
|
198
|
+
console.log('Blocks by topoheight count:', res?.length);
|
|
199
|
+
});
|
|
200
|
+
test('getBlocksRangeByHeight', async () => {
|
|
201
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBlocksRangeByHeight({ start_height: 0, end_height: 2 }));
|
|
202
|
+
expect(err).toBeNull();
|
|
203
|
+
expect(Array.isArray(res)).toBe(true);
|
|
204
|
+
console.log('Blocks by height count:', res?.length);
|
|
205
|
+
});
|
|
206
|
+
test('getAccounts', async () => {
|
|
207
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAccounts({ maximum: 5 }));
|
|
208
|
+
expect(err).toBeNull();
|
|
209
|
+
expect(Array.isArray(res)).toBe(true);
|
|
210
|
+
console.log('Accounts:', res);
|
|
211
|
+
});
|
|
212
|
+
test('validateAddress', async () => {
|
|
213
|
+
// Skip if no real address available
|
|
214
|
+
if (!realAddress) {
|
|
215
|
+
console.log('Skipping: no real address available');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.validateAddress({ address: realAddress, allow_integrated: false }));
|
|
219
|
+
expect(err).toBeNull();
|
|
220
|
+
expect(res).toBeDefined();
|
|
221
|
+
console.log('Validate address:', res);
|
|
222
|
+
});
|
|
223
|
+
test('getContractTransactions', async () => {
|
|
224
|
+
// Skip if no real contract available
|
|
225
|
+
if (!realContract) {
|
|
226
|
+
console.log('Skipping: no real contract available');
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractTransactions({ contract: realContract, maximum: 5 }));
|
|
230
|
+
expect(err).toBeNull();
|
|
231
|
+
expect(res).toBeDefined();
|
|
232
|
+
console.log('Contract transactions:', res);
|
|
233
|
+
});
|
|
234
|
+
test('simulateContractInvoke', async () => {
|
|
235
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.simulateContractInvoke({
|
|
236
|
+
source: realAddress || 'xel:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqp5uek2',
|
|
237
|
+
contract: realContract || '0000000000000000000000000000000000000000000000000000000000000000',
|
|
238
|
+
deposits: {},
|
|
239
|
+
entry_id: 0,
|
|
240
|
+
parameters: []
|
|
241
|
+
}));
|
|
242
|
+
// simulate may fail if entry doesn't exist, but we should get a response
|
|
243
|
+
console.log('Simulate result:', err, res);
|
|
244
|
+
});
|
|
245
|
+
test('getBlockAtTopoheight', async () => {
|
|
246
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBlockAtTopoheight({ topoheight: 0 }));
|
|
247
|
+
expect(err).toBeNull();
|
|
248
|
+
expect(res).toBeDefined();
|
|
249
|
+
expect(res.hash).toBeDefined();
|
|
250
|
+
console.log('Block at topoheight 0:', res.hash);
|
|
251
|
+
});
|
|
252
|
+
test('getBlocksAtHeight', async () => {
|
|
253
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBlocksAtHeight({ height: 0 }));
|
|
254
|
+
expect(err).toBeNull();
|
|
255
|
+
expect(Array.isArray(res)).toBe(true);
|
|
256
|
+
console.log('Blocks at height 0:', res?.length);
|
|
257
|
+
});
|
|
258
|
+
test('getBlockByHash', async () => {
|
|
259
|
+
const [err1, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
260
|
+
expect(err1).toBeNull();
|
|
261
|
+
expect(topBlock).toBeDefined();
|
|
262
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.getBlockByHash({ hash: topBlock.hash }));
|
|
263
|
+
expect(err2).toBeNull();
|
|
264
|
+
expect(res).toBeDefined();
|
|
265
|
+
expect(res.hash).toBe(topBlock.hash);
|
|
266
|
+
console.log('Block by hash:', res.hash);
|
|
267
|
+
});
|
|
268
|
+
test('getBlockDifficultyByHash', async () => {
|
|
269
|
+
const [err1, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
270
|
+
expect(err1).toBeNull();
|
|
271
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.getBlockDifficultyByHash({ block_hash: topBlock.hash }));
|
|
272
|
+
expect(err2).toBeNull();
|
|
273
|
+
expect(res).toBeDefined();
|
|
274
|
+
console.log('Block difficulty:', res);
|
|
275
|
+
});
|
|
276
|
+
test('getBlockBaseFeeByHash', async () => {
|
|
277
|
+
const [err1, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
278
|
+
expect(err1).toBeNull();
|
|
279
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.getBlockBaseFeeByHash({ block_hash: topBlock.hash }));
|
|
280
|
+
expect(err2).toBeNull();
|
|
281
|
+
expect(res).toBeDefined();
|
|
282
|
+
console.log('Block base fee:', res);
|
|
283
|
+
});
|
|
284
|
+
test('getBlockSummaryAtTopoheight', async () => {
|
|
285
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBlockSummaryAtTopoheight({ topoheight: 0 }));
|
|
286
|
+
expect(err).toBeNull();
|
|
287
|
+
expect(res).toBeDefined();
|
|
288
|
+
console.log('Block summary at topoheight 0:', res);
|
|
289
|
+
});
|
|
290
|
+
test('getBlockSummaryByHash', async () => {
|
|
291
|
+
const [err1, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
292
|
+
expect(err1).toBeNull();
|
|
293
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.getBlockSummaryByHash({ hash: topBlock.hash }));
|
|
294
|
+
expect(err2).toBeNull();
|
|
295
|
+
expect(res).toBeDefined();
|
|
296
|
+
console.log('Block summary by hash:', res);
|
|
297
|
+
});
|
|
298
|
+
test('getAsset', async () => {
|
|
299
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAsset({ asset: '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
300
|
+
expect(err).toBeNull();
|
|
301
|
+
expect(res).toBeDefined();
|
|
302
|
+
console.log('XELIS asset:', res);
|
|
303
|
+
});
|
|
304
|
+
test('getAssetSupply', async () => {
|
|
305
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAssetSupply({ asset: '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
306
|
+
expect(err).toBeNull();
|
|
307
|
+
expect(res).toBeDefined();
|
|
308
|
+
expect(res.data).toBeGreaterThan(0);
|
|
309
|
+
console.log('XELIS supply:', res);
|
|
310
|
+
});
|
|
311
|
+
test('getAssetSupplyAtTopoheight', async () => {
|
|
312
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAssetSupplyAtTopoheight({ asset: '0000000000000000000000000000000000000000000000000000000000000000', topoheight: 0 }));
|
|
313
|
+
expect(err).toBeNull();
|
|
314
|
+
expect(res).toBeDefined();
|
|
315
|
+
console.log('XELIS supply at topoheight 0:', res);
|
|
316
|
+
});
|
|
317
|
+
test('getContractModule', async () => {
|
|
318
|
+
if (!realContract) {
|
|
319
|
+
console.log('Skipping: no real contract available');
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractModule({ contract: realContract }));
|
|
323
|
+
// Module may not be available for all contracts
|
|
324
|
+
console.log('Contract module:', err, res);
|
|
325
|
+
});
|
|
326
|
+
test('getContractData', async () => {
|
|
327
|
+
if (!realContract) {
|
|
328
|
+
console.log('Skipping: no real contract available');
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractData({ contract: realContract, key: '0' }));
|
|
332
|
+
// May fail if key doesn't exist
|
|
333
|
+
console.log('Contract data:', err, res);
|
|
334
|
+
});
|
|
335
|
+
test('getContractDataAtTopoheight', async () => {
|
|
336
|
+
if (!realContract) {
|
|
337
|
+
console.log('Skipping: no real contract available');
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractDataAtTopoheight({ contract: realContract, key: '0', topoheight: 0 }));
|
|
341
|
+
console.log('Contract data at topoheight:', err, res);
|
|
342
|
+
});
|
|
343
|
+
test('getContractBalance', async () => {
|
|
344
|
+
if (!realContract) {
|
|
345
|
+
console.log('Skipping: no real contract available');
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractBalance({ contract: realContract, asset: '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
349
|
+
expect(err).toBeNull();
|
|
350
|
+
expect(res).toBeDefined();
|
|
351
|
+
console.log('Contract balance:', res);
|
|
352
|
+
});
|
|
353
|
+
test('getContractBalanceAtTopoheight', async () => {
|
|
354
|
+
if (!realContract) {
|
|
355
|
+
console.log('Skipping: no real contract available');
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const [errTopo, topoheight] = await (0, await_to_js_1.to)(daemon.getTopoheight());
|
|
359
|
+
if (errTopo || !topoheight) {
|
|
360
|
+
console.log('Skipping: cannot get topoheight');
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractBalanceAtTopoheight({ contract: realContract, asset: '0000000000000000000000000000000000000000000000000000000000000000', topoheight }));
|
|
364
|
+
if (err) {
|
|
365
|
+
console.log('Contract balance at topoheight (soft fail):', err.message);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
expect(err).toBeNull();
|
|
369
|
+
expect(res).toBeDefined();
|
|
370
|
+
console.log('Contract balance at topoheight:', res);
|
|
371
|
+
});
|
|
372
|
+
test('getContractAssets', async () => {
|
|
373
|
+
if (!realContract) {
|
|
374
|
+
console.log('Skipping: no real contract available');
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractAssets({ contract: realContract }));
|
|
378
|
+
expect(err).toBeNull();
|
|
379
|
+
expect(Array.isArray(res)).toBe(true);
|
|
380
|
+
console.log('Contract assets:', res);
|
|
381
|
+
});
|
|
382
|
+
test('getContracts', async () => {
|
|
383
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContracts({ maximum: 5 }));
|
|
384
|
+
expect(err).toBeNull();
|
|
385
|
+
expect(Array.isArray(res)).toBe(true);
|
|
386
|
+
console.log('Contracts:', res);
|
|
387
|
+
});
|
|
388
|
+
test('getContractDataEntries', async () => {
|
|
389
|
+
if (!realContract) {
|
|
390
|
+
console.log('Skipping: no real contract available');
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractDataEntries({ contract: realContract, maximum: 5 }));
|
|
394
|
+
expect(err).toBeNull();
|
|
395
|
+
expect(res).toBeDefined();
|
|
396
|
+
console.log('Contract data entries:', res);
|
|
397
|
+
});
|
|
398
|
+
test('getContractLogs', async () => {
|
|
399
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractLogs({ caller: realContract || '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
400
|
+
console.log('Contract logs:', err, res);
|
|
401
|
+
});
|
|
402
|
+
test('getTransactionExecutor', async () => {
|
|
403
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTransactionExecutor('0000000000000000000000000000000000000000000000000000000000000000'));
|
|
404
|
+
console.log('Tx executor:', err, res);
|
|
405
|
+
});
|
|
406
|
+
test('getTransaction', async () => {
|
|
407
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTransaction('0000000000000000000000000000000000000000000000000000000000000000'));
|
|
408
|
+
console.log('Transaction:', err, res);
|
|
409
|
+
});
|
|
410
|
+
test('getTransactions', async () => {
|
|
411
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTransactions([]));
|
|
412
|
+
expect(err).toBeNull();
|
|
413
|
+
expect(Array.isArray(res)).toBe(true);
|
|
414
|
+
console.log('Transactions:', res);
|
|
415
|
+
});
|
|
416
|
+
test('getTransactionsSummary', async () => {
|
|
417
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getTransactionsSummary({ tx_hashes: [] }));
|
|
418
|
+
expect(err).toBeNull();
|
|
419
|
+
expect(Array.isArray(res)).toBe(true);
|
|
420
|
+
console.log('Transactions summary:', res);
|
|
421
|
+
});
|
|
422
|
+
test('isTxExecutedInBlock', async () => {
|
|
423
|
+
const [err1, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
424
|
+
expect(err1).toBeNull();
|
|
425
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.isTxExecutedInBlock({ tx_hash: '0000000000000000000000000000000000000000000000000000000000000000', block_hash: topBlock.hash }));
|
|
426
|
+
expect(err2).toBeNull();
|
|
427
|
+
expect(res).toBeDefined();
|
|
428
|
+
console.log('Is tx executed in block:', res);
|
|
429
|
+
});
|
|
430
|
+
test('getP2PBlockPropagation', async () => {
|
|
431
|
+
const [err1, topBlock] = await (0, await_to_js_1.to)(daemon.getTopBlock());
|
|
432
|
+
expect(err1).toBeNull();
|
|
433
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.getP2PBlockPropagation({ hash: topBlock.hash, outgoing: false, incoming: false }));
|
|
434
|
+
expect(err2).toBeNull();
|
|
435
|
+
expect(res).toBeDefined();
|
|
436
|
+
console.log('P2P block propagation:', res);
|
|
437
|
+
});
|
|
438
|
+
test('splitAddress', async () => {
|
|
439
|
+
if (!realAddress) {
|
|
440
|
+
console.log('Skipping: no real address available');
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.splitAddress({ address: realAddress }));
|
|
444
|
+
if (err) {
|
|
445
|
+
console.log('Split address (not an integrated address):', err.message);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
expect(err).toBeNull();
|
|
449
|
+
expect(res).toBeDefined();
|
|
450
|
+
console.log('Split address:', res);
|
|
451
|
+
});
|
|
452
|
+
test('extractKeyFromAddress', async () => {
|
|
453
|
+
if (!realAddress) {
|
|
454
|
+
console.log('Skipping: no real address available');
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.extractKeyFromAddress({ address: realAddress, as_hex: true }));
|
|
458
|
+
expect(err).toBeNull();
|
|
459
|
+
expect(res).toBeDefined();
|
|
460
|
+
console.log('Extract key:', res);
|
|
461
|
+
});
|
|
462
|
+
test('makeIntegratedAddress', async () => {
|
|
463
|
+
if (!realAddress) {
|
|
464
|
+
console.log('Skipping: no real address available');
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.makeIntegratedAddress({ address: realAddress, integrated_data: 'test' }));
|
|
468
|
+
expect(err).toBeNull();
|
|
469
|
+
expect(res).toBeDefined();
|
|
470
|
+
console.log('Integrated address:', res);
|
|
471
|
+
});
|
|
472
|
+
test('decryptExtraData', async () => {
|
|
473
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.decryptExtraData({ shared_key: [], extra_data: [] }));
|
|
474
|
+
console.log('Decrypt extra data:', err, res);
|
|
475
|
+
});
|
|
476
|
+
test('getMempoolCache', async () => {
|
|
477
|
+
if (!realAddress) {
|
|
478
|
+
console.log('Skipping: no real address available');
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getMempoolCache(realAddress));
|
|
482
|
+
console.log('Mempool cache:', err, res);
|
|
483
|
+
});
|
|
484
|
+
test('getMinerWork', async () => {
|
|
485
|
+
if (!realAddress) {
|
|
486
|
+
console.log('Skipping: no real address available');
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const [err1, template] = await (0, await_to_js_1.to)(daemon.getBlockTemplate(realAddress));
|
|
490
|
+
if (err1 || !template) {
|
|
491
|
+
console.log('Skipping miner work: block template failed:', err1);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
const [err2, res] = await (0, await_to_js_1.to)(daemon.getMinerWork({ template: template.template }));
|
|
495
|
+
expect(err2).toBeNull();
|
|
496
|
+
expect(res).toBeDefined();
|
|
497
|
+
console.log('Miner work:', res);
|
|
498
|
+
});
|
|
499
|
+
test('getBlockTemplate', async () => {
|
|
500
|
+
if (!realAddress) {
|
|
501
|
+
console.log('Skipping: no real address available');
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBlockTemplate(realAddress));
|
|
505
|
+
expect(err).toBeNull();
|
|
506
|
+
expect(res).toBeDefined();
|
|
507
|
+
expect(res.template).toBeDefined();
|
|
508
|
+
console.log('Block template:', res);
|
|
509
|
+
});
|
|
510
|
+
test('getBalance', async () => {
|
|
511
|
+
if (!realAddress) {
|
|
512
|
+
console.log('Skipping: no real address available');
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getBalance({ address: realAddress, asset: '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
516
|
+
expect(err).toBeNull();
|
|
517
|
+
expect(res).toBeDefined();
|
|
518
|
+
console.log('Balance:', res);
|
|
519
|
+
});
|
|
520
|
+
test('getStableBalance', async () => {
|
|
521
|
+
if (!realAddress) {
|
|
522
|
+
console.log('Skipping: no real address available');
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getStableBalance({ address: realAddress, asset: '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
526
|
+
expect(err).toBeNull();
|
|
527
|
+
expect(res).toBeDefined();
|
|
528
|
+
console.log('Stable balance:', res);
|
|
529
|
+
});
|
|
530
|
+
test('hasBalance', async () => {
|
|
531
|
+
if (!realAddress) {
|
|
532
|
+
console.log('Skipping: no real address available');
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.hasBalance({ address: realAddress, asset: '0000000000000000000000000000000000000000000000000000000000000000' }));
|
|
536
|
+
expect(err).toBeNull();
|
|
537
|
+
expect(res).toBeDefined();
|
|
538
|
+
console.log('Has balance:', res);
|
|
539
|
+
});
|
|
540
|
+
test('getNonce', async () => {
|
|
541
|
+
if (!realAddress) {
|
|
542
|
+
console.log('Skipping: no real address available');
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getNonce({ address: realAddress }));
|
|
546
|
+
expect(err).toBeNull();
|
|
547
|
+
expect(res).toBeDefined();
|
|
548
|
+
console.log('Nonce:', res);
|
|
549
|
+
});
|
|
550
|
+
test('hasNonce', async () => {
|
|
551
|
+
if (!realAddress) {
|
|
552
|
+
console.log('Skipping: no real address available');
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.hasNonce({ address: realAddress }));
|
|
556
|
+
expect(err).toBeNull();
|
|
557
|
+
expect(res).toBeDefined();
|
|
558
|
+
console.log('Has nonce:', res);
|
|
559
|
+
});
|
|
560
|
+
test('getAccountHistory', async () => {
|
|
561
|
+
if (!realAddress) {
|
|
562
|
+
console.log('Skipping: no real address available');
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAccountHistory({ address: realAddress, maximum_topoheight: 10 }));
|
|
566
|
+
expect(err).toBeNull();
|
|
567
|
+
expect(Array.isArray(res)).toBe(true);
|
|
568
|
+
console.log('Account history:', res);
|
|
569
|
+
});
|
|
570
|
+
test('getAccountAssets', async () => {
|
|
571
|
+
if (!realAddress) {
|
|
572
|
+
console.log('Skipping: no real address available');
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAccountAssets({ address: realAddress }));
|
|
576
|
+
expect(err).toBeNull();
|
|
577
|
+
expect(Array.isArray(res)).toBe(true);
|
|
578
|
+
console.log('Account assets:', res);
|
|
579
|
+
});
|
|
580
|
+
test('isAccountRegistered', async () => {
|
|
581
|
+
if (!realAddress) {
|
|
582
|
+
console.log('Skipping: no real address available');
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.isAccountRegistered({ address: realAddress, in_stable_height: false }));
|
|
586
|
+
expect(err).toBeNull();
|
|
587
|
+
expect(res).toBeDefined();
|
|
588
|
+
console.log('Is account registered:', res);
|
|
589
|
+
});
|
|
590
|
+
test('getAccountRegistrationTopoheight', async () => {
|
|
591
|
+
if (!realAddress) {
|
|
592
|
+
console.log('Skipping: no real address available');
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getAccountRegistrationTopoheight(realAddress));
|
|
596
|
+
expect(err).toBeNull();
|
|
597
|
+
expect(res).toBeGreaterThanOrEqual(0);
|
|
598
|
+
console.log('Account registration topoheight:', res);
|
|
599
|
+
});
|
|
600
|
+
test('getMultisig', async () => {
|
|
601
|
+
if (!realAddress) {
|
|
602
|
+
console.log('Skipping: no real address available');
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getMultisig({ address: realAddress }));
|
|
606
|
+
console.log('Multisig:', err, res);
|
|
607
|
+
});
|
|
608
|
+
test('hasMultisig', async () => {
|
|
609
|
+
if (!realAddress) {
|
|
610
|
+
console.log('Skipping: no real address available');
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.hasMultisig({ address: realAddress }));
|
|
614
|
+
expect(err).toBeNull();
|
|
615
|
+
expect(res).toBeDefined();
|
|
616
|
+
console.log('Has multisig:', res);
|
|
617
|
+
});
|
|
618
|
+
test('getContractsOutputs', async () => {
|
|
619
|
+
if (!realAddress) {
|
|
620
|
+
console.log('Skipping: no real address available');
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractsOutputs({ address: realAddress, topoheight: 0 }));
|
|
624
|
+
expect(err).toBeNull();
|
|
625
|
+
expect(res).toBeDefined();
|
|
626
|
+
console.log('Contract outputs:', res);
|
|
627
|
+
});
|
|
628
|
+
test('getContractScheduledExecutionsAtTopoheight', async () => {
|
|
629
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractScheduledExecutionsAtTopoheight({ topoheight: 0 }));
|
|
630
|
+
expect(err).toBeNull();
|
|
631
|
+
expect(Array.isArray(res)).toBe(true);
|
|
632
|
+
console.log('Scheduled executions:', res);
|
|
633
|
+
});
|
|
634
|
+
test('getContractRegisteredExecutionsAtTopoheight', async () => {
|
|
635
|
+
const [err, res] = await (0, await_to_js_1.to)(daemon.getContractRegisteredExecutionsAtTopoheight({ topoheight: 0 }));
|
|
636
|
+
expect(err).toBeNull();
|
|
637
|
+
expect(Array.isArray(res)).toBe(true);
|
|
638
|
+
console.log('Registered executions:', res);
|
|
639
|
+
});
|
|
640
|
+
});
|
package/dist/cjs/daemon/types.js
CHANGED
|
@@ -104,9 +104,15 @@ var RPCMethod;
|
|
|
104
104
|
RPCMethod["GetBlockTemplate"] = "get_block_template";
|
|
105
105
|
RPCMethod["GetMinerWork"] = "get_miner_work";
|
|
106
106
|
RPCMethod["SubmitBlock"] = "submit_block";
|
|
107
|
+
RPCMethod["GetContractTransactions"] = "get_contract_transactions";
|
|
108
|
+
RPCMethod["SimulateContractInvoke"] = "simulate_contract_invoke";
|
|
109
|
+
RPCMethod["RewindChain"] = "rewind_chain";
|
|
110
|
+
RPCMethod["ClearCaches"] = "clear_caches";
|
|
111
|
+
RPCMethod["PruneChain"] = "prune_chain";
|
|
107
112
|
})(RPCMethod = exports.RPCMethod || (exports.RPCMethod = {}));
|
|
108
113
|
var RPCEvent;
|
|
109
114
|
(function (RPCEvent) {
|
|
115
|
+
RPCEvent["NewTopoHeight"] = "new_topo_height";
|
|
110
116
|
RPCEvent["NewBlock"] = "new_block";
|
|
111
117
|
RPCEvent["BlockOrdered"] = "block_ordered";
|
|
112
118
|
RPCEvent["BlockOrphaned"] = "block_orphaned";
|
|
@@ -115,11 +121,10 @@ var RPCEvent;
|
|
|
115
121
|
RPCEvent["TransactionOrphaned"] = "transaction_orphaned";
|
|
116
122
|
RPCEvent["TransactionAddedInMempool"] = "transaction_added_in_mempool";
|
|
117
123
|
RPCEvent["TransactionExecuted"] = "transaction_executed";
|
|
118
|
-
RPCEvent["
|
|
124
|
+
RPCEvent["ContractInvoke"] = "contract_invoke";
|
|
119
125
|
RPCEvent["ContractTransfers"] = "contract_transfers";
|
|
120
|
-
RPCEvent["InvokeContractError"] = "invoke_contract_error";
|
|
121
126
|
RPCEvent["ContractEvent"] = "contract_event";
|
|
122
|
-
RPCEvent["
|
|
127
|
+
RPCEvent["ContractDeploy"] = "contract_deploy";
|
|
123
128
|
RPCEvent["NewAsset"] = "new_asset";
|
|
124
129
|
RPCEvent["PeerConnected"] = "peer_connected";
|
|
125
130
|
RPCEvent["PeerDisconnected"] = "peer_disconnected";
|