Skip to content

Commit

Permalink
V3.3.0
Browse files Browse the repository at this point in the history
- Update dependencies.
- Move Layout serialzation to blockchain_utils package.
  • Loading branch information
mrtnetwork committed May 29, 2024
1 parent 201f5ac commit c1810fb
Show file tree
Hide file tree
Showing 685 changed files with 6,800 additions and 7,944 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
## 3.3.0

- Update dependencies.
- Move Layout serialzation to blockchain_utils package.

## 3.2.0

- Introducing a Transaction Builder for Cardano: Simplify Transaction Creation and Signing.

## 3.1.0

- Update dependencies.
- Constructors for Tron Native Contracts for Deserialization from Protobuf

## 3.0.1

- Update dependencies.

## 3.0.0
- Added support for the Cardano network.

- Added support for the Cardano network.

## 2.0.0

- Added support for the Solana network.

## 1.0.0

- Resolved encoding and decoding issues with Tron operations..
- Corrected Eip1559 fee calculation in ETHTransactionBuilder.
- Updated dependencies to ensure compatibility and leverage the latest features.

## 0.0.1

* TODO: Release.

- TODO: Release.
2 changes: 1 addition & 1 deletion 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:lints/recommended.yaml # For production apps
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
5 changes: 2 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ dependencies:
path: ../
web_socket_channel: ^2.4.0
http: ^1.1.0
blockchain_utils: ^2.1.2
# blockchain_utils:
# path: ../../blockchain_utils
# blockchain_utils: ^2.1.2
blockchain_utils: ^3.0.0
# 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
Binary file added lib/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/ada/src/address/era/shelly/core/shelly_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class ADAShellyAddress extends ADAAddress {
case ADAAddressType.enterprise:
return ADAEnterpriseAddress(address, network: network);
default:
throw MessageException(
throw const MessageException(
"Invalid shelly address. for byron address please use ByronAddress.");
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/ada/src/builder/builder/transaction_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ADATransactionBuilder {

int estimateSize({ADAAddress? onChangeAddress}) {
if (utxos.isEmpty || _outputs.isEmpty) {
throw MessageException("Utxos and outputs must not be not empty.");
throw const MessageException("Utxos and outputs must not be not empty.");
}
final outs = _outputs.map((e) {
if (e.amount.coin == BigInt.zero) {
Expand Down Expand Up @@ -135,7 +135,7 @@ class ADATransactionBuilder {

TransactionOutput? onChangeAddress(ADAAddress onChangeAddress) {
if (_fee == null) {
throw MessageException(
throw const MessageException(
"please calculation the transaction fees befor using change address.");
}
final change = _changeOutput(onChangeAddress);
Expand All @@ -153,7 +153,7 @@ class ADATransactionBuilder {

TransactionBody buildTxBody({AuxiliaryDataHash? auxHash}) {
if (fee == null) {
throw MessageException(
throw const MessageException(
"cannot build transaction body before calculation fee.");
}
final mint = getMint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class SingleHostAddr extends Relay {
CborObject toCbor() {
return CborListValue.fixedLength([
type.toCbor(),
port == null ? CborNullValue() : CborIntValue(port!),
ipv4?.toCbor() ?? CborNullValue(),
ipv6?.toCbor() ?? CborNullValue()
port == null ? const CborNullValue() : CborIntValue(port!),
ipv4?.toCbor() ?? const CborNullValue(),
ipv6?.toCbor() ?? const CborNullValue()
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SingleHostName extends Relay {
CborObject toCbor() {
return CborListValue.fixedLength([
type.toCbor(),
port == null ? CborNullValue() : CborIntValue(port!),
port == null ? const CborNullValue() : CborIntValue(port!),
CborStringValue(dnsName)
]);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/ada/src/models/metadata/types/bytes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class TransactionMetadataBytes extends TransactionMetadata<List<int>> {
{MetadataSchemaConfig config = const MetadataSchemaConfig(
jsonSchema: MetadataJsonSchema.noConversions)}) {
if (config.jsonSchema == MetadataJsonSchema.noConversions) {
throw MessageException("bytes not allowed in JSON in specified schema.");
throw const MessageException(
"bytes not allowed in JSON in specified schema.");
}
if (config.jsonSchema == MetadataJsonSchema.detailedSchema) {
return {"bytes": BytesUtils.toHexString(value)};
Expand Down
10 changes: 5 additions & 5 deletions lib/ada/src/models/metadata/utils/metadata_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TransactionMetadataUtils {
static TransactionMetadata _parseDetailed(
dynamic value, MetadataJsonSchema jsonSchema) {
if (value is! Map<String, dynamic> || value.length != 1) {
throw MessageException(
throw const MessageException(
"DetailedSchema requires types to be tagged objects");
}
final entry = value.entries.first;
Expand All @@ -81,19 +81,19 @@ class TransactionMetadataUtils {
return _encodeArray(v, jsonSchema);
case "map":
if (v is! List) {
throw MessageException(
throw const MessageException(
r"entry format in detailed schema map object not correct. Needs to be of form '{'k': 'key', 'v': 'value'}'",
);
}
final Map<TransactionMetadata, TransactionMetadata> values = {};
for (final i in v) {
if (i is! Map) {
throw MessageException(
throw const MessageException(
r"entry format in detailed schema map object not correct. Needs to be of form '{'k': 'key', 'v': 'value'}'",
);
}
if (!i.containsKey("k") || !i.containsKey("v")) {
throw MessageException(
throw const MessageException(
r"entry format in detailed schema map object not correct. Needs to be of form '{'k': 'key', 'v': 'value'}'",
);
}
Expand Down Expand Up @@ -185,7 +185,7 @@ class TransactionMetadataUtils {
throw MessageException("Invalid metadata format. type not allowed.",
details: {"Value": val, "Type": "${val.runtimeType}"});
}
throw MessageException("null not allowed in metadata");
throw const MessageException("null not allowed in metadata");
}

static dynamic encodeKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConstrPlutusData extends PlutusData {
final BigInt? alternative =
PlutusDataUtils.cborTagToAlternative(cbor.tags.first);
if (alternative == null) {
throw MessageException("Invalid ConstrPlutusData tag.");
throw const MessageException("Invalid ConstrPlutusData tag.");
}
return ConstrPlutusData(
alternative: alternative,
Expand Down
16 changes: 8 additions & 8 deletions lib/ada/src/models/plutus/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PlutusDataUtils {
throw MessageException("Invalid plutus format. type not allowed.",
details: {"Value": val, "Type": "${val.runtimeType}"});
}
throw MessageException("null not allowed in plutus data");
throw const MessageException("null not allowed in plutus data");
}

static PlutusData _encodeMap(Map value, PlutusJsonSchema jsonSchema) {
Expand All @@ -144,7 +144,7 @@ class PlutusDataUtils {

static PlutusData _parseDetailed(dynamic value, PlutusJsonSchema schame) {
if (value is! Map<String, dynamic>) {
throw MessageException(
throw const MessageException(
"DetailedSchema requires types to be tagged objects");
}
if (value.length == 1) {
Expand All @@ -160,19 +160,19 @@ class PlutusDataUtils {
return _encodeString(schame: schame, value: v, isKey: false);
case "map":
if (v is! List) {
throw MessageException(
throw const MessageException(
r"entry format in detailed schema map object not correct. Needs to be of form '{'k': 'key', 'v': 'value'}'",
);
}
final Map<PlutusData, PlutusData> values = {};
for (final i in v) {
if (i is! Map) {
throw MessageException(
throw const MessageException(
r"entry format in detailed schema map object not correct. Needs to be of form '{'k': 'key', 'v': 'value'}'",
);
}
if (!i.containsKey("k") || !i.containsKey("v")) {
throw MessageException(
throw const MessageException(
r"entry format in detailed schema map object not correct. Needs to be of form '{'k': 'key', 'v': 'value'}'",
);
}
Expand All @@ -185,17 +185,17 @@ class PlutusDataUtils {
}
} else {
if (value.length != 2) {
throw MessageException(
throw const MessageException(
"detailed schemas must either have only one of the following keys: \"int\", \"bytes\", \"list\" or \"map\", or both of these 2 keys: \"constructor\" + \"fields\"");
}
final constructor = value["constructor"];
if (constructor is! int && constructor is! BigInt) {
throw MessageException(
throw const MessageException(
"tagged constructors must contain an unsigned integer called \"constructor\"");
}
final fileds = value["fields"];
if (fileds is! List) {
throw MessageException(
throw const MessageException(
"tagged constructors must contian a list called \"fields\"");
}
final List<PlutusData> plutusList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ class TransactionOutput with ADASerialization {
if (scriptRef != null ||
plutusData?.type == TransactionDataOptionType.data) {
return CborMapValue.fixedLength({
CborIntValue(0): address.toCbor(),
CborIntValue(1): amount.toCbor(),
if (plutusData != null) ...{CborIntValue(2): plutusData!.toCbor(false)},
const CborIntValue(0): address.toCbor(),
const CborIntValue(1): amount.toCbor(),
if (plutusData != null) ...{
const CborIntValue(2): plutusData!.toCbor(false)
},
if (scriptRef != null) ...{
CborIntValue(3): scriptRef!.toScriptRefCbor()
const CborIntValue(3): scriptRef!.toScriptRefCbor()
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ class AuxiliaryData with ADASerialization {
[]);
return CborTagValue(
CborMapValue.fixedLength({
if (metadata != null) ...{CborIntValue(0): metadata!.toCbor()},
if (metadata != null) ...{const CborIntValue(0): metadata!.toCbor()},
if (nativeScripts?.isNotEmpty ?? false) ...{
CborIntValue(1): CborListValue.fixedLength(
const CborIntValue(1): CborListValue.fixedLength(
nativeScripts!.map((e) => e.toCbor()).toList())
},
if (plutusScripts != null) ...{
CborIntValue(2): CborListValue.fixedLength(plutusScripts!
const CborIntValue(2): CborListValue.fixedLength(plutusScripts!
.where((element) => element.language == Language.plutusV1)
.map((e) => e.toCbor())
.toList())
},
if (plutusV2.value.isNotEmpty) ...{CborIntValue(3): plutusV2},
if (plutusV2.value.isNotEmpty) ...{const CborIntValue(3): plutusV2},
}),
TransactionMetadataUtils.auxiliaryDataCborTag);
}
Expand Down
26 changes: 13 additions & 13 deletions lib/ada/src/models/transaction/transaction/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,42 +142,42 @@ class TransactionBody with ADASerialization {
0: CborListValue.fixedLength(inputs.map((e) => e.toCbor()).toList()),
1: CborListValue.fixedLength(outputs.map((e) => e.toCbor()).toList()),
2: CborUnsignedValue.u64(fee),
if (ttl != null) ...{CborIntValue(3): CborUnsignedValue.u64(ttl!)},
if (ttl != null) ...{const CborIntValue(3): CborUnsignedValue.u64(ttl!)},
if (certs?.isNotEmpty ?? false) ...{
CborIntValue(4):
const CborIntValue(4):
CborListValue.fixedLength(certs!.map((e) => e.toCbor()).toList())
},
if (withdrawals != null) ...{
CborIntValue(5): withdrawals!.toCbor(),
const CborIntValue(5): withdrawals!.toCbor(),
},
if (update != null) ...{CborIntValue(6): update!.toCbor()},
if (update != null) ...{const CborIntValue(6): update!.toCbor()},
if (auxiliaryDataHash != null) ...{7: auxiliaryDataHash!.toCbor()},
if (validityStartInterval != null) ...{
CborIntValue(8): CborUnsignedValue.u64(validityStartInterval!)
const CborIntValue(8): CborUnsignedValue.u64(validityStartInterval!)
},
if (mint != null) ...{CborIntValue(9): mint!.toCbor()},
if (mint != null) ...{const CborIntValue(9): mint!.toCbor()},
if (scriptDataHash != null) ...{
CborIntValue(11): scriptDataHash!.toCbor()
const CborIntValue(11): scriptDataHash!.toCbor()
},
if (collateral?.isNotEmpty ?? false) ...{
CborIntValue(13): CborListValue.fixedLength(
const CborIntValue(13): CborListValue.fixedLength(
collateral!.map((e) => e.toCbor()).toList())
},
if (requiredSigners?.isNotEmpty ?? false) ...{
CborIntValue(14): CborListValue.fixedLength(
const CborIntValue(14): CborListValue.fixedLength(
requiredSigners!.map((e) => e.toCbor()).toList())
},
if (network != null) ...{
CborIntValue(15): CborIntValue(network!.value),
const CborIntValue(15): CborIntValue(network!.value),
},
if (collateralReturn != null) ...{
CborIntValue(16): collateralReturn!.toCbor()
const CborIntValue(16): collateralReturn!.toCbor()
},
if (totalCollateral != null) ...{
CborIntValue(17): CborUnsignedValue.u64(totalCollateral!),
const CborIntValue(17): CborUnsignedValue.u64(totalCollateral!),
},
if (referenceInputs?.isNotEmpty ?? false) ...{
CborIntValue(18): CborListValue.fixedLength(
const CborIntValue(18): CborListValue.fixedLength(
referenceInputs!.map((e) => e.toCbor()).toList())
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,27 @@ class TransactionWitnessSet with ADASerialization {
[];
return CborMapValue.fixedLength({
if (vKeys?.isNotEmpty ?? false) ...{
CborIntValue(0):
const CborIntValue(0):
CborListValue.fixedLength(vKeys!.map((e) => e.toCbor()).toList())
},
if (nativeScripts?.isNotEmpty ?? false) ...{
CborIntValue(1): CborListValue.fixedLength(
const CborIntValue(1): CborListValue.fixedLength(
nativeScripts!.map((e) => e.toCbor()).toList()),
},
if (bootstraps?.isNotEmpty ?? false) ...{
CborIntValue(2): CborListValue.fixedLength(
const CborIntValue(2): CborListValue.fixedLength(
bootstraps!.map((e) => e.toCbor()).toList()),
},
if (plutusScripts != null) ...{
CborIntValue(3): CborListValue.fixedLength(
const CborIntValue(3): CborListValue.fixedLength(
plutusVersion1.map((e) => e.toCbor()).toList()),
if (plutusVersion2.isNotEmpty)
CborIntValue(6): CborListValue.fixedLength(
const CborIntValue(6): CborListValue.fixedLength(
plutusVersion2.map((e) => e.toCbor()).toList()),
},
if (plutusData != null) ...{CborIntValue(4): plutusData!.toCbor()},
if (plutusData != null) ...{const CborIntValue(4): plutusData!.toCbor()},
if (redeemers?.isNotEmpty ?? false) ...{
CborIntValue(5): CborListValue.fixedLength(
const CborIntValue(5): CborListValue.fixedLength(
redeemers!.map((e) => e.toCbor()).toList()),
},
});
Expand Down
2 changes: 1 addition & 1 deletion lib/ada/src/models/update/models/nonce.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Nonce with ADASerialization {
factory Nonce.deserialize(CborListValue cbor) {
final int hasHash = cbor.getIndex(0);
if (hasHash != 0 && hasHash != 1) {
throw MessageException("Invalid Nonce cbor bytes.");
throw const MessageException("Invalid Nonce cbor bytes.");
}
return Nonce(hasHash == 0 ? null : cbor.getIndex(1));
}
Expand Down
Loading

0 comments on commit c1810fb

Please sign in to comment.