Skip to content

Commit

Permalink
Merge branch 'release/1.0.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
Foboz committed Mar 24, 2020
2 parents 9f81c16 + 8ab8435 commit 382d3b3
Show file tree
Hide file tree
Showing 45 changed files with 1,032 additions and 228 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### Release 1.0.14
ANNOUNCEMENT: Full-fledged MEW wallet app is now available!
You can now buy, hold and send Ether and tokens directly in the app, without having to connect to MEW web.

Upgrade your MEWconnect app in just a few taps: download MEW wallet app, it will automatically detect if you are already using MEWconnect and offer you to import your account.

Launch MEWconnect after this update for more details.
P. S. If you don't want to upgrade, you can continue using MEWconnect app.

Questions? Please reach out to us via support@myetherwallet.com

### Release 1.0.13
- Bugfixes

Expand Down
266 changes: 161 additions & 105 deletions MyEtherWallet-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@protocol MigrationService;
@protocol SecurityService;
@protocol WhatsNewService;
@protocol AnalyticsService;

@protocol ServiceComponents <NSObject>
- (id <MEWConnectFacade>) MEWConnectFacade;
Expand All @@ -42,4 +43,5 @@
- (id <MigrationService>) migrationService;
- (id <SecurityService>) securityService;
- (id <WhatsNewService>) whatsNewService;
- (id <AnalyticsService>) analyticsService;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#import "MigrationServiceImplementation.h"
#import "SecurityServiceImplementation.h"
#import "WhatsNewServiceImplementation.h"
#import "AnalyticsServiceImplementation.h"

#import "OperationSchedulerImplementation.h"

Expand Down Expand Up @@ -192,6 +193,16 @@ - (MEWconnectServiceStateMachine *) MEWconnectServiceStateMachine {
}];
}

- (id<AnalyticsService>)analyticsService {
return [TyphoonDefinition withClass:[AnalyticsServiceImplementation class]
configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(analyticsOperationFactory)
with:[self.operationFactoriesAssembly analyticsOperationFactory]];
[definition injectProperty:@selector(operationScheduler)
with:[self operationScheduler]];
}];
}

#pragma mark - Other Services

