mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
parent
b77c22b0df
commit
d332377a2b
36 changed files with 402 additions and 667 deletions
|
@ -1,33 +1,26 @@
|
|||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:on_chain/solana/solana.dart';
|
||||
|
||||
class SolanaRPCHTTPService implements SolanaServiceProvider {
|
||||
class SolanaRPCHTTPService implements SolanaJSONRPCService {
|
||||
SolanaRPCHTTPService(
|
||||
{required this.url, Client? client, this.defaultRequestTimeout = const Duration(seconds: 30)})
|
||||
: client = client ?? Client();
|
||||
|
||||
@override
|
||||
final String url;
|
||||
final Client client;
|
||||
final Duration defaultRequestTimeout;
|
||||
|
||||
@override
|
||||
Future<SolanaServiceResponse<T>> doRequest<T>(SolanaRequestDetails params,
|
||||
{Duration? timeout}) async {
|
||||
if (!params.type.isPostRequest) {
|
||||
final response = await client.get(
|
||||
params.toUri(url),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
).timeout(timeout ?? defaultRequestTimeout);
|
||||
return params.toResponse(response.bodyBytes, response.statusCode);
|
||||
}
|
||||
|
||||
final response = await client
|
||||
.post(
|
||||
params.toUri(url),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: params.body(),
|
||||
)
|
||||
.timeout(timeout ?? defaultRequestTimeout);
|
||||
return params.toResponse(response.bodyBytes, response.statusCode);
|
||||
Future<Map<String, dynamic>> call(SolanaRequestDetails params, [Duration? timeout]) async {
|
||||
final response = await client.post(
|
||||
Uri.parse(url),
|
||||
body: params.toRequestBody(),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
).timeout(timeout ?? defaultRequestTimeout);
|
||||
final data = json.decode(response.body) as Map<String, dynamic>;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,11 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: cake-update-v4
|
||||
resolved-ref: "437dadd0bd9bf73ec6a551299577799341f6486a"
|
||||
ref: cake-update-v2
|
||||
resolved-ref: "59fdf29d72068e0522a96a8953ed7272833a9f57"
|
||||
url: "https://github.com/cake-tech/blockchain_utils"
|
||||
source: git
|
||||
version: "4.3.0"
|
||||
version: "3.3.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -478,11 +478,11 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: cake-update-v4
|
||||
resolved-ref: "084fb7bf13ec42d74f26ac08c883ce07c10fca7e"
|
||||
ref: cake-update-v2
|
||||
resolved-ref: "93440dc5126369b873ca1fccc13c3c1240b1c5c2"
|
||||
url: "https://github.com/cake-tech/on_chain.git"
|
||||
source: git
|
||||
version: "6.2.0"
|
||||
version: "3.7.0"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -30,7 +30,7 @@ dependencies:
|
|||
on_chain:
|
||||
git:
|
||||
url: https://github.com/cake-tech/on_chain.git
|
||||
ref: cake-update-v4
|
||||
ref: cake-update-v2
|
||||
# tor:
|
||||
# git:
|
||||
# url: https://github.com/cake-tech/tor.git
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue