Skip to content

Commit

Permalink
V4.7.0
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
mrtnetwork committed Jul 14, 2024
1 parent 560d845 commit d83e8fb
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 41 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.7.0

* Update dependencies

## 4.6.0

* add asyncTransactionBuilder method to support building transactions asynchronously.
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ packages:
path: ".."
relative: true
source: path
version: "4.4.0"
version: "4.7.0"
blockchain_utils:
dependency: "direct main"
description:
path: "../../blockchain_utils"
relative: true
source: path
version: "3.1.0"
version: "3.3.0"
boolean_selector:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
path: ../
blockchain_utils:
path: ../../blockchain_utils
# blockchain_utils: ^3.0.0
# blockchain_utils: ^3.3.0
http: ^1.2.0

dev_dependencies:
Expand Down
17 changes: 8 additions & 9 deletions lib/src/models/network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:bitcoin_base/src/exception/exception.dart';
import 'package:bitcoin_base/src/utils/enumerate.dart';
import 'package:blockchain_utils/bip/bip/bip.dart';
import 'package:blockchain_utils/bip/bip/conf/bip_coins.dart';
import 'package:blockchain_utils/bip/coin_conf/coin_conf.dart';
import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart';

Expand Down Expand Up @@ -56,7 +55,7 @@ abstract class BasedUtxoNetwork implements Enumerate {
return values.firstWhere((element) => element.value == name);
}

List<CryptoCoins> get coins;
List<BipCoins> get coins;

/// Checks if the current network is the mainnet.
bool get isMainnet => this == BitcoinNetwork.mainnet;
Expand Down Expand Up @@ -108,7 +107,7 @@ class BitcoinSVNetwork implements BasedUtxoNetwork {
[P2pkhAddressType.p2pkh, PubKeyAddressType.p2pk];

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) return [Bip44Coins.bitcoinSv];
return [Bip44Coins.bitcoinSvTestnet];
}
Expand Down Expand Up @@ -169,7 +168,7 @@ class BitcoinNetwork implements BasedUtxoNetwork {
];

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) {
return [
Bip44Coins.bitcoin,
Expand Down Expand Up @@ -240,7 +239,7 @@ class LitecoinNetwork implements BasedUtxoNetwork {
];

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) {
return [Bip44Coins.litecoin, Bip49Coins.litecoin, Bip84Coins.litecoin];
}
Expand Down Expand Up @@ -302,7 +301,7 @@ class DashNetwork implements BasedUtxoNetwork {
final String value;

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) return [Bip44Coins.dash, Bip49Coins.dash];
return [Bip44Coins.dashTestnet, Bip49Coins.dashTestnet];
}
Expand Down Expand Up @@ -358,7 +357,7 @@ class DogecoinNetwork implements BasedUtxoNetwork {
];

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) return [Bip44Coins.dogecoin, Bip49Coins.dogecoin];
return [Bip44Coins.dogecoinTestnet, Bip49Coins.dogecoinTestnet];
}
Expand Down Expand Up @@ -435,7 +434,7 @@ class BitcoinCashNetwork implements BasedUtxoNetwork {
];

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) return [Bip44Coins.bitcoinCash, Bip49Coins.bitcoinCash];
return [Bip44Coins.bitcoinCashTestnet, Bip49Coins.bitcoinCashTestnet];
}
Expand Down Expand Up @@ -487,7 +486,7 @@ class PepeNetwork implements BasedUtxoNetwork {
];

