Skip to content

Commit

Permalink
v4.3.0
Browse files Browse the repository at this point in the history
Update dependencies.
  • Loading branch information
mrtnetwork committed Oct 1, 2024
1 parent 2245d38 commit c0d40c6
Show file tree
Hide file tree
Showing 61 changed files with 245 additions and 230 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.3.0

- Update dependencies.

## 4.2.0

- Fixed Solana simulate transaction model
Expand Down
10 changes: 8 additions & 2 deletions example/lib/example/contract/call_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ void main() async {
params: [],
));
} on RPCError catch (e) {
final revertErrors = contract.decodeError(e.data);
final data = e.details?["data"];
if (data != null) {
final revertErrors = contract.decodeError(data);
}
}

// Another RPC call expected to raise an error, catch the error and decode it
Expand All @@ -114,7 +117,10 @@ void main() async {
],
));
} on RPCError catch (e) {
final revertErrors = contract.decodeError(e.data);
final data = e.details?["data"];
if (data != null) {
final revertErrors = contract.decodeError(data);
}
}

// Retrieve the function information for a specific function name
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: ^3.3.0
blockchain_utils: ^3.4.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
1 change: 1 addition & 0 deletions lib/ada/src/ada.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export 'provider/provider.dart';
export 'serialization/cbor_serialization.dart';
export 'utils/ada_helper.dart';
export 'builder/builder.dart';
export 'exception/exception.dart';
5 changes: 3 additions & 2 deletions lib/ada/src/address/era/core/address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/address/era/byron/byron.dart';
import 'package:on_chain/ada/src/address/era/shelly/shelly.dart';
import 'package:on_chain/ada/src/address/utils/utils.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

