Skip to content

Commit

Permalink
Fixes & cleanup
Browse files Browse the repository at this point in the history
Fix private key signup method
Removed TUSC
Reset prompt operation permission scope upon switching blockchain accounts
  • Loading branch information
grctest committed May 13, 2024
1 parent 249f2a7 commit 78c47e9
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 139 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The EOS blockchain has their own native javascript library that can be used (e.g

The wallet now also supports deeplinks, encrypted deeplinks, qr codes and local json files for generating blockchain request prompts for approval & broadcast with the BeetEOS wallet. These input methods do not require external packages, and can be stored for later use.

Supported blockchains: Bitshares, Bitshares testnet, TUSC, EOS, BEOS, TLOS.
Supported blockchains: Bitshares, Bitshares testnet, EOS, BEOS, TLOS.

## For end users

Expand All @@ -56,7 +56,7 @@ BeetEOS is an [electron-based app](https://www.electronjs.org) for [cross-platfo

To run BeetEOS it's simply a case of

``` bash
```bash
# clone
git clone https://github.com/beetapp/beeteos
cd beeteos
Expand Down
52 changes: 30 additions & 22 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ async function _parseDeeplink(
}

if (request.payload.method === Actions.INJECTED_CALL) {
console.log({req: request.payload.params})
let authorizedUse = false;
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
let tr;
try {
tr = await blockchain._parseTransactionBuilder(
Expand All @@ -443,16 +444,20 @@ async function _parseDeeplink(
}
}
} else if (["EOS", "BEOS", "TLOS"].includes(chain)) {
if (request.payload.params.actions) {
for (
let i = 0;
i < request.payload.params.actions.length;
i++
) {
let operation = request.payload.params.actions[i];
if (settingsRows && settingsRows.includes(operation.name)) {
authorizedUse = true;
break;
if (request.payload.params && request.payload.params.length > 1) {
const actions = JSON.parse(request.payload.params[1]).actions;

if (actions) {
for (
let i = 0;
i < actions.length;
i++
) {
let operation = actions[i];
if (settingsRows && settingsRows.includes(operation.name)) {
authorizedUse = true;
break;
}
}
}
}
Expand Down Expand Up @@ -680,6 +685,10 @@ const createWindow = async () => {
responses["getAccessType"] = blockchain.getAccessType();
}

if (methods.includes("getSignUpInput")) {
responses["getSignUpInput"] = blockchain.getSignUpInput();
}

if (methods.includes("getImportOptions")) {
responses["getImportOptions"] = blockchain.getImportOptions();
}
Expand Down Expand Up @@ -917,7 +926,7 @@ const createWindow = async () => {

let parsedData = JSON.parse(qrData);
let authorizedUse = false;
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
const ops = parsedData.operations[0].operations;
for (let i = 0; i < ops.length; i++) {
let operation = ops[i];
Expand Down Expand Up @@ -946,7 +955,7 @@ const createWindow = async () => {
if (authorizedUse) {
let qrTX;
try {
qrTX = ["BTS", "BTS_TEST", "TUSC"].includes(chain)
qrTX = ["BTS", "BTS_TEST"].includes(chain)
? await blockchain.handleQR(
JSON.stringify(parsedData.operations[0])
)
Expand All @@ -964,7 +973,7 @@ const createWindow = async () => {
origin: "localhost",
appName: "qr",
browser: qrChoice,
params: ["BTS", "BTS_TEST", "TUSC"].includes(chain)
params: ["BTS", "BTS_TEST"].includes(chain)
? qrTX.toObject()
: qrTX,
chain: chain,
Expand Down Expand Up @@ -1121,7 +1130,6 @@ const createWindow = async () => {
"explore.beos.world",
"blocksights.info",
"telos.eosx.io",
"wallet.tusc.network",
];
ipcMain.on("openURL", (event, arg) => {
try {
Expand Down Expand Up @@ -1406,9 +1414,11 @@ if (currentOS === "win32" || currentOS === "linux") {
console.log(error);
return;
}

let deeplinkingUrl = deeplink.includes("beeteos://api/") ? deeplink.split("beeteos://api/")[1] : deeplink.split("rawbeeteos://api/")[1];


let deeplinkingUrl = deeplink.includes("beeteos://api/")
? deeplink.split("beeteos://api/")[1]
: deeplink.split("rawbeeteos://api/")[1];

let qs;
try {
qs = queryString.parse(deeplinkingUrl);
Expand All @@ -1419,9 +1429,7 @@ if (currentOS === "win32" || currentOS === "linux") {

if (qs) {
mainWindow.webContents.send(
deeplink.includes("raw")
? "rawdeeplink"
: "deeplink",
deeplink.includes("raw") ? "rawdeeplink" : "deeplink",
qs
);
}
Expand Down Expand Up @@ -1478,7 +1486,7 @@ if (currentOS === "win32" || currentOS === "linux") {
}

if (qs) {
dialog.showErrorBox("Error", JSON.stringify({qs: qs}));
dialog.showErrorBox("Error", JSON.stringify({ qs: qs }));
mainWindow.webContents.send(urlType, qs);
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/blockchains/ImportKeys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
let privateKey = ref("");
async function next() {
let authorities = {};
if (requiredFields.value.privateKey != null) {
if (requiredFields.value && requiredFields.value.privateKey) {
authorities.privateKey = privateKey.value;
}
Expand Down Expand Up @@ -107,7 +107,7 @@
{{ t('common.keys_cta') }}
</p>

<template v-if="requiredFields.privateKey !== null">
<template v-if="requiredFields && requiredFields.privateKey">
<p class="mb-2 font-weight-bold">
{{ t(accessType == 'account' ? 'common.active_authority' : 'common.public_authority') }}
</p>
Expand All @@ -131,7 +131,7 @@
{{ t('common.back_btn') }}
</ui-button>

<span v-if="requiredFields.privateKey != null">
<span v-if="requiredFields && requiredFields.privateKey">
<ui-button
v-if="accountname !== '' && privateKey !== ''"
raised
Expand Down
2 changes: 1 addition & 1 deletion src/components/blockchains/bitshares/ImportBinFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const emit = defineEmits(['back', 'continue', 'imported']);
onMounted(() => {
if (!["BTS", "BTS_TEST", "TUSC"].includes(props.chain)) {
if (!["BTS", "BTS_TEST"].includes(props.chain)) {
throw "Unsupported chain!";
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/blockchains/bitshares/ImportCloudPass.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const emit = defineEmits(['back', 'continue', 'imported']);
onMounted(() => {
if (!["BTS", "BTS_TEST", "TUSC"].includes(props.chain)) {
if (!["BTS", "BTS_TEST"].includes(props.chain)) {
throw "Unsupported chain!";
}
})
Expand Down
15 changes: 14 additions & 1 deletion src/components/local.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, onMounted, toRaw } from 'vue';
import { ref, computed, onMounted, watch, toRaw } from 'vue';
import { useI18n } from 'vue-i18n';
import AccountSelect from "./account-select";
Expand All @@ -24,6 +24,19 @@
return store.getters['AccountStore/getChain'];
});
let selectedAccount = computed(() => {
if (!store.state.WalletStore.isUnlocked) {
return;
}
return store.getters["AccountStore/getCurrentSafeAccount"]()
})
watch(selectedAccount, async (newVal, oldVal) => {
console.log("User changed account - resetting configured scope!")
chosenScope.value = null;
selectedRows.value = null;
}, {immediate: true});
let supportsLocal = ref(false);
let operationTypes = ref([]);
onMounted(async () => {
Expand Down
12 changes: 6 additions & 6 deletions src/components/main-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
} = args;
if (
(["BTS", "BTS_TEST", "TUSC"].includes(chain)) &&
(["BTS", "BTS_TEST"].includes(chain)) &&
((!visualizedAccount && account && !account.accountName) || !visualizedParams)
) {
console.log("Missing required fields for injected call");
Expand Down Expand Up @@ -373,7 +373,7 @@
window.electron.popupApproved(request.id, async (args) => {
let _request = request;
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
if (request.payload.memo) {
let from;
let to;
Expand Down Expand Up @@ -441,7 +441,7 @@
}
let activeKey;
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
try {
activeKey = request.payload.account_id
? store.getters['AccountStore/getActiveKey'](request)
Expand All @@ -466,7 +466,7 @@
if (txType == "signAndBroadcast") {
try {
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
finalResult = await window.electron.blockchainRequest({
methods: ["signAndBroadcast"],
account: null,
Expand Down Expand Up @@ -539,7 +539,7 @@
window.electron.popupApproved(request.id, async (result) => {
let activeKey;
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
try {
activeKey = request.payload.account_id
? store.getters['AccountStore/getActiveKey'](request)
Expand All @@ -564,7 +564,7 @@
let transaction;
try {
if (["BTS", "BTS_TEST", "TUSC"].includes(chain)) {
if (["BTS", "BTS_TEST"].includes(chain)) {
transaction = await window.electron.requestSignature(request.payload.params, signingKey);
} else if (["EOS", "BEOS", "TLOS"].includes(chain)) {
transaction = await window.electron.requestSignature(JSON.parse(request.payload.params[1]), signingKey);
Expand Down
15 changes: 14 additions & 1 deletion src/components/qr.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, watchEffect, inject, onMounted, toRaw } from 'vue';
import { ref, computed, watchEffect, inject, watch, onMounted, toRaw } from 'vue';
import { useI18n } from 'vue-i18n';
import AccountSelect from "./account-select";
Expand Down Expand Up @@ -38,6 +38,19 @@
return store.getters['AccountStore/getChain'];
});
let selectedAccount = computed(() => {
if (!store.state.WalletStore.isUnlocked) {
return;
}
return store.getters["AccountStore/getCurrentSafeAccount"]()
})
watch(selectedAccount, async (newVal, oldVal) => {
console.log("User changed account - resetting configured scope!")
chosenScope.value = null;
selectedRows.value = null;
}, {immediate: true});
async function evaluateQR (data) {
if (!data) {
return;
Expand Down
14 changes: 14 additions & 0 deletions src/components/raw-link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import store from '../store/index.js';
import router from '../router/index.js';
import { watch } from 'vue';
const { t } = useI18n({ useScope: 'global' });
Expand Down Expand Up @@ -35,6 +36,19 @@
}
}
let selectedAccount = computed(() => {
if (!store.state.WalletStore.isUnlocked) {
return;
}
return store.getters["AccountStore/getCurrentSafeAccount"]()
})
watch(selectedAccount, async (newVal, oldVal) => {
console.log("User changed account - resetting configured scope!")
chosenScope.value = null;
selectedRows.value = null;
}, {immediate: true});
let chain = computed(() => {
return store.getters['AccountStore/getChain'];
});
Expand Down
15 changes: 14 additions & 1 deletion src/components/totp.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { watchEffect, ref, computed, onMounted, toRaw } from 'vue';
import { watchEffect, ref, computed, onMounted, watch, toRaw } from 'vue';
import { useI18n } from 'vue-i18n';
import AccountSelect from "./account-select";
Expand All @@ -13,6 +13,19 @@
let chain = computed(() => {
return store.getters['AccountStore/getChain'];
});
let selectedAccount = computed(() => {
if (!store.state.WalletStore.isUnlocked) {
return;
}
return store.getters["AccountStore/getCurrentSafeAccount"]()
})
watch(selectedAccount, async (newVal, oldVal) => {
console.log("User changed account - resetting configured scope!")
chosenScope.value = null;
selectedRows.value = null;
}, {immediate: true});
let compatible = ref(false);
let operationTypes = ref([]);
Expand Down
20 changes: 0 additions & 20 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,6 @@ let _blockchains = {
},
],
},
TUSC: {
coreSymbol: "TUSC",
name: "The Universal Settlement Coin",
chainId:
"eb938e2a955e39e335120d0a99f3b9f8c04a9ed5690275ea5037d6bbadfc6cf3",
nodeList: [
{
url: "wss://api.tusc.network/wallet",
},
{
url: "wss://api.cryptotusc.com",
},
{
url: "wss://tuscapi.gambitweb.com",
},
{
url: "wss://api.readyrhino.one",
},
],
},
EOS: {
coreSymbol: "EOS",
name: "EOSmainnet",
Expand Down
Loading

0 comments on commit 78c47e9

Please sign in to comment.