@override
List<CryptoCoins> get coins {
List<BipCoins> get coins {
if (isMainnet) {
return [Bip44Coins.pepecoin, Bip49Coins.pepecoin];
}
Expand Down
17 changes: 17 additions & 0 deletions lib/src/provider/api_provider/api_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:bitcoin_base/src/provider/models/models.dart';
import 'package:bitcoin_base/src/provider/service/http/http_service.dart';
import 'package:bitcoin_base/src/models/network.dart';
import 'package:blockchain_utils/utils/string/string.dart';

class ApiProvider {
ApiProvider(
Expand Down Expand Up @@ -138,4 +139,20 @@ class ApiProvider {
return transactions;
}
}

Future<String> getBlockHeight(int height) async {
final url = api.getBlockHeight(height);
final response = await _getRequest<String>(url);
switch (api.apiType) {
case APIType.mempool:
return response;
default:
final toJson = StringUtils.toJson<Map<String, dynamic>>(response);
return toJson["hash"];
}
}

Future<String> genesis() async {
return getBlockHeight(0);
}
}
57 changes: 32 additions & 25 deletions lib/src/provider/models/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class APIConfig {
final String transaction;
final String transactions;
final String sendTransaction;
final String blockHeight;
final APIType apiType;
final BasedUtxoNetwork network;

Expand Down Expand Up @@ -41,6 +42,11 @@ class APIConfig {
return baseUrl.replaceAll("###", address);
}

String getBlockHeight(int blockHaight) {
String baseUrl = blockHeight;
return baseUrl.replaceAll("###", "$blockHaight");
}

factory APIConfig.fromBlockCypher(BasedUtxoNetwork network) {
String baseUrl;
switch (network) {
Expand All @@ -65,14 +71,15 @@ class APIConfig {
}

return APIConfig(
url: "$baseUrl/addrs/###/?unspentOnly=true&includeScript=true&limit=2000",
feeRate: baseUrl,
transaction: "$baseUrl/txs/###",
sendTransaction: "$baseUrl/txs/push",
apiType: APIType.blockCypher,
transactions: "$baseUrl/addrs/###/full?limit=200",
network: network,
);
url:
"$baseUrl/addrs/###/?unspentOnly=true&includeScript=true&limit=2000",
feeRate: baseUrl,
transaction: "$baseUrl/txs/###",
sendTransaction: "$baseUrl/txs/push",
apiType: APIType.blockCypher,
transactions: "$baseUrl/addrs/###/full?limit=200",
network: network,
blockHeight: "$baseUrl/blocks/###");
}

factory APIConfig.mempool(BasedUtxoNetwork network) {
Expand All @@ -90,23 +97,23 @@ class APIConfig {
}

return APIConfig(
url: "$baseUrl/address/###/utxo",
feeRate: "$baseUrl/v1/fees/recommended",
transaction: "$baseUrl/tx/###",
sendTransaction: "$baseUrl/tx",
apiType: APIType.mempool,
transactions: "$baseUrl/address/###/txs",
network: network,
);
url: "$baseUrl/address/###/utxo",
feeRate: "$baseUrl/v1/fees/recommended",
transaction: "$baseUrl/tx/###",
sendTransaction: "$baseUrl/tx",
apiType: APIType.mempool,
transactions: "$baseUrl/address/###/txs",
network: network,
blockHeight: "$baseUrl/block-height/###");
}

APIConfig({
required this.url,
required this.feeRate,
required this.transaction,
required this.transactions,
required this.sendTransaction,
required this.apiType,
required this.network,
});
APIConfig(
{required this.url,
required this.feeRate,
required this.transaction,
required this.transactions,
required this.sendTransaction,
required this.apiType,
required this.network,
required this.blockHeight});
}
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bitcoin_base
description: A versatile library for Bitcoin, Dogecoin, Litecoin, Dash, BSV, and BCH. Supports P2PKH, P2SH, P2WPKH, P2WSH, P2TR, with advanced creation, signing, and spending capabilities.
version: 4.6.0
version: 4.7.0
homepage: "https://github.com/mrtnetwork/bitcoin_base"
repository: "https://github.com/mrtnetwork/bitcoin_base"
Author: mrhaydari.t@gmail.com
Expand All @@ -16,10 +16,10 @@ environment:


dependencies:
blockchain_utils: ^3.2.0
# blockchain_utils: ^3.3.0

# blockchain_utils:
# path: ../blockchain_utils
blockchain_utils:
path: ../blockchain_utils


dev_dependencies:
Expand Down

0 comments on commit d83e8fb

Please sign in to comment.