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-2081 - Fixed issue when domain records not picked up when sending crypto #666

Merged
merged 2 commits into from
Sep 9, 2024
Merged
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 @@ -63,26 +63,12 @@ extension SendCryptoAsset {

func addressFor(token: BalanceTokenUIDescription,
in currencies: [CoinRecord]) -> String? {
let coinRecords = currencies.filter { $0.ticker == token.symbol }
let chain = resolveCoinRecordChainIdentifier(token.chain)
guard let tokenRecord = coinRecords.first(where: { record in
if record.network == nil {
return token.chain == token.symbol
}
return record.network == chain
}) else { return nil }
guard let tokenRecord = currencies.first(where: { $0.ticker == token.symbol && $0.network == token.chain }) else { return nil }

let recordsIdentifier = tokenRecord.expandedTicker
return self.records[recordsIdentifier]
}

private func resolveCoinRecordChainIdentifier(_ chain: String) -> String {
switch chain {
case BlockchainType.Ethereum.shortCode:
return "ERC20"
default:
return chain
for (recordKey, address) in records where tokenRecord.isMatching(recordKey: recordKey) {
return address
}
return nil
}

init(wallet: WalletEntity) async throws {
Expand Down