From c4eb822b0dd579454b9c945a411b7bfaec54296e Mon Sep 17 00:00:00 2001 From: Kyle Zsembery Date: Wed, 7 Oct 2020 14:02:44 +1100 Subject: [PATCH] WIP: LNS displaying owned records --- .github/workflows/build.yml | 1 + src-electron/main-process/modules/daemon.js | 26 +- .../main-process/modules/wallet-rpc.js | 12 + src/components/lns/lns_mylns.vue | 6 +- src/components/lns/lns_record_list.vue | 311 ++++-------------- src/components/lns/lns_records.vue | 267 +++++++++++++++ src/components/settings.vue | 2 + 7 files changed, 366 insertions(+), 259 deletions(-) create mode 100644 src/components/lns/lns_records.vue diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10e438f..a6392ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: branches: - master - development + - lokinet-name-reg jobs: build: diff --git a/src-electron/main-process/modules/daemon.js b/src-electron/main-process/modules/daemon.js index 28e354b..c512dae 100644 --- a/src-electron/main-process/modules/daemon.js +++ b/src-electron/main-process/modules/daemon.js @@ -488,8 +488,15 @@ export class Daemon { if (!Array.isArray(owners) || owners.length === 0) { return []; } + console.log("Getting records for owners with owners:"); + console.log(owners[0]); - const data = await this.sendRPC("lns_owners_to_names", { entries: owners }); + // try just the main address as owner + const data = await this.sendRPC("lns_owners_to_names", { + entries: [owners[0]] + }); + console.log("data returned from lns_owners_to_names call"); + console.log(data); if (!data.hasOwnProperty("result")) return []; // We need to map request_index to owner @@ -514,7 +521,11 @@ export class Daemon { entries: [ { name_hash: nameHash, - types: [0] // Update this when we have other types. Type 0 = session + // Update this when we have other types. + // 0 = session + // 2+ = lokinet for different # years + // TODO: Ensure these are actually the correct types + types: [0, 2] } ] }; @@ -525,15 +536,22 @@ 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]; } _sanitizeLNSRecords(records) { + console.log("sanitizing lns records: "); return (records || []).map(record => { // Record type is in uint16 format // Session = 0 - // For now since wallet and loki names haven't been implemented, we always assume it's session - const type = "session"; + console.log("record is "); + console.log(record); + let type = "lokinet"; + if (record.type === 0) { + type = "session"; + } return { ...record, type diff --git a/src-electron/main-process/modules/wallet-rpc.js b/src-electron/main-process/modules/wallet-rpc.js index 17e015a..ddf9399 100644 --- a/src-electron/main-process/modules/wallet-rpc.js +++ b/src-electron/main-process/modules/wallet-rpc.js @@ -963,6 +963,7 @@ export class WalletRPC { } async updateLocalLNSRecords() { + console.log("calling updateLocalLNSRecords"); try { const addressData = await this.sendRPC( "get_address", @@ -985,6 +986,9 @@ 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 }; @@ -1016,6 +1020,14 @@ export class WalletRPC { }; }); this.wallet_state.lnsRecords = newRecords; + // console.log("New LNS records found in update:"); + // console.log(newRecords); + + const isSession = record => record.type === "session"; + let nonSessionRecords = newRecords.filter(record => !isSession(record)); + console.log("non session records"); + console.log(nonSessionRecords); + this.sendGateway("set_wallet_data", { lnsRecords: newRecords }); // Decrypt the records serially diff --git a/src/components/lns/lns_mylns.vue b/src/components/lns/lns_mylns.vue index 8dfb56a..36009a2 100644 --- a/src/components/lns/lns_mylns.vue +++ b/src/components/lns/lns_mylns.vue @@ -4,18 +4,18 @@
{{ $t("strings.myLnsDescription") }}
- + diff --git a/src/components/lns/lns_record_list.vue b/src/components/lns/lns_record_list.vue index 7eb6abc..8d20bc7 100644 --- a/src/components/lns/lns_record_list.vue +++ b/src/components/lns/lns_record_list.vue @@ -1,281 +1,88 @@ - + diff --git a/src/components/lns/lns_records.vue b/src/components/lns/lns_records.vue new file mode 100644 index 0000000..bbb0df2 --- /dev/null +++ b/src/components/lns/lns_records.vue @@ -0,0 +1,267 @@ + + + + + diff --git a/src/components/settings.vue b/src/components/settings.vue index b330470..79d5dda 100644 --- a/src/components/settings.vue +++ b/src/components/settings.vue @@ -131,6 +131,8 @@ export default { }, methods: { save() { + console.log("pending config to save"); + console.log(this.pending_config); this.$gateway.send("core", "save_config", this.pending_config); this.isVisible = false; },