From e1bf2368bdcb5f02d326e0412d56c976730631ad Mon Sep 17 00:00:00 2001 From: ennucore Date: Thu, 5 Jan 2023 11:14:41 +0100 Subject: [PATCH] Checkout --- .idea/workspace.xml | 31 ++- src/components/Socket.vue | 539 ++++++++++++++++++++++++++++++++++++++ src/result.ts | 10 +- src/utils.ts | 12 + src/views/Checkout.vue | 35 ++- 5 files changed, 593 insertions(+), 34 deletions(-) create mode 100644 src/components/Socket.vue diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9cd20cd..462d1e4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,22 +1,12 @@ - - + + - - - - - - - - - - - + @@ -262,6 +259,8 @@ - \ No newline at end of file diff --git a/src/components/Socket.vue b/src/components/Socket.vue new file mode 100644 index 0000000..28e504d --- /dev/null +++ b/src/components/Socket.vue @@ -0,0 +1,539 @@ + + + + + diff --git a/src/result.ts b/src/result.ts index 731fc65..9605676 100644 --- a/src/result.ts +++ b/src/result.ts @@ -2,7 +2,7 @@ import {Zone} from "@/zone"; import {Collection} from "@/collection"; -import {parse_zone} from "@/utils"; +import {parse_zone, Message} from "@/utils"; let ex_collection = () => new Collection("example.ton", "Example collection"); @@ -12,15 +12,17 @@ export class Result { auction_price?: number; owner?: string; collection_required: Collection | null; - condition_fullfilled: boolean | null = null; + condition_fulfilled: boolean | null = null; + buy_msg: Message | null = null; - constructor(domain: string, buy_price?: number, auction_price?: number, owner?: string, collection_required: Collection | null = null, condition_fullfilled: boolean | null = null) { + constructor(domain: string, buy_price?: number, auction_price?: number, owner?: string, collection_required: Collection | null = null, condition_fulfilled: boolean | null = null, buy_msg: Message | null = null) { this.domain = domain; this.buy_price = buy_price; this.auction_price = auction_price; this.owner = owner; this.collection_required = collection_required; - this.condition_fullfilled = condition_fullfilled; + this.condition_fulfilled = condition_fulfilled; + this.buy_msg = buy_msg; } getRouteParams(): any { diff --git a/src/utils.ts b/src/utils.ts index 5dc0236..8a98431 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,3 +1,15 @@ +export class Message { + address: string; + amount: string; + payload: string; + + constructor(address: string, amount: string, payload: string) { + this.address = address; + this.amount = amount; + this.payload = payload; + } +} + export function qr_options(url: string, imageSize: number = 0.4, imageMargin: number = 3, margin: number = 10): any { return { width: 300, diff --git a/src/views/Checkout.vue b/src/views/Checkout.vue index 74ddafb..5dc66c0 100644 --- a/src/views/Checkout.vue +++ b/src/views/Checkout.vue @@ -11,12 +11,9 @@
To buy
-
Scan this:
-
-
-
-
- +
Confirm the transaction in your wallet
+
+
@@ -25,13 +22,13 @@ import DarkLayout from "../components/DarkLayout.vue"; import DomainBar from "../components/DomainBar.vue"; import {get_domain_result, get_ton_link} from "../result"; -import QRCodeStyling from 'qr-code-styling'; import RotateSquare2 from "../components/RotateSquare2.vue"; import {qr_options} from "../utils"; +import Socket from "../components/Socket.vue"; export default { name: "Checkout", - components: {RotateSquare2, DomainBar, DarkLayout}, + components: {Socket, RotateSquare2, DomainBar, DarkLayout}, props: { domain: { type: String, @@ -51,15 +48,25 @@ export default { async get_result() { this.result = await get_domain_result(this.domain + '.' + this.zone); this.ton_link = await get_ton_link(this.result); + }, + async sign_transaction() + { + await this.get_result(); + let d = new Date(); + let validness = parseInt((d.getTime() / 100).toFixed(0)) + 3600; + const transaction = { + validUntil: validness, + messages: [ + this.result.buy_msg + ] + } + await this.$store.state.connector.sendTransaction(transaction); + this.$router.push({name: 'Explore', params: {domain: this.domain + '.' + this.zone}}); } + }, mounted() { - this.get_result().then( - () => { - this.qr_code = new QRCodeStyling(this.options) - this.qr_code.append(this.$refs["qrCode"]) - } - ) + this.get_result() }, computed: { loaded() {