Skip to content

Commit

Permalink
fix nip-47 info permission split by space OR commans to be complaint …
Browse files Browse the repository at this point in the history
…with spec but still support old nwc version with bug of using commans
  • Loading branch information
frnandu committed Feb 29, 2024
1 parent 32e4ded commit 45215ea
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/provider/nwc_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class NwcProvider extends ChangeNotifier {
// TODO make this multi account aware
String? perms = sharedPreferences.getString(DataKey.NWC_PERMISSIONS);
if (StringUtil.isNotBlank(perms)) {
permissions = perms!.split(",");
permissions = perms!.split(" ");
if (permissions.length==1) {
permissions = permissions[0].split(",");
}
}
uri = await settingProvider.getNwc();
secret = await settingProvider.getNwcSecret();
Expand Down Expand Up @@ -101,7 +104,11 @@ class NwcProvider extends ChangeNotifier {
sharedPreferences.setString(DataKey.NWC_PERMISSIONS, event.content);
sharedPreferences.setString(DataKey.NWC_RELAY, relay!);
sharedPreferences.setString(DataKey.NWC_PUB_KEY, walletPubKey!);
permissions = event.content.split(",");
permissions = event.content.split(" ");
if (permissions.length==1) {
permissions = permissions[0].split(",");
}

if (permissions.contains(NwcCommand.GET_BALANCE) && balance==null) {
await requestBalance(walletPubKey!, relay!, secret!);
}
Expand Down

0 comments on commit 45215ea

Please sign in to comment.