@fenelabs/fene-sdk 0.3.2 → 0.3.6
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 +151 -398
- package/dist/index.d.mts +260 -1197
- package/dist/index.d.ts +260 -1197
- package/dist/index.js +343 -1042
- package/dist/index.mjs +333 -1018
- package/package.json +27 -43
- package/CHANGELOG.md +0 -176
package/package.json
CHANGED
|
@@ -1,68 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fenelabs/fene-sdk",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"types": "
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"description": "TypeScript SDK for Fene API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
10
|
"import": "./dist/index.mjs",
|
|
12
|
-
"require": "./dist/index.js"
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
"README.md",
|
|
18
|
-
"CHANGELOG.md",
|
|
19
|
-
"LICENSE"
|
|
16
|
+
"dist"
|
|
20
17
|
],
|
|
21
18
|
"scripts": {
|
|
22
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
23
20
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
24
|
-
"lint": "
|
|
25
|
-
"
|
|
26
|
-
"prepublishOnly": "
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"ethers": "^6.9.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/node": "^20.10.0",
|
|
33
|
-
"tsup": "^8.0.1",
|
|
34
|
-
"typescript": "^5.3.0"
|
|
21
|
+
"lint": "tsc --noEmit",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"prepublishOnly": "pnpm run build"
|
|
35
24
|
},
|
|
36
25
|
"keywords": [
|
|
37
26
|
"resonance",
|
|
38
|
-
"
|
|
39
|
-
"ethereum",
|
|
40
|
-
"staking",
|
|
27
|
+
"api",
|
|
41
28
|
"sdk",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"web3",
|
|
45
|
-
"validator",
|
|
46
|
-
"delegator",
|
|
47
|
-
"dpos",
|
|
48
|
-
"organization",
|
|
49
|
-
"politics",
|
|
50
|
-
"typescript"
|
|
29
|
+
"blockchain",
|
|
30
|
+
"fene"
|
|
51
31
|
],
|
|
52
|
-
"author": "
|
|
32
|
+
"author": "Fene Labs",
|
|
53
33
|
"license": "MIT",
|
|
54
34
|
"repository": {
|
|
55
35
|
"type": "git",
|
|
56
36
|
"url": "https://github.com/fenelabs/fene-sdk"
|
|
57
37
|
},
|
|
58
|
-
"
|
|
59
|
-
"
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^25.0.3",
|
|
40
|
+
"tsup": "^8.0.0",
|
|
41
|
+
"typescript": "^5.3.0",
|
|
42
|
+
"vitest": "^1.0.0"
|
|
60
43
|
},
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
"access": "public"
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"viem": "^2.0.0"
|
|
64
46
|
},
|
|
65
|
-
"
|
|
66
|
-
"
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"viem": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
67
51
|
}
|
|
68
52
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to the Resonance SDK will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [0.2.1] - 2025-12-10
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
#### Analytics Helper Utilities
|
|
13
|
-
- **Error handling helpers**: `isValidatorNotFound()`, `isServiceUnavailable()`, `isTimeout()`
|
|
14
|
-
- **Data validation helpers**: `isStaleData()`, `isCachedData()`, `validatePagination()`
|
|
15
|
-
- **Sync monitoring helpers**: `isSyncHealthy()`, `isSyncDegraded()`, `getSyncLag()`
|
|
16
|
-
- **Data freshness**: `getDataFreshness()` - Calculate freshness score (0-100)
|
|
17
|
-
- **Number formatting**: `formatNumber()`, `weiToEther()` - Format large numbers
|
|
18
|
-
- **Batch optimization**: `getOptimalBatchSize()` - Calculate optimal pagination size
|
|
19
|
-
|
|
20
|
-
#### Retry Logic
|
|
21
|
-
- **`withRetry()`** - Execute functions with automatic retry on transient errors
|
|
22
|
-
- **`createRetryWrapper()`** - Create retry-wrapped versions of functions
|
|
23
|
-
- Configurable retry options: max retries, backoff, custom predicates
|
|
24
|
-
- Built-in retry for timeout and 503 errors
|
|
25
|
-
- Exponential backoff with max delay cap
|
|
26
|
-
|
|
27
|
-
### Changed
|
|
28
|
-
- Enhanced README with utility function documentation
|
|
29
|
-
- Added `examples/analytics-advanced.ts` with advanced usage patterns
|
|
30
|
-
- Improved error handling examples
|
|
31
|
-
|
|
32
|
-
## [0.2.0] - 2025-12-10
|
|
33
|
-
|
|
34
|
-
### Added
|
|
35
|
-
|
|
36
|
-
#### Analytics API Module (Subgraph Data)
|
|
37
|
-
- **New `analytics` module** for accessing subgraph-indexed blockchain data
|
|
38
|
-
- `getProtocolStats()` - Get protocol-level statistics (total staking, validator counts, rewards)
|
|
39
|
-
- `getSyncStatus()` - Check synchronization status of analytics workers
|
|
40
|
-
- `getAllValidators()` - Get paginated list of validators with analytics data
|
|
41
|
-
- `getTopValidators()` - Get top validators sorted by uptime
|
|
42
|
-
- `getValidatorAnalytics()` - Get detailed analytics for a specific validator
|
|
43
|
-
- `getValidatorRewards()` - Get validator rewards and stakes with **mandatory pagination**
|
|
44
|
-
- `getAllValidatorRewards()` - Auto-pagination helper for fetching complete reward data
|
|
45
|
-
|
|
46
|
-
#### New Types
|
|
47
|
-
- `ValidatorAnalytics` - Validator analytics data structure
|
|
48
|
-
- `ValidatorAnalyticsListResponse` - Paginated validator list response
|
|
49
|
-
- `ProtocolStats` - Protocol-level statistics
|
|
50
|
-
- `ValidatorRewardsResponse` - Validator rewards with metadata
|
|
51
|
-
- `SyncStatusResponse` - Worker synchronization status
|
|
52
|
-
- `RewardDTO`, `StakeDTO`, `RewardSummary` - Reward-related types
|
|
53
|
-
- `ResponseMetadata` - Response metadata with cache and pagination info
|
|
54
|
-
- `PaginationOptions`, `ValidatorListOptions` - Pagination interfaces
|
|
55
|
-
|
|
56
|
-
### Changed
|
|
57
|
-
- Updated main SDK class to include `analytics` module
|
|
58
|
-
- Enhanced README with comprehensive analytics documentation
|
|
59
|
-
- Added `examples/analytics-usage.ts` with complete usage examples
|
|
60
|
-
|
|
61
|
-
### Notes
|
|
62
|
-
- Analytics data is sourced from The Graph subgraph and may have slight delays
|
|
63
|
-
- Rewards endpoint requires pagination to prevent excessive data transfer
|
|
64
|
-
- Always check `metadata.cached` and `metadata.stale` flags for data freshness
|
|
65
|
-
- Use `getSyncStatus()` to verify subgraph synchronization before critical operations
|
|
66
|
-
|
|
67
|
-
## [0.1.1] - 2025-11-26
|
|
68
|
-
|
|
69
|
-
### Fixed
|
|
70
|
-
- Fixed referral validate endpoint to use correct query parameter `code` instead of `referral_code`
|
|
71
|
-
- Fixed indentation in referrals.ts validate method
|
|
72
|
-
|
|
73
|
-
### Changed
|
|
74
|
-
- Updated JSDoc comment to reflect correct query parameter format `?code=CODE`
|
|
75
|
-
|
|
76
|
-
## [0.1.0] - 2024-11-26
|
|
77
|
-
|
|
78
|
-
### Added
|
|
79
|
-
|
|
80
|
-
#### Core SDK Features
|
|
81
|
-
- Initial release of Resonance Network SDK
|
|
82
|
-
- Full TypeScript support with comprehensive type definitions
|
|
83
|
-
- Support for both CommonJS and ES modules
|
|
84
|
-
- Browser and Node.js compatibility
|
|
85
|
-
|
|
86
|
-
#### API Modules
|
|
87
|
-
- **Global API**: Network statistics, APR calculations, and leaderboards
|
|
88
|
-
- `getStats()` - Get global network statistics
|
|
89
|
-
- `getNetworkAPR()` - Get network APR
|
|
90
|
-
- `getNetworkAPRBreakdown()` - Get detailed APR breakdown
|
|
91
|
-
- `getLeaderboardDelegators()` - Get delegator leaderboard
|
|
92
|
-
- `getLeaderboardValidators()` - Get validator leaderboard
|
|
93
|
-
|
|
94
|
-
- **Validators API**: Complete validator information and metrics
|
|
95
|
-
- `getAll()` - List all validators
|
|
96
|
-
- `get()` - Get validator details
|
|
97
|
-
- `getDelegators()` - Get validator's delegators
|
|
98
|
-
- `getStakeBreakdown()` - Get stake distribution
|
|
99
|
-
- `getEpoch()` - Get epoch-specific data
|
|
100
|
-
- `getHistory()` - Get historical data
|
|
101
|
-
- `getWithdrawals()` - Get withdrawal history
|
|
102
|
-
- `getMetrics()` - Get performance metrics
|
|
103
|
-
- `getSlashing()` - Get slashing events
|
|
104
|
-
- `getAPR()` - Get validator-specific APR
|
|
105
|
-
|
|
106
|
-
- **Delegators API**: Delegator data and staking information
|
|
107
|
-
- `getAll()` - List all delegators
|
|
108
|
-
- `get()` - Get delegator details
|
|
109
|
-
- `getStakes()` - Get stake breakdown
|
|
110
|
-
- `getRewards()` - Get reward history
|
|
111
|
-
- `getWithdrawals()` - Get withdrawal history
|
|
112
|
-
- `getUnbonding()` - Get unbonding status
|
|
113
|
-
- `getValidators()` - Get active validators
|
|
114
|
-
|
|
115
|
-
- **Referrals API**: Referral code management
|
|
116
|
-
- `validate()` - Validate referral code
|
|
117
|
-
- `create()` - Create new referral code (authenticated)
|
|
118
|
-
- `apply()` - Apply referral code
|
|
119
|
-
- `delete()` - Delete referral code (authenticated)
|
|
120
|
-
- `unlink()` - Unlink delegator from referral (authenticated)
|
|
121
|
-
- `getDelegatorReferral()` - Get delegator's referral info
|
|
122
|
-
- `getValidatorReferral()` - Get validator's referral info
|
|
123
|
-
|
|
124
|
-
- **Slashing API**: Slashing events and penalties
|
|
125
|
-
- `getEvents()` - Get slashing events with optional filters
|
|
126
|
-
|
|
127
|
-
#### Authentication
|
|
128
|
-
- Web3 wallet authentication support
|
|
129
|
-
- JWT token management
|
|
130
|
-
- Session storage for token persistence
|
|
131
|
-
- Automatic token expiration checking
|
|
132
|
-
- Support for both validator and delegator roles
|
|
133
|
-
|
|
134
|
-
#### HTTP Client
|
|
135
|
-
- Custom timeout configuration
|
|
136
|
-
- Custom header support
|
|
137
|
-
- Automatic error handling
|
|
138
|
-
- Query parameter building
|
|
139
|
-
- Request/response type safety
|
|
140
|
-
|
|
141
|
-
#### Developer Experience
|
|
142
|
-
- Comprehensive TypeScript types for all API responses
|
|
143
|
-
- Example files for common use cases
|
|
144
|
-
- React hooks example for authentication
|
|
145
|
-
- Full JSDoc documentation
|
|
146
|
-
- ESLint configuration
|
|
147
|
-
- Build tooling with tsup
|
|
148
|
-
|
|
149
|
-
### Documentation
|
|
150
|
-
- Complete README with usage examples
|
|
151
|
-
- API reference documentation
|
|
152
|
-
- React and Next.js integration examples
|
|
153
|
-
- Node.js usage examples
|
|
154
|
-
- Authentication flow examples
|
|
155
|
-
- Error handling examples
|
|
156
|
-
|
|
157
|
-
### Build & Distribution
|
|
158
|
-
- CommonJS (CJS) build for Node.js
|
|
159
|
-
- ES Module (ESM) build for modern bundlers
|
|
160
|
-
- TypeScript declaration files (.d.ts)
|
|
161
|
-
- Tree-shakeable exports
|
|
162
|
-
|
|
163
|
-
## [Unreleased]
|
|
164
|
-
|
|
165
|
-
### Planned Features
|
|
166
|
-
- WebSocket support for real-time updates
|
|
167
|
-
- Caching layer for frequently accessed data
|
|
168
|
-
- Rate limiting and retry logic
|
|
169
|
-
- GraphQL support (if API adds GraphQL)
|
|
170
|
-
- Additional utility functions for common operations
|
|
171
|
-
- React hooks package (@resonance/sdk-react)
|
|
172
|
-
- Vue composables package (@resonance/sdk-vue)
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
[0.1.0]: https://github.com/resonance-network/sdk/releases/tag/v0.1.0
|