-
Notifications
You must be signed in to change notification settings - Fork 1
feat: publish subgraph hash configmap #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,7 @@ import { | |||||||||||||||||||||||||||
| promptForCount, | ||||||||||||||||||||||||||||
| promptForText, | ||||||||||||||||||||||||||||
| } from "./bootstrap.prompt-helpers.ts"; | ||||||||||||||||||||||||||||
| import { loadSubgraphHash } from "./bootstrap.subgraph.ts"; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| type CliOptions = { | ||||||||||||||||||||||||||||
| allocations?: string; | ||||||||||||||||||||||||||||
|
|
@@ -48,6 +49,7 @@ type CliOptions = { | |||||||||||||||||||||||||||
| genesisConfigmapName?: string; | ||||||||||||||||||||||||||||
| staticNodesConfigmapName?: string; | ||||||||||||||||||||||||||||
| faucetArtifactPrefix?: string; | ||||||||||||||||||||||||||||
| subgraphHashFile?: string; | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| type BootstrapDependencies = { | ||||||||||||||||||||||||||||
|
|
@@ -58,6 +60,7 @@ type BootstrapDependencies = { | |||||||||||||||||||||||||||
| service: BesuGenesisService; | ||||||||||||||||||||||||||||
| loadAllocations: typeof loadAllocations; | ||||||||||||||||||||||||||||
| loadAbis: typeof loadAbis; | ||||||||||||||||||||||||||||
| loadSubgraphHash: typeof loadSubgraphHash; | ||||||||||||||||||||||||||||
| outputResult: (type: OutputType, payload: OutputPayload) => Promise<void>; | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -69,6 +72,7 @@ const { | |||||||||||||||||||||||||||
| genesisConfigMapName: DEFAULT_GENESIS_CONFIGMAP_NAME, | ||||||||||||||||||||||||||||
| staticNodesConfigMapName: DEFAULT_STATIC_NODES_CONFIGMAP_NAME, | ||||||||||||||||||||||||||||
| faucetArtifactPrefix: DEFAULT_FAUCET_ARTIFACT_PREFIX, | ||||||||||||||||||||||||||||
| subgraphConfigMapName: DEFAULT_SUBGRAPH_CONFIGMAP_NAME, | ||||||||||||||||||||||||||||
| } = ARTIFACT_DEFAULTS; | ||||||||||||||||||||||||||||
| const OUTPUT_CHOICES: OutputType[] = ["screen", "file", "kubernetes"]; | ||||||||||||||||||||||||||||
| const LEADING_DOT_REGEX = /^\./u; | ||||||||||||||||||||||||||||
|
|
@@ -303,6 +307,7 @@ const runBootstrap = async ( | |||||||||||||||||||||||||||
| genesisConfigmapName: genesisConfigmapNameOption, | ||||||||||||||||||||||||||||
| staticNodesConfigmapName: staticNodesConfigmapNameOption, | ||||||||||||||||||||||||||||
| faucetArtifactPrefix: faucetArtifactPrefixOption, | ||||||||||||||||||||||||||||
| subgraphHashFile: subgraphHashFileOption, | ||||||||||||||||||||||||||||
| } = options; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const resolveCount = ( | ||||||||||||||||||||||||||||
|
|
@@ -399,6 +404,22 @@ const runBootstrap = async ( | |||||||||||||||||||||||||||
| ? await deps.loadAbis(trimmedAbiDirectory) | ||||||||||||||||||||||||||||
| : []; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const envSubgraphHashFile = Bun.env.SUBGRAPH_HASH_FILE?.trim(); | ||||||||||||||||||||||||||||
| const providedSubgraphHashFile = | ||||||||||||||||||||||||||||
| subgraphHashFileOption === undefined | ||||||||||||||||||||||||||||
| ? undefined | ||||||||||||||||||||||||||||
| : subgraphHashFileOption.trim(); | ||||||||||||||||||||||||||||
| let subgraphHashPath: string | undefined; | ||||||||||||||||||||||||||||
| if (providedSubgraphHashFile && providedSubgraphHashFile.length > 0) { | ||||||||||||||||||||||||||||
| subgraphHashPath = providedSubgraphHashFile; | ||||||||||||||||||||||||||||
| } else if (envSubgraphHashFile && envSubgraphHashFile.length > 0) { | ||||||||||||||||||||||||||||
| subgraphHashPath = envSubgraphHashFile; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+407
to
+417
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for determining
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const subgraphHash = subgraphHashPath | ||||||||||||||||||||||||||||
| ? await deps.loadSubgraphHash(subgraphHashPath) | ||||||||||||||||||||||||||||
| : undefined; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const { genesis } = await deps.promptForGenesis(deps.service, { | ||||||||||||||||||||||||||||
| faucetAddress, | ||||||||||||||||||||||||||||
| allocations: allocationOverrides, | ||||||||||||||||||||||||||||
|
|
@@ -425,8 +446,10 @@ const runBootstrap = async ( | |||||||||||||||||||||||||||
| validatorPrefix: staticNodePodPrefix, | ||||||||||||||||||||||||||||
| genesisConfigMapName, | ||||||||||||||||||||||||||||
| staticNodesConfigMapName, | ||||||||||||||||||||||||||||
| subgraphConfigMapName: DEFAULT_SUBGRAPH_CONFIGMAP_NAME, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| abiArtifacts, | ||||||||||||||||||||||||||||
| subgraphHash, | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await deps.outputResult(outputType ?? "screen", payload); | ||||||||||||||||||||||||||||
|
|
@@ -441,6 +464,7 @@ const defaultDependencies: BootstrapDependencies = { | |||||||||||||||||||||||||||
| service: new BesuGenesisService(), | ||||||||||||||||||||||||||||
| loadAllocations, | ||||||||||||||||||||||||||||
| loadAbis, | ||||||||||||||||||||||||||||
| loadSubgraphHash, | ||||||||||||||||||||||||||||
| outputResult: defaultOutputResult, | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
| /* c8 ignore end */ | ||||||||||||||||||||||||||||
|
|
@@ -487,6 +511,11 @@ const createCliCommand = ( | |||||||||||||||||||||||||||
| "Directory containing ABI JSON files to publish as ConfigMaps.", | ||||||||||||||||||||||||||||
| (value: string) => stripSurroundingQuotes(value) | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| .option( | ||||||||||||||||||||||||||||
| "--subgraph-hash-file <path>", | ||||||||||||||||||||||||||||
| "Path to a file containing the subgraph IPFS hash.", | ||||||||||||||||||||||||||||
| (value: string) => stripSurroundingQuotes(value) | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| .option( | ||||||||||||||||||||||||||||
| "-o, --outputType <type>", | ||||||||||||||||||||||||||||
| `Output target (${OUTPUT_CHOICES.join(", ")}).`, | ||||||||||||||||||||||||||||
|
|
@@ -601,6 +630,10 @@ const createCliCommand = ( | |||||||||||||||||||||||||||
| normalizedOptions.abiDirectory === undefined | ||||||||||||||||||||||||||||
| ? undefined | ||||||||||||||||||||||||||||
| : stripSurroundingQuotes(normalizedOptions.abiDirectory), | ||||||||||||||||||||||||||||
| subgraphHashFile: | ||||||||||||||||||||||||||||
| normalizedOptions.subgraphHashFile === undefined | ||||||||||||||||||||||||||||
| ? undefined | ||||||||||||||||||||||||||||
| : stripSurroundingQuotes(normalizedOptions.subgraphHashFile), | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| for (const { key, sanitize } of TEXT_OPTION_DESCRIPTORS) { | ||||||||||||||||||||||||||||
|
|
@@ -628,6 +661,12 @@ const createCliCommand = ( | |||||||||||||||||||||||||||
| trimmed.length === 0 ? undefined : trimmed; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (sanitizedOptions.subgraphHashFile) { | ||||||||||||||||||||||||||||
| const trimmed = sanitizedOptions.subgraphHashFile.trim(); | ||||||||||||||||||||||||||||
| sanitizedOptions.subgraphHashFile = | ||||||||||||||||||||||||||||
| trimmed.length === 0 ? undefined : trimmed; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await runBootstrap(sanitizedOptions, deps); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
finallyblock for restoring theSUBGRAPH_HASH_FILEenvironment variable can be simplified. Theif/elsestatement is not necessary, as assigningoriginalEnv(which can be a string orundefined) directly toBun.env.SUBGRAPH_HASH_FILEachieves the same result more concisely.