- (id <CameraService>) cameraServiceWithDelegate:(id <CameraServiceDelegate>)delegate {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// AnalyticsService.h
// MyEtherWallet-iOS
//
// Created by Mikhail Nikanorov on 3/10/20.
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved.
//

@import Foundation;

@protocol AnalyticsService <NSObject>
- (void) trackBannerShown;
- (void) trackBannerClicked;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// AnalyticsServiceImplementation.h
// MyEtherWallet-iOS
//
// Created by Mikhail Nikanorov on 3/10/20.
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved.
//

#import "AnalyticsService.h"

@class AnalyticsOperationFactory;
@protocol OperationScheduler;

NS_ASSUME_NONNULL_BEGIN

@interface AnalyticsServiceImplementation : NSObject <AnalyticsService>
@property (nonatomic, strong) AnalyticsOperationFactory *analyticsOperationFactory;
@property (nonatomic, strong) id <OperationScheduler> operationScheduler;
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// AnalyticsServiceImplementation.m
// MyEtherWallet-iOS
//
// Created by Mikhail Nikanorov on 3/10/20.
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved.
//

@import CoreTelephony;

#import "AnalyticsServiceImplementation.h"

#import "OperationScheduler.h"
#import "CompoundOperationBase.h"

#import "AnalyticsOperationFactory.h"

#import "AnalyticsQuery.h"
#import "AnalyticsBody.h"

@interface AnalyticsServiceImplementation ()
@property (nonatomic, strong) NSString *iso;
@end

@implementation AnalyticsServiceImplementation

- (void) trackBannerShown {
AnalyticsQuery *query = [self _obtainQuery];
AnalyticsBody *body = [self _obtainBodyWithEvent:@"iOS-MEWconnectApp-Banner-shown"];

CompoundOperationBase *compoundOperation = [self.analyticsOperationFactory analyticsWithQuery:query body:body];
[self.operationScheduler addOperation:compoundOperation];
}

- (void) trackBannerClicked {
AnalyticsQuery *query = [self _obtainQuery];
AnalyticsBody *body = [self _obtainBodyWithEvent:@"iOS-MEWconnectApp-Banner-FreeUpgrade-clicked"];

CompoundOperationBase *compoundOperation = [self.analyticsOperationFactory analyticsWithQuery:query body:body];
[self.operationScheduler addOperation:compoundOperation];
}

#pragma mark - Private

- (AnalyticsQuery *) _obtainQuery {
AnalyticsQuery *query = [[AnalyticsQuery alloc] init];
query.iso = self.iso;
return query;
}

- (AnalyticsBody *) _obtainBodyWithEvent:(NSString *)event {
AnalyticsBody *body = [[AnalyticsBody alloc] init];

NSISO8601DateFormatter *dateFormatter = [[NSISO8601DateFormatter alloc] init];
dateFormatter.formatOptions = NSISO8601DateFormatWithFullDate | NSISO8601DateFormatWithFullTime;
if (@available(iOS 11.0, *)) {
dateFormatter.formatOptions |= NSISO8601DateFormatWithFractionalSeconds;
}

NSString *timestamp = [dateFormatter stringFromDate:[NSDate date]];
if (@available(iOS 11.0, *)) {
//do nothing
} else {
if ([timestamp length] > 1) {
NSMutableString *timestampWithFractionalSeconds = [timestamp mutableCopy];
[timestampWithFractionalSeconds insertString:@".000" atIndex:[timestamp length] - 1];
timestamp = [timestampWithFractionalSeconds copy];
}
}

body.events = @[
@{
@"id": event,
@"timestamp": timestamp
}
];
return body;
}

#pragma mark - Override

- (NSString *)iso {
if (!_iso) {
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = networkInfo.subscriberCellularProvider;
NSString *cellularISO = carrier.isoCountryCode.lowercaseString;
if ([cellularISO length] > 0) {
_iso = cellularISO;
return _iso;
}

NSString *localeISO = [[NSLocale currentLocale] countryCode].lowercaseString;
if ([localeISO length] > 0) {
_iso = localeISO;
return _iso;
}

_iso = @"__";
}
return _iso;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@class AccountsOperationFactory;
@class FiatPricesOperationFactory;
@class SimplexOperationFactory;
@class AnalyticsOperationFactory;

@interface OperationFactoriesAssembly : TyphoonAssembly <RamblerInitialAssembly>
@property (nonatomic, strong, readonly) TyphoonAssembly <RequestConfiguratorsFactory> *requestConfiguratorsFactory;
Expand All @@ -33,5 +34,6 @@
- (TokensOperationFactory *) tokensOperationFactory;
- (FiatPricesOperationFactory *) fiatPricesOperationFactory;
- (SimplexOperationFactory *) simplexOperationFactory;
- (AnalyticsOperationFactory *) analyticsOperationFactory;
@end

Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@
#import "QueryTransformerBase.h"
#import "FiatPricesQueryTransformer.h"
#import "SimplexQueryTransformer.h"
#import "AnalyticsQueryTransformer.h"

#import "BodyTransformerBase.h"
#import "TokensBodyTransformer.h"
#import "SimplexBodyTransformer.h"
#import "AnalyticsBodyTransformer.h"

#import "HeadersBuilderBase.h"
#import "SimplexHeadersBuilder.h"

#import "TokensOperationFactory.h"
#import "FiatPricesOperationFactory.h"
#import "SimplexOperationFactory.h"
#import "AnalyticsOperationFactory.h"

static NSString *const kConfigFileName = @"HeadersConfig.plist";

Expand Down Expand Up @@ -73,6 +76,19 @@ - (SimplexOperationFactory *) simplexOperationFactory {
}];
}

- (AnalyticsOperationFactory *) analyticsOperationFactory {
return [TyphoonDefinition withClass:[AnalyticsOperationFactory class]
configuration:^(TyphoonDefinition *definition) {
[definition useInitializer:@selector(initWithBuilder:queryTransformer:bodyTransformer:headersBuilder:)
parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:[self networkOperationBuilder]];
[initializer injectParameterWith:[self analyticsQueryTransformer]];
[initializer injectParameterWith:[self analyticsBodyTransformer]];
[initializer injectParameterWith:[self headersBuilder]];
}];
}];
}

#pragma mark - Builders

- (NetworkCompoundOperationBuilder *) networkOperationBuilder
Expand Down Expand Up @@ -118,6 +134,10 @@ - (SimplexQueryTransformer *) simplexQueryTransformer {
return [TyphoonDefinition withClass:[SimplexQueryTransformer class]];
}

