Skip to content

Commit

Permalink
MOB-1935 - Basic Base chain support (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg authored Apr 3, 2024
1 parent e3efaa4 commit 35d7066
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct BalanceTokenUIDescription: Hashable, Identifiable {

let chain: String
let symbol: String
let gasCurrency: String
let name: String
let balance: Double
let balanceUsd: Double
Expand All @@ -25,14 +26,24 @@ struct BalanceTokenUIDescription: Hashable, Identifiable {
static let iconSize: InitialsView.InitialsSize = .default
static let iconStyle: InitialsView.Style = .gray

var balanceSymbol: String {
// For 'parent' token we show gas currency (which is ETH for Base token)
if parentSymbol == nil {
return gasCurrency
}
return symbol
}

init(walletBalance: WalletTokenPortfolio) {
self.chain = walletBalance.symbol
self.symbol = walletBalance.symbol
self.gasCurrency = walletBalance.gasCurrency
self.name = walletBalance.name
self.balance = walletBalance.balanceAmt.rounded(toDecimalPlaces: 2)
self.balanceUsd = walletBalance.value.walletUsdAmt
self.marketUsd = walletBalance.value.marketUsdAmt ?? 0
self.marketPctChange24Hr = walletBalance.value.marketPctChange24Hr
self.logoURL = URL(string: walletBalance.logoUrl ?? "")
}

init(chain: String,
Expand All @@ -41,10 +52,10 @@ struct BalanceTokenUIDescription: Hashable, Identifiable {
balance: Double,
balanceUsd: Double,
marketUsd: Double? = nil,
marketPctChange24Hr: Double? = nil,
icon: UIImage? = nil) {
marketPctChange24Hr: Double? = nil) {
self.chain = chain
self.symbol = symbol
self.gasCurrency = symbol
self.name = name
self.balance = balance
self.balanceUsd = balanceUsd
Expand All @@ -55,12 +66,14 @@ struct BalanceTokenUIDescription: Hashable, Identifiable {
init(chain: String, walletToken: WalletTokenPortfolio.Token, parentSymbol: String, parentLogoURL: URL?) {
self.chain = chain
self.symbol = walletToken.symbol
self.gasCurrency = walletToken.gasCurrency
self.name = walletToken.name
self.balance = walletToken.balanceAmt.rounded(toDecimalPlaces: 2)
self.balanceUsd = walletToken.value?.walletUsdAmt ?? 0
self.marketUsd = walletToken.value?.marketUsdAmt ?? 0
self.marketPctChange24Hr = walletToken.value?.marketPctChange24Hr
self.parentSymbol = parentSymbol
self.parentLogoURL = parentLogoURL
self.logoURL = URL(string: walletToken.logoUrl ?? "")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extension MockEntitiesFabric {

let balance: [WalletTokenPortfolio] = [.init(address: address,
symbol: "ETH",
gasCurrency: "ETH",
name: "Ethereum",
type: "native",
firstTx: nil, lastTx: nil,
Expand All @@ -102,7 +103,8 @@ extension MockEntitiesFabric {
totalValueUsd: "$2,206.70",
logoUrl: nil),
.init(address: address,
symbol: "MATIC",
symbol: "MATIC",
gasCurrency: "MATIC",
name: "Polygon",
type: "native",
firstTx: nil, lastTx: nil,
Expand All @@ -111,7 +113,8 @@ extension MockEntitiesFabric {
tokens: [.init(type: "erc20",
name: "(PoS) Tether USD",
address: address,
symbol: "USDT",
symbol: "USDT",
gasCurrency: "MATIC",
logoUrl: nil,
balanceAmt: 9.2,
value: .init(marketUsd: "$1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct HomeWalletTokenRowView: View {
.frame(height: token.isSkeleton ? 16 : 24)
.skeletonable()
.skeletonCornerRadius(12)
Text("\(token.balance.formatted(toMaxNumberAfterComa: 2)) \(token.symbol)")
Text("\(token.balance.formatted(toMaxNumberAfterComa: 2)) \(token.balanceSymbol)")
.font(.currentFont(size: 14, weight: .regular))
.foregroundStyle(secondaryColor)
.frame(height: token.isSkeleton ? 12 : 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ struct ProfileWalletBalance: Codable, Hashable {
struct WalletTokenPortfolio: Codable, Hashable {
let address: String
let symbol: String
let gasCurrency: String
let name: String
let type: String
let firstTx: Date?
Expand Down Expand Up @@ -708,6 +709,7 @@ struct WalletTokenPortfolio: Codable, Hashable {
let name: String
let address: String
let symbol: String
let gasCurrency: String
let logoUrl: String?
let balanceAmt: Double
let value: WalletTokenPortfolio.Value?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@

// Home
"HOME_WALLET_TOKENS_COME_TITLE" = "No more tokens here yet";
"HOME_WALLET_TOKENS_COME_SUBTITLE" = "We currently support Ethereum and Polygon tokens, more coming in the future updates!";
"HOME_WALLET_TOKENS_COME_SUBTITLE" = "We currently support Ethereum, Polygon and Base tokens, more coming in the future updates!";
"HOME_WALLET_COLLECTIBLES_EMPTY_TITLE" = "No collectibles in your wallet";
"HOME_WALLET_COLLECTIBLES_EMPTY_SUBTITLE" = "To receive collectibles and see them here, just copy your wallet address below.";
"NFT_DETAILS_ABOUT_COLLECTION_HEADER" = "About %@";
Expand Down

0 comments on commit 35d7066

Please sign in to comment.