@@ -18,8 +18,9 @@ import { toTransactionJSON } from '@transaction/utils/encoding';
18
18
import { useBlockchainApplicationMeta } from '@blockchainApplication/manage/hooks/queries/useBlockchainApplicationMeta' ;
19
19
import { convertFromBaseDenom } from '@token/fungible/utils/helpers' ;
20
20
import { joinModuleAndCommand } from '@transaction/utils/moduleCommand' ;
21
- import { signMessage } from '@message/store/action' ;
21
+ import { signMessage , signClaimMessage } from '@message/store/action' ;
22
22
import { addSearchParamsToUrl , removeSearchParamsFromUrl } from 'src/utils/searchParams' ;
23
+ import { sizeOfString } from 'src/utils/helpers' ;
23
24
import { validator } from '@liskhq/lisk-client' ;
24
25
import { useSession } from '@libs/wcm/hooks/useSession' ;
25
26
import { useEvents } from '@libs/wcm/hooks/useEvents' ;
@@ -36,12 +37,12 @@ import { ReactComponent as SwitchIcon } from '../../../../../../setup/react/asse
36
37
import EmptyState from './EmptyState' ;
37
38
import styles from './requestSummary.css' ;
38
39
39
- const getTitle = ( key , t ) =>
40
+ export const getTitle = ( key , t ) =>
40
41
Object . values ( SIGNING_METHODS ) . find ( ( item ) => item . key === key ) ?. title ?? t ( 'Method not found.' ) ;
41
42
const defaultToken = { symbol : 'LSK' } ;
42
43
43
44
// eslint-disable-next-line max-statements
44
- const RequestSummary = ( { nextStep, history, message } ) => {
45
+ const RequestSummary = ( { nextStep, history, message, portalMessage } ) => {
45
46
const { t } = useTranslation ( ) ;
46
47
const { getAccountByAddress, accounts } = useAccounts ( ) ;
47
48
const [ currentAccount , setCurrentAccount ] = useCurrentAccount ( ) ;
@@ -86,6 +87,12 @@ const RequestSummary = ({ nextStep, history, message }) => {
86
87
actionFunction : ( formProps , _ , privateKey ) =>
87
88
reduxDispatch ( signMessage ( { message, nextStep, privateKey, currentAccount } ) ) ,
88
89
} ) ;
90
+ } else if ( portalMessage ) {
91
+ nextStep ( {
92
+ portalMessage,
93
+ actionFunction : ( formProps , _ , privateKey ) =>
94
+ reduxDispatch ( signClaimMessage ( { portalMessage, nextStep, privateKey, currentAccount } ) ) ,
95
+ } ) ;
89
96
} else {
90
97
const moduleCommand = joinModuleAndCommand ( transaction ) ;
91
98
const transactionJSON = toTransactionJSON ( transaction , request ?. request ?. params . schema ) ;
@@ -110,6 +117,7 @@ const RequestSummary = ({ nextStep, history, message }) => {
110
117
} ) ;
111
118
}
112
119
} ;
120
+
113
121
const rejectHandler = async ( ) => {
114
122
await respond ( { payload : USER_REJECT_ERROR } ) ;
115
123
removeSearchParamsFromUrl ( history , [ 'modal' , 'status' , 'name' , 'action' ] ) ;
@@ -144,14 +152,19 @@ const RequestSummary = ({ nextStep, history, message }) => {
144
152
const { payload, schema, address : publicKey } = request . request . params ;
145
153
let transactionObj ;
146
154
147
- if ( ! message ) {
155
+ // Validate portal message
156
+ if ( portalMessage && sizeOfString ( portalMessage ) === 84 ) {
157
+ setErrorMessage ( '' ) ;
158
+ } else if ( portalMessage && sizeOfString ( portalMessage ) !== 84 ) {
159
+ setErrorMessage ( 'Claim message of invalid size received.' ) ;
160
+ } else if ( ! message ) {
148
161
validator . validator . validateSchema ( schema ) ;
149
162
transactionObj = decodeTransaction ( Buffer . from ( payload , 'hex' ) , schema ) ;
150
163
validator . validator . validate ( schema , transactionObj . params ) ;
151
164
setTransaction ( transactionObj ) ;
152
165
}
153
-
154
- const senderPublicKey = ! message ? transactionObj . senderPublicKey : publicKey ;
166
+ const senderPublicKey =
167
+ ! message && ! portalMessage ? transactionObj . senderPublicKey : publicKey ;
155
168
const address = extractAddressFromPublicKey ( senderPublicKey ) ;
156
169
const account = getAccountByAddress ( address ) ;
157
170
setSenderAccount ( {
@@ -203,7 +216,7 @@ const RequestSummary = ({ nextStep, history, message }) => {
203
216
204
217
return (
205
218
< div className = { `${ styles . wrapper } ` } >
206
- { ! message && (
219
+ { ! message && ! portalMessage && (
207
220
< BlockchainAppDetailsHeader
208
221
headerText = { getTitle ( request ?. request ?. method , t ) }
209
222
application = { application }
@@ -221,7 +234,9 @@ const RequestSummary = ({ nextStep, history, message }) => {
221
234
</ span >
222
235
) : (
223
236
< div className = { styles . invalidTransactionTextContainer } >
224
- < span > { t ( 'Invalid transaction initiated from another application/network.' ) } </ span >
237
+ < span >
238
+ { t ( 'Invalid signature request initiated from another application/network.' ) }
239
+ </ span >
225
240
< span className = { styles . errorMessage } > { errorMessage } </ span >
226
241
</ div >
227
242
) }
0 commit comments