forked from smartcontractkit/functions-hardhat-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Functions-request-config.js
48 lines (42 loc) · 1.69 KB
/
Functions-request-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const fs = require("fs")
// Loads environment variables from .env.enc file (if it exists)
require("@chainlink/env-enc").config()
const Location = {
Inline: 0,
Remote: 1,
}
const CodeLanguage = {
JavaScript: 0,
}
const ReturnType = {
uint: "uint256",
uint256: "uint256",
int: "int256",
int256: "int256",
string: "string",
bytes: "Buffer",
Buffer: "Buffer",
}
// Configure the request by setting the fields below
const requestConfig = {
// Location of source code (only Inline is currently supported)
codeLocation: Location.Inline,
// Code language (only JavaScript is currently supported)
codeLanguage: CodeLanguage.JavaScript,
// String containing the source code to be executed
source: fs.readFileSync("./calculation-example.js").toString(),
//source: fs.readFileSync('./API-request-example.js').toString(),
// 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 ?? "" },
// Per-node secrets objects assigned to each DON member. When using per-node secrets, nodes can only use secrets which they have been assigned.
perNodeSecrets: [],
// ETH wallet key used to sign secrets so they cannot be accessed by a 3rd party
walletPrivateKey: process.env["PRIVATE_KEY"],
// 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"],
// Expected type of the returned value
expectedReturnType: ReturnType.uint256,
// Redundant URLs which point to encrypted off-chain secrets
secretsURLs: [],
}
module.exports = requestConfig