Skip to content

Commit

Permalink
feat: Update endorsement chain page to support remark (#941)
Browse files Browse the repository at this point in the history
* feat: v5 update endorement chain

* chore: fix test case

* chore: resolve type error

* chore: resolve package-lock

* chore: resolve test error

* chore: resolve test error

* chore: update cli package version

* chore: add missing os in package-lock

* chore: revert test fixes

* chore: update amoy rpcUrl

---------

Co-authored-by: nghaninn <[email protected]>
  • Loading branch information
nghaninn and nghaninn authored Oct 17, 2024
1 parent a94c70f commit 76930d7
Show file tree
Hide file tree
Showing 36 changed files with 1,113 additions and 1,083 deletions.
654 changes: 284 additions & 370 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"prep": "run-s lint:fix test integration:testcafe:dev integration:headful",
"prepare": "husky install",
"serve-static": "npx http-server dist -s -p 3000",
"storybook": "npm run build:css && sleep 2 && storybook dev -p 6006 ",
"storybook": "run-p dev:css storybook:dev",
"storybook:dev": "sleep 2 && storybook dev -p 6006",
"storybook:build": "npm run build:css && sleep 2 && storybook build -o docs",
"test": "jest",
"test:coverage": "npm run test -- --collectCoverage",
Expand All @@ -47,14 +48,15 @@
},
"dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@ethersproject/abstract-provider": "^5.7.0",
"@govtechsg/address-identity-resolver": "^1.5.0",
"@govtechsg/ethers-contract-hook": "^2.2.0",
"@govtechsg/oa-encryption": "^1.3.5",
"@govtechsg/open-attestation-utils": "1.0.9",
"@reduxjs/toolkit": "^1.6.1",
"@tradetrust-tt/decentralized-renderer-react-components": "^3.14.1",
"@tradetrust-tt/document-store": "^3.2.0",
"@tradetrust-tt/token-registry": "^4.10.1",
"@tradetrust-tt/token-registry": "^5.0.0-alpha.1",
"@tradetrust-tt/tradetrust": "^6.9.4",
"@tradetrust-tt/tradetrust-ui-components": "^2.22.2",
"@tradetrust-tt/tradetrust-utils": "^1.13.5",
Expand All @@ -78,6 +80,7 @@
"react-helmet": "^6.1.0",
"react-markdown": "^6.0.2",
"react-redux": "^7.2.4",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-timer-hook": "^3.0.7",
"react-tooltip": "^4.5.1",
Expand All @@ -93,7 +96,6 @@
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.23.3",
"@cypress/webpack-preprocessor": "^6.0.1",
"@govtechsg/open-attestation-cli": "^2.5.0",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-postcss": "^2.0.0",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
Expand All @@ -103,10 +105,12 @@
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/react-hooks": "^7.0.0",
"@tradetrust-tt/tradetrust-cli": "^3.0.0-alpha.1",
"@types/debug": "^4.1.5",
"@types/file-saver": "^2.0.3",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.2",
"@types/lodash": "^4.17.10",
"@types/node": "^22.7.5",
"@types/qrcode.react": "^1.0.1",
"@types/react": "^17.0.9",
"@types/react-dom": "^17.0.6",
Expand Down Expand Up @@ -155,6 +159,7 @@
"path-browserify": "^1.0.1",
"postcss": "^8.4.6",
"postcss-cli": "^8.3.1",
"postcss-loader": "^4.3.0",
"prettier": "^2.3.1",
"process": "^0.11.10",
"redux-devtools-extension": "^2.13.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { TradeTrustToken } from "@tradetrust-tt/token-registry/contracts";
import { useRestoreToken } from "../../hooks/useRestoreToken";
import { BurnAddress } from "../../../constants/chain-info";

export enum TokenRegistryVersion {
V2 = "V2",
V4 = "V4",
V5 = "V5",
}

interface TokenInformationContext {
tokenRegistryAddress?: string;
tokenId?: string;
Expand All @@ -30,10 +36,11 @@ interface TokenInformationContext {
isSurrendered: boolean;
isTokenBurnt: boolean;
isTitleEscrow?: boolean;
version?: TokenRegistryVersion;
resetStates: () => void;
destroyToken: TradeTrustToken["burn"];
destroyTokenState: ContractFunctionState;
restoreToken: () => Promise<void>;
restoreToken: (remark: string) => Promise<void>;
restoreTokenState: ContractFunctionState;
}

Expand Down Expand Up @@ -69,6 +76,12 @@ interface TokenInformationContextProviderProps {
children: React.ReactNode;
}

// TODO: HAN Move the constant value to token-registry repo
export const TitleEscrowInterface = {
V4: "0x079dff60",
V5: "0xa00f1762",
};

export const TokenInformationContextProvider: FunctionComponent<TokenInformationContextProviderProps> = ({
children,
}) => {
Expand All @@ -85,7 +98,9 @@ export const TokenInformationContextProvider: FunctionComponent<TokenInformation
const isTokenBurnt = documentOwner === BurnAddress; // check if the token belongs to burn address.

// First check whether Contract is TitleEscrow
const { isInterfaceType: isTitleEscrow } = useSupportsInterface(titleEscrow, "0x079dff60");
const { isInterfaceType: isTitleEscrowV4 } = useSupportsInterface(titleEscrow, TitleEscrowInterface.V4);
const { isInterfaceType: isTitleEscrowV5 } = useSupportsInterface(titleEscrow, TitleEscrowInterface.V5);
const isTitleEscrow = isTitleEscrowV4 || isTitleEscrowV5;

// Contract Read Functions
const { call: getHolder, value: holder } = useContractFunctionHook(titleEscrow, "holder");
Expand Down Expand Up @@ -223,6 +238,7 @@ export const TokenInformationContextProvider: FunctionComponent<TokenInformation
isSurrendered,
isTokenBurnt,
isTitleEscrow,
version: isTitleEscrowV4 ? TokenRegistryVersion.V4 : TokenRegistryVersion.V5,
documentOwner,
nominate,
nominateState,
Expand Down
Loading

0 comments on commit 76930d7

Please sign in to comment.