diff --git a/src/pages/Tron/Address/List/components/index.tsx b/src/pages/Tron/Address/List/components/index.tsx
new file mode 100644
index 0000000..cdee8a0
--- /dev/null
+++ b/src/pages/Tron/Address/List/components/index.tsx
@@ -0,0 +1,55 @@
+import React, { useRef } from 'react';
+import { createForm } from '@formily/core';
+import { createSchemaField } from '@formily/react';
+import Modal, { ModalProps } from '@/components/Modal';
+import { Form, FormItem, Input, NumberPicker } from '@formily/antd';
+
+interface AddAddressModalPropsType extends ModalProps {
+ onOk: (val: any) => void;
+ onCancel: () => void;
+}
+
+const SchemaField = createSchemaField({
+ components: {
+ FormItem,
+ Input,
+ NumberPicker,
+ },
+});
+
+const form = createForm({});
+
+const AddAddressModal = ({ onOk, onCancel, ...rest }: AddAddressModalPropsType) => {
+ const handleOk = () => {
+ const formState = form.getFormState();
+ onOk(formState.values);
+ };
+ const handleCancel = () => {
+ onCancel();
+ };
+
+ return (
+
+
+
+ );
+};
+
+export default AddAddressModal;
diff --git a/src/pages/Tron/Address/List/index.tsx b/src/pages/Tron/Address/List/index.tsx
index 334ed1e..73b4a47 100644
--- a/src/pages/Tron/Address/List/index.tsx
+++ b/src/pages/Tron/Address/List/index.tsx
@@ -1,72 +1,13 @@
import React, { useRef, useState } from 'react';
import Table, { ProColumns, ActionType } from '@/components/Table';
-import { Modal, Spin, message } from 'antd';
-import { initWeb3, walletSign } from '../../../../utils/web3';
-import DetailPageContainer from '@/components/DetailPageContainer';
-import {
- Form,
- FormItem,
- Input,
- Select,
- Submit,
- FormGrid,
- ArrayItems,
- Editable,
- Switch,
- ArrayTable,
- FormButtonGroup,
- NumberPicker,
-} from '@formily/antd';
+import { message } from 'antd';
+import AddAddressModal from '@/pages/Tron/Address/List/components/index';
+import { initWeb3, walletSign } from '@/utils/web3';
import { creatTronAddress, getAddressList } from '@/services/address';
-import { createForm } from '@formily/core';
-import { createSchemaField } from '@formily/react';
-
-// import { web3 } from '@/utils/web3';
import { fetchTronTableData } from '@/utils/table';
-// import { getTronBalance, getTronTokenBalance, setTronRpc } from '@/utils/tronweb';
-
-// import { useIntl, history, FormattedMessage, useModel } from 'umi';
const Address: React.FC = () => {
const tableRef = useRef();
const [visible, setVisible] = useState(false);
- const form = createForm({});
- const [loading, setLoading] = useState(false);
- const SchemaField = createSchemaField({
- components: {
- FormItem,
- FormGrid,
- Input,
- Select,
- ArrayTable,
- Switch,
- ArrayItems,
- NumberPicker,
- Editable,
- },
- });
- // const addAddress = () => {
- // setVisible(true);
- // };
- const handleSubmit = async (val) => {
- const params = { ...val };
- setLoading(true);
- await initWeb3();
- const signInfo = await walletSign();
- params.key = signInfo.raw;
- params.sign = signInfo.sign;
- params.coinType = 'tron';
- await creatTronAddress(params);
- tableRef.current?.reload();
- message.success('操作成功');
- setLoading(false);
- };
- // const save = async () => {
- // const res = await makeTronAddress(state.form);
- // };
- // const featchdata = async (item) => {
- // const res = await getAddressList(state.form);
- // const ret = item
- // };
const columns: ProColumns[] = [
{
@@ -81,11 +22,6 @@ const Address: React.FC = () => {
hideInSearch: true,
width: '20%',
},
- {
- title: '余额',
- dataIndex: 'balance',
- hideInSearch: true,
- },
{
title: 'key',
dataIndex: 'key',
@@ -112,43 +48,28 @@ const Address: React.FC = () => {
return fetchTronTableData(getAddressList, params);
}}
/>
- setVisible(false)}
- onCancel={() => setVisible(false)}
- width={800}
- >
-
-
-
-
-
-
+ onCancel={function () {
+ setVisible(false);
+ }}
+ onOk={async function (val: any): Promise {
+ try {
+ await initWeb3();
+ const signInfo = await walletSign();
+ val.key = signInfo.raw;
+ val.sign = signInfo.sign;
+ val.coinType = 'tron';
+ const params = { ...val };
+ await creatTronAddress(params);
+ message.success('添加成功');
+ } catch (e) {
+ console.log(e);
+ message.success('发生错误');
+ setVisible(false);
+ }
+ }}
+ />
);
};
diff --git a/src/pages/Tron/Record/List/index.tsx b/src/pages/Tron/Record/List/index.tsx
index f3ca3e1..982059e 100644
--- a/src/pages/Tron/Record/List/index.tsx
+++ b/src/pages/Tron/Record/List/index.tsx
@@ -8,14 +8,12 @@ const Address: React.FC = () => {
{
title: '交易哈希',
dataIndex: 'txHash',
- // width: '10%',
hideInSearch: true,
},
{
title: '金额',
dataIndex: 'amount',
hideInSearch: true,
- // width: '20%',
},
{
@@ -68,17 +66,8 @@ const Address: React.FC = () => {
{
- // history.push(RoutePath.WORK.EDIT);
- // },
- // },
- // ]}
request={async (params) => {
return fetchTronTableData(getTronRecord, params);
}}
diff --git a/src/pages/Tron/Token/List/components/index.tsx b/src/pages/Tron/Token/List/components/index.tsx
new file mode 100644
index 0000000..6e947a1
--- /dev/null
+++ b/src/pages/Tron/Token/List/components/index.tsx
@@ -0,0 +1,93 @@
+import React, { useRef } from 'react';
+import { createForm } from '@formily/core';
+import { createSchemaField } from '@formily/react';
+import Modal, { ModalProps } from '@/components/Modal';
+import { Form, FormItem, Input, NumberPicker } from '@formily/antd';
+
+interface AddTokenModalPropsType extends ModalProps {
+ onOk: (val: any) => void;
+ onCancel: () => void;
+}
+
+const SchemaField = createSchemaField({
+ components: {
+ FormItem,
+ Input,
+ NumberPicker,
+ },
+});
+
+const form = createForm({});
+
+const AddTokenModal = ({ onOk, onCancel, ...rest }: AddTokenModalPropsType) => {
+ const handleOk = () => {
+ const formState = form.getFormState();
+ onOk(formState.values);
+ };
+
+ const handleCancel = () => {
+ onCancel();
+ };
+
+ return (
+
+
+
+ );
+};
+
+export default AddTokenModal;
diff --git a/src/pages/Tron/Token/List/index.tsx b/src/pages/Tron/Token/List/index.tsx
index 9f091f2..5485f06 100644
--- a/src/pages/Tron/Token/List/index.tsx
+++ b/src/pages/Tron/Token/List/index.tsx
@@ -1,51 +1,12 @@
import React, { useRef, useState } from 'react';
import Table, { ProColumns, ActionType } from '@/components/Table';
-import { Modal, Spin, message } from 'antd';
-import { createSchemaField } from '@formily/react';
-import { createForm } from '@formily/core';
-import DetailPageContainer from '@/components/DetailPageContainer';
-// import { fetchTronTableData } from '@/utils/table';
-
-import {
- Form,
- FormItem,
- Input,
- Select,
- Submit,
- FormGrid,
- ArrayItems,
- Editable,
- Switch,
- ArrayTable,
- FormButtonGroup,
- NumberPicker,
-} from '@formily/antd';
+import { message } from 'antd';
+import AddTokenModal from '@/pages/Tron/Token/List/components/index';
+import { initWeb3, walletSign } from '@/utils/web3';
const Address: React.FC = () => {
const tableRef = useRef();
- const form = createForm({});
const [visible, setVisible] = useState(false);
- const [loading, setLoading] = useState(false);
- const SchemaField = createSchemaField({
- components: {
- FormItem,
- FormGrid,
- Input,
- Select,
- ArrayTable,
- Switch,
- ArrayItems,
- NumberPicker,
- Editable,
- },
- });
- // const state = {
- // queryForm: {
- // page: 1,
- // size: 20,
- // coin_type: 'tron',
- // },
- // };
const columns: ProColumns[] = [
{
title: '网络名称',
@@ -96,27 +57,10 @@ const Address: React.FC = () => {
width: 150,
},
];
- const handleSubmit = async (val) => {
- const params = { ...val };
- setLoading(true);
- params.cointype = 'tron';
- // const res = await makeTronAddress(params);
- // if(res.code == 200){
-
- // }
- tableRef.current?.reload();
- message.success('操作成功');
- setLoading(false);
- // history.back();
- // } catch (e) {
- // setLoading(false);
- // }
- };
return (
{
},
},
]}
- // request={async (params) => {
- // return fetchTronTableData(queryWorkList, state.queryForm);
- // }}
/>
- setVisible(false)}
- onCancel={() => setVisible(false)}
- width={800}
- >
-
-
-
-
-
-
+ onCancel={function () {
+ setVisible(false);
+ }}
+ onOk={async function (val: any): Promise {
+ try {
+ await initWeb3();
+ const signInfo = await walletSign();
+ val.key = signInfo.raw;
+ val.sign = signInfo.sign;
+ val.coinType = 'tron';
+ const params = { ...val };
+ // await creatTronAddress(params);
+ message.success('添加成功');
+ } catch (e) {
+ console.log(e);
+ message.success('添加错误');
+ setVisible(false);
+ }
+ }}
+ />
);
};
diff --git a/src/utils/table.ts b/src/utils/table.ts
index 687ed70..393a477 100644
--- a/src/utils/table.ts
+++ b/src/utils/table.ts
@@ -1,5 +1,4 @@
// 格式化表格获取数据接口的返回
-import { getTronBalance } from './tronweb';
export const fetchTableData = async (
fetch: (params: any) => Promise,
params: any,
@@ -33,14 +32,10 @@ export const fetchTronTableData = async (
params.coinType = 'tron';
const res = (await fetch(params)) || {};
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) {
n[key] = n[formatObj[key]];
- n.balance = getTronBalance(n.address);
}
});
return {