Skip to content

Commit

Permalink
test: 💍 log in updateCFD
Browse files Browse the repository at this point in the history
Closes: #1299
  • Loading branch information
arealclimber committed Oct 20, 2023
1 parent ee24c8e commit 6f15c2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "src",
"version": "0.8.0+60.2",
"version": "0.8.0+62.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down Expand Up @@ -81,4 +81,4 @@
"pre-commit": "npm run test && lint-staged"
}
}
}
}
15 changes: 15 additions & 0 deletions src/contexts/user_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,9 @@ export const UserProvider = ({children}: IUserProvider) => {
const updateCFDOrder = useCallback(
async (applyUpdateCFDOrder: IApplyUpdateCFDOrder | undefined): Promise<IResult> => {
let result: IResult;
// Deprecated: [debug] (Shirley - 20231020)
// eslint-disable-next-line no-console
console.log('updateCFDOrder', 'applyUpdateCFDOrder', applyUpdateCFDOrder);
try {
if (!enableServiceTermRef.current) throw new CustomError(Code.SERVICE_TERM_DISABLE);
const propertiesToCheck = ['guaranteedStopFee', 'stopLoss', 'takeProfit'];
Expand All @@ -1123,13 +1126,25 @@ export const UserProvider = ({children}: IUserProvider) => {
if (!applyUpdateCFDOrder || !isValidFormat)
throw new CustomError(Code.INVAILD_ORDER_INPUTS);
const updateAppliedCFD = getCFD(applyUpdateCFDOrder.referenceId);
// Deprecated: [debug] (Shirley - 20231020)
// eslint-disable-next-line no-console
console.log('updateCFDOrder', 'updateAppliedCFD', updateAppliedCFD);

if (!updateAppliedCFD) throw new CustomError(Code.CFD_ORDER_NOT_FOUND);
if (updateAppliedCFD.state !== OrderState.OPENING)
throw new CustomError(Code.CFD_ORDER_IS_ALREADY_CLOSED);
const typeData = transactionEngine.transferCFDOrderToTransaction(applyUpdateCFDOrder);
// Deprecated: [debug] (Shirley - 20231020)
// eslint-disable-next-line no-console
console.log('updateCFDOrder', 'typeData', typeData);

if (!typeData) throw new CustomError(Code.FAILED_TO_CREATE_TRANSACTION);
// TODO: send request to chain(use Lunar?) (20230324 - tzuhan)
const signature: string = await lunar.signTypedData(typeData);
// Deprecated: [debug] (Shirley - 20231020)
// eslint-disable-next-line no-console
console.log('updateCFDOrder', 'signature', signature);

/* Info: (20230505 - Julian) 需要再驗證一次簽名是否正確 */
const success = lunar.verifyTypedData(typeData, signature);
// Deprecated: [debug] (20230509 - Tzuhan)
Expand Down

0 comments on commit 6f15c2c

Please sign in to comment.