Skip to content

Instantly share code, notes, and snippets.

@wolverineks
Created February 6, 2018 20:04
Show Gist options
  • Save wolverineks/6128b1d365e85eb93458a9a38fc4562e to your computer and use it in GitHub Desktop.
Save wolverineks/6128b1d365e85eb93458a9a38fc4562e to your computer and use it in GitHub Desktop.
Proposed Redux State
export type WalletId = string
export type CurrencyCode = string
export type IsoCurrencyCode = string
export type PluginName = string
export type SceneKey = string
export type SceneData = Object
export type State = {
edge: EdgeState, // everything non-serializable
account: AccountState,
wallets: WalletsState,
settings: SettingsState,
scenes: ScenesState,
device: DeviceState
}
export type EdgeState = { // everything non-serializable
account: EdgeAccount | null,
context: EdgeContext | null,
wallets: {[WalletId]: EdgeCurrencyWallet} // keto-derived from account?
}
export type AccountState = {
username: string, // keto-derived from state.edge.account
loginType: // keto-derived from state.edge.account
‘newAccount’
| ‘password’
| ‘pin’
| ‘recovery’
| ‘key’
}
export type SettingsState = {
autoLogoutMode: {
isEnabled: boolean,
seconds: number
},
bluetoothMode: {
isEnabled: boolean
},
defaultFiat: IsoCurrencyCode,
merchantMode: {
isEnabled: boolean
},
otpMode: {
isEnabled: boolean,
key: string,
resetDate: Date
},
touchId: {
isEnabled: boolean,
isSupported: boolean
},
byCurrencyCode: CurrencySettingsState
}
export type CurrencySettingsState = {
[CurrencyCode]: {
denominations: {[key: string]: EdgeDenomination},
displayDenominationKey: string, // overkill? confusing?
displayDenomination: EdgeDenomination, // keto-derived
exchangeDenomination: EdgeDenomination, // keto-derived
spendingLimits: {
daily: {
isEnabled: boolean,
nativeAmount: string
},
transaction: {
isEnabled: boolean,
nativeAmount: string
}
}
}
}
export type WalletsState = {
byId: {[WalletId]: GuiWallet},
activeWalletIds: Array<WalletId>,
archivedWalletIds: Array<WalletId>,
selectedWalletId: WalletId
selectedCurrencyCode: CurrencyCode
selectedWallet: GuiWallet // derived from byId[selectedWalletId]
}
export type ScenesState = { // incomplete, just an example
[SceneKey]: SceneData,
main: {
dropdownAlert: { // displays globally
isVisible: boolean
},
popupModal: { // displays globally
isVisible: boolean
},
passwordReminderModal: { // displays globally
isVisible: boolean
},
},
walletList: {
deleteWalletModal: { // displays only on this scene
isVisible: boolean,
walletId: WalletId
},
getPrivateSeedModal: { // displays only on this scene
isVisible: boolean,
walletId: WalletId
},
renameWalletModal: { // displays only on this scene
isVisible: boolean,
walletId: WalletId
},
resyncWalletModal: { // displays only on this scene
isVisible: boolean,
walletId: WalletId
},
}
}
export type DeviceState = {
permissions: PermissionsState,
contacts: ContactsState,
locale: LocaleState,
specs: SpecsState,
}
export type PermissionState = ‘granted’ | ‘denied’ | ‘restricted’ | null
export type Permission = ‘bluetooth’ | ‘camera’ | ‘contacts’ | ‘photos’
export type PermissionsState = {
[Permission]: PermissionState
}
export type GuiContact = {
hasThumbnail: boolean,
emailAddresses: Array<string>,
postalAddress: Array<string>,
middleName: string,
company: string,
jobTitle: string,
familyName: string,
thumbnailPath: string,
recordID: string,
givenName: string,
}
export type ContactsState = Array<GuiContact> | null
export type LocaleState = {
localeIdentifier: string,
decimalSeparator: string,
quotationBeginDelimiterKey: string,
quotationEndDelimiterKey: string,
currencySymbol: string,
currencyCode: string,
// ios only:
usesMetricSystem: boolean,
localeLanguageCode: string,
countryCode: string,
calendar: string,
groupingSeparator: string,
collatorIdentifier: string,
alternateQuotationBeginDelimiterKey: string,
alternateQuotationEndDelimiterKey: string,
measurementSystem: string,
preferredLanguages: Array<string>
} | null
export type SpecsState = {
// android only
// apiLevel: number,
// firstInstallTime: number,
// ipAddress: Promise<string>,
// instanceId: string,
// lastUpdateTime: number,
// macAddress: Promise<string>,
// maxMemory: number,
// phoneNumber: string,
// serialNumber: string,
applicationName: string,
brand: string,
buildNumber: string,
bundleId: string,
carrier: string,
deviceCountry: string,
deviceId: string,
deviceLocale: string,
deviceName: string,
freeDiskStorage: number,
manufacturer: string,
model: string,
readableVersion: string,
systemName: string,
systemVersion: string,
timezone: string,
totalDiskCapacity: number,
totalMemory: number,
uniqueId: string,
userAgent: string,
version: string,
is24Hour: boolean,
isEmulator: string,
isPinOrFingerprintSet: boolean,
isTablet: boolean
} | null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment