Merge pull request 'user-vance-dev' (#3) from user-vance-dev into dev
Reviewed-on: http://110.42.203.40:14500/gary/frontend-recharge-system/pulls/3
This commit is contained in:
commit
40d43ae160
|
|
@ -56,12 +56,16 @@
|
||||||
"@formily/antd": "^2.0.7",
|
"@formily/antd": "^2.0.7",
|
||||||
"@formily/core": "^2.0.7",
|
"@formily/core": "^2.0.7",
|
||||||
"@formily/react": "^2.0.7",
|
"@formily/react": "^2.0.7",
|
||||||
|
"@metamask/detect-provider": "^1.2.0",
|
||||||
"@umijs/route-utils": "^2.0.3",
|
"@umijs/route-utils": "^2.0.3",
|
||||||
|
"@walletconnect/client": "^1.7.1",
|
||||||
|
"@walletconnect/qrcode-modal": "^1.7.1",
|
||||||
"ahooks": "^2.10.14",
|
"ahooks": "^2.10.14",
|
||||||
"antd": "^4.17.2",
|
"antd": "^4.17.2",
|
||||||
"axios": "^0.24.0",
|
"axios": "^0.24.0",
|
||||||
"braft-editor": "^2.3.9",
|
"braft-editor": "^2.3.9",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
|
"js-md5": "^0.7.3",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
"moment": "^2.25.3",
|
"moment": "^2.25.3",
|
||||||
"omit.js": "^2.0.2",
|
"omit.js": "^2.0.2",
|
||||||
|
|
@ -71,6 +75,7 @@
|
||||||
"react-dev-inspector": "^1.1.1",
|
"react-dev-inspector": "^1.1.1",
|
||||||
"react-dom": "^17.0.0",
|
"react-dom": "^17.0.0",
|
||||||
"react-helmet-async": "^1.0.4",
|
"react-helmet-async": "^1.0.4",
|
||||||
|
"tronweb": "^4.2.0",
|
||||||
"umi": "^3.5.0",
|
"umi": "^3.5.0",
|
||||||
"umi-serve": "^1.9.10",
|
"umi-serve": "^1.9.10",
|
||||||
"web3": "^1.7.0",
|
"web3": "^1.7.0",
|
||||||
|
|
|
||||||
|
|
@ -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 (
|
||||||
|
<Modal title="添加地址" onOk={handleOk} onCancel={handleCancel} width={800} {...rest}>
|
||||||
|
<Form form={form} labelCol={4} wrapperCol={18}>
|
||||||
|
<SchemaField>
|
||||||
|
<SchemaField.String
|
||||||
|
name="alias"
|
||||||
|
title="备注"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
<SchemaField.Number
|
||||||
|
name="num"
|
||||||
|
title="数量"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="NumberPicker"
|
||||||
|
/>
|
||||||
|
</SchemaField>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddAddressModal;
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
import React, { useRef, useState } from 'react';
|
||||||
|
import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import AddAddressModal from '@/pages/Tron/Address/List/components/addAddressModal';
|
||||||
|
import { initWeb3, walletSign } from '@/utils/web3';
|
||||||
|
import { creatTronAddress, getAddressList } from '@/services/address';
|
||||||
|
import { fetchTronTableData } from '@/utils/table';
|
||||||
|
const Address: React.FC = () => {
|
||||||
|
const tableRef = useRef<ActionType>();
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
dataIndex: 'alias',
|
||||||
|
width: '10%',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '地址',
|
||||||
|
dataIndex: 'address',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: '20%',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'key',
|
||||||
|
dataIndex: 'key',
|
||||||
|
width: 150,
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
rowKey="id"
|
||||||
|
actionRef={tableRef}
|
||||||
|
toolBarActions={[
|
||||||
|
{
|
||||||
|
type: 'add',
|
||||||
|
onConfirm: () => {
|
||||||
|
setVisible(true);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
request={async (params) => {
|
||||||
|
return fetchTronTableData(getAddressList, params);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<AddAddressModal
|
||||||
|
visible={visible}
|
||||||
|
onCancel={function () {
|
||||||
|
setVisible(false);
|
||||||
|
}}
|
||||||
|
onOk={async function (val: any): Promise<void> {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Address;
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
import React, { useRef } from 'react';
|
||||||
|
import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
|
import { fetchTronTableData } from '@/utils/table';
|
||||||
|
import { getTronRecord } from '@/services/address';
|
||||||
|
const Address: React.FC = () => {
|
||||||
|
const tableRef = useRef<ActionType>();
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
title: '交易哈希',
|
||||||
|
dataIndex: 'txHash',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '金额',
|
||||||
|
dataIndex: 'amount',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: '链名称',
|
||||||
|
dataIndex: 'chain',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '转换后的数量',
|
||||||
|
dataIndex: 'blockNumber',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '位数',
|
||||||
|
dataIndex: 'decimals',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '发送地址',
|
||||||
|
dataIndex: 'from',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '通知地址',
|
||||||
|
dataIndex: 'to',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '时间',
|
||||||
|
dataIndex: 'timeStamp',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '合约地址',
|
||||||
|
dataIndex: 'toAddress',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Token名称',
|
||||||
|
dataIndex: 'contract',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'contract',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
rowKey="id"
|
||||||
|
actionRef={tableRef}
|
||||||
|
request={async (params) => {
|
||||||
|
return fetchTronTableData(getTronRecord, params);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Address;
|
||||||
|
|
@ -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 (
|
||||||
|
<Modal title="添加地址" onOk={handleOk} onCancel={handleCancel} width={800} {...rest}>
|
||||||
|
<Form form={form} labelCol={4} wrapperCol={18}>
|
||||||
|
<SchemaField>
|
||||||
|
<SchemaField.String
|
||||||
|
name="network"
|
||||||
|
title="网络名称"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
<SchemaField.String
|
||||||
|
name="rpcUrl"
|
||||||
|
title="RPC URL"
|
||||||
|
required
|
||||||
|
x-component-props={{ maxLength: 100, showCount: true }}
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input.TextArea"
|
||||||
|
/>
|
||||||
|
<SchemaField.String
|
||||||
|
name="apiKey"
|
||||||
|
title="API Key"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Input"
|
||||||
|
/>
|
||||||
|
<SchemaField.Number
|
||||||
|
name="contract"
|
||||||
|
title="代币合约地址(放空则查找主代币"
|
||||||
|
required
|
||||||
|
x-validator="number"
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="NumberPicker"
|
||||||
|
/>
|
||||||
|
<SchemaField.String
|
||||||
|
name="symbol"
|
||||||
|
title="代币符号"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Editor"
|
||||||
|
/>
|
||||||
|
<SchemaField.String
|
||||||
|
name="decimals"
|
||||||
|
title="精度"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Editor"
|
||||||
|
/>
|
||||||
|
<SchemaField.String
|
||||||
|
name="browser"
|
||||||
|
title="区块浏览器"
|
||||||
|
required
|
||||||
|
x-decorator="FormItem"
|
||||||
|
x-component="Editor"
|
||||||
|
/>
|
||||||
|
</SchemaField>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddTokenModal;
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
import React, { useRef, useState } from 'react';
|
||||||
|
import Table, { ProColumns, ActionType } from '@/components/Table';
|
||||||
|
import { message } from 'antd';
|
||||||
|
import AddTokenModal from '@/pages/Tron/Token/List/components/addTokenModal';
|
||||||
|
import { initWeb3, walletSign } from '@/utils/web3';
|
||||||
|
|
||||||
|
const Address: React.FC = () => {
|
||||||
|
const tableRef = useRef<ActionType>();
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
title: '网络名称',
|
||||||
|
dataIndex: 'network',
|
||||||
|
width: '10%',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '地址',
|
||||||
|
dataIndex: 'address',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: '20%',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: 'API Key',
|
||||||
|
dataIndex: 'apiKey',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '代币符号',
|
||||||
|
dataIndex: 'symbol',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'RPC URL',
|
||||||
|
dataIndex: 'rpcUrl',
|
||||||
|
width: 150,
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '精度',
|
||||||
|
dataIndex: 'decimals',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '区块浏览器',
|
||||||
|
dataIndex: 'browser',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '代币合约地址',
|
||||||
|
dataIndex: 'contract',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
rowKey="id"
|
||||||
|
actionRef={tableRef}
|
||||||
|
toolBarActions={[
|
||||||
|
{
|
||||||
|
type: 'add',
|
||||||
|
onConfirm: () => {
|
||||||
|
setVisible(true);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<AddTokenModal
|
||||||
|
visible={visible}
|
||||||
|
onCancel={function () {
|
||||||
|
setVisible(false);
|
||||||
|
}}
|
||||||
|
onOk={async function (val: any): Promise<void> {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Address;
|
||||||
|
|
@ -93,9 +93,12 @@ const WorkList = () => {
|
||||||
return fetchTableData(queryWorkList, params);
|
return fetchTableData(queryWorkList, params);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<WorkSelectModal value={[1, 2, 3]} onOk={function (val: any): void {
|
<WorkSelectModal
|
||||||
|
value={[1, 2, 3]}
|
||||||
|
onOk={function (val: any): void {
|
||||||
throw new Error('Function not implemented.');
|
throw new Error('Function not implemented.');
|
||||||
} } />
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,32 @@ export default [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'TRON',
|
||||||
|
path: RoutePath.TRON,
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: RoutePath.TRON,
|
||||||
|
redirect: RoutePath.TRONRECORD.LIST,
|
||||||
|
hideInMenu: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TRON地址管理',
|
||||||
|
path: RoutePath.TRONADDRESS.LIST,
|
||||||
|
component: './Tron/Address/List',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TRON充值记录',
|
||||||
|
path: RoutePath.TRONRECORD.LIST,
|
||||||
|
component: './Tron/Record/List',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TRON币种类型',
|
||||||
|
path: RoutePath.TRONTOKEN.LIST,
|
||||||
|
component: './Tron/Token/List',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: '设置',
|
name: '设置',
|
||||||
path: RoutePath.SETTING,
|
path: RoutePath.SETTING,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const SETTING = '/setting';
|
const SETTING = '/setting';
|
||||||
const ETH = '/eth';
|
const ETH = '/eth';
|
||||||
|
const TRON = '/tron';
|
||||||
const ALL = '/all';
|
const ALL = '/all';
|
||||||
const RoutePath = {
|
const RoutePath = {
|
||||||
LOGIN: '/login',
|
LOGIN: '/login',
|
||||||
|
|
@ -27,6 +28,19 @@ const RoutePath = {
|
||||||
LIST: `${ETH}/currency`,
|
LIST: `${ETH}/currency`,
|
||||||
EDIT: `${ETH}/currency/edit`,
|
EDIT: `${ETH}/currency/edit`,
|
||||||
},
|
},
|
||||||
|
TRON: TRON,
|
||||||
|
TRONADDRESS: {
|
||||||
|
LIST: `${TRON}/tron/address/list`,
|
||||||
|
EDIT: `${TRON}/tron/address/edit`,
|
||||||
|
},
|
||||||
|
TRONRECORD: {
|
||||||
|
LIST: `${TRON}/tron/record`,
|
||||||
|
EDIT: `${TRON}/tron/record/edit`,
|
||||||
|
},
|
||||||
|
TRONTOKEN: {
|
||||||
|
LIST: `${TRON}/token`,
|
||||||
|
EDIT: `${TRON}/token/edit`,
|
||||||
|
},
|
||||||
SETTING: SETTING,
|
SETTING: SETTING,
|
||||||
WORK: {
|
WORK: {
|
||||||
LIST: `${SETTING}/work`,
|
LIST: `${SETTING}/work`,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import request from '@/utils/request';
|
||||||
|
|
||||||
|
// export const login = (data) => {
|
||||||
|
// return request.request({
|
||||||
|
// url: '/admin/login',
|
||||||
|
// method: 'post',
|
||||||
|
// data,
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
export const getAddressList = (data) => {
|
||||||
|
return request.request({
|
||||||
|
url: '/admin/api/v1/address/get',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const getTronRecord = (data) => {
|
||||||
|
return request.request({
|
||||||
|
url: 'admin/api/v1/records/get',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const creatTronAddress = (data) => {
|
||||||
|
return request.request({
|
||||||
|
url: 'admin/api/v1/address/mask',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
@ -21,3 +21,25 @@ export const fetchTableData = async (
|
||||||
total: res.total,
|
total: res.total,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
export const fetchTronTableData = async (
|
||||||
|
fetch: (params: any) => Promise<any>,
|
||||||
|
params: any,
|
||||||
|
formatObj: any = {},
|
||||||
|
) => {
|
||||||
|
params.page = params.page;
|
||||||
|
params.size = params.size;
|
||||||
|
params.coinType = 'tron';
|
||||||
|
const res = (await fetch(params)) || {};
|
||||||
|
const data = res;
|
||||||
|
data.forEach((n: any) => {});
|
||||||
|
data?.forEach((n: any) => {
|
||||||
|
for (const key in formatObj) {
|
||||||
|
n[key] = n[formatObj[key]];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: data,
|
||||||
|
total: res.total,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
//@ts-ignore
|
||||||
|
import TronWeb from 'tronweb';
|
||||||
|
|
||||||
|
let tronWeb: any;
|
||||||
|
|
||||||
|
export function getTronWeb() {
|
||||||
|
return tronWeb;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// window.setTronRpc = setTronRpc;
|
||||||
|
|
||||||
|
export function setTronRpc(rpcUrl = 'https://api.trongrid.io', apiKey = '') {
|
||||||
|
const HttpProvider = TronWeb.providers.HttpProvider;
|
||||||
|
const fullNode = new HttpProvider(rpcUrl);
|
||||||
|
const solidityNode = new HttpProvider(rpcUrl);
|
||||||
|
const eventServer = new HttpProvider(rpcUrl);
|
||||||
|
// 这个私钥是随机生成的,可以自己生成
|
||||||
|
tronWeb = new TronWeb(
|
||||||
|
fullNode,
|
||||||
|
solidityNode,
|
||||||
|
eventServer,
|
||||||
|
'5B1E0F83361AD79F8B676CE205B50A6A036876D25F969F290F8017F87CAA9BA3',
|
||||||
|
);
|
||||||
|
tronWeb.setHeader({ 'TRON-PRO-API-KEY': apiKey });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getTronBalance(account: any) {
|
||||||
|
return await tronWeb.trx.getBalance(account);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue