新增钱包地址模块微调

This commit is contained in:
vancekk 2022-06-20 17:33:47 +08:00
parent 8fa974f0b5
commit 5e3bfec173
4 changed files with 42 additions and 84 deletions

View File

@ -1,8 +1,8 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import Table, { ProColumns, ActionType } from '@/components/Table'; import Table, { ProColumns, ActionType } from '@/components/Table';
import { Modal, Spin, message } from 'antd'; import { Modal, Spin, message } from 'antd';
import { initWeb3, walletSign } from '../../../../utils/web3';
import DetailPageContainer from '@/components/DetailPageContainer'; import DetailPageContainer from '@/components/DetailPageContainer';
import md5 from 'js-md5';
import { import {
Form, Form,
FormItem, FormItem,
@ -31,23 +31,6 @@ const Address: React.FC = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const form = createForm({}); const form = createForm({});
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const state = {
formRef: null,
confirmKey: '',
tokenList: [],
token: '',
form: {
coin_type: 'tron',
alias: '',
key: '',
num: 1,
},
queryForm: {
page: 1,
size: 20,
coinType: 'tron',
},
};
const SchemaField = createSchemaField({ const SchemaField = createSchemaField({
components: { components: {
FormItem, FormItem,
@ -67,19 +50,15 @@ const Address: React.FC = () => {
const handleSubmit = async (val) => { const handleSubmit = async (val) => {
const params = { ...val }; const params = { ...val };
setLoading(true); setLoading(true);
params.cointype = 'tron'; await initWeb3();
params.key = md5(params.key); const signInfo = await walletSign();
const res = await creatTronAddress(params); params.key = signInfo.raw;
// if(res.code == 200){ params.sign = signInfo.sign;
params.coinType = 'tron';
// } await creatTronAddress(params);
tableRef.current?.reload(); tableRef.current?.reload();
message.success('操作成功'); message.success('操作成功');
setLoading(false); setLoading(false);
// history.back();
// } catch (e) {
// setLoading(false);
// }
}; };
// const save = async () => { // const save = async () => {
// const res = await makeTronAddress(state.form); // const res = await makeTronAddress(state.form);
@ -152,14 +131,6 @@ const Address: React.FC = () => {
x-decorator="FormItem" x-decorator="FormItem"
x-component="Input" x-component="Input"
/> />
<SchemaField.String
name="key"
title="密码"
required
x-component-props={{ maxLength: 100, showCount: true }}
x-decorator="FormItem"
x-component="Input.TextArea"
/>
<SchemaField.Number <SchemaField.Number
name="num" name="num"
title="数量" title="数量"

View File

@ -1,81 +1,71 @@
import React, { useRef } from 'react'; import React, { useRef } from 'react';
import Table, { ProColumns, ActionType } from '@/components/Table'; import Table, { ProColumns, ActionType } from '@/components/Table';
import { Button } from 'antd';
import { Link } from 'umi';
import RoutePath from '@/routes/routePath';
import { fetchTronTableData } from '@/utils/table'; import { fetchTronTableData } from '@/utils/table';
import { getTronRecord } from '@/services/address'; import { getTronRecord } from '@/services/address';
import { PlusCircleOutlined } from '@ant-design/icons';
const Address: React.FC = () => { const Address: React.FC = () => {
const tableRef = useRef<ActionType>(); const tableRef = useRef<ActionType>();
const addAddress = () => {};
const columns: ProColumns<any>[] = [ const columns: ProColumns<any>[] = [
{ {
title: '交易哈希', title: '交易哈希',
dataIndex: 'tx', dataIndex: 'txHash',
width: '10%', // width: '10%',
hideInSearch: true, hideInSearch: true,
}, },
{ {
title: '金额', title: '金额',
dataIndex: 'amount', dataIndex: 'amount',
hideInSearch: true, hideInSearch: true,
width: '20%', // width: '20%',
}, },
{ {
title: '链名称', title: '链名称',
dataIndex: 'chain', dataIndex: 'chain',
ellipsis: true, hideInSearch: true,
}, },
{ {
title: '转换后的数量', title: '转换后的数量',
dataIndex: 'symbol', dataIndex: 'blockNumber',
width: 150, hideInSearch: true,
}, },
{ {
title: '位数', title: '位数',
dataIndex: 'rpcUrl', dataIndex: 'decimals',
width: 150, hideInSearch: true,
}, },
{ {
title: '发送地址', title: '发送地址',
dataIndex: 'decimals', dataIndex: 'from',
width: 150, hideInSearch: true,
}, },
{ {
title: '通知地址', title: '通知地址',
dataIndex: 'browser', dataIndex: 'to',
width: 150, hideInSearch: true,
}, },
{ {
title: '时间', title: '时间',
dataIndex: 'timesTamp', dataIndex: 'timeStamp',
width: 150, hideInSearch: true,
}, },
{ {
title: '合约地址', title: '合约地址',
dataIndex: 'toAddress', dataIndex: 'toAddress',
width: 150, hideInSearch: true,
}, },
{ {
title: 'Token名称', title: 'Token名称',
dataIndex: 'contract', dataIndex: 'contract',
width: 150, hideInSearch: true,
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'contract', dataIndex: 'contract',
width: 150, hideInSearch: true,
}, },
]; ];
return ( return (
<div> <div>
<div>
<Button type="primary" icon={<PlusCircleOutlined />} onClick={addAddress}>
</Button>
</div>
<Table <Table
columns={columns} columns={columns}
// indexColumn // indexColumn

View File

@ -1,7 +1,6 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import Table, { ProColumns, ActionType } from '@/components/Table'; import Table, { ProColumns, ActionType } from '@/components/Table';
import { Button, Modal, Spin, message } from 'antd'; import { Modal, Spin, message } from 'antd';
import { PlusCircleOutlined } from '@ant-design/icons';
import { createSchemaField } from '@formily/react'; import { createSchemaField } from '@formily/react';
import { createForm } from '@formily/core'; import { createForm } from '@formily/core';
import DetailPageContainer from '@/components/DetailPageContainer'; import DetailPageContainer from '@/components/DetailPageContainer';
@ -22,10 +21,8 @@ import {
NumberPicker, NumberPicker,
} from '@formily/antd'; } from '@formily/antd';
// import { useIntl, history, FormattedMessage, useModel } from 'umi';
const Address: React.FC = () => { const Address: React.FC = () => {
const tableRef = useRef<ActionType>(); const tableRef = useRef<ActionType>();
const addAddress = () => {};
const form = createForm({}); const form = createForm({});
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@ -42,13 +39,13 @@ const Address: React.FC = () => {
Editable, Editable,
}, },
}); });
const state = { // const state = {
queryForm: { // queryForm: {
page: 1, // page: 1,
size: 20, // size: 20,
coin_type: 'tron', // coin_type: 'tron',
}, // },
}; // };
const columns: ProColumns<any>[] = [ const columns: ProColumns<any>[] = [
{ {
title: '网络名称', title: '网络名称',
@ -66,31 +63,36 @@ const Address: React.FC = () => {
{ {
title: 'API Key', title: 'API Key',
dataIndex: 'apiKey', dataIndex: 'apiKey',
ellipsis: true, hideInSearch: true,
}, },
{ {
title: '代币符号', title: '代币符号',
dataIndex: 'symbol', dataIndex: 'symbol',
hideInSearch: true,
width: 150, width: 150,
}, },
{ {
title: 'RPC URL', title: 'RPC URL',
dataIndex: 'rpcUrl', dataIndex: 'rpcUrl',
width: 150, width: 150,
hideInSearch: true,
}, },
{ {
title: '精度', title: '精度',
dataIndex: 'decimals', dataIndex: 'decimals',
hideInSearch: true,
width: 150, width: 150,
}, },
{ {
title: '区块浏览器', title: '区块浏览器',
dataIndex: 'browser', dataIndex: 'browser',
hideInSearch: true,
width: 150, width: 150,
}, },
{ {
title: '代币合约地址', title: '代币合约地址',
dataIndex: 'contract', dataIndex: 'contract',
hideInSearch: true,
width: 150, width: 150,
}, },
]; ];
@ -112,11 +114,6 @@ const Address: React.FC = () => {
}; };
return ( return (
<div> <div>
<div>
<Button type="primary" icon={<PlusCircleOutlined />} onClick={addAddress}>
</Button>
</div>
<Table <Table
columns={columns} columns={columns}
// indexColumn // indexColumn

View File

@ -31,16 +31,16 @@ export const fetchTronTableData = async (
params.page = params.page; params.page = params.page;
params.size = params.size; params.size = params.size;
params.coinType = 'tron'; params.coinType = 'tron';
// delete params.current;
// delete params.pageSize;
const res = (await fetch(params)) || {}; const res = (await fetch(params)) || {};
const data = res; const data = res;
data.forEach((n: any) => {
// n.balance = getTronBalance(n.address);
console.log(n.address);
});
data?.forEach((n: any) => { data?.forEach((n: any) => {
for (const key in formatObj) { for (const key in formatObj) {
n[key] = n[formatObj[key]]; n[key] = n[formatObj[key]];
n.balance = getTronBalance(n.address); n.balance = getTronBalance(n.address);
console.log(n.balance);
} }
}); });
return { return {