Skip to content

Commit dd84c87

Browse files
committed
Update: add data encrypt to token build
1 parent 2217801 commit dd84c87

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

config.example.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,16 @@ export const DevnetUrlConfig = {
3939
* The current network configuration version number. If cached locally, increase the current version.
4040
*/
4141
export const NET_CONFIG_VERSION = 1038;
42+
43+
44+
/**
45+
* token build keys
46+
*/
47+
export const react_private_keys = `
48+
-----BEGIN PRIVATE KEY-----
49+
-----END PRIVATE KEY-----
50+
`
51+
export const node_public_keys = `
52+
-----BEGIN PUBLIC KEY-----
53+
-----END PUBLIC KEY-----
54+
`

src/popup/pages/Send/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import ICON_Address from "../../component/SVG/ICON_Address";
4141
import ICON_Wallet from "../../component/SVG/ICON_Wallet";
4242
import Toast from "../../component/Toast";
4343
import styles from "./index.module.scss";
44+
import { decryptData, encryptData } from "@/utils/fore";
45+
import { node_public_keys, react_private_keys } from "../../../../config";
4446

4547
const SendPage = ({}) => {
4648
const dispatch = useDispatch();
@@ -313,19 +315,22 @@ const SendPage = ({}) => {
313315
isNewAccount: fundNewAccountStatus,
314316
gqlUrl: currentNode.url,
315317
};
316-
const buildData = await buildTokenBody(buildTokenData);
318+
const data = encryptData(JSON.stringify(buildTokenData),node_public_keys);// 这里用测试的
319+
const buildData = await buildTokenBody(data);
317320
if (buildData.unSignTx) {
321+
let realUnSignTxStr = decryptData(buildData.unSignTx.encryptedData,buildData.unSignTx.encryptedAESKey,buildData.unSignTx.iv,react_private_keys);
322+
let realUnSignTx = JSON.stringify(realUnSignTxStr)
318323
const checkChangeStatus = verifyTokenCommand(
319324
buildTokenData,
320325
token.tokenId,
321-
buildData.unSignTx
326+
realUnSignTx
322327
);
323328
if (!checkChangeStatus) {
324329
setConfirmBtnStatus(false);
325330
Toast.info(i18n.t("buildFailed"));
326331
return;
327332
}
328-
return buildData.unSignTx;
333+
return realUnSignTx;
329334
} else {
330335
setConfirmBtnStatus(false);
331336
Toast.info(buildData.error || String(buildData));

0 commit comments

Comments
 (0)