From b4baca34ea9613b2bfdc880dbf342bd17a567388 Mon Sep 17 00:00:00 2001 From: ennucore Date: Tue, 24 Jan 2023 22:38:05 +0100 Subject: [PATCH] Managing records --- .idea/workspace.xml | 6 ++- src/assets/icons/logout.svg | 24 +++++++++++ src/views/Checkout.vue | 1 - src/views/Explore.vue | 80 +++++++++++++++++++++++++++++++++++-- 4 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 src/assets/icons/logout.svg diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4f94cd3..f3324e9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,8 @@ + - @@ -92,7 +92,9 @@ - + + + 1670844191163 diff --git a/src/assets/icons/logout.svg b/src/assets/icons/logout.svg new file mode 100644 index 0000000..2f39f45 --- /dev/null +++ b/src/assets/icons/logout.svg @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/src/views/Checkout.vue b/src/views/Checkout.vue index 0c1662c..8ba91b1 100644 --- a/src/views/Checkout.vue +++ b/src/views/Checkout.vue @@ -56,7 +56,6 @@ export default { const transaction = { validUntil: validness, messages: [ - Object.assign({}, this.result.content_msg), Object.assign({}, this.result.buy_msg) ] } diff --git a/src/views/Explore.vue b/src/views/Explore.vue index b6602e3..d7b9ad2 100644 --- a/src/views/Explore.vue +++ b/src/views/Explore.vue @@ -25,13 +25,16 @@
is owned by
you
+ View nft

Wallet:

-
Save
+
+ Save +
@@ -39,7 +42,8 @@

Site:

-
Save
+
Save +
@@ -62,6 +66,7 @@ import RotateSquare2 from "../components/RotateSquare2.vue"; import {get_domain_result, get_records} from "../result"; import {convertAddress} from "../utils"; import contenteditable from 'vue-contenteditable'; +import {call_api} from "../api"; export default { name: "Explore", @@ -76,7 +81,9 @@ export default { result: null, records: null, wallet_rec: null, - site_rec: null + site_rec: null, + signingSite: false, + signingWallet: false } }, mounted() { @@ -109,8 +116,75 @@ export default { }, isMine() { return this.result.owner === this.$store.getters.address; + }, + walletChanged() { + return this.records && this.wallet_rec !== this.records.wallet; + }, + siteChanged() { + return this.records && this.site_rec !== this.records.site; } }, + methods: { + async saveWallet() { + if (!this.walletChanged) { + return; + } + // get the message from api at /set-record/site/{site} and sign it with tonconnect (from storage) + let message = await call_api('set-record/wallet/' + this.wallet_rec); + // send the message to tonconnect + let d = new Date(); + let validness = parseInt((d.getTime() / 1000).toFixed(0)) + 360000; + let transaction = { + validUntil: validness, + messages: [ + { + amount: (0.05 * 1000000000).toString(), + address: this.result.nft_info.address, + payload: message + } + ] + }; + this.signingWallet = true; + console.log("Sending transaction", transaction); + const result = await this.$store.state.connector.sendTransaction(transaction); + this.signingWallet = false; + if(!result.boc) { + // todo + } + get_records(this.result.nft_info.address).then(r => { + this.records = r; + }) + }, + async saveSite() { + if (!this.siteChanged) { + return; + } + // get the message from api at /set-record/site/{site} and sign it with tonconnect (from storage) + let message = await call_api('set-record/site/' + this.site_rec); + // send the message to tonconnect + let d = new Date(); + let validness = parseInt((d.getTime() / 1000).toFixed(0)) + 360000; + let transaction = { + validUntil: validness, + messages: [ + { + amount: (0.05 * 1000000000).toString(), + address: this.result.nft_info.address, + payload: message + } + ] + }; + this.signingSite = true; + const result = await this.$store.state.connector.sendTransaction(transaction); + this.signingSite = false; + if(!result.boc) { + // todo + } + get_records(this.result.nft_info.address).then(r => { + this.records = r; + }) + }, + }, watch: { records: function (val) { if (val) {