-
Notifications
You must be signed in to change notification settings - Fork 1
SymWallet_Android_SDK
SangHyun Lee edited this page Oct 16, 2019
·
5 revisions
- Version : 0.4.1
- Date created
- September 2nd 2019 +SymWallet Application SDK 0.3.1
- September 25th 2019 +SymWallet Application SDK 0.4.0
- October 4th 2019
- Modified date: October 4, 2019
- Creator : Jihoon Gong (WiseM Global)
- Use SymWallet's features to handle payments, remittances, provide third-party logins.
- All SDK functions go through Request from App-> Delegate from SymWallet-> Response Callback, thereby immediate response is not available. Thus, the response is delivered via Receiver.
<!--
{appId} : Issued ID at the requested App
i.e.) <meta-data android:name="SymAppID" android:value="aBs3hLh5ei0K"/>
-->
<meta-data android:name="SymAppID" android:value="{appId}"/>
<!--
Receiver configuration to receive responses to requests
-->
<receiver android:name="com.symverse.symwallet.sdk.SymWalletResultReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.symverse.symwallet.sdk.SymWalletResultReceiver_{appId}" />
</intent-filter>
</receiver>
@Override
public void onReceive(RequestId requestId, WalletAPI.API api, SendData sendData, ReceiveData receiveData) {
if (receiveData.getStatus().equals("success")) {
// Successful
switch(sendData.getApi()) {
case SymSDK.WalletAPI.API.SEND : {
// receiveData.getResult() - TxHash(String)
}
break;
case SymSDK.WalletAPI.API.PAID : {
// receiveData.getResult() - TxHash(String)
}
break;
case SymSDK.WalletAPI.API.SIGNIN : {
// receiveData.getResult() - Signature(JSON String)
}
break;
case SymSDK.WalletAPI.API.SIGN_DATA : {
// receiveData.getResult() - Signature(JSON String)
}
break;
case SymSDK.WalletAPI.API.VERIFYING_SIGN : {
// receiveData.getResult() - VerifyResult(JSON String)
}
break;
case SymSDK.WalletAPI.API.LIST_KEYSTORE : {
// receiveData.getResult() - KeyStoreInfo(JSON String)
}
break;
case SymSDK.WalletAPI.API.EXPORT_KEY : {
switch (sendData.getExportMode()) {
case SymSDK.WalletAPI.ExportMode.PATH : {
// receiveData.getResult() - FilePath(String)
}
break;
case SymSDK.WalletAPI.ExportMode.CONTENT : {
// receiveData.getResult() - KeyStore(JSON String)
}
break;
}
}
break;
}
} else {
// Failed
}
}
- Provide functions of SymWallet
- Provides the ability to send tokens using SymWallet.
- Decimal Scale is not applied to the remittance amount, so Decimal Scale should be added directly to the transfer value. i.e., SYM "1" -> "1000000000000000000" void send(Context, Receiver, String, String, String)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver interface |
walletId | Unit ID that manages coins and tokens used in SymWallet |
toAddress | Account address on the same network as the selected WalletID (or during transaction) |
value | Amount to send. For value without Decimal Scale, input as String type. |
Code
SymSDK.WalletAPI.send(accplicationContext, callbackReceiver, "0x010000000002", "0x00020000000000000002", "1000000000000000000")
-
Provides payment functions using SymWallet.
-
Addition provision is needed in order to display the payment information such as ID, store name, and product name. Moreover, it must pay special attention to the actual payment price before delivering, since the price is determined as
value * quantities-discount
. -
Prices and discounts are subject to Decimal Scale. It allows decimal points. void paid(Context, Receiver, String, String, String, String, String, String, String, String, String)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver interface |
storeId | Store ID |
storeName | Store name |
itemId | Product ID |
itemName | Product name |
walletId | Unit ID that handles coins and tokens in SymWallet |
toAddress | Account address on the same network as the selected WalletID (or during transaction) |
value | Price of 1 product. For value without Decimal Scale, input as String type. i.e., SYM "1" -> "1" or "1.0" |
quantities | Quantity of a product. Payment amount will be set as value * quantities - discount during payment process |
discount | Discounted price (Available in the future) |
Code
SymSDK.WalletAPI.paid(accplicationContext, callbackReceiver, "0x010000000002", "Sym Store", "item_0100012", "SymCafe Expresso", "0x010000000002", "0x00020000000000000002", "15", "2", "1")
- Create linked account data by using SymWallet
- Sign and deliver linked data with the selected keystore file
- The messageHashString in the request can be used to verify the signature.
- messageHash changes on request.
- When linking accounts, link services by using received data (SymID and PublicHash).
- You can later verify that you are a valid user through verifyingSignData or via Symverse blockchain.
- A guide to verification via Symverse blockchain will be provided later. String signIn(Context, Receiver, String, String, String)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver interface |
appId | Application ID of the requesting service |
user |
UUID or equivalent used by the requesting service |
Code
String messageHashString = SymSDK.WalletAPI.signIn(applicationContext, callbackReceiver, "aBs3hLh5ei0K", "user_0")
- Create linked account data by using SymWallet
- Sign and deliver linked data with the selected keystore file
- The messageHashString in the request can be used to verify the signature.
- You can later verify that you are a valid user through verifyingSignData or via Symverse blockchain.
- A guide to verification via Symverse blockchain will be provided later. String signData(Context, Receiver, String)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver interface |
data | String data for delivering sign |
Code
String messageHashString = SymSDK.WalletAPI.signData(applicationContext, callbackReceiver, data)
- The signature is verified through the SymWallet.
- Deliver the signature to be verified by the service.
- You can verify the signed data via SignIn or SignData. String verifyingSign(Context, Receiver, String)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver interface |
sign | Delivering signed data through SignIn or SignData without modification (Hex String) |
Code
String messageHashString = SymSDK.WalletAPI.verifyingSign(applicationContext, callbackReceiver, sign)
- Sends the list of SymVerse keystores running on SymWallet.
- Only SymIDs are sent from the keystore and it can be used to find SymIDs that are mapped with the service subscriber. void listKeyStore(Context, Receiver)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver interface |
Code
SymSDK.WalletAPI.exportKey(applicationContext, callbackReceiver)
- Extract keyStore from SymWallet.
- The extracted KeyStore is used in the server-side SDK for dApp service development and cannot be used in wallets.
- Although the format is similar to the Ethereum v3 keystore, they are not compatible due to differences in hash creation and storage data.
- Extract the keyStore used by the server-side SDK for dApp Service Development from SymWallet. void exportKey(Context, Receiver, ExportMode)
Parameters
Parameter | Note |
---|---|
context | Context of the currently running app |
receiver | Receiver that handles Callback which implements WalletServiceReceiver |
exportMode | PATH : Send saved file path after saving it as file. CONTENT : Send the contents of the keyStore directly.(JSON) |
Code
SymSDK.WalletAPI.exportKey(applicationContext, callbackReceiver, exportMode)
- The results of the request are sent via SymWallet API.
onReceive(RequestId, WalletAPI, SendData, ReceiveData)
RequestId | Request ID randomly assigned to limit duplicate requests when a request occurs |
WalletAPI | Information of the requested SymWallet API |
SendData | Information created on request |
ReceiveData | Result of request that has been delegated and sent |
SEND
PAID
SIGNIN
SIGN_DATA
VERIFYING_SIGN
LIST_KEYSTORE
EXPORT_KEY
-
PATH
: Notifies file path after saving as file -
CONTENT
: Notifies the contents via result value without saving it as file
Variable | Type | Note |
---|---|---|
id | String | |
timestamp | long |
Variable | Type | Note |
---|---|---|
package | String | Package Name of the requested App |
callback | String | Class of Receiver that sends results |
api | String | Name of the requested API SEND, PAID, SIGNIN, SIGN_DATA, VERIFYING_SIGN, LIST_KEYSTORE, EXPORT_KEY |
version | long | Version of the requested API |
storeId | String | Store ID |
storeName | String | Store name |
itemId | String | Product ID |
itemName | String | Product name |
walletId | String | Unit ID that handles coins and tokens used in SymWallet |
toAddress | String | Receiving address |
value | String | Remittance amount or price of 1 product Message Hash, in case of SignIn or SignData (Hex String) Signature, in case of VerifyingSignVerifyingSign (Hex String) |
quantities | String | Product quantity |
discount | String | Discounted price |
export_mode | String | Use in EXPORT_KEY only. In case of PATH, PATH will be notified after saving as file In case of CONTENT, ReceiveData result is sent. |
timestamp | long | Timestamp when a request is made |
Variable | Type | Note |
---|---|---|
version | long | Responder's API version |
minVer | long | Minimum version requirement for Responder's Api to be processed |
status | String | The one value among success, cancel, and fail |
result | String | - In case of Send or Paid, Transaction Hash - In case of SignIn or SignData, Signature Data(JSON String) - In case of VerifyingSign, Verify result(JSON String) - In case of ListKeyStore, KeyStoreInfos(JSON String) - For ExportKey, refers to saved file path when export_mode is PATH and KeyStore(JSON String) in case of CONTENT |
citizen | String | Result of GSym.citizen_getCitizenBySymID call |
error | String | Output message if there was an error during processing |
timestamp | long | Timestamp when the result is made |
API | Payload |
---|---|
Send or Paid | 0xbb149c239723f5fc2378a6ad32b22c52881e0129a5db43c52ab05f744583717a |
SignIn or SignData | { "signature": "0x00025ba7bc8d9c870002208711072c40cda9e280a13e9017dfbf0ba53c60c6192c97981ce1c9f19209a8030100200847ba5d8b4717555b981d5803b9a809193b413eaf2dde838505fe540931c84b20025695012713fb3409c084e0f51bdbbf907b06e89a09893c81a16c2003c85c73", “sym_id": "0x00025ba7bc8d9c870002", "public_hash": "0x91c66ab568501d9ea99bdad2e77b6ba78741c90d" } |
VerifyingSign | { "result": "success", "message_hash": "0x8711072c40cda9e280a13e9017dfbf0ba53c60c6192c97981ce1c9f19209a803", "public_hash": "0x91c66ab568501d9ea99bdad2e77b6ba78741c90d" } |
ListKeyStore | { "result": [ { “sym_id": "0x00025ba7bc8d9c870002", "public_hash": "0x91c66ab568501d9ea99bdad2e77b6ba78741c90d" }, { "sym_id": "0x00024961a85c90da0002", "public_hash": "0x18a85e637bef63db9e56f5c232d5a6117c756b2f" }, { "sym_id": "0x00026252746375740002", “public_hash": "0xf868d984427eaf0805947415d757654dacb8fd56" } ], "count": "3" } |
- Occurs when the parameter is not sent or the value is empty.
- This error occurs while checking the data via received parameter before configuring SendData.
- Occurs when the Receiver cannot be found to receive callbacks.
- This error occurs while checking the Receiver via received parameter before configuring SendData.
- Occurs when the version of the SDK using the WalletAPI is lower than the version supported by SymWallet.
- Errors that occur after a request is made to the SymWallet via API are received through the Receiver.