Skip to content

Commit

Permalink
V5.1.0
Browse files Browse the repository at this point in the history
-Update dependencies.
  • Loading branch information
mrtnetwork committed Jan 23, 2025
1 parent c9c8743 commit d0393f6
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 5.1.0

- Update dependencies.
- Allow deserialization ADA transaction inputs encoded as Cbor(Set).

## 5.0.0

- Minimum required Dart SDK version updated to 3.3.
Expand Down
4 changes: 2 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file configures the analyzer to use the lint rule set from `package:lint`

include: package:flutter_lints/flutter.yaml # For production apps
include: package:lints/recommended.yaml
# include: package:flutter_lints/flutter.yaml # For production apps
# include: package:lint/casual.yaml # For code samples, hackathons and other non-production code
# include: package:lint/package.yaml # Use this for packages with public API

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
http: ^1.1.0
# blockchain_utils:
# path: ../../../blockchain_utils
blockchain_utils: ^4.0.0
blockchain_utils: ^4.0.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
Expand Down
6 changes: 2 additions & 4 deletions lib/ada/src/models/transaction/transaction/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ class TransactionBody with ADASerialization {
factory TransactionBody.deserialize(CborMapValue cbor) {
return TransactionBody(
inputs: cbor
.getValueFromIntKey<CborListValue>(0)
.value
.getIterableFromIntKey(0)!
.map((e) => TransactionInput.deserialize(e))
.toList(),
outputs: cbor
.getValueFromIntKey<CborListValue>(1)
.value
.getIterableFromIntKey(1)!
.map((e) => TransactionOutput.deserialize(e))
.toList(),
fee: cbor.getValueFromIntKey<CborObject>(2).getInteger(),
Expand Down
16 changes: 16 additions & 0 deletions lib/ada/src/serialization/cbor/cbor_serialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,20 @@ extension QuickCborMap on CborMapValue {
}
return val;
}

List<dynamic>? getIterableFromIntKey(int key, {bool throwOnNull = true}) {
final val = value[CborIntValue(key)];
if (val == null || val is CborNullValue) {
if (throwOnNull) {
throw ADAPluginException('Object not found.', details: {"key": key});
}
}
if (val is CborListValue) {
return val.value;
}
if (val is CborSetValue) {
return val.value.toList();
}
throw ADAPluginException('value is not iterable.', details: {"key": key});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ abstract class TronProtocolBufferImpl {
} else {
encode = ProtocolBufferEncoder.encode(tagNumber, value);
}

bytes.add(encode);
}
return bytes.toBytes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class CreateSmartContract extends TronBaseContract {
CreateSmartContract(
{required this.ownerAddress,
required this.newContract,
this.callTokenValue,
this.tokenId});
BigInt? callTokenValue,
this.tokenId})
: callTokenValue = callTokenValue == BigInt.zero ? null : callTokenValue;
factory CreateSmartContract.deserialize(List<int> bytes) {
final decode = TronProtocolBufferImpl.decode(bytes);
return CreateSmartContract(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/tron/src/models/contract/base_contract/base.dart';
import 'package:on_chain/tron/src/models/contract/smart_contract/abi_types.dart';
import 'package:on_chain/tron/src/models/contract/smart_contract/smart_contract_abi_entry_param.dart';
Expand Down Expand Up @@ -42,12 +43,8 @@ class SmartContractABIEntry extends TronProtocolBufferImpl {
required this.type,
this.payable,
this.stateMutability})
: inputs = inputs == null
? null
: List<SmartContractBABIEntryParam>.unmodifiable(inputs),
outputs = outputs == null
? null
: List<SmartContractBABIEntryParam>.unmodifiable(outputs);
: inputs = inputs?.emptyAsNull?.immutable,
outputs = outputs?.emptyAsNull?.immutable;
factory SmartContractABIEntry.deserialize(List<int> bytes) {
final decode = TronProtocolBufferImpl.decode(bytes);
return SmartContractABIEntry(
Expand Down
13 changes: 7 additions & 6 deletions lib/tron/src/models/contract/transaction/transaction_raw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ class TransactionRaw extends TronProtocolBufferImpl {
this.feeLimit})
: assert(feeLimit == null || feeLimit > BigInt.zero,
'fee limit must not be zero.'),
refBlockBytes = BytesUtils.toBytes(refBlockBytes, unmodifiable: true),
refBlockHash = BytesUtils.toBytes(refBlockHash, unmodifiable: true),
data = BytesUtils.tryToBytes(data, unmodifiable: true),
scripts = BytesUtils.tryToBytes(scripts, unmodifiable: true),
auths = auths == null ? null : List<Authority>.unmodifiable(auths),
contract = List<TransactionContract>.unmodifiable(contract);
assert(contract.isNotEmpty, 'at least one contract required'),
refBlockBytes = refBlockBytes.asImmutableBytes,
refBlockHash = refBlockHash.asImmutableBytes,
data = data?.emptyAsNull?.asImmutableBytes,
scripts = scripts?.emptyAsNull?.asImmutableBytes,
auths = auths?.emptyAsNull?.immutable,
contract = contract.immutable;

/// The reference block bytes of the transaction.
final List<int> refBlockBytes;
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: on_chain
description: Streamline Ethereum, Tron, Solana and Cardano operations. Effortlessly create transactions, interact with smart contracts, sign, and send transactions.
version: 5.0.0
version: 5.1.0
homepage: "https://github.com/mrtnetwork/on_chain"
repository: "https://github.com/mrtnetwork/on_chain"
Author: [email protected]
Expand All @@ -17,13 +17,13 @@ environment:


dependencies:
blockchain_utils: ^4.0.0
blockchain_utils: ^4.0.1
# blockchain_utils:
# path: ../../blockchain_utils


dev_dependencies:
lints: ^5.0.0
lints: ^5.1.1
test: ^1.25.9
flutter_lints: ^5.0.0
# For information on the generic Dart part of this file, see the
Expand Down
3 changes: 3 additions & 0 deletions test/tron/serialization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,6 @@ void main() {
'0a023f86220896a55a5c6ef6407040868884d9cc31521d68747470733a2f2f6769746875622e636f6d2f6d72746e6574776f726b5abd01080412b8010a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e74726163741283010a15417fbb78c66505876284a49ad89bee3df2e0b7ca5e12190a1541cd8d8ad1b4a5bd7afe46949421d2b411a3601717100112190a15416d93bd35508007a45a1c7cdb8b982e70bf391775100112190a1541e817b29047a50558cc8f5e97c5bb99d4723cbaa2100112190a1541b40de3abd90961539517d57d0f79f477072ebda0100170d886b7c4cc31900180ade204');
});
}

/// 0a023f86220896a55a5c6ef6407040868884d9cc31521d68747470733a2f2f6769746875622e636f6d2f6d72746e6574776f726b5abd01080412b8010a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e74726163741283010a15417fbb78c66505876284a49ad89bee3df2e0b7ca5e12190a1541cd8d8ad1b4a5bd7afe46949421d2b411a3601717100112190a15416d93bd35508007a45a1c7cdb8b982e70bf391775100112190a1541e817b29047a50558cc8f5e97c5bb99d4723cbaa2100112190a
/// 0a023f86220896a55a5c6ef6407040868884d9cc3150005abd01080412b8010a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e566f74655769746e657373436f6e74726163741283010a15417fbb78c66505876284a49ad89bee3df2e0b7ca5e12190a1541cd8d8ad1b4a5bd7afe46949421d2b411a3601717100112190a15416d93bd35508007a45a1c7cdb8b982e70bf391775100112190a1541e817b29047a50558cc8f5e97c5bb99d4723cbaa2100112190a1541b40de3abd90961539517d57d0f79f477072ebda0100170d886b7c4cc31900180ade204

0 comments on commit d0393f6

Please sign in to comment.