@sodax/wallet-sdk-react 1.3.1-beta-rc3 → 1.3.1-beta
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/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +12 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/xchains/bitcoin/XverseXConnector.ts +19 -3
- package/src/xchains/bitcoin/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sodax/wallet-sdk-react",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.3.1-beta
|
|
4
|
+
"version": "1.3.1-beta",
|
|
5
5
|
"description": "Wallet SDK of Sodax",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"wagmi": "2.16.9",
|
|
49
49
|
"zustand": "4.5.2",
|
|
50
50
|
"bs58": "6.0.0",
|
|
51
|
-
"@sodax/types": "1.3.1-beta
|
|
52
|
-
"@sodax/wallet-sdk-core": "1.3.1-beta
|
|
51
|
+
"@sodax/types": "1.3.1-beta",
|
|
52
|
+
"@sodax/wallet-sdk-core": "1.3.1-beta"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.0.8",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { XAccount } from '@/types';
|
|
2
|
-
import { detectBitcoinAddressType, type IBitcoinWalletProvider, type AddressType } from '@sodax/types';
|
|
2
|
+
import { detectBitcoinAddressType, type IBitcoinWalletProvider, type AddressType, type BtcWalletAddressType } from '@sodax/types';
|
|
3
3
|
import { AddressPurpose, MessageSigningProtocols } from 'sats-connect';
|
|
4
4
|
import { BitcoinXConnector } from './BitcoinXConnector';
|
|
5
5
|
|
|
@@ -153,11 +153,27 @@ class XverseWalletProvider implements IBitcoinWalletProvider {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
const XVERSE_ADDRESS_TYPE_KEY = 'xverse-address-type';
|
|
157
|
+
|
|
156
158
|
export class XverseXConnector extends BitcoinXConnector {
|
|
157
159
|
private walletProvider: XverseWalletProvider | undefined;
|
|
158
160
|
|
|
161
|
+
/** Address purpose used when connecting. Taproot (Ordinals) by default to match Radfi. */
|
|
162
|
+
public addressPurpose: AddressPurpose;
|
|
163
|
+
|
|
159
164
|
constructor() {
|
|
160
165
|
super('Xverse', 'xverse');
|
|
166
|
+
// Restore saved preference, default to Taproot
|
|
167
|
+
const saved = typeof window !== 'undefined' ? localStorage.getItem(XVERSE_ADDRESS_TYPE_KEY) : null;
|
|
168
|
+
this.addressPurpose = saved === 'segwit' ? AddressPurpose.Payment : AddressPurpose.Ordinals;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Set address purpose and persist to localStorage. */
|
|
172
|
+
public setAddressPurpose(type: BtcWalletAddressType): void {
|
|
173
|
+
this.addressPurpose = type === 'taproot' ? AddressPurpose.Ordinals : AddressPurpose.Payment;
|
|
174
|
+
if (typeof window !== 'undefined') {
|
|
175
|
+
localStorage.setItem(XVERSE_ADDRESS_TYPE_KEY, type);
|
|
176
|
+
}
|
|
161
177
|
}
|
|
162
178
|
|
|
163
179
|
public static isAvailable(): boolean {
|
|
@@ -176,7 +192,7 @@ export class XverseXConnector extends BitcoinXConnector {
|
|
|
176
192
|
const { request } = await import('sats-connect');
|
|
177
193
|
|
|
178
194
|
const response = await request('getAccounts', {
|
|
179
|
-
purposes: [
|
|
195
|
+
purposes: [this.addressPurpose],
|
|
180
196
|
message: 'Connect to Sodax',
|
|
181
197
|
});
|
|
182
198
|
|
|
@@ -185,7 +201,7 @@ export class XverseXConnector extends BitcoinXConnector {
|
|
|
185
201
|
}
|
|
186
202
|
|
|
187
203
|
const accounts = response.result as GetAccountsResult[];
|
|
188
|
-
const paymentAccount = accounts.find(a => a.purpose ===
|
|
204
|
+
const paymentAccount = accounts.find(a => a.purpose === this.addressPurpose) || accounts[0];
|
|
189
205
|
|
|
190
206
|
if (!paymentAccount) return undefined;
|
|
191
207
|
|
|
@@ -2,5 +2,6 @@ export { BitcoinXService } from './BitcoinXService';
|
|
|
2
2
|
export { BitcoinXConnector } from './BitcoinXConnector';
|
|
3
3
|
export { UnisatXConnector } from './UnisatXConnector';
|
|
4
4
|
export { XverseXConnector } from './XverseXConnector';
|
|
5
|
+
export type { BtcWalletAddressType } from '@sodax/types';
|
|
5
6
|
export { OKXXConnector } from './OKXXConnector';
|
|
6
7
|
export { useBitcoinXConnectors } from './useBitcoinXConnectors';
|