Skip to content

Commit

Permalink
v3.8.0
Browse files Browse the repository at this point in the history
- Update dependencies.
  • Loading branch information
mrtnetwork committed Aug 17, 2024
1 parent 25cdb79 commit 756817b
Show file tree
Hide file tree
Showing 64 changed files with 704 additions and 263 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.8.0

- Update dependencies.

## 3.7.0

- Update dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ void main() async {
final freezeAuthority = QuickWalletForTest(index: 1112);
final mintAccount = QuickWalletForTest(index: 1111);
final mintAccSpace = SolanaMintAccount.size;

final rent = await QuickWalletForTest.rpc
.request(SolanaRPCGetMinimumBalanceForRentExemption(size: mintAccSpace));
final createAccount = SystemProgram.createAccount(
Expand Down
21 changes: 20 additions & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
void main() async {}
void main() async {
// /// WebSocket RPC Service
// final websocketRpc = await RPCWebSocketService.connect(
// "wss://go.getblock.io/b9c91d92aaeb4e5ba2d4cca664ab708c", onEvents: (p0) {
// print("on event $p0");
// }, onClose: (p0) {});
// // Establish a WebSocket RPC connection to the specified endpoint for real-time updates.

// /// Ethereum RPC
// final rpc = EVMRPC(websocketRpc);

// final getblock = await rpc.request(RPCETHSubscribe());
// print("block $getblock");
// Timer.periodic(const Duration(seconds: 5), (s) async {
// // final re = await rpc.request(RPCETHSubscribe());
// // print("re $re");
// });
// print("get block $getblock");
// final changed = await Future.delayed(const Duration(seconds: 60));
}
3 changes: 2 additions & 1 deletion lib/ada/src/models/certificate/types/pool/pool_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class PoolParams with ADASerialization {
.toList(),
poolMetadata: cbor
.getIndex<CborListValue?>(8)
?.to<PoolMetadata, CborListValue>((e) => PoolMetadata.deserialize(e)),
?.castTo<PoolMetadata, CborListValue>(
(e) => PoolMetadata.deserialize(e)),
);
}
PoolParams copyWith({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class SingleHostAddr extends Relay {
port: cbor.getIndex<CborIntValue?>(1)?.value,
ipv4: cbor
.getIndex<CborBytesValue?>(2)
?.to<Ipv4, CborBytesValue>((e) => Ipv4.deserialize(e)),
?.castTo<Ipv4, CborBytesValue>((e) => Ipv4.deserialize(e)),
ipv6: cbor
.getIndex<CborBytesValue?>(3)
?.to<Ipv6, CborBytesValue>((e) => Ipv6.deserialize(e)),
?.castTo<Ipv6, CborBytesValue>((e) => Ipv6.deserialize(e)),
);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/ada/src/models/header/header/header_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class HeaderBody with ADASerialization {
cbor.sublist(operationIndex, operationIndex + 4)),
prevHash: cbor
.getIndex<CborObject?>(2)
?.to<BlockHash, CborBytesValue>((e) => BlockHash.deserialize(e)),
?.castTo<BlockHash, CborBytesValue>(
(e) => BlockHash.deserialize(e)),
protocolVersion:
ProtocolVersion.deserialize(cbor.sublist(protocolVersionIndex)),
vrfvKey: VRFVKey.deserialize(cbor.getIndex(4)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ class TransactionOutput with ADASerialization {
amount: Value.deserialize(cbor.getIndex<CborObject>(1)),
plutusData: cbor
.getIndex<CborObject?>(2)
?.to<DataOption, CborObject>((e) => DataOption.deserialize(e)),
?.castTo<DataOption, CborObject>(
(e) => DataOption.deserialize(e)),
scriptRef: cbor
.getIndex<CborObject?>(3)
?.to<ScriptRef, CborListValue>((e) => ScriptRef.deserialize(e)));
?.castTo<ScriptRef, CborListValue>(
(e) => ScriptRef.deserialize(e)));
}
final CborMapValue<CborObject, CborObject> cborMap = cbor.cast();
final address =
Expand All @@ -62,10 +64,10 @@ class TransactionOutput with ADASerialization {
amount: Value.deserialize(cborMap.getValueFromIntKey(1)),
plutusData: cborMap
.getValueFromIntKey<CborObject?>(2)
?.to<DataOption, CborObject>((e) => DataOption.deserialize(e)),
?.castTo<DataOption, CborObject>((e) => DataOption.deserialize(e)),
scriptRef: cborMap
.getValueFromIntKey<CborTagValue?>(3)
?.to<ScriptRef, CborTagValue>((e) => ScriptRef.deserialize(e)));
?.castTo<ScriptRef, CborTagValue>((e) => ScriptRef.deserialize(e)));
}
TransactionOutput copyWith({
ADAAddress? address,
Expand Down
12 changes: 6 additions & 6 deletions lib/ada/src/models/transaction/transaction/auxiliary_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class AuxiliaryData with ADASerialization {
return AuxiliaryData(
metadata: cbor
.getIndex<CborObject?>(0)
?.to<GeneralTransactionMetadata, CborMapValue>(
?.castTo<GeneralTransactionMetadata, CborMapValue>(
(e) => GeneralTransactionMetadata.deserialize(e)),
nativeScripts: cbor
.getIndex<CborObject?>(1)
?.to<List<NativeScript>, CborListValue>((e) =>
?.castTo<List<NativeScript>, CborListValue>((e) =>
e.value.map((i) => NativeScript.deserialize(i)).toList()),
);
} else {
Expand All @@ -51,19 +51,19 @@ class AuxiliaryData with ADASerialization {
preferAlonzoFormat: true,
metadata: cobrList
.getValueFromIntKey<CborObject?>(0)
?.to<GeneralTransactionMetadata, CborMapValue>(
?.castTo<GeneralTransactionMetadata, CborMapValue>(
(e) => GeneralTransactionMetadata.deserialize(e)),
nativeScripts: cobrList
.getValueFromIntKey<CborObject?>(1)
?.to<List<NativeScript>, CborListValue>((e) =>
?.castTo<List<NativeScript>, CborListValue>((e) =>
e.value.map((i) => NativeScript.deserialize(i)).toList()),
plutusScripts: cobrList
.getValueFromIntKey<CborObject?>(2)
?.to<List<PlutusScript>, CborListValue>((e) {
?.castTo<List<PlutusScript>, CborListValue>((e) {
final v1 = e.value.map((i) => PlutusScript.deserialize(i)).toList();
final v2 = cobrList
.getValueFromIntKey<CborObject?>(3)
?.to<List<PlutusScript>, CborListValue>((e) {
?.castTo<List<PlutusScript>, CborListValue>((e) {
return e.value
.map((i) =>
PlutusScript.deserialize(i, language: Language.plutusV2))
Expand Down
27 changes: 13 additions & 14 deletions lib/ada/src/models/transaction/transaction/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,28 @@ class TransactionBody with ADASerialization {
ttl: cbor.getValueFromIntKey<CborObject?>(3)?.getInteger(),
withdrawals: cbor
.getValueFromIntKey<CborObject?>(5)
?.to<Withdrawals, CborMapValue>((e) => Withdrawals.deserialize(e)),
?.castTo<Withdrawals, CborMapValue>(
(e) => Withdrawals.deserialize(e)),
auxiliaryDataHash: cbor
.getValueFromIntKey<CborObject?>(7)
?.to<AuxiliaryDataHash, CborBytesValue>(
?.castTo<AuxiliaryDataHash, CborBytesValue>(
(CborBytesValue e) => AuxiliaryDataHash.deserialize(e)),
certs: cbor
.getValueFromIntKey<CborObject?>(4)
?.to<List<Certificate>, CborListValue<CborObject>>(
(CborListValue<CborObject> e) => e.value
.map((e) => Certificate.deserialize(e.cast()))
.toList()),
?.castTo<List<Certificate>, CborListValue<CborObject>>((CborListValue<CborObject> e) =>
e.value.map((e) => Certificate.deserialize(e.cast())).toList()),
update: cbor
.getValueFromIntKey<CborListValue?>(6)
?.to<Update, CborListValue>((e) => Update.deserialize(e)),
?.castTo<Update, CborListValue>((e) => Update.deserialize(e)),
validityStartInterval: cbor.getValueFromIntKey<CborObject?>(8)?.getInteger(),
mint: cbor.getValueFromIntKey<CborMapValue?>(9)?.to<Mint, CborMapValue>((e) => Mint.deserialize(e.cast())),
scriptDataHash: cbor.getValueFromIntKey<CborBytesValue?>(11)?.to<ScriptDataHash, CborBytesValue>((e) => ScriptDataHash.deserialize(e)),
collateral: cbor.getValueFromIntKey<CborListValue?>(13)?.to<List<TransactionInput>, CborListValue<CborObject>>((e) => e.value.map((e) => TransactionInput.deserialize(e.cast())).toList()),
requiredSigners: cbor.getValueFromIntKey<CborListValue?>(14)?.to<List<Ed25519KeyHash>, CborListValue<CborObject>>((e) => e.value.map((e) => Ed25519KeyHash.deserialize(e.cast())).toList()),
network: cbor.getValueFromIntKey<CborIntValue?>(15)?.to<ADANetwork, CborIntValue>((e) => ADANetwork.fromTag(e.value)),
collateralReturn: cbor.getValueFromIntKey<CborObject?>(16)?.to<TransactionOutput, CborObject>((e) => TransactionOutput.deserialize(e)),
mint: cbor.getValueFromIntKey<CborMapValue?>(9)?.castTo<Mint, CborMapValue>((e) => Mint.deserialize(e.cast())),
scriptDataHash: cbor.getValueFromIntKey<CborBytesValue?>(11)?.castTo<ScriptDataHash, CborBytesValue>((e) => ScriptDataHash.deserialize(e)),
collateral: cbor.getValueFromIntKey<CborListValue?>(13)?.castTo<List<TransactionInput>, CborListValue<CborObject>>((e) => e.value.map((e) => TransactionInput.deserialize(e.cast())).toList()),
requiredSigners: cbor.getValueFromIntKey<CborListValue?>(14)?.castTo<List<Ed25519KeyHash>, CborListValue<CborObject>>((e) => e.value.map((e) => Ed25519KeyHash.deserialize(e.cast())).toList()),
network: cbor.getValueFromIntKey<CborIntValue?>(15)?.castTo<ADANetwork, CborIntValue>((e) => ADANetwork.fromTag(e.value)),
collateralReturn: cbor.getValueFromIntKey<CborObject?>(16)?.castTo<TransactionOutput, CborObject>((e) => TransactionOutput.deserialize(e)),
totalCollateral: cbor.getValueFromIntKey<CborObject?>(17)?.getInteger(),
referenceInputs: cbor.getValueFromIntKey<CborListValue?>(18)?.to<List<TransactionInput>, CborListValue<CborObject>>((e) => e.value.map((e) => TransactionInput.deserialize(e.cast())).toList()));
referenceInputs: cbor.getValueFromIntKey<CborListValue?>(18)?.castTo<List<TransactionInput>, CborListValue<CborObject>>((e) => e.value.map((e) => TransactionInput.deserialize(e.cast())).toList()));
}
TransactionBody copyWith({
List<TransactionInput>? inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ADATransaction with ADASerialization {
body: TransactionBody.deserialize(cbor.getIndex(0)),
witnessSet: TransactionWitnessSet.deserialize(cbor.getIndex(1)),
isValid: cbor.getIndex(2),
data: cbor.getIndex<CborObject?>(3)?.to<AuxiliaryData, CborObject>(
data: cbor.getIndex<CborObject?>(3)?.castTo<AuxiliaryData, CborObject>(
(e) => AuxiliaryData.deserialize(e)));
}
factory ADATransaction.fromJson(Map<String, dynamic> json) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class TransactionWitnessSet with ADASerialization {
factory TransactionWitnessSet.deserialize(CborMapValue cbor) {
final v1 = cbor
.getValueFromIntKey<CborListValue?>(3)
?.to<List<PlutusScript>, CborListValue<CborObject>>((e) {
?.castTo<List<PlutusScript>, CborListValue<CborObject>>((e) {
return e.value.map((i) => PlutusScript.deserialize(i.cast())).toList();
});
final v2 = cbor
.getValueFromIntKey<CborListValue?>(6)
?.to<List<PlutusScript>, CborListValue<CborObject>>((e) => e.value
?.castTo<List<PlutusScript>, CborListValue<CborObject>>((e) => e.value
.map((i) =>
PlutusScript.deserialize(i.cast(), language: Language.plutusV2))
.toList());
Expand All @@ -53,23 +53,21 @@ class TransactionWitnessSet with ADASerialization {
?.value
.map((e) => Vkeywitness.deserialize(e))
.toList(),
nativeScripts: cbor
.getValueFromIntKey<CborListValue?>(1)
?.to<List<NativeScript>, CborListValue<CborObject>>((e) => e.value
.map((e) => NativeScript.deserialize(e.cast()))
.toList()),
nativeScripts: cbor.getValueFromIntKey<CborListValue?>(1)?.castTo<List<NativeScript>, CborListValue<CborObject>>((e) =>
e.value.map((e) => NativeScript.deserialize(e.cast())).toList()),
bootstraps: cbor
.getValueFromIntKey<CborListValue?>(2)
?.to<List<BootstrapWitness>, CborListValue<CborObject>>((e) => e.value
?.castTo<List<BootstrapWitness>, CborListValue<CborObject>>((e) => e.value
.map((e) => BootstrapWitness.deserialize(e.cast()))
.toList()),
plutusScripts:
v1 == null && v2 == null ? null : [...v1 ?? [], ...v2 ?? []],
plutusData: cbor
.getValueFromIntKey<CborListValue?>(4)
?.to<PlutusList, CborListValue>((e) => PlutusList.deserialize(e)),
redeemers: cbor.getValueFromIntKey<CborListValue?>(5)?.to<List<Redeemer>, CborListValue<CborObject>>(
(e) => e.value.map((i) => Redeemer.deserialize(i.cast())).toList()));
plutusData: cbor.getValueFromIntKey<CborListValue?>(4)?.castTo<PlutusList, CborListValue>(
(e) => PlutusList.deserialize(e)),
redeemers: cbor
.getValueFromIntKey<CborListValue?>(5)
?.castTo<List<Redeemer>, CborListValue<CborObject>>(
(e) => e.value.map((i) => Redeemer.deserialize(i.cast())).toList()));
}
TransactionWitnessSet copyWith({
List<Vkeywitness>? vKeys,
Expand Down
20 changes: 10 additions & 10 deletions lib/ada/src/models/update/models/protocol_param_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,28 @@ class ProtocolParamUpdate with ADASerialization {
nOpt: cbor.getValueFromIntKey<CborIntValue?>(8)?.value,
poolPledgeInfluence: cbor
.getValueFromIntKey<CborTagValue?>(9)
?.to<UnitInterval, CborTagValue>(
?.castTo<UnitInterval, CborTagValue>(
(e) => UnitInterval.deserialize(e)),
expansionRate: cbor.getValueFromIntKey<CborTagValue?>(10)?.to<UnitInterval, CborTagValue>(
expansionRate: cbor.getValueFromIntKey<CborTagValue?>(10)?.castTo<UnitInterval, CborTagValue>(
(e) => UnitInterval.deserialize(e)),
treasuryGrowthRate: cbor
.getValueFromIntKey<CborTagValue?>(11)
?.to<UnitInterval, CborTagValue>(
?.castTo<UnitInterval, CborTagValue>(
(e) => UnitInterval.deserialize(e)),
d: cbor.getValueFromIntKey<CborTagValue?>(12)?.to<UnitInterval, CborTagValue>(
d: cbor.getValueFromIntKey<CborTagValue?>(12)?.castTo<UnitInterval, CborTagValue>(
(e) => UnitInterval.deserialize(e)),
extraEntropy: cbor
.getValueFromIntKey<CborListValue?>(13)
?.to<Nonce, CborListValue>((e) => Nonce.deserialize(e)),
?.castTo<Nonce, CborListValue>((e) => Nonce.deserialize(e)),
protocolVersion: cbor
.getValueFromIntKey<CborListValue?>(14)
?.to<ProtocolVersion, CborListValue>((e) => ProtocolVersion.deserialize(e)),
?.castTo<ProtocolVersion, CborListValue>((e) => ProtocolVersion.deserialize(e)),
minPoolCost: cbor.getValueFromIntKey<CborObject?>(16)?.getInteger(),
adaPerUtxoByte: cbor.getValueFromIntKey<CborObject?>(17)?.getInteger(),
costModel: cbor.getValueFromIntKey<CborMapValue?>(18)?.to<Costmdls, CborMapValue>((e) => Costmdls.deserialize(e)),
executionCosts: cbor.getValueFromIntKey<CborListValue?>(19)?.to<ExUnitPrices, CborListValue>((e) => ExUnitPrices.deserialize(e)),
maxTxExUnits: cbor.getValueFromIntKey<CborListValue?>(20)?.to<ExUnits, CborListValue>((e) => ExUnits.deserialize(e)),
maxBlockExUnits: cbor.getValueFromIntKey<CborListValue?>(21)?.to<ExUnits, CborListValue>((e) => ExUnits.deserialize(e)),
costModel: cbor.getValueFromIntKey<CborMapValue?>(18)?.castTo<Costmdls, CborMapValue>((e) => Costmdls.deserialize(e)),
executionCosts: cbor.getValueFromIntKey<CborListValue?>(19)?.castTo<ExUnitPrices, CborListValue>((e) => ExUnitPrices.deserialize(e)),
maxTxExUnits: cbor.getValueFromIntKey<CborListValue?>(20)?.castTo<ExUnits, CborListValue>((e) => ExUnits.deserialize(e)),
maxBlockExUnits: cbor.getValueFromIntKey<CborListValue?>(21)?.castTo<ExUnits, CborListValue>((e) => ExUnits.deserialize(e)),
maxValueSize: cbor.getValueFromIntKey<CborIntValue?>(22)?.value,
collateralPercentage: cbor.getValueFromIntKey<CborIntValue?>(23)?.value,
maxCollateralInputs: cbor.getValueFromIntKey<CborIntValue?>(24)?.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class BlockfrostRequestBlockchainGenesis extends BlockforestRequestParam<

@override
ADAGenesisParametersResponse onResonse(Map<String, dynamic> result) {
print("result $result");
return ADAGenesisParametersResponse.fromJson(result);
}
}
12 changes: 12 additions & 0 deletions lib/ada/src/provider/exception/blockfrost_api_error.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import 'package:blockchain_utils/exception/exceptions.dart';

/// https://blockfrost.dev/api/blockfrost-io-api-documentation
class BlockfrostStatusCode {
static const int invalidRequest = 400;
static const int exceedRequestLimit = 402;
static const int inValidAuthenticated = 403;
static const int resourceDoesNotExist = 404;
static const int rateLimit = 429;
static const int bannedToMuchRequest = 418;
}

class BlockfrostError implements BlockchainUtilsException {
@override
final String message;
Expand All @@ -18,3 +28,5 @@ class BlockfrostError implements BlockchainUtilsException {
return "Error: $error, Message: $message, StatusCode: $statusCode";
}
}
// HTTP 418 return code is used when the user has been auto-banned for flooding too much after previously receiving error code 402 or 429.
// HTTP 500 return code is used when our endpoints are having a problem.
2 changes: 1 addition & 1 deletion lib/ada/src/serialization/cbor/cbor_serialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extension QuickCborObject on CborObject {
/// Converts the value of the [CborObject] to the specified type [E] using the provided function [toe].
///
/// Throws a [MessageException] if the value cannot be converted to type [T].
E to<E, T>(E Function(T e) toe) {
E castTo<E, T>(E Function(T e) toe) {
if (this is T) {
return toe(this as T);
}
Expand Down
27 changes: 18 additions & 9 deletions lib/ethereum/src/address/evm_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import 'package:on_chain/solidity/address/core.dart';
import 'package:blockchain_utils/bip/address/eth_addr.dart';
import 'package:blockchain_utils/blockchain_utils.dart';

/// Class representing an Ethereum address, implementing the [BaseHexAddress] interface.
/// Class representing an Ethereum address, implementing the [SolidityAddress] interface.
class ETHAddress implements SolidityAddress {
/// Private constructor for creating an instance of [ETHAddress] with a given Ethereum address
const ETHAddress._(this.address);

/// The Ethereum address string.
final String address;

/// Private constructor for creating an instance of [ETHAddress] with a given Ethereum address
const ETHAddress._(this.address);

/// Creates an [ETHAddress] instance from a public key represented as a bytes.
factory ETHAddress.fromPublicKey(List<int> keyBytes) {
try {
Expand Down Expand Up @@ -45,16 +45,25 @@ class ETHAddress implements SolidityAddress {
return BytesUtils.fromHexString(address);
}

@override
String toString() {
return address;
}

/// Constant representing the length of the ETH address in bytes
static const int lengthInBytes = 20;

@override
String toHex() {
return address;
}

@override
String toString() {
return address;
}

@override
operator ==(other) {
if (other is! ETHAddress) return false;
return address == other.address;
}

@override
int get hashCode => address.hashCode;
}
7 changes: 2 additions & 5 deletions lib/ethereum/src/rpc/core/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ abstract class ETHRequestParams {

/// Represents the details of an Ethereum JSON-RPC request.
class ETHRequestDetails {
const ETHRequestDetails({
required this.id,
required this.method,
required this.params,
});
const ETHRequestDetails(
{required this.id, required this.method, required this.params});

/// The unique identifier for the JSON-RPC request.
final int id;
Expand Down
Loading

0 comments on commit 756817b

Please sign in to comment.