Fix Robot token not loading to android (#313)

* Fix Robot token not loading to android

* Redo Maker
This commit is contained in:
KoalaSat 2022-11-06 16:20:54 +00:00 committed by GitHub
parent 3d4908c43c
commit 5ae1f8ca18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 54 deletions

View File

@ -1,12 +1,12 @@
{
"name": "frontend",
"version": "0.2.2",
"version": "0.2.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "frontend",
"version": "0.2.2",
"version": "0.2.3",
"license": "ISC",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.16.7",

View File

@ -20,7 +20,6 @@ import {
Settings,
Favorites,
defaultMaker,
defaultRobot,
defaultInfo,
Coordinator,
} from '../models';
@ -56,7 +55,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
list: [],
loading: true,
});
const [robot, setRobot] = useState<Robot>(defaultRobot);
const [robot, setRobot] = useState<Robot>(new Robot());
const [maker, setMaker] = useState<Maker>(defaultMaker);
const [info, setInfo] = useState<Info>(defaultInfo);
const [coordinators, setCoordinators] = useState<Coordinator[]>(defaultCoordinators);

View File

@ -1,46 +1,29 @@
import { systemClient } from '../services/System';
export interface Robot {
nickname: string | null;
token: string | null;
pubKey: string | null;
encPrivKey: string | null;
bitsEntropy: number | null;
shannonEntropy: number | null;
stealthInvoices: boolean;
activeOrderId: number | null;
lastOrderId: number | null;
earnedRewards: number;
referralCode: string;
tgEnabled: boolean;
tgBotName: string;
tgToken: string;
loading: boolean;
avatarLoaded: boolean;
copiedToken: boolean;
class Robot {
constructor() {
this.token = systemClient.getCookie('robot_token') ?? undefined;
this.pubKey = systemClient.getCookie('pub_key') ?? undefined;
this.encPrivKey = systemClient.getCookie('enc_priv_key') ?? undefined;
}
public nickname?: string;
public token?: string;
public pubKey?: string;
public encPrivKey?: string;
public bitsEntropy?: number;
public shannonEntropy?: number;
public stealthInvoices: boolean = true;
public activeOrderId?: number;
public lastOrderId?: number;
public earnedRewards: number = 0;
public referralCode: string = '';
public tgEnabled: boolean = false;
public tgBotName: string = 'unknown';
public tgToken: string = 'unknown';
public loading: boolean = false;
public avatarLoaded: boolean = false;
public copiedToken: boolean = false;
}
const pubKeyCookie = systemClient.getCookie('pub_key');
const privKeyCookie = systemClient.getCookie('enc_priv_key');
export const defaultRobot: Robot = {
nickname: null,
token: systemClient.getCookie('robot_token') ?? null,
pubKey: pubKeyCookie ? pubKeyCookie.split('\\').join('\n') : null,
encPrivKey: privKeyCookie ? privKeyCookie.split('\\').join('\n') : null,
bitsEntropy: null,
shannonEntropy: null,
stealthInvoices: true,
activeOrderId: null,
lastOrderId: null,
earnedRewards: 0,
referralCode: '',
tgEnabled: false,
tgBotName: 'unknown',
tgToken: 'unknown',
loading: false,
avatarLoaded: false,
copiedToken: false,
};
export default Robot;

View File

@ -36,7 +36,8 @@ export const baseSettings: Settings = {
? 'dark'
: 'light',
fontSize: 14,
language: i18n.resolvedLanguage == null ? 'en' : i18n.resolvedLanguage.substring(0, 2),
language:
i18n.resolvedLanguage == null ? 'en' : (i18n.resolvedLanguage.substring(0, 2) as Language),
freezeViewports: false,
network: undefined,
coordinator: undefined,

View File

@ -1,16 +1,17 @@
import Robot from './Robot.model';
export type { LimitList } from './Limit.model';
export type { Limit } from './Limit.model';
export type { Maker } from './Maker.model';
export type { Order } from './Book.model';
export type { Book } from './Book.model';
export type { Robot } from './Robot.model';
export type { Info } from './Info.model';
export type { Settings } from './Settings.model';
export type { Language } from './Settings.model';
export type { Favorites } from './Favorites.model';
export type { Coordinator } from './Coordinator.model';
export type { Maker } from './Maker.model';
export { Robot };
export { defaultMaker } from './Maker.model';
export { defaultRobot } from './Robot.model';
export { defaultSettings } from './Settings.default.basic';
export { defaultInfo } from './Info.model';

View File

@ -13,7 +13,6 @@ import {
Settings,
Favorites,
defaultMaker,
defaultRobot,
defaultInfo,
} from '../models';
@ -78,7 +77,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
list: [],
loading: true,
});
const [robot, setRobot] = useState<Robot>(defaultRobot);
const [robot, setRobot] = useState<Robot>(new Robot());
const [maker, setMaker] = useState<Maker>(defaultMaker);
const [info, setInfo] = useState<Info>(defaultInfo);
const [fav, setFav] = useState<Favorites>({ type: null, currency: 0 });

View File

@ -1,4 +1,3 @@
import { systemClient } from '../System';
import { NativeRobosatsPromise, NativeWebViewMessage, NativeWebViewMessageSystem } from './index.d';
class NativeRobosats {

View File

@ -1,12 +1,12 @@
{
"name": "robosats",
"version": "0.2.2",
"version": "0.2.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "robosats",
"version": "0.2.2",
"version": "0.2.3",
"dependencies": {
"@react-native-clipboard/clipboard": "^1.11.1",
"@react-native-community/netinfo": "^9.3.4",