user-zzy-dev #2
|
|
@ -76,7 +76,8 @@
|
||||||
"web3": "^1.7.0",
|
"web3": "^1.7.0",
|
||||||
"@metamask/detect-provider": "^1.2.0",
|
"@metamask/detect-provider": "^1.2.0",
|
||||||
"@walletconnect/client": "^1.7.1",
|
"@walletconnect/client": "^1.7.1",
|
||||||
"@walletconnect/qrcode-modal": "^1.7.1"
|
"@walletconnect/qrcode-modal": "^1.7.1",
|
||||||
|
"bignumber.js": "^9.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ant-design/pro-cli": "^2.0.2",
|
"@ant-design/pro-cli": "^2.0.2",
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ const WorkEdit = () => {
|
||||||
val.sign = signInfo.sign;
|
val.sign = signInfo.sign;
|
||||||
val.coinType = 'eth';
|
val.coinType = 'eth';
|
||||||
val.num = parseInt(val.num);
|
val.num = parseInt(val.num);
|
||||||
const params = { ...val };
|
await AddAddress(val);
|
||||||
await AddAddress(params);
|
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
history.back();
|
history.back();
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
import { queryAddressList } from '@/services/eth';
|
import { queryAddressList } from '@/services/eth';
|
||||||
import { fetchTableData } from '@/utils/table';
|
import { fetchTableData } from '@/utils/table';
|
||||||
import CoinType from '@/constants/enum/coinType';
|
import CoinType from '@/constants/enum/coinType';
|
||||||
import AddAddressModal from '../Edit/AddAddressModal';
|
import AddAddressModal from './components/AddAddressModal';
|
||||||
import { AddAddress } from '@/services/eth';
|
import { AddAddress } from '@/services/eth';
|
||||||
import { initWeb3, walletSign } from '../../../../utils/web3';
|
import { initWeb3, walletSign } from '@/utils/web3';
|
||||||
import { message, Select } from 'antd';
|
import { message, Select } from 'antd';
|
||||||
|
|
||||||
const AddressList = () => {
|
const AddressList = () => {
|
||||||
|
|
@ -63,14 +63,12 @@ const AddressList = () => {
|
||||||
<div>
|
<div>
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
// indexColumn
|
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
actionRef={tableRef}
|
actionRef={tableRef}
|
||||||
toolBarActions={[
|
toolBarActions={[
|
||||||
{
|
{
|
||||||
type: 'add',
|
type: 'add',
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
// history.push(RoutePath.ETH_ADDRESS.EDIT);
|
|
||||||
setIsModalVisible(true);
|
setIsModalVisible(true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
import { queryRecordList } from '@/services/eth';
|
import { queryRecordList } from '@/services/eth';
|
||||||
import { fetchTableData } from '@/utils/table';
|
import { fetchTableData } from '@/utils/table';
|
||||||
import CoinType from '@/constants/enum/coinType';
|
import CoinType from '@/constants/enum/coinType';
|
||||||
import { web3 } from '@/utils/web3';
|
|
||||||
import { Select } from 'antd';
|
import { Select } from 'antd';
|
||||||
|
import { getBalanceAmount } from '@/utils/formatBalance';
|
||||||
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
const AddressList = () => {
|
const AddressList = () => {
|
||||||
const tableRef = useRef<ActionType>();
|
const tableRef = useRef<ActionType>();
|
||||||
|
|
@ -36,7 +37,6 @@ const AddressList = () => {
|
||||||
dataIndex: 'txHash',
|
dataIndex: 'txHash',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
// search: { transform: (value: any) => ({ startTime: value[0], endTime: value[1] }) },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '金额',
|
title: '金额',
|
||||||
|
|
@ -73,28 +73,17 @@ const AddressList = () => {
|
||||||
<div>
|
<div>
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
// indexColumn
|
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
actionRef={tableRef}
|
actionRef={tableRef}
|
||||||
// toolBarActions={[
|
|
||||||
// {
|
|
||||||
// type: 'add',
|
|
||||||
// onConfirm: () => {
|
|
||||||
// history.push(RoutePath.ETH_ADDRESS.EDIT);
|
|
||||||
// setIsModalVisible(true);
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ]}
|
|
||||||
request={async (params) => {
|
request={async (params) => {
|
||||||
// params.coinType = CoinType.ETH;
|
|
||||||
const res = await fetchTableData(queryRecordList, params);
|
const res = await fetchTableData(queryRecordList, params);
|
||||||
for (const key in res.data) {
|
for (const key in res.data) {
|
||||||
if (Object.prototype.hasOwnProperty.call(res.data, key)) {
|
if (Object.prototype.hasOwnProperty.call(res.data, key)) {
|
||||||
const element = res.data[key];
|
const element = res.data[key];
|
||||||
element.amount = web3.utils
|
element.amount = getBalanceAmount(
|
||||||
.toBN(element.amount)
|
new BigNumber(element.amount),
|
||||||
.div(web3.utils.toBN(Math.pow(10, Number(element.decimals))))
|
element.decimals,
|
||||||
.toNumber();
|
).toNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
import { queryAddressList } from '@/services/eth';
|
import { queryAddressList } from '@/services/eth';
|
||||||
import { fetchTableData } from '@/utils/table';
|
import { fetchTableData } from '@/utils/table';
|
||||||
import CoinType from '@/constants/enum/coinType';
|
import CoinType from '@/constants/enum/coinType';
|
||||||
import AddAddressModal from '../Edit/AddAddressModal';
|
import AddAddressModal from './components/AddAddressModal';
|
||||||
import { AddAddress } from '@/services/eth';
|
import { AddAddress } from '@/services/eth';
|
||||||
import { initWeb3, walletSign } from '../../../../utils/web3';
|
import { initWeb3, walletSign } from '@/utils/web3';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
|
|
||||||
const AddressList = () => {
|
const AddressList = () => {
|
||||||
|
|
@ -43,7 +43,6 @@ const AddressList = () => {
|
||||||
{
|
{
|
||||||
type: 'add',
|
type: 'add',
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
// history.push(RoutePath.ETH_ADDRESS.EDIT);
|
|
||||||
setIsModalVisible(true);
|
setIsModalVisible(true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -65,8 +64,7 @@ const AddressList = () => {
|
||||||
val.key = signInfo.raw;
|
val.key = signInfo.raw;
|
||||||
val.sign = signInfo.sign;
|
val.sign = signInfo.sign;
|
||||||
val.coinType = CoinType.ETH;
|
val.coinType = CoinType.ETH;
|
||||||
const params = { ...val };
|
await AddAddress(val);
|
||||||
await AddAddress(params);
|
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
setIsModalVisible(false);
|
setIsModalVisible(false);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
import { queryRecordList } from '@/services/eth';
|
import { queryRecordList } from '@/services/eth';
|
||||||
import { fetchTableData } from '@/utils/table';
|
import { fetchTableData } from '@/utils/table';
|
||||||
import CoinType from '@/constants/enum/coinType';
|
import CoinType from '@/constants/enum/coinType';
|
||||||
import { web3 } from '@/utils/web3';
|
import { getBalanceAmount } from '@/utils/formatBalance';
|
||||||
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
const AddressList = () => {
|
const AddressList = () => {
|
||||||
const tableRef = useRef<ActionType>();
|
const tableRef = useRef<ActionType>();
|
||||||
|
|
@ -13,7 +14,6 @@ const AddressList = () => {
|
||||||
dataIndex: 'txHash',
|
dataIndex: 'txHash',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
// search: { transform: (value: any) => ({ startTime: value[0], endTime: value[1] }) },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '金额',
|
title: '金额',
|
||||||
|
|
@ -50,28 +50,18 @@ const AddressList = () => {
|
||||||
<div>
|
<div>
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
// indexColumn
|
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
actionRef={tableRef}
|
actionRef={tableRef}
|
||||||
// toolBarActions={[
|
|
||||||
// {
|
|
||||||
// type: 'add',
|
|
||||||
// onConfirm: () => {
|
|
||||||
// history.push(RoutePath.ETH_ADDRESS.EDIT);
|
|
||||||
// setIsModalVisible(true);
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ]}
|
|
||||||
request={async (params) => {
|
request={async (params) => {
|
||||||
params.coinType = CoinType.ETH;
|
params.coinType = CoinType.ETH;
|
||||||
const res = await fetchTableData(queryRecordList, params);
|
const res = await fetchTableData(queryRecordList, params);
|
||||||
for (const key in res.data) {
|
for (const key in res.data) {
|
||||||
if (Object.prototype.hasOwnProperty.call(res.data, key)) {
|
if (Object.prototype.hasOwnProperty.call(res.data, key)) {
|
||||||
const element = res.data[key];
|
const element = res.data[key];
|
||||||
element.amount = web3.utils
|
element.amount = getBalanceAmount(
|
||||||
.toBN(element.amount)
|
new BigNumber(element.amount),
|
||||||
.div(web3.utils.toBN(Math.pow(10, Number(element.decimals))))
|
element.decimals,
|
||||||
.toNumber();
|
).toNumber();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
|
export const BIG_ZERO = new BigNumber(0);
|
||||||
|
export const BIG_ONE = new BigNumber(1);
|
||||||
|
export const BIG_NINE = new BigNumber(9);
|
||||||
|
export const BIG_TEN = new BigNumber(10);
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import BigNumber from 'bignumber.js';
|
||||||
|
import { BIG_TEN } from './bigNumber';
|
||||||
|
|
||||||
|
export const getBalanceAmount = (amount: BigNumber, decimals = 18) => {
|
||||||
|
return new BigNumber(amount).dividedBy(BIG_TEN.pow(decimals));
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue