Skip to content

Commit 9c0c0da

Browse files
authored
Merge pull request #23 from beetapp/eos_prompt
Eos prompt
2 parents d523f82 + 34c7b1f commit 9c0c0da

File tree

5 files changed

+1066
-674
lines changed

5 files changed

+1066
-674
lines changed

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"eslint.provideLintTask": true,
1111
"eslint.run": "onSave",
1212
"editor.codeActionsOnSave": {
13-
"source.fixAll.eslint": true
13+
"source.fixAll.eslint": "explicit"
1414
}
1515
}

src/background.js

+44-40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import path from "path";
22
import url from "url";
33
import fs from "fs";
4+
import fsPromises from "fs/promises";
5+
46
import os from "os";
57

68
import queryString from "query-string";
@@ -46,7 +48,6 @@ const logger = new Logger(isDevMode ? 3 : 0);
4648
let tray = null;
4749
let regexBTS = /1.2.\d+/g;
4850

49-
5051
async function _readFile(filePath) {
5152
return new Promise((resolve, reject) => {
5253
if (!filePath || !filePath.includes(".bin")) {
@@ -618,6 +619,8 @@ const createWindow = async () => {
618619
ipcMain.handle("blockchainRequest", async (event, arg) => {
619620
const { methods, account, chain } = arg;
620621

622+
console.log({ methods, account, chain });
623+
621624
let blockchain;
622625
try {
623626
blockchain = await getBlockchainAPI(chain);
@@ -864,7 +867,7 @@ const createWindow = async () => {
864867
allowedOperations
865868
);
866869
} catch (error) {
867-
console.log(error);
870+
console.log({ error, location: "_parseDeeplink" });
868871
}
869872

870873
if (apiobj && apiobj.type === Actions.INJECTED_CALL) {
@@ -892,50 +895,51 @@ const createWindow = async () => {
892895

893896
if (methods.includes("localFileUpload")) {
894897
const { allowedOperations, filePath } = arg;
898+
try {
899+
const data = await fsPromises.readFile(filePath, "utf-8");
900+
901+
let apiobj;
902+
try {
903+
apiobj = await _parseDeeplink(
904+
data,
905+
"local",
906+
chain,
907+
blockchain,
908+
blockchainActions,
909+
allowedOperations,
910+
null, // avoid TOTP
911+
true // changes request parsing
912+
);
913+
} catch (error) {
914+
console.log(error);
915+
}
895916

896-
fs.readFile(filePath, "utf-8", async (error, data) => {
897-
if (!error) {
898-
let apiobj;
917+
if (apiobj && apiobj.type === Actions.INJECTED_CALL) {
918+
let status;
899919
try {
900-
apiobj = await _parseDeeplink(
901-
data,
902-
"local",
903-
chain,
920+
status = await inject(
904921
blockchain,
905-
blockchainActions,
906-
allowedOperations,
907-
null, // avoid TOTP
908-
true // changes request parsing
922+
apiobj,
923+
mainWindow.webContents
909924
);
910925
} catch (error) {
911-
console.log(error);
926+
console.log({ error: error || "No status" });
912927
}
913928

914-
if (apiobj && apiobj.type === Actions.INJECTED_CALL) {
915-
let status;
916-
try {
917-
status = await inject(
918-
blockchain,
919-
apiobj,
920-
mainWindow.webContents
921-
);
922-
} catch (error) {
923-
console.log({ error: error || "No status" });
924-
}
929+
console.log({ status });
925930

926-
if (
927-
status &&
928-
status.result &&
929-
!status.result.isError &&
930-
!status.result.canceled
931-
) {
932-
responses["localFileUpload"] = status.result;
933-
}
931+
if (
932+
status &&
933+
status.result &&
934+
!status.result.isError &&
935+
!status.result.canceled
936+
) {
937+
responses["localFileUpload"] = status.result;
934938
}
935-
} else {
936-
console.log({ error });
937939
}
938-
});
940+
} catch (error) {
941+
console.log({ error });
942+
}
939943
}
940944

941945
if (methods.includes("processQR")) {
@@ -1079,7 +1083,7 @@ const createWindow = async () => {
10791083
}
10801084
}
10811085
}
1082-
1086+
10831087
if (methods.includes("decryptBackup")) {
10841088
const { filePath, pass } = arg;
10851089

@@ -1099,7 +1103,7 @@ const createWindow = async () => {
10991103
} catch (error) {
11001104
console.log({ error });
11011105
}
1102-
1106+
11031107
if (unlocked) {
11041108
let retrievedAccounts;
11051109
try {
@@ -1110,12 +1114,12 @@ const createWindow = async () => {
11101114
} catch (error) {
11111115
console.log({ error });
11121116
}
1113-
1117+
11141118
if (retrievedAccounts) {
11151119
responses["decryptBackup"] = retrievedAccounts;
11161120
}
11171121
}
1118-
1122+
11191123
wh = null;
11201124
}
11211125
}

0 commit comments

Comments
 (0)