From 93ace3600906772f9960db2976d8277de43a9a3b Mon Sep 17 00:00:00 2001 From: redDwarf03 Date: Sun, 29 Oct 2023 17:43:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Add=20Blockchain=20Version=20in?= =?UTF-8?q?=20newKeychainTransaction=20and=20newAccessKeychainTransaction?= =?UTF-8?q?=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 +++- lib/src/services/api_service.dart | 16 +++++++++++++--- pubspec.yaml | 2 +- test/keychain_test.dart | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e24c9e..062cf3cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ Changelog ========= - +#### Version 3.3.2 +* Add Blockchain Version in newKeychainTransaction and newAccessKeychainTransaction methods + #### Version 3.3.1 * TypedEncoding serialization introduced for the recipients' args * Add Blockchain Version GraphQL request diff --git a/lib/src/services/api_service.dart b/lib/src/services/api_service.dart index 94d49450..f1c57782 100644 --- a/lib/src/services/api_service.dart +++ b/lib/src/services/api_service.dart @@ -610,7 +610,8 @@ class ApiService with JsonRPCUtil { Transaction newKeychainTransaction( String seed, List authorizedPublicKeys, - Uint8List originPrivateKey, { + Uint8List originPrivateKey, + int blockchainTxVersion, { String? serviceName, String? derivationPath, }) { @@ -635,7 +636,11 @@ class ApiService with JsonRPCUtil { ); } - return Transaction(type: 'keychain', data: Transaction.initData()) + return Transaction( + type: 'keychain', + version: blockchainTxVersion, + data: Transaction.initData(), + ) .setContent(jsonEncode(keychain.toDID())) .addOwnership( uint8ListToHex(aesEncrypt(keychain.encode(), aesKey)), @@ -654,6 +659,7 @@ class ApiService with JsonRPCUtil { String seed, Uint8List keychainAddress, Uint8List originPrivateKey, + int blockchainTxVersion, ) { final aesKey = uint8ListToHex( Uint8List.fromList( @@ -674,7 +680,11 @@ class ApiService with JsonRPCUtil { ), ]; - return Transaction(type: 'keychain_access', data: Transaction.initData()) + return Transaction( + type: 'keychain_access', + version: blockchainTxVersion, + data: Transaction.initData(), + ) .addOwnership( uint8ListToHex(aesEncrypt(keychainAddress, aesKey)), authorizedKeys, diff --git a/pubspec.yaml b/pubspec.yaml index 4c22713d..7182d20b 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.3.1 +version: 3.3.2 environment: sdk: ">=3.1.0 <4.0.0" diff --git a/test/keychain_test.dart b/test/keychain_test.dart index 1506ba79..9049cf1f 100644 --- a/test/keychain_test.dart +++ b/test/keychain_test.dart @@ -180,6 +180,13 @@ void main() { ApiService('https://mainnet.archethic.net').getOriginKey(); log('originPrivateKey: $originPrivateKey'); + final blockchainTxVersion = int.parse( + (await ApiService('https://mainnet.archethic.net') + .getBlockchainVersion()) + .version + .transaction, + ); + /// Create Keychain from keyChain seed and wallet public key to encrypt secret final keychainTransaction = ApiService('https://mainnet.archethic.net').newKeychainTransaction( @@ -190,6 +197,7 @@ void main() { ), ], Uint8List.fromList(hexToUint8List(originPrivateKey)), + blockchainTxVersion, serviceName: kServiceName, derivationPath: kDerivationPath, ); @@ -203,6 +211,7 @@ void main() { hexToUint8List(keychainTransaction.address!.address!), ), Uint8List.fromList(hexToUint8List(originPrivateKey)), + blockchainTxVersion, ); log('accessKeychainTx: ${accessKeychainTx.convertToJSON()}'); @@ -318,6 +327,13 @@ void main() { ApiService('https://mainnet.archethic.net').getOriginKey(); log('originPrivateKey: $originPrivateKey'); + final blockchainTxVersion = int.parse( + (await ApiService('https://mainnet.archethic.net') + .getBlockchainVersion()) + .version + .transaction, + ); + /// Create Keychain from keyChain seed and wallet public key to encrypt secret final keychainTransaction = ApiService('https://mainnet.archethic.net').newKeychainTransaction( @@ -328,6 +344,7 @@ void main() { ), ], Uint8List.fromList(hexToUint8List(originPrivateKey)), + blockchainTxVersion, serviceName: kServiceName, derivationPath: kDerivationPath, ); @@ -341,6 +358,7 @@ void main() { hexToUint8List(keychainTransaction.address!.address!), ), Uint8List.fromList(hexToUint8List(originPrivateKey)), + blockchainTxVersion, ); log('accessKeychainTx: ${accessKeychainTx.convertToJSON()}');