WalletConnect / WalletConnectFlutterV2

WalletConnect v2 client made in Dart for Flutter.
https://pub.dev/packages/walletconnect_flutter_v2
Apache License 2.0
117 stars 61 forks source link

AuthRequestParams with non-null resources List throws json parsing error #103

Closed bobwith2bees closed 1 year ago

bobwith2bees commented 1 year ago

Steps to Reproduce

Workaround

    final AuthRequestResponse authReq = await _wcClient.requestAuth(
      params: AuthRequestParams(
        aud: 'http://localhost:3000/login',
        domain: 'localhost:3000',
        chainId: 'eip155:1',
        statement: 'By signing in you are demonstrating to ${kAppName} you are the owner of the account selected. No account connection, access, or permissions in any form is granted by this EIP-4361 request.',
        nbf: notBefore.toIso8601String(), 
        exp: expires.toIso8601String(),
        resources: ['https://eips.ethereum.org/EIPS/eip-4361'], // kb articles etc
      ),
E/flutter (17423): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<String>?'
E/flutter (17423): #0      new CacaoPayload (package:walletconnect_flutter_v2/apis/auth_api/models/auth_client_models.dart:201:22)
E/flutter (17423): #1      _$CacaoPayloadFromJson (package:walletconnect_flutter_v2/apis/auth_api/models/auth_client_models.g.dart:101:67)
E/flutter (17423): #2      new CacaoPayload.fromJson (package:walletconnect_flutter_v2/apis/auth_api/models/auth_client_models.dart:224:7)
E/flutter (17423): #3      _$CacaoFromJson (package:walletconnect_flutter_v2/apis/auth_api/models/auth_client_models.g.dart:173:23)
E/flutter (17423): #4      new Cacao.fromJson (package:walletconnect_flutter_v2/apis/auth_api/models/auth_client_models.dart:279:56)
E/flutter (17423): #5      AuthEngine._requestAuthResponseHandler (package:walletconnect_flutter_v2/apis/auth_api/auth_engine.dart:188:31)
E/flutter (17423): <asynchronous suspension>
E/flutter (17423): 

pubspec.yaml has 2.0.8 with a few commits.

#  walletconnect_flutter_v2: ^2.0.8 
  walletconnect_flutter_v2:
    git:
      url: https://github.com/WalletConnect/WalletConnectDartV2.git
      ref: 88684edd261c588bc932bcc9ce5de827641568c4
Luzzotica commented 1 year ago

Yeah, I'll be honest there isn't a test that includes resources, so I'm not surprised.

Let me add your resources to the tests I'm running and fix the issue.

Luzzotica commented 1 year ago

Updated to explicit json and added tests, this should be resolved with 2.0.13