@0xio/sdk 2.1.7 → 2.2.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/CHANGELOG.md +44 -0
- package/LICENSE +1 -1
- package/README.md +72 -11
- package/dist/index.d.ts +22 -5
- package/dist/index.esm.js +60 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +60 -29
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +60 -29
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the 0xio Wallet SDK will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.2.0] - 2026-03-08
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Devnet Network Support**: Added full Octra Devnet configuration (`rpcUrl`, `explorerUrl`, `explorerAddressUrl`, `indexerUrl`) to the built-in `NETWORKS` registry.
|
|
9
|
+
- **Expanded `NetworkInfo` Type**: Added `explorerAddressUrl`, `indexerUrl`, and `supportsPrivacy` fields to the `NetworkInfo` interface for richer network metadata.
|
|
10
|
+
- **Privacy Flag**: Each network now exposes `supportsPrivacy: boolean` so DApps can detect FHE/encrypted balance support at the config level.
|
|
11
|
+
- **Devnet Validation**: `isValidNetworkId()` now accepts `'devnet'` in addition to `'mainnet'` and `'custom'`.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Explorer URLs**: Mainnet `explorerUrl` and `explorerAddressUrl` now include trailing `/` to match all other 0xio platforms (extension, app, desktop).
|
|
15
|
+
- **Mock Data**: `generateMockData()` now returns a `NetworkInfo` object with all new fields (`explorerAddressUrl`, `indexerUrl`, `supportsPrivacy`, correct URLs).
|
|
16
|
+
|
|
17
|
+
### Network Configurations
|
|
18
|
+
|
|
19
|
+
| Network | RPC | Explorer | Privacy | Testnet |
|
|
20
|
+
|---------|-----|----------|---------|---------|
|
|
21
|
+
| Mainnet Alpha | `https://octra.network` | `https://octrascan.io` | No | No |
|
|
22
|
+
| Devnet | `http://165.227.225.79:8080` | `https://devnet.octrascan.io` | Yes | Yes |
|
|
23
|
+
| Custom | User-defined | User-defined | No | No |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## [2.1.8] - 2026-02-13
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **Transaction Finality**: New `TransactionFinality` type (`'pending' | 'confirmed' | 'rejected'`) and `finality` field on `TransactionResult` and `Transaction` interfaces.
|
|
31
|
+
- **RPC Error Codes**: 7 new `ErrorCode` entries for RPC-level transaction errors from `octra_submit` and `octra_submitBatch`:
|
|
32
|
+
- `MALFORMED_TRANSACTION` — Transaction is malformed
|
|
33
|
+
- `SELF_TRANSFER` — Cannot transfer to yourself
|
|
34
|
+
- `SENDER_NOT_FOUND` — Sender address not found
|
|
35
|
+
- `INVALID_SIGNATURE` — Invalid transaction signature
|
|
36
|
+
- `DUPLICATE_TRANSACTION` — Duplicate transaction detected
|
|
37
|
+
- `NONCE_TOO_FAR` — Transaction nonce is too far ahead
|
|
38
|
+
- `INTERNAL_ERROR` — Internal server error
|
|
39
|
+
- **Error Messages**: All new error codes have corresponding human-readable messages in `createErrorMessage()`.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
- Address validation now enforces `oct` prefix and 47-char length per Octra address spec.
|
|
43
|
+
- Mock data generates correct `oct`-prefixed addresses instead of uppercase `OCT`.
|
|
44
|
+
- `getBalance()` throws `ZeroXIOWalletError` instead of generic `Error` when address is missing.
|
|
45
|
+
- Decimal conversion comment now references JSON-RPC spec (6 decimal places confirmed).
|
|
46
|
+
- Stale REST endpoint comment (`/send-tx`, `/send-batch`) updated to JSON-RPC method names.
|
|
47
|
+
- Mock data network config updated from testnet to mainnet (`octra.network`).
|
|
48
|
+
|
|
5
49
|
## [2.1.7] - 2026-01-27
|
|
6
50
|
|
|
7
51
|
### Added
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# 0xio Wallet SDK
|
|
2
2
|
|
|
3
|
-
**Version:** 2.
|
|
3
|
+
**Version:** 2.2.0
|
|
4
4
|
|
|
5
5
|
Official TypeScript SDK for integrating DApps with 0xio Wallet on Octra Network.
|
|
6
6
|
|
|
7
|
-
## What's New in v2.
|
|
7
|
+
## What's New in v2.2.0
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
9
|
+
- **Devnet Support**: Built-in Octra Devnet network configuration — DApps can now target devnet out of the box
|
|
10
|
+
- **Expanded `NetworkInfo`**: New fields `explorerAddressUrl`, `indexerUrl`, and `supportsPrivacy` for richer network metadata
|
|
11
|
+
- **Privacy Detection**: `supportsPrivacy` flag lets DApps check if a network supports FHE/encrypted balances
|
|
12
|
+
- **Explorer URL Fix**: Mainnet explorer URLs now include trailing `/` for correct link generation
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
@@ -84,7 +85,7 @@ interface Balance {
|
|
|
84
85
|
### Transactions
|
|
85
86
|
|
|
86
87
|
#### `wallet.sendTransaction(txData): Promise<TransactionResult>`
|
|
87
|
-
Send a transaction.
|
|
88
|
+
Send a transaction. Returns result with transaction finality status.
|
|
88
89
|
|
|
89
90
|
```typescript
|
|
90
91
|
interface TransactionData {
|
|
@@ -92,6 +93,14 @@ interface TransactionData {
|
|
|
92
93
|
amount: number; // Amount in OCT
|
|
93
94
|
message?: string; // Optional memo
|
|
94
95
|
}
|
|
96
|
+
|
|
97
|
+
interface TransactionResult {
|
|
98
|
+
txHash: string;
|
|
99
|
+
success: boolean;
|
|
100
|
+
finality?: 'pending' | 'confirmed' | 'rejected';
|
|
101
|
+
message?: string;
|
|
102
|
+
explorerUrl?: string;
|
|
103
|
+
}
|
|
95
104
|
```
|
|
96
105
|
|
|
97
106
|
### Message Signing
|
|
@@ -130,15 +139,27 @@ wallet.on('networkChanged', (event) => console.log('Network:', event.newNetwork.
|
|
|
130
139
|
import { ZeroXIOWalletError, ErrorCode } from '@0xio/sdk';
|
|
131
140
|
|
|
132
141
|
try {
|
|
133
|
-
const
|
|
142
|
+
const result = await wallet.sendTransaction({ to: 'oct1...', amount: 10 });
|
|
134
143
|
} catch (error) {
|
|
135
144
|
if (error instanceof ZeroXIOWalletError) {
|
|
136
145
|
switch (error.code) {
|
|
137
146
|
case ErrorCode.USER_REJECTED:
|
|
138
|
-
console.log('User rejected the
|
|
147
|
+
console.log('User rejected the request');
|
|
148
|
+
break;
|
|
149
|
+
case ErrorCode.INSUFFICIENT_BALANCE:
|
|
150
|
+
console.log('Not enough balance');
|
|
151
|
+
break;
|
|
152
|
+
case ErrorCode.INVALID_SIGNATURE:
|
|
153
|
+
console.log('Invalid transaction signature');
|
|
154
|
+
break;
|
|
155
|
+
case ErrorCode.DUPLICATE_TRANSACTION:
|
|
156
|
+
console.log('Transaction already submitted');
|
|
139
157
|
break;
|
|
140
|
-
case ErrorCode.
|
|
141
|
-
console.log('
|
|
158
|
+
case ErrorCode.SELF_TRANSFER:
|
|
159
|
+
console.log('Cannot send to yourself');
|
|
160
|
+
break;
|
|
161
|
+
case ErrorCode.NONCE_TOO_FAR:
|
|
162
|
+
console.log('Transaction nonce too far ahead');
|
|
142
163
|
break;
|
|
143
164
|
case ErrorCode.WALLET_LOCKED:
|
|
144
165
|
console.log('Please unlock your wallet');
|
|
@@ -148,6 +169,46 @@ try {
|
|
|
148
169
|
}
|
|
149
170
|
```
|
|
150
171
|
|
|
172
|
+
## Networks
|
|
173
|
+
|
|
174
|
+
The SDK ships with built-in configurations for Octra networks:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { NETWORKS, getNetworkConfig } from '@0xio/sdk';
|
|
178
|
+
|
|
179
|
+
// Get devnet config
|
|
180
|
+
const devnet = getNetworkConfig('devnet');
|
|
181
|
+
console.log(devnet.rpcUrl); // http://165.227.225.79:8080
|
|
182
|
+
console.log(devnet.supportsPrivacy); // true
|
|
183
|
+
console.log(devnet.isTestnet); // true
|
|
184
|
+
|
|
185
|
+
// Get mainnet config
|
|
186
|
+
const mainnet = getNetworkConfig('mainnet');
|
|
187
|
+
console.log(mainnet.rpcUrl); // https://octra.network
|
|
188
|
+
console.log(mainnet.supportsPrivacy); // false
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
| Network | Privacy (FHE) | Explorer |
|
|
192
|
+
|---------|:---:|---|
|
|
193
|
+
| Mainnet Alpha | No | [octrascan.io](https://octrascan.io) |
|
|
194
|
+
| Devnet | Yes | [devnet.octrascan.io](https://devnet.octrascan.io) |
|
|
195
|
+
|
|
196
|
+
### NetworkInfo Type
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
interface NetworkInfo {
|
|
200
|
+
id: string;
|
|
201
|
+
name: string;
|
|
202
|
+
rpcUrl: string;
|
|
203
|
+
explorerUrl?: string; // Transaction explorer base URL
|
|
204
|
+
explorerAddressUrl?: string; // Address explorer base URL
|
|
205
|
+
indexerUrl?: string; // Indexer/API base URL
|
|
206
|
+
supportsPrivacy: boolean; // FHE encrypted balance support
|
|
207
|
+
color: string; // Brand color hex
|
|
208
|
+
isTestnet: boolean;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
151
212
|
## Requirements
|
|
152
213
|
|
|
153
214
|
- 0xio Wallet Extension v2.0.1 or higher
|
|
@@ -159,4 +220,4 @@ See [DOCUMENTATION.md](DOCUMENTATION.md) for complete API reference.
|
|
|
159
220
|
|
|
160
221
|
## License
|
|
161
222
|
|
|
162
|
-
MIT License. Copyright 2026 0xio
|
|
223
|
+
MIT License. Copyright 2026 0xio Labs.
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ interface NetworkInfo {
|
|
|
17
17
|
readonly name: string;
|
|
18
18
|
readonly rpcUrl: string;
|
|
19
19
|
readonly explorerUrl?: string;
|
|
20
|
+
readonly explorerAddressUrl?: string;
|
|
21
|
+
readonly indexerUrl?: string;
|
|
22
|
+
readonly supportsPrivacy: boolean;
|
|
20
23
|
readonly color: string;
|
|
21
24
|
readonly isTestnet: boolean;
|
|
22
25
|
}
|
|
@@ -38,9 +41,11 @@ interface SignedTransaction {
|
|
|
38
41
|
readonly signature: string;
|
|
39
42
|
readonly public_key: string;
|
|
40
43
|
}
|
|
44
|
+
type TransactionFinality = 'pending' | 'confirmed' | 'rejected';
|
|
41
45
|
interface TransactionResult {
|
|
42
46
|
readonly txHash: string;
|
|
43
47
|
readonly success: boolean;
|
|
48
|
+
readonly finality?: TransactionFinality;
|
|
44
49
|
readonly message?: string;
|
|
45
50
|
readonly explorerUrl?: string;
|
|
46
51
|
}
|
|
@@ -58,6 +63,7 @@ interface Transaction {
|
|
|
58
63
|
readonly fee: number;
|
|
59
64
|
readonly timestamp: number;
|
|
60
65
|
readonly status: 'pending' | 'confirmed' | 'failed';
|
|
66
|
+
readonly finality?: TransactionFinality;
|
|
61
67
|
readonly message?: string;
|
|
62
68
|
readonly blockHeight?: number;
|
|
63
69
|
}
|
|
@@ -125,7 +131,14 @@ declare enum ErrorCode {
|
|
|
125
131
|
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
126
132
|
WALLET_LOCKED = "WALLET_LOCKED",
|
|
127
133
|
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
|
|
128
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
134
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
|
135
|
+
MALFORMED_TRANSACTION = "MALFORMED_TRANSACTION",
|
|
136
|
+
SELF_TRANSFER = "SELF_TRANSFER",
|
|
137
|
+
SENDER_NOT_FOUND = "SENDER_NOT_FOUND",
|
|
138
|
+
INVALID_SIGNATURE = "INVALID_SIGNATURE",
|
|
139
|
+
DUPLICATE_TRANSACTION = "DUPLICATE_TRANSACTION",
|
|
140
|
+
NONCE_TOO_FAR = "NONCE_TOO_FAR",
|
|
141
|
+
INTERNAL_ERROR = "INTERNAL_ERROR"
|
|
129
142
|
}
|
|
130
143
|
declare class ZeroXIOWalletError extends Error {
|
|
131
144
|
readonly code: ErrorCode;
|
|
@@ -361,7 +374,7 @@ declare class ZeroXIOWallet extends EventEmitter {
|
|
|
361
374
|
* to ensure secure wallet interactions.
|
|
362
375
|
*
|
|
363
376
|
* @module communication
|
|
364
|
-
* @version
|
|
377
|
+
* @version 2.2.0
|
|
365
378
|
* @license MIT
|
|
366
379
|
*/
|
|
367
380
|
|
|
@@ -572,7 +585,7 @@ declare function createDefaultBalance(total?: number): Balance;
|
|
|
572
585
|
* SDK Configuration constants
|
|
573
586
|
*/
|
|
574
587
|
declare const SDK_CONFIG: {
|
|
575
|
-
readonly version: "2.
|
|
588
|
+
readonly version: "2.2.0";
|
|
576
589
|
readonly defaultNetworkId: "mainnet";
|
|
577
590
|
readonly communicationTimeout: 30000;
|
|
578
591
|
readonly retryAttempts: 3;
|
|
@@ -678,6 +691,10 @@ declare function generateMockData(): {
|
|
|
678
691
|
id: string;
|
|
679
692
|
name: string;
|
|
680
693
|
rpcUrl: string;
|
|
694
|
+
explorerUrl: string;
|
|
695
|
+
explorerAddressUrl: string;
|
|
696
|
+
indexerUrl: string;
|
|
697
|
+
supportsPrivacy: boolean;
|
|
681
698
|
color: string;
|
|
682
699
|
isTestnet: boolean;
|
|
683
700
|
};
|
|
@@ -695,7 +712,7 @@ declare function createLogger(prefix: string, debug: boolean): {
|
|
|
695
712
|
groupEnd: () => void;
|
|
696
713
|
};
|
|
697
714
|
|
|
698
|
-
declare const SDK_VERSION = "2.
|
|
715
|
+
declare const SDK_VERSION = "2.2.0";
|
|
699
716
|
declare const MIN_EXTENSION_VERSION = "2.0.1";
|
|
700
717
|
declare const SUPPORTED_EXTENSION_VERSIONS = "^2.0.1";
|
|
701
718
|
declare function createZeroXIOWallet(config: {
|
|
@@ -712,4 +729,4 @@ declare function checkSDKCompatibility(): {
|
|
|
712
729
|
};
|
|
713
730
|
|
|
714
731
|
export { DEFAULT_NETWORK_ID, ErrorCode, EventEmitter, ExtensionCommunicator, MIN_EXTENSION_VERSION, NETWORKS, SDK_CONFIG, SDK_VERSION, SUPPORTED_EXTENSION_VERSIONS, ZeroXIOWallet, ZeroXIOWalletError, checkBrowserSupport, checkSDKCompatibility, createDefaultBalance, createErrorMessage, createLogger, createOctraWallet, createZeroXIOWallet, delay, formatAddress, formatOCT, formatTimestamp, formatTxHash, formatOCT as formatZeroXIO, fromMicroOCT, fromMicroOCT as fromMicroZeroXIO, generateMockData, getAllNetworks, getDefaultNetwork, getNetworkConfig, isBrowser, isErrorType, isValidAddress, isValidAmount, isValidFeeLevel, isValidMessage, isValidNetworkId, retry, toMicroOCT, toMicroOCT as toMicroZeroXIO, withTimeout };
|
|
715
|
-
export type { AccountChangedEvent, Balance, BalanceChangedEvent, ConnectEvent, ConnectOptions, ConnectionInfo, DisconnectEvent, ErrorEvent, ExtensionRequest, ExtensionResponse, NetworkChangedEvent, NetworkInfo, PendingPrivateTransfer, Permission, PrivateBalanceInfo, PrivateTransferData, SDKConfig, SignedTransaction, Transaction, TransactionConfirmedEvent, TransactionData, TransactionHistory, TransactionResult, WalletAddress, WalletEvent, WalletEventType };
|
|
732
|
+
export type { AccountChangedEvent, Balance, BalanceChangedEvent, ConnectEvent, ConnectOptions, ConnectionInfo, DisconnectEvent, ErrorEvent, ExtensionRequest, ExtensionResponse, NetworkChangedEvent, NetworkInfo, PendingPrivateTransfer, Permission, PrivateBalanceInfo, PrivateTransferData, SDKConfig, SignedTransaction, Transaction, TransactionConfirmedEvent, TransactionData, TransactionFinality, TransactionHistory, TransactionResult, WalletAddress, WalletEvent, WalletEventType };
|
package/dist/index.esm.js
CHANGED
|
@@ -119,6 +119,14 @@ var ErrorCode;
|
|
|
119
119
|
ErrorCode["WALLET_LOCKED"] = "WALLET_LOCKED";
|
|
120
120
|
ErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
|
|
121
121
|
ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
122
|
+
// RPC error types from octra_submit and octra_submitBatch
|
|
123
|
+
ErrorCode["MALFORMED_TRANSACTION"] = "MALFORMED_TRANSACTION";
|
|
124
|
+
ErrorCode["SELF_TRANSFER"] = "SELF_TRANSFER";
|
|
125
|
+
ErrorCode["SENDER_NOT_FOUND"] = "SENDER_NOT_FOUND";
|
|
126
|
+
ErrorCode["INVALID_SIGNATURE"] = "INVALID_SIGNATURE";
|
|
127
|
+
ErrorCode["DUPLICATE_TRANSACTION"] = "DUPLICATE_TRANSACTION";
|
|
128
|
+
ErrorCode["NONCE_TOO_FAR"] = "NONCE_TOO_FAR";
|
|
129
|
+
ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
122
130
|
})(ErrorCode || (ErrorCode = {}));
|
|
123
131
|
class ZeroXIOWalletError extends Error {
|
|
124
132
|
constructor(code, message, details) {
|
|
@@ -143,9 +151,8 @@ function isValidAddress(address) {
|
|
|
143
151
|
if (!address || typeof address !== 'string') {
|
|
144
152
|
return false;
|
|
145
153
|
}
|
|
146
|
-
// Octra addresses
|
|
147
|
-
|
|
148
|
-
const addressRegex = /^[A-Za-z0-9]{20,64}$/;
|
|
154
|
+
// Octra addresses use "oct" prefix followed by alphanumeric characters (47 chars total)
|
|
155
|
+
const addressRegex = /^oct[A-Za-z0-9]{44}$/;
|
|
149
156
|
return addressRegex.test(address);
|
|
150
157
|
}
|
|
151
158
|
/**
|
|
@@ -164,7 +171,7 @@ function isValidNetworkId(networkId) {
|
|
|
164
171
|
if (!networkId || typeof networkId !== 'string') {
|
|
165
172
|
return false;
|
|
166
173
|
}
|
|
167
|
-
const validNetworks = ['mainnet', '
|
|
174
|
+
const validNetworks = ['mainnet', 'devnet', 'custom'];
|
|
168
175
|
return validNetworks.includes(networkId.toLowerCase());
|
|
169
176
|
}
|
|
170
177
|
/**
|
|
@@ -244,7 +251,7 @@ function toMicroOCT(amount) {
|
|
|
244
251
|
if (!isValidAmount(amount)) {
|
|
245
252
|
throw new ZeroXIOWalletError(ErrorCode.INVALID_AMOUNT, 'Invalid amount for conversion');
|
|
246
253
|
}
|
|
247
|
-
//
|
|
254
|
+
// OCT uses 6 decimal places (1 OCT = 1,000,000 raw units per JSON-RPC spec)
|
|
248
255
|
const microOCT = Math.round(amount * 1000000);
|
|
249
256
|
return microOCT.toString();
|
|
250
257
|
}
|
|
@@ -278,7 +285,14 @@ function createErrorMessage(code, context) {
|
|
|
278
285
|
[ErrorCode.PERMISSION_DENIED]: 'Permission denied for this operation',
|
|
279
286
|
[ErrorCode.WALLET_LOCKED]: 'Wallet is locked, please unlock first',
|
|
280
287
|
[ErrorCode.RATE_LIMIT_EXCEEDED]: 'Rate limit exceeded, please try again later',
|
|
281
|
-
[ErrorCode.UNKNOWN_ERROR]: 'An unknown error occurred'
|
|
288
|
+
[ErrorCode.UNKNOWN_ERROR]: 'An unknown error occurred',
|
|
289
|
+
[ErrorCode.MALFORMED_TRANSACTION]: 'Transaction is malformed',
|
|
290
|
+
[ErrorCode.SELF_TRANSFER]: 'Cannot transfer to yourself',
|
|
291
|
+
[ErrorCode.SENDER_NOT_FOUND]: 'Sender address not found',
|
|
292
|
+
[ErrorCode.INVALID_SIGNATURE]: 'Invalid transaction signature',
|
|
293
|
+
[ErrorCode.DUPLICATE_TRANSACTION]: 'Duplicate transaction detected',
|
|
294
|
+
[ErrorCode.NONCE_TOO_FAR]: 'Transaction nonce is too far ahead',
|
|
295
|
+
[ErrorCode.INTERNAL_ERROR]: 'Internal server error'
|
|
282
296
|
};
|
|
283
297
|
const baseMessage = baseMessages[code] || 'Unknown error';
|
|
284
298
|
return context ? `${baseMessage}: ${context}` : baseMessage;
|
|
@@ -371,7 +385,7 @@ function checkBrowserSupport() {
|
|
|
371
385
|
*/
|
|
372
386
|
function generateMockData() {
|
|
373
387
|
return {
|
|
374
|
-
address: '
|
|
388
|
+
address: 'oct' + Math.random().toString(36).substring(2, 22) + Math.random().toString(36).substring(2, 26),
|
|
375
389
|
balance: {
|
|
376
390
|
public: Math.floor(Math.random() * 10000),
|
|
377
391
|
private: Math.floor(Math.random() * 1000),
|
|
@@ -379,11 +393,15 @@ function generateMockData() {
|
|
|
379
393
|
currency: 'OCT'
|
|
380
394
|
},
|
|
381
395
|
networkInfo: {
|
|
382
|
-
id: '
|
|
383
|
-
name: 'Octra
|
|
384
|
-
rpcUrl: 'https://
|
|
396
|
+
id: 'mainnet',
|
|
397
|
+
name: 'Octra Mainnet Alpha',
|
|
398
|
+
rpcUrl: 'https://octra.network',
|
|
399
|
+
explorerUrl: 'https://octrascan.io/transactions/',
|
|
400
|
+
explorerAddressUrl: 'https://octrascan.io/addresses/',
|
|
401
|
+
indexerUrl: 'https://network.octrascan.com',
|
|
402
|
+
supportsPrivacy: false,
|
|
385
403
|
color: '#f59e0b',
|
|
386
|
-
isTestnet:
|
|
404
|
+
isTestnet: false
|
|
387
405
|
}
|
|
388
406
|
};
|
|
389
407
|
}
|
|
@@ -446,7 +464,7 @@ function createLogger(prefix, debug) {
|
|
|
446
464
|
* to ensure secure wallet interactions.
|
|
447
465
|
*
|
|
448
466
|
* @module communication
|
|
449
|
-
* @version
|
|
467
|
+
* @version 2.2.0
|
|
450
468
|
* @license MIT
|
|
451
469
|
*/
|
|
452
470
|
/**
|
|
@@ -836,17 +854,13 @@ class ExtensionCommunicator extends EventEmitter {
|
|
|
836
854
|
return false;
|
|
837
855
|
// Check for extension-injected indicators
|
|
838
856
|
const win = window;
|
|
839
|
-
// Look for
|
|
857
|
+
// Look for extension-injected globals (matches injected.ts)
|
|
840
858
|
return !!(win.wallet0xio ||
|
|
841
859
|
win.ZeroXIOWallet ||
|
|
842
|
-
win.__0XIO_EXTENSION__ ||
|
|
843
|
-
win.__OCTRA_EXTENSION__ ||
|
|
844
860
|
win.octraWallet ||
|
|
845
861
|
(win.chrome?.runtime?.id) ||
|
|
846
|
-
document.querySelector('meta[name="0xio-
|
|
847
|
-
document.querySelector('
|
|
848
|
-
document.querySelector('[data-0xio-extension]') ||
|
|
849
|
-
document.querySelector('[data-octra-extension]'));
|
|
862
|
+
document.querySelector('meta[name="0xio-dapp"]') ||
|
|
863
|
+
document.querySelector('[data-0xio-sdk-bridge]'));
|
|
850
864
|
}
|
|
851
865
|
/**
|
|
852
866
|
* Wait for extension to become available
|
|
@@ -911,11 +925,11 @@ class ExtensionCommunicator extends EventEmitter {
|
|
|
911
925
|
hasPostMessage: typeof window.postMessage === 'function',
|
|
912
926
|
origin: window.location?.origin,
|
|
913
927
|
extensionDetection: {
|
|
914
|
-
|
|
915
|
-
hasZeroXIOWallet: !!win.
|
|
928
|
+
hasWallet0xio: !!win.wallet0xio,
|
|
929
|
+
hasZeroXIOWallet: !!win.ZeroXIOWallet,
|
|
930
|
+
hasOctraWallet: !!win.octraWallet,
|
|
916
931
|
hasChromeRuntimeId: !!(win.chrome?.runtime?.id),
|
|
917
|
-
|
|
918
|
-
hasDataAttribute: !!document.querySelector('[data-octra-extension]')
|
|
932
|
+
hasSdkBridge: !!document.querySelector('[data-0xio-sdk-bridge]')
|
|
919
933
|
}
|
|
920
934
|
};
|
|
921
935
|
}
|
|
@@ -972,17 +986,34 @@ const NETWORKS = {
|
|
|
972
986
|
id: 'mainnet',
|
|
973
987
|
name: 'Octra Mainnet Alpha',
|
|
974
988
|
rpcUrl: 'https://octra.network',
|
|
975
|
-
explorerUrl: 'https://octrascan.io/',
|
|
976
|
-
|
|
989
|
+
explorerUrl: 'https://octrascan.io/transactions/',
|
|
990
|
+
explorerAddressUrl: 'https://octrascan.io/addresses/',
|
|
991
|
+
indexerUrl: 'https://network.octrascan.com',
|
|
992
|
+
supportsPrivacy: false,
|
|
993
|
+
color: '#f59e0b',
|
|
977
994
|
isTestnet: false
|
|
978
995
|
},
|
|
996
|
+
'devnet': {
|
|
997
|
+
id: 'devnet',
|
|
998
|
+
name: 'Octra Devnet',
|
|
999
|
+
rpcUrl: 'http://165.227.225.79:8080',
|
|
1000
|
+
explorerUrl: 'https://devnet.octrascan.io/tx.html?hash=',
|
|
1001
|
+
explorerAddressUrl: 'https://devnet.octrascan.io/address.html?addr=',
|
|
1002
|
+
indexerUrl: 'https://devnet.octrascan.io',
|
|
1003
|
+
supportsPrivacy: true,
|
|
1004
|
+
color: '#8b5cf6',
|
|
1005
|
+
isTestnet: true
|
|
1006
|
+
},
|
|
979
1007
|
'custom': {
|
|
980
1008
|
id: 'custom',
|
|
981
1009
|
name: 'Custom Network',
|
|
982
1010
|
rpcUrl: '',
|
|
983
1011
|
explorerUrl: '',
|
|
1012
|
+
explorerAddressUrl: '',
|
|
1013
|
+
indexerUrl: '',
|
|
1014
|
+
supportsPrivacy: false,
|
|
984
1015
|
color: '#64748b',
|
|
985
|
-
isTestnet: false
|
|
1016
|
+
isTestnet: false
|
|
986
1017
|
}
|
|
987
1018
|
};
|
|
988
1019
|
const DEFAULT_NETWORK_ID = 'mainnet';
|
|
@@ -1021,7 +1052,7 @@ function createDefaultBalance(total = 0) {
|
|
|
1021
1052
|
* SDK Configuration constants
|
|
1022
1053
|
*/
|
|
1023
1054
|
const SDK_CONFIG = {
|
|
1024
|
-
version: '2.
|
|
1055
|
+
version: '2.2.0',
|
|
1025
1056
|
defaultNetworkId: DEFAULT_NETWORK_ID,
|
|
1026
1057
|
communicationTimeout: 30000, // 30 seconds
|
|
1027
1058
|
retryAttempts: 3,
|
|
@@ -1232,7 +1263,7 @@ class ZeroXIOWallet extends EventEmitter {
|
|
|
1232
1263
|
try {
|
|
1233
1264
|
const address = this.getAddress();
|
|
1234
1265
|
if (!address) {
|
|
1235
|
-
throw new
|
|
1266
|
+
throw new ZeroXIOWalletError(ErrorCode.INVALID_ADDRESS, 'No address found');
|
|
1236
1267
|
}
|
|
1237
1268
|
// Fetch balance from extension (bypasses CORS, has access to private balance)
|
|
1238
1269
|
let publicBalance = 0;
|
|
@@ -1647,7 +1678,7 @@ var wallet = /*#__PURE__*/Object.freeze({
|
|
|
1647
1678
|
*/
|
|
1648
1679
|
// Main exports
|
|
1649
1680
|
// Version information
|
|
1650
|
-
const SDK_VERSION = '2.
|
|
1681
|
+
const SDK_VERSION = '2.2.0';
|
|
1651
1682
|
const MIN_EXTENSION_VERSION = '2.0.1';
|
|
1652
1683
|
const SUPPORTED_EXTENSION_VERSIONS = '^2.0.1'; // Supports all versions >= 2.0.1
|
|
1653
1684
|
// Quick setup function for simple use cases
|