Skip to content

Commit 5c11143

Browse files
author
Rachin Kapoor
authored
Merge pull request #150 from ostdotcom/develop
Pull updates from develop
2 parents 0b52ba8 + e6b1c14 commit 5c11143

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2518
-79
lines changed

CHANGELOG.MD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# OST Wallet SDK Changelog
22

3+
## Version 2.4.1
4+
* User can authorize external session by scanning QR-Code. To use `Authorize session by scanning QR code`, please update downstream sdk.<br/>
5+
iOS: v2.4.1<br/>
6+
Android: v2.4.1
7+
* User can pass QR-Code payload to perform QR-Code actions without opening Scanner in OstWalletUI.
8+
This functionality is available for `scanQRCodeToAuthorizeSession`, `scanQRCodeToExecuteTransaction`, `scanQRCodeToAuthorizeDevice`,
9+
10+
## Version 2.4.0
11+
* OstRedemption UI component is now available in SDK. To use `OstRedemption`, please update downstream sdk.<br/>
12+
iOS:`v2.4.0`<br/>
13+
Android:`v2.4.0`
14+
* `getRedeemableSkus` and `getRedeemableSkuDetails` apis added in `OstJsonApi`.
15+
16+
317
## Version 2.3.14
418
* ReadMe updates<br/>
519
* Removed unused imports<br/>

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Ost React Native Wallet SDK...
3232
- [Implementation](#implementation-1)
3333
+ [Wallet Settings UI Component](#wallet-settings-ui-component)
3434
- [Implementation](#implementation-2)
35+
+ [Redemption flow UI Component](#redemption-flow-ui-component)
36+
- [Implementation](#implementation-3)
3537
+ [OstTransactionHelper - Transaction and Session Integrated Workflow](#osttransactionhelper---transaction-and-session-integrated-workflow)
3638
- [Implementation](#implementation-3)
3739
* [Intermediate Usage - Ost Wallet SDK UI](#intermediate-usage---ost-wallet-sdk-ui)
@@ -240,6 +242,8 @@ Activate User workflow deploys user's wallet on the blockchain and whitelists th
240242
#### Implementation
241243
Please refer to [Activate User UI Workflow Documentation](./documentation/OstWalletUI.md#activate-user) for implementation details.
242244

245+
<a id="wallet-settings-ui-component" />
246+
243247
### 3. Wallet Settings UI Component
244248
---
245249
OstWallet Settings is a pre-built UI component available exclusively available in `ost-wallet-sdk-react-native` SDK.
@@ -249,7 +253,18 @@ It is a wallet settings page that can be used by end-users to perfrom 12 differe
249253
#### Implementation
250254
Please refer to [OstWallet Settings Documentation](./documentation/OstWalletSettings.md) for implementation details.
251255

252-
### 4. OstvTransaction Helper - Transaction and Add Session Integrated Workflow
256+
<a id="redemption-flow-ui-component" />
257+
258+
### 4. Redemption Flow UI Component
259+
---
260+
OstRedemption component is a pre-built UI component available exclusively in `ost-wallet-sdk-react-native` SDK.
261+
It consist two pages - one displaying redeemable product list and another displaying product details and redemption options. It can be used by end-users to integrate redemption flow into their app.
262+
> <b>IMPORTANT:</b> This feature requires application to use [React Navigation](https://reactnavigation.org/docs/en/getting-started.html) package.
263+
264+
#### Implementation
265+
Please reder to [OstRedemption flow Documentation](./documentation/OstRedemptionFlow.md) for implementation details.
266+
267+
### 5. OstTransaction Helper - Transaction and Add Session Integrated Workflow
253268
---
254269
`OstTransactionHelper` is a transaction helper provided by the SDK that creates session keys before performing a transaction if needed. App developers can configure the session creation parameters (session buckets) as per application's need.
255270

android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ allprojects {
1818
}
1919

2020
apply plugin: 'com.android.library'
21-
2221
android {
2322
compileSdkVersion 28
2423
buildToolsVersion '28.0.3'
@@ -45,5 +44,5 @@ repositories {
4544

4645
dependencies {
4746
implementation 'com.facebook.react:react-native:+'
48-
api 'com.ost:ost-wallet-sdk-android:2.3.8'
47+
api 'com.ost:ost-wallet-sdk-android:2.4.1'
4948
}

android/src/main/java/com/ostwalletrnsdk/OstRNSdkJsonApiModule.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,46 @@ public void getCurrentDeviceForUserId(
150150
}
151151
}
152152

153+
@ReactMethod
154+
public void getRedeemableSkus(
155+
String userId,
156+
ReadableMap requestMap,
157+
Callback successCallback,
158+
Callback errorCallback
159+
) {
160+
try {
161+
Map<String,Object> requestPayload = new HashMap<>();
162+
if (null != requestMap) {
163+
requestPayload = requestMap.toHashMap();
164+
}
165+
OstJsonApi.getRedeemableSkus(userId ,requestPayload, new OstJsonApiCallbackImpl(successCallback, errorCallback));
166+
} catch (Throwable e) {
167+
errorCallback.invoke(Utils.getError(e, "rn_orsjam_grs_1"));
168+
return;
169+
}
170+
}
171+
172+
173+
@ReactMethod
174+
public void getRedeemableSkuDetails(
175+
String userId,
176+
String skuId,
177+
ReadableMap requestMap,
178+
Callback successCallback,
179+
Callback errorCallback
180+
) {
181+
try {
182+
Map<String,Object> requestPayload = new HashMap<>();
183+
if (null != requestMap) {
184+
requestPayload = requestMap.toHashMap();
185+
}
186+
OstJsonApi.getRedeemableSkuDetails(userId , skuId ,requestPayload, new OstJsonApiCallbackImpl(successCallback, errorCallback));
187+
} catch (Throwable e) {
188+
errorCallback.invoke(Utils.getError(e, "rn_orsjam_grsd_1"));
189+
return;
190+
}
191+
}
192+
153193

154194
private static class OstJsonApiCallbackImpl implements OstJsonApiCallback {
155195

android/src/main/java/com/ostwalletrnsdk/Utils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONExc
9595
map.putDouble(key, (Double) value);
9696
} else if (value instanceof String) {
9797
map.putString(key, (String) value);
98+
} else if (null == value || "null".equalsIgnoreCase(value.toString())){
99+
map.putNull(key);
98100
} else {
99101
map.putString(key, value.toString());
100102
}
@@ -119,6 +121,8 @@ public static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONE
119121
array.pushDouble((Double) value);
120122
} else if (value instanceof String) {
121123
array.pushString((String) value);
124+
} else if (null == value || "null".equalsIgnoreCase(value.toString())) {
125+
array.pushNull();
122126
} else {
123127
array.pushString(value.toString());
124128
}

android/src/main/java/com/ostwalletrnsdk/ui/OstWalletUiRnSdkModule.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,31 @@ public void getAddDeviceQRCode(String userId, String uuid) {
165165
}
166166

167167
@ReactMethod
168-
public void scanQRCodeToAuthorizeDevice(String userId, String uuid) {
168+
public void scanQRCodeToAuthorizeDevice(String userId, String qrPayload, String uuid) {
169169
Activity currentActivity = getCurrentActivity();
170170
OstUICallbackImpl ostUICallback = new OstUICallbackImpl( uuid, this.reactContext,
171171
new OstWorkflowContext(OstWorkflowContext.WORKFLOW_TYPE.AUTHORIZE_DEVICE_WITH_QR_CODE));
172-
String workflowId = OstWalletUI.scanQRCodeToAuthorizeDevice(currentActivity, userId, ostUICallback);
172+
String workflowId = OstWalletUI.scanQRCodeToAuthorizeDevice(currentActivity, qrPayload, userId, ostUICallback);
173173
SdkInteract.getInstance().subscribe(workflowId, ostUICallback);
174174
}
175175

176+
177+
@ReactMethod
178+
public void scanQRCodeToAuthorizeSession(String userId, String qrPayload, String uuid) {
179+
Activity currentActivity = getCurrentActivity();
180+
OstUICallbackImpl ostUICallback = new OstUICallbackImpl( uuid, this.reactContext,
181+
new OstWorkflowContext(OstWorkflowContext.WORKFLOW_TYPE.AUTHORIZE_DEVICE_WITH_QR_CODE));
182+
String workflowId = OstWalletUI.scanQRCodeToAuthorizeSession(currentActivity, qrPayload, userId, ostUICallback);
183+
SdkInteract.getInstance().subscribe(workflowId, ostUICallback);
184+
}
185+
186+
176187
@ReactMethod
177-
public void scanQRCodeToExecuteTransaction(String userId, String uuid) {
188+
public void scanQRCodeToExecuteTransaction(String userId, String qrPayload, String uuid) {
178189
Activity currentActivity = getCurrentActivity();
179190
OstUICallbackImpl ostUICallback = new OstUICallbackImpl( uuid, this.reactContext,
180191
new OstWorkflowContext(OstWorkflowContext.WORKFLOW_TYPE.EXECUTE_TRANSACTION));
181-
String workflowId = OstWalletUI.scanQRCodeToExecuteTransaction(currentActivity, userId, ostUICallback);
192+
String workflowId = OstWalletUI.scanQRCodeToExecuteTransaction(currentActivity, qrPayload, userId, ostUICallback);
182193
SdkInteract.getInstance().subscribe(workflowId, ostUICallback);
183194
}
184195

assets/down-arrow.png

1.74 KB
Loading

assets/msg-icon.png

9.13 KB
Loading

0 commit comments

Comments
 (0)