Skip to content

Commit

Permalink
Merge pull request #62 from SushantChandla/v1
Browse files Browse the repository at this point in the history
changed uint8list to bytelist
  • Loading branch information
kaderate authored Oct 7, 2021
2 parents 638ff10 + a4be29b commit 647f3fb
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [2.12.4]
sdk: [2.14.3]

services:
flextesa:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/contracts/impl/contract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Contract {
/// - when [params] are incompatible with the entrypoint signature, a [TypeError] is thrown
Future<OperationsList> callOperation({
String entrypoint = 'default',
dynamic? params,
dynamic params,
required Keystore source,
int amount = 0,
int? customFee,
Expand Down
26 changes: 12 additions & 14 deletions lib/src/core/client/impl/tezart_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ class TezartClient {
bool reveal = true,
}) async {
return _catchHttpError<OperationsList>(() async {
log.info(
'request transfer $amount µtz from $source.address to the destination $destination');

final operationsList =
OperationsList(source: source, rpcInterface: rpcInterface)
..appendOperation(
TransactionOperation(
amount: amount,
destination: destination,
customFee: customFee,
customGasLimit: customGasLimit,
customStorageLimit: customStorageLimit,
),
);
log.info('request transfer $amount µtz from $source.address to the destination $destination');

final operationsList = OperationsList(source: source, rpcInterface: rpcInterface)
..appendOperation(
TransactionOperation(
amount: amount,
destination: destination,
customFee: customFee,
customGasLimit: customGasLimit,
customStorageLimit: customStorageLimit,
),
);
if (reveal) {
await _prependRevealIfNotRevealed(
operationsList,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/crypto/impl/encrypted_secret_key_to_seed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ String encryptedSecretKeyToSeed({
);

final secretbox = SecretBox(encryptionKey);
final decryptedBytes = secretbox.decrypt(secretKeyBytes, nonce: nonce);
final decryptedBytes = secretbox.decrypt(ByteList.fromList(secretKeyBytes), nonce: nonce);

final seed = crypto.encodeWithPrefix(
prefix: Prefixes.edsk2,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/crypto/impl/external_crypto_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Uint8List seedBytesFromMnemonic(String mnemonic, {String passphrase = ''}) {
return seedBytes.sublist(0, 32);
}

Uint8List secretKeyBytesFromSeedBytes(Uint8List seed) => signingKeyFromSeedBytes(seed);
ByteList secretKeyBytesFromSeedBytes(Uint8List seed) => signingKeyFromSeedBytes(seed);

Uint8List publicKeyBytesFromSeedBytes(Uint8List seed) => signingKeyFromSeedBytes(seed).verifyKey;
ByteList publicKeyBytesFromSeedBytes(Uint8List seed) => signingKeyFromSeedBytes(seed).verifyKey;

@visibleForTesting
SigningKey signingKeyFromSeedBytes(Uint8List seed) => SigningKey(seed: seed);

Uint8List signDetached({required Uint8List bytes, required Uint8List secretKey}) {
ByteList signDetached({required Uint8List bytes, required Uint8List secretKey}) {
final seed = secretKey.sublist(0, 32); // the seed is the first 32 bytes of the secret key

return SigningKey(seed: seed).sign(bytes).sublist(0, 64);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/crypto/impl/secret_key_seed_conversion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ String seedToSecretKey(String seed) {

return encodeWithPrefix(
prefix: secretKeyPrefix,
bytes: secretKey,
bytes: Uint8List.fromList(secretKey.toList()),
);
}
2 changes: 1 addition & 1 deletion lib/src/keystore/impl/keystore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Keystore extends Equatable {

return crypto.encodeWithPrefix(
prefix: _publicKeyPrefix,
bytes: pk,
bytes: Uint8List.fromList(pk.toList()),
);
});

Expand Down
4 changes: 3 additions & 1 deletion lib/src/micheline_decoder/impl/address_decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class AddressDecoder implements MichelineDecoder {
prefix = Prefixes.tz2;
} else if (stringBytes.startsWith('0002')) {
prefix = Prefixes.tz3;
} else if (stringBytes.startsWith('01')) prefix = Prefixes.KT;
} else if (stringBytes.startsWith('01')) {
prefix = Prefixes.KT;
}

return prefix == null ? data['bytes'] : encodeWithPrefix(prefix: prefix, bytes: bytes);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/micheline_encoder/impl/option_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'micheline_encoder.dart';

class OptionEncoder implements MichelineEncoder {
@override
final dynamic? params;
final dynamic params;
@override
final Map<String, dynamic> type;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/micheline_encoder/impl/pair_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PairEncoder implements MichelineEncoder {
throw TypeError();
}

dynamic? get _secondParams {
dynamic get _secondParams {
if (params is Map) return params;
if (params is List) {
if (params.length > 2) return params.skip(1).toList();
Expand Down
5 changes: 3 additions & 2 deletions lib/src/signature/impl/signature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:typed_data';

import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
import 'package:pinenacl/ed25519.dart';
import 'package:tezart/src/common/validators/hex_validator.dart';
import 'package:tezart/src/keystore/keystore.dart';

Expand Down Expand Up @@ -61,7 +62,7 @@ class Signature extends Equatable {
}

/// Signed bytes of this.
Uint8List get signedBytes {
ByteList get signedBytes {
return crypto.catchUnhandledErrors(() {
final watermarkedBytes =
watermark == null ? bytes : Uint8List.fromList(crypto.hexDecode(_watermarkToHex[watermark]!) + bytes);
Expand All @@ -76,7 +77,7 @@ class Signature extends Equatable {
/// Base 58 encoding of this using 'edsig' prefix.
String get edsig {
return crypto.catchUnhandledErrors(() {
return crypto.encodeWithPrefix(prefix: crypto.Prefixes.edsig, bytes: signedBytes);
return crypto.encodeWithPrefix(prefix: crypto.Prefixes.edsig, bytes: Uint8List.fromList(signedBytes.toList()));
});
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
convert: ^3.0.0 # Encoders and decoders for converting between different data representations
dio: ^4.0.0 # http client
equatable: ^2.0.0
pinenacl: ^0.2.0 # Dart implementation of TweetNacl
pinenacl: ^0.3.3 # Dart implementation of TweetNacl
json_serializable: ^4.1.0 # code generation for toJson and fromJson methods
json_annotation: ^4.0.1 # Classes and helper functions that support JSON code generation via the `json_serializable` package.
retry: ^3.1.0 # retry a function if an error happens
Expand Down

0 comments on commit 647f3fb

Please sign in to comment.