@spacesops/wdk-react-native-core 1.0.0-beta.66 → 1.0.0-beta.67
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spacesops/wdk-react-native-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.67",
|
|
4
4
|
"description": "Core functionality for React Native wallets - wallet management, balance fetching, and worklet operations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isValidAccountIndex,
|
|
14
14
|
isValidNetworkName,
|
|
15
15
|
isValidBalanceString,
|
|
16
|
+
isValidAddress,
|
|
16
17
|
} from '../../utils/typeGuards'
|
|
17
18
|
import type { NetworkConfig, NetworkConfigs, TokenConfig, TokenConfigs } from '../../types'
|
|
18
19
|
|
|
@@ -160,6 +161,14 @@ describe('typeGuards', () => {
|
|
|
160
161
|
})
|
|
161
162
|
})
|
|
162
163
|
|
|
164
|
+
describe('isValidAddress', () => {
|
|
165
|
+
it('should accept TON, Tron, and Solana wallet addresses', () => {
|
|
166
|
+
expect(isValidAddress('UQCt4XDZ_rgMu14lE5ENox6yqHxx3c9df-gHLynhEEKbTRV0')).toBe(true)
|
|
167
|
+
expect(isValidAddress('TVKDsaESudgCQReXPNvStw2n2BXnmodyeC')).toBe(true)
|
|
168
|
+
expect(isValidAddress('Ed9f9Koh6rqMvFXccVJp5bNuxFs8rYdbVibW9JXRskLU')).toBe(true)
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
163
172
|
describe('isValidAccountIndex', () => {
|
|
164
173
|
it('should return true for valid account indices', () => {
|
|
165
174
|
expect(isValidAccountIndex(0)).toBe(true)
|
package/src/index.ts
CHANGED
package/src/utils/schemas.ts
CHANGED
|
@@ -49,9 +49,37 @@ export const bitcoinAddressSchema = z.string().regex(
|
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* TON user-friendly wallet address (EQ/UQ + base64url).
|
|
53
53
|
*/
|
|
54
|
-
export const
|
|
54
|
+
export const tonAddressSchema = z.string().regex(/^(EQ|UQ)[A-Za-z0-9_-]{46}$/, {
|
|
55
|
+
message: 'Must be a valid TON address (EQ/UQ user-friendly format)',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Tron Base58Check wallet address.
|
|
60
|
+
*/
|
|
61
|
+
export const tronAddressSchema = z.string().regex(/^T[1-9A-HJ-NP-Za-km-z]{33}$/, {
|
|
62
|
+
message: 'Must be a valid Tron address',
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Solana Base58 wallet address.
|
|
67
|
+
*/
|
|
68
|
+
export const solanaAddressSchema = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, {
|
|
69
|
+
message: 'Must be a valid Solana address',
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Address schema (Ethereum, Spark, Bitcoin, TON, Tron, or Solana)
|
|
74
|
+
*/
|
|
75
|
+
export const addressSchema = z.union([
|
|
76
|
+
ethereumAddressSchema,
|
|
77
|
+
sparkAddressSchema,
|
|
78
|
+
bitcoinAddressSchema,
|
|
79
|
+
tonAddressSchema,
|
|
80
|
+
tronAddressSchema,
|
|
81
|
+
solanaAddressSchema,
|
|
82
|
+
])
|
|
55
83
|
|
|
56
84
|
/**
|
|
57
85
|
* Network configuration schema
|
package/src/utils/typeGuards.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
accountIndexSchema,
|
|
22
22
|
networkNameSchema,
|
|
23
23
|
balanceStringSchema,
|
|
24
|
+
addressSchema,
|
|
24
25
|
} from './schemas'
|
|
25
26
|
import type {
|
|
26
27
|
NetworkConfig,
|
|
@@ -104,10 +105,10 @@ export function isBitcoinAddress(value: unknown): value is string {
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
|
-
* Type guard to check if a value is a valid address (Ethereum, Spark, or
|
|
108
|
+
* Type guard to check if a value is a valid address (Ethereum, Spark, Bitcoin, TON, Tron, or Solana)
|
|
108
109
|
*/
|
|
109
110
|
export function isValidAddress(value: unknown): value is string {
|
|
110
|
-
return
|
|
111
|
+
return addressSchema.safeParse(value).success
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/**
|