Skip to content
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

Calm #217

Closed
wants to merge 2 commits into from
Closed

Calm #217

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Functions-request-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ const { Location, ReturnType, CodeLanguage } = require("@chainlink/functions-too
// Configure the request by setting the fields below
const requestConfig = {
// String containing the source code to be executed
source: fs.readFileSync("./calculation-example.js").toString(),
source: fs.readFileSync("./secrets-example.js").toString(),
//source: fs.readFileSync("./API-request-example.js").toString(),
// Location of source code (only Inline is currently supported)
codeLocation: Location.Inline,
// Optional. Secrets can be accessed within the source code with `secrets.varName` (ie: secrets.apiKey). The secrets object can only contain string values.
secrets: { apiKey: process.env.COINMARKETCAP_API_KEY ?? "" },
secrets: { test: "Hello world" },
// Optional if secrets are expected in the sourceLocation of secrets (only Remote or DONHosted is supported)
secretsLocation: Location.DONHosted,
secretsLocation: Location.Remote,
// Args (string only array) can be accessed within the source code with `args[index]` (ie: args[0]).
args: ["1", "bitcoin", "btc-bitcoin", "btc", "1000000", "450"],
// Code language (only JavaScript is currently supported)
codeLanguage: CodeLanguage.JavaScript,
// Expected type of the returned value
expectedReturnType: ReturnType.uint256,
expectedReturnType: ReturnType.string,
}

module.exports = requestConfig
9 changes: 9 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
arbitrumSepolia: networks.arbitrumSepolia.verifyApiKey,
baseSepolia: networks.baseSepolia.verifyApiKey,
optimismSepolia: networks.optimismSepolia.verifyApiKey,
calm: "UNNEEDED",
},
customChains: [
{
Expand Down Expand Up @@ -90,6 +91,14 @@ module.exports = {
browserURL: "https://amoy.polygonscan.com",
},
},
{
network: "calm",
chainId: 1337,
urls: {
apiURL: "https://chain-alpha-blockscout.shib.sandbox.enterprise.chain.link/api",
browserURL: "https://chain-alpha-blockscout.shib.sandbox.enterprise.chain.link",
},
},
],
},
gasReporter: {
Expand Down
18 changes: 16 additions & 2 deletions networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ const networks = {
"https://02.functions-gateway.testnet.chain.link/",
],
},
calm: {
url: "https://chain-alpha-rpc.shib.sandbox.enterprise.chain.link/",
gasPrice: 10000000000,
nonce: undefined,
accounts,
verifyApiKey: "UNNEEDED",
chainId: 1337,
confirmations: DEFAULT_VERIFICATION_BLOCK_CONFIRMATIONS,
nativeCurrencySymbol: "ETH",
linkToken: "0x42699A7612A82f1d9C36148af9C77354759b210b",
linkPriceFeed: "0xE08fB6ACf0229AeD65e0e7bDA485b0960d2Cf5a6", // https://docs.chain.link/data-feeds/price-feeds/addresses?network=base&page=1
functionsRouter: "0x589D1988547E26d424A72A03e7cb141047a938bf",
donId: "fun-project-calm-1",
},
optimismSepolia: {
url: process.env.OPTIMISM_SEPOLIA_RPC_URL || "UNSET", // https://docs.optimism.io/chain/networks#op-sepolia
gasPrice: undefined,
Expand Down Expand Up @@ -228,8 +242,8 @@ const networks = {
accounts,
confirmations: 1,
nativeCurrencySymbol: "ETH",
linkToken: "0x94d3C68A91C972388d7863D25EDD2Be7e2F21F21",
functionsRouter: "0xCbfD616baE0F13EFE0528c446184C9C0EAa8040e",
linkToken: "0x61557a252572fA439D67a3f055B7Db933f061826",
functionsRouter: "0x4106961a86BB4D0117b79bBE0b61bc37334eEA3B",
donId: "local-functions-testnet",
},
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions secrets-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return Functions.encodeString(secrets.test)
14 changes: 6 additions & 8 deletions tasks/Functions-consumer/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ task("functions-request", "Initiates an on-demand request from a Functions consu
}

// Estimate the cost of the request fulfillment
const { gasPrice } = await hre.ethers.provider.getFeeData()
const gasPriceWei = BigInt(Math.ceil(hre.ethers.utils.formatUnits(gasPrice, "wei").toString()))

// I am using a hardcoded gas price instead of the one suggested by Ethers here
//const { gasPrice } = await hre.ethers.provider.getFeeData()
//const gasPriceWei = BigInt(Math.ceil(hre.ethers.utils.formatUnits(gasPrice, "wei").toString()))
const estimatedCostJuels = await subManager.estimateFunctionsRequestCost({
donId,
subscriptionId,
callbackGasLimit,
gasPriceWei,
gasPriceWei: BigInt(networks[network.name].gasPrice),
})

// Ensure that the subscription has a sufficient balance
Expand Down Expand Up @@ -201,11 +203,7 @@ task("functions-request", "Initiates an on-demand request from a Functions consu
)
const requestTxReceipt = await requestTx.wait(1)
if (network.name !== "localFunctionsTestnet") {
spinner.info(
`Transaction confirmed, see ${
utils.getEtherscanURL(network.config.chainId) + "tx/" + requestTx.hash
} for more details.`
)
spinner.info(`Transaction confirmed: ${requestTx.hash}`)
}

// Listen for fulfillment
Expand Down
1 change: 1 addition & 0 deletions tasks/utils/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const BASE_URLS = {
42161: "https://arbiscan.io/",
84532: "https://sepolia.basescan.org/",
11155420: "https://sepolia-optimistic.etherscan.io/",
1337: "https://chain-alpha-blockscout.shib.sandbox.enterprise.chain.link/api",
}

/**
Expand Down
Loading