Skip to content

Commit

Permalink
fix: post req body
Browse files Browse the repository at this point in the history
  • Loading branch information
detherminal committed Sep 14, 2024
1 parent e0051c8 commit 6cbc37f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
8 changes: 6 additions & 2 deletions lib/wallets/api/cardano/blockfrost_http_provider.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:convert';
import 'dart:io';
import 'package:cbor/simple.dart';
import 'package:on_chain/ada/src/provider/blockfrost/core/core.dart';
import 'package:on_chain/ada/src/provider/service/service.dart';

import '../../../utilities/logger.dart';

class BlockfrostHttpProvider implements BlockfrostServiceProvider {
BlockfrostHttpProvider({
required this.url,
Expand Down Expand Up @@ -36,12 +39,13 @@ class BlockfrostHttpProvider implements BlockfrostServiceProvider {
Future<dynamic> post(BlockforestRequestDetails params,
[Duration? timeout,]) async {
final request = await client.postUrl(Uri.parse(params.url(url, "api/$version"))).timeout(timeout ?? defaultRequestTimeout);
request.headers.add("Content-Type", "application/json");
// Need to change this for other operations than submitting transactions
request.headers.add("Content-Type", "application/cbor");
request.headers.add("Accept", "application/json");
if (projectId != null) {
request.headers.add("project_id", projectId!);
}
request.write(json.encode(params.body));
request.add(params.body as List<int>);
final response = await request.close();
final data = json.decode(await response.transform(utf8.decoder).join());
return data;
Expand Down
54 changes: 27 additions & 27 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ packages:
dependency: "direct main"
description:
name: device_info_plus
sha256: a7fd703482b391a87d60b6061d04dfdeab07826b96f9abd8f5ed98068acc0074
sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110"
url: "https://pub.dev"
source: hosted
version: "10.1.2"
version: "9.1.2"
device_info_plus_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -1113,18 +1113,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -1184,10 +1184,10 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
version: "0.8.0"
memoize:
dependency: transitive
description:
Expand All @@ -1200,10 +1200,10 @@ packages:
dependency: "direct main"
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.12.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -1433,18 +1433,18 @@ packages:
dependency: "direct overridden"
description:
name: pinenacl
sha256: "57e907beaacbc3c024a098910b6240758e899674de07d6949a67b52fd984cbdf"
sha256: e5fb0bce1717b7f136f35ee98b5c02b3e6383211f8a77ca882fa7812232a07b9
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.3.4"
platform:
dependency: transitive
description:
name: platform
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.5"
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -1793,32 +1793,32 @@ packages:
dependency: transitive
description:
name: test
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
url: "https://pub.dev"
source: hosted
version: "1.25.7"
version: "1.25.2"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.0"
test_core:
dependency: transitive
description:
name: test_core
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
url: "https://pub.dev"
source: hosted
version: "0.6.4"
version: "0.6.0"
tezart:
dependency: "direct main"
description:
path: "."
ref: d000cc245e51d3ff50e6467960fb3d9159d5b2a9
resolved-ref: d000cc245e51d3ff50e6467960fb3d9159d5b2a9
ref: "13fa937ea9a9fc34caf047e068df9535f65c27ad"
resolved-ref: "13fa937ea9a9fc34caf047e068df9535f65c27ad"
url: "https://github.com/cypherstack/tezart.git"
source: git
version: "2.0.5"
Expand Down Expand Up @@ -2011,10 +2011,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.2.1"
wakelock:
dependency: "direct main"
description:
Expand Down Expand Up @@ -2121,7 +2121,7 @@ packages:
source: hosted
version: "1.2.1"
win32:
dependency: "direct overridden"
dependency: transitive
description:
name: win32
sha256: "68d1e89a91ed61ad9c370f9f8b6effed9ae5e0ede22a270bdfa6daf79fc2290a"
Expand Down Expand Up @@ -2194,5 +2194,5 @@ packages:
source: hosted
version: "0.2.3"
sdks:
dart: ">=3.5.2 <4.0.0"
flutter: ">=3.24.2"
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.19.6"

0 comments on commit 6cbc37f

Please sign in to comment.