/// Represents an abstract class for ADA addresses with serialization capabilities.
Expand Down Expand Up @@ -47,7 +48,7 @@ abstract class ADAAddress with ADASerialization {
break;
}
if (addr is! T) {
throw MessageException("Invalid address type.", details: {
throw ADAPluginException("Invalid address type.", details: {
"Excepted": "$T",
"Type": addr.runtimeType,
"address": addr.address
Expand All @@ -73,7 +74,7 @@ abstract class ADAAddress with ADASerialization {
}

if (address is! T) {
throw MessageException("Invalid ADA address type.", details: {
throw ADAPluginException("Invalid ADA address type.", details: {
"Excepted": "$T",
"Type": address.addressType,
"address": address.address
Expand Down
5 changes: 3 additions & 2 deletions lib/ada/src/address/era/shelly/core/shelly_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/address/era/core/address.dart';
import 'package:on_chain/ada/src/address/era/shelly/shelly.dart';
import 'package:on_chain/ada/src/address/utils/utils.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';
import 'package:on_chain/ada/src/models/credential/core/stake_cred.dart';

Expand Down Expand Up @@ -30,7 +31,7 @@ abstract class ADAShellyAddress extends ADAAddress {
case ADAAddressType.enterprise:
return ADAEnterpriseAddress(address, network: network);
default:
throw const MessageException(
throw const ADAPluginException(
"Invalid shelly address. for byron address please use ByronAddress.");
}
}
Expand All @@ -44,7 +45,7 @@ abstract class ADAShellyAddress extends ADAAddress {
static T deserialize<T extends ADAShellyAddress>(CborBytesValue cbor) {
ADAAddress address = ADAAddress.deserialize(cbor);
if (address is! T) {
throw MessageException("Invalid address type.", details: {
throw ADAPluginException("Invalid address type.", details: {
"Excepted": "$T",
"Type": address.runtimeType,
"address": address.address
Expand Down
5 changes: 3 additions & 2 deletions lib/ada/src/address/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:blockchain_utils/bip/address/ada/ada.dart';
import 'package:blockchain_utils/bip/address/addr_key_validator.dart';
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/address/era/core/address.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/models/credential/core/stake_cred.dart';
import 'package:on_chain/ada/src/models/credential/core/stake_cred_type.dart';
import 'package:on_chain/ada/src/models/credential/key.dart';
Expand All @@ -23,7 +24,7 @@ class AdaAddressUtils {
AdaGenericAddrDecoder().decode(address, {"net_tag": network});
if (addrType != null) {
if (decodeAddr.type.header != addrType.header) {
throw MessageException("Incorrect address type. ",
throw ADAPluginException("Incorrect address type. ",
details: {"Excepted": addrType.name, "type": decodeAddr.type});
}
}
Expand Down Expand Up @@ -59,7 +60,7 @@ class AdaAddressUtils {
final decode =
AdaGenericAddrDecoder().decode(address, {"net_tag": network});
if (decode.type == ADAAddressType.byron) {
throw MessageException("Invalid shelly address.",
throw ADAPluginException("Invalid shelly address.",
details: {"address": address, "type": decode.type});
}
if (keepPrefix) {
Expand Down
12 changes: 7 additions & 5 deletions lib/ada/src/builder/builder/transaction_builder.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/address/address.dart';
import 'package:on_chain/ada/src/builder/builder/tranasction_builder_utils.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/models/ada_models.dart';
import 'package:on_chain/ada/src/provider/provider.dart';
import 'certificate_builder.dart';
Expand Down Expand Up @@ -77,7 +78,7 @@ class ADATransactionBuilder {
final multiAsset = utxos.multiAsset;
final asset = multiAsset - _outputs.multiAsset;
if (lovelence.isNegative) {
throw MessageException("Insufficient input in transaction.", details: {
throw ADAPluginException("Insufficient input in transaction.", details: {
"utxo lovelence": utxos.sumOflovelace,
"output lovelence": _outputs.sumOflovelace
});
Expand All @@ -94,7 +95,8 @@ class ADATransactionBuilder {

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

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

TransactionBody buildTxBody({AuxiliaryDataHash? auxHash}) {
if (fee == null) {
throw const MessageException(
throw const ADAPluginException(
"cannot build transaction body before calculation fee.");
}
final mint = getMint();
Expand Down Expand Up @@ -229,7 +231,7 @@ class ADATransactionBuilder {
final asset = utxos.multiAsset - outputs.multiAsset;

if (lovelence != BigInt.zero || asset != MultiAsset.empty) {
throw MessageException(
throw ADAPluginException(
"The amount of inputs and outputs is not calculated correctly",
details: {"lovelence": lovelence, "asset": asset});
}
Expand Down
6 changes: 6 additions & 0 deletions lib/ada/src/exception/exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import 'package:blockchain_utils/exception/exceptions.dart';

class ADAPluginException extends BlockchainUtilsException {
const ADAPluginException(String message, {Map<String, dynamic>? details})
: super(message, details: details);
}
3 changes: 2 additions & 1 deletion lib/ada/src/keypair/keypair/private_key.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/address/era/byron/byron.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/models/fixed_bytes/models/models.dart';
import 'package:on_chain/ada/src/models/transaction/witnesses/bootstrap_witness.dart';
import 'package:on_chain/ada/src/models/transaction/witnesses/vkey_witness.dart';
Expand All @@ -18,7 +19,7 @@ class AdaPrivateKey {
factory AdaPrivateKey.fromBytes(List<int> privateKeyBytes) {
if (privateKeyBytes.length != Ed25519KeysConst.privKeyByteLen &&
privateKeyBytes.length != Ed25519KholawKeysConst.privKeyByteLen) {
throw MessageException("Invalid private key bytes.", details: {
throw ADAPluginException("Invalid private key bytes.", details: {
"length": privateKeyBytes.length,
"Excepted":
"${Ed25519KeysConst.privKeyByteLen} or ${Ed25519KholawKeysConst.privKeyByteLen}"
Expand Down
3 changes: 2 additions & 1 deletion lib/ada/src/models/certificate/core/certificate.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/models/certificate/certs.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

Expand Down Expand Up @@ -37,7 +38,7 @@ abstract class Certificate with ADASerialization {
try {
type = CertificateType.fromName(json.keys.first);
} on StateError {
throw MessageException("Invalid json certificate.",
throw ADAPluginException("Invalid json certificate.",
details: {"json": json});
}
switch (type) {
Expand Down
9 changes: 5 additions & 4 deletions lib/ada/src/models/certificate/core/types.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:blockchain_utils/cbor/cbor.dart';
import 'package:blockchain_utils/exception/exception.dart';

import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

/// Represents the type of a certificate.
Expand Down Expand Up @@ -57,7 +58,7 @@ class CertificateType with ADASerialization {
{CertificateType? validate}) {
final type = fromValue(cbor.value);
if (validate != null && type != validate) {
throw MessageException("Invalid Certificate type.",
throw ADAPluginException("Invalid Certificate type.",
details: {"Excepted": validate, "Type": type});
}
return type;
Expand All @@ -67,7 +68,7 @@ class CertificateType with ADASerialization {
static CertificateType fromValue(int? value) {
return values.firstWhere(
(element) => element.value == value,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No CertificateType found matching the specified value",
details: {"value": value}),
);
Expand All @@ -77,7 +78,7 @@ class CertificateType with ADASerialization {
static CertificateType fromName(String? name) {
return values.firstWhere(
(element) => element.name == name,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No CertificateType found matching the specified name",
details: {"name": name}),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';
import 'package:on_chain/ada/src/models/certificate/types/move_instantaneous_reward/types/to_other_pot.dart';
import 'package:on_chain/ada/src/models/certificate/types/move_instantaneous_reward/types/to_stake_credentials.dart';
Expand All @@ -21,7 +22,7 @@ abstract class MIR with ADASerialization {
}
factory MIR.fromJson(dynamic json) {
if (json is! Map && json is! String) {
throw MessageException("Invalid MIR json. value must be string or map",
throw ADAPluginException("Invalid MIR json. value must be string or map",
details: {"json": json});
}
if (json is String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:blockchain_utils/cbor/cbor.dart';
import 'package:blockchain_utils/exception/exceptions.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

/// Represents a pot for Move instance reward.
Expand Down Expand Up @@ -31,7 +31,7 @@ class MIRPot with ADASerialization {
static MIRPot fromValue(int? value) {
return values.firstWhere(
(element) => element.value == value,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No MIRPot found matching the specified value",
details: {"value": value}),
);
Expand All @@ -41,7 +41,7 @@ class MIRPot with ADASerialization {
static MIRPot fromName(String? name) {
return values.firstWhere(
(element) => element.name == name,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No MIRPot found matching the specified name",
details: {"name": name}),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';
import 'package:on_chain/ada/src/models/certificate/types/pool/relay/core/relay_type.dart';
import 'package:on_chain/ada/src/models/certificate/types/pool/relay/relays/multi_host_name.dart';
Expand Down Expand Up @@ -30,7 +31,7 @@ abstract class Relay with ADASerialization {
try {
type = RelayType.fromName(json.keys.first);
} on StateError {
throw MessageException("Invalid Relay json.", details: {"json": json});
throw ADAPluginException("Invalid Relay json.", details: {"json": json});
}
switch (type) {
case RelayType.multiHostName:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:blockchain_utils/cbor/cbor.dart';
import 'package:blockchain_utils/exception/exceptions.dart';
import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

/// Enum representing the type of relay.
Expand Down Expand Up @@ -33,7 +33,7 @@ class RelayType with ADASerialization {
factory RelayType.deserialize(CborIntValue cbor, {RelayType? validate}) {
final type = fromValue(cbor.value);
if (validate != null && type != validate) {
throw MessageException("Invalid RelayType.",
throw ADAPluginException("Invalid RelayType.",
details: {"Expected": validate, "Type": type});
}
return fromValue(cbor.value);
Expand All @@ -43,7 +43,7 @@ class RelayType with ADASerialization {
static RelayType fromValue(int? value) {
return values.firstWhere(
(element) => element.value == value,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No RelayType found matching the specified value",
details: {"value": value}),
);
Expand All @@ -53,7 +53,7 @@ class RelayType with ADASerialization {
static RelayType fromName(String? name) {
return values.firstWhere(
(element) => element.name == name,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No RelayType found matching the specified name",
details: {"name": name}),
);
Expand Down
7 changes: 4 additions & 3 deletions lib/ada/src/models/credential/core/stake_cred_type.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:blockchain_utils/cbor/cbor.dart';
import 'package:blockchain_utils/exception/exception.dart';

import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

/// Represents the type of a stake credential.
Expand Down Expand Up @@ -31,7 +32,7 @@ class StakeCredType with ADASerialization {
static StakeCredType fromValue(int? value) {
return values.firstWhere(
(element) => element.value == value,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No StakeCredType found matching the specified value",
details: {"value": value}),
);
Expand All @@ -41,7 +42,7 @@ class StakeCredType with ADASerialization {
static StakeCredType fromName(String? name) {
return values.firstWhere(
(element) => element.name == name,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No StakeCredType found matching the specified name",
details: {"name": name}),
);
Expand Down
7 changes: 4 additions & 3 deletions lib/ada/src/models/data_options/core/data_option_type.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:blockchain_utils/cbor/cbor.dart';
import 'package:blockchain_utils/exception/exception.dart';

import 'package:on_chain/ada/src/exception/exception.dart';
import 'package:on_chain/ada/src/serialization/cbor_serialization.dart';

/// Represents the type of data included in a transaction option with serialization support.
Expand Down Expand Up @@ -39,7 +40,7 @@ class TransactionDataOptionType with ADASerialization {
{TransactionDataOptionType? validate}) {
final type = fromValue(cbor.value);
if (validate != null && validate != type) {
throw MessageException("Invalid TransactionDataOptionType.",
throw ADAPluginException("Invalid TransactionDataOptionType.",
details: {"Excepted": validate, "Type": type});
}
return type;
Expand All @@ -49,7 +50,7 @@ class TransactionDataOptionType with ADASerialization {
static TransactionDataOptionType fromValue(int? value) {
return values.firstWhere(
(element) => element.value == value,
orElse: () => throw MessageException(
orElse: () => throw ADAPluginException(
"No TransactionDataOptionType found matching the specified value",
details: {"value": value}),
);
Expand Down
Loading

0 comments on commit c0d40c6

Please sign in to comment.