diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec4b52..c898755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,32 @@ +## 0.0.3+3 + +### Updates +[UPDATE] Reformat style. + +[UPDATE] Update example. + + +### Fixed bugs +[FIXED] fixed bug in Deadline null + +[FIXED] fixed bug in MosaicSupplyChangeTransaction + +[FIXED] fixed bug in duration MosaicDefinition + +[FIXED] fixed bug in duration namespace + +[FIXED] fixed bug in _MessageDTO null + +[FIXED] fixed bug in parentId null + +[FIXED] fixed bug in List _MosaicNameDTO + +[FIXED] fixed bug in List _MosaicInfoDTO + +[FIXED] fixed bug in List _BlockInfoDTO + +[FIXED] fixed bug in BlockInfoDTO + ## 0.0.3+2 ### Updates diff --git a/LICENSE b/LICENSE index fdff7c3..791ee54 100644 --- a/LICENSE +++ b/LICENSE @@ -6,38 +6,38 @@ 1. Definitions. - "License" shall mean the terms and conditions for use, reproduction, + 'License' shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - "Licensor" shall mean the copyright owner or entity authorized by + 'Licensor' shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - "Legal Entity" shall mean the union of the acting entity and all + 'Legal Entity' shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the + 'control' means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - "You" (or "Your") shall mean an individual or Legal Entity + 'You' (or 'Your') shall mean an individual or Legal Entity exercising permissions granted by this License. - "Source" form shall mean the preferred form for making modifications, + 'Source' form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - "Object" form shall mean any form resulting from mechanical + 'Object' form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - "Work" shall mean the work of authorship, whether in Source or + 'Work' shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - "Derivative Works" shall mean any work, whether in Source or Object + 'Derivative Works' shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes @@ -45,21 +45,21 @@ separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - "Contribution" shall mean any work of authorship, including + 'Contribution' shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" + the copyright owner. For the purposes of this definition, 'submitted' means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." + designated in writing by the copyright owner as 'Not a Contribution.' - "Contributor" shall mean Licensor and any individual or Legal Entity + 'Contributor' shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. @@ -103,7 +103,7 @@ excluding those notices that do not pertain to any part of the Derivative Works; and - (d) If the Work includes a "NOTICE" text file as part of its + (d) If the Work includes a 'NOTICE' text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not @@ -142,7 +142,7 @@ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, + Contributor provides its Contributions) on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A @@ -178,24 +178,24 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" + boilerplate notice, with the fields enclosed by brackets '[]' replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier + same 'printed page' as the copyright notice for easier identification within third-party archives. Copyright 2018 ProximaX Limited - Licensed under the Apache License, Version 2.0 (the "License"); + Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, + distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/README.md b/README.md index c9d7524..963b472 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Add this to your package's pubspec.yaml file: ```dart dependencies: - xpx_chain_sdk: 0.0.3+2 + xpx_chain_sdk: 0.0.3+3 ``` **2. Install it** diff --git a/lib/src/api/api_account_routes.dart b/lib/src/api/api_account_routes.dart index da439a1..b77ad87 100644 --- a/lib/src/api/api_account_routes.dart +++ b/lib/src/api/api_account_routes.dart @@ -266,9 +266,10 @@ class AccountRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = (_apiClient.deserialize(response.body, 'List')) - .map((item) => item) - .toList(); + final List resp = + (_apiClient.deserialize(response.body, 'List')) + .map((item) => item) + .toList(); return resp.map(_deserializeDTO).toList(); } else { return null; @@ -332,9 +333,10 @@ class AccountRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = (_apiClient.deserialize(response.body, 'List')) - .map((item) => item) - .toList(); + final List resp = + (_apiClient.deserialize(response.body, 'List')) + .map((item) => item) + .toList(); return resp.map(_deserializeDTO).toList(); } else { return null; @@ -397,9 +399,10 @@ class AccountRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = (_apiClient.deserialize(response.body, 'List')) - .map((item) => item) - .toList(); + final List resp = + (_apiClient.deserialize(response.body, 'List')) + .map((item) => item) + .toList(); return resp.map(_deserializeDTO).toList(); } else { return null; @@ -462,9 +465,10 @@ class AccountRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = (_apiClient.deserialize(response.body, 'List')) - .map((item) => item) - .toList(); + final List resp = + (_apiClient.deserialize(response.body, 'List')) + .map((item) => item) + .toList(); return resp.map(_deserializeDTO).toList(); } else { return null; @@ -527,9 +531,10 @@ class AccountRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = (_apiClient.deserialize(response.body, 'List')) - .map((item) => item) - .toList(); + final List resp = + (_apiClient.deserialize(response.body, 'List')) + .map((item) => item) + .toList(); return resp.map(_deserializeDTO).toList(); } else { return null; diff --git a/lib/src/api/api_blockchain_routes.dart b/lib/src/api/api_blockchain_routes.dart index 7c811ca..8575253 100644 --- a/lib/src/api/api_blockchain_routes.dart +++ b/lib/src/api/api_blockchain_routes.dart @@ -90,7 +90,7 @@ class BlockchainRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final resp = apiClient.deserialize(response.body, 'BlockInfoDTO'); + final resp = apiClient.deserialize(response.body, '_BlockInfoDTO'); return BlockInfo.fromDTO(resp); } else { return null; @@ -296,10 +296,12 @@ class BlockchainRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = apiClient - .deserialize(response.body, 'List') - .map((item) => item) - .toList(); + // ignore: avoid_as + final resp = + (apiClient.deserialize(response.body, 'List<_BlockInfoDTO>') as List) + // ignore: avoid_as + .map((item) => item as _BlockInfoDTO) + .toList(); return BlockInfo.listFromDTO(resp); } else { return null; diff --git a/lib/src/api/api_client.dart b/lib/src/api/api_client.dart index 0b271cd..8c10c43 100644 --- a/lib/src/api/api_client.dart +++ b/lib/src/api/api_client.dart @@ -88,7 +88,7 @@ class _ApiClient { return AnnounceTransactionInfoDTO.fromJson(value); case 'BlockDTO': return _BlockDTO.fromJson(value); - case 'BlockInfoDTO': + case '_BlockInfoDTO': return _BlockInfoDTO.fromJson(value); case 'BlockMetaDTO': return _BlockMetaDTO.fromJson(value); diff --git a/lib/src/api/api_mosaic_routes.dart b/lib/src/api/api_mosaic_routes.dart index f78ea77..285854e 100644 --- a/lib/src/api/api_mosaic_routes.dart +++ b/lib/src/api/api_mosaic_routes.dart @@ -93,10 +93,12 @@ class MosaicRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = apiClient - .deserialize(response.body, 'List<_MosaicInfoDTO>') - .map((item) => item) - .toList(); + final resp = + // ignore: avoid_as + (apiClient.deserialize(response.body, 'List<_MosaicInfoDTO>') as List) + // ignore: avoid_as + .map((item) => item as _MosaicInfoDTO) + .toList(); return MosaicInfo.listFromDTO(resp); } else { return null; @@ -142,10 +144,13 @@ class MosaicRoutesApi { if (response.statusCode >= 400) { throw ApiException(response.statusCode, response.body); } else if (response.body != null) { - final List resp = apiClient - .deserialize(response.body, 'List<_MosaicNameDTO>') - .map((item) => item) - .toList(); + // ignore: avoid_as + final resp = + // ignore: avoid_as + (apiClient.deserialize(response.body, 'List<_MosaicNameDTO>') as List) + // ignore: avoid_as + .map((item) => item as _MosaicNameDTO) + .toList(); return MosaicName.listFromDTO(resp); } else { return null; diff --git a/lib/src/model/account_dto.dart b/lib/src/model/account_dto.dart index c089761..8674f19 100644 --- a/lib/src/model/account_dto.dart +++ b/lib/src/model/account_dto.dart @@ -37,7 +37,7 @@ class _AccountDTO { }; static List<_AccountDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _AccountDTO.fromJson(value)).toList(); static Map mapFromJson( @@ -64,7 +64,7 @@ class _AccountInfoDTO { Map toJson() => {'meta': meta, 'account': account}; static List<_AccountInfoDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _AccountInfoDTO.fromJson(value)).toList(); static Map mapFromJson( @@ -82,7 +82,7 @@ class _AccountMetaDTO { : assert(json != null, 'json must not be null'); static List<_AccountMetaDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _AccountMetaDTO.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/alias_model.dart b/lib/src/model/alias_model.dart index 25b7077..c247bc4 100644 --- a/lib/src/model/alias_model.dart +++ b/lib/src/model/alias_model.dart @@ -40,6 +40,7 @@ class Alias { return data; } - static List listFromJson(List json) => - json == null ? [] : json.map((value) => Alias.fromDTO(value)).toList(); + static List listFromJson(List json) => json == null + ? [] + : json.map((value) => Alias.fromDTO(value)).toList(); } diff --git a/lib/src/model/block_dto.dart b/lib/src/model/block_dto.dart index 6c6e56e..dced28a 100644 --- a/lib/src/model/block_dto.dart +++ b/lib/src/model/block_dto.dart @@ -128,7 +128,7 @@ class _BlockMetaDTO { num numTransactions; static List<_BlockMetaDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _BlockMetaDTO.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/block_model.dart b/lib/src/model/block_model.dart index 0655783..abbf0aa 100644 --- a/lib/src/model/block_model.dart +++ b/lib/src/model/block_model.dart @@ -72,7 +72,7 @@ class BlockInfo { } static List listFromDTO(List<_BlockInfoDTO> json) => json == null - ? null + ? null : json.map((value) => BlockInfo.fromDTO(value)).toList(); } @@ -127,10 +127,9 @@ class BlockchainStorageInfo { int numAccounts; @override - String toString() => - '{numBlocks:$numBlocks,' - ' numTransactions:$numTransactions,' - ' numAccounts:$numAccounts}'; + String toString() => '{numBlocks:$numBlocks,' + ' numTransactions:$numTransactions,' + ' numAccounts:$numAccounts}'; Map toJson() { final data = {}; diff --git a/lib/src/model/merkle_path_item.dart b/lib/src/model/merkle_path_item.dart index 22ac88b..3a25cde 100644 --- a/lib/src/model/merkle_path_item.dart +++ b/lib/src/model/merkle_path_item.dart @@ -15,7 +15,7 @@ class MerklePathItem { String toString() => 'MerklePathItem[position=$position, hash=$hash, ]'; static List listFromJson(List json) => json == null - ? null + ? null : json.map((value) => MerklePathItem.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/mosaic_dto.dart b/lib/src/model/mosaic_dto.dart index c67d5cc..5c85a84 100644 --- a/lib/src/model/mosaic_dto.dart +++ b/lib/src/model/mosaic_dto.dart @@ -20,7 +20,7 @@ class _MosaicDTO { } static List<_MosaicDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _MosaicDTO.fromJson(value)).toList(); static Map mapFromJson( @@ -54,7 +54,7 @@ class _MosaicInfoDTO { } static List<_MosaicInfoDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _MosaicInfoDTO.fromJson(value)).toList(); static Map mapFromJson( @@ -76,7 +76,7 @@ class _MosaicMetaDTO { String id; static List<_MosaicMetaDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _MosaicMetaDTO.fromJson(value)).toList(); static Map mapFromJson( @@ -121,7 +121,9 @@ class _MosaicDefinitionDTO { class _MosaicNameDTO { _MosaicNameDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - parentId = UInt64DTO.fromJson(json['parentId']); + parentId = + json['parentId'] != null ? UInt64DTO.fromJson(json['parentId']) : null; + mosaicId = UInt64DTO.fromJson(json['mosaicId']); names = List.from(json['names']); } @@ -133,7 +135,7 @@ class _MosaicNameDTO { List names; static List<_MosaicNameDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _MosaicNameDTO.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/mosaic_model.dart b/lib/src/model/mosaic_model.dart index a7d93c0..4d93169 100644 --- a/lib/src/model/mosaic_model.dart +++ b/lib/src/model/mosaic_model.dart @@ -45,8 +45,9 @@ class Mosaic { return data; } - static List listFromDTO(List<_MosaicDTO> json) => - json == null ? [] : json.map((value) => Mosaic.fromDTO(value)).toList(); + static List listFromDTO(List<_MosaicDTO> json) => json == null + ? [] + : json.map((value) => Mosaic.fromDTO(value)).toList(); } class MosaicId extends Id { @@ -137,7 +138,7 @@ class MosaicInfo { class MosaicName { MosaicName.fromDTO(_MosaicNameDTO value) : assert(json != null, 'json must not be null') { - parentId = value.parentId == null + parentId = value.parentId != null ? MosaicId.fromId(value.parentId.toBigInt()) : null; mosaicId = MosaicId.fromId(value.mosaicId.toBigInt()); @@ -168,7 +169,6 @@ class MosaicProperties { MosaicProperties.fromJson(List value) : assert(json != null, 'mosaic Properties is not valid') { - if (value.length < 3) { throw _errInvalidMosaicProperties; } @@ -184,8 +184,7 @@ class MosaicProperties { } MosaicProperties.fromDTO(List<_MosaicPropertiesDTO> value) - : assert(json != null, 'mosaic Properties is not valid') { - + : assert(json != null, 'mosaic Properties is not valid') { if (value.length < 3) { throw _errInvalidMosaicProperties; } diff --git a/lib/src/model/namespace_dto.dart b/lib/src/model/namespace_dto.dart index 44aa76a..eb7cda9 100644 --- a/lib/src/model/namespace_dto.dart +++ b/lib/src/model/namespace_dto.dart @@ -46,7 +46,7 @@ class _NamespaceDTO { } static List<_NamespaceDTO> listFromJson(List json) => json == null - ? null + ? null : json.map((value) => _NamespaceDTO.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/namespace_model.dart b/lib/src/model/namespace_model.dart index caba638..635eb7b 100644 --- a/lib/src/model/namespace_model.dart +++ b/lib/src/model/namespace_model.dart @@ -143,7 +143,7 @@ class NamespaceInfo { '}\n'; static List listFromDTO(List json) => json == null - ? null + ? null : json.map((value) => NamespaceInfo.fromDTO(value)).toList(); Map toJson() { diff --git a/lib/src/model/node_info.dart b/lib/src/model/node_info.dart index e819d1d..973d78e 100644 --- a/lib/src/model/node_info.dart +++ b/lib/src/model/node_info.dart @@ -38,7 +38,7 @@ class NodeInfo { '}\n'; static List listFromJson(List json) => json == null - ? null + ? null : json.map((value) => NodeInfo.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/node_time_dto.dart b/lib/src/model/node_time_dto.dart index 2207b76..83ebd66 100644 --- a/lib/src/model/node_time_dto.dart +++ b/lib/src/model/node_time_dto.dart @@ -18,7 +18,7 @@ class NodeTime { {'communicationTimestamps': communicationTimestamps}; static List listFromJson(List json) => json == null - ? null + ? null : json.map((value) => NodeTime.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/transaction_dto.dart b/lib/src/model/transaction_dto.dart index 021803e..f76ce58 100644 --- a/lib/src/model/transaction_dto.dart +++ b/lib/src/model/transaction_dto.dart @@ -196,7 +196,8 @@ class _TransferTransactionDTO extends _AbstractTransactionDTO { }); _mosaics = mosaics; } - _message = _MessageDTO.fromJson(json['message']); + _message = + json['message'] != null ? _MessageDTO.fromJson(json['message']) : null; } String _recipient; diff --git a/lib/src/model/transaction_ids.dart b/lib/src/model/transaction_ids.dart index 826e017..3259b0b 100644 --- a/lib/src/model/transaction_ids.dart +++ b/lib/src/model/transaction_ids.dart @@ -18,7 +18,7 @@ class TransactionIds { Map toJson() => {'transactionIds': transactionIds}; static List listFromJson(List json) => json == null - ? null + ? null : json.map((value) => TransactionIds.fromJson(value)).toList(); static Map mapFromJson( diff --git a/lib/src/model/transaction_model.dart b/lib/src/model/transaction_model.dart index ffc7bf5..daf8067 100644 --- a/lib/src/model/transaction_model.dart +++ b/lib/src/model/transaction_model.dart @@ -198,7 +198,9 @@ class Deadline { Deadline.fromUInt64DTO(UInt64DTO data) : assert(data.lower != null || data.higher == null, 'lower or higher must not be null') { - value = DateTime.fromMillisecondsSinceEpoch(data.toBigInt().toInt()); + value = data.toBigInt() != null + ? DateTime.fromMillisecondsSinceEpoch(data.toBigInt().toInt()) + : null; } DateTime value; @@ -465,7 +467,6 @@ class TransferTransaction extends AbstractTransaction implements Transaction { value._meta._merkleComponentHash) { type = transactionTypeFromRaw(value._transaction.type); deadline = Deadline.fromUInt64DTO(value._transaction.deadline); - signature = value._transaction.signature; networkType = extractNetworkType(value._transaction.version); version = extractVersion(value._transaction.version); @@ -592,7 +593,7 @@ class RegisterNamespaceTransaction extends AbstractTransaction this.networkType = networkType; namspaceName = rootNamespaceName; namespaceType = NamespaceType.root; - duration = duration; + this.duration = duration; } } @@ -747,7 +748,7 @@ class MosaicDefinitionTransaction extends AbstractTransaction mosaicProperties = mosaicProps; // Signer of transaction must be the same with ownerPublicKey mosaicId = MosaicId.fromNonceAndOwner(nonce, ownerPublicKey); - duration = duration; + this.duration = duration; } } @@ -866,10 +867,10 @@ class MosaicSupplyChangeTransaction extends AbstractTransaction version = _mosaicSupplyChangeVersion; this.deadline = deadline; type = transactionTypeFromRaw(16973); - networkType = networkType; - mosaicId = mosaicId; + this.networkType = networkType; + this.mosaicId = mosaicId; mosaicSupplyType = supplyType; - delta = delta; + this.delta = delta; } } diff --git a/lib/src/model/u_int64_dto.dart b/lib/src/model/u_int64_dto.dart index 98a37da..c04d381 100644 --- a/lib/src/model/u_int64_dto.dart +++ b/lib/src/model/u_int64_dto.dart @@ -3,7 +3,11 @@ part of xpx_chain_sdk; class UInt64DTO { UInt64DTO([this.higher, this.lower]); - UInt64DTO.fromJson(json) : assert(json != null, 'json must not be null') { + UInt64DTO.fromJson(json) { + if (json == null) { + return; + } + higher = Int32(json[0]); lower = Int32(json[1]); } @@ -34,7 +38,6 @@ class UInt64DTO { if (lower == null || higher == null) { return null; } - final buffer = Buffer.bigEndian(8) ..writeInt32(lower.toInt()) ..writeInt32(higher.toInt()); diff --git a/pubspec.yaml b/pubspec.yaml index f841ef8..ded850b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: xpx_chain_sdk -version: 0.0.3+2 +version: 0.0.3+3 description: Official ProximaX Sirius Blockchain SDK Library in Dart. author: 'Eleazar Garrido ' homepage: https://www.proximax.io