Skip to content

Commit

Permalink
V5.0.0
Browse files Browse the repository at this point in the history
- Minimum required Dart SDK version updated to 3.3.
- The RPC method names and service class implementations have been updated. Please refer to the examples folder for guidance.
- Update dependencies.
  • Loading branch information
mrtnetwork committed Jan 2, 2025
1 parent 0384879 commit f82665a
Show file tree
Hide file tree
Showing 1,503 changed files with 14,241 additions and 14,111 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 5.0.0

- Minimum required Dart SDK version updated to 3.3.
- The RPC method names and service class implementations have been updated. Please refer to the examples folder for guidance.
- Update dependencies.

## 4.5.0

- Update dependencies.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Here are some examples:
"wss://polygon-mumbai-bor.publicnode.com");
/// Create an Ethereum RPC instance
final rpc = EVMRPC(wsocketService);
final rpc = EthereumProvider(wsocketService);
/// Define a seed for generating a private key
final seed = BytesUtils.fromHexString(
Expand Down Expand Up @@ -312,7 +312,7 @@ Here are some examples:
/// For Tron: If the output parameters include an address, set isTron to true.
/// If it doesn't, set isTron to false to receive an ETH address instead of a Tron address.
final contract = ContractABI.fromJson(tronContract["entrys"]!, isTron: true);
final rpc = EVMRPC(RPCHttpService("https://api.shasta.trongrid.io/jsonrpc"));
final rpc = EthereumProvider(RPCHttpService("https://api.shasta.trongrid.io/jsonrpc"));
final call1 = await rpc.request(RPCCall.fromMethod(
contractAddress:
Expand Down Expand Up @@ -466,7 +466,7 @@ Here are some examples:
final service = RPCHttpService("https://api.devnet.solana.com");
/// Initialize the Solana RPC client.
final rpc = SolanaRPC(service);
final rpc = SolanaProvider(service);
/// Define the owner's private key and derive the owner's public key.
final ownerPrivateKey = SolanaPrivateKey.fromSeedHex(
Expand Down Expand Up @@ -532,7 +532,7 @@ Here are some examples:
network: ADANetwork.testnetPreprod);
/// Set up the Blockfrost provider
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
Expand Down Expand Up @@ -689,7 +689,7 @@ Example:
// Establish a WebSocket RPC connection to the specified endpoint for real-time updates.
/// Ethereum RPC
final rpc = EVMRPC(httpRpc);
final rpc = EthereumProvider(httpRpc);
// Create an Ethereum RPC instance using the HTTP RPC service.
/// Get Balance
Expand Down Expand Up @@ -748,7 +748,7 @@ Example:
```dart
/// Initialize the Solana RPC client with the devnet endpoint.
final service = SolanaRPC(RPCHttpService("https://api.devnet.solana.com"));
final service = SolanaProvider(RPCHttpService("https://api.devnet.solana.com"));
/// Retrieve the account information for a specific address.
final accountModel = await service.request(const SolanaRPCGetAccountInfo(
Expand All @@ -774,7 +774,7 @@ Example:
```dart
/// Set up the Blockfrost provider with the specified URL and project ID
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
Expand Down
76 changes: 68 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,69 @@
# include: package:lints/recommended.yaml
include: package:flutter_lints/flutter.yaml
# Uncomment the following section to specify additional rules.
# 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:lint/casual.yaml # For code samples, hackathons and other non-production code
# include: package:lint/package.yaml # Use this for packages with public API


# You might want to exclude auto-generated files from dart analysis
analyzer:
exclude:
#- '**.freezed.dart'
#- '**.g.dart'

# You can customize the lint rules set to your own liking. A list of all rules
# can be found at https://dart-lang.github.io/linter/lints/options/options.html
linter:
rules:
prefer_final_locals: true # Warns when a local variable could be final
prefer_final_in_for_each: true # Warns when a forEach variable could be final
prefer_const_constructors: true # Warns when a constructor could be const
prefer_const_declarations: true # Warns when a declaration could be const
# rules:
# - unnecessary_const
# - prefer_const_declarations
# - prefer_final_locals # Warns when a local variable could be final
# - prefer_final_in_for_each # Warns when a forEach variable could be final
# - always_declare_return_types
# - annotate_overrides
# - avoid_init_to_null
# - avoid_null_checks_in_equality_operators
# - avoid_relative_lib_imports
# - avoid_return_types_on_setters
# - avoid_shadowing_type_parameters
# - avoid_single_cascade_in_expression_statements
# - avoid_types_as_parameter_names
# - await_only_futures
# - camel_case_extensions
# - curly_braces_in_flow_control_structures
# - empty_catches
# - empty_constructor_bodies
# - library_names
# - library_prefixes
# - no_duplicate_case_values
# - null_closures
# # - omit_local_variable_types
# - prefer_adjacent_string_concatenation
# - prefer_collection_literals
# - prefer_conditional_assignment
# - prefer_contains
# - prefer_equal_for_default_values
# - prefer_final_fields
# - prefer_for_elements_to_map_fromIterable
# - prefer_generic_function_type_aliases
# - prefer_if_null_operators
# - prefer_inlined_adds
# - prefer_is_empty
# - prefer_is_not_empty
# - prefer_iterable_whereType
# - prefer_single_quotes
# - prefer_spread_collections
# - recursive_getters
# - slash_for_doc_comments
# - sort_child_properties_last
# - type_init_formals
# - unawaited_futures
# - unnecessary_brace_in_string_interps
# - unnecessary_getters_setters
# - unnecessary_new
# - unnecessary_null_in_if_null_operators
# - unnecessary_this
# - unrelated_type_equality_checks
# - use_function_type_syntax_for_parameters
# - use_rethrow_when_possible
# - valid_regexps
16 changes: 0 additions & 16 deletions example/lib/a.dart

This file was deleted.

2 changes: 1 addition & 1 deletion example/lib/example/cardano/deploy_plutus_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void main() async {
final hash = body.toHash().toHex();
assert(hash ==
"05ddd72d58d663c4a1d4c282ee653184ecc44df8595e07e70562badf03a90ba0");
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
await provider.request(BlockfrostRequestSubmitTransaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() async {
publicKey: BytesUtils.fromHexString(
"004e4f3bba48cf6712fcfd9fa2a030b6ca0564d6488e1d821753b0830a32f1ba1a"),
);
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/legacy_to_legacy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() async {
"KjgoiXJS2coqEj7BmUEY9TSJxppxySTBNDskVreRH2VN9TGV2SX1b8BRstVaPAA7eWCsEFLg8VKj47mNLJ5M21qPiaZqxphEYDBjdwvg44ot",
network: ADANetwork.testnetPreprod,
);
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
final body = TransactionBody(inputs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() async {
network: ADANetwork.testnetPreprod,
);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/mint_nft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void main() async {
pubkeyBytes: spend.publicKey.compressed,
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() async {
pubkeyBytes: spend2.publicKey.compressed,
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/mint_with_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
pubkeyBytes: spend.publicKey.compressed,
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/pool_registration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void main() async {

final poolRegistration = PoolRegistration(poolParams);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
final parameters =
Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/provider_call_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'provider_example/provider.dart';

void main() async {
/// Set up the Blockfrost provider with the specified URL and project ID
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
45 changes: 21 additions & 24 deletions example/lib/example/cardano/provider_example/provider.dart
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
import 'dart:convert';
import 'package:blockchain_utils/service/models/params.dart';
import 'package:http/http.dart' as http;
import 'package:on_chain/ada/src/provider/blockfrost/core/core.dart';
import 'package:on_chain/ada/src/provider/service/service.dart';

class BlockforestHTTPProvider implements BlockfrostServiceProvider {
BlockforestHTTPProvider(
class BlockFrostHTTPProvider implements BlockFrostServiceProvider {
BlockFrostHTTPProvider(
{required this.url,
this.version = "v0",
this.projectId,
http.Client? client,
this.defaultRequestTimeout = const Duration(seconds: 30)})
: client = client ?? http.Client();
@override

final String url;
final String version;
final String? projectId;
final http.Client client;
final Duration defaultRequestTimeout;

@override
Future<dynamic> get(BlockforestRequestDetails params,
[Duration? timeout]) async {
final response =
await client.get(Uri.parse(params.url(url, version)), headers: {
'Content-Type': 'application/json',
"Accept": "application/json",
if (projectId != null) ...{"project_id": projectId!},
}).timeout(timeout ?? defaultRequestTimeout);
final data = json.decode(response.body);
return data;
}

@override
Future<dynamic> post(BlockforestRequestDetails params,
[Duration? timeout]) async {
Future<BaseServiceResponse<T>> doRequest<T>(BlockFrostRequestDetails params,
{Duration? timeout}) async {
if (params.type == RequestServiceType.get) {
final response =
await client.get(params.toUri(url, version: version), headers: {
'Content-Type': 'application/json',
"Accept": "application/json",
...params.headers,
if (projectId != null) ...{"project_id": projectId!},
}).timeout(timeout ?? defaultRequestTimeout);
return params.toResponse(response.bodyBytes, response.statusCode);
}
final response = await client
.post(Uri.parse(params.url(url, version)),
.post(params.toUri(url, version: version),
headers: {
'Content-Type': 'application/json',
"Accept": "application/json",
...params.headers,
if (projectId != null) ...{"project_id": projectId!},
...params.header
},
body: params.body)
body: params.body())
.timeout(timeout ?? defaultRequestTimeout);
final data = json.decode(response.body);
return data;
return params.toResponse(response.bodyBytes, response.statusCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void main() async {
final addr = ADABaseAddress.shellyWallet(
shelleyWallet: internal10, network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
final input = TransactionInput(
Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/register_stake_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() async {
stakePubkeyBytes: spend2.publicKey.compressed,
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
final stakeRegistration = StakeRegistration(receiver.stakeCredential);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/shelly_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() async {
network: ADANetwork.testnetPreprod);

/// Set up the Blockfrost provider
final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/shelly_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() async {
"addr_test1gzkrh0ytcw257np6x6lxp74a6p4erj7rqt9azycnckgp2fgpqyqskrjv3p",
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/shelly_3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() async {
"addr_test1vpmlrrdzzl68qdr3y7jjzyfmyepnnyjs3lxquckzxc8ysggzzfs29",
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/shelly_32byte_private_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
"addr_test1vp0q6wvr6y3elejn69efhnxr5akk24azaxcez3xw8m9n85gmr5qny",
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/shelly_to_legacy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() async {
"FHnt4NL7yPXpa2nSSgu36kbQw4jpxWR3V5Yr7MEaPjWa58V3doFnkj3rwzhTTEX",
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
2 changes: 1 addition & 1 deletion example/lib/example/cardano/shelly_with_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() async {
"addr_test1vp0q6wvr6y3elejn69efhnxr5akk24azaxcez3xw8m9n85gmr5qny",
network: ADANetwork.testnetPreprod);

final provider = BlockforestProvider(BlockforestHTTPProvider(
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
url: "https://cardano-preprod.blockfrost.io/api/v0/",
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));

Expand Down
Loading

0 comments on commit f82665a

Please sign in to comment.