@tria-sdk/constants 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./src/config";
2
+ export * from "./src/chains";
3
+ export * from "./src/txn";
4
+ export * from "./src/connect";
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@tria-sdk/constants",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc --project tsconfig.json"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC"
13
+ }
package/src/chains.ts ADDED
@@ -0,0 +1,212 @@
1
+ export const zkLink = "ZKLINK-NOVA";
2
+ export const zkLinkTestnet = "ZKLINK-NOVA-TESTNET";
3
+ export const bitlayerTestnet = "BITLAYER-TESTNET";
4
+
5
+ export type ZKLINK = "ZKLINK-NOVA";
6
+ export type ZKLINK_TESTNET = "ZKLINK-NOVA-TESTNET";
7
+ export type BITLAYER_TESTNET = "BITLAYER-TESTNET";
8
+
9
+ export const TESTNET_CHAINS = [
10
+ "MUMBAI",
11
+ "FUSESPARK",
12
+ "MANTA-TESTNET",
13
+ "METIS-TESTNET",
14
+ "MANTLE-TESTNET",
15
+ zkLinkTestnet,
16
+ bitlayerTestnet,
17
+ ];
18
+
19
+ export const SUPPORTED_EVM_CHAINS = [
20
+ "ETH",
21
+ "POLYGON",
22
+ "AVALANCHE",
23
+ "ARBITRUM",
24
+ "BINANCE",
25
+ "OPTIMISM",
26
+ "FANTOM",
27
+ "FUSE",
28
+ "FUSESPARK",
29
+ "MUMBAI",
30
+ "MANTA",
31
+ "MANTA-TESTNET",
32
+ "METIS",
33
+ "METIS-TESTNET",
34
+ "MANTLE",
35
+ "MANTLE-TESTNET",
36
+ zkLink,
37
+ zkLinkTestnet,
38
+ bitlayerTestnet,
39
+ ];
40
+
41
+ export const AA_SUPPORTED_EVM_CHAINS = [
42
+ "ETH",
43
+ "POLYGON",
44
+ "AVALANCHE",
45
+ "ARBITRUM",
46
+ "BINANCE",
47
+ "OPTIMISM",
48
+ "FANTOM",
49
+ "FUSE",
50
+ "MUMBAI",
51
+ ];
52
+
53
+ export const ALLCHAINS = [
54
+ "ETH",
55
+ "POLYGON",
56
+ "AVALANCHE",
57
+ "ARBITRUM",
58
+ "BINANCE",
59
+ "OPTIMISM",
60
+ "FANTOM",
61
+ "FUSE",
62
+ "FUSESPARK",
63
+ "MUMBAI",
64
+ "MANTA",
65
+ "MANTA-TESTNET",
66
+ "METIS",
67
+ "METIS-TESTNET",
68
+ "MANTLE",
69
+ "MANTLE-TESTNET",
70
+ "SOLANA",
71
+ zkLink,
72
+ zkLinkTestnet,
73
+ bitlayerTestnet,
74
+ ];
75
+
76
+ const baseLogoUrl = "https://static.tria.so/chain-logo-w";
77
+ const baseLogoUrlBlack = "https://static.tria.so/chain-logo-b";
78
+
79
+ export const networks = [
80
+ {
81
+ chainName: "ETH",
82
+ logo: `${baseLogoUrl}/Ethereum.webp`,
83
+ },
84
+ {
85
+ chainName: "FANTOM",
86
+ logo: `${baseLogoUrl}/Fantom.webp`,
87
+ },
88
+ {
89
+ chainName: "POLYGON",
90
+ logo: `${baseLogoUrl}/Polygon.svg`,
91
+ },
92
+ {
93
+ chainName: "AVALANCHE",
94
+ logo: `${baseLogoUrl}/Avalanche.webp`,
95
+ },
96
+ {
97
+ chainName: "OPTIMISM",
98
+ logo: `${baseLogoUrl}/Optimism.webp`,
99
+ },
100
+ {
101
+ chainName: "ARBITRUM",
102
+ logo: `${baseLogoUrl}/Arbitrum.webp`,
103
+ },
104
+ {
105
+ chainName: "FUSE",
106
+ logo: `${baseLogoUrl}/Fuse.webp`,
107
+ },
108
+ {
109
+ chainName: "FUSESPARK",
110
+ logo: `${baseLogoUrl}/Fuse.webp`,
111
+ },
112
+ {
113
+ chainName: "MUMBAI",
114
+ logo: `${baseLogoUrl}/Polygon.svg`,
115
+ },
116
+ {
117
+ chainName: "BINANCE",
118
+ logo: `${baseLogoUrl}/Binance.svg`,
119
+ },
120
+ // {
121
+ // chainName: 'LINEA',
122
+ // logo: `${baseLogoUrl}/Linea.svg`,
123
+ // },
124
+ {
125
+ chainName: "METIS",
126
+ logo: `${baseLogoUrl}/Metis.webp`,
127
+ },
128
+ {
129
+ chainName: "METIS-TESTNET",
130
+ logo: `${baseLogoUrl}/Metis.webp`,
131
+ },
132
+ {
133
+ chainName: "MANTA",
134
+ logo: `${baseLogoUrl}/Manta.webp`,
135
+ },
136
+ {
137
+ chainName: "MANTA-TESTNET",
138
+ logo: `${baseLogoUrl}/Manta.webp`,
139
+ },
140
+ {
141
+ chainName: "MANTLE",
142
+ logo: `${baseLogoUrl}/Mantle.webp`,
143
+ },
144
+ {
145
+ chainName: "MANTLE-TESTNET",
146
+ logo: `${baseLogoUrl}/Mantle.webp`,
147
+ },
148
+ {
149
+ chainName: "SOLANA",
150
+ logo: `${baseLogoUrl}/Solana.webp`,
151
+ },
152
+ {
153
+ chainName: zkLink,
154
+ logo: ``,
155
+ },
156
+ {
157
+ chainName: zkLinkTestnet,
158
+ logo: ``,
159
+ },
160
+ {
161
+ chainName: bitlayerTestnet,
162
+ logo: ``,
163
+ },
164
+ ];
165
+
166
+ export const chainNameToLogo = {
167
+ ETH: `${baseLogoUrl}/Ethereum.webp`,
168
+ FANTOM: `${baseLogoUrl}/Fantom.webp`,
169
+ POLYGON: `${baseLogoUrl}/Polygon.webp`,
170
+ AVALANCHE: `${baseLogoUrl}/Avalanche.webp`,
171
+ OPTIMISM: `${baseLogoUrl}/Optimism.webp`,
172
+ ARBITRUM: `${baseLogoUrl}/Arbitrum.webp`,
173
+ LINEA: `${baseLogoUrl}/Linea.webp`,
174
+ MUMBAI: `${baseLogoUrl}/Polygon.webp`,
175
+ FUSE: `${baseLogoUrl}/Fuse.webp`,
176
+ FUSESPARK: `${baseLogoUrl}/Fuse.webp`,
177
+ BINANCE: `${baseLogoUrl}/Binance.svg`,
178
+ MANTA: `${baseLogoUrl}/Manta.webp`,
179
+ "MANTA-TESTNET": `${baseLogoUrl}/Manta.webp`,
180
+ METIS: `${baseLogoUrl}/Metis.webp`,
181
+ "METIS-TESTNET": `${baseLogoUrl}/Metis.webp`,
182
+ MANTLE: `${baseLogoUrl}/Mantle.webp`,
183
+ "MANTLE-TESTNET": `${baseLogoUrl}/Mantle.webp`,
184
+ SOLANA: `${baseLogoUrl}/Solana.webp`,
185
+ [zkLink]: ``,
186
+ [zkLinkTestnet]: ``,
187
+ [bitlayerTestnet]: ``,
188
+ };
189
+
190
+ export const chainNameToLogoBlack = {
191
+ ETH: `${baseLogoUrlBlack}/Ethereum.webp`,
192
+ BINANCE: `${baseLogoUrlBlack}/binance.webp`,
193
+ FANTOM: `${baseLogoUrlBlack}/Fantom.webp`,
194
+ POLYGON: `${baseLogoUrlBlack}/Polygon.webp`,
195
+ AVALANCHE: `${baseLogoUrlBlack}/Avalanche.webp`,
196
+ OPTIMISM: `${baseLogoUrlBlack}/Optimism.webp`,
197
+ ARBITRUM: `${baseLogoUrlBlack}/Arbitrum.webp`,
198
+ LINEA: `${baseLogoUrlBlack}/Linea.webp`,
199
+ MUMBAI: `${baseLogoUrlBlack}/Polygon.webp`,
200
+ FUSE: `${baseLogoUrlBlack}/fuse.webp`,
201
+ FUSESPARK: `${baseLogoUrlBlack}/fuse.webp`,
202
+ MANTA: `${baseLogoUrlBlack}/Manta.webp`,
203
+ "MANTA-TESTNET": `${baseLogoUrlBlack}/Manta.webp`,
204
+ METIS: `${baseLogoUrlBlack}/Metis.webp`,
205
+ "METIS-TESTNET": `${baseLogoUrlBlack}/Metis.webp`,
206
+ MANTLE: `${baseLogoUrlBlack}/Mantle.webp`,
207
+ "MANTLE-TESTNET": `${baseLogoUrlBlack}/Mantle.webp`,
208
+ SOLANA: `${baseLogoUrlBlack}/Solana.webp`,
209
+ [zkLink]: ``,
210
+ [zkLinkTestnet]: ``,
211
+ [bitlayerTestnet]: ``,
212
+ };
package/src/config.ts ADDED
@@ -0,0 +1,24 @@
1
+ import {
2
+ AA_SUPPORTED_EVM_CHAINS,
3
+ ALLCHAINS,
4
+ SUPPORTED_EVM_CHAINS,
5
+ TESTNET_CHAINS,
6
+ } from "./chains";
7
+
8
+ export const prodApiUrl = "https://prod.tria.so";
9
+
10
+ export const isEvmChain = (chainName: string) => {
11
+ return SUPPORTED_EVM_CHAINS.includes(chainName);
12
+ };
13
+
14
+ export const isAaSupportedChain = (chainName: string) => {
15
+ return AA_SUPPORTED_EVM_CHAINS.includes(chainName);
16
+ };
17
+
18
+ export const isChainSupported = (chainName: string) => {
19
+ return ALLCHAINS.includes(chainName);
20
+ };
21
+
22
+ export const isTestnetChain = (chainName: string) => {
23
+ return TESTNET_CHAINS.includes(chainName);
24
+ };
package/src/connect.ts ADDED
@@ -0,0 +1,26 @@
1
+ export const eventTypes = {
2
+ logIn: "Log in",
3
+ triaSignUp: "Tria Sign up",
4
+ socialSignUp: "Social Sign up",
5
+ signMessage: "Sign Message",
6
+ send: "Send",
7
+ disconnect: "Disconnect",
8
+ switchChain: "Switch chain",
9
+ detected: "Detected Logged in Tria account",
10
+ logout: "Logout",
11
+ passMessage: "Pass Message",
12
+ accessToken: "Access Token Pass",
13
+ idTokenPass: "Id Token Pass",
14
+ saveToAuth: "Save to Auth Iframe",
15
+ };
16
+
17
+ export const TRIA_WALLET_STORE = "tria.wallet.store";
18
+ export const TRIA_WALLET_SELECTED_CHAIN = "tria.wallet.selectedChain";
19
+ export const storageKeys = {
20
+ TRIA_WALLET_STORE: "tria.wallet.store",
21
+ TRIA_WALLET_SELECTED_CHAIN: "tria.wallet.selectedChain",
22
+ PERSIST_ROOT: "persist:root",
23
+ };
24
+ export const triaAuthUrl = "https://auth.tria.so";
25
+
26
+ // export const PARENT_URL = document?.referrer || window?.parent?.[0]?.location?.ancestorOrigins?.[0];
package/src/txn.ts ADDED
@@ -0,0 +1,227 @@
1
+ import { bitlayerTestnet, zkLink, zkLinkTestnet } from "./chains";
2
+
3
+ export const explorerBaseUrls = {
4
+ ETH: "https://etherscan.io",
5
+ POLYGON: "https://polygonscan.com",
6
+ AVALANCHE: "https://snowtrace.io",
7
+ ARBITRUM: "https://arbiscan.io",
8
+ BINANCE: "https://bscscan.com",
9
+ OPTIMISM: "https://optimistic.etherscan.io",
10
+ FANTOM: "https://ftmscan.com",
11
+ SOLANA: "https://solscan.io",
12
+ APTOS: "https://explorer.aptoslabs.com",
13
+ NEO: "https://neo3.neotube.io",
14
+ SUI: "https://suiexplorer.com/?network=mainnet",
15
+ FUSE: "https://explorer.fuse.io",
16
+ FUSESPARK: "https://explorer.fusespark.io",
17
+ MUMBAI: "https://mumbai.polygonscan.com",
18
+ METIS: "https://andromeda-explorer.metis.io",
19
+ "METIS-TESTNET": "https://sepolia.explorer.metisdevops.link",
20
+ MANTLE: "https://explorer.mantle.xyz",
21
+ "MANTLE-TESTNET": "https://explorer.testnet.mantle.xyz",
22
+ MANTA: "https://pacific-explorer.manta.network",
23
+ "MANTA-TESTNET": "https://manta-testnet.calderaexplorer.xyz",
24
+ [zkLink]: "https://explorer.zklink.io",
25
+ [zkLinkTestnet]: "https://goerli.explorer.zklink.io",
26
+ [bitlayerTestnet]: "https://testnet-scan.bitlayer.org/en-us",
27
+ };
28
+
29
+ export const txnBaseUrl = {
30
+ ETH: `${explorerBaseUrls.ETH}/tx`, // /txHash
31
+ POLYGON: `${explorerBaseUrls.POLYGON}/tx`,
32
+ AVALANCHE: `${explorerBaseUrls.AVALANCHE}/tx`,
33
+ ARBITRUM: `${explorerBaseUrls.ARBITRUM}/tx`,
34
+ BINANCE: `${explorerBaseUrls.BINANCE}/tx`,
35
+ OPTIMISM: `${explorerBaseUrls.OPTIMISM}/tx`,
36
+ FANTOM: `${explorerBaseUrls.FANTOM}/tx`,
37
+ FUSE: `${explorerBaseUrls.FUSE}/tx`,
38
+ FUSESPARK: `${explorerBaseUrls.FUSESPARK}/tx`,
39
+ MUMBAI: `${explorerBaseUrls.MUMBAI}/tx`,
40
+ METIS: `${explorerBaseUrls.METIS}/tx`,
41
+ "METIS-TESTNET": `${explorerBaseUrls["METIS-TESTNET"]}/tx`,
42
+ MANTLE: `${explorerBaseUrls.MANTLE}/tx`,
43
+ "MANTLE-TESTNET": `${explorerBaseUrls["MANTLE-TESTNET"]}/tx`,
44
+ MANTA: `${explorerBaseUrls.MANTA}/tx`,
45
+ "MANTA-TESTNET": `${explorerBaseUrls["MANTA-TESTNET"]}/tx`,
46
+ [zkLink]: `${explorerBaseUrls[zkLink]}/tx`,
47
+ [zkLinkTestnet]: `${explorerBaseUrls[zkLinkTestnet]}/tx`,
48
+ [bitlayerTestnet]: `${explorerBaseUrls[bitlayerTestnet]}/tx`,
49
+ };
50
+
51
+ export const nativeTokenDetails = {
52
+ ETH: {
53
+ name: "Ether",
54
+ symbol: "ETH",
55
+ logoUrl: "https://www.datocms-assets.com/86369/1669619533-ethereum.png",
56
+ },
57
+ POLYGON: {
58
+ name: "Matic Token",
59
+ symbol: "MATIC",
60
+ logoUrl:
61
+ "https://logos.covalenthq.com/tokens/1/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png",
62
+ },
63
+ AVALANCHE: {
64
+ name: "Avalanche Coin",
65
+ symbol: "AVAX",
66
+ logoUrl:
67
+ "https://www.datocms-assets.com/86369/1686152997-avalanche-colour.png",
68
+ },
69
+ ARBITRUM: {
70
+ name: "Arbitrum Mainnet Ether",
71
+ symbol: "ETH",
72
+ logoUrl: "https://www.datocms-assets.com/86369/1669925028-arbitrum.png",
73
+ },
74
+ BINANCE: {
75
+ name: "Binance Coin",
76
+ symbol: "BNB",
77
+ logoUrl:
78
+ "https://www.datocms-assets.com/86369/1670003837-biance-smart-chain-colour.png",
79
+ },
80
+ OPTIMISM: {
81
+ name: "Ether",
82
+ symbol: "ETH",
83
+ logoUrl:
84
+ "https://www.datocms-assets.com/86369/1670347461-optimisim-colour.png",
85
+ },
86
+ FANTOM: {
87
+ name: "Fantom",
88
+ symbol: "FTM",
89
+ logoUrl: "https://www.datocms-assets.com/86369/1669925359-fantom-1.png",
90
+ },
91
+ FUSE: {
92
+ name: "Fuse",
93
+ symbol: "FUSE",
94
+ logoUrl:
95
+ "https://assets.coingecko.com/coins/images/10347/standard/fuse.png",
96
+ },
97
+ FUSESPARK: {
98
+ name: "Spark",
99
+ symbol: "SPARK",
100
+ logoUrl:
101
+ "https://assets.coingecko.com/coins/images/10347/standard/fuse.png",
102
+ },
103
+ MUMBAI: {
104
+ name: "Matic Token",
105
+ symbol: "MATIC",
106
+ logoUrl:
107
+ "https://logos.covalenthq.com/tokens/1/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png",
108
+ },
109
+ METIS: {
110
+ name: "Metis Token",
111
+ symbol: "METIS",
112
+ logoUrl: "https://static.tria.so/chain-logo-w/Metis.webp",
113
+ },
114
+ "METIS-TESTNET": {
115
+ name: "Metis Token",
116
+ symbol: "METIS",
117
+ logoUrl: "https://static.tria.so/chain-logo-w/Metis.webp",
118
+ },
119
+ MANTLE: {
120
+ name: "Mantle",
121
+ symbol: "MNT",
122
+ logoUrl: "https://static.tria.so/chain-logo-w/Mantle.webp",
123
+ },
124
+ "MANTLE-TESTNET": {
125
+ name: "Mantle",
126
+ symbol: "MNT",
127
+ logoUrl: "https://static.tria.so/chain-logo-w/Mantle.webp",
128
+ },
129
+ MANTA: {
130
+ name: "Ether",
131
+ symbol: "ETH",
132
+ logoUrl: "https://static.tria.so/chain-logo-w/Manta.webp",
133
+ },
134
+ "MANTA-TESTNET": {
135
+ name: "Ether",
136
+ symbol: "ETH",
137
+ logoUrl: "https://static.tria.so/chain-logo-w/Manta.webp",
138
+ },
139
+ SOLANA: {
140
+ name: "Solana",
141
+ symbol: "SOL",
142
+ logoUrl: "https://static.tria.so/chain-logo-w/Solana.webp",
143
+ },
144
+ [zkLink]: {
145
+ name: "Ether",
146
+ symbol: "ETH",
147
+ logoUrl: "https://static.tria.so/chain-logo-w/Ethereum.webp",
148
+ },
149
+ [zkLinkTestnet]: {
150
+ name: "Ether",
151
+ symbol: "ETH",
152
+ logoUrl: "https://static.tria.so/chain-logo-w/bitcoin.webp",
153
+ },
154
+ [bitlayerTestnet]: {
155
+ name: "Bitcoin",
156
+ symbol: "BTC",
157
+ logoUrl: "https://static.tria.so/chain-logo-w/bitcoin.webp",
158
+ },
159
+ };
160
+
161
+ const alchemyKey = "kcuWVV9ss_iLWJ2Lw6xdHbmtZYixfY7Z";
162
+
163
+ export const rpcUrls = {
164
+ MUMBAI: `https://polygon-mumbai.g.alchemy.com/v2/${alchemyKey}`, //'https://polygon-mumbai.blockpi.network/v1/rpc/public',
165
+ ETH: "https://eth.llamarpc.com",
166
+ POLYGON: `https://polygon-mainnet.g.alchemy.com/v2/${alchemyKey}`, // 'https://polygon.llamarpc.com',
167
+ AVALANCHE: "https://avalanche-c-chain.publicnode.com",
168
+ ARBITRUM: "https://arbitrum-one.publicnode.com",
169
+ BINANCE: "https://bsc.publicnode.com",
170
+ OPTIMISM: "https://optimism.meowrpc.com",
171
+ FANTOM: "https://fantom.publicnode.com",
172
+ FUSE: "https://rpc.fuse.io",
173
+ FUSESPARK: "https://rpc.fusespark.io",
174
+ MANTA: "https://1rpc.io/manta",
175
+ "MANTA-TESTNET": "https://manta-testnet.calderachain.xyz/http",
176
+ METIS: "https://metis-pokt.nodies.app",
177
+ "METIS-TESTNET": "https://goerli.gateway.metisdevops.link",
178
+ MANTLE: "https://rpc.mantle.xyz",
179
+ "MANTLE-TESTNET": "https://rpc.testnet.mantle.xyz",
180
+ [zkLink]: "https://rpc.zklink.io",
181
+ [zkLinkTestnet]: "https://goerli.rpc.zklink.io",
182
+ [bitlayerTestnet]: "https://testnet-rpc.bitlayer.org",
183
+ };
184
+
185
+ export const chainNameToChainId = {
186
+ MUMBAI: 80001,
187
+ POLYGON: 137,
188
+ ETH: 1,
189
+ AVALANCHE: 43114,
190
+ ARBITRUM: 42161,
191
+ BINANCE: 56,
192
+ OPTIMISM: 10,
193
+ FANTOM: 250,
194
+ FUSE: 122,
195
+ FUSESPARK: 123,
196
+ MANTA: 169,
197
+ "MANTA-TESTNET": 3441005,
198
+ METIS: 1088,
199
+ "METIS-TESTNET": 599,
200
+ MANTLE: 5000,
201
+ "MANTLE-TESTNET": 5001,
202
+ [zkLink]: 810180,
203
+ [zkLinkTestnet]: 810182,
204
+ [bitlayerTestnet]: 200810,
205
+ };
206
+
207
+ export const chainIdToChainName = {
208
+ 80001: "MUMBAI",
209
+ 137: "POLYGON",
210
+ 1: "ETH",
211
+ 43114: "AVALANCHE",
212
+ 42161: "ARBITRUM",
213
+ 56: "BINANCE",
214
+ 10: "OPTIMISM",
215
+ 250: "FANTOM",
216
+ 122: "FUSE",
217
+ 123: "FUSESPARK",
218
+ 5000: "MANTLE",
219
+ 5001: "MANTLE-TESTNET",
220
+ 1088: "METIS",
221
+ 599: "METIS-TESTNET",
222
+ 169: "MANTA",
223
+ 3441005: "MANTA-TESTNET",
224
+ 810180: zkLink,
225
+ 810182: zkLinkTestnet,
226
+ 200810: bitlayerTestnet,
227
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "CommonJS", // "CommonJS",
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "moduleResolution": "node",
9
+ "outDir": "dist",
10
+ "resolveJsonModule": true,
11
+ // "noImplicitReturns": true,
12
+ "declaration": true
13
+ },
14
+ "include": ["**/*.ts", "**/*.js"],
15
+ "exclude": ["**/*.d.ts"]
16
+ }