From 8190a4033db4abad8bf95a36565f20131f55203d Mon Sep 17 00:00:00 2001 From: redDwarf03 Date: Mon, 22 May 2023 12:20:19 +0200 Subject: [PATCH] Fix getStorageNoncePublicKey method --- CHANGELOG.md | 3 ++ lib/src/model/shared_secrets.dart | 4 +-- lib/src/model/shared_secrets.freezed.dart | 43 ++++++++--------------- lib/src/model/shared_secrets.g.dart | 5 +-- lib/src/services/api_service.dart | 4 +-- pubspec.yaml | 2 +- test/api_test.dart | 2 +- 7 files changed, 23 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ebbc905..dde35419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +#### Version 3.1.1 (2023-05-22) +* Fix getStorageNoncePublicKey method + #### Version 3.1.0 (2023-05-16) * Add new classes to manage 'hosting' type transactions * Add setOriginSignature setter in transaction class diff --git a/lib/src/model/shared_secrets.dart b/lib/src/model/shared_secrets.dart index 54666b04..3ce4a528 100644 --- a/lib/src/model/shared_secrets.dart +++ b/lib/src/model/shared_secrets.dart @@ -11,10 +11,10 @@ class SharedSecrets with _$SharedSecrets { const factory SharedSecrets({ /// The storage nonce public key: Public Key to encrypt data for the node, /// so they will be able to decrypt it (mostly for smart contract authorized key) - Map? storageNoncePublicKey, + String? storageNoncePublicKey, }) = _SharedSecrets; const SharedSecrets._(); factory SharedSecrets.fromJson(Map json) => - _$SharedSecretsFromJson(json); + _$SharedSecretsFromJson(json['sharedSecrets']); } diff --git a/lib/src/model/shared_secrets.freezed.dart b/lib/src/model/shared_secrets.freezed.dart index c49c30be..f7c6340e 100644 --- a/lib/src/model/shared_secrets.freezed.dart +++ b/lib/src/model/shared_secrets.freezed.dart @@ -22,8 +22,7 @@ SharedSecrets _$SharedSecretsFromJson(Map json) { mixin _$SharedSecrets { /// The storage nonce public key: Public Key to encrypt data for the node, /// so they will be able to decrypt it (mostly for smart contract authorized key) - Map? get storageNoncePublicKey => - throw _privateConstructorUsedError; + String? get storageNoncePublicKey => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -37,7 +36,7 @@ abstract class $SharedSecretsCopyWith<$Res> { SharedSecrets value, $Res Function(SharedSecrets) then) = _$SharedSecretsCopyWithImpl<$Res, SharedSecrets>; @useResult - $Res call({Map? storageNoncePublicKey}); + $Res call({String? storageNoncePublicKey}); } /// @nodoc @@ -59,7 +58,7 @@ class _$SharedSecretsCopyWithImpl<$Res, $Val extends SharedSecrets> storageNoncePublicKey: freezed == storageNoncePublicKey ? _value.storageNoncePublicKey : storageNoncePublicKey // ignore: cast_nullable_to_non_nullable - as Map?, + as String?, ) as $Val); } } @@ -72,7 +71,7 @@ abstract class _$$_SharedSecretsCopyWith<$Res> __$$_SharedSecretsCopyWithImpl<$Res>; @override @useResult - $Res call({Map? storageNoncePublicKey}); + $Res call({String? storageNoncePublicKey}); } /// @nodoc @@ -90,9 +89,9 @@ class __$$_SharedSecretsCopyWithImpl<$Res> }) { return _then(_$_SharedSecrets( storageNoncePublicKey: freezed == storageNoncePublicKey - ? _value._storageNoncePublicKey + ? _value.storageNoncePublicKey : storageNoncePublicKey // ignore: cast_nullable_to_non_nullable - as Map?, + as String?, )); } } @@ -100,28 +99,15 @@ class __$$_SharedSecretsCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$_SharedSecrets extends _SharedSecrets { - const _$_SharedSecrets({final Map? storageNoncePublicKey}) - : _storageNoncePublicKey = storageNoncePublicKey, - super._(); + const _$_SharedSecrets({this.storageNoncePublicKey}) : super._(); factory _$_SharedSecrets.fromJson(Map json) => _$$_SharedSecretsFromJson(json); - /// The storage nonce public key: Public Key to encrypt data for the node, - /// so they will be able to decrypt it (mostly for smart contract authorized key) - final Map? _storageNoncePublicKey; - /// The storage nonce public key: Public Key to encrypt data for the node, /// so they will be able to decrypt it (mostly for smart contract authorized key) @override - Map? get storageNoncePublicKey { - final value = _storageNoncePublicKey; - if (value == null) return null; - if (_storageNoncePublicKey is EqualUnmodifiableMapView) - return _storageNoncePublicKey; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } + final String? storageNoncePublicKey; @override String toString() { @@ -133,14 +119,13 @@ class _$_SharedSecrets extends _SharedSecrets { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_SharedSecrets && - const DeepCollectionEquality() - .equals(other._storageNoncePublicKey, _storageNoncePublicKey)); + (identical(other.storageNoncePublicKey, storageNoncePublicKey) || + other.storageNoncePublicKey == storageNoncePublicKey)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, const DeepCollectionEquality().hash(_storageNoncePublicKey)); + int get hashCode => Object.hash(runtimeType, storageNoncePublicKey); @JsonKey(ignore: true) @override @@ -157,8 +142,8 @@ class _$_SharedSecrets extends _SharedSecrets { } abstract class _SharedSecrets extends SharedSecrets { - const factory _SharedSecrets( - {final Map? storageNoncePublicKey}) = _$_SharedSecrets; + const factory _SharedSecrets({final String? storageNoncePublicKey}) = + _$_SharedSecrets; const _SharedSecrets._() : super._(); factory _SharedSecrets.fromJson(Map json) = @@ -168,7 +153,7 @@ abstract class _SharedSecrets extends SharedSecrets { /// The storage nonce public key: Public Key to encrypt data for the node, /// so they will be able to decrypt it (mostly for smart contract authorized key) - Map? get storageNoncePublicKey; + String? get storageNoncePublicKey; @override @JsonKey(ignore: true) _$$_SharedSecretsCopyWith<_$_SharedSecrets> get copyWith => diff --git a/lib/src/model/shared_secrets.g.dart b/lib/src/model/shared_secrets.g.dart index 46a26d4b..9e9bf2b6 100644 --- a/lib/src/model/shared_secrets.g.dart +++ b/lib/src/model/shared_secrets.g.dart @@ -8,10 +8,7 @@ part of 'shared_secrets.dart'; _$_SharedSecrets _$$_SharedSecretsFromJson(Map json) => _$_SharedSecrets( - storageNoncePublicKey: - (json['storageNoncePublicKey'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), + storageNoncePublicKey: json['storageNoncePublicKey'] as String?, ); Map _$$_SharedSecretsToJson(_$_SharedSecrets instance) => diff --git a/lib/src/services/api_service.dart b/lib/src/services/api_service.dart index 0a1f32d0..bc4b3724 100644 --- a/lib/src/services/api_service.dart +++ b/lib/src/services/api_service.dart @@ -155,9 +155,7 @@ class ApiService { result.exception!.linkException.toString(), ); } - - return result.parsedData!.storageNoncePublicKey!['storageNoncePublicKey'] ?? - ''; + return result.parsedData!.storageNoncePublicKey ?? ''; } /// Query the network to find a balance from a list of addresses diff --git a/pubspec.yaml b/pubspec.yaml index 54366371..b591db85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ name: archethic_lib_dart description: Archethic dart library for Flutter for Node and Browser. This library aims to provide a easy way to create Archethic transaction and to send them over the network homepage: https://github.com/archethic-foundation/libdart -version: 3.1.0 +version: 3.1.1 environment: sdk: ">=2.19.0 <3.0.0" diff --git a/test/api_test.dart b/test/api_test.dart index acb6ec01..80539e8f 100644 --- a/test/api_test.dart +++ b/test/api_test.dart @@ -42,7 +42,7 @@ void main() { expect( storageNoncePublicKey, - '00008D6D0FD165FEF6966E4E6ACE0DDF2A9CA4E24F5ADBFF5CFB370B477A058DB769', + '000122A6CD9ED07E46835D6E88E5BD0BEE84C3F5E5DBF8E916AD9B2EC912C44AFEC2', ); });