|
|
@ -1,9 +1,9 @@ |
|
|
|
// import {call_api} from "@/api";
|
|
|
|
// import {call_api} from "@/api";
|
|
|
|
|
|
|
|
|
|
|
|
import {Zone} from "@/zone"; |
|
|
|
import { Zone } from "@/zone"; |
|
|
|
import type {Message} from "@/utils"; |
|
|
|
import type { Message } from "@/utils"; |
|
|
|
import type {Collection} from "@/collection"; |
|
|
|
import type { Collection } from "@/collection"; |
|
|
|
import {call_api} from "@/api"; |
|
|
|
import { call_api } from "@/api"; |
|
|
|
|
|
|
|
|
|
|
|
// let ex_collection = () => new Collection("example.ton", "Example collection");
|
|
|
|
// let ex_collection = () => new Collection("example.ton", "Example collection");
|
|
|
|
|
|
|
|
|
|
|
@ -18,7 +18,17 @@ export class Result { |
|
|
|
content_msg: Message | null = null; |
|
|
|
content_msg: Message | null = null; |
|
|
|
nft_info?: any; |
|
|
|
nft_info?: any; |
|
|
|
|
|
|
|
|
|
|
|
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, content_msg: Message | null = null, nft_info?: any) { |
|
|
|
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, |
|
|
|
|
|
|
|
content_msg: Message | null = null, |
|
|
|
|
|
|
|
nft_info?: any |
|
|
|
|
|
|
|
) { |
|
|
|
this.domain = domain; |
|
|
|
this.domain = domain; |
|
|
|
this.buy_price = buy_price; |
|
|
|
this.buy_price = buy_price; |
|
|
|
this.auction_price = auction_price; |
|
|
|
this.auction_price = auction_price; |
|
|
@ -41,27 +51,45 @@ export class Result { |
|
|
|
let content_msg = data.content_msg; |
|
|
|
let content_msg = data.content_msg; |
|
|
|
let nft_info = data.nft_info; |
|
|
|
let nft_info = data.nft_info; |
|
|
|
|
|
|
|
|
|
|
|
return new Result(domain, buy_price, auction_price, owner, collection_required, condition_fulfilled, buy_msg, content_msg, nft_info); |
|
|
|
return new Result( |
|
|
|
|
|
|
|
domain, |
|
|
|
|
|
|
|
buy_price, |
|
|
|
|
|
|
|
auction_price, |
|
|
|
|
|
|
|
owner, |
|
|
|
|
|
|
|
collection_required, |
|
|
|
|
|
|
|
condition_fulfilled, |
|
|
|
|
|
|
|
buy_msg, |
|
|
|
|
|
|
|
content_msg, |
|
|
|
|
|
|
|
nft_info |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getRouteParams(): any { |
|
|
|
getRouteParams(): any { |
|
|
|
return { |
|
|
|
return { |
|
|
|
domain_init: /* domain up to . */ this.domain.split('.')[0], |
|
|
|
domain_init: /* domain up to . */ this.domain.split(".")[0], |
|
|
|
domain: /* domain up to . */ this.domain.split('.')[0], |
|
|
|
domain: /* domain up to . */ this.domain.split(".")[0], |
|
|
|
zone: /* domain after . */ this.domain.split('.').slice(1).join('.') |
|
|
|
zone: /* domain after . */ this.domain.split(".").slice(1).join("."), |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
canAuction(): boolean { |
|
|
|
canAuction(): boolean { |
|
|
|
return this.auction_price !== undefined && this.auction_price !== null && this.owner === undefined; |
|
|
|
return ( |
|
|
|
|
|
|
|
this.auction_price !== undefined && |
|
|
|
|
|
|
|
this.auction_price !== null && |
|
|
|
|
|
|
|
this.owner === undefined |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
canBuy(): boolean { |
|
|
|
canBuy(): boolean { |
|
|
|
return this.buy_price !== undefined && this.buy_price !== null && this.owner === undefined; |
|
|
|
return ( |
|
|
|
|
|
|
|
this.buy_price !== undefined && |
|
|
|
|
|
|
|
this.buy_price !== null && |
|
|
|
|
|
|
|
this.owner === undefined |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
zone(): string { |
|
|
|
zone(): string { |
|
|
|
return this.domain.split('.').slice(1).join('.'); |
|
|
|
return this.domain.split(".").slice(1).join("."); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -70,7 +98,7 @@ export class Result { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
export async function get_search_results(query: string) { |
|
|
|
export async function get_search_results(query: string) { |
|
|
|
return Result.fromBackend(await call_api('find/' + query)); |
|
|
|
return Result.fromBackend(await call_api("find/" + query)); |
|
|
|
/*await sleep(200); |
|
|
|
/*await sleep(200); |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
new Result(query + '.ton', 5, 3), |
|
|
|
new Result(query + '.ton', 5, 3), |
|
|
@ -81,7 +109,7 @@ export async function get_search_results(query: string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function get_domain_result(domain: string, _address?: string) { |
|
|
|
export async function get_domain_result(domain: string, _address?: string) { |
|
|
|
return Result.fromBackend(await call_api('get/' + domain)); |
|
|
|
return Result.fromBackend(await call_api("get/" + domain)); |
|
|
|
/*await sleep(100); |
|
|
|
/*await sleep(100); |
|
|
|
if (domain === 'test.ton') { |
|
|
|
if (domain === 'test.ton') { |
|
|
|
return new Result(domain); |
|
|
|
return new Result(domain); |
|
|
@ -105,12 +133,26 @@ export async function get_domain_result(domain: string, _address?: string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function get_records(address: string) { |
|
|
|
export async function get_records(address: string) { |
|
|
|
return await call_api('records/' + address); |
|
|
|
return await call_api("records/" + address); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function get_zones() { |
|
|
|
export async function get_zones() { |
|
|
|
let zones_back = await call_api('zones'); |
|
|
|
let zones_back = await call_api("zones"); |
|
|
|
return zones_back.map((zone: any) => new Zone(zone.zone, zone.price_buy_1, zone.price_buy_2, zone.collection_required, zone.price_auction_1, zone.price_auction_2, zone.min_length, zone.length_1, zone.length_2, zone.address)); |
|
|
|
return zones_back.map( |
|
|
|
|
|
|
|
(zone: any) => |
|
|
|
|
|
|
|
new Zone( |
|
|
|
|
|
|
|
zone.zone, |
|
|
|
|
|
|
|
zone.price_buy_1, |
|
|
|
|
|
|
|
zone.price_buy_2, |
|
|
|
|
|
|
|
zone.collection_required, |
|
|
|
|
|
|
|
zone.price_auction_1, |
|
|
|
|
|
|
|
zone.price_auction_2, |
|
|
|
|
|
|
|
zone.min_length, |
|
|
|
|
|
|
|
zone.length_1, |
|
|
|
|
|
|
|
zone.length_2, |
|
|
|
|
|
|
|
zone.address |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
/*await sleep(10); |
|
|
|
/*await sleep(10); |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
new Zone("example.ton", 3, 5, ex_collection()), |
|
|
|
new Zone("example.ton", 3, 5, ex_collection()), |
|
|
@ -141,24 +183,42 @@ export class TonLink { |
|
|
|
|
|
|
|
|
|
|
|
// Get the link for buying a domain
|
|
|
|
// Get the link for buying a domain
|
|
|
|
export function get_ton_link(res: Result) { |
|
|
|
export function get_ton_link(res: Result) { |
|
|
|
return new TonLink(res.zone(), 'b/' + res.domain, res.buy_price!); |
|
|
|
return new TonLink(res.zone(), "b/" + res.domain, res.buy_price!); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export let link_types = ['telegram', /*'website',*/ 'getgems', 'email']; |
|
|
|
export let link_types = ["telegram", /*'website',*/ "getgems", "email"]; |
|
|
|
export let link_icons = {'telegram': 'fab fa-telegram', 'website': 'material-icons language', 'getgems': 'fas fa-gem', 'email': 'fas fa-envelope'}; |
|
|
|
export let link_icons = { |
|
|
|
export let default_links = {'telegram': 'https://t.me/', 'website': 'https://', 'getgems': 'https://getgems.org/', 'email': 'example@example.org'}; |
|
|
|
telegram: "fab fa-telegram", |
|
|
|
|
|
|
|
website: "material-icons language", |
|
|
|
|
|
|
|
getgems: "fas fa-gem", |
|
|
|
|
|
|
|
email: "fas fa-envelope", |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
export let default_links = { |
|
|
|
|
|
|
|
telegram: "https://t.me/", |
|
|
|
|
|
|
|
website: "https://", |
|
|
|
|
|
|
|
getgems: "https://getgems.org/", |
|
|
|
|
|
|
|
email: "example@example.org", |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export class SiteConstructorParams { |
|
|
|
export class SiteConstructorParams { |
|
|
|
domain: string; |
|
|
|
domain: string; |
|
|
|
title: string; |
|
|
|
title: string; |
|
|
|
description: string; |
|
|
|
description: string; |
|
|
|
contacts: Map<string, string> = new Map<string, string>(); |
|
|
|
contacts: Map<string, string> = new Map<string, string>(); |
|
|
|
|
|
|
|
template_id: string; |
|
|
|
constructor(domain: string, title: string = '', description: string = '', contacts: Map<string, string> = new Map<string, string>()) { |
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
|
|
|
|
domain: string, |
|
|
|
|
|
|
|
title: string = "", |
|
|
|
|
|
|
|
description: string = "", |
|
|
|
|
|
|
|
contacts: Map<string, string> = new Map<string, string>(), |
|
|
|
|
|
|
|
template_id: string = "" |
|
|
|
|
|
|
|
) { |
|
|
|
this.domain = domain; |
|
|
|
this.domain = domain; |
|
|
|
this.title = title; |
|
|
|
this.title = title; |
|
|
|
this.description = description; |
|
|
|
this.description = description; |
|
|
|
this.contacts = contacts; |
|
|
|
this.contacts = contacts; |
|
|
|
|
|
|
|
this.template_id = template_id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
copy(): SiteConstructorParams { |
|
|
|
copy(): SiteConstructorParams { |
|
|
@ -167,6 +227,12 @@ export class SiteConstructorParams { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function get_constr_params(domain: string) { |
|
|
|
export async function get_constr_params(domain: string) { |
|
|
|
let res = await call_api('get-site-data/' + domain); |
|
|
|
let res = await call_api("get-site-data/" + domain); |
|
|
|
return new SiteConstructorParams(res.domain, res.title, res.description, res.contacts); |
|
|
|
return new SiteConstructorParams( |
|
|
|
|
|
|
|
res.domain, |
|
|
|
|
|
|
|
res.title, |
|
|
|
|
|
|
|
res.description, |
|
|
|
|
|
|
|
res.contacts, |
|
|
|
|
|
|
|
res.template_id |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|