@0xio/sdk 2.1.3
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/CHANGELOG.md +238 -0
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/index.d.ts +698 -0
- package/dist/index.esm.js +1705 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1745 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +1751 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +80 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the 0xio Wallet SDK will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.1.3] - 2026-01-17
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Simplified Balance Fetching**: Reverted to extension-based balance fetching to avoid CORS issues. The SDK now fetches both public and private balance exclusively from the extension's background script, which has unrestricted network access.
|
|
9
|
+
- **Reliability**: Removed complex hybrid architecture in favor of a simpler, more reliable single-source approach.
|
|
10
|
+
|
|
11
|
+
## [2.1.2] - 2026-01-17
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Critical Refactor**: `getBalance` now implements a **Hybrid Architecture**. It fetches Public Balance directly from the RPC (bypassing extension middleware) and merges it with Private Balance from the extension. This permanently resolves "0.00" balance issues caused by extension caching or race conditions.
|
|
15
|
+
- **Feature**: Added support for `private` balance field in the standard Balance response.
|
|
16
|
+
- **Internal**: Added robust mapping for RPC responses to ensure correct public/private `Balance` object structure.
|
|
17
|
+
|
|
18
|
+
## [2.1.1] - 2026-01-16
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Updated logging to be less verbose in production.
|
|
22
|
+
|
|
23
|
+
## [2.0.2] - 2025-12-22
|
|
24
|
+
|
|
25
|
+
### Breaking Changes
|
|
26
|
+
- **Network Migration**: Default network changed from `octra-testnet` to `mainnet`.
|
|
27
|
+
- **Testnet Removal**: Removed hardcoded Testnet configuration.
|
|
28
|
+
- **Compatibility**: SDK now strictly requires Extension versions `2.0.1`, `2.0.3`, or `2.0.4`.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- Updated `NETWORKS` configuration to point to Octra Mainnet Alpha (`https://octra.network`).
|
|
32
|
+
- `isTestnet` flag set to `false` by default.
|
|
33
|
+
|
|
34
|
+
## [2.0.1] - 2025-11-24
|
|
35
|
+
|
|
36
|
+
### Breaking Changes
|
|
37
|
+
- **Rebranded message sources**: Changed from `octra-sdk-*` to `0xio-sdk-*` for consistency with 0xio branding
|
|
38
|
+
- `octra-sdk-request` → `0xio-sdk-request`
|
|
39
|
+
- `octra-sdk-bridge` → `0xio-sdk-bridge`
|
|
40
|
+
- This is a breaking change that requires wallet extension v2.0+ for compatibility
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
- Updated package metadata to reflect 0xio Team ownership
|
|
44
|
+
- Changed author from "NullxGery" to "0xio Team"
|
|
45
|
+
- Updated author email from "0xgery@proton.me" to "team@0xio.xyz"
|
|
46
|
+
- Updated repository URL from `0xGery/0xio-sdk` to `0xio-xyz/0xio-sdk`
|
|
47
|
+
- Updated keywords: "0xio" → "0xio wallet", added "octra wallet"
|
|
48
|
+
- Author URL changed to organization: `https://github.com/0xio-xyz`
|
|
49
|
+
|
|
50
|
+
### Migration Guide
|
|
51
|
+
To upgrade from v1.x to v2.x:
|
|
52
|
+
1. Update SDK: `npm install @0xio/sdk@^2.0.0`
|
|
53
|
+
2. Update 0xio Wallet extension to v2.0 or higher
|
|
54
|
+
3. No code changes required - API remains unchanged
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## [1.0.4] - 2025-10-23
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
- Fixed network configuration to use correct Octra Network RPC endpoint
|
|
62
|
+
- Removed non-existent 0xio-testnet network configuration
|
|
63
|
+
- Updated default network to octra-testnet with https://octra.network RPC
|
|
64
|
+
- Updated explorer URL to https://octrascan.io/
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## [1.0.3] - 2025-10-04
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
- Updated CHANGELOG.md with complete release notes for all versions
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## [1.0.2] - 2025-10-04
|
|
76
|
+
|
|
77
|
+
### Changed
|
|
78
|
+
- Removed development-only documentation files for cleaner npm package
|
|
79
|
+
- Package now only includes essential documentation (README, CHANGELOG, LICENSE)
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## [1.0.1] - 2025-10-04
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
- Added missing RATE_LIMIT_EXCEEDED error message
|
|
87
|
+
- Fixed branding: Updated all references from "Octra Wallet" to "0xio Wallet"
|
|
88
|
+
- Clarified SDK is for Octra Network/blockchain, not "0xio network"
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## [1.0.0] - 2025-10-04
|
|
93
|
+
|
|
94
|
+
### Major Release - Production Ready
|
|
95
|
+
|
|
96
|
+
This is the first stable release of the 0xio Wallet SDK, a comprehensive bridge for dApps to connect to the 0xio Wallet extension on the Octra Network.
|
|
97
|
+
|
|
98
|
+
### Security Improvements
|
|
99
|
+
- **Fixed 8 critical wildcard origins** in postMessage communication
|
|
100
|
+
- **Origin validation**: All messages now validate against `window.location.origin`
|
|
101
|
+
- **Rate limiting**: Implemented 50 concurrent requests, 20 requests/second limits
|
|
102
|
+
- **Cryptographic request IDs**: Using `crypto.randomUUID()` instead of predictable sequential IDs
|
|
103
|
+
- **Professional code refactoring**: All files now include comprehensive JSDoc documentation
|
|
104
|
+
|
|
105
|
+
### Package Changes
|
|
106
|
+
- **Package renamed**: `@0xgery/wallet-sdk` → `@0xio/sdk`
|
|
107
|
+
- **Version bump**: 0.2.1 → 1.0.0 (production-ready)
|
|
108
|
+
- **Repository**: Published to https://github.com/0xGery/0xio-sdk
|
|
109
|
+
- **Homepage**: https://0xio.xyz
|
|
110
|
+
|
|
111
|
+
### Branding Updates
|
|
112
|
+
- SDK rebranded from "Octra Wallet SDK" to "0xio Wallet SDK"
|
|
113
|
+
- Wallet name: 0xio Wallet (for Octra Network)
|
|
114
|
+
- Currency: OCT (Octra Network's native gas token)
|
|
115
|
+
|
|
116
|
+
### Files Added
|
|
117
|
+
- LICENSE (MIT)
|
|
118
|
+
- .npmignore (excludes examples, source, docs from npm package)
|
|
119
|
+
- .gitignore (standard Node.js gitignore)
|
|
120
|
+
- Complete integration examples (React, Vue, Vanilla JS)
|
|
121
|
+
|
|
122
|
+
### Technical Improvements
|
|
123
|
+
- **JSDoc coverage**: 0% → 95%
|
|
124
|
+
- **Code quality**: Refactored all functions to <30 lines
|
|
125
|
+
- **Error handling**: Enhanced with detailed context and diagnostics
|
|
126
|
+
- **TypeScript**: Full type safety with comprehensive type definitions
|
|
127
|
+
|
|
128
|
+
### Breaking Changes
|
|
129
|
+
None - maintains backward compatibility with exported `OctraWallet` class (also exported as `ZeroXIOWallet`)
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## [0.2.1] - 2025-09-09
|
|
134
|
+
|
|
135
|
+
### Changes
|
|
136
|
+
- Update debugging messages to use plain text formatting
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## [0.2.0] - 2025-09-09
|
|
141
|
+
|
|
142
|
+
### Major Features Added
|
|
143
|
+
|
|
144
|
+
- **Built-in Extension Detection**: No longer requires wrapper polling - SDK automatically detects and monitors extension availability
|
|
145
|
+
- **Automatic Retry Logic**: Exponential backoff retry system for all extension requests (3 retries by default)
|
|
146
|
+
- **Enhanced Error Diagnostics**: Detailed error reporting showing specific failure causes, browser state, and extension diagnostics
|
|
147
|
+
- **Event-Based Communication**: Real-time extension events replace polling - instant updates for account changes, balance updates, network switches
|
|
148
|
+
- **Development Mode**: Comprehensive debugging tools with detailed logging for development environments
|
|
149
|
+
|
|
150
|
+
### Technical Improvements
|
|
151
|
+
|
|
152
|
+
#### Extension Detection
|
|
153
|
+
- Continuous background monitoring of extension availability
|
|
154
|
+
- Multiple detection methods: runtime checks, DOM signals, extension-specific indicators
|
|
155
|
+
- Automatic reconnection attempts when extension becomes available
|
|
156
|
+
- Detailed browser compatibility diagnostics
|
|
157
|
+
|
|
158
|
+
#### Retry & Error Handling
|
|
159
|
+
- Exponential backoff retry logic (1s, 2s, 4s delays)
|
|
160
|
+
- Enhanced error context with request IDs, retry counts, timestamps
|
|
161
|
+
- Browser and extension state diagnostics in error details
|
|
162
|
+
- Specific timeout handling with detailed failure information
|
|
163
|
+
|
|
164
|
+
#### Event System
|
|
165
|
+
- Real-time event forwarding from extension to SDK
|
|
166
|
+
- Automatic balance updates on transaction confirmations
|
|
167
|
+
- Account and network change detection and handling
|
|
168
|
+
- Extension lock/unlock state management
|
|
169
|
+
- Event-driven connection state management
|
|
170
|
+
|
|
171
|
+
#### Development Tools
|
|
172
|
+
- Advanced logging system with grouped output and table formatting
|
|
173
|
+
- Debug mode auto-detection for localhost/development environments
|
|
174
|
+
- Browser console utilities at `window.__ZEROXIO_SDK_UTILS__`
|
|
175
|
+
- Extension event simulation for testing
|
|
176
|
+
- Comprehensive SDK state inspection tools
|
|
177
|
+
|
|
178
|
+
### API Enhancements
|
|
179
|
+
|
|
180
|
+
#### New Utility Functions (now exported)
|
|
181
|
+
```typescript
|
|
182
|
+
// Validation
|
|
183
|
+
isValidAddress, isValidAmount, isValidMessage, isValidFeeLevel, isValidNetworkId
|
|
184
|
+
|
|
185
|
+
// Formatting
|
|
186
|
+
formatOCT, formatAddress, formatTimestamp, formatTxHash
|
|
187
|
+
|
|
188
|
+
// Conversion
|
|
189
|
+
toMicroOCT, fromMicroOCT
|
|
190
|
+
|
|
191
|
+
// Error handling
|
|
192
|
+
createErrorMessage, isErrorType
|
|
193
|
+
|
|
194
|
+
// Async utilities
|
|
195
|
+
delay, retry, withTimeout
|
|
196
|
+
|
|
197
|
+
// Browser support
|
|
198
|
+
isBrowser, checkBrowserSupport
|
|
199
|
+
|
|
200
|
+
// Development
|
|
201
|
+
generateMockData, createLogger
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Enhanced Debug Information
|
|
205
|
+
- `getDebugInfo()` now includes extension diagnostics and availability state
|
|
206
|
+
- Real-time extension state monitoring
|
|
207
|
+
- Detailed browser environment detection
|
|
208
|
+
|
|
209
|
+
### Bug Fixes
|
|
210
|
+
- Fixed substr() deprecation warning (replaced with substring())
|
|
211
|
+
- Improved error handling for edge cases in extension communication
|
|
212
|
+
- Better cleanup of pending requests and event listeners
|
|
213
|
+
- Enhanced memory management for background processes
|
|
214
|
+
|
|
215
|
+
### Developer Experience
|
|
216
|
+
- Rich console output with grouped logging in development mode
|
|
217
|
+
- Automatic debug mode detection for development environments
|
|
218
|
+
- Extension event simulation tools for testing
|
|
219
|
+
- Comprehensive error messages with actionable information
|
|
220
|
+
- SDK state inspection utilities accessible from browser console
|
|
221
|
+
|
|
222
|
+
### Breaking Changes
|
|
223
|
+
None - this version maintains full backward compatibility with v0.1.x
|
|
224
|
+
|
|
225
|
+
### Performance Improvements
|
|
226
|
+
- Reduced polling overhead by switching to event-based communication
|
|
227
|
+
- More efficient extension detection with targeted checks
|
|
228
|
+
- Optimized retry logic to reduce unnecessary network calls
|
|
229
|
+
- Background monitoring with minimal CPU impact
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## [0.1.2-dev] - Previous Version
|
|
234
|
+
- Initial SDK implementation
|
|
235
|
+
- Basic extension communication
|
|
236
|
+
- Core wallet operations
|
|
237
|
+
- Transaction handling
|
|
238
|
+
- Private transfer support
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 NullxGery (0xGery)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# 0xio Wallet SDK
|
|
2
|
+
|
|
3
|
+
**Version:** 2.1.3
|
|
4
|
+
|
|
5
|
+
A comprehensive TypeScript/JavaScript SDK that enables seamless integration between decentralized applications (DApps) and the 0xio Wallet browser extension.
|
|
6
|
+
|
|
7
|
+
## What's New in v2.1.2 (The "Fertility" Update)
|
|
8
|
+
|
|
9
|
+
- **Robust "Hybrid" Balance Fetching:** Fixed a critical issue where `getBalance()` could return stale cached data or fail on 404s. The SDK now fetches **Public Balance** directly from the RPC node (`https://octra.network/balance`) while securely retrieving **Private Balance** from the extension.
|
|
10
|
+
- **Private Balance Support:** The `Balance` object now includes a `private` field, populated by the secure context of the 0xio Wallet.
|
|
11
|
+
- **Enhanced Types:** Full type definitions for the composite Public/Private balance structure.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @0xio/sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { ZeroXIOWallet } from '@0xio/sdk';
|
|
25
|
+
|
|
26
|
+
// 1. Initialize
|
|
27
|
+
const wallet = new ZeroXIOWallet({
|
|
28
|
+
appName: 'My DApp',
|
|
29
|
+
requiredPermissions: ['read_balance']
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await wallet.initialize();
|
|
33
|
+
|
|
34
|
+
// 2. Connect
|
|
35
|
+
const connection = await wallet.connect();
|
|
36
|
+
console.log('Connected:', connection.address);
|
|
37
|
+
|
|
38
|
+
// 3. Get Fresh Balance (Public + Private)
|
|
39
|
+
const balance = await wallet.getBalance(true); // true = force refresh
|
|
40
|
+
console.log('Total:', balance.total);
|
|
41
|
+
console.log('Public:', balance.public);
|
|
42
|
+
console.log('Private:', balance.private);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API Reference
|
|
46
|
+
|
|
47
|
+
### `wallet.getBalance(forceRefresh?: boolean)`
|
|
48
|
+
|
|
49
|
+
Fetches the current balance.
|
|
50
|
+
- **Returns**: `Promise<Balance>`
|
|
51
|
+
```typescript
|
|
52
|
+
interface Balance {
|
|
53
|
+
public: number; // Visible on chain
|
|
54
|
+
private: number; // Encrypted (FHE), decrypted locally
|
|
55
|
+
total: number; // public + private
|
|
56
|
+
currency: 'OCT';
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `wallet.connect(options?)`
|
|
61
|
+
|
|
62
|
+
Requests a connection to the user's wallet.
|
|
63
|
+
- **Returns**: `Promise<ConnectEvent>` including initial address and balance.
|
|
64
|
+
|
|
65
|
+
### `wallet.sendTransaction(txData)`
|
|
66
|
+
|
|
67
|
+
Sends a standard or shielded transaction.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Build
|
|
73
|
+
npm run build
|
|
74
|
+
|
|
75
|
+
# Link locally
|
|
76
|
+
npm link
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT License. Copyright © 2026 0xio Team.
|