-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from 3Dpass/dev
FEATURE: Notifications
- Loading branch information
Showing
61 changed files
with
1,647 additions
and
883 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
lib/core/polkawallet/utils/tx_update_event_logs_handler.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:polkawallet_sdk/utils/web_logs_handler.dart'; | ||
|
||
class TxUpdateEventLogsHandler extends WebLogsHandler { | ||
const TxUpdateEventLogsHandler( | ||
this.msgId, | ||
this.setTransactionResult, | ||
); | ||
|
||
final String msgId; | ||
|
||
/// @param {String} is extrinsicSuccess or message | ||
final void Function(String) setTransactionResult; | ||
|
||
static const String extrinsicSuccess = 'ok'; | ||
|
||
@override | ||
void handle(final String data) { | ||
final dynamic rawData = jsonDecode(data); | ||
|
||
if (!(rawData is Map && | ||
rawData.keys.contains('path') && | ||
rawData.keys.contains('data'))) { | ||
return; | ||
} | ||
|
||
final dynamic path = rawData['path']; | ||
|
||
if (!(path is String && path.contains('txUpdateEvent|msgId=$msgId'))) { | ||
return; | ||
} | ||
|
||
final dynamic dataSection = rawData['data']; | ||
|
||
if (!(dataSection is Map && | ||
dataSection.keys.contains('title') && | ||
dataSection.keys.contains('message'))) { | ||
return; | ||
} | ||
|
||
final String title = dataSection['title'] as String; | ||
if (title == "system.ExtrinsicSuccess") { | ||
setTransactionResult(extrinsicSuccess); | ||
} else if (title == 'system.ExtrinsicFailed') { | ||
setTransactionResult(dataSection['message'] as String); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.