- (AnalyticsQueryTransformer *) analyticsQueryTransformer {
return [TyphoonDefinition withClass:[AnalyticsQueryTransformer class]];
}

#pragma mark - Body Transformers

- (TokensBodyTransformer *) contractsBodyTransformer {
Expand All @@ -132,6 +152,10 @@ - (SimplexBodyTransformer *) simplexBodyTransformer {
return [TyphoonDefinition withClass:[SimplexBodyTransformer class]];
}

- (AnalyticsBodyTransformer *) analyticsBodyTransformer {
return [TyphoonDefinition withClass:[AnalyticsBodyTransformer class]];
}

#pragma mark - Headers Builders

- (HeadersBuilderBase *) headersBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<string>NSURL(https://cryptorates.mewapi.io)</string>
<key>SimplexAPIURL</key>
<string>NSURL(https://apiccswap.myetherwallet.com)</string>
<key>AnalyticsURL</key>
<string>NSURL(https://api.myetherwallet.com)</string>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

#import "RESTRequestConfigurator.h"

static NSString *const kConfigFileName = @"MEWconnect.API.plist";
static NSString *const kConfigFileName = @"MEWconnect.API.plist";

static NSString *const kNodeURLKey = @"API.NodeURL";
static NSString *const kTickerURLKey = @"API.TickerURL";
static NSString *const kSimplexAPIURLKey = @"API.SimplexAPIURL";
static NSString *const kNodeURLKey = @"API.NodeURL";
static NSString *const kTickerURLKey = @"API.TickerURL";
static NSString *const kSimplexAPIURLKey = @"API.SimplexAPIURL";
static NSString *const kAnalyticsAPIURLKey = @"API.AnalyticsURL";

@implementation RequestConfiguratorsAssembly

Expand All @@ -34,6 +35,8 @@ @implementation RequestConfiguratorsAssembly
use:[self simplexAPIRequestConfigurator]];
[matcher caseEqual:@(RequestConfigurationSimplexWebType)
use:[self simplexWebRequestConfiguratorWithURL:url]];
[matcher caseEqual:@(RequestConfigurationAnalyticsType)
use:[self analyticsRequestConfigurator]];
}];
}

Expand Down Expand Up @@ -73,6 +76,15 @@ @implementation RequestConfiguratorsAssembly
}];
}

- (id<RequestConfigurator>) analyticsRequestConfigurator {
return [TyphoonDefinition withClass:[RESTRequestConfigurator class] configuration:^(TyphoonDefinition *definition) {
[definition useInitializer:@selector(initWithBaseURL:apiPath:) parameters:^(TyphoonMethod *initializer) {
[initializer injectParameterWith:TyphoonConfig(kAnalyticsAPIURLKey)];
[initializer injectParameterWith:nil];
}];
}];
}

#pragma mark - Config

- (id)configurer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ static NSString *const kServiceNameQuote = @"quote";
static NSString *const kServiceNameOrder = @"order";
static NSString *const kServiceNameStatus = @"status";

static NSString *const kServiceNameAnalytics = @"analytics/record/ios";

#endif /* ServiceNameConstants_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AnalyticsBodyTransformer.h
// MyEtherWallet-iOS
//
// Created by Mikhail Nikanorov on 3/10/20.
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved.
//

#import "BodyTransformerBase.h"

@interface AnalyticsBodyTransformer : BodyTransformerBase

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// AnalyticsBodyTransformer.m
// MyEtherWallet-iOS
//
// Created by Mikhail Nikanorov on 3/10/20.
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved.
//

#import "AnalyticsBodyTransformer.h"
#import "AnalyticsBody.h"

static NSString *const kAnalyticsBodyEventKey = @"events";

@implementation AnalyticsBodyTransformer

- (NSData *)deriveDataFromBody:(AnalyticsBody *)body {
return [NSJSONSerialization dataWithJSONObject:@{kAnalyticsBodyEventKey: body.events} options:0 error:nil];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AnalyticsQueryTransformer.h
// MyEtherWallet-iOS
//
// Created by Mikhail Nikanorov on 3/10/20.
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved.
//

#import "QueryTransformerBase.h"

@interface AnalyticsQueryTransformer : QueryTransformerBase

@end
Loading

0 comments on commit 382d3b3

Please sign in to comment.