@@ -19,6 +19,7 @@ import {
1919 Keychains ,
2020 KeyType ,
2121 ManageUnspentsOptions ,
22+ MessageStandardType ,
2223 MessageTypes ,
2324 PopulatedIntent ,
2425 PrebuildTransactionWithIntentOptions ,
@@ -3414,6 +3415,10 @@ describe('V2 Wallet:', function () {
34143415
34153416 describe ( 'Message Signing' , function ( ) {
34163417 const txHash = '0xrrrsss1b' ;
3418+ const messageRaw = 'hello world' ;
3419+ const messageEncoded = Buffer . from ( `\u0019Ethereum Signed Message:\n${ messageRaw . length } ${ messageRaw } ` ) . toString (
3420+ 'hex'
3421+ ) ;
34173422 const txRequestForMessageSigning : TxRequest = {
34183423 txRequestId : reqId . toString ( ) ,
34193424 transactions : [ ] ,
@@ -3438,19 +3443,19 @@ describe('V2 Wallet:', function () {
34383443 signatureShares : [ { from : SignatureShareType . USER , to : SignatureShareType . USER , share : '' } ] ,
34393444 combineSigShare : '0:rrr:sss:3' ,
34403445 txHash,
3446+ messageEncoded,
34413447 } ,
34423448 ] ,
34433449 } ;
34443450 let signTxRequestForMessage ;
34453451 const messageSigningCoins = [ 'teth' , 'tpolygon' ] ;
3446- const messageRaw = 'test' ;
34473452 const expected : SignedMessage = {
34483453 txRequestId : reqId . toString ( ) ,
34493454 txHash,
34503455 signature : txHash ,
34513456 messageRaw,
34523457 coin : 'teth' ,
3453- messageEncoded : Buffer . from ( '\u0019Ethereum Signed Message:\n4test' ) . toString ( 'hex' ) ,
3458+ messageEncoded,
34543459 } ;
34553460
34563461 beforeEach ( async function ( ) {
@@ -3480,8 +3485,11 @@ describe('V2 Wallet:', function () {
34803485
34813486 it ( 'sol create signMessage tx request' , async function ( ) {
34823487 await tssSolWallet
3483- . createSignMessageRequest ( {
3484- messageRaw,
3488+ . buildSignMessageRequest ( {
3489+ message : {
3490+ messageRaw,
3491+ messageStandardType : MessageStandardType . EIP191 ,
3492+ } ,
34853493 } )
34863494 . should . be . rejectedWith ( 'Message signing not supported for Testnet Solana' ) ;
34873495 } ) ;
@@ -3496,13 +3504,16 @@ describe('V2 Wallet:', function () {
34963504 it ( 'should create tx Request with signMessage intent' , async function ( ) {
34973505 nock ( bgUrl ) . post ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /msgrequests` ) . reply ( 200 , txRequestForMessageSigning ) ;
34983506
3499- const txRequest = await tssEthWallet . createSignMessageRequest ( {
3500- messageRaw,
3507+ const txRequest = await tssEthWallet . buildSignMessageRequest ( {
3508+ message : {
3509+ messageRaw,
3510+ messageStandardType : MessageStandardType . EIP191 ,
3511+ } ,
35013512 } ) ;
35023513 txRequest . should . deepEqual ( txRequestForMessageSigning ) ;
35033514 } ) ;
35043515
3505- it ( ' should sign message' , async function ( ) {
3516+ it ( `[ ${ coinName } ] should sign message` , async function ( ) {
35063517 const signMessageTssSpy = sinon . spy ( tssEthWallet , 'signMessageTss' as any ) ;
35073518 nock ( bgUrl )
35083519 . get (
@@ -3514,7 +3525,7 @@ describe('V2 Wallet:', function () {
35143525
35153526 const signMessage = await tssEthWallet . signMessage ( {
35163527 reqId,
3517- message : { messageRaw, txRequestId } ,
3528+ message : { messageRaw, txRequestId, messageStandardType : MessageStandardType . EIP191 } ,
35183529 prv : 'secretKey' ,
35193530 } ) ;
35203531 signMessage . should . deepEqual ( expectedWithCoinField ) ;
@@ -3524,14 +3535,14 @@ describe('V2 Wallet:', function () {
35243535 ) ;
35253536 } ) ;
35263537
3527- it ( ' should sign message when custodianMessageId is provided' , async function ( ) {
3538+ it ( `[ ${ coinName } ] should sign message when custodianMessageId is provided` , async function ( ) {
35283539 const signMessageTssSpy = sinon . spy ( tssEthWallet , 'signMessageTss' as any ) ;
3529- nock ( bgUrl ) . post ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /txrequests ` ) . reply ( 200 , txRequestForMessageSigning ) ;
3540+ nock ( bgUrl ) . post ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /msgrequests ` ) . reply ( 200 , txRequestForMessageSigning ) ;
35303541
35313542 const signMessage = await tssEthWallet . signMessage ( {
35323543 custodianMessageId : 'unittest' ,
35333544 reqId,
3534- message : { messageRaw } ,
3545+ message : { messageRaw, messageStandardType : MessageStandardType . EIP191 } ,
35353546 prv : 'secretKey' ,
35363547 } ) ;
35373548 signMessage . should . deepEqual ( expectedWithCoinField ) ;
@@ -3541,13 +3552,13 @@ describe('V2 Wallet:', function () {
35413552 ) ;
35423553 } ) ;
35433554
3544- it ( ' should sign message when txRequestId not provided' , async function ( ) {
3555+ it ( `[ ${ coinName } ] should sign message when txRequestId not provided` , async function ( ) {
35453556 const signMessageTssSpy = sinon . spy ( tssEthWallet , 'signMessageTss' as any ) ;
3546- nock ( bgUrl ) . post ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /txrequests ` ) . reply ( 200 , txRequestForMessageSigning ) ;
3557+ nock ( bgUrl ) . post ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /msgrequests ` ) . reply ( 200 , txRequestForMessageSigning ) ;
35473558
35483559 const signMessage = await tssEthWallet . signMessage ( {
35493560 reqId,
3550- message : { messageRaw } ,
3561+ message : { messageRaw, messageStandardType : MessageStandardType . EIP191 } ,
35513562 prv : 'secretKey' ,
35523563 } ) ;
35533564 signMessage . should . deepEqual ( expectedWithCoinField ) ;
@@ -3561,7 +3572,7 @@ describe('V2 Wallet:', function () {
35613572 await tssEthWallet
35623573 . signMessage ( {
35633574 reqId,
3564- message : { messageRaw, txRequestId } ,
3575+ message : { messageRaw, txRequestId, messageStandardType : MessageStandardType . EIP191 } ,
35653576 prv : '' ,
35663577 } )
35673578 . should . be . rejectedWith ( 'keychain does not have property encryptedPrv' ) ;
0 commit comments