Skip to content

Commit

Permalink
Add promotion id to iOS ClaimPromotion wrapper method
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson authored and NejcZdovc committed May 10, 2020
1 parent 58b4231 commit 435dd91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion vendor/brave-ios/Ledger/BATBraveLedger.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ NS_SWIFT_NAME(BraveLedger)

- (void)fetchPromotions:(nullable void (^)(NSArray<BATPromotion *> *grants))completion;

- (void)claimPromotion:(NSString *)deviceCheckPublicKey
- (void)claimPromotion:(NSString *)promotionId
publicKey:(NSString *)deviceCheckPublicKey
completion:(void (^)(BATResult result, NSString * _Nonnull nonce))completion;

- (void)attestPromotion:(NSString *)promotionId
Expand Down
5 changes: 2 additions & 3 deletions vendor/brave-ios/Ledger/BATBraveLedger.mm
Original file line number Diff line number Diff line change
Expand Up @@ -941,17 +941,16 @@ - (void)fetchPromotions:(nullable void (^)(NSArray<BATPromotion *> *grants))comp
});
}

- (void)claimPromotion:(NSString *)deviceCheckPublicKey completion:(void (^)(BATResult result, NSString * _Nonnull nonce))completion
- (void)claimPromotion:(NSString *)promotionId publicKey:(NSString *)deviceCheckPublicKey completion:(void (^)(BATResult result, NSString * _Nonnull nonce))completion
{
const auto payload = [NSDictionary dictionaryWithObject:deviceCheckPublicKey forKey:@"publicKey"];
const auto jsonData = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil];
if (!jsonData) {
BLOG(ledger::LogLevel::LOG_ERROR) << "Missing JSON payload while attempting to claim promotion" << std::endl;
return;
}
// TODO we need to put promotion id in
const auto jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
ledger->ClaimPromotion(jsonString.UTF8String, ^(const ledger::Result result, const std::string& json) {
ledger->ClaimPromotion(promotionId.UTF8String, jsonString.UTF8String, ^(const ledger::Result result, const std::string& json) {
const auto jsonData = [[NSString stringWithUTF8String:json.c_str()] dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *nonce = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
Expand Down

0 comments on commit 435dd91

Please sign in to comment.