From fbdedf15a7c9b1ae822652926ce50ecd954f5d01 Mon Sep 17 00:00:00 2001 From: necklace Date: Mon, 6 Jul 2020 21:34:31 +0800 Subject: [PATCH 1/4] fix optionalOf serialize bug #31 --- lib/src/serialize.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/serialize.dart b/lib/src/serialize.dart index 5c7beee..d4c9fab 100644 --- a/lib/src/serialize.dart +++ b/lib/src/serialize.dart @@ -614,6 +614,8 @@ void serializeStruct(Type self, SerialBuffer buffer, Object data, } else { if (allowExtensions && field.type.extensionOf != null) { state.skippedBinaryExtension = true; + } else if(field.type.optionalOf != null ) { + field.type.serialize(field.type, buffer, dy[field.name],state: state); } else { throw 'missing ' + self.name + From f897a9bb497472be83afc9f04a7632b34dbd0f7c Mon Sep 17 00:00:00 2001 From: necklace Date: Mon, 6 Jul 2020 21:54:24 +0800 Subject: [PATCH 2/4] add createTransaction --- lib/src/client.dart | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/src/client.dart b/lib/src/client.dart index 1e88577..067415b 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -275,6 +275,21 @@ class EOSClient { return pushTransactionArgs; } + Future createTransaction(Transaction transaction, + { dynamic key, + int blocksBehind = 3, + int expireSecond = 180}) async { + NodeInfo info = await this.getInfo(); + Block refBlock = await getBlock((info.headBlockNum - blocksBehind).toString()); + final pKey = key ?? this.keys.values.toList()[0]; + + Transaction trx = await _fullFill(transaction, refBlock); + PushTransactionArgs pushTransactionArgs = await _createTransactionArgs( + info.chainId, transactionTypes['transaction'], trx, pKey); + + return pushTransactionArgs; + } + /// Get data needed to serialize actions in a contract */ Future _getContract(String accountName, {bool reload = false}) async { @@ -358,6 +373,21 @@ class EOSClient { return PushTransactionArgs(signatures, serializedTrx); } + + Future _createTransactionArgs(String chainId, + Type transactionType, Transaction transaction, ecc.EOSPrivateKey pKey) async { + List signatures = []; + + Uint8List serializedTrx = transaction.toBinary(transactionType); + + Uint8List signBuf = Uint8List.fromList(List.from(ser.stringToHex(chainId)) + ..addAll(serializedTrx) + ..addAll(Uint8List(32))); + + signatures.add(pKey.sign(signBuf).toString()); + + return PushTransactionArgs(signatures, serializedTrx); + } } class PushTransactionArgs { From a2af3b59c6d9ccda25369d25c0d2d5672734fec0 Mon Sep 17 00:00:00 2001 From: necklace Date: Mon, 6 Jul 2020 22:30:46 +0800 Subject: [PATCH 3/4] fix create transaction bug --- lib/src/client.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 067415b..61327ef 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -377,7 +377,7 @@ class EOSClient { Future _createTransactionArgs(String chainId, Type transactionType, Transaction transaction, ecc.EOSPrivateKey pKey) async { List signatures = []; - + transaction = await _serializeActions(transaction); Uint8List serializedTrx = transaction.toBinary(transactionType); Uint8List signBuf = Uint8List.fromList(List.from(ser.stringToHex(chainId)) From 16f7af9e0b191f04e09ffa6bd97f35b220031cc8 Mon Sep 17 00:00:00 2001 From: necklace Date: Tue, 15 Sep 2020 19:07:44 +0800 Subject: [PATCH 4/4] fix stringToSymbol bug --- lib/src/serialize.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/serialize.dart b/lib/src/serialize.dart index d4c9fab..1b54cee 100644 --- a/lib/src/serialize.dart +++ b/lib/src/serialize.dart @@ -580,7 +580,7 @@ Symbol stringToSymbol(String s) { if (!exp.hasMatch(s)) { throw 'Invalid symbol'; } - return Symbol(name: m[2].toString(), precision: int.parse([1].toString())); + return Symbol(name: m[0].group(2), precision: int.parse(m[0].group(1).toString())); } /// Convert `Symbol` to `string`. format: `precision,NAME`. */