Skip to content

Commit c4ec43a

Browse files
committed
feat: move infura key to build-time environment variable
1 parent bfa28dc commit c4ec43a

5 files changed

Lines changed: 37 additions & 8 deletions

File tree

.github/workflows/tokenscript-viewer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
cd "${PROJ_PATH}"
3636
npm ci
3737
npm run build
38+
env:
39+
INFURA_API_KEY: ${{ vars.INFURA_API_KEY }}
3840
- uses: actions/upload-artifact@v4
3941
with:
4042
name: tokenscript-viewer

javascript/tokenscript-viewer/package-lock.json

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

javascript/tokenscript-viewer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"devDependencies": {
1717
"@types/dexie": "^1.3.1",
1818
"@types/jsdom": "^21.1.3",
19+
"dotenv": "^16.4.5",
1920
"patch-package": "^6.5.1",
2021
"rollup-plugin-node-builtins": "^2.1.2",
2122
"rollup-plugin-node-polyfills": "^0.2.1",

javascript/tokenscript-viewer/src/integration/constants.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {IChainConfig} from "@tokenscript/engine-js/src/wallet/EthersAdapter";
2+
import {Env} from "@stencil/core";
23

34
export interface ChainMapInterface {
45
[key: number]: string;
@@ -67,6 +68,8 @@ export const CHAIN_NAME_MAP: ChainMapInterface = {
6768
[ChainID.BASE_SEPOLIA]: "Base (Sepolia Testnet)"
6869
};
6970

71+
const INFURA_API_KEY = Env.INFURA_API_KEY ?? "9f79b2f9274344af90b8d4e244b580ef"
72+
7073
export const CHAIN_EAS_SCHEMA_REGI_MAP: ChainMapInterface = {
7174
[ChainID.ETHEREUM]: '0xA7b39296258348C78294F95B872b282326A97BDF',
7275
[ChainID.SEPOLIA]: '0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0',
@@ -76,26 +79,26 @@ export const CHAIN_EAS_SCHEMA_REGI_MAP: ChainMapInterface = {
7679

7780
export const CHAIN_CONFIG: {[chain: number]: IChainConfig} = {
7881
[ChainID.ETHEREUM]: {
79-
rpc: 'https://mainnet.infura.io/v3/3ca8f1ba91f84e1f97c99f6218fe3743',
82+
rpc: `https://mainnet.infura.io/v3/${INFURA_API_KEY}`,
8083
explorer: 'https://etherscan.com/tx/'
8184
},
8285
[ChainID.SEPOLIA]: {
83-
rpc: 'https://sepolia.infura.io/v3/9f79b2f9274344af90b8d4e244b580ef',
86+
rpc: `https://sepolia.infura.io/v3/${INFURA_API_KEY}`,
8487
explorer: 'https://sepolia.etherscan.io/tx/'
8588
},
8689
[ChainID.HOLESKY]: {
87-
rpc: 'https://holesky.infura.io/v3/9f79b2f9274344af90b8d4e244b580ef',
90+
rpc: `https://holesky.infura.io/v3/${INFURA_API_KEY}`,
8891
explorer: 'https://holesky.etherscan.io/tx/'
8992
},
9093
[ChainID.POLYGON]: {
9194
rpc: [
92-
'https://polygon-mainnet.infura.io/v3/3ca8f1ba91f84e1f97c99f6218fe3743',
95+
`https://polygon-mainnet.infura.io/v3/${INFURA_API_KEY}`,
9396
//'https://polygon.meowrpc.com'
9497
],
9598
explorer: 'https://polygonscan.com/tx/'
9699
},
97100
[ChainID.AMOY]: {
98-
rpc: 'https://polygon-amoy.infura.io/v3/9f79b2f9274344af90b8d4e244b580ef',
101+
rpc: `https://polygon-amoy.infura.io/v3/${INFURA_API_KEY}`,
99102
explorer: 'https://amoy.polygonscan.com/tx/'
100103
},
101104
[ChainID.BSC]: {
@@ -143,11 +146,11 @@ export const CHAIN_CONFIG: {[chain: number]: IChainConfig} = {
143146
explorer: 'https://explorer.sepolia.mantle.xyz/tx/'
144147
},
145148
[ChainID.BASE]: {
146-
rpc: 'https://base-mainnet.infura.io/v3/3ca8f1ba91f84e1f97c99f6218fe3743',
149+
rpc: `https://base-mainnet.infura.io/v3/${INFURA_API_KEY}`,
147150
explorer: 'https://basescan.org/tx/'
148151
},
149152
[ChainID.BASE_SEPOLIA]: {
150-
rpc: 'https://base-sepolia.infura.io/v3/3ca8f1ba91f84e1f97c99f6218fe3743',
153+
rpc: `https://base-sepolia.infura.io/v3/${INFURA_API_KEY}`,
151154
explorer: 'https://sepolia.basescan.org/tx/'
152155
}
153156
}

javascript/tokenscript-viewer/stencil.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Config} from '@stencil/core';
33
//import builtins from 'rollup-plugin-node-builtins';
44
//import globals from 'rollup-plugin-node-globals';
55
import nodePolyfills from "rollup-plugin-node-polyfills";
6+
import 'dotenv/config'
67

78
// https://stenciljs.com/docs/config
89

@@ -19,6 +20,9 @@ export const config: Config = {
1920
polyfills: false
2021
},
2122
],
23+
env: {
24+
INFURA_API_KEY: process.env.INFURA_API_KEY
25+
},
2226
nodeResolve: {
2327
module: true,
2428
browser: true,

0 commit comments

Comments
 (0)