Skip to content

Commit

Permalink
Fix getStorageNoncePublicKey method
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed May 22, 2023
1 parent c312775 commit 8190a40
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 40 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/shared_secrets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>? storageNoncePublicKey,
String? storageNoncePublicKey,
}) = _SharedSecrets;
const SharedSecrets._();

factory SharedSecrets.fromJson(Map<String, dynamic> json) =>
_$SharedSecretsFromJson(json);
_$SharedSecretsFromJson(json['sharedSecrets']);
}
43 changes: 14 additions & 29 deletions lib/src/model/shared_secrets.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ SharedSecrets _$SharedSecretsFromJson(Map<String, dynamic> 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<String, String>? get storageNoncePublicKey =>
throw _privateConstructorUsedError;
String? get storageNoncePublicKey => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
Expand All @@ -37,7 +36,7 @@ abstract class $SharedSecretsCopyWith<$Res> {
SharedSecrets value, $Res Function(SharedSecrets) then) =
_$SharedSecretsCopyWithImpl<$Res, SharedSecrets>;
@useResult
$Res call({Map<String, String>? storageNoncePublicKey});
$Res call({String? storageNoncePublicKey});
}

/// @nodoc
Expand All @@ -59,7 +58,7 @@ class _$SharedSecretsCopyWithImpl<$Res, $Val extends SharedSecrets>
storageNoncePublicKey: freezed == storageNoncePublicKey
? _value.storageNoncePublicKey
: storageNoncePublicKey // ignore: cast_nullable_to_non_nullable
as Map<String, String>?,
as String?,
) as $Val);
}
}
Expand All @@ -72,7 +71,7 @@ abstract class _$$_SharedSecretsCopyWith<$Res>
__$$_SharedSecretsCopyWithImpl<$Res>;
@override
@useResult
$Res call({Map<String, String>? storageNoncePublicKey});
$Res call({String? storageNoncePublicKey});
}

/// @nodoc
Expand All @@ -90,38 +89,25 @@ class __$$_SharedSecretsCopyWithImpl<$Res>
}) {
return _then(_$_SharedSecrets(
storageNoncePublicKey: freezed == storageNoncePublicKey
? _value._storageNoncePublicKey
? _value.storageNoncePublicKey
: storageNoncePublicKey // ignore: cast_nullable_to_non_nullable
as Map<String, String>?,
as String?,
));
}
}

/// @nodoc
@JsonSerializable()
class _$_SharedSecrets extends _SharedSecrets {
const _$_SharedSecrets({final Map<String, String>? storageNoncePublicKey})
: _storageNoncePublicKey = storageNoncePublicKey,
super._();
const _$_SharedSecrets({this.storageNoncePublicKey}) : super._();

factory _$_SharedSecrets.fromJson(Map<String, dynamic> 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<String, String>? _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<String, String>? 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() {
Expand All @@ -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
Expand All @@ -157,8 +142,8 @@ class _$_SharedSecrets extends _SharedSecrets {
}

abstract class _SharedSecrets extends SharedSecrets {
const factory _SharedSecrets(
{final Map<String, String>? storageNoncePublicKey}) = _$_SharedSecrets;
const factory _SharedSecrets({final String? storageNoncePublicKey}) =
_$_SharedSecrets;
const _SharedSecrets._() : super._();

factory _SharedSecrets.fromJson(Map<String, dynamic> json) =
Expand All @@ -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<String, String>? get storageNoncePublicKey;
String? get storageNoncePublicKey;
@override
@JsonKey(ignore: true)
_$$_SharedSecretsCopyWith<_$_SharedSecrets> get copyWith =>
Expand Down
5 changes: 1 addition & 4 deletions lib/src/model/shared_secrets.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions lib/src/services/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion test/api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void main() {

expect(
storageNoncePublicKey,
'00008D6D0FD165FEF6966E4E6ACE0DDF2A9CA4E24F5ADBFF5CFB370B477A058DB769',
'000122A6CD9ED07E46835D6E88E5BD0BEE84C3F5E5DBF8E916AD9B2EC912C44AFEC2',
);
});

Expand Down

0 comments on commit 8190a40

Please sign in to comment.