@tokemak/graph-cli 0.0.6 → 0.0.7

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/dist/index.js CHANGED
@@ -3078,17 +3078,44 @@ function getSdk6(client, withWrapper = defaultWrapper6) {
3078
3078
  }
3079
3079
 
3080
3080
  // clients.ts
3081
- var endpoints = {
3082
- [import_chains.mainnet.id]: import_config.coreMainnetConfig.subgraphEndpoint,
3083
- [import_chains.base.id]: import_config.coreBaseConfig.subgraphEndpoint,
3084
- [import_chains.sonic.id]: import_config.coreSonicConfig.subgraphEndpoint,
3085
- [import_chains.plasma.id]: import_config.corePlasmaConfig.subgraphEndpoint,
3086
- [import_chains.arbitrum.id]: import_config.coreArbitrumConfig.subgraphEndpoint,
3087
- [import_chains.linea.id]: import_config.coreLineaConfig.subgraphEndpoint
3081
+ var getEndpoint = (chainId) => {
3082
+ let config;
3083
+ switch (chainId) {
3084
+ case import_chains.mainnet.id:
3085
+ config = import_config.coreMainnetConfig;
3086
+ break;
3087
+ case import_chains.base.id:
3088
+ config = import_config.coreBaseConfig;
3089
+ break;
3090
+ case import_chains.sonic.id:
3091
+ config = import_config.coreSonicConfig;
3092
+ break;
3093
+ case import_chains.plasma.id:
3094
+ config = import_config.corePlasmaConfig;
3095
+ break;
3096
+ case import_chains.arbitrum.id:
3097
+ config = import_config.coreArbitrumConfig;
3098
+ break;
3099
+ case import_chains.linea.id:
3100
+ config = import_config.coreLineaConfig;
3101
+ break;
3102
+ default:
3103
+ throw new Error(`Unsupported chainId: ${chainId}`);
3104
+ }
3105
+ if (!config) {
3106
+ throw new Error(
3107
+ `Config for chainId ${chainId} is undefined. Make sure @tokemak/config is properly installed and built.`
3108
+ );
3109
+ }
3110
+ if (!config.subgraphEndpoint) {
3111
+ throw new Error(
3112
+ `subgraphEndpoint is undefined for chainId ${chainId}. Make sure @tokemak/config is properly configured.`
3113
+ );
3114
+ }
3115
+ return config.subgraphEndpoint;
3088
3116
  };
3089
3117
  var getSdkByChainId = (chainId) => {
3090
- const url = endpoints[chainId];
3091
- if (!url) throw new Error(`Unsupported chainId: ${chainId}`);
3118
+ const url = getEndpoint(chainId);
3092
3119
  const client = new import_graphql_request.GraphQLClient(url);
3093
3120
  if (chainId === import_chains.base.id) return getSdk2(client);
3094
3121
  if (chainId === import_chains.sonic.id) return getSdk3(client);
package/dist/index.mjs CHANGED
@@ -3049,17 +3049,44 @@ function getSdk6(client, withWrapper = defaultWrapper6) {
3049
3049
  }
3050
3050
 
3051
3051
  // clients.ts
3052
- var endpoints = {
3053
- [mainnet.id]: coreMainnetConfig.subgraphEndpoint,
3054
- [base.id]: coreBaseConfig.subgraphEndpoint,
3055
- [sonic.id]: coreSonicConfig.subgraphEndpoint,
3056
- [plasma.id]: corePlasmaConfig.subgraphEndpoint,
3057
- [arbitrum.id]: coreArbitrumConfig.subgraphEndpoint,
3058
- [linea.id]: coreLineaConfig.subgraphEndpoint
3052
+ var getEndpoint = (chainId) => {
3053
+ let config;
3054
+ switch (chainId) {
3055
+ case mainnet.id:
3056
+ config = coreMainnetConfig;
3057
+ break;
3058
+ case base.id:
3059
+ config = coreBaseConfig;
3060
+ break;
3061
+ case sonic.id:
3062
+ config = coreSonicConfig;
3063
+ break;
3064
+ case plasma.id:
3065
+ config = corePlasmaConfig;
3066
+ break;
3067
+ case arbitrum.id:
3068
+ config = coreArbitrumConfig;
3069
+ break;
3070
+ case linea.id:
3071
+ config = coreLineaConfig;
3072
+ break;
3073
+ default:
3074
+ throw new Error(`Unsupported chainId: ${chainId}`);
3075
+ }
3076
+ if (!config) {
3077
+ throw new Error(
3078
+ `Config for chainId ${chainId} is undefined. Make sure @tokemak/config is properly installed and built.`
3079
+ );
3080
+ }
3081
+ if (!config.subgraphEndpoint) {
3082
+ throw new Error(
3083
+ `subgraphEndpoint is undefined for chainId ${chainId}. Make sure @tokemak/config is properly configured.`
3084
+ );
3085
+ }
3086
+ return config.subgraphEndpoint;
3059
3087
  };
3060
3088
  var getSdkByChainId = (chainId) => {
3061
- const url = endpoints[chainId];
3062
- if (!url) throw new Error(`Unsupported chainId: ${chainId}`);
3089
+ const url = getEndpoint(chainId);
3063
3090
  const client = new GraphQLClient(url);
3064
3091
  if (chainId === base.id) return getSdk2(client);
3065
3092
  if (chainId === sonic.id) return getSdk3(client);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokemak/graph-cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -10,24 +10,24 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
+ "scripts": {
14
+ "codegen": "graphql-codegen --config codegen.ts",
15
+ "build": "pnpm codegen && tsup",
16
+ "watch": "graphql-codegen --watch"
17
+ },
13
18
  "devDependencies": {
14
19
  "@graphql-codegen/cli": "5.0.6",
15
20
  "@graphql-codegen/typescript": "4.1.6",
16
21
  "@graphql-codegen/typescript-graphql-request": "6.2.0",
17
22
  "@graphql-codegen/typescript-operations": "4.6.1",
18
- "tsup": "^8.0.0",
19
- "@tokemak/eslint-config": "0.0.0"
23
+ "@tokemak/eslint-config": "workspace:*",
24
+ "tsup": "^8.0.0"
20
25
  },
21
26
  "dependencies": {
22
27
  "graphql": "16.11.0",
23
28
  "graphql-request": "7.1.2",
24
29
  "graphql-tag": "2.12.6",
25
30
  "viem": "2.x",
26
- "@tokemak/config": "0.0.4"
27
- },
28
- "scripts": {
29
- "codegen": "graphql-codegen --config codegen.ts",
30
- "build": "pnpm codegen && tsup",
31
- "watch": "graphql-codegen --watch"
31
+ "@tokemak/config": "workspace:*"
32
32
  }
33
- }
33
+ }