Wallet Retrieval
Once a wallet has been created, it can be retrieved from the database on the user's device. Authenticating the user will sync wallets with the server.
Android
On Android, an ArrayList of Keystore
objects can be found on the State
instance. This is accessible through ZumoKit.store().getState()
, as seen in the example below.
import com.zumo.zumokit.ZumoKit;
import com.zumo.zumokit.Store;
import com.zumo.zumokit.State;
import com.zumo.zumokit.Keystore;
import com.zumo.zumokit.WalletManagement;
State state = this.zumoKit.store().getState();
ArrayList<Keystore> keystores = state.getKeystores();
You can attempt to access the first object in the ArrayList with the following:
try {
Keystore keystore = keystores.get(0);
} catch(Exception e) {
// No wallet found.
}
Before you can interact with wallet, you need to unlock it:
WalletManagement wm = this.zumoKit.walletManagement();
boolean unlockedStatus = wm.unlockWallet(keystore, "password123");
In case wallet was succesfully unlocked keystore.getUnlocked()
is set to true
.
iOS
On iOS, an array of CPKeystore
objects can be found on the CPState
instance. This is accessible through [[zumoKit store] getState]
, as seen in the example below.
#import <ZumoKitSDK/ZumoKit.h>
#import <ZumoKitSDK/CPStore.h>
#import <ZumoKitSDK/CPState.h>
#import <ZumoKitSDK/CPKeystore.h>
#import <ZumoKitSDK/CPWalletManagement.h>
CPState *state = [[_zumoKit store] getState];
NSArray<CPKeystore *> *keystores = [state keystores];
You can check the wallet count and access the first object in the array with the following:
if([keystores count] > 0) {
CPKeystore *keystore = [keystores objectAtIndex:0];
}
Before you can interact with wallet, you need to unlock it:
CPWalletManagement *walletManagement = [_zumoKit walletManagement];
BOOL status = [walletManagement
unlockWallet:keystore
password:@"password123"];
In case wallet was succesfully unlocked keystore.unlocked
is set to YES
.
React Native
The React Native ZumoKit SDK currently only supports a single wallet and the method to access it is available on the ZumoKit
singleton.
import ZumoKit from 'react-native-zumo-kit';
try {
const wallet = await ZumoKit.getWallet();
} catch(error) {
// There was a problem retreiving the wallet.
}
If no wallet was found, or there was a problem retrieving the wallet then the promise will be rejected, causing an error to be catchable.