@@ -11,40 +11,81 @@ import type { SIWXSigner } from '../core/SIWXSigner.js'
1111
1212export default class DefaultSigner implements SIWXSigner {
1313 public async signMessage ( message : string , chainId ?: string ) : Promise < string > {
14+ console . log ( '[DefaultSigner] signMessage called' , { chainId, messageLength : message . length } )
15+
1416 const network = chainId
1517 ? ChainController . getCaipNetworkById ( chainId as CaipNetworkId )
1618 : ChainController . getActiveCaipNetwork ( )
1719
20+ console . log ( '[DefaultSigner] network resolved' , {
21+ chainId,
22+ networkId : network ?. caipNetworkId ,
23+ namespace : network ?. chainNamespace
24+ } )
25+
1826 if ( ! network ) {
1927 throw new Error ( 'DefaultSigner: No network found' )
2028 }
2129
2230 const namespace = network . chainNamespace
2331 const adapter = AdapterController . get ( namespace )
2432
33+ console . log ( '[DefaultSigner] adapter lookup' , {
34+ namespace,
35+ adapterFound : ! ! adapter ,
36+ adapterName : adapter ?. constructor ?. name
37+ } )
38+
2539 if ( ! adapter ) {
2640 throw new Error ( `DefaultSigner: No adapter found for namespace ${ namespace } ` )
2741 }
2842
2943 const accountData = ChainController . getAccountData ( namespace )
3044 const address = accountData ?. address
3145
46+ console . log ( '[DefaultSigner] account data' , {
47+ namespace,
48+ address,
49+ hasAccountData : ! ! accountData
50+ } )
51+
3252 if ( ! address ) {
3353 throw new Error ( `DefaultSigner: No address found for namespace ${ namespace } ` )
3454 }
3555
3656 const connectorId = ConnectorController . getConnectorId ( namespace )
57+ const provider = ProviderController . getProvider ( namespace )
58+
59+ console . log ( '[DefaultSigner] signing context' , {
60+ connectorId,
61+ hasProvider : ! ! provider ,
62+ providerType : provider ?. constructor ?. name
63+ } )
3764
3865 if ( connectorId === ConstantsUtil . CONNECTOR_ID . AUTH ) {
3966 RouterController . pushTransactionStack ( { } )
4067 }
4168
42- const result = await adapter . signMessage ( {
43- message,
44- address,
45- provider : ProviderController . getProvider ( namespace )
46- } )
69+ console . log ( '[DefaultSigner] calling adapter.signMessage...' )
4770
48- return result . signature
71+ try {
72+ const result = await adapter . signMessage ( {
73+ message,
74+ address,
75+ provider
76+ } )
77+
78+ console . log ( '[DefaultSigner] signMessage success' , { signatureLength : result . signature ?. length } )
79+
80+ return result . signature
81+ } catch ( error ) {
82+ console . error ( '[DefaultSigner] signMessage FAILED' , {
83+ error,
84+ namespace,
85+ address,
86+ chainId : network . caipNetworkId
87+ } )
88+ throw error
89+ }
4990 }
5091}
0 commit comments