@toruslabs/ethereum-controllers 5.6.3 → 5.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3510,7 +3510,7 @@ function createProcessTypedMessage(_ref4) {
3510
3510
  if (Array.isArray(request.params)) {
3511
3511
  if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [typedData, address]`);
3512
3512
  const params = request.params;
3513
- const message = params[0];
3513
+ const message = typeof params[0] === "string" ? JSON.parse(params[0]) : params[0];
3514
3514
  const address = params[1];
3515
3515
  msgParams = {
3516
3516
  from: address,
@@ -3537,7 +3537,7 @@ function createProcessTypedMessageV3(_ref5) {
3537
3537
  if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [address, typedData]`);
3538
3538
  const params = request.params;
3539
3539
  const address = params[0];
3540
- const message = JSON.parse(params[1]);
3540
+ const message = params[1];
3541
3541
  msgParams = {
3542
3542
  from: address,
3543
3543
  data: message,
@@ -3563,7 +3563,7 @@ function createProcessTypedMessageV4(_ref6) {
3563
3563
  if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [address, typedData]`);
3564
3564
  const params = request.params;
3565
3565
  const address = params[0];
3566
- const message = JSON.parse(params[1]);
3566
+ const message = params[1];
3567
3567
  msgParams = {
3568
3568
  from: address,
3569
3569
  data: message,
@@ -3588,12 +3588,23 @@ function createProcessPersonalMessage(_ref7) {
3588
3588
  if (Array.isArray(request.params)) {
3589
3589
  if (!(request.params.length >= 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [message, address]`);
3590
3590
  const params = request.params;
3591
- const message = params[0];
3592
- const address = params[1];
3593
- msgParams = {
3594
- from: address,
3595
- data: message
3596
- };
3591
+ if (typeof params[0] === "object") {
3592
+ const {
3593
+ challenge,
3594
+ address
3595
+ } = params[0];
3596
+ msgParams = {
3597
+ from: address,
3598
+ data: challenge
3599
+ };
3600
+ } else {
3601
+ const message = params[0];
3602
+ const address = params[1];
3603
+ msgParams = {
3604
+ from: address,
3605
+ data: message
3606
+ };
3607
+ }
3597
3608
  }
3598
3609
  response.result = await processPersonalMessage(msgParams, request);
3599
3610
  });
@@ -3148,7 +3148,7 @@ function createProcessTypedMessage(_ref4) {
3148
3148
  if (Array.isArray(request.params)) {
3149
3149
  if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [typedData, address]`);
3150
3150
  const params = request.params;
3151
- const message = params[0];
3151
+ const message = typeof params[0] === "string" ? JSON.parse(params[0]) : params[0];
3152
3152
  const address = params[1];
3153
3153
  msgParams = {
3154
3154
  from: address,
@@ -3175,7 +3175,7 @@ function createProcessTypedMessageV3(_ref5) {
3175
3175
  if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [address, typedData]`);
3176
3176
  const params = request.params;
3177
3177
  const address = params[0];
3178
- const message = JSON.parse(params[1]);
3178
+ const message = params[1];
3179
3179
  msgParams = {
3180
3180
  from: address,
3181
3181
  data: message,
@@ -3201,7 +3201,7 @@ function createProcessTypedMessageV4(_ref6) {
3201
3201
  if (!(request.params.length === 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [address, typedData]`);
3202
3202
  const params = request.params;
3203
3203
  const address = params[0];
3204
- const message = JSON.parse(params[1]);
3204
+ const message = params[1];
3205
3205
  msgParams = {
3206
3206
  from: address,
3207
3207
  data: message,
@@ -3226,12 +3226,23 @@ function createProcessPersonalMessage(_ref7) {
3226
3226
  if (Array.isArray(request.params)) {
3227
3227
  if (!(request.params.length >= 2)) throw new Error(`WalletMiddleware - incorrect params for ${method} method. expected [message, address]`);
3228
3228
  const params = request.params;
3229
- const message = params[0];
3230
- const address = params[1];
3231
- msgParams = {
3232
- from: address,
3233
- data: message
3234
- };
3229
+ if (typeof params[0] === "object") {
3230
+ const {
3231
+ challenge,
3232
+ address
3233
+ } = params[0];
3234
+ msgParams = {
3235
+ from: address,
3236
+ data: challenge
3237
+ };
3238
+ } else {
3239
+ const message = params[0];
3240
+ const address = params[1];
3241
+ msgParams = {
3242
+ from: address,
3243
+ data: message
3244
+ };
3245
+ }
3235
3246
  }
3236
3247
  response.result = await processPersonalMessage(msgParams, request);
3237
3248
  });