Commit 67d43f9a by haojie

1

parent 74cabc7d
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
location / {
try_files $uri $uri/ /index.php?$query_string;
}
\ No newline at end of file
<template> <template>
<Head :title="info.title" /> <Head :title="info.title" />
<Layout> </Layout> <Layout>
<Navbar title="铭文查询" content="检测改铭文ID是否已被铸造"></Navbar>
<div class="inscription-search-box">
<!-- input -->
<CustomInput v-model="inputValue" :clear="true" @search="onSearch">
</CustomInput>
</div>
<div class="inscription-search-content">
<div class="inscription-search-table">
<CustomTable
:data="tableList"
:columns="columns"
:loading="loading"
></CustomTable>
</div>
</div>
</Layout>
</template> </template>
<script setup lang="ts"> <script lang="tsx" setup>
import Layout from "@/layout/index.vue"; import Layout from "@/layout/index.vue";
import { Head } from "@inertiajs/vue3"; import { Head } from "@inertiajs/vue3";
import { ref } from "vue"; import Navbar from "@/components/navbar.vue";
import CustomTable from "@/components/table.vue";
import CustomInput from "@/components/input/index.vue";
import { reactive, ref } from "vue";
import TipsSvg from "@/assets/svg/content/tips.svg";
import CustomTooltip from "@/components/tooltip.vue";
import { inscriptionWasCast } from "@/utils/api/external";
import { showMessage, isDev, getMask, timeFormatSeconds } from "@/utils/tool";
import { test_wallet_list } from "@/constants/testData";
defineProps({ info: Object }); defineProps({ info: Object });
/**
* 按钮组的value
*/
const groupBtn_all = "all";
// 搜索框的值
const inputValue = ref("");
const pageNum = ref(1);
const pageSize = ref(10);
const loading = ref(false);
// 接口返回的列表
const allTableList = reactive({
[groupBtn_all]: [],
});
// 页面展示的列表
const tableList = ref([]);
// 上次搜索的地址
const oldAddress = ref("");
// 打开hash链接
const openLink = (value) => {
if (!value) {
showMessage("没有hash");
return;
}
const url = "https://etherscan.io/tx/" + value;
window.open(url);
};
const columns = [
{
colKey: "name",
title: "名称",
align: "center",
className: "font700",
width: "10%",
},
{
colKey: "number",
title: "数量",
align: "center",
className: "font700",
width: "10%",
},
{
colKey: "creator",
title: "铸造者",
align: "center",
className: "public-style font700",
},
{
colKey: "current_owner",
title: "当前持有者",
align: "center",
className: "public-style font700",
},
{
colKey: "creation_timestamp",
title: "锻造时间",
align: "center",
className: "public-style font700",
},
{
colKey: "content_uri",
title: "铭文数据",
align: "center",
cell: (h, { col, row }) => (
<div>
<CustomTooltip content={row[col.colKey]}>
<span class="tip-span">查看</span>
</CustomTooltip>
</div>
),
},
{
colKey: "transaction_hash",
title: (h, { colIndex }) => (
<span class="table-tip-label">
Hash
<CustomTooltip
content="您当前拥有的资产被铸造出来时的hash,在erc20协议中,
该hash的转移为表示所有转移权"
>
<span class="tip">
<TipsSvg></TipsSvg>
</span>
</CustomTooltip>
</span>
),
align: "center",
cell: (h, { col, row }) => (
<div
class="tip-span open-link"
onClick={openLink.bind(this, row[col.colKey])}
>
Etherscan
</div>
),
},
];
const listResult = (list: any[]) => {
// 分别过滤出对应的列表
list.forEach((item: any) => {
item.creator = getMask(item.creator);
item.current_owner = getMask(item.current_owner);
item.creation_timestamp = timeFormatSeconds(item.creation_timestamp);
// 过滤出名称和数量
const match = item.content_uri.match(/{.*}/);
if (match) {
const jsonStr = match[0];
const jsonObject = JSON.parse(jsonStr);
item.name = jsonObject.tick;
item.number = jsonObject.amt;
} else {
console.log("content_uri格式错误");
console.log(item.content_uri);
}
});
// 全部数据
allTableList[groupBtn_all] = list;
};
const getList = async () => {
try {
if (!inputValue.value) {
showMessage("未输入钱包地址");
return;
}
if (isDev()) {
// 本地环境
let res = {
result: true,
ethscription: {
transaction_hash:
"0xa34274bb32c63fa0b19b1bbf6629582b4e53fb1e1a867bb906f92e921e02e884",
current_owner: "0x2594c567255faa27b914e0b1a69ba07b473775fd",
content_uri:
'data:,{"p":"erc-20","op":"mint","tick":"ETHS","id":"16760","amt":"1000"}',
overall_order_number: 1755576300000127,
creator: "0x2594c567255faa27b914e0b1a69ba07b473775fd",
creation_timestamp: "2023-06-25T10:00:47.000Z",
valid_data_uri: true,
ethscription_number: "",
ethereum_punk_id: null,
finalization_status: "pending",
block_confirmations: 14454,
min_block_confirmations: 14454,
},
};
// 判断参数
if (res.ethscription.valid_data_uri) {
// 有效
listResult([res.ethscription]);
tableList.value = allTableList[groupBtn_all];
} else {
// 无效
}
} else {
const res: any = await inscriptionWasCast(inputValue.value);
if (res) {
console.log(res);
}
}
} catch (e) {
console.log(e);
}
};
// 开始搜索
const onSearch = () => {
pageNum.value = 1;
getList();
};
</script> </script>
<style lang="less">
.inscription-search-box {
height: 130px;
display: flex;
justify-content: center;
align-items: center;
}
.inscription-search-content {
max-width: 1430px;
flex: 1;
border-radius: 8px;
background: white;
padding: 20px;
margin: 0 auto;
display: flex;
flex-direction: column;
.inscription-search-table {
margin-top: 20px;
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
.table-tip-label {
display: flex;
justify-content: center;
align-items: center;
.tip {
margin-left: 6px;
cursor: pointer;
display: flex;
align-items: center;
}
}
.tip-span {
font-weight: 700;
color: #0075ff;
}
.open-link {
cursor: pointer;
}
.pagination-box {
margin-top: 20px;
}
}
}
</style>
...@@ -5,20 +5,20 @@ ...@@ -5,20 +5,20 @@
title="钱包查询" title="钱包查询"
content="输入你的钱包地址查询铭文数量、铭文是否有效" content="输入你的钱包地址查询铭文数量、铭文是否有效"
></Navbar> ></Navbar>
<div class="inscription-search-box"> <div class="inscription-wallet-box">
<!-- input --> <!-- input -->
<CustomInput v-model="inputValue" :clear="true" @search="onSearch"> <CustomInput v-model="inputValue" :clear="true" @search="onSearch">
</CustomInput> </CustomInput>
</div> </div>
<div class="inscription-search-content"> <div class="inscription-wallet-content">
<InscriptionHeld :list="[]"></InscriptionHeld>
<div> <div>
<CustomGroupButton <CustomGroupButton
:list="groupBtns" :list="groupBtns"
v-model="currentBtn" v-model="currentBtn"
@change="groupButtonChange"
></CustomGroupButton> ></CustomGroupButton>
</div> </div>
<div class="inscription-search-table"> <div class="inscription-wallet-table">
<CustomTable <CustomTable
:data="tableList" :data="tableList"
:columns="columns" :columns="columns"
...@@ -43,85 +43,126 @@ import { Head } from "@inertiajs/vue3"; ...@@ -43,85 +43,126 @@ import { Head } from "@inertiajs/vue3";
import Navbar from "@/components/navbar.vue"; import Navbar from "@/components/navbar.vue";
import CustomTable from "@/components/table.vue"; import CustomTable from "@/components/table.vue";
import CustomInput from "@/components/input/index.vue"; import CustomInput from "@/components/input/index.vue";
import InscriptionHeld from "./components/InscriptionHeld.vue"; import { reactive, ref } from "vue";
import { ref } from "vue";
import CustomGroupButton from "@/components/groupButton.vue"; import CustomGroupButton from "@/components/groupButton.vue";
import TipsSvg from "@/assets/svg/content/tips.svg"; import TipsSvg from "@/assets/svg/content/tips.svg";
import CustomTooltip from "@/components/tooltip.vue"; import CustomTooltip from "@/components/tooltip.vue";
import CustomPagination from "@/components/pagination.vue"; import CustomPagination from "@/components/pagination.vue";
import { getUserInscriptionList } from "@/utils/api/external"; import { getUserInscriptionList } from "@/utils/api/external";
import { showMessage } from "@/utils/tool"; import { showMessage, isDev, getMask, timeFormatSeconds } from "@/utils/tool";
import { test_wallet_list } from "@/constants/testData";
defineProps({ info: Object }); defineProps({ info: Object });
/**
* 按钮组的value
*/
const groupBtn_all = "all";
const groupBtn_cast = "cast";
const groupBtn_send = "send";
// 搜索框的值 // 搜索框的值
const inputValue = ref(""); const inputValue = ref("");
// 当前选中的按钮 // 当前选中的按钮
const currentBtn = ref("assets"); const currentBtn = ref(groupBtn_all);
// 按钮组 // 按钮组
const groupBtns = [ const groupBtns = [
{ {
// all
label: "资产", label: "资产",
value: "assets", value: groupBtn_all,
}, },
{ {
// 两个地址相同的
label: "铸造", label: "铸造",
value: "cast", value: groupBtn_cast,
}, },
{ {
// 两个地址不同的
label: "发送", label: "发送",
value: "send", value: groupBtn_send,
},
{
label: "收到",
value: "receive",
}, },
]; ];
const pageNum = ref(1); const pageNum = ref(1);
const pageSize = ref(10); const pageSize = ref(10);
const total = ref(0); const total = ref(0);
const loading = ref(false); const loading = ref(false);
// 接口返回的列表
const allTableList = reactive({
[groupBtn_all]: [],
[groupBtn_cast]: [],
[groupBtn_send]: [],
});
// 页面展示的列表
const tableList = ref([]); const tableList = ref([]);
// 上次搜索的地址
const oldAddress = ref("");
// 按钮组变化
const groupButtonChange = (value: string) => {
arrayPag(value);
};
// 打开hash链接
const openLink = (value) => {
if (!value) {
showMessage("没有hash");
return;
}
const url = "https://etherscan.io/tx/" + value;
window.open(url);
};
const columns = [ const columns = [
{ {
colKey: "applicant", colKey: "name",
title: "名称", title: "名称",
align: "center", align: "center",
className: "font700",
width: "10%",
}, },
{ {
colKey: "applicant", colKey: "number",
title: "方法", title: "数量",
align: "center", align: "center",
className: "font700",
width: "10%",
}, },
{ {
colKey: "applicant", colKey: "creator",
title: "数量", title: "铸造者",
align: "center", align: "center",
className: "public-style font700",
}, },
{ {
colKey: "applicant", colKey: "current_owner",
title: (h, { colIndex }) => ( title: "当前持有者",
<span class="table-tip-label"> align: "center",
Hash className: "public-style font700",
<CustomTooltip },
content="您当前拥有的资产被铸造出来时的hash,在erc20协议中, {
该hash的转移为表示所有转移权" colKey: "creation_timestamp",
> title: "锻造时间",
<span class="tip"> align: "center",
<TipsSvg></TipsSvg> className: "public-style font700",
</span> },
{
colKey: "content_uri",
title: "铭文数据",
align: "center",
cell: (h, { col, row }) => (
<div>
<CustomTooltip content={row[col.colKey]}>
<span class="tip-span">查看</span>
</CustomTooltip> </CustomTooltip>
</span> </div>
), ),
align: "center",
}, },
{ {
colKey: "applicant", colKey: "transaction_hash",
title: (h, { colIndex }) => ( title: (h, { colIndex }) => (
<span class="table-tip-label"> <span class="table-tip-label">
链接 Hash
<CustomTooltip <CustomTooltip
content="您当前拥有的资产来源。如果是铸造,则会跳转到铸造对应的 content="您当前拥有的资产被铸造出来时的hash,在erc20协议中,
Hash,如果是收到,那么会跳转到r收到的这笔Hash。" 该hash的转移为表示所有转移权"
> >
<span class="tip"> <span class="tip">
<TipsSvg></TipsSvg> <TipsSvg></TipsSvg>
...@@ -130,46 +171,114 @@ Hash,如果是收到,那么会跳转到r收到的这笔Hash。" ...@@ -130,46 +171,114 @@ Hash,如果是收到,那么会跳转到r收到的这笔Hash。"
</span> </span>
), ),
align: "center", align: "center",
}, cell: (h, { col, row }) => (
{ <div
colKey: "applicant", class="tip-span open-link"
title: "操作", onClick={openLink.bind(this, row[col.colKey])}
align: "center", >
Etherscan
</div>
),
}, },
]; ];
// 过滤出对应条件的列表
const getCurrentList = (list: any[]) => {
// 两个地址相同的
allTableList[groupBtn_cast] = list.filter(
(item: any) => item.current_owner === item.creator
);
// 两个地址不同的
allTableList[groupBtn_send] = list.filter(
(item: any) => item.current_owner !== item.creator
);
};
const listResult = (list: any[]) => {
// 分别过滤出对应的列表
list.forEach((item: any) => {
item.creator = getMask(item.creator);
item.current_owner = getMask(item.current_owner);
item.creation_timestamp = timeFormatSeconds(item.creation_timestamp);
// 过滤出名称和数量
const match = item.content_uri.match(/{.*}/);
if (match) {
const jsonStr = match[0];
const jsonObject = JSON.parse(jsonStr);
item.name = jsonObject.tick;
item.number = jsonObject.amt;
} else {
console.log("content_uri格式错误");
console.log(item.content_uri);
}
});
// 全部数据
allTableList[groupBtn_all] = list;
getCurrentList(list);
total.value = list.length;
//分页
arrayPag();
};
const getList = async () => { const getList = async () => {
try { try {
if (!inputValue.value) { if (!inputValue.value) {
showMessage("未输入钱包地址"); showMessage("未输入钱包地址");
return; return;
} }
const res: any = await getUserInscriptionList(inputValue.value); if (isDev()) {
// 本地环境
listResult(test_wallet_list);
} else {
loading.value = true;
const res: any = await getUserInscriptionList(inputValue.value);
if (res) {
oldAddress.value = inputValue.value;
let list = JSON.parse(res);
if (list.length) {
listResult(list);
}
}
loading.value = false;
}
} catch (e) { } catch (e) {
console.log(e); console.log(e);
loading.value = false;
} }
}; };
const arrayPag = (value?: string) => {
// 根据页数和分页大小、当前按钮--获取对应的数据
const start = (pageNum.value - 1) * pageSize.value;
tableList.value = allTableList[value ? value : currentBtn.value].slice(
start,
pageSize.value + start
);
// 改变total
total.value = allTableList[value ? value : currentBtn.value].length;
};
// 开始搜索 // 开始搜索
const onSearch = () => { const onSearch = () => {
pageNum.value = 1;
getList(); getList();
}; };
// 页数变化 // 页数变化
const pageChange = (value: number) => { const pageChange = (value: number) => {
pageNum.value = value; pageNum.value = value;
// 请求接口 arrayPag();
// getList();
}; };
</script> </script>
<style lang="less"> <style lang="less">
.inscription-search-box { .inscription-wallet-box {
height: 130px; height: 130px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.inscription-search-content { .inscription-wallet-content {
max-width: 1430px; max-width: 1430px;
border: 1px solid #dedede; border: 1px solid #dedede;
flex: 1; flex: 1;
...@@ -179,7 +288,7 @@ const pageChange = (value: number) => { ...@@ -179,7 +288,7 @@ const pageChange = (value: number) => {
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.inscription-search-table { .inscription-wallet-table {
margin-top: 20px; margin-top: 20px;
flex: 1; flex: 1;
display: flex; display: flex;
...@@ -196,7 +305,15 @@ const pageChange = (value: number) => { ...@@ -196,7 +305,15 @@ const pageChange = (value: number) => {
align-items: center; align-items: center;
} }
} }
.tip-span {
font-weight: 700;
color: #0075ff;
}
.open-link {
cursor: pointer;
}
.pagination-box { .pagination-box {
margin-top: 20px;
} }
} }
} }
......
...@@ -24,11 +24,14 @@ const props = withDefaults( ...@@ -24,11 +24,14 @@ const props = withDefaults(
}>(), }>(),
{} {}
); );
const emit = defineEmits(["update:modelValue"]); const emit = defineEmits(["update:modelValue", "change"]);
const currentBtn = ref(props.modelValue); const currentBtn = ref(props.modelValue);
const change = (value: string) => { const change = (value: string) => {
if (currentBtn.value !== value) {
emit("change", value);
}
currentBtn.value = value; currentBtn.value = value;
}; };
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref, watch } from "vue";
import { Pagination as TPagination } from "tdesign-vue-next"; import { Pagination as TPagination } from "tdesign-vue-next";
const props = withDefaults( const props = withDefaults(
...@@ -32,6 +32,15 @@ const onCurrentChange = (value: number) => { ...@@ -32,6 +32,15 @@ const onCurrentChange = (value: number) => {
cpageNum.value = value; cpageNum.value = value;
emit("pageChange", value); emit("pageChange", value);
}; };
watch(
() => props.pageNum,
(v) => {
if (v) {
cpageNum.value = v;
}
}
);
</script> </script>
<style lang="less"></style> <style lang="less"></style>
...@@ -39,6 +39,17 @@ const handleRowClick = () => { ...@@ -39,6 +39,17 @@ const handleRowClick = () => {
} }
} }
tbody { tbody {
tr {
td {
font-size: 15px;
}
}
.public-style {
white-space: nowrap;
}
.font700 {
font-weight: 700;
}
} }
} }
</style> </style>
This source diff could not be displayed because it is too large. You can view the blob instead.
<template> <template>
<div class="custom-layout"> <div class="custom-layout">
<Header></Header> <Header></Header>
<div class="custom-content"> <div class="custom-content narrow-scrollbar">
<slot></slot> <slot></slot>
</div> </div>
</div> </div>
...@@ -23,8 +23,8 @@ import Header from "./header.vue"; ...@@ -23,8 +23,8 @@ import Header from "./header.vue";
background: #ffffff; background: #ffffff;
max-height: calc(100vh - 64px); max-height: calc(100vh - 64px);
overflow-y: auto; overflow-y: auto;
display: flex; // display: flex;
flex-direction: column; // flex-direction: column;
} }
} }
</style> </style>
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
**/
export default function SHA256(s) {
var chrsz = 8;
var hexcase = 0;
function safe_add(x, y) {
var lsw = (x & 0xffff) + (y & 0xffff);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xffff);
}
function S(X, n) {
return (X >>> n) | (X << (32 - n));
}
function R(X, n) {
return X >>> n;
}
function Ch(x, y, z) {
return (x & y) ^ (~x & z);
}
function Maj(x, y, z) {
return (x & y) ^ (x & z) ^ (y & z);
}
function Sigma0256(x) {
return S(x, 2) ^ S(x, 13) ^ S(x, 22);
}
function Sigma1256(x) {
return S(x, 6) ^ S(x, 11) ^ S(x, 25);
}
function Gamma0256(x) {
return S(x, 7) ^ S(x, 18) ^ R(x, 3);
}
function Gamma1256(x) {
return S(x, 17) ^ S(x, 19) ^ R(x, 10);
}
function core_sha256(m, l) {
var K = new Array(
0x428a2f98,
0x71374491,
0xb5c0fbcf,
0xe9b5dba5,
0x3956c25b,
0x59f111f1,
0x923f82a4,
0xab1c5ed5,
0xd807aa98,
0x12835b01,
0x243185be,
0x550c7dc3,
0x72be5d74,
0x80deb1fe,
0x9bdc06a7,
0xc19bf174,
0xe49b69c1,
0xefbe4786,
0xfc19dc6,
0x240ca1cc,
0x2de92c6f,
0x4a7484aa,
0x5cb0a9dc,
0x76f988da,
0x983e5152,
0xa831c66d,
0xb00327c8,
0xbf597fc7,
0xc6e00bf3,
0xd5a79147,
0x6ca6351,
0x14292967,
0x27b70a85,
0x2e1b2138,
0x4d2c6dfc,
0x53380d13,
0x650a7354,
0x766a0abb,
0x81c2c92e,
0x92722c85,
0xa2bfe8a1,
0xa81a664b,
0xc24b8b70,
0xc76c51a3,
0xd192e819,
0xd6990624,
0xf40e3585,
0x106aa070,
0x19a4c116,
0x1e376c08,
0x2748774c,
0x34b0bcb5,
0x391c0cb3,
0x4ed8aa4a,
0x5b9cca4f,
0x682e6ff3,
0x748f82ee,
0x78a5636f,
0x84c87814,
0x8cc70208,
0x90befffa,
0xa4506ceb,
0xbef9a3f7,
0xc67178f2
);
var HASH = new Array(
0x6a09e667,
0xbb67ae85,
0x3c6ef372,
0xa54ff53a,
0x510e527f,
0x9b05688c,
0x1f83d9ab,
0x5be0cd19
);
var W = new Array(64);
var a, b, c, d, e, f, g, h, i, j;
var T1, T2;
m[l >> 5] |= 0x80 << (24 - (l % 32));
m[(((l + 64) >> 9) << 4) + 15] = l;
for (var i = 0; i < m.length; i += 16) {
a = HASH[0];
b = HASH[1];
c = HASH[2];
d = HASH[3];
e = HASH[4];
f = HASH[5];
g = HASH[6];
h = HASH[7];
for (var j = 0; j < 64; j++) {
if (j < 16) W[j] = m[j + i];
else
W[j] = safe_add(
safe_add(
safe_add(Gamma1256(W[j - 2]), W[j - 7]),
Gamma0256(W[j - 15])
),
W[j - 16]
);
T1 = safe_add(
safe_add(
safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)),
K[j]
),
W[j]
);
T2 = safe_add(Sigma0256(a), Maj(a, b, c));
h = g;
g = f;
f = e;
e = safe_add(d, T1);
d = c;
c = b;
b = a;
a = safe_add(T1, T2);
}
HASH[0] = safe_add(a, HASH[0]);
HASH[1] = safe_add(b, HASH[1]);
HASH[2] = safe_add(c, HASH[2]);
HASH[3] = safe_add(d, HASH[3]);
HASH[4] = safe_add(e, HASH[4]);
HASH[5] = safe_add(f, HASH[5]);
HASH[6] = safe_add(g, HASH[6]);
HASH[7] = safe_add(h, HASH[7]);
}
return HASH;
}
function str2binb(str) {
var bin = Array();
var mask = (1 << chrsz) - 1;
for (var i = 0; i < str.length * chrsz; i += chrsz) {
bin[i >> 5] |=
(str.charCodeAt(i / chrsz) & mask) << (24 - (i % 32));
}
return bin;
}
function Utf8Encode(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if (c > 127 && c < 2048) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
function binb2hex(binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for (var i = 0; i < binarray.length * 4; i++) {
str +=
hex_tab.charAt(
(binarray[i >> 2] >> ((3 - (i % 4)) * 8 + 4)) & 0xf
) +
hex_tab.charAt((binarray[i >> 2] >> ((3 - (i % 4)) * 8)) & 0xf);
}
return str;
}
s = Utf8Encode(s);
return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
}
import request from "../request/other"; import request from "../request/other";
import SHA256 from "../SHA256";
/** /**
* 外部接口都放这里 * 外部接口都放这里
*/ */
...@@ -7,3 +8,16 @@ import request from "../request/other"; ...@@ -7,3 +8,16 @@ import request from "../request/other";
export const getUserInscriptionList = (address: string) => { export const getUserInscriptionList = (address: string) => {
return request.get("/api/ethscriptions/owned_by/" + address); return request.get("/api/ethscriptions/owned_by/" + address);
}; };
// 铭文是否被铸造
export const inscriptionWasCast = (
data: string,
conversion: boolean = true
) => {
let value: any = data;
if (conversion) {
value = SHA256(value);
console.log(value);
}
return request.get("/api/ethscriptions/exists/" + value);
};
...@@ -5,8 +5,6 @@ const mode = import.meta.env.MODE; ...@@ -5,8 +5,6 @@ const mode = import.meta.env.MODE;
const getBaseUrl = () => { const getBaseUrl = () => {
if (mode == "development") { if (mode == "development") {
return ""; return "";
// return "http://127.0.0.1:3008";
// return "https://eth-script-indexer-eca25c4cf43b.herokuapp.com";
} else { } else {
return ""; return "";
} }
...@@ -27,14 +25,7 @@ instance.interceptors.request.use((config) => { ...@@ -27,14 +25,7 @@ instance.interceptors.request.use((config) => {
instance.interceptors.response.use( instance.interceptors.response.use(
(response) => { (response) => {
const { data } = response; const { data } = response;
console.log(response); return data;
if (data.code === 0) {
return data;
} else {
MessagePlugin.closeAll();
MessagePlugin.error(data.msg || "请求错误");
return Promise.reject(data.msg);
}
}, },
(err) => { (err) => {
if ("response" in err) { if ("response" in err) {
......
import { MessagePlugin } from "tdesign-vue-next"; import { MessagePlugin } from "tdesign-vue-next";
// 是否dev环境
export const isDev = () => {
const mode = import.meta.env.MODE;
if (mode == "development") {
return true;
}
return false;
};
// 获取路由中的路径,参数等 // 获取路由中的路径,参数等
export const getRoute = () => { export const getRoute = () => {
return window.location; return window.location;
...@@ -26,3 +34,31 @@ export const showMessage = ( ...@@ -26,3 +34,31 @@ export const showMessage = (
// 类型报错-所以用上面的方法 // 类型报错-所以用上面的方法
// MessagePlugin[type](value); // MessagePlugin[type](value);
}; };
// 掩码
export const getMask = (value: string, start: number = 6, end: number = 6) => {
let startStr = value.slice(0, start);
let endStr = value.slice(value.length - end, value.length);
return `${startStr}...${endStr}`;
};
// 转换日期格式
export const timeFormatSeconds = (time: string) => {
let d = time ? new Date(time) : new Date();
let year = d.getFullYear();
let month: any = d.getMonth() + 1;
let day: any = d.getDate();
let hours: any = d.getHours();
let min: any = d.getMinutes();
let seconds: any = d.getSeconds();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
if (hours < 0) hours = "0" + hours;
if (min < 10) min = "0" + min;
if (seconds < 10) seconds = "0" + seconds;
return (
year + "-" + month + "-" + day + " " + hours + ":" + min + ":" + seconds
);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment