[Refactor] Move code accessing EthereumAddress pod into in-house AlphaWalletAddress pod so it's hidden in app codebase

pull/4277/head
Hwee-Boon Yar 3 years ago
parent 495001f533
commit e6eff90b49
  1. 18
      AlphaWallet/Core/Ethereum/ABI/DecodedFunctionCall+Decode.swift
  2. 1
      Podfile
  3. 6
      Podfile.lock
  4. 1
      modules/AlphaWalletAddress/AlphaWalletAddress.podspec
  5. 15
      modules/AlphaWalletAddress/AlphaWalletAddress/Extensions/EthereumAddress+Extensions.swift
  6. 12
      modules/AlphaWalletAddress/AlphaWalletAddress/ThirdPartyAddress+Extension.swift

@ -5,26 +5,14 @@
// Created by Vladyslav Shepitko on 11.05.2021.
//
import EthereumAddress
import EthereumABI
import BigInt
import EthereumABI
fileprivate typealias EthereumAddress_fromEthereumAddressPod = EthereumAddress
extension EthereumAddress_fromEthereumAddressPod: CustomStringConvertible {
public var description: String {
return address
}
}
//NOTE: extracted to separated file to avoid missunderstanding with EthereumAddress address, web3swift and EthereumAddress contains the same struct for EthereumAddress. it causes types comparison issue
extension FunctionCall.Argument {
init(type: ABIType, anyValue: Any?) {
self.type = type
if let address = anyValue as? EthereumAddress_fromEthereumAddressPod {
self.value = AlphaWallet.Address.ethereumAddress(eip55String: address.address)
} else if let address = anyValue as? EthereumAddress_fromWeb3SwiftPod {
self.value = AlphaWallet.Address.ethereumAddress(eip55String: address.address)
if let address = AlphaWallet.Address(possibleAddress: anyValue) {
self.value = address
} else {
self.value = anyValue
}

@ -30,7 +30,6 @@ target 'AlphaWallet' do
pod 'AWSSNS', '2.18.0'
pod 'Mixpanel-swift', '2.8.0'
pod 'EthereumABI', '1.3.0'
pod 'EthereumAddress', '1.3.0'
pod 'BlockiesSwift'
pod 'PaperTrailLumberjack/Swift'
pod 'WalletConnectSwift', :git => 'https://github.com/WalletConnect/WalletConnectSwift.git'

@ -3,6 +3,7 @@ PODS:
- Alamofire-Synchronous (4.0.0):
- Alamofire (~> 4.0)
- AlphaWalletAddress (1.0.1):
- EthereumAddress
- TrustKeystore
- web3swift
- AlphaWalletCore (1.0.1)
@ -137,7 +138,6 @@ DEPENDENCIES:
- CocoaLumberjack (= 3.7.0)
- CryptoSwift (~> 1.4)
- EthereumABI (= 1.3.0)
- EthereumAddress (= 1.3.0)
- FloatingPanel
- iOSSnapshotTestCase (= 6.2.0)
- JSONRPCKit (~> 2.0.0)
@ -268,7 +268,7 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
Alamofire-Synchronous: eedf1e6e961c3795a63c74990b3f7d9fbfac7e50
AlphaWalletAddress: 1a9b66128e764472bcf97f334e0b3accec6e165d
AlphaWalletAddress: d742c9b77d0a798c6711de5c32b573e474b64d8e
AlphaWalletCore: f0dc8f3f6c6600b9419596b944deb4145f00f7e1
AlphaWalletENS: df3cb79a2def496f78b06a838d0a111528e473db
AlphaWalletWeb3Provider: 7ca1e1c1dc841dc1915f970daace48bf34931655
@ -318,6 +318,6 @@ SPEC CHECKSUMS:
web3swift: 06118d4c4edc801444aaa995bbbddeda176b97ef
xcbeautify: b2c6b50c9cab6414296898e94cd153e4ea879662
PODFILE CHECKSUM: e82a1d7ccab29ff427668269c80f4a8d5720381a
PODFILE CHECKSUM: 9113af2e2571299baf345600ebb01a26d5ded8d5
COCOAPODS: 1.11.2

@ -27,4 +27,5 @@ Pod::Spec.new do |s|
s.dependency 'TrustKeystore'
s.dependency 'web3swift'
s.dependency 'EthereumAddress'
end

@ -0,0 +1,15 @@
//
// EthereumAddressEthereumAddress+typealias.swift
// AlphaWalletAddress
//
// Created by Hwee-Boon Yar on Apr/10/22.
import EthereumAddress
typealias EthereumAddress_fromEthereumAddressPod = EthereumAddress
extension EthereumAddress: CustomStringConvertible {
public var description: String {
address
}
}

@ -14,6 +14,18 @@ extension AlphaWallet.Address {
self = .ethereumAddress(eip55String: address.eip55String)
}
public init?(possibleAddress: Any?) {
if let address = possibleAddress as? AlphaWallet.Address {
self = address
} else if let address = possibleAddress as? EthereumAddress_fromEthereumAddressPod {
self = .ethereumAddress(eip55String: address.address)
} else if let address = possibleAddress as? web3swift.EthereumAddress {
self = .ethereumAddress(eip55String: address.address)
} else {
return nil
}
}
public func sameContract(as contract: web3swift.EthereumAddress) -> Bool {
return eip55String == contract.address
}

Loading…
Cancel
Save