Skip to content

Commit

Permalink
chore: update all v5 related packages
Browse files Browse the repository at this point in the history
  • Loading branch information
nghaninn committed Dec 2, 2024
1 parent 16cd6cf commit 38f5cb1
Show file tree
Hide file tree
Showing 19 changed files with 6,868 additions and 2,522 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
"\\.(css|sass|scss)$": "identity-obj-proxy",
"^swiper/css(/.*)?$": "<rootDir>/_mocks_/fileMock.js",
"node:stream": "<rootDir>/node_modules/stream-browserify",
"node:crypto": "<rootDir>/node_modules/crypto-browserify",
"node:util": "<rootDir>/node_modules/util",
"node:events": "<rootDir>/node_modules/events",
"node:process": "<rootDir>/node_modules/process",
Expand Down
7,169 changes: 4,931 additions & 2,238 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,23 @@
"@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": "^5.0.0-alpha.2",
"@tradetrust-tt/tradetrust": "^6.9.4",
"@tradetrust-tt/tradetrust-ui-components": "^3.0.0-alpha.1",
"@tradetrust-tt/tradetrust-utils": "^1.13.5",
"@tradetrust-tt/tt-verify": "^8.9.4",
"@trustvc/trustvc": "^1.0.0-alpha.9",
"@tradetrust-tt/decentralized-renderer-react-components": "^3.14.3",
"@tradetrust-tt/document-store": "^4.1.0",
"@tradetrust-tt/token-registry": "^5.0.2",
"@tradetrust-tt/tradetrust": "^6.9.7",
"@tradetrust-tt/tradetrust-ui-components": "^3.0.0",
"@tradetrust-tt/tradetrust-utils": "^2.0.0",
"@tradetrust-tt/tt-verify": "^9.1.0",
"@trustvc/trustvc": "^1.0.0",
"@types/gtag.js": "0.0.8",
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"date-fns": "^2.22.1",
"date-fns-tz": "^1.1.4",
"ethers": "^5.4.7",
"ethers": "^5.7.2",
"file-saver": "^2.0.5",
"history": "^4.10.1",
"lodash": "^4.17.21",
Expand Down Expand Up @@ -187,6 +186,7 @@
"npm": ">=8.0"
},
"overrides": {
"ethers": "^5.7.2",
"ethereumjs-abi": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz"
},
"optionalDependencies": {
Expand Down
18 changes: 18 additions & 0 deletions src/__mocks__/@tradetrust-tt/tradetrust-utils/constants/network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export declare const networks: readonly [
"local",
"mainnet",
"matic",
"maticmum",
"amoy",
"sepolia",
"xdc",
"xdcapothem",
"hederatestnet",
"hederamainnet",
"stabilitytestnet",
"stability",
"astron"
];
export type networkName = (typeof networks)[number];
export type networkType = "production" | "test" | "development";
export type networkCurrency = "ETH" | "MATIC" | "XDC" | "HBAR" | "FREE" | "ASTRON";
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import { networkName, networkType, networkCurrency } from "./network";
import "dotenv/config";

export enum CHAIN_ID {
local = "1337",
mainnet = "1",
matic = "137",
amoy = "80002",
sepolia = "11155111",
xdc = "50",
xdcapothem = "51",
hederatestnet = "296",
hederamainnet = "295",
stabilitytestnet = "20180427",
stability = "101010",
astron = "1338",
}

export type chainInfo = {
id: CHAIN_ID;
label: string;
name: networkName;
type: networkType;
currency: networkCurrency;
explorerUrl: string;
explorerApiUrl?: string;
rpcUrl?: string;
nativeCurrency?: {
name: string;
symbol: string;
decimals: number;
};
};

type supportedChains = Record<CHAIN_ID, chainInfo>;

export const SUPPORTED_CHAINS: supportedChains = {
[CHAIN_ID.local]: {
id: CHAIN_ID.local,
label: "Local",
name: "local",
type: "development",
currency: "ETH",
explorerUrl: "https://localhost/explorer",
rpcUrl: "http://localhost:8545",
},
[CHAIN_ID.mainnet]: {
id: CHAIN_ID.mainnet,
label: "Mainnet",
name: "mainnet",
type: "production",
currency: "ETH",
explorerUrl: "https://etherscan.io",
explorerApiUrl: "https://api.etherscan.io",
},
[CHAIN_ID.matic]: {
id: CHAIN_ID.matic,
label: "Polygon",
name: "matic",
type: "production",
currency: "MATIC",
explorerUrl: "https://polygonscan.com",
rpcUrl: "https://polygon-rpc.com",
nativeCurrency: {
name: "MATIC",
symbol: "MATIC",
decimals: 18,
},
},
[CHAIN_ID.amoy]: {
id: CHAIN_ID.amoy,
label: "Polygon Amoy",
name: "amoy",
type: "test",
currency: "MATIC",
explorerUrl: "https://www.oklink.com/amoy",
explorerApiUrl: `https://www.oklink.com/${process.env.OKLINK_API_KEY}`,
rpcUrl: `https://polygon-amoy.infura.io/v3/${process.env.INFURA_API_KEY}`,
nativeCurrency: {
name: "MATIC",
symbol: "aMATIC",
decimals: 18,
},
},
[CHAIN_ID.sepolia]: {
id: CHAIN_ID.sepolia,
label: "Sepolia",
name: "sepolia",
type: "test",
currency: "ETH",
explorerUrl: "https://sepolia.etherscan.io",
rpcUrl: "https://rpc.sepolia.org",
nativeCurrency: {
name: "ETH",
symbol: "sepETH",
decimals: 18,
},
},
[CHAIN_ID.xdc]: {
id: CHAIN_ID.xdc,
label: "XDC Network",
name: "xdc",
type: "production",
currency: "XDC",
explorerUrl: "https://xdcscan.io",
rpcUrl: "https://tradetrustrpc.xdcrpc.com",
nativeCurrency: {
name: "XDC",
symbol: "XDC",
decimals: 18,
},
},
[CHAIN_ID.xdcapothem]: {
id: CHAIN_ID.xdcapothem,
label: "Apothem Network",
name: "xdcapothem",
type: "test",
currency: "XDC",
explorerUrl: "https://apothem.xdcscan.io",
rpcUrl: "https://tradetrustarpc.xdcrpc.com",
nativeCurrency: {
name: "XDC",
symbol: "XDC",
decimals: 18,
},
},
[CHAIN_ID.hederatestnet]: {
id: CHAIN_ID.hederatestnet,
label: "Hedera Testnet Network",
name: "hederatestnet",
type: "test",
currency: "HBAR",
explorerUrl: "https://hashscan.io/testnet",
rpcUrl: "https://testnet.hashio.io/api",
nativeCurrency: {
name: "HBAR",
symbol: "HBAR",
decimals: 18,
},
},
[CHAIN_ID.hederamainnet]: {
id: CHAIN_ID.hederamainnet,
label: "Hedera MainNet Network",
name: "hederamainnet",
type: "production",
currency: "HBAR",
explorerUrl: "https://hashscan.io/mainnet",
rpcUrl: "https://mainnet.hashio.io/api",
nativeCurrency: {
name: "HBAR",
symbol: "HBAR",
decimals: 18,
},
},
[CHAIN_ID.stabilitytestnet]: {
id: CHAIN_ID.stabilitytestnet,
label: "Stability Testnet Network",
name: "stabilitytestnet",
type: "test",
currency: "FREE",
explorerUrl: "https://stability-testnet.blockscout.com/",
rpcUrl: "https://free.testnet.stabilityprotocol.com",
nativeCurrency: {
name: "FREE",
symbol: "FREE",
decimals: 18,
},
},
[CHAIN_ID.stability]: {
id: CHAIN_ID.stability,
label: "Stability Network",
name: "stability",
type: "production",
currency: "FREE",
explorerUrl: "https://stability.blockscout.com/",
rpcUrl: `https://gtn.stabilityprotocol.com/zgt/${process.env.STABILITY_API_KEY}`,
nativeCurrency: {
name: "FREE",
symbol: "FREE",
decimals: 18,
},
},
[CHAIN_ID.astron]: {
id: CHAIN_ID.astron,
label: "Astron Network",
name: "astron",
type: "production",
currency: "ASTRON",
explorerUrl: "https://astronscanl2.bitfactory.cn/",
rpcUrl: `https://astronlayer2.bitfactory.cn/rpc/`,
nativeCurrency: {
name: "ASTRON",
symbol: "ASTRON",
decimals: 18,
},
},
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { ContractFunctionState, useContractFunctionHook } from "@govtechsg/ethers-contract-hook";
import { constants } from "@tradetrust-tt/token-registry";
import { TitleEscrow, TradeTrustToken } from "@tradetrust-tt/token-registry/contracts";
import React, { createContext, FunctionComponent, useCallback, useContext, useEffect, useState } from "react";
import { BurnAddress } from "../../../constants/chain-info";
import { ContractFunctionState, useContractFunctionHook } from "../../hooks/useContractFunctionHook";
import { useRestoreToken } from "../../hooks/useRestoreToken";
import { useSupportsInterface } from "../../hooks/useSupportsInterface";
import { useTitleEscrowContract } from "../../hooks/useTitleEscrowContract";
import { useTokenRegistryContract } from "../../hooks/useTokenRegistryContract";
import { useProviderContext } from "../provider";
const { contractInterfaceId } = constants;

export enum TokenRegistryVersion {
V2 = "V2",
Expand Down Expand Up @@ -54,7 +56,7 @@ interface TokenInformationContext {
restoreTokenState: ContractFunctionState;
}

const contractFunctionStub = () => {
const contractFunctionStub: any = () => {
return undefined as any;
};

Expand Down Expand Up @@ -96,7 +98,7 @@ interface TokenInformationContextProviderProps {
// TODO: HAN Move the constant value to token-registry repo
export const TitleEscrowInterface = {
V4: "0x079dff60",
V5: "0x3e143f7b",
V5: contractInterfaceId.TitleEscrow,
};

export const TokenInformationContextProvider: FunctionComponent<TokenInformationContextProviderProps> = ({
Expand Down Expand Up @@ -303,7 +305,7 @@ export const TokenInformationContextProvider: FunctionComponent<TokenInformation
isReturnedToIssuer,
isTokenBurnt,
isTitleEscrow,
version: isTitleEscrowV4 ? TokenRegistryVersion.V4 : TokenRegistryVersion.V5,
version: isTitleEscrowV5 ? TokenRegistryVersion.V5 : TokenRegistryVersion.V4,
documentOwner,
nominate,
nominateState,
Expand Down
Loading

0 comments on commit 38f5cb1

Please sign in to comment.