Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

No Bug: Update Rewards native libraries and add dev environment support #1761

Merged
merged 1 commit into from
Oct 23, 2019
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
Binary file modified BraveRewards/BraveRewards.framework/BraveRewards
Binary file not shown.
5 changes: 3 additions & 2 deletions BraveRewards/BraveRewards.framework/Headers/BATBraveAds.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ NS_SWIFT_NAME(BraveAds)

/// Whether or not to use staging servers. Defaults to false
@property (nonatomic, class, getter=isDebug) BOOL debug;
/// Whether or not to use production servers. Defaults to true
@property (nonatomic, class, getter=isProduction) BOOL production;
/// The environment that ads is communicating with. See ledger's BATEnvironment
/// for appropriate values.
@property (nonatomic, class) int environment;
/// Marks if this is being ran in a test environment. Defaults to false
@property (nonatomic, class, getter=isTesting) BOOL testing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ NS_SWIFT_NAME(BraveLedger)

/// Whether or not to use staging servers. Defaults to false
@property (nonatomic, class, getter=isDebug) BOOL debug;
/// Whether or not to use production servers. Defaults to true
@property (nonatomic, class, getter=isProduction) BOOL production;
/// The environment that ledger is communicating with
@property (nonatomic, class) BATEnvironment environment;
/// Marks if this is being ran in a test environment. Defaults to false
@property (nonatomic, class, getter=isTesting) BOOL testing;
/// Number of minutes between reconciles override. Defaults to 0 (no override)
Expand Down
17 changes: 11 additions & 6 deletions BraveRewards/BraveRewards.framework/Headers/BATBraveRewards.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ NS_SWIFT_NAME(BraveRewardsConfiguration)

/// Whether or not rewards is being tested
@property (nonatomic, getter=isTesting) BOOL testing;
/// Whether or not rewards is in production
@property (nonatomic, getter=isProduction) BOOL production;
//@property (nonatomic, getter=isDebug) BOOL debug;
/// The rewards environment
@property (nonatomic) BATEnvironment environment;
/// Where ledger and ads should save their state
@property (nonatomic, copy) NSString *stateStoragePath;
/// The number of seconds between overrides. Defaults to 0 (no override) which means reconciles
Expand All @@ -25,16 +26,20 @@ NS_SWIFT_NAME(BraveRewardsConfiguration)
/// Whether or not to enable short retries between contribution attempts
@property (nonatomic) BOOL useShortRetries;

