2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-05-08 14:36:05 +00:00
|
|
|
import 'package:stackwallet/db/isar/main_db.dart';
|
|
|
|
import 'package:stackwallet/models/isar/models/block_explorer.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
|
|
|
2023-05-26 19:25:59 +00:00
|
|
|
// Returns the default block explorer URL for the given coin and txid
|
2023-05-04 18:10:37 +00:00
|
|
|
Uri getDefaultBlockExplorerUrlFor({
|
2022-08-26 08:11:35 +00:00
|
|
|
required Coin coin,
|
|
|
|
required String txid,
|
|
|
|
}) {
|
|
|
|
switch (coin) {
|
|
|
|
case Coin.bitcoin:
|
2023-03-24 01:14:48 +00:00
|
|
|
return Uri.parse("https://mempool.space/tx/$txid");
|
2022-10-28 18:03:52 +00:00
|
|
|
case Coin.litecoin:
|
|
|
|
return Uri.parse("https://chain.so/tx/LTC/$txid");
|
|
|
|
case Coin.litecoinTestNet:
|
|
|
|
return Uri.parse("https://chain.so/tx/LTCTEST/$txid");
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.bitcoinTestNet:
|
2023-03-24 01:14:48 +00:00
|
|
|
return Uri.parse("https://mempool.space/testnet/tx/$txid");
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.dogecoin:
|
|
|
|
return Uri.parse("https://chain.so/tx/DOGE/$txid");
|
2023-04-17 13:53:39 +00:00
|
|
|
case Coin.eCash:
|
|
|
|
return Uri.parse("https://explorer.bitcoinabc.org/tx/$txid");
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.dogecoinTestNet:
|
|
|
|
return Uri.parse("https://chain.so/tx/DOGETEST/$txid");
|
|
|
|
case Coin.epicCash:
|
2023-05-08 14:36:05 +00:00
|
|
|
// TODO: Handle this case.
|
2022-08-26 08:11:35 +00:00
|
|
|
throw UnimplementedError("missing block explorer for epic cash");
|
2022-12-13 17:39:19 +00:00
|
|
|
case Coin.ethereum:
|
|
|
|
return Uri.parse("https://etherscan.io/tx/$txid");
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.monero:
|
|
|
|
return Uri.parse("https://xmrchain.net/tx/$txid");
|
2022-09-27 08:09:31 +00:00
|
|
|
case Coin.wownero:
|
|
|
|
return Uri.parse("https://explore.wownero.com/search?value=$txid");
|
2022-08-26 08:11:35 +00:00
|
|
|
case Coin.firo:
|
|
|
|
return Uri.parse("https://explorer.firo.org/tx/$txid");
|
|
|
|
case Coin.firoTestNet:
|
|
|
|
return Uri.parse("https://testexplorer.firo.org/tx/$txid");
|
2022-09-26 20:32:53 +00:00
|
|
|
case Coin.bitcoincash:
|
|
|
|
return Uri.parse("https://blockchair.com/bitcoin-cash/transaction/$txid");
|
|
|
|
case Coin.bitcoincashTestnet:
|
|
|
|
return Uri.parse(
|
|
|
|
"https://blockexplorer.one/bitcoin-cash/testnet/tx/$txid");
|
2022-09-23 21:02:53 +00:00
|
|
|
case Coin.namecoin:
|
|
|
|
return Uri.parse("https://chainz.cryptoid.info/nmc/tx.dws?$txid.htm");
|
2022-10-25 15:06:37 +00:00
|
|
|
case Coin.particl:
|
|
|
|
return Uri.parse("https://chainz.cryptoid.info/part/tx.dws?$txid.htm");
|
2023-07-19 17:08:46 +00:00
|
|
|
case Coin.stellar:
|
|
|
|
return Uri.parse("https://stellarchain.io/tx/$txid");
|
2023-05-19 10:20:16 +00:00
|
|
|
case Coin.nano:
|
|
|
|
return Uri.parse("https://www.nanolooker.com/block/$txid");
|
2023-05-30 23:19:31 +00:00
|
|
|
case Coin.banano:
|
|
|
|
return Uri.parse("https://www.bananolooker.com/block/$txid");
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-04 18:10:37 +00:00
|
|
|
|
2023-05-26 19:25:59 +00:00
|
|
|
// Returns internal Isar ID for the inserted object/record
|
2023-05-08 14:36:05 +00:00
|
|
|
Future<int> setBlockExplorerForCoin({
|
|
|
|
required Coin coin,
|
|
|
|
required Uri url,
|
|
|
|
}) async {
|
|
|
|
return await MainDB.instance.putTransactionBlockExplorer(
|
|
|
|
TransactionBlockExplorer(
|
|
|
|
ticker: coin.ticker,
|
|
|
|
url: url.toString(),
|
|
|
|
),
|
|
|
|
);
|
2023-05-04 18:10:37 +00:00
|
|
|
}
|
|
|
|
|
2023-05-26 19:25:59 +00:00
|
|
|
// Returns the block explorer URL for the given coin and txid
|
2023-05-04 18:10:37 +00:00
|
|
|
Uri getBlockExplorerTransactionUrlFor({
|
|
|
|
required Coin coin,
|
|
|
|
required String txid,
|
|
|
|
}) {
|
2023-05-08 14:36:05 +00:00
|
|
|
String? url = MainDB.instance.getTransactionBlockExplorer(coin: coin)?.url;
|
2023-05-04 18:10:37 +00:00
|
|
|
if (url == null) {
|
|
|
|
return getDefaultBlockExplorerUrlFor(coin: coin, txid: txid);
|
|
|
|
} else {
|
2023-05-08 14:36:05 +00:00
|
|
|
url = url.replaceAll("%5BTXID%5D", txid);
|
2023-05-05 17:30:22 +00:00
|
|
|
return Uri.parse(url);
|
2023-05-04 18:10:37 +00:00
|
|
|
}
|
|
|
|
}
|