Renewing and updating is clean
This commit is contained in:
parent
d83126755b
commit
2ef74854e6
18
.eslintrc.js
18
.eslintrc.js
|
@ -1,20 +1,22 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
parserOptions: {
|
||||
parser: "babel-eslint"
|
||||
parser: "babel-eslint",
|
||||
ecmaVersion: 10,
|
||||
sourceType: "module"
|
||||
},
|
||||
env: {
|
||||
node: true,
|
||||
browser: true
|
||||
browser: true,
|
||||
es6: true
|
||||
},
|
||||
extends: [
|
||||
// "plugin:prettier/recommended",
|
||||
"plugin:vue/recommended",
|
||||
"eslint:recommended",
|
||||
"prettier/vue"
|
||||
"prettier/vue",
|
||||
"plugin:prettier/recommended"
|
||||
],
|
||||
// required to lint *.vue files
|
||||
plugins: ["vue", "prettier"],
|
||||
plugins: ["prettier"],
|
||||
globals: {
|
||||
__statics: true,
|
||||
__ryo_bin: true
|
||||
|
@ -23,7 +25,7 @@ module.exports = {
|
|||
rules: {
|
||||
// allow debugger during development
|
||||
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
|
||||
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
|
||||
"vue/component-name-in-template-casing": ["error", "PascalCase"]
|
||||
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
|
||||
// "vue/component-name-in-template-casing": ["error", "PascalCase"]
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
// intentionally blank
|
||||
module.exports = {
|
||||
semi: true,
|
||||
singleQuote: false,
|
||||
useTabs: false,
|
||||
trailingComma: "none",
|
||||
printWidth: 80
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "loki-electron-wallet",
|
||||
"version": "1.4.6",
|
||||
"version": "1.5.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -6138,9 +6138,9 @@
|
|||
}
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz",
|
||||
"integrity": "sha512-oB8cpLWSAjOVFEJhhyMZh6NOEOtBVziaqdDQ86+qhDHFbZXoRTM7pNSvFRfW/W/L/LrQ38C99J5CGuRBBzBsdA==",
|
||||
"version": "6.12.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.12.0.tgz",
|
||||
"integrity": "sha512-9jWPlFlgNwRUYVoujvWTQ1aMO8o6648r+K7qU7K5Jmkbyqav1fuEZC0COYpGBxyiAJb65Ra9hrmFx19xRGwXWw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"get-stdin": "^6.0.0"
|
||||
|
|
|
@ -53,12 +53,12 @@
|
|||
"electron-devtools-installer": "^2.2.4",
|
||||
"electron-notarize": "^0.1.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-config-prettier": "^6.12.0",
|
||||
"eslint-friendly-formatter": "^4.0.1",
|
||||
"eslint-loader": "^2.2.1",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
"eslint-plugin-node": "^8.0.1",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-vue": "^5.2.3",
|
||||
"husky": "^4.2.3",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import child_process from "child_process";
|
||||
|
||||
const request = require("request-promise");
|
||||
const queue = require("promise-queue");
|
||||
const http = require("http");
|
||||
|
@ -488,20 +489,18 @@ export class Daemon {
|
|||
if (!Array.isArray(owners) || owners.length === 0) {
|
||||
return [];
|
||||
}
|
||||
// NEED TO FIX THIS
|
||||
// console.log("Getting records for owners with owners:");
|
||||
// console.log(owners[0]);
|
||||
|
||||
// try just the main address as owner
|
||||
// only 256 addresses allowed in this call
|
||||
let ownersMax = owners.slice(0, 256);
|
||||
const data = await this.sendRPC("lns_owners_to_names", {
|
||||
entries: [owners[0]]
|
||||
entries: ownersMax
|
||||
});
|
||||
if (!data.hasOwnProperty("result")) return [];
|
||||
|
||||
// We need to map request_index to owner
|
||||
const { entries } = data.result;
|
||||
const recordsWithOwners = (entries || []).map(record => {
|
||||
const owner = owners[record.request_index];
|
||||
const owner = ownersMax[record.request_index];
|
||||
return {
|
||||
...record,
|
||||
owner
|
||||
|
@ -520,10 +519,8 @@ export class Daemon {
|
|||
entries: [
|
||||
{
|
||||
name_hash: nameHash,
|
||||
// Update this when we have other types.
|
||||
// 0 = session
|
||||
// 2+ = lokinet for different # years
|
||||
// TODO: Ensure these are actually the correct types
|
||||
// 2 = lokinet
|
||||
types: [0, 2]
|
||||
}
|
||||
]
|
||||
|
@ -535,8 +532,6 @@ export class Daemon {
|
|||
const entries = this._sanitizeLNSRecords(data.result.entries);
|
||||
if (entries.length === 0) return null;
|
||||
|
||||
// console.log("Returning entries 0 of entries:");
|
||||
// console.log(entries);
|
||||
return entries[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import child_process from "child_process";
|
||||
|
||||
const request = require("request-promise");
|
||||
const queue = require("promise-queue");
|
||||
const http = require("http");
|
||||
|
@ -363,7 +364,6 @@ export class WalletRPC {
|
|||
this.lnsRenewMapping(params.password, params.type, params.name);
|
||||
break;
|
||||
case "lns_known_names":
|
||||
console.log("LNS known records case");
|
||||
this.lnsKnownNames();
|
||||
break;
|
||||
case "update_lns_mapping":
|
||||
|
@ -987,9 +987,6 @@ export class WalletRPC {
|
|||
addresses
|
||||
);
|
||||
|
||||
// console.log("records from owners");
|
||||
// console.log(records);
|
||||
|
||||
// We need to ensure that we decrypt any incoming records that we already have
|
||||
const currentRecords = this.wallet_state.lnsRecords;
|
||||
const recordsToUpdate = { ...this.purchasedNames };
|
||||
|
@ -1021,12 +1018,13 @@ export class WalletRPC {
|
|||
};
|
||||
});
|
||||
|
||||
// what does this even do?? isn't state set through the gateway
|
||||
this.wallet_state.lnsRecords = newRecords;
|
||||
|
||||
// console.log("New LNS records found in update:");
|
||||
// console.log(newRecords);
|
||||
|
||||
// ========= FETCH THE CACHED RECORDS HERE AND JOIN WITH THE OTHER RECORDS =====
|
||||
// ===== UI DISPLAYS UNLOCKED RECORDS IF THE ENTRY HAS A 'name' and 'value' field
|
||||
// const isSession = record => record.type === "session";
|
||||
// let nonSessionRecords = newRecords.filter(record => !isSession(record));
|
||||
// console.log("non session records");
|
||||
|
@ -1101,8 +1099,6 @@ export class WalletRPC {
|
|||
lokinet_1y, lokinet_2y, lokinet_5y, lokinet_10y
|
||||
*/
|
||||
lnsRenewMapping(password, type, name) {
|
||||
console.log("Lns renew mapping called with type and name:");
|
||||
console.log(type, name);
|
||||
let _name = name.trim().toLowerCase();
|
||||
|
||||
// the RPC accepts names with the .loki already appeneded only
|
||||
|
@ -1140,11 +1136,8 @@ export class WalletRPC {
|
|||
name: _name
|
||||
};
|
||||
|
||||
console.log("lns renew mapping about to be called");
|
||||
this.sendRPC("lns_renew_mapping", params).then(data => {
|
||||
if (data.hasOwnProperty("error")) {
|
||||
console.log("error");
|
||||
console.log(data);
|
||||
let error =
|
||||
data.error.message.charAt(0).toUpperCase() +
|
||||
data.error.message.slice(1);
|
||||
|
@ -1518,7 +1511,6 @@ export class WalletRPC {
|
|||
|
||||
// submits the transaction to the blockchain, irreversible from here
|
||||
async relayTransaction(metadataList, isBlink, addressSave, note, isSweepAll) {
|
||||
console.log("Relay transaction called");
|
||||
// for a sweep these don't exist
|
||||
let address = "";
|
||||
let payment_id = "";
|
||||
|
|
|
@ -66,8 +66,9 @@ export default {
|
|||
timeout: 1000,
|
||||
message
|
||||
});
|
||||
|
||||
this.$refs.form.reset();
|
||||
this.renewing = false;
|
||||
this.updating = false;
|
||||
break;
|
||||
case -1:
|
||||
this.$q.notify({
|
||||
|
@ -110,12 +111,17 @@ export default {
|
|||
this.renewing = false;
|
||||
},
|
||||
async update(record, oldRecord) {
|
||||
console.log("update called");
|
||||
console.log(record);
|
||||
console.log(oldRecord);
|
||||
// Make sure we have a diff between the 2 records
|
||||
const isOwnerDifferent =
|
||||
record.owner !== "" && record.owner !== oldRecord.owner;
|
||||
const isBackupOwnerDifferent =
|
||||
record.backup_owner !== "" &&
|
||||
record.backup_owner !== oldRecord.backup_owner;
|
||||
console.log("old value: " + oldRecord.value);
|
||||
console.log("new value: " + record.value);
|
||||
const isValueDifferent = record.value !== oldRecord.value;
|
||||
const different =
|
||||
isOwnerDifferent || isBackupOwnerDifferent || isValueDifferent;
|
||||
|
@ -132,10 +138,12 @@ export default {
|
|||
|
||||
const updatedRecord = {
|
||||
...record,
|
||||
value: isValueDifferent ? record.value : "",
|
||||
value: isValueDifferent ? record.value : oldRecord.value,
|
||||
owner: isOwnerDifferent ? record.owner : "",
|
||||
backup_owner: isBackupOwnerDifferent ? record.backup_owner : ""
|
||||
};
|
||||
console.log("updated record");
|
||||
console.log(updatedRecord);
|
||||
|
||||
let passwordDialog = await this.showPasswordConfirmation({
|
||||
title: this.$t("dialog.lnsUpdate.title"),
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
:placeholder="owner_placeholder"
|
||||
borderless
|
||||
dense
|
||||
:disable="renewing"
|
||||
@blur="$v.record.owner.$touch"
|
||||
/>
|
||||
</LokiField>
|
||||
|
|
|
@ -9,17 +9,15 @@
|
|||
<q-icon :name="isLocked(record) ? 'lock' : 'lock_open'" size="24px" />
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label :class="bindClass(record)">
|
||||
{{ isLocked(record) ? record.name_hash : record.name }}
|
||||
</q-item-label>
|
||||
<q-item-label v-if="!isLocked(record)">
|
||||
{{ record.value }}
|
||||
</q-item-label>
|
||||
<q-item-label :class="bindClass(record)">{{
|
||||
isLocked(record) ? record.name_hash : record.name
|
||||
}}</q-item-label>
|
||||
<q-item-label v-if="!isLocked(record)">{{ record.value }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side class="height">
|
||||
<template v-if="isLocked(record)">
|
||||
{{ record.update_height | blockHeight }}
|
||||
</template>
|
||||
<template v-if="isLocked(record)">{{
|
||||
record.update_height | blockHeight
|
||||
}}</template>
|
||||
<template v-else>
|
||||
<q-item-section>
|
||||
<div class="row update-renew-buttons">
|
||||
|
@ -39,14 +37,12 @@
|
|||
</template>
|
||||
</q-item-section>
|
||||
<q-item-section v-if="!isLocked(record)" side>
|
||||
<span v-if="record.type === 'session'">
|
||||
{{ record.update_height | blockHeight }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ record.expiration_height | expirationHeight }}
|
||||
</span>
|
||||
<span v-if="record.type === 'session'">{{
|
||||
record.update_height | blockHeight
|
||||
}}</span>
|
||||
<span v-else>{{ record.expiration_height | expirationHeight }}</span>
|
||||
</q-item-section>
|
||||
<!-- <ContextMenu
|
||||
<ContextMenu
|
||||
:menu-items="validMenuItems(record)"
|
||||
@ownerCopy="copy(record.owner, $t('notification.positive.ownerCopied'))"
|
||||
@nameCopy="copy(record.name, $t('notification.positive.nameCopied'))"
|
||||
|
@ -57,7 +53,7 @@
|
|||
$t('notification.positive.backupOwnerCopied')
|
||||
)
|
||||
"
|
||||
/> -->
|
||||
/>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</template>
|
||||
|
@ -65,10 +61,14 @@
|
|||
<script>
|
||||
import { mapState } from "vuex";
|
||||
import { i18n } from "boot/i18n";
|
||||
// import ContextMenu from "components/menus/contextmenu";
|
||||
import ContextMenu from "components/menus/contextmenu";
|
||||
const { clipboard } = require("electron");
|
||||
|
||||
export default {
|
||||
name: "LNSRecordList",
|
||||
components: {
|
||||
ContextMenu
|
||||
},
|
||||
props: {
|
||||
recordList: {
|
||||
type: Array,
|
||||
|
@ -79,9 +79,6 @@ export default {
|
|||
required: true
|
||||
}
|
||||
},
|
||||
// components: {
|
||||
// ContextMenu
|
||||
// },
|
||||
computed: mapState({
|
||||
theme: state => state.gateway.app.config.appearance.theme
|
||||
}),
|
||||
|
@ -107,6 +104,56 @@ export default {
|
|||
},
|
||||
onRenew(record) {
|
||||
this.$emit("onRenew", record);
|
||||
},
|
||||
copyNameI18nLabel(record) {
|
||||
if (record.type === "session") {
|
||||
return "menuItems.copyName";
|
||||
} else {
|
||||
return "menuItems.copyLokinetName";
|
||||
}
|
||||
},
|
||||
copyValueI18nLabel(record) {
|
||||
if (record.type === "session") {
|
||||
return "menuItems.copySessionId";
|
||||
} else if (record.type === "lokinet") {
|
||||
return "menuItems.copyLokinetAddress";
|
||||
}
|
||||
return "menuItems.copyAddress";
|
||||
},
|
||||
validMenuItems(record) {
|
||||
// change name depending on if lokinet or session
|
||||
const lockedItems = [
|
||||
{ action: "nameCopy", i18n: this.copyNameI18nLabel(record) },
|
||||
{ action: "copyValue", i18n: this.copyValueI18nLabel(record) }
|
||||
];
|
||||
let menuItems = [{ action: "ownerCopy", i18n: "menuItems.copyOwner" }];
|
||||
const backupOwnerItem = [
|
||||
{ action: "backupOwnerCopy", i18n: "menuItems.copyBackupOwner" }
|
||||
];
|
||||
if (!this.isLocked(record)) {
|
||||
menuItems = [...lockedItems, ...menuItems];
|
||||
}
|
||||
if (record.backup_owner !== "") {
|
||||
menuItems = [...menuItems, ...backupOwnerItem];
|
||||
}
|
||||
return menuItems;
|
||||
},
|
||||
// can copy a value on unlock
|
||||
copyValue(record) {
|
||||
let message = this.$t("notification.positive.lokinetAddressCopied");
|
||||
if (record.type === "session") {
|
||||
message = this.$t("notification.positive.sessionIdCopied");
|
||||
}
|
||||
this.copy(record.value, message);
|
||||
},
|
||||
copy(value, message) {
|
||||
if (!value) return;
|
||||
clipboard.writeText(value.trim());
|
||||
this.$q.notify({
|
||||
type: "positive",
|
||||
timeout: 2000,
|
||||
message
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -50,11 +50,9 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const { clipboard } = require("electron");
|
||||
import { mapState } from "vuex";
|
||||
import LokiField from "components/loki_field";
|
||||
import { session_id_or_lokinet_name } from "src/validators/common";
|
||||
// import ContextMenu from "components/menus/contextmenu";
|
||||
import LNSRecordList from "./lns_record_list";
|
||||
|
||||
export default {
|
||||
|
@ -62,7 +60,6 @@ export default {
|
|||
components: {
|
||||
LokiField,
|
||||
LNSRecordList
|
||||
// ContextMenu
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -93,23 +90,6 @@ export default {
|
|||
}
|
||||
}),
|
||||
methods: {
|
||||
validMenuItems(record) {
|
||||
const lockedItems = [
|
||||
{ action: "nameCopy", i18n: "menuItems.copyName" },
|
||||
{ action: "copyValue", i18n: this.copyValueI18nLabel(record) }
|
||||
];
|
||||
let menuItems = [{ action: "ownerCopy", i18n: "menuItems.copyOwner" }];
|
||||
const backupOwnerItem = [
|
||||
{ action: "backupOwnerCopy", i18n: "menuItems.copyBackupOwner" }
|
||||
];
|
||||
if (!this.isLocked(record)) {
|
||||
menuItems = [...lockedItems, ...menuItems];
|
||||
}
|
||||
if (record.backup_owner !== "") {
|
||||
menuItems = [...menuItems, ...backupOwnerItem];
|
||||
}
|
||||
return menuItems;
|
||||
},
|
||||
records_of_type(state, type) {
|
||||
// receives the type and returns the records of that type
|
||||
const ourAddresses = this.ourAddresses;
|
||||
|
@ -137,14 +117,6 @@ export default {
|
|||
isLocked(record) {
|
||||
return !record.name || !record.value;
|
||||
},
|
||||
copyValueI18nLabel(record) {
|
||||
if (record.type === "session") {
|
||||
return "menuItems.copySessionId";
|
||||
} else if (record.type === "lokinet") {
|
||||
return "menuItems.copyLokinetName";
|
||||
}
|
||||
return "menuItems.copyAddress";
|
||||
},
|
||||
onUpdate(record) {
|
||||
this.$emit("onUpdate", record);
|
||||
},
|
||||
|
@ -205,23 +177,6 @@ export default {
|
|||
type
|
||||
});
|
||||
this.decrypting = true;
|
||||
},
|
||||
// TODO: Update this
|
||||
copyValue(record) {
|
||||
let message = this.$t("notification.positive.addressCopied");
|
||||
if (record.type === "session") {
|
||||
message = this.$t("notification.positive.sessionIdCopied");
|
||||
}
|
||||
this.copy(record.value, message);
|
||||
},
|
||||
copy(value, message) {
|
||||
if (!value) return;
|
||||
clipboard.writeText(value.trim());
|
||||
this.$q.notify({
|
||||
type: "positive",
|
||||
timeout: 2000,
|
||||
message
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -270,6 +270,8 @@ export default {
|
|||
changePassword: "Change Password",
|
||||
copyAddress: "Copy address",
|
||||
copyBackupOwner: "Copy backup owner",
|
||||
copyLokinetAddress: "Copy lokinet address",
|
||||
copyLokinetName: "Copy lokinet name",
|
||||
copyName: "Copy name",
|
||||
copyOwner: "Copy owner",
|
||||
copyQR: "Copy QR code",
|
||||
|
@ -310,6 +312,8 @@ export default {
|
|||
imported: "Key images imported"
|
||||
},
|
||||
lnsRecordUpdated: "LNS Record was successfully updated",
|
||||
lokinetAddressCopied: "Full lokinet address copied",
|
||||
lokinetNameCopied: "Lokinet name copied",
|
||||
passwordUpdated: "Password updated",
|
||||
namePurchased: "Name successfully purchased",
|
||||
nameRenewed: "Name successfully renewed",
|
||||
|
|
Loading…
Reference in New Issue