/// The default configuration. Channel is debug, no changes to ledger configuration
/// The default configuration. Environment is dev, no changes to ledger configuration
///
/// State is stored in Application Support
@property (nonatomic, class, readonly) BATBraveRewardsConfiguration *defaultConfiguration NS_SWIFT_NAME(default);
/// The production configuration. Channel is production, no changes to ledger configuration
/// The staging configuration. Environment is staging, no changes to ledger configuration
///
/// State is stored in Application Support
@property (nonatomic, class, readonly) BATBraveRewardsConfiguration *stagingConfiguration NS_SWIFT_NAME(staging);
/// The production configuration. Environment is production, no changes to ledger configuration
///
/// State is stored in Application Support
@property (nonatomic, class, readonly) BATBraveRewardsConfiguration *productionConfiguration NS_SWIFT_NAME(production);
/// The testing configuration. Channel is debug & testing. Short retries are enabled, number of
/// seconds between reconciles is set to 30 seconds instead of 30 days.
/// The testing configuration. Environment is development & is_testing is set to true. Short retries are enabled,
/// number of seconds between reconciles is set to 30 seconds instead of 30 days.
///
/// State is saved to a directory created in /tmp
@property (nonatomic, class, readonly) BATBraveRewardsConfiguration *testingConfiguration NS_SWIFT_NAME(testing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,15 @@ typedef NS_ENUM(NSInteger, BATWalletStatus) {
} NS_SWIFT_NAME(WalletStatus);


typedef NS_ENUM(NSInteger, BATEnvironment) {
BATEnvironmentStaging = 0,
BATEnvironmentProduction = 1,
BATEnvironmentDevelopment = 2,
} NS_SWIFT_NAME(Environment);

@class BATContributionInfo, BATPublisherInfo, BATPublisherBanner, BATPendingContribution, BATPendingContributionInfo, BATVisitData, BATGrant, BATWalletProperties, BATBalance, BATAutoContributeProps, BATMediaEventInfo, BATExternalWallet, BATBalanceReportInfo, BATActivityInfoFilterOrderPair, BATActivityInfoFilter, BATReconcileInfo, BATRewardsInternalsInfo, BATServerPublisherInfo, BATTransferFee;


@class BATContributionInfo, BATPublisherInfo, BATPublisherBanner, BATPendingContribution, BATPendingContributionInfo, BATVisitData, BATGrant, BATWalletProperties, BATBalance, BATAutoContributeProps, BATMediaEventInfo, BATExternalWallet, BATBalanceReportInfo, BATActivityInfoFilterOrderPair, BATActivityInfoFilter, BATReconcileInfo, BATRewardsInternalsInfo, BATServerPublisherInfo, BATTransferFee, BATContributionQueue, BATContributionQueuePublisher;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -336,4 +343,19 @@ NS_SWIFT_NAME(TransferFee)
@property (nonatomic) uint32_t executionId;
@end

NS_SWIFT_NAME(ContributionQueue)
@interface BATContributionQueue : NSObject <NSCopying>
@property (nonatomic) uint64_t id;
@property (nonatomic) BATRewardsType type;
@property (nonatomic) double amount;
@property (nonatomic) bool partial;
@property (nonatomic, copy) NSArray<BATContributionQueuePublisher *> * publishers;
@end

NS_SWIFT_NAME(ContributionQueuePublisher)
@interface BATContributionQueuePublisher : NSObject <NSCopying>
@property (nonatomic, copy) NSString * publisherKey;
@property (nonatomic) double amountPercent;
@end

NS_ASSUME_NONNULL_END
Binary file modified BraveRewards/BraveRewards.framework/Model.momd/Model.mom
Binary file not shown.
Binary file modified BraveRewards/BraveRewards.framework/Model.momd/VersionInfo.plist
Binary file not shown.
11 changes: 9 additions & 2 deletions BraveRewardsUI/QA Settings/QASettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class QASettingsViewController: TableViewController {
fatalError()
}

private let segmentedControl = UISegmentedControl(items: EnvironmentOverride.allCases.map { $0.name })
private let segmentedControl = UISegmentedControl(items: EnvironmentOverride.sortedCases.map { $0.name })

@objc private func environmentChanged() {
let value = segmentedControl.selectedSegmentIndex
Expand Down Expand Up @@ -168,7 +168,14 @@ public class QASettingsViewController: TableViewController {
}

@objc private func tappedRestoreWallet() {
let environment = BraveLedger.isProduction ? "production" : "staging"
let environment: String = {
switch BraveLedger.environment {
case .production: return "production"
case .staging: return "staging"
case .development: return "development"
default: return "(unknown)"
}
}()
let alert = UIAlertController(title: "Restore Wallet", message: "Enter the recovery key for the wallet (must be a \(environment) wallet). Your existing wallet will be overwritten.", preferredStyle: .alert)
alert.addTextField { textField in
textField.returnKeyType = .done
Expand Down
4 changes: 2 additions & 2 deletions BraveRewardsUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ A UI framework for consuming Brave Rewards. The core logic around BraveRewards r
The latest BraveRewards.framework was built on:

```
brave-browser/51350aa972b4df31081360db71bc7cb4f36275b7
brave-core/dc5776e4409cf53d2a19357d8a546f59a961ceaa
brave-browser/61bfb8840c2cfa2b0dd9d9443198470d8c2849c0
brave-core/aa7d1dc81fe055b05f75b606817bed2a209a689f
```
8 changes: 7 additions & 1 deletion BraveShared/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,24 @@ extension Preferences {
public static let myFirstAdShown = Option<Bool>(key: "rewards.ads.my-first-ad-shown", default: false)
public static let hideRewardsIcon = Option<Bool>(key: "rewards.hide-rewards-icon", default: false)

public enum EnvironmentOverride: Int, CaseIterable {
public enum EnvironmentOverride: Int {
case none
case staging
case prod
case dev

public var name: String {
switch self {
case .none: return "None"
case .staging: return "Staging"
case .prod: return "Prod"
case .dev: return "Dev"
}
}

public static var sortedCases: [EnvironmentOverride] {
return [.none, .dev, .staging, .prod]
}
}
/// In debug/beta, this is the overriden environment.
public static let environmentOverride = Option<Int>(key: "rewards.environment-override",
Expand Down
13 changes: 11 additions & 2 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,18 @@ class BrowserViewController: UIViewController {
configuration = .production
} else {
if let override = Preferences.Rewards.EnvironmentOverride(rawValue: Preferences.Rewards.environmentOverride.value), override != .none {
configuration = override == .prod ? .production : .default
switch override {
case .dev:
configuration = .default
case .staging:
configuration = .staging
case .prod:
configuration = .production
default:
configuration = .staging
}
} else {
configuration = AppConstants.BuildChannel == .developer ? .default : .production
configuration = AppConstants.BuildChannel == .developer ? .staging : .production
}
}
rewards = BraveRewards(configuration: configuration)
Expand Down