@@ -6,24 +6,13 @@ import { PsbtInputAccounts, SatsConnector } from './base';
6
6
7
7
type WalletNetwork = 'livenet' | 'testnet' ;
8
8
9
- const getLibNetwork = ( network : WalletNetwork ) : Network => {
10
- switch ( network ) {
11
- case 'livenet' :
12
- return Network . mainnet ;
13
- case 'testnet' :
14
- return Network . testnet ;
15
- }
16
- } ;
17
-
18
- const getUnisatNetwork = ( network : Network ) : WalletNetwork => {
19
- switch ( network ) {
20
- default :
21
- case Network . mainnet :
22
- return 'livenet' ;
23
- case Network . testnet :
24
- return 'testnet' ;
25
- }
26
- } ;
9
+ type WalletChain =
10
+ | 'BITCOIN_MAINNET'
11
+ | 'BITCOIN_TESTNET'
12
+ | 'BITCOIN_TESTNET4'
13
+ | 'BITCOIN_SIGNET'
14
+ | 'FRACTAL_BITCOIN_MAINNET'
15
+ | 'FRACTAL_BITCOIN_TESTNET' ;
27
16
28
17
type AccountsChangedEvent = ( event : 'accountsChanged' , handler : ( accounts : Array < string > ) => void ) => void ;
29
18
@@ -36,7 +25,9 @@ type UniSatBase = {
36
25
requestAccounts : ( ) => Promise < string [ ] > ;
37
26
getAccounts : ( ) => Promise < string [ ] > ;
38
27
getNetwork : ( ) => Promise < WalletNetwork > ;
28
+ getChain : ( ) => Promise < WalletChain > ;
39
29
switchNetwork : ( network : WalletNetwork ) => Promise < void > ;
30
+ switchChain : ( network : WalletChain ) => Promise < void > ;
40
31
getPublicKey : ( ) => Promise < string > ;
41
32
getBalance : ( ) => Promise < Balance > ;
42
33
signMessage : ( msg : string , type ?: 'ecdsa' | 'bip322-simple' ) => Promise < string > ;
@@ -120,14 +111,7 @@ class UnisatConnector extends SatsConnector {
120
111
async connect ( ) : Promise < void > {
121
112
const walletSource = this . getSource ( ) ! ;
122
113
123
- const network = await walletSource . getNetwork ( ) ;
124
- const mappedNetwork = getLibNetwork ( network ) ;
125
-
126
- if ( mappedNetwork !== this . network ) {
127
- const expectedNetwork = getUnisatNetwork ( this . network ) ;
128
-
129
- await walletSource . switchNetwork ( expectedNetwork ) ;
130
- }
114
+ await walletSource . switchChain ( 'BITCOIN_SIGNET' ) ;
131
115
132
116
const [ accounts , publicKey ] = await Promise . all ( [ walletSource . requestAccounts ( ) , walletSource . getPublicKey ( ) ] ) ;
133
117
0 commit comments