11import { rm , writeFile } from "node:fs/promises" ;
22import { basename , resolve } from "node:path" ;
3- import { writeTemplate } from "@/commands/codegen/utils/write-template" ;
4- import { getApplicationOrPersonalAccessToken } from "@/utils/get-app-or-personal-token" ;
53import { generateSchema } from "@gql.tada/cli-utils" ;
64import { projectRoot } from "@settlemint/sdk-utils/filesystem" ;
75import { appendHeaders , graphqlFetchWithRetry } from "@settlemint/sdk-utils/http" ;
86import { installDependencies , isPackageInstalled } from "@settlemint/sdk-utils/package-manager" ;
97import { note } from "@settlemint/sdk-utils/terminal" ;
108import { type DotEnv , LOCAL_INSTANCE , STANDALONE_INSTANCE } from "@settlemint/sdk-utils/validation" ;
9+ import { writeTemplate } from "@/commands/codegen/utils/write-template" ;
10+ import { getApplicationOrPersonalAccessToken } from "@/utils/get-app-or-personal-token" ;
1111
1212const PACKAGE_NAME = "@settlemint/sdk-blockscout" ;
1313
@@ -167,6 +167,18 @@ import { createLogger, requestLogger, type LogLevel } from '@settlemint/sdk-util
167167
168168const logger = createLogger({ level: process.env.SETTLEMINT_LOG_LEVEL as LogLevel });
169169
170+ // Validate required environment variables
171+ const blockscoutEndpoint = process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT;
172+ const blockscoutUiEndpointVar = process.env.SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT;
173+
174+ if (!blockscoutEndpoint) {
175+ throw new Error('SETTLEMINT_BLOCKSCOUT_ENDPOINT environment variable is required');
176+ }
177+
178+ if (!blockscoutUiEndpointVar) {
179+ throw new Error('SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT environment variable is required');
180+ }
181+
170182export const { client: blockscoutClient, graphql: blockscoutGraphql } = createBlockscoutClient<{
171183 introspection: introspection;
172184 disableMasking: true;
@@ -189,13 +201,13 @@ export const { client: blockscoutClient, graphql: blockscoutGraphql } = createBl
189201 Wei: string;
190202 };
191203}>({
192- instance: process.env.SETTLEMINT_BLOCKSCOUT_ENDPOINT! ,
204+ instance: blockscoutEndpoint ,
193205 accessToken: process.env.SETTLEMINT_ACCESS_TOKEN,
194206}, {
195207 fetch: requestLogger(logger, "blockscout", fetch) as typeof fetch,
196208});
197209
198- export const blockscoutUiEndpoint = process.env.SETTLEMINT_BLOCKSCOUT_UI_ENDPOINT! ;` ;
210+ export const blockscoutUiEndpoint = blockscoutUiEndpointVar ;` ;
199211
200212 await writeTemplate ( template , "/lib/settlemint" , "blockscout.ts" ) ;
201213
0 commit comments