@@ -17,7 +17,7 @@ import {
17
17
} from 'viem' ;
18
18
import type { ERC20Contract } from '../contracts/erc20' ;
19
19
import type { SimulatedTxRequest } from '../../types' ;
20
- import { handleGRPCRequest , authClient , createSIWEMessage } from '../../utils' ;
20
+ import { handleGRPCRequest , authClient , createSIWEMessage , fromH160ToAddress } from '../../utils' ;
21
21
import type { CLEAR_ADDRESS , SEAPORT_ADDRESS } from '../../constants' ;
22
22
import type { ClearinghouseContract } from '../contracts/clearinghouse' ;
23
23
@@ -31,12 +31,10 @@ export class Trader {
31
31
public chain : Chain ;
32
32
public authenticated = false ;
33
33
public publicClient : PublicClient < Transport , Chain > ;
34
- public walletClient : WalletClient ; //<Transport, Chain, PrivateKeyAccount>;
34
+ public walletClient : WalletClient ;
35
35
36
36
/** cached results */
37
- // { [ERC20_ADDRESS]: BALANCE}
38
37
private erc20Balances = new Map < Address , bigint > ( ) ;
39
- // { [ERC20_ADDRESS]: { [CLEAR_ADDRESS]: APPROVED_AMOUNT, [SEAPORT_ADDRESS]: APPROVED_AMOUNT } }
40
38
private erc20Allowances = new Map <
41
39
Address ,
42
40
{
@@ -96,7 +94,8 @@ export class Trader {
96
94
const res = await handleGRPCRequest ( async ( ) =>
97
95
authClient . authenticate ( { } ) ,
98
96
) ;
99
- this . authenticated = res !== null ;
97
+ if ( res ) this . authenticated = fromH160ToAddress ( res ) . toLowerCase ( ) === this . account . address . toLowerCase ( )
98
+ return this . authenticated ;
100
99
}
101
100
102
101
public async verifyWithSIWE ( message : string , signature : `0x${string } `) {
@@ -108,7 +107,8 @@ export class Trader {
108
107
} ) ,
109
108
} ) ,
110
109
) ;
111
- return { verified : res !== null } ;
110
+ if ( res ) return { verified : fromH160ToAddress ( res ) . toLowerCase ( ) === this . account . address . toLowerCase ( ) }
111
+ return { verified : null } ;
112
112
}
113
113
114
114
public async createAndSignMessage ( nonce : string ) {
0 commit comments