diff --git a/.eslintrc.js b/.eslintrc.js index 6ddd910..fb4e449 100644 --- a/.eslintrc.js +++ b/.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"] } }; diff --git a/.prettierrc.js b/.prettierrc.js index 65e2cc3..e0e0ce3 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1 +1,7 @@ -// intentionally blank +module.exports = { + semi: true, + singleQuote: false, + useTabs: false, + trailingComma: "none", + printWidth: 80 +}; diff --git a/package-lock.json b/package-lock.json index 1badd9d..89cf488 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" diff --git a/package.json b/package.json index ca49866..0ece62c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src-electron/main-process/modules/daemon.js b/src-electron/main-process/modules/daemon.js index a09fec2..63859bd 100644 --- a/src-electron/main-process/modules/daemon.js +++ b/src-electron/main-process/modules/daemon.js @@ -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]; } diff --git a/src-electron/main-process/modules/wallet-rpc.js b/src-electron/main-process/modules/wallet-rpc.js index 37948b7..fd95be1 100644 --- a/src-electron/main-process/modules/wallet-rpc.js +++ b/src-electron/main-process/modules/wallet-rpc.js @@ -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 = ""; diff --git a/src/components/lns/lns_input.vue b/src/components/lns/lns_input.vue index 7e05a17..c65fbc1 100644 --- a/src/components/lns/lns_input.vue +++ b/src/components/lns/lns_input.vue @@ -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"), diff --git a/src/components/lns/lns_input_form.vue b/src/components/lns/lns_input_form.vue index 0d00c31..fa4f607 100644 --- a/src/components/lns/lns_input_form.vue +++ b/src/components/lns/lns_input_form.vue @@ -73,6 +73,7 @@ :placeholder="owner_placeholder" borderless dense + :disable="renewing" @blur="$v.record.owner.$touch" /> diff --git a/src/components/lns/lns_record_list.vue b/src/components/lns/lns_record_list.vue index 199186d..83a9465 100644 --- a/src/components/lns/lns_record_list.vue +++ b/src/components/lns/lns_record_list.vue @@ -9,17 +9,15 @@ - - {{ isLocked(record) ? record.name_hash : record.name }} - - - {{ record.value }} - + {{ + isLocked(record) ? record.name_hash : record.name + }} + {{ record.value }} - + - - {{ record.update_height | blockHeight }} - - - {{ record.expiration_height | expirationHeight }} - + {{ + record.update_height | blockHeight + }} + {{ record.expiration_height | expirationHeight }} - + /> @@ -65,10 +61,14 @@