Skip to content

Commit

Permalink
gh-2573 Restrict entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Bespalov committed Sep 8, 2022
1 parent 7a978ea commit ef74e3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
6 changes: 6 additions & 0 deletions Multisig/Data/ClaimingAppController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class ClaimingAppController {
claimingService = App.shared.claimingService
}

static func isAvailable(chain: Chain) -> Bool {
let isChainSupported = chain.id == Chain.ChainID.ethereumRinkeby || chain.id == Chain.ChainID.ethereumMainnet
let isEnabledInConfig = NSString(string: FirebaseRemoteConfig.shared.value(key: .safeClaimEnabled) ?? "false").boolValue
return isChainSupported && isEnabledInConfig
}

// MARK: - Static data

func guardians(completion: @escaping (Result<[Guardian], Error>) -> Void) -> URLSessionTask? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,8 @@ final class HeaderViewController: ContainerViewController {
currentDataTask?.cancel()
do {
guard let safe = try Safe.getSelected() else { return }
var claimableAmountValue: String?
if safe.addressValue != Address(exactly: "0xfF501B324DC6d78dC9F983f140B9211c3EdB4dc7") {
// TODO: Get actual value instead of 0 always
claimableAmountValue = "0"
}

safeBarView.set(safeTokenClaimable: true)
safeBarView.set(safeTokenClaimable: ClaimingAppController.isAvailable(chain: safe.chain!))

currentDataTask = clientGatewayService.asyncSafeInfo(safeAddress: safe.addressValue,
chainId: safe.chain!.id!) { [weak self] result in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ class BalancesViewController: LoadableViewController, UITableViewDelegate, UITab
guard let safe = try? Safe.getSelected() else {
return false
}
return safeTokenBannerWasShown != true &&
// claim possible only on mainnet or rinkeby (for testing)
(safe.chain?.id == Chain.ChainID.ethereumMainnet || safe.chain?.id == Chain.ChainID.ethereumRinkeby) &&
// claim flag has to be enabled in Firebase Remote Config
NSString(string: remoteConfig.value(key: .safeClaimEnabled) ?? "false").boolValue
return safeTokenBannerWasShown != true && ClaimingAppController.isAvailable(chain: safe.chain!)
}

private var safeTokenBannerWasShown: Bool? {
Expand Down Expand Up @@ -240,12 +236,11 @@ class BalancesViewController: LoadableViewController, UITableViewDelegate, UITab
let cell = tableView.dequeueCell(SafeTokenBannerTableViewCell.self, for: indexPath)
cell.setupBanner(
onClaim: { [unowned self] in
//TODO: start safe token claim flow
guard let safe = try? Safe.getSelected() else {
return
}

//safeTokenBannerWasShown = true
safeTokenBannerWasShown = true
Tracker.trackEvent(.bannerSafeTokenClaim)
claimTokenFlow = ClaimSafeTokenFlow(safe: safe) { [unowned self] _ in
claimTokenFlow = nil
Expand Down
20 changes: 10 additions & 10 deletions Multisig/UI/UI Library/Views/ClaimableAmountView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clipsSubviews="YES" contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="82" height="83"/>
<rect key="frame" x="0.0" y="0.0" width="83" height="83"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ico-safe-token-logo" translatesAutoresizingMaskIntoConstraints="NO" id="art-Vr-paJ">
<rect key="frame" x="8" y="8" width="67" height="67"/>
<color key="tintColor" name="primary"/>
<constraints>
<constraint firstAttribute="width" secondItem="art-Vr-paJ" secondAttribute="height" id="pDB-En-Law"/>
<constraint firstAttribute="width" secondItem="art-Vr-paJ" secondAttribute="height" multiplier="1:1" id="pzi-11-ReT"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wmn-K2-4m6">
<rect key="frame" x="0.0" y="0.0" width="82" height="83"/>
<rect key="frame" x="0.0" y="0.0" width="83" height="83"/>
<connections>
<action selector="claimButtonTouched:" destination="-1" eventType="touchUpInside" id="U8B-E7-Ahi"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" name="backgroundTetriary"/>
<color key="backgroundColor" name="backgroundPrimary"/>
<constraints>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="Wmn-K2-4m6" secondAttribute="trailing" id="2X8-tF-vPp"/>
<constraint firstAttribute="trailing" secondItem="Wmn-K2-4m6" secondAttribute="trailing" id="2X8-tF-vPp"/>
<constraint firstItem="art-Vr-paJ" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="8" id="6xT-Vs-XA6"/>
<constraint firstAttribute="trailing" secondItem="art-Vr-paJ" secondAttribute="trailing" constant="8" id="RH5-ts-hjv"/>
<constraint firstAttribute="bottom" secondItem="Wmn-K2-4m6" secondAttribute="bottom" id="V8D-YK-Jjb"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="leading" secondItem="Wmn-K2-4m6" secondAttribute="leading" id="cbD-6U-2WS"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="art-Vr-paJ" secondAttribute="bottom" constant="8" id="dqQ-PT-q4X"/>
<constraint firstAttribute="leading" secondItem="Wmn-K2-4m6" secondAttribute="leading" id="cbD-6U-2WS"/>
<constraint firstAttribute="bottom" secondItem="art-Vr-paJ" secondAttribute="bottom" constant="8" id="dqQ-PT-q4X"/>
<constraint firstAttribute="top" secondItem="Wmn-K2-4m6" secondAttribute="top" id="jeh-fq-iD1"/>
<constraint firstItem="art-Vr-paJ" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="8" id="urH-h5-nPo"/>
</constraints>
Expand All @@ -50,9 +50,9 @@
</view>
</objects>
<resources>
<image name="ico-safe-token-logo" width="16" height="16"/>
<namedColor name="backgroundTetriary">
<color red="0.93333333333333335" green="0.93725490196078431" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<image name="ico-safe-token-logo" width="662" height="662"/>
<namedColor name="backgroundPrimary">
<color red="0.96470588235294119" green="0.96862745098039216" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="primary">
<color red="0.0" green="0.54509803921568623" blue="0.45098039215686275" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down

0 comments on commit ef74e3b

Please sign in to comment.