Skip to content

Commit

Permalink
AND-8947 Simplify EstimationFeeAddressFactory by union empty address …
Browse files Browse the repository at this point in the history
…branches
  • Loading branch information
nzeeei committed Oct 31, 2024
1 parent debd40d commit c4b76a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,23 @@ class EstimationFeeAddressFactory {
@Suppress("LongMethod", "CyclomaticComplexMethod")
fun makeAddress(blockchain: Blockchain): String {
return when (blockchain) {
Blockchain.Cardano -> CARDANO_ESTIMATION_ADDRESS
Blockchain.Unknown, // shouldn't get there
Blockchain.Ducatus, // doesn't depend on destination
Blockchain.Tezos, // doesn't depend on destination
Blockchain.Hedera, Blockchain.HederaTestnet, // doesn't depend on destination
Blockchain.Chia, Blockchain.ChiaTestnet, // doesn't depend on destination
Blockchain.InternetComputer, // fixed
Blockchain.Casper, Blockchain.CasperTestnet, // fixed
-> ""

Blockchain.Chia, Blockchain.ChiaTestnet -> {
// Can not generate and doesn't depend on destination
""
}
Blockchain.Nexa, Blockchain.NexaTestnet,
-> TODO("Not implemented")

Blockchain.Cardano -> CARDANO_ESTIMATION_ADDRESS
Blockchain.XRP,
Blockchain.Stellar, Blockchain.StellarTestnet,
Blockchain.Binance, Blockchain.BinanceTestnet,
Blockchain.SolanaTestnet,
Blockchain.Hedera, Blockchain.HederaTestnet,
-> {
// Doesn't depend on amount and destination
""
}

Blockchain.Tezos -> {
// Tezos has a fixed fee.
""
}

Blockchain.Ducatus, Blockchain.Unknown -> {
// Unsupported
""
}

// We have to generate a new dummy address for UTXO-like
Blockchain.Bitcoin,
Expand All @@ -59,7 +50,6 @@ class EstimationFeeAddressFactory {
Blockchain.RavencoinTestnet,
-> "RT5qKgXdmh9pqtz71cgfL834VfeXFVH1sG"
Blockchain.Solana -> "9wuDg6Y4H4j86Kg5aUGrUeaBa3sAUzjMs37KbeGFnRuM"
Blockchain.Nexa, Blockchain.NexaTestnet -> TODO("Not implemented")
Blockchain.Radiant -> "1K8jBuCKzuwvFCjL7Qpqq69k1hnVXJ31Nc"
// EVM-like
Blockchain.EthereumClassic, Blockchain.EthereumClassicTestnet ->
Expand Down Expand Up @@ -132,20 +122,16 @@ class EstimationFeeAddressFactory {
"0x4626b7ef23fb2800a0e224e8249f47e0db3579070262da2a7efb0bc52c882867"
Blockchain.Algorand, Blockchain.AlgorandTestnet ->
"CW6XDCKQAZUGAIOTGE2NEPYFFVW6H6IKFOTOF3W5WDUVHH4ZIDCIKYDPXY"
Blockchain.Koinos, Blockchain.KoinosTestnet -> "1C423Vbd44zjghhJR5fKJdLFS3rgVFUc9A"
Blockchain.Koinos, Blockchain.KoinosTestnet,
-> "1C423Vbd44zjghhJR5fKJdLFS3rgVFUc9A"
Blockchain.Filecoin -> "f1wxdu6d25dc4hmebdfgriswooum22plhmmpxibzq"
Blockchain.Kaspa -> "kaspa:qyp2f0ust8wyvuvqrzajvehx5jyh43vcjgessjdkw9vyw6rww4fdlsgzysspfuq"
Blockchain.Sei, Blockchain.SeiTestnet -> "sei1lhjvds604fvac32j4eygpr820lyc82dlfv0ea4"
Blockchain.InternetComputer -> {
// Doesn't depend on amount and destination
""
}
Blockchain.Sui,
Blockchain.SuiTestnet,
Blockchain.Sei, Blockchain.SeiTestnet,
-> "sei1lhjvds604fvac32j4eygpr820lyc82dlfv0ea4"
Blockchain.Sui, Blockchain.SuiTestnet,
-> "0xbca45e36a271e106546c89984108685215724e488570a0049a187c473cd521bc"
Blockchain.EnergyWebX, Blockchain.EnergyWebXTestnet,
-> "5CogUCbb5PYYbEHhDVGDN6JRRYBkd4sFRVc4wwP8oy5Su34Z"
Blockchain.Casper, Blockchain.CasperTestnet -> ""
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ class EstimationFeeAddressFactoryTest {

private val factory = EstimationFeeAddressFactory()
private val hardcodedAddressesForBlockchain = mapOf(
Blockchain.Cardano to "addr1q95pg4z9tf26r5dwf72vmh62u3pr9sewq2waahyhpjzm3enz43pvhh0us3z0z5xen2skq200e67eu89s5v2s0sdh3fnsm9lknu",
Blockchain.Chia to "",
Blockchain.ChiaTestnet to "",
Blockchain.XRP to "",
Blockchain.Stellar to "",
Blockchain.StellarTestnet to "",
Blockchain.Binance to "",
Blockchain.BinanceTestnet to "",
Blockchain.SolanaTestnet to "",
Blockchain.Hedera to "",
Blockchain.HederaTestnet to "",
Blockchain.Tezos to "",
Blockchain.Kaspa to "",
Blockchain.Ducatus to "",
Blockchain.InternetComputer to "",
Blockchain.Casper to "",
Blockchain.CasperTestnet to "",
Blockchain.Cardano to "addr1q95pg4z9tf26r5dwf72vmh62u3pr9sewq2waahyhpjzm3enz43pvhh0us3z0z5xen2skq200e67eu89s5v2s0sdh3fnsm9lknu",
Blockchain.XRP to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.Stellar to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.StellarTestnet to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.Binance to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.BinanceTestnet to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.SolanaTestnet to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.Bitcoin to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.BitcoinTestnet to "bc1qkrc5kmpq546wr2xk0errg58yw9jjq7thvhdk5k",
Blockchain.Litecoin to "MSqjXH6toL4kHqsRo3mWaWMkhmiH9GQxLR",
Expand Down Expand Up @@ -120,8 +122,8 @@ class EstimationFeeAddressFactoryTest {
Blockchain.Kaspa to "kaspa:qyp2f0ust8wyvuvqrzajvehx5jyh43vcjgessjdkw9vyw6rww4fdlsgzysspfuq",
Blockchain.Sei to "sei1lhjvds604fvac32j4eygpr820lyc82dlfv0ea4",
Blockchain.SeiTestnet to "sei1lhjvds604fvac32j4eygpr820lyc82dlfv0ea4",
Blockchain.InternetComputer to "",
Blockchain.Sui to "0xbca45e36a271e106546c89984108685215724e488570a0049a187c473cd521bc",
Blockchain.Kaspa to "kaspa:qyp2f0ust8wyvuvqrzajvehx5jyh43vcjgessjdkw9vyw6rww4fdlsgzysspfuq",
)

@Test
Expand Down

0 comments on commit c4b76a8

Please sign in to comment.