Skip to content

Commit

Permalink
Merge pull request #59 from bitshares/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
clockworkgr authored Feb 6, 2019
2 parents 3e67639 + ae0b025 commit 8bf3e74
Show file tree
Hide file tree
Showing 26 changed files with 2,560 additions and 935 deletions.
302 changes: 270 additions & 32 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "beet",
"productName": "beet",
"version": "0.3.4",
"version": "0.4.2",
"description": "Beet is a stand-alone key-manager and signing app for BitShares.",
"main": "src/index.js",
"scripts": {
Expand Down Expand Up @@ -55,6 +55,8 @@
},
"dependencies": {
"@panter/vue-i18next": "^0.15.0",
"@smokenetwork/smoke-js": "^0.1.2",
"@whaleshares/wlsjs": "^0.1.1",
"bitsharesjs": "^1.8.3",
"bootstrap-vue": "^2.0.0-rc.11",
"chalk": "^2.4.2",
Expand All @@ -68,6 +70,7 @@
"i18next-node-fs-backend": "^2.1.1",
"otpauth": "^3.2.2",
"readline": "^1.3.0",
"steem": "^0.7.4",
"typeface-rajdhani": "0.0.54",
"typeface-roboto": "0.0.54",
"uuid": "^3.3.2",
Expand Down
59 changes: 12 additions & 47 deletions src/components/balances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,40 @@
<div class="balances mt-3">
<p class="mb-1 font-weight-bold small">{{ $t('balances_lbl') }}</p>
<table class="table small table-striped table-sm">
<tbody>
<tbody v-if="balances != null">
<tr
v-for="balance in balances"
:key="balance.id"
>
<td class="text-left"><span class="small">{{ balance.prefix }}</span>{{ balance.asset_name }}</td>
<td class="text-right">{{ balance.balance }}</td>
</tr>
<tr v-if="balances.length == 0">
<td class="text-left"><span class="small" />No balances</td>
<td class="text-right">-</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import { Apis } from "bitsharesjs-ws";
import getBlockchain from "../lib/blockchains/blockchainFactory"
export default {
name: "Balances",
i18nOptions: { namespaces: "common" },
data() {
return {
rawbalances: [],
balances: []
balances: null
};
},
mounted() {},
methods: {
getBalances: async function() {
let result = await Apis.instance()
.db_api()
.exec("get_full_accounts", [
[this.$store.state.WalletStore.wallet.accountID],
false
])
.then(res => {
this.rawbalances = res[0][1].balances;
let neededassets = [];
for (var i = 0; i < res[0][1].balances.length; i++) {
neededassets.push(res[0][1].balances[i].asset_type);
}
return Apis.instance()
.db_api()
.exec("get_objects", [neededassets]);
});
this.balances = [];
for (var i = 0; i < this.rawbalances.length; i++) {
if (result[i].issuer == "1.2.0") {
this.balances[i] = {
asset_type: this.rawbalances[i].asset_type,
asset_name: result[i].symbol,
balance: this.rawbalances[i].balance,
owner: result[i].issuer,
prefix: "BIT"
};
} else {
this.balances[i] = {
asset_type: this.rawbalances[i].asset_type,
asset_name: result[i].symbol,
rawbalance: this.rawbalances[i].balance,
balance: this.formatMoney(
this.rawbalances[i].balance /
Math.pow(10, result[i].precision),
result[i].precision
),
owner: result[i].issuer,
prefix: ""
};
}
}
return;
getBalances: function() {
let blockchain = getBlockchain(this.$store.state.WalletStore.wallet.chain);
blockchain.getBalances(this.$store.state.WalletStore.wallet.accountName).then((balances) => {
this.balances = balances;
});
},
formatMoney: function(n, decimals, decimal_sep, thousands_sep) {
var c = isNaN(decimals) ? 2 : Math.abs(decimals),
Expand Down
2 changes: 0 additions & 2 deletions src/components/beetframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
</div>
</template>
<script>
import { EventBus } from '../lib/event-bus.js';
import {
ipcRenderer,
} from 'electron';
Expand Down
95 changes: 48 additions & 47 deletions src/components/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<input
id="inputActive"
v-model="activepk"
type="text"
type="password"
class="form-control mb-3 small"
:placeholder="$t('active_authority_placeholder')"
required=""
Expand All @@ -83,7 +83,7 @@
<input
id="inputMemo"
v-model="memopk"
type="text"
type="password"
class="form-control mb-3 small"
:placeholder="$t('memo_authority_placeholder')"
required=""
Expand All @@ -101,7 +101,7 @@
<input
id="inputOwner"
v-model="ownerpk"
type="text"
type="password"
class="form-control mb-3 small"
:placeholder="$t('owner_authority_placeholder')"
required=""
Expand Down Expand Up @@ -180,11 +180,11 @@
</template>

<script>
import { PrivateKey } from "bitsharesjs";
import { Apis } from "bitsharesjs-ws";
import { chainList } from "../config/config.js";
import { blockchains } from "../config/config.js";
import RendererLogger from "../lib/RendererLogger";
import getBlockchain from "../lib/blockchains/blockchainFactory"
const logger = new RendererLogger();
export default {
Expand All @@ -205,7 +205,7 @@ export default {
includeOwner: 0,
errorMsg: "",
selectedChain: 0,
chainList: chainList
chainList: Object.values(blockchains)
};
},
methods: {
Expand Down Expand Up @@ -243,55 +243,55 @@ export default {
this.$refs.errorModal.show();
return;
}
let blockchain = getBlockchain(this.selectedChain);
try {
apkey = PrivateKey.fromWif(this.activepk)
.toPublicKey()
.toString(this.selectedChain);
mpkey = PrivateKey.fromWif(this.memopk)
.toPublicKey()
.toString(this.selectedChain);
apkey = blockchain.getPublicKey(this.activepk);
mpkey = blockchain.getPublicKey(this.memopk);
if (this.includeOwner == 1) {
opkey = PrivateKey.fromWif(this.ownerpk)
.toPublicKey()
.toString(this.selectedChain);
opkey =blockchain.getPublicKey(this.ownerpk);
}
} catch (e) {
console.error(e);
this.errorMsg = this.$t("invalid_key_error");
this.$refs.errorModal.show();
return;
}
this.$refs.loaderAnimModal.show();
let verified = await Apis.instance(
this.$store.state.SettingsStore.settings.selected_node,
true
).init_promise.then(() => {
return Apis.instance()
.db_api()
.exec("get_full_accounts", [[this.accountname], false])
.then(res => {
// TODO: Better verification
if (
res[0][1].account.active.key_auths[0][0] == apkey &&
(res[0][1].account.owner.key_auths[0][0] == opkey ||
this.includeOwner == 0) &&
res[0][1].account.options.memo_key == mpkey
) {
this.$refs.loaderAnimModal.hide();
return res[0][1].account.id;
} else {
this.$refs.loaderAnimModal.hide();
this.$refs.errorModal.show();
this.errorMsg = this.$t("unverified_account_error");
return null;
}
});
blockchain.getAccount(this.accountname).then((account) => {
console.log(account);
let active_check = false;
account.active.public_keys.forEach((key) => {
if (key[0] == apkey) {
active_check = true;
}
});
let owner_check = !this.includeOwner;
account.owner.public_keys.forEach((key) => {
if (key[0] == opkey) {
owner_check = true;
}
});
let memo_check = account.memo.public_key == mpkey;
if (active_check && owner_check && memo_check) {
this.$refs.loaderAnimModal.hide();
this.accountID = account.id;
this.step = 3;
} else {
this.$refs.loaderAnimModal.hide();
this.$refs.errorModal.show();
this.errorMsg = this.$t("unverified_account_error");
this.accountID = "";
}
}).catch((err) => {
console.log(err);
this.$refs.loaderAnimModal.hide();
this.$refs.errorModal.show();
this.errorMsg = this.$t("unverified_account_error");
this.accountID = "";
});
if (verified != null) {
this.accountID = verified;
this.step = 3;
} else {
return;
}
},
verifyAndCreate: async function() {
if (this.password != this.confirmpassword || this.password == "") {
Expand All @@ -316,8 +316,9 @@ export default {
memo: this.memopk
}
}
}).then(() => {
this.$router.replace("/dashboard");
});
this.$router.replace("/dashboard");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/header-small.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<script>
import LangSelect from "./lang-select";
export default {
name: "HeaderSmall",
i18nOptions: { namespaces: "common" },
Expand Down
2 changes: 0 additions & 2 deletions src/components/lang-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import { locales } from "../config/i18n.js";
import Multiselect from 'vue-multiselect'
import i18next from 'i18next';
export default {
name: "LangSelect",
Expand Down
Loading

0 comments on commit 8bf3e74

Please sign in to comment.