Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 900e227

Browse files
authored
feat: package exports (#10)
1 parent b336796 commit 900e227

7 files changed

Lines changed: 106 additions & 73 deletions

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# tradetrust-utils
2+
23
This is a repository that houses shared project logic between tradetrust website and tradetrust document creator.
34

45
Currently, this is still an experiment to see whether this structure of sharing logic between the 2 repos is sustainable.
56

67
We will monitor whether the dependencies will get out of hand.
78

8-
Before any commits here, please ask the maintainers (TradeTrust team) first.
9+
Before any commits here, please ask the maintainers (TradeTrust team) first.
10+
11+
### Direct import
12+
13+
If the consuming application does not support treeshaking, you should do direct import instead. Example:
14+
15+
```
16+
import { CHAIN_ID } from "@govtechsg/tradetrust-utils/constants/supportedChains";
17+
```

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,37 @@
22
"name": "@govtechsg/tradetrust-utils",
33
"version": "0.1.0",
44
"description": "",
5-
"main": "dist/cjs/index.js",
6-
"module": "dist/esm/index.js",
7-
"types": "dist/types/src/index.d.ts",
5+
"types": "./dist/types/index.d.ts",
6+
"typesVersions": {
7+
"*": {
8+
".": [
9+
"./dist/types/index.d.ts"
10+
],
11+
"constants/*": [
12+
"./dist/types/constants/*.d.ts"
13+
]
14+
}
15+
},
16+
"exports": {
17+
".": {
18+
"require": "./dist/cjs/index.js",
19+
"import": "./dist/esm/index.js"
20+
},
21+
"./constants/*": {
22+
"require": "./dist/cjs/constants/*.js",
23+
"import": "./dist/esm/constants/*.js"
24+
}
25+
},
26+
"main": "./dist/cjs/index.js",
27+
"module": "./dist/esm/index.js",
28+
"files": [
29+
"dist"
30+
],
831
"scripts": {
9-
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:type",
32+
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types",
1033
"build:cjs": "tsc --module commonjs --outDir dist/cjs --project ./tsconfig.prod.json",
1134
"build:esm": "tsc --module es2015 --outDir dist/esm --project ./tsconfig.prod.json",
12-
"build:type": "tsc -d --emitDeclarationOnly --outDir dist/types/src",
35+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist/types --project ./tsconfig.prod.json",
1336
"clean": "rm -rf dist/",
1437
"test:ci": "jest --runInBand",
1538
"test": "NODE_OPTIONS=--max-old-space-size=2048 jest",
@@ -43,7 +66,7 @@
4366
"prettier": "^2.5.1",
4467
"semantic-release": "^18.0.1",
4568
"ts-jest": "^27.1.0",
46-
"typescript": "^4.5.2"
69+
"typescript": "^4.9.4"
4770
},
4871
"publishConfig": {
4972
"access": "public"

src/constants/SupportedNetworks.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/constants/network.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type networkName = "local" | "mainnet" | "matic" | "maticmum" | "goerli" | "sepolia";
2+
3+
export type networkType = "production" | "test" | "development";
4+
5+
export type networkCurrency = "ETH" | "MATIC";

src/constants/supportedChains.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { networkName, networkType, networkCurrency } from "./network";
2+
3+
export enum CHAIN_ID {
4+
local = "1337",
5+
mainnet = "1",
6+
matic = "137",
7+
maticmum = "80001",
8+
goerli = "5",
9+
sepolia = "11155111",
10+
}
11+
12+
export type chainInfo = {
13+
label: string;
14+
name: networkName;
15+
type: networkType;
16+
currency: networkCurrency;
17+
};
18+
19+
type supportedChains = Record<CHAIN_ID, chainInfo>;
20+
21+
export const SUPPORTED_CHAINS: supportedChains = {
22+
[CHAIN_ID.local]: {
23+
label: "Local",
24+
name: "local",
25+
type: "development",
26+
currency: "ETH",
27+
},
28+
[CHAIN_ID.mainnet]: {
29+
label: "Mainnet",
30+
name: "mainnet",
31+
type: "production",
32+
currency: "ETH",
33+
},
34+
[CHAIN_ID.matic]: {
35+
label: "Polygon",
36+
name: "matic",
37+
type: "production",
38+
currency: "MATIC",
39+
},
40+
[CHAIN_ID.maticmum]: {
41+
label: "Polygon Mumbai",
42+
name: "maticmum",
43+
type: "test",
44+
currency: "MATIC",
45+
},
46+
[CHAIN_ID.goerli]: {
47+
label: "Goerli",
48+
name: "goerli",
49+
type: "test",
50+
currency: "ETH",
51+
},
52+
[CHAIN_ID.sepolia]: {
53+
label: "Sepolia",
54+
name: "sepolia",
55+
type: "test",
56+
currency: "ETH",
57+
},
58+
};

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as CONSTANTS from "./constants/VerificationErrorMessages";
2-
export * from "./constants/SupportedNetworks";
2+
export * from "./constants/supportedChains";
33
export * from "./analytics";
44
export * from "./fragments";
55
export { CONSTANTS };

0 commit comments

Comments
 (0)