-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from ostdotcom/develop
OstWalletSettings UI component added.
- Loading branch information
Showing
39 changed files
with
2,571 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# OstTransaction Config | ||
|
||
## Introduction | ||
|
||
App developers can configure session `expiration_time` and `spending_limit` while executing transaction. | ||
|
||
To configure the content, the sdk needs to be provided with [JSON object](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON). | ||
|
||
The default configuration can be found [here](../js/TransactionHelper/ost-transaction-config.json). | ||
|
||
## Dictionary Data Structure | ||
|
||
Here is the small sample json representation of the configuration. | ||
|
||
```js | ||
{ | ||
"session_buckets": [ | ||
{ | ||
expiration_time: 60*60*24*30*2, //2 months | ||
spending_limit: '10' | ||
}, | ||
{ | ||
expiration_time: 60*60*24*30, //1 months | ||
spending_limit: '50' | ||
}, | ||
{ | ||
expiration_time: 60*60*24, //24 hours | ||
spending_limit: '100' | ||
}, | ||
{ | ||
expiration_time: 60*60*1, //1 hour | ||
spending_limit: '1000' | ||
} | ||
] | ||
} | ||
``` | ||
|
||
In the above example: | ||
|
||
* The first-level key `session_buckets` corresponds to list of buckets for creating session. The bucket selection is | ||
depends on `spending_limit`. | ||
* The second-level keys | ||
- `expiration_time` : corresponds to expiry time of session. | ||
- `spending_limit` : corresponds to spending limit of session. | ||
|
||
Above configuration allows user to execute transction of spending limit `1000`. SDK throws error, if user makes transaction above `1000`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# OstTransaction Helper | ||
|
||
## Introduction | ||
|
||
Developer can call functions of transaction helper to execute transaction and setting up config for transaction. | ||
|
||
## Set Transaction Config | ||
|
||
Developer can set list of buckets for creating session. For details, Please refer [this](./OstTransactionConfig.md) | ||
|
||
```js | ||
import {OstTransactionHelper} from "@ostdotcom/ost-wallet-sdk-react-native/js/index" | ||
|
||
OstTransactionHelper.setTxConfig(ost-tx-config); | ||
``` | ||
|
||
## Execute Direct Transfer | ||
|
||
Execute direct transfer can be performed by calling | ||
|
||
><b>Note</b> <br /> | ||
>Developer needs to create a class extends from OstWalletUIWorkflowCallback and write logic to get passphrase prefix from their application server. Please refer [this](./OstWalletUI.md) section for documentation. | ||
```js | ||
import {OstTransactionHelper} from "@ostdotcom/ost-wallet-sdk-react-native/js/index" | ||
|
||
const ostUserId = <OstUserId> | ||
const txMeta = {"type": "user_to_user", "name": "Tokens sent", "details": "Sending tokens vis direct transafer"}; | ||
const workflowCallback = new OstWalletUIWorkflowCallback() | ||
|
||
let uuid = OstTransactionHelper.executeDirectTransfer(ostUserId, [tokenValue], [token_holder_address], txMeta, workflowCallback); | ||
|
||
OstWalletSdkUI.subscribe(uuid, OstWalletSdkUI.EVENTS.flowComplete, (workflowContext, contextEntity) => { | ||
//functionality for transaction success | ||
}); | ||
OstWalletSdkUI.subscribe(uuid, OstWalletSdkUI.EVENTS.flowInterrupt, (workflowContext, ostError) => { | ||
//functionality for transaction failed | ||
}); | ||
OstWalletSdkUI.subscribe(uuid, OstWalletSdkUI.EVENTS.requestAcknowledged, (workflowContext, contextEntity) => { | ||
//functionality for transaction ack. | ||
}); | ||
``` | ||
|
||
New session will be created with appropriate bucket, if sdk won't get any active session for given spending limit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# OstWallet Settings | ||
|
||
## Introduction | ||
|
||
OstWallet Settings is a pre-built UI Component available exclusively available in `ost-wallet-sdk-react-native` Sdk. | ||
It is a wallet settings page that can be used by end-users to perfrom different wallet operations. | ||
> <b>IMPORTANT:</b> This feature requires application to use [React Navigation](https://reactnavigation.org/docs/en/getting-started.html) package. | ||
OstWalletSettings supports 13 workflows: | ||
|
||
* Activate User | ||
* Wallet Details | ||
* Initialize Recovery | ||
* Add Session | ||
* Reset a User's PIN | ||
* Get Mnemonic Phrase | ||
* Authorize device using mnemonics | ||
* Abort Device Recovery | ||
* Revoke Device | ||
* Scan QR Code to add another device | ||
* Get Current Device QR code | ||
* Enable Biometrics | ||
* Disable Biometrics | ||
|
||
## Usage | ||
|
||
### Create wallet settings stack navigation | ||
|
||
```js | ||
import {OstWalletSettingsComponent} from '@ostdotcom/ost-wallet-sdk-react-native'; | ||
|
||
let settingsStack = createStackNavigator( | ||
{ | ||
"WalletSettingScreen": OstWalletSettingsComponent | ||
} | ||
); | ||
``` | ||
|
||
### Naviagte to settings page | ||
`ostUserId` and `ostWalletUIWorkflowCallback` are mandetory parameters that need to be passed as params to the `WalletSettingScreen` screen. | ||
```js | ||
const ostUserId = <APPLICATION-USER-OST-USER-ID> | ||
const delegate = new OstWalletUIWorkflowCallback(ostUserId, {}) | ||
this.props.navigation.push("WalletSettingScreen", {'ostUserId': ostUserId, 'ostWalletUIWorkflowCallback': delegate}); | ||
``` | ||
|
||
><b>Note</b> <br/> | ||
> Developer needs to create a class extends from `OstWalletUIWorkflowCallback` and write logic to get passphrase prefix from their application server. | ||
> Please refer [this](OstWalletUI.md#setup-your-passphrase-prefix-delegate) section for documentation. | ||
## UI Customization | ||
|
||
Developer can customize wallet settings by updating respective properties mentioned in image. OstTheme config shown [here](./configs/ost-sdk-theme-config.js) | ||
|
||
![copy-framework-file](images/wallet_settings.png) | ||
![copy-framework-file](images/wallet_details.png) | ||
|
||
## Settings Content | ||
|
||
Developer can modify `header` and `description` of settings options. To modify contet, [refer here](./OstWalletSettingsConfig.md). | ||
|
||
```js | ||
import {OstWalletSettings} from "@ostdotcom/ost-wallet-sdk-react-native/js/index"; | ||
|
||
let settingsContentConfig = {} | ||
|
||
OstWalletSettings.setMasterConfig(settingsContentConfig) | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# OstWallet Settings Config | ||
|
||
## Introduction | ||
|
||
App developers can configure the text shown on settings page. | ||
|
||
To configure the content, the sdk needs to be provided with [JSON object](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON). | ||
|
||
The default configuration can be found [here](../js/WalletSettings/ost-wallet-settings-config.json). | ||
|
||
## Dictionary Data Structure | ||
|
||
Here is the small sample json representation of the configuration. | ||
|
||
```json | ||
{ | ||
"item_display_order": [ | ||
"activate_user", | ||
], | ||
"item_configs": { | ||
"activate_user": { | ||
"content_config": { | ||
"heading": "Activate User", | ||
"description": "User is not activated yet." | ||
}, | ||
"config": { | ||
"spending_limit": "0", | ||
"expiration_time": 0 | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
In the above example: | ||
|
||
* The first-level key `item_display_order` corresponds to sequence of allowed workflows. | ||
* The first-level key `item_configs` corresponds to config for workflows. | ||
* The second-level key `activate_user` corresponds to activate user workflow. | ||
* The third-level key `content_config` corresponds to `heading` and `description` of workflows. | ||
* The third-level key `config` corresponds to respective config for workflows. | ||
|
||
## Supported Workflows | ||
|
||
OstWalletSettings supports 13 workflows | ||
|
||
| Configuration Keys | Workflows | | ||
| ------------------------------------------------ |:--------------------------------------------------------------| | ||
| activate_user | Activate User | | ||
| wallet_details | Wallet Details | | ||
| recover_device | Initialize Recovery | | ||
| add_session | Add Session | | ||
| reset_pin | Reset a User's PIN | | ||
| show_mnemonics | Get Mnemonic Phrase | | ||
| authorize_device_with_mnemonics | Authorize device using mnemonics | | ||
| abort_recovery | Abort Device Recovery | | ||
| revoke_device | Revoke Device | | ||
| add_another_device | Scan QR Code to add another device | | ||
| show_device_qr_code | Get current Device QR code | | ||
| enable_biometrics | Use biometrics to authorize new Sessions and to confirm high value transactions. | | ||
| disable_biometrics | Turn off biometrics and use PIN to authorize new Sessions and to confirm high value transactions. | | ||
|
||
* All workflows have `content_config`. | ||
* `config` varies workflow to workflow. | ||
|
||
## Workflow Config | ||
|
||
Some workflows requires additional data. It can be passed to workflow by setting it in `config`. | ||
|
||
| Workflows | Config Keys | Config Type | | ||
| -------------------------------------- | -------------------------------------------------- | ------------------------------- | | ||
| activate_user | - spending_limit | String | | ||
| | - expiration_time | Number | | ||
| wallet_details | - ost_view_endpoint | String | | ||
| add_session | - spending_limit | String | | ||
| | - expiration_time | Number | | ||
|
||
|
Oops, something went wrong.