Skip to content

Commit

Permalink
Merge pull request #17 from Tezsure/dev
Browse files Browse the repository at this point in the history
Release beta 2.1.1-beta
  • Loading branch information
yoyodefi authored Feb 23, 2021
2 parents 3eed3b0 + 5eeb82e commit 6bcc10c
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 40 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# [2.1.0+1]
# [2.1.1-beta]

* Fix for revelation of an account Ref #12

# [2.1.0-beta]

* Deploy contract
* Call contract
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _MyAppState extends State<MyApp> {
);
print("Applied operation ===> $delegationResult['appliedOp']");
print("Operation groupID ===> $delegationResult['operationGroupID']");

//Deploy a contract
var contract = """parameter string;
storage string;
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.0+1"
version: "2.1.1-beta"
typed_data:
dependency: transitive
description:
Expand Down
18 changes: 7 additions & 11 deletions lib/chain/tezos/tezos_message_utils.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import 'dart:typed_data';

import 'package:blake2b/blake2b_hash.dart';
import 'package:bs58check/bs58check.dart';
import 'package:bs58check/bs58check.dart' as bs58check;
import 'package:convert/convert.dart';
import 'package:tezster_dart/helper/generateKeys.dart';
import 'package:tezster_dart/src/soft-signer/soft_signer.dart';

class TezosMessageUtils {
static String writeBranch(String branch) {
return hex.encode(base58
.decode(branch)
.sublist(2, base58.decode(branch).length - 4)
.toList());
return hex.encode(bs58check.decode(branch).sublist(2).toList());
}

static String writeInt(int value) {
Expand Down Expand Up @@ -51,9 +48,8 @@ class TezosMessageUtils {
}

static String writeAddress(String address) {
var base58data = base58.decode(address).sublist(3);
base58data = base58data.sublist(0, base58data.length - 4);
var _hex = hex.encode(base58data);
var bs58checkdata = bs58check.decode(address).sublist(3);
var _hex = hex.encode(bs58checkdata);
if (address.startsWith("tz1")) {
return "0000" + _hex;
} else if (address.startsWith("tz2")) {
Expand All @@ -70,11 +66,11 @@ class TezosMessageUtils {

static String writePublicKey(String publicKey) {
if (publicKey.startsWith("edpk")) {
return "00" + hex.encode(base58.decode(publicKey).sublist(4));
return "00" + hex.encode(bs58check.decode(publicKey).sublist(4));
} else if (publicKey.startsWith("sppk")) {
return "01" + hex.encode(base58.decode(publicKey).sublist(4));
return "01" + hex.encode(bs58check.decode(publicKey).sublist(4));
} else if (publicKey.startsWith("p2pk")) {
return "02" + hex.encode(base58.decode(publicKey).sublist(4));
return "02" + hex.encode(bs58check.decode(publicKey).sublist(4));
} else {
throw new Exception('Unrecognized key type');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/chain/tezos/tezos_node_reader.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:tezster_dart/helper/http_helper.dart';

class TezosNodeReader {
Expand All @@ -21,7 +20,7 @@ class TezosNodeReader {
{String chainid = 'main'}) async {
var response = await HttpHelper.performGetRequest(server,
'chains/$chainid/blocks/$block/context/contracts/$publicKeyHash/manager_key');
return response.toString().isNotEmpty ? response.toString() : '';
return response != null ? response.toString() : '';
}

static Future<Map<dynamic, dynamic>> getBlockAtOffset(
Expand Down
8 changes: 4 additions & 4 deletions lib/chain/tezos/tezos_node_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ class TezosNodeWriter {
if (!isKeyRevealed) {
var revealOp = OperationModel(
counter: counter,
fee: '0',
fee: '0', // Reveal Fee will be covered by the appended operation
source: publicKeyHash,
kind: 'reveal',
gasLimit: 10600,
storageLimit: 0,
gasLimit: TezosConstants.DefaultKeyRevealGasLimit,
storageLimit: TezosConstants.DefaultKeyRevealStorageLimit,
publicKey: publicKey,
);
for (var index = 0; index < operations.length; index++) {
Expand Down Expand Up @@ -210,7 +210,7 @@ class TezosNodeWriter {

static String forgeOperations(
String branch, List<OperationModel> operations) {
var encoded = TezosMessageUtils.writeBranch(branch);
String encoded = TezosMessageUtils.writeBranch(branch);
operations.forEach((element) {
encoded += TezosMessageCodec.encodeOperation(element);
});
Expand Down
5 changes: 5 additions & 0 deletions lib/helper/constants.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
class TezosConstants {
static const OperationGroupWatermark = "03";

static const DefaultTransactionStorageLimit = 496;
static const DefaultTransactionGasLimit = 10600;

static const DefaultDelegationFee = 1258;
static const DefaultDelegationStorageLimit = 0;
static const DefaultDelegationGasLimit = 1101;

static const DefaultKeyRevealStorageLimit = 0;
static const DefaultKeyRevealGasLimit = 1100;
}
49 changes: 30 additions & 19 deletions lib/models/operation_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class OperationModel {

Map<String, dynamic> parameters;

String pkh;
String secret;

OperationModel({
this.destination,
this.amount,
Expand All @@ -27,6 +30,8 @@ class OperationModel {
this.publicKey,
this.delegate,
this.script,
this.pkh,
this.secret,
}) {
if (kind == 'delegation') {
gasLimit = TezosConstants.DefaultDelegationGasLimit;
Expand Down Expand Up @@ -78,26 +83,32 @@ class OperationModel {
'delegate': delegate,
'script': script
}
: parameters == null
: kind == "activate_account"
? {
'destination': destination,
'amount': amount,
'storage_limit': storageLimit.toString(),
'gas_limit': gasLimit.toString(),
'counter': counter.toString(),
'fee': fee,
'source': source,
'kind': kind,
'pkh': pkh,
'secret': secret,
}
: {
'destination': destination,
'amount': amount,
'storage_limit': storageLimit.toString(),
'gas_limit': gasLimit.toString(),
'counter': counter.toString(),
'fee': fee,
'source': source,
'kind': kind,
'parameters': parameters,
};
: parameters == null
? {
'destination': destination,
'amount': amount,
'storage_limit': storageLimit.toString(),
'gas_limit': gasLimit.toString(),
'counter': counter.toString(),
'fee': fee,
'source': source,
'kind': kind,
}
: {
'destination': destination,
'amount': amount,
'storage_limit': storageLimit.toString(),
'gas_limit': gasLimit.toString(),
'counter': counter.toString(),
'fee': fee,
'source': source,
'kind': kind,
'parameters': parameters,
};
}
1 change: 1 addition & 0 deletions lib/src/tezster_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,5 @@ class TezsterDart {
parameterFormat: codeFormat ?? TezosParameterFormat.Micheline,
offset: offset ?? 54);
}

}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: tezster_dart
description: A flutter package which provides the functionalities to play around
with tezos dApps
version: 2.1.0+1
version: 2.1.1-beta
homepage: https://github.com/Tezsure/tezster_dart
repository: https://github.com/Tezsure/tezster_dart
issue_tracker: https://github.com/Tezsure/tezster_dart/issues
Expand Down

0 comments on commit 6bcc10c

Please sign in to comment.