forked from smartcontractkit/functions-hardhat-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions-request-config.js
52 lines (46 loc) · 1.77 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
49
50
51
52
const fs = require("fs")
// Loads environment variables from .env file (if it exists)
require("dotenv").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,
// location of secrets (Inline or Remote)
secretsLocation: 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)
secrets: { apiKey: process.env.COINMARKETCAP_API_KEY },
// 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: [],
// Default offchain secrets object used by the `functions-build-offchain-secrets` command
globalOffchainSecrets: {},
// Per-node offchain secrets objects used by the `functions-build-offchain-secrets` command
perNodeOffchainSecrets: [],
}
module.exports = requestConfig