Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-1935 - Basic Base chain support #472

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -650,6 +650,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 @@ -709,6 +710,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 @@ -964,7 +964,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