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