Skip to content

Commit 24ac8ba

Browse files
committed
Consume new signature
1 parent b019050 commit 24ac8ba

File tree

8 files changed

+342
-429
lines changed

8 files changed

+342
-429
lines changed

OpacityCore/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies {
5656
implementation libs.material
5757
implementation libs.geckoview.nightly
5858
implementation libs.androidx.security.crypto
59+
implementation libs.kotlinx.serialization.json
5960
testImplementation libs.junit
6061
androidTestImplementation libs.androidx.junit
6162
androidTestImplementation libs.androidx.espresso.core

OpacityCore/src/main/cpp/OpacityCore.cpp

Lines changed: 187 additions & 241 deletions
Large diffs are not rendered by default.

OpacityCore/src/main/java/com/opacitylabs/opacitycore/OpacityCore.kt

Lines changed: 128 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
77
import kotlinx.coroutines.Dispatchers
88
import kotlinx.coroutines.withContext
99
import org.mozilla.geckoview.GeckoRuntime
10+
import kotlinx.serialization.*
11+
import kotlinx.serialization.json.*
1012

1113
object OpacityCore {
1214
enum class Environment {
@@ -76,170 +78,139 @@ object OpacityCore {
7678
LocalBroadcastManager.getInstance(appContext).sendBroadcast(closeIntent)
7779
}
7880

79-
suspend fun getUberRiderProfile(): OpacityResponse {
80-
return withContext(Dispatchers.IO) { getUberRiderProfileNative() }
81-
}
82-
83-
suspend fun getUberRiderTripHistory(cursor: String): OpacityResponse {
84-
return withContext(Dispatchers.IO) { getUberRiderTripHistoryNative(cursor) }
85-
}
86-
87-
suspend fun getUberRiderTrip(id: String): OpacityResponse {
88-
return withContext(Dispatchers.IO) { getUberRiderTripNative(id) }
89-
}
90-
91-
suspend fun getUberDriverProfile(): OpacityResponse {
92-
return withContext(Dispatchers.IO) { getUberDriverProfileNative() }
93-
}
94-
95-
suspend fun getUberDriverTrips(
96-
startDate: String,
97-
endDate: String,
98-
cursor: String
99-
): OpacityResponse {
100-
return withContext(Dispatchers.IO) { getUberDriverTripsNative(startDate, endDate, cursor) }
101-
}
102-
103-
suspend fun getRedditAccount(): OpacityResponse {
104-
return withContext(Dispatchers.IO) { getRedditAccountNative() }
105-
}
106-
107-
suspend fun getRedditFollowedSubreddits(): OpacityResponse {
108-
return withContext(Dispatchers.IO) { getRedditFollowedSubredditsNative() }
109-
}
110-
111-
suspend fun getRedditComments(): OpacityResponse {
112-
return withContext(Dispatchers.IO) { getRedditCommentsNative() }
113-
}
114-
115-
suspend fun getRedditPosts(): OpacityResponse {
116-
return withContext(Dispatchers.IO) { getRedditPostsNative() }
117-
}
118-
119-
suspend fun getZabkaAccount(): OpacityResponse {
120-
return withContext(Dispatchers.IO) { getZabkaAccountNative() }
121-
}
122-
123-
suspend fun getZabkaPoints(): OpacityResponse {
124-
return withContext(Dispatchers.IO) { getZabkaPointsNative() }
125-
}
126-
127-
private external fun init(apiKey: String, dryRun: Boolean): Int
128-
suspend fun getCartaProfile(): OpacityResponse {
129-
return withContext(Dispatchers.IO) { getCartaProfileNative() }
130-
}
131-
132-
suspend fun getCartaOrganizations(): OpacityResponse {
133-
return withContext(Dispatchers.IO) { getCartaOrganizationsNative() }
134-
}
135-
136-
suspend fun getCartaPortfolioInvestments(firmId: String, accountId: String): OpacityResponse {
137-
return withContext(Dispatchers.IO) { getCartaPortfolioInvestmentsNative(firmId, accountId) }
138-
}
139-
140-
suspend fun getCartaHoldingsCompanies(accountId: String): OpacityResponse {
141-
return withContext(Dispatchers.IO) { getCartaHoldingsCompaniesNative(accountId) }
142-
}
143-
144-
suspend fun getCartaCorporationSecurities(
145-
accountId: String,
146-
corporationId: String
147-
): OpacityResponse {
81+
// suspend fun getRedditAccount(): OpacityResponse {
82+
// return withContext(Dispatchers.IO) { getRedditAccountNative() }
83+
// }
84+
//
85+
// suspend fun getRedditFollowedSubreddits(): OpacityResponse {
86+
// return withContext(Dispatchers.IO) { getRedditFollowedSubredditsNative() }
87+
// }
88+
//
89+
// suspend fun getRedditComments(): OpacityResponse {
90+
// return withContext(Dispatchers.IO) { getRedditCommentsNative() }
91+
// }
92+
//
93+
// suspend fun getRedditPosts(): OpacityResponse {
94+
// return withContext(Dispatchers.IO) { getRedditPostsNative() }
95+
// }
96+
//
97+
// suspend fun getZabkaAccount(): OpacityResponse {
98+
// return withContext(Dispatchers.IO) { getZabkaAccountNative() }
99+
// }
100+
//
101+
// suspend fun getZabkaPoints(): OpacityResponse {
102+
// return withContext(Dispatchers.IO) { getZabkaPointsNative() }
103+
// }
104+
//
105+
// private external fun init(apiKey: String, dryRun: Boolean): Int
106+
// suspend fun getCartaProfile(): OpacityResponse {
107+
// return withContext(Dispatchers.IO) { getCartaProfileNative() }
108+
// }
109+
//
110+
// suspend fun getCartaOrganizations(): OpacityResponse {
111+
// return withContext(Dispatchers.IO) { getCartaOrganizationsNative() }
112+
// }
113+
//
114+
// suspend fun getCartaPortfolioInvestments(firmId: String, accountId: String): OpacityResponse {
115+
// return withContext(Dispatchers.IO) { getCartaPortfolioInvestmentsNative(firmId, accountId) }
116+
// }
117+
//
118+
// suspend fun getCartaHoldingsCompanies(accountId: String): OpacityResponse {
119+
// return withContext(Dispatchers.IO) { getCartaHoldingsCompaniesNative(accountId) }
120+
// }
121+
//
122+
// suspend fun getCartaCorporationSecurities(
123+
// accountId: String,
124+
// corporationId: String
125+
// ): OpacityResponse {
126+
// return withContext(Dispatchers.IO) {
127+
// getCartaCorporationSecuritiesNative(
128+
// accountId,
129+
// corporationId
130+
// )
131+
// }
132+
// }
133+
//
134+
// suspend fun getGithubProfile(): OpacityResponse {
135+
// return withContext(Dispatchers.IO) { getGithubProfileNative() }
136+
// }
137+
//
138+
// suspend fun getInstagramProfile(): OpacityResponse {
139+
// return withContext(Dispatchers.IO) { getInstagramProfileNative() }
140+
// }
141+
//
142+
// suspend fun getInstagramLikes(): OpacityResponse {
143+
// return withContext(Dispatchers.IO) { getInstagramLikesNative() }
144+
// }
145+
//
146+
// suspend fun getInstagramComments(): OpacityResponse {
147+
// return withContext(Dispatchers.IO) { getInstagramCommentsNative() }
148+
// }
149+
//
150+
// suspend fun getInstagramSavedPosts(): OpacityResponse {
151+
// return withContext(Dispatchers.IO) { getInstagramSavedPostsNative() }
152+
// }
153+
//
154+
// suspend fun getGustoMembersTable(): OpacityResponse {
155+
// return withContext(Dispatchers.IO) { getGustoMembersTableNative() }
156+
// }
157+
//
158+
// suspend fun getGustoPayrollAdminId(): OpacityResponse {
159+
// return withContext(Dispatchers.IO) { getGustoPayrollAdminIdNative() }
160+
// }
161+
162+
suspend fun get(name: String, params: Map<String, Any>?): Map<String, Any> {
148163
return withContext(Dispatchers.IO) {
149-
getCartaCorporationSecuritiesNative(
150-
accountId,
151-
corporationId
152-
)
164+
val paramsString = params?.let { Json.encodeToString(it) }
165+
val res = getNative(name, paramsString)
166+
if(res.status != 0) {
167+
throw Exception(res.err)
168+
}
169+
170+
val map: Map<String, JsonElement> = Json.parseToJsonElement(res.data!!).jsonObject.toMap()
171+
map
153172
}
154173
}
155174

156-
suspend fun getGithubProfile(): OpacityResponse {
157-
return withContext(Dispatchers.IO) { getGithubProfileNative() }
158-
}
159-
160-
suspend fun getInstagramProfile(): OpacityResponse {
161-
return withContext(Dispatchers.IO) { getInstagramProfileNative() }
162-
}
163-
164-
suspend fun getInstagramLikes(): OpacityResponse {
165-
return withContext(Dispatchers.IO) { getInstagramLikesNative() }
166-
}
167-
168-
suspend fun getInstagramComments(): OpacityResponse {
169-
return withContext(Dispatchers.IO) { getInstagramCommentsNative() }
170-
}
171-
172-
suspend fun getInstagramSavedPosts(): OpacityResponse {
173-
return withContext(Dispatchers.IO) { getInstagramSavedPostsNative() }
174-
}
175-
176-
suspend fun getGustoMembersTable(): OpacityResponse {
177-
return withContext(Dispatchers.IO) { getGustoMembersTableNative() }
178-
}
179-
180-
suspend fun getGustoPayrollAdminId(): OpacityResponse {
181-
return withContext(Dispatchers.IO) { getGustoPayrollAdminIdNative() }
182-
}
183-
184-
suspend fun get(name: String, params: String?): OpacityResponse {
185-
return withContext(Dispatchers.IO) { getNative(name, params) }
186-
}
187-
188175
private external fun init(apiKey: String, dryRun: Boolean, environment: Int): Int
189176

190177
private external fun getNative(name: String, params: String?): OpacityResponse
191178

192179
external fun emitWebviewEvent(eventJson: String)
193-
private external fun getUberFareEstimate(
194-
pickupLatitude: Double,
195-
pickupLongitude: Double,
196-
destinationLatitude: Double,
197-
destinationLongitude: Double
198-
): OpacityResponse
199-
200-
private external fun getUberRiderProfileNative(): OpacityResponse
201-
private external fun getUberRiderTripHistoryNative(cursor: String): OpacityResponse
202-
private external fun getUberRiderTripNative(id: String): OpacityResponse
203-
private external fun getUberDriverProfileNative(): OpacityResponse
204-
private external fun getUberDriverTripsNative(
205-
startDate: String,
206-
endDate: String,
207-
cursor: String
208-
): OpacityResponse
209-
210-
private external fun getRedditAccountNative(): OpacityResponse
211-
private external fun getRedditFollowedSubredditsNative(): OpacityResponse
212-
private external fun getRedditCommentsNative(): OpacityResponse
213-
private external fun getRedditPostsNative(): OpacityResponse
214-
215-
// Zabka
216-
private external fun getZabkaAccountNative(): OpacityResponse
217-
private external fun getZabkaPointsNative(): OpacityResponse
218-
219-
// carta
220-
private external fun getCartaProfileNative(): OpacityResponse
221-
private external fun getCartaOrganizationsNative(): OpacityResponse
222-
private external fun getCartaPortfolioInvestmentsNative(
223-
firmId: String,
224-
accountId: String
225-
): OpacityResponse
226-
227-
private external fun getCartaHoldingsCompaniesNative(accountId: String): OpacityResponse
228-
private external fun getCartaCorporationSecuritiesNative(
229-
accountId: String,
230-
corporationId: String
231-
): OpacityResponse
232-
233-
// github
234-
private external fun getGithubProfileNative(): OpacityResponse
235-
236-
// instagram
237-
private external fun getInstagramProfileNative(): OpacityResponse
238-
private external fun getInstagramLikesNative(): OpacityResponse
239-
private external fun getInstagramCommentsNative(): OpacityResponse
240-
private external fun getInstagramSavedPostsNative(): OpacityResponse
241-
242-
// Gusto
243-
private external fun getGustoMembersTableNative(): OpacityResponse
244-
private external fun getGustoPayrollAdminIdNative(): OpacityResponse
180+
181+
// private external fun getRedditAccountNative(): OpacityResponse
182+
// private external fun getRedditFollowedSubredditsNative(): OpacityResponse
183+
// private external fun getRedditCommentsNative(): OpacityResponse
184+
// private external fun getRedditPostsNative(): OpacityResponse
185+
//
186+
// // Zabka
187+
// private external fun getZabkaAccountNative(): OpacityResponse
188+
// private external fun getZabkaPointsNative(): OpacityResponse
189+
//
190+
// // carta
191+
// private external fun getCartaProfileNative(): OpacityResponse
192+
// private external fun getCartaOrganizationsNative(): OpacityResponse
193+
// private external fun getCartaPortfolioInvestmentsNative(
194+
// firmId: String,
195+
// accountId: String
196+
// ): OpacityResponse
197+
//
198+
// private external fun getCartaHoldingsCompaniesNative(accountId: String): OpacityResponse
199+
// private external fun getCartaCorporationSecuritiesNative(
200+
// accountId: String,
201+
// corporationId: String
202+
// ): OpacityResponse
203+
//
204+
// // github
205+
// private external fun getGithubProfileNative(): OpacityResponse
206+
//
207+
// // instagram
208+
// private external fun getInstagramProfileNative(): OpacityResponse
209+
// private external fun getInstagramLikesNative(): OpacityResponse
210+
// private external fun getInstagramCommentsNative(): OpacityResponse
211+
// private external fun getInstagramSavedPostsNative(): OpacityResponse
212+
//
213+
// // Gusto
214+
// private external fun getGustoMembersTableNative(): OpacityResponse
215+
// private external fun getGustoPayrollAdminIdNative(): OpacityResponse
245216
}

OpacityCore/src/main/java/com/opacitylabs/opacitycore/OpacityResponse.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.opacitylabs.opacitycore
22

33
data class OpacityResponse(
44
val status: Int,
5-
val json: String?,
6-
val proof: String?,
5+
val data: String?,
76
val err: String?
87
)

OpacityCore/src/main/jni/include/opacity.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,12 @@ extern const int32_t OPACITY_ENVIRONMENT_PRODUCTION;
3434

3535
int32_t init(const char *api_key_str, bool dry_run, int32_t backend_environment);
3636

37-
int32_t get(const char *name,
38-
const char *params,
39-
char **json_ptr,
40-
char **proof_ptr,
41-
char **err_ptr);
37+
int32_t get(const char *name, const char *params, char **res_ptr, char **err_ptr);
4238

4339
void free_string(char *ptr);
4440

4541
void emit_webview_event(const char *payload);
4642

47-
const char *start(const char *request);
48-
4943
int32_t get_uber_rider_profile(char **json_ptr, char **proof_ptr, char **err_ptr);
5044

5145
int32_t get_uber_rider_trip_history(const char *cursor,
@@ -166,8 +160,6 @@ extern bool is_wifi_connected(void);
166160

167161
extern bool is_rooted(void);
168162

169-
const char *verify(const char *proof);
170-
171163
extern void secure_set(const char *key, const char *value);
172164

173165
extern const char *secure_get(const char *key);

0 commit comments

Comments
 (0)