generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stuck on failed off chain api request executed by DON
- Loading branch information
1 parent
1574a22
commit 252b146
Showing
13 changed files
with
673 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./send-link"; | ||
export * from "./get-token-balance"; | ||
export * from "./upload-secret-to-gist"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as dotenv from "dotenv"; | ||
dotenv.config(); | ||
// import chalk from "chalk"; | ||
import { task } from "hardhat/config"; | ||
import { SecretsManager, createGist } from "@chainlink/functions-toolkit"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { networkConfig } from "../helper-hardhat-config"; | ||
|
||
/** Upload a single secret to a github gist | ||
* @param key the name for the secret | ||
* @param value the value of the secret | ||
* @returns the `encryptedSecretsReference` used to make a chainlink functions request | ||
*/ | ||
|
||
export async function uploadSecretToGist(hre: HardhatRuntimeEnvironment, key: string, value: string) { | ||
if (hre.network.name !== "sepolia") { | ||
throw new Error("This script is only configured for sepolia network"); | ||
} | ||
|
||
const chainId = await hre.ethers.provider.getNetwork().then(network => network.chainId); | ||
const { routerAddress, toolkitDonId } = networkConfig[chainId].FunctionsConsumer; | ||
|
||
const [signer] = await hre.ethers.getSigners(); | ||
|
||
const secretsManager = new SecretsManager({ | ||
signer: signer, | ||
functionsRouterAddress: routerAddress, | ||
donId: toolkitDonId, | ||
}); | ||
await secretsManager.initialize(); | ||
|
||
const secretsObject = { [key]: value }; | ||
// console.log("secretsObject", secretsObject); | ||
|
||
const encryptedSecrets = await secretsManager.encryptSecrets(secretsObject); | ||
// console.log("encryptedSecrets", encryptedSecrets); | ||
|
||
if (process.env.GITHUB_ACCESS_TOKEN) { | ||
const gistURL = await createGist(process.env.GITHUB_ACCESS_TOKEN, JSON.stringify(encryptedSecrets)); | ||
console.log("gistURL", gistURL); | ||
const encryptedSecretsReference: string = await secretsManager.encryptSecretsUrls([gistURL]); | ||
console.log("encryptedSecretsReference:", encryptedSecretsReference); | ||
return encryptedSecretsReference; | ||
} else { | ||
throw new Error("GITHUB_ACCESS_TOKEN not found in .env"); | ||
} | ||
} | ||
|
||
task("upload-secret-to-gist", "Uploads encrypted secrets to a GitHub gist") | ||
.addParam("key", "The name for the secret") | ||
.addParam("value", "The value of the secret") | ||
.setAction(async (taskArgs, hre) => { | ||
await uploadSecretToGist(hre, taskArgs.key, taskArgs.value); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.