Skip to content

Commit f82665a

Browse files
committed
V5.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.
1 parent 0384879 commit f82665a

File tree

1,503 files changed

+14241
-14111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,503 files changed

+14241
-14111
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 5.0.0
2+
3+
- Minimum required Dart SDK version updated to 3.3.
4+
- The RPC method names and service class implementations have been updated. Please refer to the examples folder for guidance.
5+
- Update dependencies.
6+
17
## 4.5.0
28

39
- Update dependencies.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Here are some examples:
207207
"wss://polygon-mumbai-bor.publicnode.com");
208208
209209
/// Create an Ethereum RPC instance
210-
final rpc = EVMRPC(wsocketService);
210+
final rpc = EthereumProvider(wsocketService);
211211
212212
/// Define a seed for generating a private key
213213
final seed = BytesUtils.fromHexString(
@@ -312,7 +312,7 @@ Here are some examples:
312312
/// For Tron: If the output parameters include an address, set isTron to true.
313313
/// If it doesn't, set isTron to false to receive an ETH address instead of a Tron address.
314314
final contract = ContractABI.fromJson(tronContract["entrys"]!, isTron: true);
315-
final rpc = EVMRPC(RPCHttpService("https://api.shasta.trongrid.io/jsonrpc"));
315+
final rpc = EthereumProvider(RPCHttpService("https://api.shasta.trongrid.io/jsonrpc"));
316316
final call1 = await rpc.request(RPCCall.fromMethod(
317317
contractAddress:
318318
@@ -466,7 +466,7 @@ Here are some examples:
466466
final service = RPCHttpService("https://api.devnet.solana.com");
467467
468468
/// Initialize the Solana RPC client.
469-
final rpc = SolanaRPC(service);
469+
final rpc = SolanaProvider(service);
470470
471471
/// Define the owner's private key and derive the owner's public key.
472472
final ownerPrivateKey = SolanaPrivateKey.fromSeedHex(
@@ -532,7 +532,7 @@ Here are some examples:
532532
network: ADANetwork.testnetPreprod);
533533
534534
/// Set up the Blockfrost provider
535-
final provider = BlockforestProvider(BlockforestHTTPProvider(
535+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
536536
url: "https://cardano-preprod.blockfrost.io/api/v0/",
537537
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
538538
@@ -689,7 +689,7 @@ Example:
689689
// Establish a WebSocket RPC connection to the specified endpoint for real-time updates.
690690
691691
/// Ethereum RPC
692-
final rpc = EVMRPC(httpRpc);
692+
final rpc = EthereumProvider(httpRpc);
693693
// Create an Ethereum RPC instance using the HTTP RPC service.
694694
695695
/// Get Balance
@@ -748,7 +748,7 @@ Example:
748748
749749
```dart
750750
/// Initialize the Solana RPC client with the devnet endpoint.
751-
final service = SolanaRPC(RPCHttpService("https://api.devnet.solana.com"));
751+
final service = SolanaProvider(RPCHttpService("https://api.devnet.solana.com"));
752752
753753
/// Retrieve the account information for a specific address.
754754
final accountModel = await service.request(const SolanaRPCGetAccountInfo(
@@ -774,7 +774,7 @@ Example:
774774
775775
```dart
776776
/// Set up the Blockfrost provider with the specified URL and project ID
777-
final provider = BlockforestProvider(BlockforestHTTPProvider(
777+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
778778
url: "https://cardano-preprod.blockfrost.io/api/v0/",
779779
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
780780

analysis_options.yaml

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,69 @@
1-
# include: package:lints/recommended.yaml
2-
include: package:flutter_lints/flutter.yaml
3-
# Uncomment the following section to specify additional rules.
1+
# This file configures the analyzer to use the lint rule set from `package:lint`
2+
3+
include: package:flutter_lints/flutter.yaml # For production apps
4+
# include: package:lint/casual.yaml # For code samples, hackathons and other non-production code
5+
# include: package:lint/package.yaml # Use this for packages with public API
6+
7+
8+
# You might want to exclude auto-generated files from dart analysis
9+
analyzer:
10+
exclude:
11+
#- '**.freezed.dart'
12+
#- '**.g.dart'
13+
14+
# You can customize the lint rules set to your own liking. A list of all rules
15+
# can be found at https://dart-lang.github.io/linter/lints/options/options.html
416
linter:
5-
rules:
6-
prefer_final_locals: true # Warns when a local variable could be final
7-
prefer_final_in_for_each: true # Warns when a forEach variable could be final
8-
prefer_const_constructors: true # Warns when a constructor could be const
9-
prefer_const_declarations: true # Warns when a declaration could be const
17+
# rules:
18+
# - unnecessary_const
19+
# - prefer_const_declarations
20+
# - prefer_final_locals # Warns when a local variable could be final
21+
# - prefer_final_in_for_each # Warns when a forEach variable could be final
22+
# - always_declare_return_types
23+
# - annotate_overrides
24+
# - avoid_init_to_null
25+
# - avoid_null_checks_in_equality_operators
26+
# - avoid_relative_lib_imports
27+
# - avoid_return_types_on_setters
28+
# - avoid_shadowing_type_parameters
29+
# - avoid_single_cascade_in_expression_statements
30+
# - avoid_types_as_parameter_names
31+
# - await_only_futures
32+
# - camel_case_extensions
33+
# - curly_braces_in_flow_control_structures
34+
# - empty_catches
35+
# - empty_constructor_bodies
36+
# - library_names
37+
# - library_prefixes
38+
# - no_duplicate_case_values
39+
# - null_closures
40+
# # - omit_local_variable_types
41+
# - prefer_adjacent_string_concatenation
42+
# - prefer_collection_literals
43+
# - prefer_conditional_assignment
44+
# - prefer_contains
45+
# - prefer_equal_for_default_values
46+
# - prefer_final_fields
47+
# - prefer_for_elements_to_map_fromIterable
48+
# - prefer_generic_function_type_aliases
49+
# - prefer_if_null_operators
50+
# - prefer_inlined_adds
51+
# - prefer_is_empty
52+
# - prefer_is_not_empty
53+
# - prefer_iterable_whereType
54+
# - prefer_single_quotes
55+
# - prefer_spread_collections
56+
# - recursive_getters
57+
# - slash_for_doc_comments
58+
# - sort_child_properties_last
59+
# - type_init_formals
60+
# - unawaited_futures
61+
# - unnecessary_brace_in_string_interps
62+
# - unnecessary_getters_setters
63+
# - unnecessary_new
64+
# - unnecessary_null_in_if_null_operators
65+
# - unnecessary_this
66+
# - unrelated_type_equality_checks
67+
# - use_function_type_syntax_for_parameters
68+
# - use_rethrow_when_possible
69+
# - valid_regexps

example/lib/a.dart

Lines changed: 0 additions & 16 deletions
This file was deleted.

example/lib/example/cardano/deploy_plutus_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void main() async {
151151
final hash = body.toHash().toHex();
152152
assert(hash ==
153153
"05ddd72d58d663c4a1d4c282ee653184ecc44df8595e07e70562badf03a90ba0");
154-
final provider = BlockforestProvider(BlockforestHTTPProvider(
154+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
155155
url: "https://cardano-preprod.blockfrost.io/api/v0/",
156156
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
157157
await provider.request(BlockfrostRequestSubmitTransaction(

example/lib/example/cardano/legacy_and_shelly_to_two_legacy_and_shelly.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void main() async {
2929
publicKey: BytesUtils.fromHexString(
3030
"004e4f3bba48cf6712fcfd9fa2a030b6ca0564d6488e1d821753b0830a32f1ba1a"),
3131
);
32-
final provider = BlockforestProvider(BlockforestHTTPProvider(
32+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
3333
url: "https://cardano-preprod.blockfrost.io/api/v0/",
3434
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
3535

example/lib/example/cardano/legacy_to_legacy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() async {
1515
"KjgoiXJS2coqEj7BmUEY9TSJxppxySTBNDskVreRH2VN9TGV2SX1b8BRstVaPAA7eWCsEFLg8VKj47mNLJ5M21qPiaZqxphEYDBjdwvg44ot",
1616
network: ADANetwork.testnetPreprod,
1717
);
18-
final provider = BlockforestProvider(BlockforestHTTPProvider(
18+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
1919
url: "https://cardano-preprod.blockfrost.io/api/v0/",
2020
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
2121
final body = TransactionBody(inputs: [

example/lib/example/cardano/legacy_to_shelly_and_to_byron.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void main() async {
2424
network: ADANetwork.testnetPreprod,
2525
);
2626

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

example/lib/example/cardano/mint_nft.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void main() async {
1010
pubkeyBytes: spend.publicKey.compressed,
1111
network: ADANetwork.testnetPreprod);
1212

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

example/lib/example/cardano/mint_token_with_native_script.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() async {
1515
pubkeyBytes: spend2.publicKey.compressed,
1616
network: ADANetwork.testnetPreprod);
1717

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

example/lib/example/cardano/mint_with_metadata.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void main() async {
1111
pubkeyBytes: spend.publicKey.compressed,
1212
network: ADANetwork.testnetPreprod);
1313

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

example/lib/example/cardano/pool_registration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void main() async {
3939

4040
final poolRegistration = PoolRegistration(poolParams);
4141

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

example/lib/example/cardano/provider_call_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'provider_example/provider.dart';
66

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

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
1-
import 'dart:convert';
1+
import 'package:blockchain_utils/service/models/params.dart';
22
import 'package:http/http.dart' as http;
33
import 'package:on_chain/ada/src/provider/blockfrost/core/core.dart';
44
import 'package:on_chain/ada/src/provider/service/service.dart';
55

6-
class BlockforestHTTPProvider implements BlockfrostServiceProvider {
7-
BlockforestHTTPProvider(
6+
class BlockFrostHTTPProvider implements BlockFrostServiceProvider {
7+
BlockFrostHTTPProvider(
88
{required this.url,
99
this.version = "v0",
1010
this.projectId,
1111
http.Client? client,
1212
this.defaultRequestTimeout = const Duration(seconds: 30)})
1313
: client = client ?? http.Client();
14-
@override
14+
1515
final String url;
1616
final String version;
1717
final String? projectId;
1818
final http.Client client;
1919
final Duration defaultRequestTimeout;
2020

2121
@override
22-
Future<dynamic> get(BlockforestRequestDetails params,
23-
[Duration? timeout]) async {
24-
final response =
25-
await client.get(Uri.parse(params.url(url, version)), headers: {
26-
'Content-Type': 'application/json',
27-
"Accept": "application/json",
28-
if (projectId != null) ...{"project_id": projectId!},
29-
}).timeout(timeout ?? defaultRequestTimeout);
30-
final data = json.decode(response.body);
31-
return data;
32-
}
33-
34-
@override
35-
Future<dynamic> post(BlockforestRequestDetails params,
36-
[Duration? timeout]) async {
22+
Future<BaseServiceResponse<T>> doRequest<T>(BlockFrostRequestDetails params,
23+
{Duration? timeout}) async {
24+
if (params.type == RequestServiceType.get) {
25+
final response =
26+
await client.get(params.toUri(url, version: version), headers: {
27+
'Content-Type': 'application/json',
28+
"Accept": "application/json",
29+
...params.headers,
30+
if (projectId != null) ...{"project_id": projectId!},
31+
}).timeout(timeout ?? defaultRequestTimeout);
32+
return params.toResponse(response.bodyBytes, response.statusCode);
33+
}
3734
final response = await client
38-
.post(Uri.parse(params.url(url, version)),
35+
.post(params.toUri(url, version: version),
3936
headers: {
37+
'Content-Type': 'application/json',
4038
"Accept": "application/json",
39+
...params.headers,
4140
if (projectId != null) ...{"project_id": projectId!},
42-
...params.header
4341
},
44-
body: params.body)
42+
body: params.body())
4543
.timeout(timeout ?? defaultRequestTimeout);
46-
final data = json.decode(response.body);
47-
return data;
44+
return params.toResponse(response.bodyBytes, response.statusCode);
4845
}
4946
}

example/lib/example/cardano/register_and_delegation_pool.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void main() async {
1818
final addr = ADABaseAddress.shellyWallet(
1919
shelleyWallet: internal10, network: ADANetwork.testnetPreprod);
2020

21-
final provider = BlockforestProvider(BlockforestHTTPProvider(
21+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
2222
url: "https://cardano-preprod.blockfrost.io/api/v0/",
2323
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
2424
final input = TransactionInput(

example/lib/example/cardano/register_stake_address.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void main() async {
1313
stakePubkeyBytes: spend2.publicKey.compressed,
1414
network: ADANetwork.testnetPreprod);
1515

16-
final provider = BlockforestProvider(BlockforestHTTPProvider(
16+
final provider = BlockFrostProvider(BlockFrostHTTPProvider(
1717
url: "https://cardano-preprod.blockfrost.io/api/v0/",
1818
projectId: "preprodMVwzqm4PuBDBSfEULoMzoj5QZcy5o3z5"));
1919
final stakeRegistration = StakeRegistration(receiver.stakeCredential);

example/lib/example/cardano/shelly_1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void main() async {
2323
network: ADANetwork.testnetPreprod);
2424

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

example/lib/example/cardano/shelly_2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void main() async {
2020
"addr_test1gzkrh0ytcw257np6x6lxp74a6p4erj7rqt9azycnckgp2fgpqyqskrjv3p",
2121
network: ADANetwork.testnetPreprod);
2222

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

example/lib/example/cardano/shelly_3.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() async {
1414
"addr_test1vpmlrrdzzl68qdr3y7jjzyfmyepnnyjs3lxquckzxc8ysggzzfs29",
1515
network: ADANetwork.testnetPreprod);
1616

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

example/lib/example/cardano/shelly_32byte_private_key.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void main() async {
1111
"addr_test1vp0q6wvr6y3elejn69efhnxr5akk24azaxcez3xw8m9n85gmr5qny",
1212
network: ADANetwork.testnetPreprod);
1313

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

example/lib/example/cardano/shelly_to_legacy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void main() async {
1111
"FHnt4NL7yPXpa2nSSgu36kbQw4jpxWR3V5Yr7MEaPjWa58V3doFnkj3rwzhTTEX",
1212
network: ADANetwork.testnetPreprod);
1313

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

example/lib/example/cardano/shelly_with_metadata.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() async {
1515
"addr_test1vp0q6wvr6y3elejn69efhnxr5akk24azaxcez3xw8m9n85gmr5qny",
1616
network: ADANetwork.testnetPreprod);
1717

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

0 commit comments

Comments
 (0)