@n1xyz/nord-ts 0.0.12 → 0.0.14
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/nord/api/core.d.ts +8 -8
- package/dist/nord/api/core.js +55 -14
- package/dist/nord/api/metrics.js +1 -1
- package/dist/nord/client/Nord.d.ts +39 -68
- package/dist/nord/client/Nord.js +97 -115
- package/dist/nord/client/NordUser.d.ts +0 -17
- package/dist/nord/client/NordUser.js +0 -28
- package/dist/types.d.ts +36 -13
- package/dist/types.js +2 -2
- package/dist/websocket/NordWebSocketClient.d.ts +0 -3
- package/dist/websocket/NordWebSocketClient.js +10 -13
- package/dist/websocket/events.d.ts +2 -2
- package/package.json +1 -1
- package/src/idl/bridge.ts +0 -1
- package/src/nord/api/core.ts +69 -17
- package/src/nord/api/metrics.ts +26 -20
- package/src/nord/api/queries.ts +7 -11
- package/src/nord/client/Nord.ts +126 -156
- package/src/nord/client/NordUser.ts +0 -49
- package/src/types.ts +38 -13
- package/src/websocket/NordWebSocketClient.ts +11 -14
- package/src/websocket/events.ts +2 -2
- package/test.ts +0 -107
package/test.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Nord } from './src/nord/client/Nord';
|
|
2
|
-
import { MetricPeriod } from './src/nord/api/metrics';
|
|
3
|
-
import { PeakTpsPeriodUnit } from './src/types';
|
|
4
|
-
|
|
5
|
-
// Configuration for Nord client
|
|
6
|
-
const NORD_CONFIG = {
|
|
7
|
-
webServerUrl: 'https://zo-devnet.n1.xyz',
|
|
8
|
-
solanaProgramId: 'nord1111111111111111111111111111111111111',
|
|
9
|
-
solanaUrl: 'https://api.devnet.solana.com',
|
|
10
|
-
initWebSockets: false // We don't need WebSockets for these tests
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Function to run all tests
|
|
14
|
-
async function runTests() {
|
|
15
|
-
console.log('Testing Nord API with URL:', NORD_CONFIG.webServerUrl);
|
|
16
|
-
console.log('----------------------------------------');
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
// Initialize Nord client
|
|
20
|
-
console.log('\nInitializing Nord client...');
|
|
21
|
-
const nord = await Nord.initNord(NORD_CONFIG);
|
|
22
|
-
console.log('Nord client initialized successfully');
|
|
23
|
-
|
|
24
|
-
// Test aggregateMetrics
|
|
25
|
-
console.log('\n1. Testing aggregateMetrics:');
|
|
26
|
-
const metrics = await nord.aggregateMetrics();
|
|
27
|
-
console.log('Aggregate Metrics:', JSON.stringify(metrics, null, 2));
|
|
28
|
-
|
|
29
|
-
// Test with custom parameters
|
|
30
|
-
console.log('\nTesting aggregateMetrics with custom parameters:');
|
|
31
|
-
const customMetrics = await nord.aggregateMetrics(
|
|
32
|
-
3,
|
|
33
|
-
PeakTpsPeriodUnit.Hour
|
|
34
|
-
);
|
|
35
|
-
console.log('Custom Aggregate Metrics:', JSON.stringify(customMetrics, null, 2));
|
|
36
|
-
|
|
37
|
-
// Test getCurrentTps
|
|
38
|
-
console.log('\n2. Testing getCurrentTps:');
|
|
39
|
-
const tps1m = await nord.getCurrentTps(MetricPeriod.ONE_MINUTE);
|
|
40
|
-
console.log(`Current TPS (1m): ${tps1m}`);
|
|
41
|
-
|
|
42
|
-
const tps5m = await nord.getCurrentTps(MetricPeriod.FIVE_MINUTES);
|
|
43
|
-
console.log(`Current TPS (5m): ${tps5m}`);
|
|
44
|
-
|
|
45
|
-
// Test getPeakTps
|
|
46
|
-
console.log('\n3. Testing getPeakTps:');
|
|
47
|
-
const peakTps24h = await nord.getPeakTps(MetricPeriod.ONE_DAY);
|
|
48
|
-
console.log(`Peak TPS (24h): ${peakTps24h}`);
|
|
49
|
-
|
|
50
|
-
const peakTps1w = await nord.getPeakTps(MetricPeriod.ONE_WEEK);
|
|
51
|
-
console.log(`Peak TPS (1w): ${peakTps1w}`);
|
|
52
|
-
|
|
53
|
-
// Test getMedianLatency
|
|
54
|
-
console.log('\n4. Testing getMedianLatency:');
|
|
55
|
-
const medianLatency1m = await nord.getMedianLatency(MetricPeriod.ONE_MINUTE);
|
|
56
|
-
console.log(`Median Latency (1m): ${medianLatency1m} ms`);
|
|
57
|
-
|
|
58
|
-
const medianLatency1h = await nord.getMedianLatency(MetricPeriod.ONE_HOUR);
|
|
59
|
-
console.log(`Median Latency (1h): ${medianLatency1h} ms`);
|
|
60
|
-
|
|
61
|
-
// Test getTotalTransactions
|
|
62
|
-
console.log('\n5. Testing getTotalTransactions:');
|
|
63
|
-
const totalTx = await nord.getTotalTransactions();
|
|
64
|
-
console.log(`Total Transactions: ${totalTx}`);
|
|
65
|
-
|
|
66
|
-
// Test queryPrometheus with a custom query
|
|
67
|
-
console.log('\n6. Testing queryPrometheus with custom query:');
|
|
68
|
-
const customQuery = 'sum(rate(nord_requests_ok_count[15m]))';
|
|
69
|
-
const customQueryResult = await nord.queryPrometheus(customQuery);
|
|
70
|
-
console.log(`Custom Query Result (${customQuery}): ${customQueryResult}`);
|
|
71
|
-
|
|
72
|
-
// Test getLastActionId
|
|
73
|
-
console.log('\n7. Testing getLastActionId:');
|
|
74
|
-
const lastActionId = await nord.getLastActionId();
|
|
75
|
-
console.log(`Last Action ID: ${lastActionId}`);
|
|
76
|
-
|
|
77
|
-
// Test queryRecentActions
|
|
78
|
-
console.log('\n8. Testing queryRecentActions:');
|
|
79
|
-
// Get 10 recent actions starting from 0
|
|
80
|
-
const recentActions = await nord.queryRecentActions(0, 10);
|
|
81
|
-
console.log(`Recent Actions (from 0 to 10):`);
|
|
82
|
-
console.log(JSON.stringify(recentActions, null, 2));
|
|
83
|
-
|
|
84
|
-
// Test queryActionsRange
|
|
85
|
-
console.log('\n9. Testing queryActionsRange:');
|
|
86
|
-
// If lastActionId is available, use it to get a range of actions
|
|
87
|
-
if (lastActionId > 10) {
|
|
88
|
-
const fromId = Math.max(0, lastActionId - 10);
|
|
89
|
-
const toId = lastActionId;
|
|
90
|
-
const actionsRange = await nord.queryRecentActions(fromId, toId);
|
|
91
|
-
console.log(`Actions Range (from ${fromId} to ${toId}):`);
|
|
92
|
-
console.log(JSON.stringify(actionsRange, null, 2));
|
|
93
|
-
} else {
|
|
94
|
-
console.log('Not enough actions to demonstrate range query');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error('Error running tests:', error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Run all tests
|
|
103
|
-
runTests().then(() => {
|
|
104
|
-
console.log('\nAll tests completed!');
|
|
105
|
-
}).catch(error => {
|
|
106
|
-
console.error('Fatal error:', error);
|
|
107
|
-
});
|