1
1
import { Environment } from '@imtbl/config' ;
2
2
import {
3
3
BrowserProvider ,
4
- getBytes ,
5
- toUtf8Bytes ,
6
4
toUtf8String ,
7
5
} from 'ethers' ;
8
6
import {
@@ -21,7 +19,14 @@ import { messageResponseListener } from './messageResponseListener';
21
19
import { ImxSigner } from './ImxSigner' ;
22
20
import { getOrSetupIFrame } from './imxWalletIFrame' ;
23
21
24
- const DEFAULT_CONNECTION_MESSAGE = 'Only sign this request if you’ve initiated an action with Immutable X.' ;
22
+ // "Only sign this request if you've initiated an action with Immutable X."
23
+ const DEFAULT_CONNECTION_BYTES = new Uint8Array ( [
24
+ 79 , 110 , 108 , 121 , 32 , 115 , 105 , 103 , 110 , 32 , 116 , 104 , 105 , 115 , 32 , 114 ,
25
+ 101 , 113 , 117 , 101 , 115 , 116 , 32 , 105 , 102 , 32 , 121 , 111 , 117 , 226 , 128 , 153 ,
26
+ 118 , 101 , 32 , 105 , 110 , 105 , 116 , 105 , 97 , 116 , 101 , 100 , 32 , 97 , 110 , 32 ,
27
+ 97 , 99 , 116 , 105 , 111 , 110 , 32 , 119 , 105 , 116 , 104 , 32 , 73 , 109 , 109 , 117 ,
28
+ 116 , 97 , 98 , 108 , 101 , 32 , 88 , 46 ,
29
+ ] ) ;
25
30
const CONNECTION_FAILED_ERROR = 'The L2 IMX Wallet connection has failed' ;
26
31
27
32
export async function connect (
@@ -31,13 +36,11 @@ export async function connect(
31
36
const l1Signer = await l1Provider . getSigner ( ) ;
32
37
const address = await l1Signer . getAddress ( ) ;
33
38
34
- console . log ( 'DEFAULT_CONNECTION_MESSAGE' , { message : DEFAULT_CONNECTION_MESSAGE } ) ;
35
- console . log ( 'toUtf8Bytes.toString()' , { toUtf8Bytes : toUtf8Bytes ( DEFAULT_CONNECTION_MESSAGE ) . toString ( ) } ) ;
39
+ // log read message here
40
+ console . log ( 'DEFAULT_CONNECTION_BYTES.toString()' , { bytes : DEFAULT_CONNECTION_BYTES . toString ( ) } ) ;
41
+ console . log ( 'DEFAULT_CONNECTION_BYTES.toUtf8String()' , { bytes : toUtf8String ( DEFAULT_CONNECTION_BYTES ) } ) ;
36
42
37
- console . log ( 'toUtf8String 1' , { toUtf8String : toUtf8String ( toUtf8Bytes ( DEFAULT_CONNECTION_MESSAGE ) ) } ) ;
38
- console . log ( 'toUtf8String 2' , { toUtf8String : toUtf8String ( getBytes ( toUtf8Bytes ( DEFAULT_CONNECTION_MESSAGE ) ) ) } ) ;
39
-
40
- const signature = await l1Signer . signMessage ( toUtf8Bytes ( DEFAULT_CONNECTION_MESSAGE ) ) ;
43
+ const signature = await l1Signer . signMessage ( DEFAULT_CONNECTION_BYTES ) ;
41
44
const iframe = await getOrSetupIFrame ( env ) ;
42
45
43
46
return new Promise ( ( resolve , reject ) => {
0 commit comments