From 1164b15b9ce06cc623eb4ddcb777f54d5d5607d3 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Fri, 8 Sep 2023 18:55:12 +0200 Subject: [PATCH 1/2] add doc generator --- docs/.nojekyll | 1 + docs/README.md | 620 +++++++++++++++++++ docs/classes/ResponseListener.md | 103 ++++ docs/classes/SecretsManager.md | 394 ++++++++++++ docs/classes/SubscriptionManager.md | 350 +++++++++++ docs/enums/CodeLanguage.md | 19 + docs/enums/FulfillmentCode.md | 85 +++ docs/enums/Location.md | 41 ++ docs/enums/ReturnType.md | 74 +++ docs/interfaces/RequestEventData.md | 118 ++++ docs/interfaces/SimulationInput.md | 140 +++++ docs/modules.md | 891 ++++++++++++++++++++++++++++ package-lock.json | 161 ++++- package.json | 5 +- src/types.ts | 2 +- tsconfig.json | 4 + 16 files changed, 3001 insertions(+), 7 deletions(-) create mode 100644 docs/.nojekyll create mode 100644 docs/README.md create mode 100644 docs/classes/ResponseListener.md create mode 100644 docs/classes/SecretsManager.md create mode 100644 docs/classes/SubscriptionManager.md create mode 100644 docs/enums/CodeLanguage.md create mode 100644 docs/enums/FulfillmentCode.md create mode 100644 docs/enums/Location.md create mode 100644 docs/enums/ReturnType.md create mode 100644 docs/interfaces/RequestEventData.md create mode 100644 docs/interfaces/SimulationInput.md create mode 100644 docs/modules.md diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e2ac661 --- /dev/null +++ b/docs/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..b9caa3c --- /dev/null +++ b/docs/README.md @@ -0,0 +1,620 @@ +@chainlink/functions-toolkit / [Exports](modules.md) + +# functions-toolkit + +An NPM package with collections of JavaScript functions that can be used for working with [Chainlink Functions](https://chain.link/functions). + +Up-to-date documentation on Chainlink Functions can be found [here](https://docs.chain.link/chainlink-functions). + +> :warning: Chainlink Functions requires signing a terms of service agreement before creating a billing subscription. See this [getting started](https://docs.chain.link/chainlink-functions/getting-started) section in the docs. + +# How to use this package + +The following classes expose functionality one would expect from their name. + +- [Subscription Manager](#functions-billing-subscription-management) +- [Secrets Manager](#functions-secrets-manager) + +The following utilities are exposed by this package. + +- [Simulate code execution on your local machine](#local-functions-simulator) (local simulation of your custom JS source code execution) + +## Functions Billing Subscription Management + +The `SubscriptionManager` class is used to manage the Chainlink billing [subscription](https://docs.chain.link/chainlink-functions/resources/concepts#subscriptions) used to pay for Functions requests. + +The typical subscriptions-related operations are + +- [How to use this package](#how-to-use-this-package) + - [Functions Billing Subscription Management](#functions-billing-subscription-management) + - [Subscription Initialization](#subscription-initialization) + - [Create Subscription](#create-subscription) + - [Fund Subscription](#fund-subscription) + - [Adding/Removing Authorized Consumer Contracts](#addingremoving-authorized-consumer-contracts) + - [Cancelling Subscriptions](#cancelling-subscriptions) + - [Transferring and Accepting Transfers of Subscriptions](#transferring-and-accepting-transfers-of-subscriptions) + - [Get subscription details](#get-subscription-details) + - [Timing out requests](#timing-out-requests) + - [Estimating request costs](#estimating-request-costs) + - [Adding transaction options](#adding-transaction-options) + - [Functions Secrets Manager](#functions-secrets-manager) + - [Initialize a SecretsManager instance](#initialize-a-secretsmanager-instance) + - [Fetch public keys](#fetch-public-keys) + - [Encrypting Secrets](#encrypting-secrets) + - [DON Hosted Secrets](#don-hosted-secrets) + - [Off-chain Hosted Secrets](#off-chain-hosted-secrets) + - [Functions Response Listener](#functions-response-listener) + - [Functions Utilities](#functions-utilities) + - [Local Functions Simulator](#local-functions-simulator) + - [Decoding Response Bytes](#decoding-response-bytes) + - [Storing Encrypted Secrets in Gists](#storing-encrypted-secrets-in-gists) + - [Building Functions Request CBOR Bytes](#building-functions-request-cbor-bytes) + +### Subscription Initialization + +To create a Subscription Manager you need an object with 3 inputs. + +1. an instance of the [Ethers.js Signer class](https://docs.ethers.org/v5/api/signer/#Signer). Ensure you have a [Provider](https://docs.ethers.org/v5/api/providers/) connected so you can communicate with the blockchain through your endpoint provider. You can use Infura or Alchemy or any other similar provider that provides access to [blockchains that Chainlink Functions supports](<(https://docs.chain.link/chainlink-functions/supported-networks)>). +2. You need the contract address for the LINK token used to fund subscriptions. Get that for the matching blockchain network [here](https://docs.chain.link/resources/link-token-contracts). +3. The contract address for the Functions Router smart contract. Get that [here](<(https://docs.chain.link/chainlink-functions/supported-networks)>). + +Then create an instance of the Subscription Manager by passing those 3 inputs in as follows: + +> const subscriptionManager = new SubscriptionManager({ +> signer: [Signer](https://docs.ethers.org/v5/api/signer/#Signer), +> [linkTokenAddress](https://docs.chain.link/resources/link-token-contracts): string +> [functionsRouterAddress](https://docs.chain.link/chainlink-functions/supported-networks): string +> }) + +After the class is instantiated, it must be initialized before it can be used. This is done by running the `initialize` async function as shown below: + +``` +await subscriptionManager.initialize() +``` + +### Create Subscription + +`createSubscription()` creates a new Functions billing subscription using the Functions Router contract and returns a promise which resolves to the subscription ID of type `number`. Optionally, a consumer contract address can also be passed to create a subscription and add an authorized consumer in a single transaction. + +``` +const subscriptionId = await subscriptionManager.createSubscription({ + consumerAddress?: string +}) +``` + +It is a good idea to make a note of your subscription ID as you will put funds in it. You'll also pass your subscription ID as an input for many operations when you're using Chainlink Functions. + +### Fund Subscription + +Adds LINK token to your subscription. You must have LINK balance sitting in your subscription in order to fund the gas used by the response transaction, and also to fund the decentralized computation/execution of your custom code that will be performed by the Chainlink Decentralized Oracle Network. + +To fund the subscription with LINK, ensure the wallet that you have connected to your Provider has LINK. You can get some testnet LINK from the [faucet](https://faucets.chain.link). + +Note that all values are denominated in [Juels](https://docs.chain.link/resources/link-token-contracts). 1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK. Do not use the JavaScript `number` type for calculations with Juels as the maximum safe JavaScript integer is only `2^54 - 1`. + +``` +const juelsAmount: BigInt | string = BigInt(2) * BigInt(10**18) +await subscriptionManager.fundSubscription({ + subscriptionId, + juelsAmount, +}) +``` + +`fundSubscription()` returns a promise which resolves to an EthersJS [TransactionReceipt](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt) + +### Adding/Removing Authorized Consumer Contracts + +A Functions Consumer smart contract is where you will trigger your Functions execution request to the Chainlink Oracle Network. This is also where the Oracle Network will return the results of your decentralized computation. A visualization of this request/response flow is below. + +![Request/Response Flow](https://docs.chain.link/images/chainlink-functions/requestAndReceive.png) +([source](<(https://docs.chain.link/chainlink-functions/resources/architecture)>)) + +Each subscription can hold a limited number of authorized Functions Consumers. Refer to the [service limits](https://docs.chain.link/chainlink-functions/resources/service-limits) to view the maximum number of consumer contracts per subscription. These are the consumer contracts that are authorized to use your subscription's LINK balance to fund the Oracle Network's compute tasks on your custom code. + +``` +const addConsumerTxReceipt = await subscriptionManager.addConsumer({ + subscriptionId, + consumerAddress, +}) +``` + +Similarly you can remove an authorized consumer contract with: + +``` +const removeConsumerTxReceipt = await subscriptionManager.removeConsumer({ + subscriptionId, + consumerAddress, +}) +``` + +Both `addConsumer()` and `removeConsumer()` return a promise which resolves to an EthersJS [TransactionReceipt](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt). + +### Cancelling Subscriptions + +Unless there is an expired pending request, you can cancel subscriptions with: + +``` +const cancelSubTxReceipt = await subscriptionManager.cancelSubscription({ subscriptionId }) +``` + +`cancelSubscription()` takes a config object that has the following type definition. You'll note that you can specify a wallet address to which the subscription's LINK balance will be refunded. If unspecified, it will default to the subscription owner's address. + +``` +type SubCancelConfig = { + subscriptionId: BigInt | number | string + refundAddress?: string + txOptions?: TransactionOptions +} +``` + +If there are any pending requests, you must first "time out" that pending request using the [timeoutRequest() function](#timing-out-requests) before cancelling the subscription. + +### Transferring and Accepting Transfers of Subscriptions + +Transferring subscriptions is a two-stage process. The subscription owner proposes the transfer with `requestSubscriptionTransfer()` and it is recorded on chain, but the ownership does not transfer until the transferee accepts by calling `acceptTransfer()`. + +``` +const transferTxReceipt = await subscriptionManager.requestSubscriptionTransfer({ + subscriptionId, + newOwner, // transferee wallet address +}) +``` + +To accept the ownership transfer, the transferee will need to have their own `SubscriptionManager` instance which is connected to the wallet address denoted by `newOwner` in the code snippet above. Then the transferee runs: + +``` +const acceptTransferTxReceipt = await transfereeSubManager.acceptSubTransfer({ subscriptionId }) +``` + +### Get subscription details + +You can request details for a given subscription (on the network on which it has been created) using + +``` +const subscriptionInfo = await getSubscriptionInfo(subscriptionId) +``` + +This is a read-only interaction with the blockchain. + +The returned promise - the variable `subscriptionInfo` in this example - resolves to a value of type `SubscriptionInfo` and has the following structure: + +``` +type SubscriptionInfo = { + balance: BigInt // Represented in Juels (1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK) + owner: string // Subscription owner's address + blockedBalance: BigInt // Balance reserved to pay for in-flight requests represented in Juels + proposedOwner: string // Address used for transferring subscriptions + consumers: string[] // Addresses of consumer contracts allowed to use the subscription + flags: string // Indicates resource limits for a given subscription (If the default limits are not enough for your use case, contact the Chainlink team by emailing support@chain.link to inquire about a potential increase.) +} +``` + +### Timing out requests + +In certain (rare) circumstances pending requests (requests that have not been fulfilled) will be expired and you may need to manually time those requests out. This is because when a request is "in-flight", your LINK tokens that pay for that computation get locked up for the duration of the request's lifecycle. Calling `timeoutRequest()` unlocks those funds and effectively 'cancels' that pending request. + +You can timeout more than one request in a single transaction. + +``` +const timeoutReceipt: TransactionReceipt | void = await timeoutRequests(timeoutReqConfig) +``` + +The `timeoutReqConfig` referred to above has the following shape: + +``` +{ + requestCommitments: RequestCommitment[] + txOptions?: TransactionOptions +} +``` + +The `RequestCommitment` type refers to the data for the in-flight requests. Note that when timing out a request, all this data must exactly match the request commitment that was emitted on-chain by the `OracleRequest` event when the request was initiated. + +``` +type RequestCommitment = { + requestId: string + coordinator: string + estimatedTotalCostJuels: BigInt + client: string + subscriptionId: number + callbackGasLimit: BigInt + adminFee: BigInt + donFee: BigInt + gasOverheadBeforeCallback: BigInt + gasOverheadAfterCallback: BigInt + timeoutTimestamp: BigInt +} +``` + +### Estimating request costs + +The SubscriptionManager class's `estimateFunctionsRequestCost` method can be used to estimate the cost of a Functions request. + +``` +const estimatedCostInJuels: BigInt = await subscriptionManager.estimateFunctionsRequestCost({ + donId, // ID of the DON to which the Functions request will be sent + subscriptionId, // Subscription ID + callbackGasLimit, // Total gas used by the consumer contract's callback + gasPriceGwei, // Gas price in gWei +}) +``` + +This method will return a promise which resolves to a `BigInt` with the estimated request cost in Juels (1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK). + +### Adding transaction options + +The SubscriptionManager class's exposed methods can take an optional `TransactionOptions` object that has the following shape. + +``` +export type TransactionOptions = { + overrides?: Overrides + confirmations?: number +} +``` + +Overrides are defined by EthersJS for [read-only calls](https://docs.ethers.org/v5/api/contract/contract/#Contract-functionsCall) and for [write transactions](https://docs.ethers.org/v5/api/contract/contract/#Contract--write). `confirmations` refers to the number of block confirmations to wait before proceeding. + +## Functions Secrets Manager + +This class helps you encrypt and manage the secrets that your Functions source code needs. These would be data you ordinarily put in your environment variables - such as API keys and auth related passwords etc. + +Functions secrets utilize threshold public key cryptography, requiring multiple nodes to participate in a decentralized decryption process such that no single node can decrypt secrets singlehandedly. + +Encrypted secrets are never stored directly on the blockchain, but instead can be either hosted by the DON or stored in a JSON file located at one or more URLs. Then, they are referenced in an on-chain request where they are fetched by the DON. + +### Initialize a SecretsManager instance + +To create a Secrets Manager you need an object with 3 inputs. + +1. An instance of the [Ethers.js Signer class](https://docs.ethers.org/v5/api/signer/#Signer). Ensure you have a [Provider](https://docs.ethers.org/v5/api/providers/) connected so you can communicate with the blockchain through your endpoint provider. You can use Infura or Alchemy or any other similar provider that provides access to [blockchains that Chainlink Functions supports](<(https://docs.chain.link/chainlink-functions/supported-networks)>). +2. The contract address for the Functions Router smart contract. Get that [here](<(https://docs.chain.link/chainlink-functions/supported-networks)>). +3. The `donId` string to reference the DON you would like to use which can also be found at the previous link. + +> const secretsManager = new SecretsManager({ +> signer: [Signer](https://docs.ethers.org/v5/api/signer/#Signer), +> [functionsRouterAddress](https://docs.chain.link/chainlink-functions/supported-networks): string +> [donId](https://docs.chain.link/chainlink-functions/supported-networks): string +> }) + +After the class is instantiated, it must be initialized before it can be used. This is done by running the `initialize()` async method. + +``` +await secretsManager.initialize() +``` + +### Fetch public keys + +You can fetch the public keys by querying the [Functions Coordinator contract](https://docs.chain.link/chainlink-functions/resources/architecture). + +In most cases you will not need to call this method directly. The other methods in `SecretsManager` will automatically use this method. + +``` +const keys = await secretsManager.fetchKeys() +``` + +`fetchKeys()` returns a promise that resolves to an object with the following properties: + +``` +{ + thresholdPublicKey: ThresholdPublicKey + donPublicKey: string +} +``` + +The threshold public key is an added layer of cryptographic protection for the security of your API secrets. Your secrets get encrypted twice - first with the `donPublicKey` and then with the `thresholdPublicKey`. + +Encrypting with the `thresholdPublicKey` requires nodes to collaborate in order to decrypt secrets. This is because secrets cannot be decrypted with a single key; instead, each DON node has a decryption key shard, and multiple nodes must come together in a decentralized process to decrypt the secrets. This improves security since no single DON node can decrypt secrets without collaborating with other DON nodes. + +### Encrypting Secrets + +Secrets are encrypted by passing them in an object to the `encryptSecrets()` method. + +Here are some important conditions you must satisfy when configuring your secrets for Chainlink Functions. + +1. Secrets are optional. You do not need to configure secrets if your custom Functions source code does not need to access any secrets that get passed in at runtime. +2. Your secrets must be passed in an object with string key/value pairs: + +``` +{ + testKey: 'testValue1', + testKey2: 'testValue2', + testKey3: 'testValue3', +} +``` + +``` +const encryptedSecrets = await secretsManager.encryptSecrets({ + testKey: 'testValue0' +}) +``` + +`encryptSecrets()` returns a promise that resolves to an object with a single property `encryptedSecrets`: + +``` +{ + encryptedSecrets: string +} +``` + +`encryptedSecrets` contains the string representation of your secrets, converted into bytes, and encrypted using the public keys. + +### DON Hosted Secrets + +Encrypted secrets can be uploaded directly to the DON via gateway URLs such that they can be used when making an on-chain request. This is accomplished by sending a signed POST request to gateway URLs which are connected to the DON. The DON then maintains a decentralized database with eventual consistency, such that the stored values will propagate to all DON nodes. To ensure redundancy, it is always recommended to send encrypted secrets storage requests to multiple gateway URLs. + +First, encrypt the secrets with [`encryptSecrets()`](#encrypting-secrets). Then, pass the `encryptedSecrets` hex string in an object to the `uploadEncryptedSecretsToDON()` method as shown below. The `storageSlotId` can be any integer value of zero or greater, however using a previously used slot ID will overwrite the existing data. After `minutesUntilExpiration`, the entry will be deleted from all DON nodes. Get the list of valid gateway URLs for each blockchain network from the [Chainlink Functions documentation](https://docs.chain.link/chainlink-functions/supported-networks). + +``` +const encryptedSecretsObj = await secretsManager.encryptSecrets({ my: 'secret' }) +const mySlotIdNumber = 0 +const myExpirationTimeInMinutes = 10 + +const { + version, // Secrets version number (corresponds to timestamp when encrypted secrets were uploaded to DON) + success, // Boolean value indicating if encrypted secrets were successfully uploaded to all nodes connected to the gateway +} = await secretsManager.uploadEncryptedSecretsToDON({ + encryptedSecretsHexstring: encryptedSecretsObj.encryptedSecrets, + gatewayUrls: [ 'https://exampleGatewayUrl1.com/gateway', 'https://exampleGatewayUrl2.com/gateway', ... ], + storageSlotId: mySlotIdNumber, + minutesUntilExpiration: myExpirationTimeInMinutes, +}) +``` + +The `uploadEncryptedSecretsToDON()` method will return a promise that resolves to an object of the type shown below. + +``` +{ + version: number, + success: boolean, +} +``` + +The `version` is a number which represents the version of the uploaded encrypted secrets; it is the POSIX time at which the `uploadEncryptedSecretsToDON()` method was initiated. This will be used when making a Functions request to ensure the latest version of the encrypted secrets are used. If the upload was unsuccessful for one or more nodes, a warning message will be printed and the `success` field will be `false`. If the upload was unsuccessful for all nodes, the method will throw an error. + +``` +const secretsEntriesForGateway = await secretsManager.listDONHostedEncryptedSecrets([ 'https://exampleGatewayUrl1.com/gateway', 'https://exampleGatewayUrl2.com/gateway', ... ]) +``` + +`listDONHostedEncryptedSecrets()` will return an array with following shape or throw an error. If the method successfully returns, but the `error` field of the returned object is populated, it indicates that the request to list secrets was successful, but there is a discrepancy between the node responses. + +``` +{ + result: [ + { + gatewayUrl: 'https://examplegatewayurl.com/gateway', + nodeResponses: [ + { + success: true, + rows: [ + { + slot_id: 0, + version: 0, + expiration: 100_000, + }, + ... + ], + }, + ... + ], + }, + ... + ], + error: 'Possible error message ' +} +``` + +`buildDONHostedEncryptedSecretsReference()` can be used to construct the hex string which represents the `encryptedSecretsReference` bytes used to reference the DON hosted encrypted secrets when making an on-chain Functions request. To use DON hosted encrypted secrets in an on-chain request, also ensure that `secretsLocation` is set to `Location.DONHosted` (ie: `2`). + +``` +const encryptedSecretsReference: string = buildDONHostedEncryptedSecretsReference({ + slotId: number, + version: number +}) +``` + +### Off-chain Hosted Secrets + +Encrypted secrets can also be stored off-chain in JSON file instead of being hosted on the DON, enabling more direct control over how the encrypted secrets data is stored. The DON nodes fetch this file from one or more URLs. + +First encrypt the secrets with [`encryptSecrets()`](#encrypting-secrets) and then paste or upload the resulting object into a private Github Gist, cloud storage bucket or or any other location such that the encrypted secrets JSON object can be fetched by the DON via URL. These secrets are encrypted so even if they're public, your secrets are not visible. + +You can also use the [gist uploader utility function](#storing-encrypted-secrets-in-gists) to upload the encrypted secrets string to a JSON file in a Github Gist. + +However you'd need to pass the URLs to your Functions Consumer contract so that the DON can retrieve the secrets. + +**Note:** ⚠️ As an additional layer of security, the URLs must also encrypted with the DON Public key before being included in an on-chain transaction. This is to prevent directly exposing the URL to anyone except DON members. You can build the encrypted URLs with: + +> const encryptedURLs: string = await encryptSecretsUrls(secretsUrls: string[]) + +The argument `secretsUrls` is an array of URLs and `encryptSecretsUrls()` returns the URLs as an encrypted, space-separated string of all the URLs you supply in the array. + +## Functions Response Listener + +The `ResponseListener` class provides an easy way to listen for on-chain responses to Functions requests. + +To create a Request Listener you need an object with 2 inputs. + +1. An instance of an [Ethers.js provider](https://docs.ethers.org/v5/api/providers/). You can use Infura or Alchemy or any other similar provider that provides access to [blockchains that Chainlink Functions supports](<(https://docs.chain.link/chainlink-functions/supported-networks)>). +2. The contract address for the Functions Router smart contract. Get that [here](<(https://docs.chain.link/chainlink-functions/supported-networks)>). + +> const responseListener = new ResponseListener({ +> provider: [Provider](https://docs.ethers.org/v5/api/providers/), +> [functionsRouterAddress](https://docs.chain.link/chainlink-functions/supported-networks): string, +> }) + +To listen for the response to a single Functions request by request ID, use the the `listenForResponse()` method. Optionally, you can provide a custom timeout after which the listener will throw an error indicating that the time limit was exceeded. If no timeout is provided, the default timeout is 300 seconds. + +**Note:** Listening for multiple responses simultaneously is not supported by the `listenForResponse()` method and will lead to undefined behavior. + +``` +const response: FunctionsResponse = await responseListener.listenForResponse( + requestId: string, + timeout?: number, +) +``` + +The `FunctionsResponse` will have the following shape. + +``` +{ + requestId: string // Request ID of the fulfilled request represented as a bytes32 hex string + subscriptionId: number // Subscription ID billed for request + totalCostInJuels: BigInt // Actual cost of request in Juels (1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK) + responseBytesHexstring: string // Response bytes sent to client contract represented as a hex string + errorString: string // Error bytes sent to client contract represented as a hex string + returnDataBytesHexstring: string // Data returned by consumer contract's handleOracleFulfillment method represented as a hex string + fulfillmentCode: FulfillmentCode // Indicates whether the request was fulfilled successfully or not +} +``` + +The possible fulfillment codes are shown below. + +``` +{ + FULFILLED = 0, // Indicates that calling the consumer contract's handleOracleFulfill method was successful + USER_CALLBACK_ERROR = 1, // Indicates that the consumer contract's handleOracleFulfill method reverted + INVALID_REQUEST_ID = 2, // Internal error + COST_EXCEEDS_COMMITMENT = 3, // Indicates that the request was not fulfilled because the cost of fulfillment is higher than the estimated cost due to an increase in gas prices + INSUFFICIENT_GAS_PROVIDED = 4, // Internal error + SUBSCRIPTION_BALANCE_INVARIANT_VIOLATION, // Internal error + INVALID_COMMITMENT = 6, // Internal error +} +``` + +To listen for multiple Functions responses for a given subscription ID, use the `listenForResponses()` method. This method is particularly useful when Chainlink Automation is being used to trigger the sending of Functions requests. `listenForResponses()` takes the subscription ID and a callback as arguments. The callback will be given a `FunctionsResponse` as an argument. + +**Note:** To avoid undefined behavior, ensure only one listener method is running at a time. + +``` +const callback = (response: FunctionsResponse) => { console.log(response) } +responseListener.listenForResponses( + subscriptionId: number, + callback, +) +``` + +When done listener for responses, use the `stopListeningForResponses` method to stop the listener. + +``` +responseListener.stopListeningForResponses() +``` + +## Functions Utilities + +### Local Functions Simulator + +> The local Functions JavaScript simulator requires Deno to be installed on your machine be and accessible via the PATH environment variable (ie: the `deno --version` command must work). +> Visit [deno.land/#installation](https://deno.land/#installation) for installation instructions. + +The `simulateScript` function is used to simulate the execution of your custom Functions JavaScript source code on your development machine. This means you can use the simulator during development to test your JavaScript code, and you can also run the simulator before you execute an on on-chain transaction that triggers a Functions request on a live network to verify your returns the expected value. This is useful for debugging especially since the `simulateScript` function returns captured terminal output which contains any console log messages or errors. + +`simulateScript` takes an object as an argument with the following parameters shown below. Arguments that can be accessed within the source via the global variable `args` or `bytesArgs` which is are injected into the runtime. You can also add API keys and other secrets using the `secrets` object that gets injected as a global variable in the runtime. + +``` +const result = await simulateScript({ + source: string // JavaScript source code + args?: string[] // Array of string arguments accessible from the source code via the global variable `args` + bytesArgs?: string[] // Array of bytes arguments, represented as hex strings, accessible from the source code via the global variable `bytesArgs` + secrets?: Record // Secret values represented as key-value pairs + maxOnChainResponseBytes?: number // Maximum size of the returned value in bytes (defaults to 256) + maxExecutionTimeMs?: number // Maximum execution duration (defaults to 10_000ms) + maxMemoryUsageMb?: number // Maximum RAM usage (defaults to 128mb) + numAllowedQueries?: number // Maximum number of HTTP requests (defaults to 5) + maxQueryDurationMs?: number // Maximum duration of each HTTP request (defaults to 9_000ms) + maxQueryUrlLength?: number // Maximum HTTP request URL length (defaults to 2048) + maxQueryRequestBytes?: number // Maximum size of outgoing HTTP request payload (defaults to 2048 == 2 KB) + maxQueryResponseBytes?: number // Maximum size of incoming HTTP response payload (defaults to 2_097_152 == 2 MB) +}) +``` + +`simulateScript` returns a promise which resolves to an object as shown below. + +``` +{ + responseBytesHexstring?: string // Response bytes which would be returned on-chain, represented as a hex string + errorString?: string // Error message that would be returned on-chain (either errorString or responseBytesHexstring will be defined) + capturedTerminalOutput: string // stdout or stderr terminal output captured during simulated execution +} +``` + +**_NOTE:_** The `simulateScript` function is a debugging tool and hence is not a perfect representation of the actual Chainlink oracle execution environment. Therefore, it is important to make a Functions request on a supported testnet blockchain before mainnet usage. + +### Decoding Response Bytes + +On-chain responses are encoded as Solidity `bytes` which are most frequently displayed as hex strings. However, these hex strings often need to be decoded into a useable type. In order to decode hex strings into human-readable values, this package provides the `decodeResult` function. Currently, the `decodeResult` function supports decoding hex strings into `uint256`, `int256` or `string` values. + +``` +const result: BigInt | string = decodeResult( + resultHexString: string, + expectedReturnType: ReturnType // 'uint256' | 'int256' | 'string' +) +``` + +Possible return values are also available in the `ReturnType` enum shown below. + +``` +export enum ReturnType { + uint = 'uint256', + uint256 = 'uint256', + int = 'int256', + int256 = 'int256', + string = 'string', + bytes = 'bytes', +} +``` + +### Storing Encrypted Secrets in Gists + +When describing the use of [off-chain secrets](#off-chain-hosted-secrets), we had described the storing of encrypted secrets off-chain, on hosted sites or storage repositories. For example we can store secrets in a private gist. + +Encrypted default secrets (DON-level secrets) would look something like this: + +``` +{ + "encryptedSecrets": '0x1234567890abcdefg', // some long hex string +} +``` + +This Functions Package includes utilities to upload the encrypted secrets to a private Github gist and to delete a gist as well. + +To use this utility with Github gist you need to create a [Github Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). + +You can upload encrypted secrets to a private Github gist with + +``` +const encryptedSecrets = await secretsManager.encryptSecrets({ + mySecret: 'secretValue' +}) + +const gistURL = await createGist(githubApiToken: string, JSON.stringify(encryptedSecrets)) // encryptedSecrets must be a string, not an object. +``` + +The `gistURL` itself must then be encrypted by calling [encryptSecretsUrls()](#off-chain-hosted-secrets). + +You can delete gists (if you need to clean them up, for example) with + +``` +const success: boolean = await deleteGist(githubApiToken: string, gistURL: string) +``` + +This function will return a promise which resolves to `true` if deletion is successful, else it will throw an error. + +### Building Functions Request CBOR Bytes + +Instead of performing the [CBOR encoding for a Functions request on-chain](https://docs.chain.link/chainlink-functions/api-reference/functions#encodecbor) in your Functions consumer contract, it is also possible to generate the CBOR encoding off-chain in order to save gas. Then, the resulting encoded CBOR bytes can be used when making an on-chain request. You can either store the encoded request in a `bytes` storage variable within your consumer contract, or initiate the Functions request by passing the CBOR-encoded request object `bytes` direclty into the `_sendRequest()` method which [is inherited from `FunctionsClient.sol`](https://docs.chain.link/chainlink-functions/api-reference/functions-client) . + +Note that when encoding a request off-chain, `args` or `bytesArgs` cannot be added to the request on-chain. This is a limitation of CBOR encoding due to its immutable structure. + +To build the CBOR encoded Functions request bytes off-chain, use the `buildRequestCBOR()` function as shown below + +``` +const functionsRequestBytesHexString: string = buildRequestCBOR({ + codeLocation: number // Must be 0 for inline source code. No other values are supported at this time. + secretsLocation?: number // Must be 1 for Remote or 2 for DONHosted secrets. No other values are supported at this time. + codeLanguage: number // Must be 0 for JavaScript. No other values are supported at this time. + source: string // JavaScript source code + encryptedSecretsReference?: string // Hex string representing an encrypted secrets URLs or DON hosted encrypted secrets reference + args?: string[] // Array of string arguments + bytesArgs?: string[] // Array of bytes arguments, represented as hex strings +}) +``` diff --git a/docs/classes/ResponseListener.md b/docs/classes/ResponseListener.md new file mode 100644 index 0000000..29c5536 --- /dev/null +++ b/docs/classes/ResponseListener.md @@ -0,0 +1,103 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / ResponseListener + +# Class: ResponseListener + +## Table of contents + +### Constructors + +- [constructor](ResponseListener.md#constructor) + +### Properties + +- [functionsRouter](ResponseListener.md#functionsrouter) + +### Methods + +- [listenForResponse](ResponseListener.md#listenforresponse) +- [listenForResponses](ResponseListener.md#listenforresponses) +- [stopListeningForResponses](ResponseListener.md#stoplisteningforresponses) + +## Constructors + +### constructor + +• **new ResponseListener**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | `Object` | +| › `functionsRouterAddress` | `string` | +| › `provider` | `Provider` | + +#### Defined in + +[ResponseListener.ts:12](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L12) + +## Properties + +### functionsRouter + +• `Private` **functionsRouter**: `Contract` + +#### Defined in + +[ResponseListener.ts:10](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L10) + +## Methods + +### listenForResponse + +▸ **listenForResponse**(`requestId`, `timeout?`): `Promise`<[`FunctionsResponse`](../modules.md#functionsresponse)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `requestId` | `string` | `undefined` | +| `timeout` | `number` | `300000` | + +#### Returns + +`Promise`<[`FunctionsResponse`](../modules.md#functionsresponse)\> + +#### Defined in + +[ResponseListener.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L22) + +___ + +### listenForResponses + +▸ **listenForResponses**(`subscriptionId`, `callback`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `subscriptionId` | `number` | +| `callback` | (`functionsResponse`: [`FunctionsResponse`](../modules.md#functionsresponse)) => `any` | + +#### Returns + +`void` + +#### Defined in + +[ResponseListener.ts:61](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L61) + +___ + +### stopListeningForResponses + +▸ **stopListeningForResponses**(): `void` + +#### Returns + +`void` + +#### Defined in + +[ResponseListener.ts:96](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L96) diff --git a/docs/classes/SecretsManager.md b/docs/classes/SecretsManager.md new file mode 100644 index 0000000..2b47671 --- /dev/null +++ b/docs/classes/SecretsManager.md @@ -0,0 +1,394 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / SecretsManager + +# Class: SecretsManager + +## Table of contents + +### Constructors + +- [constructor](SecretsManager.md#constructor) + +### Properties + +- [donId](SecretsManager.md#donid) +- [functionsCoordinator](SecretsManager.md#functionscoordinator) +- [functionsRouter](SecretsManager.md#functionsrouter) +- [initialized](SecretsManager.md#initialized) +- [signer](SecretsManager.md#signer) + +### Methods + +- [buildDONHostedEncryptedSecretsReference](SecretsManager.md#builddonhostedencryptedsecretsreference) +- [createGatewayMessage](SecretsManager.md#creategatewaymessage) +- [createGatewayMessageBody](SecretsManager.md#creategatewaymessagebody) +- [encryptSecrets](SecretsManager.md#encryptsecrets) +- [encryptSecretsUrls](SecretsManager.md#encryptsecretsurls) +- [extractNodeResponses](SecretsManager.md#extractnoderesponses) +- [fetchKeys](SecretsManager.md#fetchkeys) +- [initialize](SecretsManager.md#initialize) +- [isInitialized](SecretsManager.md#isinitialized) +- [listDONHostedEncryptedSecrets](SecretsManager.md#listdonhostedencryptedsecrets) +- [sendMessageToGateways](SecretsManager.md#sendmessagetogateways) +- [uploadEncryptedSecretsToDON](SecretsManager.md#uploadencryptedsecretstodon) +- [validateGatewayUrls](SecretsManager.md#validategatewayurls) +- [verifyDONHostedSecrets](SecretsManager.md#verifydonhostedsecrets) +- [verifyOffchainSecrets](SecretsManager.md#verifyoffchainsecrets) + +## Constructors + +### constructor + +• **new SecretsManager**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | `Object` | +| › `donId` | `string` | +| › `functionsRouterAddress` | `string` | +| › `signer` | `Signer` | + +#### Defined in + +[SecretsManager.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L27) + +## Properties + +### donId + +• `Private` `Optional` **donId**: `string` + +#### Defined in + +[SecretsManager.ts:24](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L24) + +___ + +### functionsCoordinator + +• `Private` **functionsCoordinator**: `Contract` + +#### Defined in + +[SecretsManager.ts:23](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L23) + +___ + +### functionsRouter + +• `Private` **functionsRouter**: `Contract` + +#### Defined in + +[SecretsManager.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L22) + +___ + +### initialized + +• `Private` **initialized**: `boolean` = `false` + +#### Defined in + +[SecretsManager.ts:25](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L25) + +___ + +### signer + +• `Private` **signer**: `Signer` + +#### Defined in + +[SecretsManager.ts:21](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L21) + +## Methods + +### buildDONHostedEncryptedSecretsReference + +▸ **buildDONHostedEncryptedSecretsReference**(`«destructured»`): `string` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | `Object` | +| › `slotId` | `number` | +| › `version` | `number` | + +#### Returns + +`string` + +#### Defined in + +[SecretsManager.ts:464](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L464) + +___ + +### createGatewayMessage + +▸ `Private` **createGatewayMessage**(`«destructured»`): `Promise`<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`GatewayMessageConfig`](../modules.md#gatewaymessageconfig) | + +#### Returns + +`Promise`<`string`\> + +#### Defined in + +[SecretsManager.ts:317](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L317) + +___ + +### createGatewayMessageBody + +▸ `Private` **createGatewayMessageBody**(`«destructured»`): `Buffer` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`GatewayMessageBody`](../modules.md#gatewaymessagebody) | + +#### Returns + +`Buffer` + +#### Defined in + +[SecretsManager.ts:343](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L343) + +___ + +### encryptSecrets + +▸ **encryptSecrets**(`secrets?`): `Promise`<{ `encryptedSecrets`: `string` }\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `secrets?` | `Record`<`string`, `string`\> | + +#### Returns + +`Promise`<{ `encryptedSecrets`: `string` }\> + +#### Defined in + +[SecretsManager.ts:141](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L141) + +___ + +### encryptSecretsUrls + +▸ **encryptSecretsUrls**(`secretsUrls`): `Promise`<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `secretsUrls` | `string`[] | + +#### Returns + +`Promise`<`string`\> + +#### Defined in + +[SecretsManager.ts:92](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L92) + +___ + +### extractNodeResponses + +▸ `Private` **extractNodeResponses**(`gatewayResponse`): [`NodeResponse`](../modules.md#noderesponse)[] + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `gatewayResponse` | `AxiosResponse`<`any`, `any`\> | + +#### Returns + +[`NodeResponse`](../modules.md#noderesponse)[] + +#### Defined in + +[SecretsManager.ts:381](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L381) + +___ + +### fetchKeys + +▸ **fetchKeys**(): `Promise`<{ `donPublicKey`: `string` ; `thresholdPublicKey`: [`ThresholdPublicKey`](../modules.md#thresholdpublickey) }\> + +#### Returns + +`Promise`<{ `donPublicKey`: `string` ; `thresholdPublicKey`: [`ThresholdPublicKey`](../modules.md#thresholdpublickey) }\> + +a Promise that resolves to an object that contains the DONpublicKey and an object that maps node addresses to their public keys + +#### Defined in + +[SecretsManager.ts:76](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L76) + +___ + +### initialize + +▸ **initialize**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[SecretsManager.ts:46](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L46) + +___ + +### isInitialized + +▸ `Private` **isInitialized**(): `void` + +#### Returns + +`void` + +#### Defined in + +[SecretsManager.ts:67](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L67) + +___ + +### listDONHostedEncryptedSecrets + +▸ **listDONHostedEncryptedSecrets**(`gatewayUrls`): `Promise`<{ `error?`: `string` ; `result`: [`GatewayResponse`](../modules.md#gatewayresponse)[] }\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `gatewayUrls` | `string`[] | + +#### Returns + +`Promise`<{ `error?`: `string` ; `result`: [`GatewayResponse`](../modules.md#gatewayresponse)[] }\> + +#### Defined in + +[SecretsManager.ts:403](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L403) + +___ + +### sendMessageToGateways + +▸ `Private` **sendMessageToGateways**(`gatewayRpcMessageConfig`): `Promise`<[`GatewayResponse`](../modules.md#gatewayresponse)[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `gatewayRpcMessageConfig` | [`GatewayMessageConfig`](../modules.md#gatewaymessageconfig) | + +#### Returns + +`Promise`<[`GatewayResponse`](../modules.md#gatewayresponse)[]\> + +#### Defined in + +[SecretsManager.ts:284](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L284) + +___ + +### uploadEncryptedSecretsToDON + +▸ **uploadEncryptedSecretsToDON**(`«destructured»`): `Promise`<{ `success`: `boolean` ; `version`: `number` }\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | `Object` | +| › `encryptedSecretsHexstring` | `string` | +| › `gatewayUrls` | `string`[] | +| › `minutesUntilExpiration` | `number` | +| › `storageSlotId` | `number` | + +#### Returns + +`Promise`<{ `success`: `boolean` ; `version`: `number` }\> + +#### Defined in + +[SecretsManager.ts:186](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L186) + +___ + +### validateGatewayUrls + +▸ `Private` **validateGatewayUrls**(`gatewayUrls`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `gatewayUrls` | `string`[] | + +#### Returns + +`void` + +#### Defined in + +[SecretsManager.ts:270](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L270) + +___ + +### verifyDONHostedSecrets + +▸ `Private` **verifyDONHostedSecrets**(`gatewayResponses`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `gatewayResponses` | [`GatewayResponse`](../modules.md#gatewayresponse)[] | + +#### Returns + +`void` + +#### Defined in + +[SecretsManager.ts:423](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L423) + +___ + +### verifyOffchainSecrets + +▸ **verifyOffchainSecrets**(`secretsUrls`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `secretsUrls` | `string`[] | + +#### Returns + +`Promise`<`boolean`\> + +#### Defined in + +[SecretsManager.ts:109](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L109) diff --git a/docs/classes/SubscriptionManager.md b/docs/classes/SubscriptionManager.md new file mode 100644 index 0000000..68d35cf --- /dev/null +++ b/docs/classes/SubscriptionManager.md @@ -0,0 +1,350 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / SubscriptionManager + +# Class: SubscriptionManager + +## Table of contents + +### Constructors + +- [constructor](SubscriptionManager.md#constructor) + +### Properties + +- [functionsAllowList](SubscriptionManager.md#functionsallowlist) +- [functionsRouter](SubscriptionManager.md#functionsrouter) +- [initialized](SubscriptionManager.md#initialized) +- [linkToken](SubscriptionManager.md#linktoken) +- [signer](SubscriptionManager.md#signer) + +### Methods + +- [acceptSubTransfer](SubscriptionManager.md#acceptsubtransfer) +- [addConsumer](SubscriptionManager.md#addconsumer) +- [cancelSubscription](SubscriptionManager.md#cancelsubscription) +- [createSubscription](SubscriptionManager.md#createsubscription) +- [estimateFunctionsRequestCost](SubscriptionManager.md#estimatefunctionsrequestcost) +- [fundSubscription](SubscriptionManager.md#fundsubscription) +- [getSubscriptionInfo](SubscriptionManager.md#getsubscriptioninfo) +- [initialize](SubscriptionManager.md#initialize) +- [isAllowlisted](SubscriptionManager.md#isallowlisted) +- [isInitialized](SubscriptionManager.md#isinitialized) +- [removeConsumer](SubscriptionManager.md#removeconsumer) +- [requestSubscriptionTransfer](SubscriptionManager.md#requestsubscriptiontransfer) +- [timeoutRequests](SubscriptionManager.md#timeoutrequests) + +## Constructors + +### constructor + +• **new SubscriptionManager**(`«destructured»`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | `Object` | +| › `functionsRouterAddress` | `string` | +| › `linkTokenAddress` | `string` | +| › `signer` | `Signer` | + +#### Defined in + +[SubscriptionManager.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L32) + +## Properties + +### functionsAllowList + +• `Private` `Optional` **functionsAllowList**: `Contract` + +#### Defined in + +[SubscriptionManager.ts:29](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L29) + +___ + +### functionsRouter + +• `Private` **functionsRouter**: `Contract` + +#### Defined in + +[SubscriptionManager.ts:28](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L28) + +___ + +### initialized + +• `Private` **initialized**: `boolean` = `false` + +#### Defined in + +[SubscriptionManager.ts:30](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L30) + +___ + +### linkToken + +• `Private` **linkToken**: `Contract` + +#### Defined in + +[SubscriptionManager.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L27) + +___ + +### signer + +• `Private` **signer**: `Signer` + +#### Defined in + +[SubscriptionManager.ts:26](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L26) + +## Methods + +### acceptSubTransfer + +▸ **acceptSubTransfer**(`«destructured»`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SubTransferAcceptConfig`](../modules.md#subtransferacceptconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:414](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L414) + +___ + +### addConsumer + +▸ **addConsumer**(`«destructured»`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SubConsumerConfig`](../modules.md#subconsumerconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:136](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L136) + +___ + +### cancelSubscription + +▸ **cancelSubscription**(`«destructured»`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SubCancelConfig`](../modules.md#subcancelconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:270](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L270) + +___ + +### createSubscription + +▸ **createSubscription**(`subCreateConfig?`): `Promise`<`number`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `subCreateConfig?` | [`SubCreateConfig`](../modules.md#subcreateconfig) | + +#### Returns + +`Promise`<`number`\> + +#### Defined in + +[SubscriptionManager.ts:93](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L93) + +___ + +### estimateFunctionsRequestCost + +▸ **estimateFunctionsRequestCost**(`«destructured»`): `Promise`<`BigInt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`EstimateCostConfig`](../modules.md#estimatecostconfig) | + +#### Returns + +`Promise`<`BigInt`\> + +#### Defined in + +[SubscriptionManager.ts:471](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L471) + +___ + +### fundSubscription + +▸ **fundSubscription**(`config`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `config` | [`SubFundConfig`](../modules.md#subfundconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:188](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L188) + +___ + +### getSubscriptionInfo + +▸ **getSubscriptionInfo**(`subscriptionId`): `Promise`<[`SubscriptionInfo`](../modules.md#subscriptioninfo)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `subscriptionId` | `string` \| `number` \| `BigInt` | + +#### Returns + +`Promise`<[`SubscriptionInfo`](../modules.md#subscriptioninfo)\> + +#### Defined in + +[SubscriptionManager.ts:248](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L248) + +___ + +### initialize + +▸ **initialize**(): `Promise`<`void`\> + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[SubscriptionManager.ts:51](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L51) + +___ + +### isAllowlisted + +▸ **isAllowlisted**(`addr`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `addr` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[SubscriptionManager.ts:83](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L83) + +___ + +### isInitialized + +▸ `Private` **isInitialized**(): `void` + +#### Returns + +`void` + +#### Defined in + +[SubscriptionManager.ts:75](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L75) + +___ + +### removeConsumer + +▸ **removeConsumer**(`«destructured»`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SubConsumerConfig`](../modules.md#subconsumerconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:318](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L318) + +___ + +### requestSubscriptionTransfer + +▸ **requestSubscriptionTransfer**(`«destructured»`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SubTransferConfig`](../modules.md#subtransferconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:370](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L370) + +___ + +### timeoutRequests + +▸ **timeoutRequests**(`«destructured»`): `Promise`<`TransactionReceipt`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SubTimeoutConfig`](../modules.md#subtimeoutconfig) | + +#### Returns + +`Promise`<`TransactionReceipt`\> + +#### Defined in + +[SubscriptionManager.ts:447](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L447) diff --git a/docs/enums/CodeLanguage.md b/docs/enums/CodeLanguage.md new file mode 100644 index 0000000..b7a9ce3 --- /dev/null +++ b/docs/enums/CodeLanguage.md @@ -0,0 +1,19 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / CodeLanguage + +# Enumeration: CodeLanguage + +## Table of contents + +### Enumeration Members + +- [JavaScript](CodeLanguage.md#javascript) + +## Enumeration Members + +### JavaScript + +• **JavaScript** = ``0`` + +#### Defined in + +[types.ts:10](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L10) diff --git a/docs/enums/FulfillmentCode.md b/docs/enums/FulfillmentCode.md new file mode 100644 index 0000000..43e9e3f --- /dev/null +++ b/docs/enums/FulfillmentCode.md @@ -0,0 +1,85 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / FulfillmentCode + +# Enumeration: FulfillmentCode + +## Table of contents + +### Enumeration Members + +- [COST\_EXCEEDS\_COMMITMENT](FulfillmentCode.md#cost_exceeds_commitment) +- [FULFILLED](FulfillmentCode.md#fulfilled) +- [INSUFFICIENT\_GAS\_PROVIDED](FulfillmentCode.md#insufficient_gas_provided) +- [INVALID\_COMMITMENT](FulfillmentCode.md#invalid_commitment) +- [INVALID\_REQUEST\_ID](FulfillmentCode.md#invalid_request_id) +- [SUBSCRIPTION\_BALANCE\_INVARIANT\_VIOLATION](FulfillmentCode.md#subscription_balance_invariant_violation) +- [USER\_CALLBACK\_ERROR](FulfillmentCode.md#user_callback_error) + +## Enumeration Members + +### COST\_EXCEEDS\_COMMITMENT + +• **COST\_EXCEEDS\_COMMITMENT** = ``3`` + +#### Defined in + +[types.ts:165](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L165) + +___ + +### FULFILLED + +• **FULFILLED** = ``0`` + +#### Defined in + +[types.ts:162](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L162) + +___ + +### INSUFFICIENT\_GAS\_PROVIDED + +• **INSUFFICIENT\_GAS\_PROVIDED** = ``4`` + +#### Defined in + +[types.ts:166](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L166) + +___ + +### INVALID\_COMMITMENT + +• **INVALID\_COMMITMENT** = ``6`` + +#### Defined in + +[types.ts:168](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L168) + +___ + +### INVALID\_REQUEST\_ID + +• **INVALID\_REQUEST\_ID** = ``2`` + +#### Defined in + +[types.ts:164](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L164) + +___ + +### SUBSCRIPTION\_BALANCE\_INVARIANT\_VIOLATION + +• **SUBSCRIPTION\_BALANCE\_INVARIANT\_VIOLATION** = ``5`` + +#### Defined in + +[types.ts:167](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L167) + +___ + +### USER\_CALLBACK\_ERROR + +• **USER\_CALLBACK\_ERROR** = ``1`` + +#### Defined in + +[types.ts:163](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L163) diff --git a/docs/enums/Location.md b/docs/enums/Location.md new file mode 100644 index 0000000..a23a549 --- /dev/null +++ b/docs/enums/Location.md @@ -0,0 +1,41 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / Location + +# Enumeration: Location + +## Table of contents + +### Enumeration Members + +- [DONHosted](Location.md#donhosted) +- [Inline](Location.md#inline) +- [Remote](Location.md#remote) + +## Enumeration Members + +### DONHosted + +• **DONHosted** = ``2`` + +#### Defined in + +[types.ts:6](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L6) + +___ + +### Inline + +• **Inline** = ``0`` + +#### Defined in + +[types.ts:4](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L4) + +___ + +### Remote + +• **Remote** = ``1`` + +#### Defined in + +[types.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L5) diff --git a/docs/enums/ReturnType.md b/docs/enums/ReturnType.md new file mode 100644 index 0000000..a63d2bb --- /dev/null +++ b/docs/enums/ReturnType.md @@ -0,0 +1,74 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / ReturnType + +# Enumeration: ReturnType + +## Table of contents + +### Enumeration Members + +- [bytes](ReturnType.md#bytes) +- [int](ReturnType.md#int) +- [int256](ReturnType.md#int256) +- [string](ReturnType.md#string) +- [uint](ReturnType.md#uint) +- [uint256](ReturnType.md#uint256) + +## Enumeration Members + +### bytes + +• **bytes** = ``"bytes"`` + +#### Defined in + +[types.ts:19](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L19) + +___ + +### int + +• **int** = ``"int256"`` + +#### Defined in + +[types.ts:16](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L16) + +___ + +### int256 + +• **int256** = ``"int256"`` + +#### Defined in + +[types.ts:17](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L17) + +___ + +### string + +• **string** = ``"string"`` + +#### Defined in + +[types.ts:18](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L18) + +___ + +### uint + +• **uint** = ``"uint256"`` + +#### Defined in + +[types.ts:14](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L14) + +___ + +### uint256 + +• **uint256** = ``"uint256"`` + +#### Defined in + +[types.ts:15](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L15) diff --git a/docs/interfaces/RequestEventData.md b/docs/interfaces/RequestEventData.md new file mode 100644 index 0000000..86c0d3c --- /dev/null +++ b/docs/interfaces/RequestEventData.md @@ -0,0 +1,118 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / RequestEventData + +# Interface: RequestEventData + +## Table of contents + +### Properties + +- [callbackGasLimit](RequestEventData.md#callbackgaslimit) +- [commitment](RequestEventData.md#commitment) +- [data](RequestEventData.md#data) +- [dataVersion](RequestEventData.md#dataversion) +- [flags](RequestEventData.md#flags) +- [requestId](RequestEventData.md#requestid) +- [requestInitiator](RequestEventData.md#requestinitiator) +- [requestingContract](RequestEventData.md#requestingcontract) +- [subscriptionId](RequestEventData.md#subscriptionid) +- [subscriptionOwner](RequestEventData.md#subscriptionowner) + +## Properties + +### callbackGasLimit + +• **callbackGasLimit**: `number` + +#### Defined in + +[localFunctionsTestnet.ts:39](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L39) + +___ + +### commitment + +• **commitment**: [`RequestCommitment`](../modules.md#requestcommitment) + +#### Defined in + +[localFunctionsTestnet.ts:40](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L40) + +___ + +### data + +• **data**: `string` + +#### Defined in + +[localFunctionsTestnet.ts:36](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L36) + +___ + +### dataVersion + +• **dataVersion**: `number` + +#### Defined in + +[localFunctionsTestnet.ts:37](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L37) + +___ + +### flags + +• **flags**: `string` + +#### Defined in + +[localFunctionsTestnet.ts:38](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L38) + +___ + +### requestId + +• **requestId**: `string` + +#### Defined in + +[localFunctionsTestnet.ts:31](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L31) + +___ + +### requestInitiator + +• **requestInitiator**: `string` + +#### Defined in + +[localFunctionsTestnet.ts:33](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L33) + +___ + +### requestingContract + +• **requestingContract**: `string` + +#### Defined in + +[localFunctionsTestnet.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L32) + +___ + +### subscriptionId + +• **subscriptionId**: `any` + +#### Defined in + +[localFunctionsTestnet.ts:34](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L34) + +___ + +### subscriptionOwner + +• **subscriptionOwner**: `string` + +#### Defined in + +[localFunctionsTestnet.ts:35](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L35) diff --git a/docs/interfaces/SimulationInput.md b/docs/interfaces/SimulationInput.md new file mode 100644 index 0000000..90df9e8 --- /dev/null +++ b/docs/interfaces/SimulationInput.md @@ -0,0 +1,140 @@ +[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / SimulationInput + +# Interface: SimulationInput + +## Table of contents + +### Properties + +- [args](SimulationInput.md#args) +- [bytesArgs](SimulationInput.md#bytesargs) +- [maxExecutionTimeMs](SimulationInput.md#maxexecutiontimems) +- [maxMemoryUsageMb](SimulationInput.md#maxmemoryusagemb) +- [maxOnChainResponseBytes](SimulationInput.md#maxonchainresponsebytes) +- [maxQueryDurationMs](SimulationInput.md#maxquerydurationms) +- [maxQueryRequestBytes](SimulationInput.md#maxqueryrequestbytes) +- [maxQueryResponseBytes](SimulationInput.md#maxqueryresponsebytes) +- [maxQueryUrlLength](SimulationInput.md#maxqueryurllength) +- [numAllowedQueries](SimulationInput.md#numallowedqueries) +- [secrets](SimulationInput.md#secrets) +- [source](SimulationInput.md#source) + +## Properties + +### args + +• `Optional` **args**: `string`[] + +#### Defined in + +[types.ts:183](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L183) + +___ + +### bytesArgs + +• `Optional` **bytesArgs**: `string`[] + +#### Defined in + +[types.ts:184](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L184) + +___ + +### maxExecutionTimeMs + +• `Optional` **maxExecutionTimeMs**: `number` + +#### Defined in + +[types.ts:187](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L187) + +___ + +### maxMemoryUsageMb + +• `Optional` **maxMemoryUsageMb**: `number` + +#### Defined in + +[types.ts:188](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L188) + +___ + +### maxOnChainResponseBytes + +• `Optional` **maxOnChainResponseBytes**: `number` + +#### Defined in + +[types.ts:186](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L186) + +___ + +### maxQueryDurationMs + +• `Optional` **maxQueryDurationMs**: `number` + +#### Defined in + +[types.ts:190](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L190) + +___ + +### maxQueryRequestBytes + +• `Optional` **maxQueryRequestBytes**: `number` + +#### Defined in + +[types.ts:192](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L192) + +___ + +### maxQueryResponseBytes + +• `Optional` **maxQueryResponseBytes**: `number` + +#### Defined in + +[types.ts:193](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L193) + +___ + +### maxQueryUrlLength + +• `Optional` **maxQueryUrlLength**: `number` + +#### Defined in + +[types.ts:191](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L191) + +___ + +### numAllowedQueries + +• `Optional` **numAllowedQueries**: `number` + +#### Defined in + +[types.ts:189](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L189) + +___ + +### secrets + +• `Optional` **secrets**: `Record`<`string`, `string`\> + +#### Defined in + +[types.ts:185](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L185) + +___ + +### source + +• **source**: `string` + +#### Defined in + +[types.ts:182](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L182) diff --git a/docs/modules.md b/docs/modules.md new file mode 100644 index 0000000..657d5ac --- /dev/null +++ b/docs/modules.md @@ -0,0 +1,891 @@ +[@chainlink/functions-toolkit](README.md) / Exports + +# @chainlink/functions-toolkit + +## Table of contents + +### Enumerations + +- [CodeLanguage](enums/CodeLanguage.md) +- [FulfillmentCode](enums/FulfillmentCode.md) +- [Location](enums/Location.md) +- [ReturnType](enums/ReturnType.md) + +### Classes + +- [ResponseListener](classes/ResponseListener.md) +- [SecretsManager](classes/SecretsManager.md) +- [SubscriptionManager](classes/SubscriptionManager.md) + +### Interfaces + +- [RequestEventData](interfaces/RequestEventData.md) +- [SimulationInput](interfaces/SimulationInput.md) + +### Type Aliases + +- [DONStoragePayload](modules.md#donstoragepayload) +- [DecodedResult](modules.md#decodedresult) +- [EncryptedSecretsEntry](modules.md#encryptedsecretsentry) +- [EstimateCostConfig](modules.md#estimatecostconfig) +- [FunctionsRequestParams](modules.md#functionsrequestparams) +- [FunctionsResponse](modules.md#functionsresponse) +- [GatewayMessage](modules.md#gatewaymessage) +- [GatewayMessageBody](modules.md#gatewaymessagebody) +- [GatewayMessageConfig](modules.md#gatewaymessageconfig) +- [GatewayResponse](modules.md#gatewayresponse) +- [NodeResponse](modules.md#noderesponse) +- [RequestCommitment](modules.md#requestcommitment) +- [SimulationResult](modules.md#simulationresult) +- [SubCancelConfig](modules.md#subcancelconfig) +- [SubConsumerConfig](modules.md#subconsumerconfig) +- [SubCreateConfig](modules.md#subcreateconfig) +- [SubFundConfig](modules.md#subfundconfig) +- [SubTimeoutConfig](modules.md#subtimeoutconfig) +- [SubTransferAcceptConfig](modules.md#subtransferacceptconfig) +- [SubTransferConfig](modules.md#subtransferconfig) +- [SubscriptionInfo](modules.md#subscriptioninfo) +- [ThresholdPublicKey](modules.md#thresholdpublickey) +- [TransactionOptions](modules.md#transactionoptions) + +### Variables + +- [DEFAULT\_MAX\_EXECUTION\_DURATION\_MS](modules.md#default_max_execution_duration_ms) +- [DEFAULT\_MAX\_HTTP\_REQUESTS](modules.md#default_max_http_requests) +- [DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES](modules.md#default_max_http_request_bytes) +- [DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS](modules.md#default_max_http_request_duration_ms) +- [DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH](modules.md#default_max_http_request_url_length) +- [DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES](modules.md#default_max_http_response_bytes) +- [DEFAULT\_MAX\_MEMORY\_USAGE\_MB](modules.md#default_max_memory_usage_mb) +- [DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES](modules.md#default_max_on_chain_response_bytes) +- [callReportGasLimit](modules.md#callreportgaslimit) +- [simulatedAllowListConfig](modules.md#simulatedallowlistconfig) +- [simulatedAllowListId](modules.md#simulatedallowlistid) +- [simulatedCoordinatorConfig](modules.md#simulatedcoordinatorconfig) +- [simulatedDonId](modules.md#simulateddonid) +- [simulatedLinkEthPrice](modules.md#simulatedlinkethprice) +- [simulatedRouterConfig](modules.md#simulatedrouterconfig) +- [simulatedSecretsKeys](modules.md#simulatedsecretskeys) +- [simulatedTransmitters](modules.md#simulatedtransmitters) +- [simulatedWallets](modules.md#simulatedwallets) + +### Functions + +- [buildRequestCBOR](modules.md#buildrequestcbor) +- [createGist](modules.md#creategist) +- [decodeResult](modules.md#decoderesult) +- [deleteGist](modules.md#deletegist) +- [deployFunctionsOracle](modules.md#deployfunctionsoracle) +- [simulateScript](modules.md#simulatescript) +- [startLocalFunctionsTestnet](modules.md#startlocalfunctionstestnet) + +## Type Aliases + +### DONStoragePayload + +Ƭ **DONStoragePayload**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `expiration` | `number` | +| `payload` | `string` | +| `signature` | `string` | +| `slot_id` | `number` | +| `version` | `number` | + +#### Defined in + +[types.ts:112](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L112) + +___ + +### DecodedResult + +Ƭ **DecodedResult**: `BigInt` \| `string` + +#### Defined in + +[decodeResult.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/decodeResult.ts#L3) + +___ + +### EncryptedSecretsEntry + +Ƭ **EncryptedSecretsEntry**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `expiration` | `number` | +| `slot_id` | `number` | +| `version` | `number` | + +#### Defined in + +[types.ts:145](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L145) + +___ + +### EstimateCostConfig + +Ƭ **EstimateCostConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `callbackGasLimit` | `number` | +| `donId` | `string` | +| `gasPriceGwei` | `BigInt` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | + +#### Defined in + +[types.ts:82](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L82) + +___ + +### FunctionsRequestParams + +Ƭ **FunctionsRequestParams**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `args?` | `string`[] | +| `bytesArgs?` | `string`[] | +| `codeLanguage` | [`CodeLanguage`](enums/CodeLanguage.md) | +| `codeLocation` | [`Location`](enums/Location.md) | +| `encryptedSecretsReference?` | `string` | +| `secretsLocation?` | [`Location`](enums/Location.md) | +| `source` | `string` | + +#### Defined in + +[types.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L22) + +___ + +### FunctionsResponse + +Ƭ **FunctionsResponse**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `errorString` | `string` | +| `fulfillmentCode` | [`FulfillmentCode`](enums/FulfillmentCode.md) | +| `requestId` | `string` | +| `responseBytesHexstring` | `string` | +| `returnDataBytesHexstring` | `string` | +| `subscriptionId` | `number` | +| `totalCostInJuels` | `BigInt` | + +#### Defined in + +[types.ts:171](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L171) + +___ + +### GatewayMessage + +Ƭ **GatewayMessage**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `jsonrpc` | ``"2.0"`` | +| `method` | `string` | +| `params` | { `body`: [`GatewayMessageBody`](modules.md#gatewaymessagebody) ; `signature`: `string` } | +| `params.body` | [`GatewayMessageBody`](modules.md#gatewaymessagebody) | +| `params.signature` | `string` | + +#### Defined in + +[types.ts:135](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L135) + +___ + +### GatewayMessageBody + +Ƭ **GatewayMessageBody**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `don_id` | `string` | +| `message_id` | `string` | +| `method` | `string` | +| `payload?` | [`DONStoragePayload`](modules.md#donstoragepayload) | +| `receiver` | `string` | + +#### Defined in + +[types.ts:127](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L127) + +___ + +### GatewayMessageConfig + +Ƭ **GatewayMessageConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `don_id` | `string` | +| `gatewayUrls` | `string`[] | +| `method` | `string` | +| `payload?` | [`DONStoragePayload`](modules.md#donstoragepayload) | + +#### Defined in + +[types.ts:120](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L120) + +___ + +### GatewayResponse + +Ƭ **GatewayResponse**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `gatewayUrl` | `string` | +| `nodeResponses` | [`NodeResponse`](modules.md#noderesponse)[] | + +#### Defined in + +[types.ts:156](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L156) + +___ + +### NodeResponse + +Ƭ **NodeResponse**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `rows?` | [`EncryptedSecretsEntry`](modules.md#encryptedsecretsentry)[] | +| `success` | `boolean` | + +#### Defined in + +[types.ts:151](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L151) + +___ + +### RequestCommitment + +Ƭ **RequestCommitment**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `adminFee` | `BigInt` | +| `callbackGasLimit` | `BigInt` | +| `client` | `string` | +| `coordinator` | `string` | +| `donFee` | `BigInt` | +| `estimatedTotalCostJuels` | `BigInt` | +| `gasOverheadAfterCallback` | `BigInt` | +| `gasOverheadBeforeCallback` | `BigInt` | +| `requestId` | `string` | +| `subscriptionId` | `number` | +| `timeoutTimestamp` | `BigInt` | + +#### Defined in + +[types.ts:98](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L98) + +___ + +### SimulationResult + +Ƭ **SimulationResult**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `capturedTerminalOutput` | `string` | +| `errorString?` | `string` | +| `responseBytesHexstring?` | `string` | + +#### Defined in + +[types.ts:196](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L196) + +___ + +### SubCancelConfig + +Ƭ **SubCancelConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `refundAddress?` | `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:61](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L61) + +___ + +### SubConsumerConfig + +Ƭ **SubConsumerConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `consumerAddress` | `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:49](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L49) + +___ + +### SubCreateConfig + +Ƭ **SubCreateConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `consumerAddress?` | `string` | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:44](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L44) + +___ + +### SubFundConfig + +Ƭ **SubFundConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `juelsAmount` | `BigInt` \| `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:55](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L55) + +___ + +### SubTimeoutConfig + +Ƭ **SubTimeoutConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `requestCommitments` | [`RequestCommitment`](modules.md#requestcommitment)[] | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:77](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L77) + +___ + +### SubTransferAcceptConfig + +Ƭ **SubTransferAcceptConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:72](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L72) + +___ + +### SubTransferConfig + +Ƭ **SubTransferConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `newOwner` | `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | + +#### Defined in + +[types.ts:66](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L66) + +___ + +### SubscriptionInfo + +Ƭ **SubscriptionInfo**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `balance` | `BigInt` | +| `blockedBalance` | `BigInt` | +| `consumers` | `string`[] | +| `flags` | `string` | +| `owner` | `string` | +| `proposedOwner` | `string` | + +#### Defined in + +[types.ts:89](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L89) + +___ + +### ThresholdPublicKey + +Ƭ **ThresholdPublicKey**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `G_bar` | `string` | +| `Group` | `string` | +| `H` | `string` | +| `HArray` | `string`[] | + +#### Defined in + +[types.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L32) + +___ + +### TransactionOptions + +Ƭ **TransactionOptions**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `confirmations?` | `number` | +| `overrides?` | `Overrides` | + +#### Defined in + +[types.ts:39](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L39) + +## Variables + +### DEFAULT\_MAX\_EXECUTION\_DURATION\_MS + +• `Const` **DEFAULT\_MAX\_EXECUTION\_DURATION\_MS**: ``10000`` + +#### Defined in + +[simulationConfig.ts:84](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L84) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUESTS + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUESTS**: ``5`` + +#### Defined in + +[simulationConfig.ts:86](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L86) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES**: ``2048`` + +#### Defined in + +[simulationConfig.ts:89](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L89) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS**: ``9000`` + +#### Defined in + +[simulationConfig.ts:87](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L87) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH**: ``2048`` + +#### Defined in + +[simulationConfig.ts:88](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L88) + +___ + +### DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES + +• `Const` **DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES**: ``2097152`` + +#### Defined in + +[simulationConfig.ts:90](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L90) + +___ + +### DEFAULT\_MAX\_MEMORY\_USAGE\_MB + +• `Const` **DEFAULT\_MAX\_MEMORY\_USAGE\_MB**: ``128`` + +#### Defined in + +[simulationConfig.ts:85](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L85) + +___ + +### DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES + +• `Const` **DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES**: ``256`` + +#### Defined in + +[simulationConfig.ts:83](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L83) + +___ + +### callReportGasLimit + +• `Const` **callReportGasLimit**: ``5000000`` + +#### Defined in + +[simulationConfig.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L32) + +___ + +### simulatedAllowListConfig + +• `Const` **simulatedAllowListConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `enabled` | `boolean` | +| `signerPublicKey` | `string` | + +#### Defined in + +[simulationConfig.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L27) + +___ + +### simulatedAllowListId + +• `Const` **simulatedAllowListId**: ``"allowlist1"`` + +#### Defined in + +[simulationConfig.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L5) + +___ + +### simulatedCoordinatorConfig + +• `Const` **simulatedCoordinatorConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `donFee` | `number` | +| `fallbackNativePerUnitLink` | `bigint` | +| `feedStalenessSeconds` | `number` | +| `fulfillmentGasPriceOverEstimationBP` | `number` | +| `gasOverheadAfterCallback` | `number` | +| `gasOverheadBeforeCallback` | `number` | +| `maxCallbackGasLimit` | `number` | +| `maxSupportedRequestDataVersion` | `number` | +| `requestTimeoutSeconds` | `number` | + +#### Defined in + +[simulationConfig.ts:15](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L15) + +___ + +### simulatedDonId + +• `Const` **simulatedDonId**: ``"coordinator1"`` + +#### Defined in + +[simulationConfig.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L3) + +___ + +### simulatedLinkEthPrice + +• `Const` **simulatedLinkEthPrice**: `bigint` + +#### Defined in + +[simulationConfig.ts:1](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L1) + +___ + +### simulatedRouterConfig + +• `Const` **simulatedRouterConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `adminFee` | `number` | +| `gasForCallExactCheck` | `number` | +| `handleOracleFulfillmentSelector` | `string` | +| `maxCallbackGasLimits` | `number`[] | +| `maxConsumersPerSubscription` | `number` | + +#### Defined in + +[simulationConfig.ts:7](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L7) + +___ + +### simulatedSecretsKeys + +• `Const` **simulatedSecretsKeys**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `donKey` | { `privateKey`: `string` ; `publicKey`: `string` } | +| `donKey.privateKey` | `string` | +| `donKey.publicKey` | `string` | +| `thresholdKeys` | { `privateKeyShares`: { `[address: string]`: `string`; } ; `publicKey`: `string` } | +| `thresholdKeys.privateKeyShares` | { `[address: string]`: `string`; } | +| `thresholdKeys.publicKey` | `string` | + +#### Defined in + +[simulationConfig.ts:55](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L55) + +___ + +### simulatedTransmitters + +• `Const` **simulatedTransmitters**: `string`[] + +#### Defined in + +[simulationConfig.ts:53](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L53) + +___ + +### simulatedWallets + +• `Const` **simulatedWallets**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `node0` | { `address`: `string` = '0xAe24F6e7e046a0C764DF51F333dE5e2fE360AC72'; `privateKey`: `string` = '0x493f20c367e9c5190b14b8071a6c765da973d41428b841c25e4aaba3577f8ece' } | +| `node0.address` | `string` | +| `node0.privateKey` | `string` | +| `node1` | { `address`: `string` = '0x37d7bf16f6fd8c37b766Fa87e047c68c51dfdf4a'; `privateKey`: `string` = '0x7abd90843922984dda18358a179679e5cabda5ad8d0ebab5714ac044663a6a14' } | +| `node1.address` | `string` | +| `node1.privateKey` | `string` | +| `node2` | { `address`: `string` = '0x6e7EF53D9811B70834902D2D9137DaD2720eAC47'; `privateKey`: `string` = '0xcb8801121add786869aac78ceb4003bf3aa8a68ae8dd31f80d61f5f98eace3c5' } | +| `node2.address` | `string` | +| `node2.privateKey` | `string` | +| `node3` | { `address`: `string` = '0xBe83eA9868AE964f8C46EFa0fea798EbE16441c5'; `privateKey`: `string` = '0x06c7ca21f24edf450251e87097264b1fd184c9570084a78aa3300e937e1954b8' } | +| `node3.address` | `string` | +| `node3.privateKey` | `string` | + +#### Defined in + +[simulationConfig.ts:34](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L34) + +## Functions + +### buildRequestCBOR + +▸ **buildRequestCBOR**(`requestParams`): `string` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `requestParams` | [`FunctionsRequestParams`](modules.md#functionsrequestparams) | + +#### Returns + +`string` + +#### Defined in + +[buildRequestCBOR.ts:8](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/buildRequestCBOR.ts#L8) + +___ + +### createGist + +▸ **createGist**(`githubApiToken`, `content`): `Promise`<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `githubApiToken` | `string` | +| `content` | `string` | + +#### Returns + +`Promise`<`string`\> + +#### Defined in + +[offchain_storage/github.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/offchain_storage/github.ts#L3) + +___ + +### decodeResult + +▸ **decodeResult**(`resultHexstring`, `expectedReturnType`): [`DecodedResult`](modules.md#decodedresult) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `resultHexstring` | `string` | +| `expectedReturnType` | [`ReturnType`](enums/ReturnType.md) | + +#### Returns + +[`DecodedResult`](modules.md#decodedresult) + +#### Defined in + +[decodeResult.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/decodeResult.ts#L5) + +___ + +### deleteGist + +▸ **deleteGist**(`githubApiToken`, `gistURL`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `githubApiToken` | `string` | +| `gistURL` | `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Defined in + +[offchain_storage/github.ts:69](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/offchain_storage/github.ts#L69) + +___ + +### deployFunctionsOracle + +▸ **deployFunctionsOracle**(`deployer`): `Promise`<`FunctionsContracts`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `deployer` | `Wallet` | + +#### Returns + +`Promise`<`FunctionsContracts`\> + +#### Defined in + +[localFunctionsTestnet.ts:264](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L264) + +___ + +### simulateScript + +▸ **simulateScript**(`«destructured»`): `Promise`<[`SimulationResult`](modules.md#simulationresult)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SimulationInput`](interfaces/SimulationInput.md) | + +#### Returns + +`Promise`<[`SimulationResult`](modules.md#simulationresult)\> + +#### Defined in + +[simulateScript/simulateScript.ts:28](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulateScript/simulateScript.ts#L28) + +___ + +### startLocalFunctionsTestnet + +▸ **startLocalFunctionsTestnet**(`port?`): `Promise`<{ `adminWallet`: { `address`: `string` ; `privateKey`: `string` } ; `close`: () => `Promise`<`void`\> ; `getFunds`: (`address`: `string`, `__namedParameters`: { `ethAmount`: `number` ; `linkAmount`: `number` }) => `Promise`<`void`\> ; `server`: `Server`<`EthereumFlavor`\> } & `FunctionsContracts`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `port` | `number` | `8545` | + +#### Returns + +`Promise`<{ `adminWallet`: { `address`: `string` ; `privateKey`: `string` } ; `close`: () => `Promise`<`void`\> ; `getFunds`: (`address`: `string`, `__namedParameters`: { `ethAmount`: `number` ; `linkAmount`: `number` }) => `Promise`<`void`\> ; `server`: `Server`<`EthereumFlavor`\> } & `FunctionsContracts`\> + +#### Defined in + +[localFunctionsTestnet.ts:50](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L50) diff --git a/package-lock.json b/package-lock.json index f6294cb..da1a19e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@chainlink/functions-toolkit", - "version": "0.0.2", + "version": "0.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@chainlink/functions-toolkit", - "version": "0.0.2", + "version": "0.0.3", "license": "MIT", "dependencies": { "axios": "^1.4.0", @@ -35,6 +35,8 @@ "prettier": "^2.8.8", "rimraf": "^5.0.1", "ts-jest": "^29.1.0", + "typedoc": "^0.25.1", + "typedoc-plugin-markdown": "^3.16.0", "typescript": "^5.0.4", "webpack": "5.82.1", "webpack-cli": "5.1.1" @@ -4376,6 +4378,12 @@ "node": ">=8" } }, + "node_modules/ansi-sequence-parser": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz", + "integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==", + "dev": true + }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -8662,9 +8670,7 @@ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "extraneous": true, "os": [ - "darwin", - "linux", - "win32" + "darwin" ], "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" @@ -11057,6 +11063,27 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "node_modules/handlebars": { + "version": "4.7.8", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", + "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5", + "neo-async": "^2.6.2", + "source-map": "^0.6.1", + "wordwrap": "^1.0.0" + }, + "bin": { + "handlebars": "bin/handlebars" + }, + "engines": { + "node": ">=0.4.7" + }, + "optionalDependencies": { + "uglify-js": "^3.1.4" + } + }, "node_modules/hard-rejection": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", @@ -12583,6 +12610,12 @@ "node": ">=6" } }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -12797,6 +12830,12 @@ "yallist": "^3.0.2" } }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -12839,6 +12878,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "dev": true, + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -14480,6 +14531,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/shiki": { + "version": "0.14.4", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.4.tgz", + "integrity": "sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ==", + "dev": true, + "dependencies": { + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" + } + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -15464,6 +15527,63 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, + "node_modules/typedoc": { + "version": "0.25.1", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.25.1.tgz", + "integrity": "sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA==", + "dev": true, + "dependencies": { + "lunr": "^2.3.9", + "marked": "^4.3.0", + "minimatch": "^9.0.3", + "shiki": "^0.14.1" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 16" + }, + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x" + } + }, + "node_modules/typedoc-plugin-markdown": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.16.0.tgz", + "integrity": "sha512-eeiC78fDNGFwemPIHiwRC+mEC7W5jwt3fceUev2gJ2nFnXpVHo8eRrpC9BLWZDee6ehnz/sPmNjizbXwpfaTBw==", + "dev": true, + "dependencies": { + "handlebars": "^4.7.7" + }, + "peerDependencies": { + "typedoc": ">=0.24.0" + } + }, + "node_modules/typedoc/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/typescript": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", @@ -15477,6 +15597,19 @@ "node": ">=12.20" } }, + "node_modules/uglify-js": { + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", + "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", + "dev": true, + "optional": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/umd": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", @@ -15680,6 +15813,18 @@ "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "dev": true }, + "node_modules/vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true + }, + "node_modules/vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -15925,6 +16070,12 @@ "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==", "dev": true }, + "node_modules/wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", + "dev": true + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 83ecc3d..6f73c73 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "test:integration": "jest --testPathPattern=integration", "test:package": "jest --config jest.config.package.js", "lint": "prettier --check . && tsc --noEmit", - "lint:fix": "npx prettier -w ." + "lint:fix": "npx prettier -w .", + "docgen": "typedoc --plugin typedoc-plugin-markdown" }, "repository": { "type": "git", @@ -51,6 +52,8 @@ "prettier": "^2.8.8", "rimraf": "^5.0.1", "ts-jest": "^29.1.0", + "typedoc": "^0.25.1", + "typedoc-plugin-markdown": "^3.16.0", "typescript": "^5.0.4", "webpack": "5.82.1", "webpack-cli": "5.1.1" diff --git a/src/types.ts b/src/types.ts index 02de069..1c37451 100644 --- a/src/types.ts +++ b/src/types.ts @@ -142,7 +142,7 @@ export type GatewayMessage = { } } -type EncryptedSecretsEntry = { +export type EncryptedSecretsEntry = { slot_id: number version: number expiration: number diff --git a/tsconfig.json b/tsconfig.json index 51aedd8..2531a89 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,10 @@ "noImplicitAny": true, "skipLibCheck": true }, + "typedocOptions": { + "entryPoints": ["src/index.ts"], + "out": "docs" + }, "include": ["src/**/*", "src/**/*.json", "test/**/*", "test/**/*.json"], "exclude": ["dist", "src/simulateScript/deno-sandbox/**/*.ts"] } From 67a2525eaa60e1be9c6e9dc0a9c40caa5ed5a3f0 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Fri, 8 Sep 2023 19:05:31 +0200 Subject: [PATCH 2/2] add doc generator --- docs/README.md | 1235 ++++++++++++++++----------- docs/classes/ResponseListener.md | 18 +- docs/classes/SecretsManager.md | 68 +- docs/classes/SubscriptionManager.md | 62 +- docs/enums/CodeLanguage.md | 4 +- docs/enums/FulfillmentCode.md | 16 +- docs/enums/Location.md | 8 +- docs/enums/ReturnType.md | 14 +- docs/interfaces/RequestEventData.md | 24 +- docs/interfaces/SimulationInput.md | 26 +- docs/modules.md | 891 ------------------- package.json | 2 +- 12 files changed, 874 insertions(+), 1494 deletions(-) delete mode 100644 docs/modules.md diff --git a/docs/README.md b/docs/README.md index b9caa3c..7fd97c5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,620 +1,891 @@ -@chainlink/functions-toolkit / [Exports](modules.md) +@chainlink/functions-toolkit + +# @chainlink/functions-toolkit + +## Table of contents + +### Enumerations + +- [CodeLanguage](enums/CodeLanguage.md) +- [FulfillmentCode](enums/FulfillmentCode.md) +- [Location](enums/Location.md) +- [ReturnType](enums/ReturnType.md) -# functions-toolkit +### Classes -An NPM package with collections of JavaScript functions that can be used for working with [Chainlink Functions](https://chain.link/functions). +- [ResponseListener](classes/ResponseListener.md) +- [SecretsManager](classes/SecretsManager.md) +- [SubscriptionManager](classes/SubscriptionManager.md) -Up-to-date documentation on Chainlink Functions can be found [here](https://docs.chain.link/chainlink-functions). +### Interfaces -> :warning: Chainlink Functions requires signing a terms of service agreement before creating a billing subscription. See this [getting started](https://docs.chain.link/chainlink-functions/getting-started) section in the docs. +- [RequestEventData](interfaces/RequestEventData.md) +- [SimulationInput](interfaces/SimulationInput.md) -# How to use this package +### Type Aliases -The following classes expose functionality one would expect from their name. +- [DONStoragePayload](README.md#donstoragepayload) +- [DecodedResult](README.md#decodedresult) +- [EncryptedSecretsEntry](README.md#encryptedsecretsentry) +- [EstimateCostConfig](README.md#estimatecostconfig) +- [FunctionsRequestParams](README.md#functionsrequestparams) +- [FunctionsResponse](README.md#functionsresponse) +- [GatewayMessage](README.md#gatewaymessage) +- [GatewayMessageBody](README.md#gatewaymessagebody) +- [GatewayMessageConfig](README.md#gatewaymessageconfig) +- [GatewayResponse](README.md#gatewayresponse) +- [NodeResponse](README.md#noderesponse) +- [RequestCommitment](README.md#requestcommitment) +- [SimulationResult](README.md#simulationresult) +- [SubCancelConfig](README.md#subcancelconfig) +- [SubConsumerConfig](README.md#subconsumerconfig) +- [SubCreateConfig](README.md#subcreateconfig) +- [SubFundConfig](README.md#subfundconfig) +- [SubTimeoutConfig](README.md#subtimeoutconfig) +- [SubTransferAcceptConfig](README.md#subtransferacceptconfig) +- [SubTransferConfig](README.md#subtransferconfig) +- [SubscriptionInfo](README.md#subscriptioninfo) +- [ThresholdPublicKey](README.md#thresholdpublickey) +- [TransactionOptions](README.md#transactionoptions) -- [Subscription Manager](#functions-billing-subscription-management) -- [Secrets Manager](#functions-secrets-manager) +### Variables -The following utilities are exposed by this package. +- [DEFAULT\_MAX\_EXECUTION\_DURATION\_MS](README.md#default_max_execution_duration_ms) +- [DEFAULT\_MAX\_HTTP\_REQUESTS](README.md#default_max_http_requests) +- [DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES](README.md#default_max_http_request_bytes) +- [DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS](README.md#default_max_http_request_duration_ms) +- [DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH](README.md#default_max_http_request_url_length) +- [DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES](README.md#default_max_http_response_bytes) +- [DEFAULT\_MAX\_MEMORY\_USAGE\_MB](README.md#default_max_memory_usage_mb) +- [DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES](README.md#default_max_on_chain_response_bytes) +- [callReportGasLimit](README.md#callreportgaslimit) +- [simulatedAllowListConfig](README.md#simulatedallowlistconfig) +- [simulatedAllowListId](README.md#simulatedallowlistid) +- [simulatedCoordinatorConfig](README.md#simulatedcoordinatorconfig) +- [simulatedDonId](README.md#simulateddonid) +- [simulatedLinkEthPrice](README.md#simulatedlinkethprice) +- [simulatedRouterConfig](README.md#simulatedrouterconfig) +- [simulatedSecretsKeys](README.md#simulatedsecretskeys) +- [simulatedTransmitters](README.md#simulatedtransmitters) +- [simulatedWallets](README.md#simulatedwallets) -- [Simulate code execution on your local machine](#local-functions-simulator) (local simulation of your custom JS source code execution) +### Functions -## Functions Billing Subscription Management +- [buildRequestCBOR](README.md#buildrequestcbor) +- [createGist](README.md#creategist) +- [decodeResult](README.md#decoderesult) +- [deleteGist](README.md#deletegist) +- [deployFunctionsOracle](README.md#deployfunctionsoracle) +- [simulateScript](README.md#simulatescript) +- [startLocalFunctionsTestnet](README.md#startlocalfunctionstestnet) -The `SubscriptionManager` class is used to manage the Chainlink billing [subscription](https://docs.chain.link/chainlink-functions/resources/concepts#subscriptions) used to pay for Functions requests. +## Type Aliases -The typical subscriptions-related operations are +### DONStoragePayload -- [How to use this package](#how-to-use-this-package) - - [Functions Billing Subscription Management](#functions-billing-subscription-management) - - [Subscription Initialization](#subscription-initialization) - - [Create Subscription](#create-subscription) - - [Fund Subscription](#fund-subscription) - - [Adding/Removing Authorized Consumer Contracts](#addingremoving-authorized-consumer-contracts) - - [Cancelling Subscriptions](#cancelling-subscriptions) - - [Transferring and Accepting Transfers of Subscriptions](#transferring-and-accepting-transfers-of-subscriptions) - - [Get subscription details](#get-subscription-details) - - [Timing out requests](#timing-out-requests) - - [Estimating request costs](#estimating-request-costs) - - [Adding transaction options](#adding-transaction-options) - - [Functions Secrets Manager](#functions-secrets-manager) - - [Initialize a SecretsManager instance](#initialize-a-secretsmanager-instance) - - [Fetch public keys](#fetch-public-keys) - - [Encrypting Secrets](#encrypting-secrets) - - [DON Hosted Secrets](#don-hosted-secrets) - - [Off-chain Hosted Secrets](#off-chain-hosted-secrets) - - [Functions Response Listener](#functions-response-listener) - - [Functions Utilities](#functions-utilities) - - [Local Functions Simulator](#local-functions-simulator) - - [Decoding Response Bytes](#decoding-response-bytes) - - [Storing Encrypted Secrets in Gists](#storing-encrypted-secrets-in-gists) - - [Building Functions Request CBOR Bytes](#building-functions-request-cbor-bytes) +Ƭ **DONStoragePayload**: `Object` -### Subscription Initialization +#### Type declaration -To create a Subscription Manager you need an object with 3 inputs. +| Name | Type | +| :------ | :------ | +| `expiration` | `number` | +| `payload` | `string` | +| `signature` | `string` | +| `slot_id` | `number` | +| `version` | `number` | -1. an instance of the [Ethers.js Signer class](https://docs.ethers.org/v5/api/signer/#Signer). Ensure you have a [Provider](https://docs.ethers.org/v5/api/providers/) connected so you can communicate with the blockchain through your endpoint provider. You can use Infura or Alchemy or any other similar provider that provides access to [blockchains that Chainlink Functions supports](<(https://docs.chain.link/chainlink-functions/supported-networks)>). -2. You need the contract address for the LINK token used to fund subscriptions. Get that for the matching blockchain network [here](https://docs.chain.link/resources/link-token-contracts). -3. The contract address for the Functions Router smart contract. Get that [here](<(https://docs.chain.link/chainlink-functions/supported-networks)>). +#### Defined in -Then create an instance of the Subscription Manager by passing those 3 inputs in as follows: +[types.ts:112](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L112) -> const subscriptionManager = new SubscriptionManager({ -> signer: [Signer](https://docs.ethers.org/v5/api/signer/#Signer), -> [linkTokenAddress](https://docs.chain.link/resources/link-token-contracts): string -> [functionsRouterAddress](https://docs.chain.link/chainlink-functions/supported-networks): string -> }) +___ -After the class is instantiated, it must be initialized before it can be used. This is done by running the `initialize` async function as shown below: +### DecodedResult -``` -await subscriptionManager.initialize() -``` +Ƭ **DecodedResult**: `BigInt` \| `string` -### Create Subscription +#### Defined in -`createSubscription()` creates a new Functions billing subscription using the Functions Router contract and returns a promise which resolves to the subscription ID of type `number`. Optionally, a consumer contract address can also be passed to create a subscription and add an authorized consumer in a single transaction. +[decodeResult.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/decodeResult.ts#L3) -``` -const subscriptionId = await subscriptionManager.createSubscription({ - consumerAddress?: string -}) -``` +___ -It is a good idea to make a note of your subscription ID as you will put funds in it. You'll also pass your subscription ID as an input for many operations when you're using Chainlink Functions. +### EncryptedSecretsEntry -### Fund Subscription +Ƭ **EncryptedSecretsEntry**: `Object` -Adds LINK token to your subscription. You must have LINK balance sitting in your subscription in order to fund the gas used by the response transaction, and also to fund the decentralized computation/execution of your custom code that will be performed by the Chainlink Decentralized Oracle Network. +#### Type declaration -To fund the subscription with LINK, ensure the wallet that you have connected to your Provider has LINK. You can get some testnet LINK from the [faucet](https://faucets.chain.link). +| Name | Type | +| :------ | :------ | +| `expiration` | `number` | +| `slot_id` | `number` | +| `version` | `number` | -Note that all values are denominated in [Juels](https://docs.chain.link/resources/link-token-contracts). 1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK. Do not use the JavaScript `number` type for calculations with Juels as the maximum safe JavaScript integer is only `2^54 - 1`. +#### Defined in -``` -const juelsAmount: BigInt | string = BigInt(2) * BigInt(10**18) -await subscriptionManager.fundSubscription({ - subscriptionId, - juelsAmount, -}) -``` +[types.ts:145](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L145) -`fundSubscription()` returns a promise which resolves to an EthersJS [TransactionReceipt](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt) +___ -### Adding/Removing Authorized Consumer Contracts +### EstimateCostConfig -A Functions Consumer smart contract is where you will trigger your Functions execution request to the Chainlink Oracle Network. This is also where the Oracle Network will return the results of your decentralized computation. A visualization of this request/response flow is below. +Ƭ **EstimateCostConfig**: `Object` -![Request/Response Flow](https://docs.chain.link/images/chainlink-functions/requestAndReceive.png) -([source](<(https://docs.chain.link/chainlink-functions/resources/architecture)>)) +#### Type declaration -Each subscription can hold a limited number of authorized Functions Consumers. Refer to the [service limits](https://docs.chain.link/chainlink-functions/resources/service-limits) to view the maximum number of consumer contracts per subscription. These are the consumer contracts that are authorized to use your subscription's LINK balance to fund the Oracle Network's compute tasks on your custom code. +| Name | Type | +| :------ | :------ | +| `callbackGasLimit` | `number` | +| `donId` | `string` | +| `gasPriceGwei` | `BigInt` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | -``` -const addConsumerTxReceipt = await subscriptionManager.addConsumer({ - subscriptionId, - consumerAddress, -}) -``` +#### Defined in -Similarly you can remove an authorized consumer contract with: +[types.ts:82](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L82) -``` -const removeConsumerTxReceipt = await subscriptionManager.removeConsumer({ - subscriptionId, - consumerAddress, -}) -``` +___ -Both `addConsumer()` and `removeConsumer()` return a promise which resolves to an EthersJS [TransactionReceipt](https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt). +### FunctionsRequestParams -### Cancelling Subscriptions +Ƭ **FunctionsRequestParams**: `Object` -Unless there is an expired pending request, you can cancel subscriptions with: +#### Type declaration -``` -const cancelSubTxReceipt = await subscriptionManager.cancelSubscription({ subscriptionId }) -``` +| Name | Type | +| :------ | :------ | +| `args?` | `string`[] | +| `bytesArgs?` | `string`[] | +| `codeLanguage` | [`CodeLanguage`](enums/CodeLanguage.md) | +| `codeLocation` | [`Location`](enums/Location.md) | +| `encryptedSecretsReference?` | `string` | +| `secretsLocation?` | [`Location`](enums/Location.md) | +| `source` | `string` | -`cancelSubscription()` takes a config object that has the following type definition. You'll note that you can specify a wallet address to which the subscription's LINK balance will be refunded. If unspecified, it will default to the subscription owner's address. +#### Defined in -``` -type SubCancelConfig = { - subscriptionId: BigInt | number | string - refundAddress?: string - txOptions?: TransactionOptions -} -``` +[types.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L22) -If there are any pending requests, you must first "time out" that pending request using the [timeoutRequest() function](#timing-out-requests) before cancelling the subscription. +___ -### Transferring and Accepting Transfers of Subscriptions +### FunctionsResponse -Transferring subscriptions is a two-stage process. The subscription owner proposes the transfer with `requestSubscriptionTransfer()` and it is recorded on chain, but the ownership does not transfer until the transferee accepts by calling `acceptTransfer()`. +Ƭ **FunctionsResponse**: `Object` -``` -const transferTxReceipt = await subscriptionManager.requestSubscriptionTransfer({ - subscriptionId, - newOwner, // transferee wallet address -}) -``` +#### Type declaration -To accept the ownership transfer, the transferee will need to have their own `SubscriptionManager` instance which is connected to the wallet address denoted by `newOwner` in the code snippet above. Then the transferee runs: +| Name | Type | +| :------ | :------ | +| `errorString` | `string` | +| `fulfillmentCode` | [`FulfillmentCode`](enums/FulfillmentCode.md) | +| `requestId` | `string` | +| `responseBytesHexstring` | `string` | +| `returnDataBytesHexstring` | `string` | +| `subscriptionId` | `number` | +| `totalCostInJuels` | `BigInt` | -``` -const acceptTransferTxReceipt = await transfereeSubManager.acceptSubTransfer({ subscriptionId }) -``` +#### Defined in -### Get subscription details +[types.ts:171](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L171) -You can request details for a given subscription (on the network on which it has been created) using +___ -``` -const subscriptionInfo = await getSubscriptionInfo(subscriptionId) -``` +### GatewayMessage -This is a read-only interaction with the blockchain. +Ƭ **GatewayMessage**: `Object` -The returned promise - the variable `subscriptionInfo` in this example - resolves to a value of type `SubscriptionInfo` and has the following structure: +#### Type declaration -``` -type SubscriptionInfo = { - balance: BigInt // Represented in Juels (1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK) - owner: string // Subscription owner's address - blockedBalance: BigInt // Balance reserved to pay for in-flight requests represented in Juels - proposedOwner: string // Address used for transferring subscriptions - consumers: string[] // Addresses of consumer contracts allowed to use the subscription - flags: string // Indicates resource limits for a given subscription (If the default limits are not enough for your use case, contact the Chainlink team by emailing support@chain.link to inquire about a potential increase.) -} -``` +| Name | Type | +| :------ | :------ | +| `id` | `string` | +| `jsonrpc` | ``"2.0"`` | +| `method` | `string` | +| `params` | { `body`: [`GatewayMessageBody`](README.md#gatewaymessagebody) ; `signature`: `string` } | +| `params.body` | [`GatewayMessageBody`](README.md#gatewaymessagebody) | +| `params.signature` | `string` | -### Timing out requests +#### Defined in -In certain (rare) circumstances pending requests (requests that have not been fulfilled) will be expired and you may need to manually time those requests out. This is because when a request is "in-flight", your LINK tokens that pay for that computation get locked up for the duration of the request's lifecycle. Calling `timeoutRequest()` unlocks those funds and effectively 'cancels' that pending request. +[types.ts:135](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L135) -You can timeout more than one request in a single transaction. +___ -``` -const timeoutReceipt: TransactionReceipt | void = await timeoutRequests(timeoutReqConfig) -``` +### GatewayMessageBody -The `timeoutReqConfig` referred to above has the following shape: +Ƭ **GatewayMessageBody**: `Object` -``` -{ - requestCommitments: RequestCommitment[] - txOptions?: TransactionOptions -} -``` +#### Type declaration -The `RequestCommitment` type refers to the data for the in-flight requests. Note that when timing out a request, all this data must exactly match the request commitment that was emitted on-chain by the `OracleRequest` event when the request was initiated. +| Name | Type | +| :------ | :------ | +| `don_id` | `string` | +| `message_id` | `string` | +| `method` | `string` | +| `payload?` | [`DONStoragePayload`](README.md#donstoragepayload) | +| `receiver` | `string` | -``` -type RequestCommitment = { - requestId: string - coordinator: string - estimatedTotalCostJuels: BigInt - client: string - subscriptionId: number - callbackGasLimit: BigInt - adminFee: BigInt - donFee: BigInt - gasOverheadBeforeCallback: BigInt - gasOverheadAfterCallback: BigInt - timeoutTimestamp: BigInt -} -``` +#### Defined in -### Estimating request costs +[types.ts:127](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L127) -The SubscriptionManager class's `estimateFunctionsRequestCost` method can be used to estimate the cost of a Functions request. +___ -``` -const estimatedCostInJuels: BigInt = await subscriptionManager.estimateFunctionsRequestCost({ - donId, // ID of the DON to which the Functions request will be sent - subscriptionId, // Subscription ID - callbackGasLimit, // Total gas used by the consumer contract's callback - gasPriceGwei, // Gas price in gWei -}) -``` +### GatewayMessageConfig -This method will return a promise which resolves to a `BigInt` with the estimated request cost in Juels (1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK). +Ƭ **GatewayMessageConfig**: `Object` -### Adding transaction options +#### Type declaration -The SubscriptionManager class's exposed methods can take an optional `TransactionOptions` object that has the following shape. +| Name | Type | +| :------ | :------ | +| `don_id` | `string` | +| `gatewayUrls` | `string`[] | +| `method` | `string` | +| `payload?` | [`DONStoragePayload`](README.md#donstoragepayload) | -``` -export type TransactionOptions = { - overrides?: Overrides - confirmations?: number -} -``` +#### Defined in -Overrides are defined by EthersJS for [read-only calls](https://docs.ethers.org/v5/api/contract/contract/#Contract-functionsCall) and for [write transactions](https://docs.ethers.org/v5/api/contract/contract/#Contract--write). `confirmations` refers to the number of block confirmations to wait before proceeding. +[types.ts:120](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L120) -## Functions Secrets Manager +___ -This class helps you encrypt and manage the secrets that your Functions source code needs. These would be data you ordinarily put in your environment variables - such as API keys and auth related passwords etc. +### GatewayResponse -Functions secrets utilize threshold public key cryptography, requiring multiple nodes to participate in a decentralized decryption process such that no single node can decrypt secrets singlehandedly. +Ƭ **GatewayResponse**: `Object` -Encrypted secrets are never stored directly on the blockchain, but instead can be either hosted by the DON or stored in a JSON file located at one or more URLs. Then, they are referenced in an on-chain request where they are fetched by the DON. +#### Type declaration -### Initialize a SecretsManager instance +| Name | Type | +| :------ | :------ | +| `gatewayUrl` | `string` | +| `nodeResponses` | [`NodeResponse`](README.md#noderesponse)[] | -To create a Secrets Manager you need an object with 3 inputs. +#### Defined in -1. An instance of the [Ethers.js Signer class](https://docs.ethers.org/v5/api/signer/#Signer). Ensure you have a [Provider](https://docs.ethers.org/v5/api/providers/) connected so you can communicate with the blockchain through your endpoint provider. You can use Infura or Alchemy or any other similar provider that provides access to [blockchains that Chainlink Functions supports](<(https://docs.chain.link/chainlink-functions/supported-networks)>). -2. The contract address for the Functions Router smart contract. Get that [here](<(https://docs.chain.link/chainlink-functions/supported-networks)>). -3. The `donId` string to reference the DON you would like to use which can also be found at the previous link. +[types.ts:156](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L156) -> const secretsManager = new SecretsManager({ -> signer: [Signer](https://docs.ethers.org/v5/api/signer/#Signer), -> [functionsRouterAddress](https://docs.chain.link/chainlink-functions/supported-networks): string -> [donId](https://docs.chain.link/chainlink-functions/supported-networks): string -> }) +___ -After the class is instantiated, it must be initialized before it can be used. This is done by running the `initialize()` async method. +### NodeResponse -``` -await secretsManager.initialize() -``` +Ƭ **NodeResponse**: `Object` -### Fetch public keys +#### Type declaration -You can fetch the public keys by querying the [Functions Coordinator contract](https://docs.chain.link/chainlink-functions/resources/architecture). +| Name | Type | +| :------ | :------ | +| `rows?` | [`EncryptedSecretsEntry`](README.md#encryptedsecretsentry)[] | +| `success` | `boolean` | -In most cases you will not need to call this method directly. The other methods in `SecretsManager` will automatically use this method. +#### Defined in -``` -const keys = await secretsManager.fetchKeys() -``` +[types.ts:151](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L151) -`fetchKeys()` returns a promise that resolves to an object with the following properties: +___ -``` -{ - thresholdPublicKey: ThresholdPublicKey - donPublicKey: string -} -``` - -The threshold public key is an added layer of cryptographic protection for the security of your API secrets. Your secrets get encrypted twice - first with the `donPublicKey` and then with the `thresholdPublicKey`. - -Encrypting with the `thresholdPublicKey` requires nodes to collaborate in order to decrypt secrets. This is because secrets cannot be decrypted with a single key; instead, each DON node has a decryption key shard, and multiple nodes must come together in a decentralized process to decrypt the secrets. This improves security since no single DON node can decrypt secrets without collaborating with other DON nodes. +### RequestCommitment -### Encrypting Secrets +Ƭ **RequestCommitment**: `Object` -Secrets are encrypted by passing them in an object to the `encryptSecrets()` method. - -Here are some important conditions you must satisfy when configuring your secrets for Chainlink Functions. - -1. Secrets are optional. You do not need to configure secrets if your custom Functions source code does not need to access any secrets that get passed in at runtime. -2. Your secrets must be passed in an object with string key/value pairs: +#### Type declaration -``` -{ - testKey: 'testValue1', - testKey2: 'testValue2', - testKey3: 'testValue3', -} -``` +| Name | Type | +| :------ | :------ | +| `adminFee` | `BigInt` | +| `callbackGasLimit` | `BigInt` | +| `client` | `string` | +| `coordinator` | `string` | +| `donFee` | `BigInt` | +| `estimatedTotalCostJuels` | `BigInt` | +| `gasOverheadAfterCallback` | `BigInt` | +| `gasOverheadBeforeCallback` | `BigInt` | +| `requestId` | `string` | +| `subscriptionId` | `number` | +| `timeoutTimestamp` | `BigInt` | -``` -const encryptedSecrets = await secretsManager.encryptSecrets({ - testKey: 'testValue0' -}) -``` +#### Defined in -`encryptSecrets()` returns a promise that resolves to an object with a single property `encryptedSecrets`: +[types.ts:98](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L98) -``` -{ - encryptedSecrets: string -} -``` +___ -`encryptedSecrets` contains the string representation of your secrets, converted into bytes, and encrypted using the public keys. +### SimulationResult -### DON Hosted Secrets +Ƭ **SimulationResult**: `Object` -Encrypted secrets can be uploaded directly to the DON via gateway URLs such that they can be used when making an on-chain request. This is accomplished by sending a signed POST request to gateway URLs which are connected to the DON. The DON then maintains a decentralized database with eventual consistency, such that the stored values will propagate to all DON nodes. To ensure redundancy, it is always recommended to send encrypted secrets storage requests to multiple gateway URLs. +#### Type declaration -First, encrypt the secrets with [`encryptSecrets()`](#encrypting-secrets). Then, pass the `encryptedSecrets` hex string in an object to the `uploadEncryptedSecretsToDON()` method as shown below. The `storageSlotId` can be any integer value of zero or greater, however using a previously used slot ID will overwrite the existing data. After `minutesUntilExpiration`, the entry will be deleted from all DON nodes. Get the list of valid gateway URLs for each blockchain network from the [Chainlink Functions documentation](https://docs.chain.link/chainlink-functions/supported-networks). +| Name | Type | +| :------ | :------ | +| `capturedTerminalOutput` | `string` | +| `errorString?` | `string` | +| `responseBytesHexstring?` | `string` | -``` -const encryptedSecretsObj = await secretsManager.encryptSecrets({ my: 'secret' }) -const mySlotIdNumber = 0 -const myExpirationTimeInMinutes = 10 +#### Defined in -const { - version, // Secrets version number (corresponds to timestamp when encrypted secrets were uploaded to DON) - success, // Boolean value indicating if encrypted secrets were successfully uploaded to all nodes connected to the gateway -} = await secretsManager.uploadEncryptedSecretsToDON({ - encryptedSecretsHexstring: encryptedSecretsObj.encryptedSecrets, - gatewayUrls: [ 'https://exampleGatewayUrl1.com/gateway', 'https://exampleGatewayUrl2.com/gateway', ... ], - storageSlotId: mySlotIdNumber, - minutesUntilExpiration: myExpirationTimeInMinutes, -}) -``` +[types.ts:196](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L196) -The `uploadEncryptedSecretsToDON()` method will return a promise that resolves to an object of the type shown below. +___ -``` -{ - version: number, - success: boolean, -} -``` +### SubCancelConfig -The `version` is a number which represents the version of the uploaded encrypted secrets; it is the POSIX time at which the `uploadEncryptedSecretsToDON()` method was initiated. This will be used when making a Functions request to ensure the latest version of the encrypted secrets are used. If the upload was unsuccessful for one or more nodes, a warning message will be printed and the `success` field will be `false`. If the upload was unsuccessful for all nodes, the method will throw an error. +Ƭ **SubCancelConfig**: `Object` -``` -const secretsEntriesForGateway = await secretsManager.listDONHostedEncryptedSecrets([ 'https://exampleGatewayUrl1.com/gateway', 'https://exampleGatewayUrl2.com/gateway', ... ]) -``` +#### Type declaration -`listDONHostedEncryptedSecrets()` will return an array with following shape or throw an error. If the method successfully returns, but the `error` field of the returned object is populated, it indicates that the request to list secrets was successful, but there is a discrepancy between the node responses. +| Name | Type | +| :------ | :------ | +| `refundAddress?` | `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | -``` -{ - result: [ - { - gatewayUrl: 'https://examplegatewayurl.com/gateway', - nodeResponses: [ - { - success: true, - rows: [ - { - slot_id: 0, - version: 0, - expiration: 100_000, - }, - ... - ], - }, - ... - ], - }, - ... - ], - error: 'Possible error message ' -} -``` +#### Defined in -`buildDONHostedEncryptedSecretsReference()` can be used to construct the hex string which represents the `encryptedSecretsReference` bytes used to reference the DON hosted encrypted secrets when making an on-chain Functions request. To use DON hosted encrypted secrets in an on-chain request, also ensure that `secretsLocation` is set to `Location.DONHosted` (ie: `2`). +[types.ts:61](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L61) -``` -const encryptedSecretsReference: string = buildDONHostedEncryptedSecretsReference({ - slotId: number, - version: number -}) -``` - -### Off-chain Hosted Secrets - -Encrypted secrets can also be stored off-chain in JSON file instead of being hosted on the DON, enabling more direct control over how the encrypted secrets data is stored. The DON nodes fetch this file from one or more URLs. - -First encrypt the secrets with [`encryptSecrets()`](#encrypting-secrets) and then paste or upload the resulting object into a private Github Gist, cloud storage bucket or or any other location such that the encrypted secrets JSON object can be fetched by the DON via URL. These secrets are encrypted so even if they're public, your secrets are not visible. - -You can also use the [gist uploader utility function](#storing-encrypted-secrets-in-gists) to upload the encrypted secrets string to a JSON file in a Github Gist. - -However you'd need to pass the URLs to your Functions Consumer contract so that the DON can retrieve the secrets. - -**Note:** ⚠️ As an additional layer of security, the URLs must also encrypted with the DON Public key before being included in an on-chain transaction. This is to prevent directly exposing the URL to anyone except DON members. You can build the encrypted URLs with: - -> const encryptedURLs: string = await encryptSecretsUrls(secretsUrls: string[]) - -The argument `secretsUrls` is an array of URLs and `encryptSecretsUrls()` returns the URLs as an encrypted, space-separated string of all the URLs you supply in the array. - -## Functions Response Listener - -The `ResponseListener` class provides an easy way to listen for on-chain responses to Functions requests. - -To create a Request Listener you need an object with 2 inputs. - -1. An instance of an [Ethers.js provider](https://docs.ethers.org/v5/api/providers/). You can use Infura or Alchemy or any other similar provider that provides access to [blockchains that Chainlink Functions supports](<(https://docs.chain.link/chainlink-functions/supported-networks)>). -2. The contract address for the Functions Router smart contract. Get that [here](<(https://docs.chain.link/chainlink-functions/supported-networks)>). - -> const responseListener = new ResponseListener({ -> provider: [Provider](https://docs.ethers.org/v5/api/providers/), -> [functionsRouterAddress](https://docs.chain.link/chainlink-functions/supported-networks): string, -> }) - -To listen for the response to a single Functions request by request ID, use the the `listenForResponse()` method. Optionally, you can provide a custom timeout after which the listener will throw an error indicating that the time limit was exceeded. If no timeout is provided, the default timeout is 300 seconds. - -**Note:** Listening for multiple responses simultaneously is not supported by the `listenForResponse()` method and will lead to undefined behavior. - -``` -const response: FunctionsResponse = await responseListener.listenForResponse( - requestId: string, - timeout?: number, -) -``` - -The `FunctionsResponse` will have the following shape. - -``` -{ - requestId: string // Request ID of the fulfilled request represented as a bytes32 hex string - subscriptionId: number // Subscription ID billed for request - totalCostInJuels: BigInt // Actual cost of request in Juels (1,000,000,000,000,000,000 (1e18) Juels are equal to 1 LINK) - responseBytesHexstring: string // Response bytes sent to client contract represented as a hex string - errorString: string // Error bytes sent to client contract represented as a hex string - returnDataBytesHexstring: string // Data returned by consumer contract's handleOracleFulfillment method represented as a hex string - fulfillmentCode: FulfillmentCode // Indicates whether the request was fulfilled successfully or not -} -``` - -The possible fulfillment codes are shown below. - -``` -{ - FULFILLED = 0, // Indicates that calling the consumer contract's handleOracleFulfill method was successful - USER_CALLBACK_ERROR = 1, // Indicates that the consumer contract's handleOracleFulfill method reverted - INVALID_REQUEST_ID = 2, // Internal error - COST_EXCEEDS_COMMITMENT = 3, // Indicates that the request was not fulfilled because the cost of fulfillment is higher than the estimated cost due to an increase in gas prices - INSUFFICIENT_GAS_PROVIDED = 4, // Internal error - SUBSCRIPTION_BALANCE_INVARIANT_VIOLATION, // Internal error - INVALID_COMMITMENT = 6, // Internal error -} -``` - -To listen for multiple Functions responses for a given subscription ID, use the `listenForResponses()` method. This method is particularly useful when Chainlink Automation is being used to trigger the sending of Functions requests. `listenForResponses()` takes the subscription ID and a callback as arguments. The callback will be given a `FunctionsResponse` as an argument. - -**Note:** To avoid undefined behavior, ensure only one listener method is running at a time. - -``` -const callback = (response: FunctionsResponse) => { console.log(response) } -responseListener.listenForResponses( - subscriptionId: number, - callback, -) -``` +___ -When done listener for responses, use the `stopListeningForResponses` method to stop the listener. +### SubConsumerConfig -``` -responseListener.stopListeningForResponses() -``` +Ƭ **SubConsumerConfig**: `Object` -## Functions Utilities +#### Type declaration -### Local Functions Simulator +| Name | Type | +| :------ | :------ | +| `consumerAddress` | `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | -> The local Functions JavaScript simulator requires Deno to be installed on your machine be and accessible via the PATH environment variable (ie: the `deno --version` command must work). -> Visit [deno.land/#installation](https://deno.land/#installation) for installation instructions. +#### Defined in -The `simulateScript` function is used to simulate the execution of your custom Functions JavaScript source code on your development machine. This means you can use the simulator during development to test your JavaScript code, and you can also run the simulator before you execute an on on-chain transaction that triggers a Functions request on a live network to verify your returns the expected value. This is useful for debugging especially since the `simulateScript` function returns captured terminal output which contains any console log messages or errors. +[types.ts:49](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L49) -`simulateScript` takes an object as an argument with the following parameters shown below. Arguments that can be accessed within the source via the global variable `args` or `bytesArgs` which is are injected into the runtime. You can also add API keys and other secrets using the `secrets` object that gets injected as a global variable in the runtime. +___ -``` -const result = await simulateScript({ - source: string // JavaScript source code - args?: string[] // Array of string arguments accessible from the source code via the global variable `args` - bytesArgs?: string[] // Array of bytes arguments, represented as hex strings, accessible from the source code via the global variable `bytesArgs` - secrets?: Record // Secret values represented as key-value pairs - maxOnChainResponseBytes?: number // Maximum size of the returned value in bytes (defaults to 256) - maxExecutionTimeMs?: number // Maximum execution duration (defaults to 10_000ms) - maxMemoryUsageMb?: number // Maximum RAM usage (defaults to 128mb) - numAllowedQueries?: number // Maximum number of HTTP requests (defaults to 5) - maxQueryDurationMs?: number // Maximum duration of each HTTP request (defaults to 9_000ms) - maxQueryUrlLength?: number // Maximum HTTP request URL length (defaults to 2048) - maxQueryRequestBytes?: number // Maximum size of outgoing HTTP request payload (defaults to 2048 == 2 KB) - maxQueryResponseBytes?: number // Maximum size of incoming HTTP response payload (defaults to 2_097_152 == 2 MB) -}) -``` +### SubCreateConfig -`simulateScript` returns a promise which resolves to an object as shown below. +Ƭ **SubCreateConfig**: `Object` -``` -{ - responseBytesHexstring?: string // Response bytes which would be returned on-chain, represented as a hex string - errorString?: string // Error message that would be returned on-chain (either errorString or responseBytesHexstring will be defined) - capturedTerminalOutput: string // stdout or stderr terminal output captured during simulated execution -} -``` +#### Type declaration -**_NOTE:_** The `simulateScript` function is a debugging tool and hence is not a perfect representation of the actual Chainlink oracle execution environment. Therefore, it is important to make a Functions request on a supported testnet blockchain before mainnet usage. - -### Decoding Response Bytes +| Name | Type | +| :------ | :------ | +| `consumerAddress?` | `string` | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | -On-chain responses are encoded as Solidity `bytes` which are most frequently displayed as hex strings. However, these hex strings often need to be decoded into a useable type. In order to decode hex strings into human-readable values, this package provides the `decodeResult` function. Currently, the `decodeResult` function supports decoding hex strings into `uint256`, `int256` or `string` values. - -``` -const result: BigInt | string = decodeResult( - resultHexString: string, - expectedReturnType: ReturnType // 'uint256' | 'int256' | 'string' -) -``` - -Possible return values are also available in the `ReturnType` enum shown below. +#### Defined in -``` -export enum ReturnType { - uint = 'uint256', - uint256 = 'uint256', - int = 'int256', - int256 = 'int256', - string = 'string', - bytes = 'bytes', -} -``` +[types.ts:44](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L44) -### Storing Encrypted Secrets in Gists +___ -When describing the use of [off-chain secrets](#off-chain-hosted-secrets), we had described the storing of encrypted secrets off-chain, on hosted sites or storage repositories. For example we can store secrets in a private gist. +### SubFundConfig -Encrypted default secrets (DON-level secrets) would look something like this: +Ƭ **SubFundConfig**: `Object` -``` -{ - "encryptedSecrets": '0x1234567890abcdefg', // some long hex string -} -``` +#### Type declaration -This Functions Package includes utilities to upload the encrypted secrets to a private Github gist and to delete a gist as well. +| Name | Type | +| :------ | :------ | +| `juelsAmount` | `BigInt` \| `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | -To use this utility with Github gist you need to create a [Github Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). +#### Defined in -You can upload encrypted secrets to a private Github gist with +[types.ts:55](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L55) -``` -const encryptedSecrets = await secretsManager.encryptSecrets({ - mySecret: 'secretValue' -}) +___ -const gistURL = await createGist(githubApiToken: string, JSON.stringify(encryptedSecrets)) // encryptedSecrets must be a string, not an object. -``` +### SubTimeoutConfig -The `gistURL` itself must then be encrypted by calling [encryptSecretsUrls()](#off-chain-hosted-secrets). +Ƭ **SubTimeoutConfig**: `Object` -You can delete gists (if you need to clean them up, for example) with +#### Type declaration -``` -const success: boolean = await deleteGist(githubApiToken: string, gistURL: string) -``` +| Name | Type | +| :------ | :------ | +| `requestCommitments` | [`RequestCommitment`](README.md#requestcommitment)[] | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | -This function will return a promise which resolves to `true` if deletion is successful, else it will throw an error. +#### Defined in -### Building Functions Request CBOR Bytes +[types.ts:77](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L77) -Instead of performing the [CBOR encoding for a Functions request on-chain](https://docs.chain.link/chainlink-functions/api-reference/functions#encodecbor) in your Functions consumer contract, it is also possible to generate the CBOR encoding off-chain in order to save gas. Then, the resulting encoded CBOR bytes can be used when making an on-chain request. You can either store the encoded request in a `bytes` storage variable within your consumer contract, or initiate the Functions request by passing the CBOR-encoded request object `bytes` direclty into the `_sendRequest()` method which [is inherited from `FunctionsClient.sol`](https://docs.chain.link/chainlink-functions/api-reference/functions-client) . +___ -Note that when encoding a request off-chain, `args` or `bytesArgs` cannot be added to the request on-chain. This is a limitation of CBOR encoding due to its immutable structure. +### SubTransferAcceptConfig -To build the CBOR encoded Functions request bytes off-chain, use the `buildRequestCBOR()` function as shown below +Ƭ **SubTransferAcceptConfig**: `Object` -``` -const functionsRequestBytesHexString: string = buildRequestCBOR({ - codeLocation: number // Must be 0 for inline source code. No other values are supported at this time. - secretsLocation?: number // Must be 1 for Remote or 2 for DONHosted secrets. No other values are supported at this time. - codeLanguage: number // Must be 0 for JavaScript. No other values are supported at this time. - source: string // JavaScript source code - encryptedSecretsReference?: string // Hex string representing an encrypted secrets URLs or DON hosted encrypted secrets reference - args?: string[] // Array of string arguments - bytesArgs?: string[] // Array of bytes arguments, represented as hex strings -}) -``` +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | + +#### Defined in + +[types.ts:72](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L72) + +___ + +### SubTransferConfig + +Ƭ **SubTransferConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `newOwner` | `string` | +| `subscriptionId` | `BigInt` \| `number` \| `string` | +| `txOptions?` | [`TransactionOptions`](README.md#transactionoptions) | + +#### Defined in + +[types.ts:66](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L66) + +___ + +### SubscriptionInfo + +Ƭ **SubscriptionInfo**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `balance` | `BigInt` | +| `blockedBalance` | `BigInt` | +| `consumers` | `string`[] | +| `flags` | `string` | +| `owner` | `string` | +| `proposedOwner` | `string` | + +#### Defined in + +[types.ts:89](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L89) + +___ + +### ThresholdPublicKey + +Ƭ **ThresholdPublicKey**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `G_bar` | `string` | +| `Group` | `string` | +| `H` | `string` | +| `HArray` | `string`[] | + +#### Defined in + +[types.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L32) + +___ + +### TransactionOptions + +Ƭ **TransactionOptions**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `confirmations?` | `number` | +| `overrides?` | `Overrides` | + +#### Defined in + +[types.ts:39](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L39) + +## Variables + +### DEFAULT\_MAX\_EXECUTION\_DURATION\_MS + +• `Const` **DEFAULT\_MAX\_EXECUTION\_DURATION\_MS**: ``10000`` + +#### Defined in + +[simulationConfig.ts:84](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L84) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUESTS + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUESTS**: ``5`` + +#### Defined in + +[simulationConfig.ts:86](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L86) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES**: ``2048`` + +#### Defined in + +[simulationConfig.ts:89](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L89) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS**: ``9000`` + +#### Defined in + +[simulationConfig.ts:87](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L87) + +___ + +### DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH + +• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH**: ``2048`` + +#### Defined in + +[simulationConfig.ts:88](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L88) + +___ + +### DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES + +• `Const` **DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES**: ``2097152`` + +#### Defined in + +[simulationConfig.ts:90](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L90) + +___ + +### DEFAULT\_MAX\_MEMORY\_USAGE\_MB + +• `Const` **DEFAULT\_MAX\_MEMORY\_USAGE\_MB**: ``128`` + +#### Defined in + +[simulationConfig.ts:85](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L85) + +___ + +### DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES + +• `Const` **DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES**: ``256`` + +#### Defined in + +[simulationConfig.ts:83](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L83) + +___ + +### callReportGasLimit + +• `Const` **callReportGasLimit**: ``5000000`` + +#### Defined in + +[simulationConfig.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L32) + +___ + +### simulatedAllowListConfig + +• `Const` **simulatedAllowListConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `enabled` | `boolean` | +| `signerPublicKey` | `string` | + +#### Defined in + +[simulationConfig.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L27) + +___ + +### simulatedAllowListId + +• `Const` **simulatedAllowListId**: ``"allowlist1"`` + +#### Defined in + +[simulationConfig.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L5) + +___ + +### simulatedCoordinatorConfig + +• `Const` **simulatedCoordinatorConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `donFee` | `number` | +| `fallbackNativePerUnitLink` | `bigint` | +| `feedStalenessSeconds` | `number` | +| `fulfillmentGasPriceOverEstimationBP` | `number` | +| `gasOverheadAfterCallback` | `number` | +| `gasOverheadBeforeCallback` | `number` | +| `maxCallbackGasLimit` | `number` | +| `maxSupportedRequestDataVersion` | `number` | +| `requestTimeoutSeconds` | `number` | + +#### Defined in + +[simulationConfig.ts:15](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L15) + +___ + +### simulatedDonId + +• `Const` **simulatedDonId**: ``"coordinator1"`` + +#### Defined in + +[simulationConfig.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L3) + +___ + +### simulatedLinkEthPrice + +• `Const` **simulatedLinkEthPrice**: `bigint` + +#### Defined in + +[simulationConfig.ts:1](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L1) + +___ + +### simulatedRouterConfig + +• `Const` **simulatedRouterConfig**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `adminFee` | `number` | +| `gasForCallExactCheck` | `number` | +| `handleOracleFulfillmentSelector` | `string` | +| `maxCallbackGasLimits` | `number`[] | +| `maxConsumersPerSubscription` | `number` | + +#### Defined in + +[simulationConfig.ts:7](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L7) + +___ + +### simulatedSecretsKeys + +• `Const` **simulatedSecretsKeys**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `donKey` | { `privateKey`: `string` ; `publicKey`: `string` } | +| `donKey.privateKey` | `string` | +| `donKey.publicKey` | `string` | +| `thresholdKeys` | { `privateKeyShares`: { `[address: string]`: `string`; } ; `publicKey`: `string` } | +| `thresholdKeys.privateKeyShares` | { `[address: string]`: `string`; } | +| `thresholdKeys.publicKey` | `string` | + +#### Defined in + +[simulationConfig.ts:55](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L55) + +___ + +### simulatedTransmitters + +• `Const` **simulatedTransmitters**: `string`[] + +#### Defined in + +[simulationConfig.ts:53](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L53) + +___ + +### simulatedWallets + +• `Const` **simulatedWallets**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `node0` | { `address`: `string` = '0xAe24F6e7e046a0C764DF51F333dE5e2fE360AC72'; `privateKey`: `string` = '0x493f20c367e9c5190b14b8071a6c765da973d41428b841c25e4aaba3577f8ece' } | +| `node0.address` | `string` | +| `node0.privateKey` | `string` | +| `node1` | { `address`: `string` = '0x37d7bf16f6fd8c37b766Fa87e047c68c51dfdf4a'; `privateKey`: `string` = '0x7abd90843922984dda18358a179679e5cabda5ad8d0ebab5714ac044663a6a14' } | +| `node1.address` | `string` | +| `node1.privateKey` | `string` | +| `node2` | { `address`: `string` = '0x6e7EF53D9811B70834902D2D9137DaD2720eAC47'; `privateKey`: `string` = '0xcb8801121add786869aac78ceb4003bf3aa8a68ae8dd31f80d61f5f98eace3c5' } | +| `node2.address` | `string` | +| `node2.privateKey` | `string` | +| `node3` | { `address`: `string` = '0xBe83eA9868AE964f8C46EFa0fea798EbE16441c5'; `privateKey`: `string` = '0x06c7ca21f24edf450251e87097264b1fd184c9570084a78aa3300e937e1954b8' } | +| `node3.address` | `string` | +| `node3.privateKey` | `string` | + +#### Defined in + +[simulationConfig.ts:34](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulationConfig.ts#L34) + +## Functions + +### buildRequestCBOR + +▸ **buildRequestCBOR**(`requestParams`): `string` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `requestParams` | [`FunctionsRequestParams`](README.md#functionsrequestparams) | + +#### Returns + +`string` + +#### Defined in + +[buildRequestCBOR.ts:8](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/buildRequestCBOR.ts#L8) + +___ + +### createGist + +▸ **createGist**(`githubApiToken`, `content`): `Promise`<`string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `githubApiToken` | `string` | +| `content` | `string` | + +#### Returns + +`Promise`<`string`\> + +#### Defined in + +[offchain_storage/github.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/offchain_storage/github.ts#L3) + +___ + +### decodeResult + +▸ **decodeResult**(`resultHexstring`, `expectedReturnType`): [`DecodedResult`](README.md#decodedresult) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `resultHexstring` | `string` | +| `expectedReturnType` | [`ReturnType`](enums/ReturnType.md) | + +#### Returns + +[`DecodedResult`](README.md#decodedresult) + +#### Defined in + +[decodeResult.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/decodeResult.ts#L5) + +___ + +### deleteGist + +▸ **deleteGist**(`githubApiToken`, `gistURL`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `githubApiToken` | `string` | +| `gistURL` | `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Defined in + +[offchain_storage/github.ts:69](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/offchain_storage/github.ts#L69) + +___ + +### deployFunctionsOracle + +▸ **deployFunctionsOracle**(`deployer`): `Promise`<`FunctionsContracts`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `deployer` | `Wallet` | + +#### Returns + +`Promise`<`FunctionsContracts`\> + +#### Defined in + +[localFunctionsTestnet.ts:264](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L264) + +___ + +### simulateScript + +▸ **simulateScript**(`«destructured»`): `Promise`<[`SimulationResult`](README.md#simulationresult)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `«destructured»` | [`SimulationInput`](interfaces/SimulationInput.md) | + +#### Returns + +`Promise`<[`SimulationResult`](README.md#simulationresult)\> + +#### Defined in + +[simulateScript/simulateScript.ts:28](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/simulateScript/simulateScript.ts#L28) + +___ + +### startLocalFunctionsTestnet + +▸ **startLocalFunctionsTestnet**(`port?`): `Promise`<{ `adminWallet`: { `address`: `string` ; `privateKey`: `string` } ; `close`: () => `Promise`<`void`\> ; `getFunds`: (`address`: `string`, `__namedParameters`: { `ethAmount`: `number` ; `linkAmount`: `number` }) => `Promise`<`void`\> ; `server`: `Server`<`EthereumFlavor`\> } & `FunctionsContracts`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `port` | `number` | `8545` | + +#### Returns + +`Promise`<{ `adminWallet`: { `address`: `string` ; `privateKey`: `string` } ; `close`: () => `Promise`<`void`\> ; `getFunds`: (`address`: `string`, `__namedParameters`: { `ethAmount`: `number` ; `linkAmount`: `number` }) => `Promise`<`void`\> ; `server`: `Server`<`EthereumFlavor`\> } & `FunctionsContracts`\> + +#### Defined in + +[localFunctionsTestnet.ts:50](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L50) diff --git a/docs/classes/ResponseListener.md b/docs/classes/ResponseListener.md index 29c5536..7c8ab55 100644 --- a/docs/classes/ResponseListener.md +++ b/docs/classes/ResponseListener.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / ResponseListener +[@chainlink/functions-toolkit](../README.md) / ResponseListener # Class: ResponseListener @@ -34,7 +34,7 @@ #### Defined in -[ResponseListener.ts:12](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L12) +[ResponseListener.ts:12](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/ResponseListener.ts#L12) ## Properties @@ -44,13 +44,13 @@ #### Defined in -[ResponseListener.ts:10](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L10) +[ResponseListener.ts:10](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/ResponseListener.ts#L10) ## Methods ### listenForResponse -▸ **listenForResponse**(`requestId`, `timeout?`): `Promise`<[`FunctionsResponse`](../modules.md#functionsresponse)\> +▸ **listenForResponse**(`requestId`, `timeout?`): `Promise`<[`FunctionsResponse`](../README.md#functionsresponse)\> #### Parameters @@ -61,11 +61,11 @@ #### Returns -`Promise`<[`FunctionsResponse`](../modules.md#functionsresponse)\> +`Promise`<[`FunctionsResponse`](../README.md#functionsresponse)\> #### Defined in -[ResponseListener.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L22) +[ResponseListener.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/ResponseListener.ts#L22) ___ @@ -78,7 +78,7 @@ ___ | Name | Type | | :------ | :------ | | `subscriptionId` | `number` | -| `callback` | (`functionsResponse`: [`FunctionsResponse`](../modules.md#functionsresponse)) => `any` | +| `callback` | (`functionsResponse`: [`FunctionsResponse`](../README.md#functionsresponse)) => `any` | #### Returns @@ -86,7 +86,7 @@ ___ #### Defined in -[ResponseListener.ts:61](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L61) +[ResponseListener.ts:61](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/ResponseListener.ts#L61) ___ @@ -100,4 +100,4 @@ ___ #### Defined in -[ResponseListener.ts:96](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/ResponseListener.ts#L96) +[ResponseListener.ts:96](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/ResponseListener.ts#L96) diff --git a/docs/classes/SecretsManager.md b/docs/classes/SecretsManager.md index 2b47671..d13871e 100644 --- a/docs/classes/SecretsManager.md +++ b/docs/classes/SecretsManager.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / SecretsManager +[@chainlink/functions-toolkit](../README.md) / SecretsManager # Class: SecretsManager @@ -51,7 +51,7 @@ #### Defined in -[SecretsManager.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L27) +[SecretsManager.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L27) ## Properties @@ -61,7 +61,7 @@ #### Defined in -[SecretsManager.ts:24](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L24) +[SecretsManager.ts:24](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L24) ___ @@ -71,7 +71,7 @@ ___ #### Defined in -[SecretsManager.ts:23](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L23) +[SecretsManager.ts:23](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L23) ___ @@ -81,7 +81,7 @@ ___ #### Defined in -[SecretsManager.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L22) +[SecretsManager.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L22) ___ @@ -91,7 +91,7 @@ ___ #### Defined in -[SecretsManager.ts:25](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L25) +[SecretsManager.ts:25](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L25) ___ @@ -101,7 +101,7 @@ ___ #### Defined in -[SecretsManager.ts:21](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L21) +[SecretsManager.ts:21](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L21) ## Methods @@ -123,7 +123,7 @@ ___ #### Defined in -[SecretsManager.ts:464](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L464) +[SecretsManager.ts:464](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L464) ___ @@ -135,7 +135,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`GatewayMessageConfig`](../modules.md#gatewaymessageconfig) | +| `«destructured»` | [`GatewayMessageConfig`](../README.md#gatewaymessageconfig) | #### Returns @@ -143,7 +143,7 @@ ___ #### Defined in -[SecretsManager.ts:317](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L317) +[SecretsManager.ts:317](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L317) ___ @@ -155,7 +155,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`GatewayMessageBody`](../modules.md#gatewaymessagebody) | +| `«destructured»` | [`GatewayMessageBody`](../README.md#gatewaymessagebody) | #### Returns @@ -163,7 +163,7 @@ ___ #### Defined in -[SecretsManager.ts:343](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L343) +[SecretsManager.ts:343](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L343) ___ @@ -183,7 +183,7 @@ ___ #### Defined in -[SecretsManager.ts:141](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L141) +[SecretsManager.ts:141](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L141) ___ @@ -203,13 +203,13 @@ ___ #### Defined in -[SecretsManager.ts:92](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L92) +[SecretsManager.ts:92](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L92) ___ ### extractNodeResponses -▸ `Private` **extractNodeResponses**(`gatewayResponse`): [`NodeResponse`](../modules.md#noderesponse)[] +▸ `Private` **extractNodeResponses**(`gatewayResponse`): [`NodeResponse`](../README.md#noderesponse)[] #### Parameters @@ -219,27 +219,27 @@ ___ #### Returns -[`NodeResponse`](../modules.md#noderesponse)[] +[`NodeResponse`](../README.md#noderesponse)[] #### Defined in -[SecretsManager.ts:381](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L381) +[SecretsManager.ts:381](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L381) ___ ### fetchKeys -▸ **fetchKeys**(): `Promise`<{ `donPublicKey`: `string` ; `thresholdPublicKey`: [`ThresholdPublicKey`](../modules.md#thresholdpublickey) }\> +▸ **fetchKeys**(): `Promise`<{ `donPublicKey`: `string` ; `thresholdPublicKey`: [`ThresholdPublicKey`](../README.md#thresholdpublickey) }\> #### Returns -`Promise`<{ `donPublicKey`: `string` ; `thresholdPublicKey`: [`ThresholdPublicKey`](../modules.md#thresholdpublickey) }\> +`Promise`<{ `donPublicKey`: `string` ; `thresholdPublicKey`: [`ThresholdPublicKey`](../README.md#thresholdpublickey) }\> a Promise that resolves to an object that contains the DONpublicKey and an object that maps node addresses to their public keys #### Defined in -[SecretsManager.ts:76](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L76) +[SecretsManager.ts:76](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L76) ___ @@ -253,7 +253,7 @@ ___ #### Defined in -[SecretsManager.ts:46](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L46) +[SecretsManager.ts:46](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L46) ___ @@ -267,13 +267,13 @@ ___ #### Defined in -[SecretsManager.ts:67](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L67) +[SecretsManager.ts:67](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L67) ___ ### listDONHostedEncryptedSecrets -▸ **listDONHostedEncryptedSecrets**(`gatewayUrls`): `Promise`<{ `error?`: `string` ; `result`: [`GatewayResponse`](../modules.md#gatewayresponse)[] }\> +▸ **listDONHostedEncryptedSecrets**(`gatewayUrls`): `Promise`<{ `error?`: `string` ; `result`: [`GatewayResponse`](../README.md#gatewayresponse)[] }\> #### Parameters @@ -283,31 +283,31 @@ ___ #### Returns -`Promise`<{ `error?`: `string` ; `result`: [`GatewayResponse`](../modules.md#gatewayresponse)[] }\> +`Promise`<{ `error?`: `string` ; `result`: [`GatewayResponse`](../README.md#gatewayresponse)[] }\> #### Defined in -[SecretsManager.ts:403](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L403) +[SecretsManager.ts:403](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L403) ___ ### sendMessageToGateways -▸ `Private` **sendMessageToGateways**(`gatewayRpcMessageConfig`): `Promise`<[`GatewayResponse`](../modules.md#gatewayresponse)[]\> +▸ `Private` **sendMessageToGateways**(`gatewayRpcMessageConfig`): `Promise`<[`GatewayResponse`](../README.md#gatewayresponse)[]\> #### Parameters | Name | Type | | :------ | :------ | -| `gatewayRpcMessageConfig` | [`GatewayMessageConfig`](../modules.md#gatewaymessageconfig) | +| `gatewayRpcMessageConfig` | [`GatewayMessageConfig`](../README.md#gatewaymessageconfig) | #### Returns -`Promise`<[`GatewayResponse`](../modules.md#gatewayresponse)[]\> +`Promise`<[`GatewayResponse`](../README.md#gatewayresponse)[]\> #### Defined in -[SecretsManager.ts:284](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L284) +[SecretsManager.ts:284](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L284) ___ @@ -331,7 +331,7 @@ ___ #### Defined in -[SecretsManager.ts:186](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L186) +[SecretsManager.ts:186](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L186) ___ @@ -351,7 +351,7 @@ ___ #### Defined in -[SecretsManager.ts:270](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L270) +[SecretsManager.ts:270](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L270) ___ @@ -363,7 +363,7 @@ ___ | Name | Type | | :------ | :------ | -| `gatewayResponses` | [`GatewayResponse`](../modules.md#gatewayresponse)[] | +| `gatewayResponses` | [`GatewayResponse`](../README.md#gatewayresponse)[] | #### Returns @@ -371,7 +371,7 @@ ___ #### Defined in -[SecretsManager.ts:423](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L423) +[SecretsManager.ts:423](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L423) ___ @@ -391,4 +391,4 @@ ___ #### Defined in -[SecretsManager.ts:109](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SecretsManager.ts#L109) +[SecretsManager.ts:109](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SecretsManager.ts#L109) diff --git a/docs/classes/SubscriptionManager.md b/docs/classes/SubscriptionManager.md index 68d35cf..b8d54fd 100644 --- a/docs/classes/SubscriptionManager.md +++ b/docs/classes/SubscriptionManager.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / SubscriptionManager +[@chainlink/functions-toolkit](../README.md) / SubscriptionManager # Class: SubscriptionManager @@ -49,7 +49,7 @@ #### Defined in -[SubscriptionManager.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L32) +[SubscriptionManager.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L32) ## Properties @@ -59,7 +59,7 @@ #### Defined in -[SubscriptionManager.ts:29](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L29) +[SubscriptionManager.ts:29](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L29) ___ @@ -69,7 +69,7 @@ ___ #### Defined in -[SubscriptionManager.ts:28](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L28) +[SubscriptionManager.ts:28](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L28) ___ @@ -79,7 +79,7 @@ ___ #### Defined in -[SubscriptionManager.ts:30](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L30) +[SubscriptionManager.ts:30](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L30) ___ @@ -89,7 +89,7 @@ ___ #### Defined in -[SubscriptionManager.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L27) +[SubscriptionManager.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L27) ___ @@ -99,7 +99,7 @@ ___ #### Defined in -[SubscriptionManager.ts:26](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L26) +[SubscriptionManager.ts:26](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L26) ## Methods @@ -111,7 +111,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`SubTransferAcceptConfig`](../modules.md#subtransferacceptconfig) | +| `«destructured»` | [`SubTransferAcceptConfig`](../README.md#subtransferacceptconfig) | #### Returns @@ -119,7 +119,7 @@ ___ #### Defined in -[SubscriptionManager.ts:414](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L414) +[SubscriptionManager.ts:414](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L414) ___ @@ -131,7 +131,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`SubConsumerConfig`](../modules.md#subconsumerconfig) | +| `«destructured»` | [`SubConsumerConfig`](../README.md#subconsumerconfig) | #### Returns @@ -139,7 +139,7 @@ ___ #### Defined in -[SubscriptionManager.ts:136](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L136) +[SubscriptionManager.ts:136](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L136) ___ @@ -151,7 +151,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`SubCancelConfig`](../modules.md#subcancelconfig) | +| `«destructured»` | [`SubCancelConfig`](../README.md#subcancelconfig) | #### Returns @@ -159,7 +159,7 @@ ___ #### Defined in -[SubscriptionManager.ts:270](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L270) +[SubscriptionManager.ts:270](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L270) ___ @@ -171,7 +171,7 @@ ___ | Name | Type | | :------ | :------ | -| `subCreateConfig?` | [`SubCreateConfig`](../modules.md#subcreateconfig) | +| `subCreateConfig?` | [`SubCreateConfig`](../README.md#subcreateconfig) | #### Returns @@ -179,7 +179,7 @@ ___ #### Defined in -[SubscriptionManager.ts:93](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L93) +[SubscriptionManager.ts:93](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L93) ___ @@ -191,7 +191,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`EstimateCostConfig`](../modules.md#estimatecostconfig) | +| `«destructured»` | [`EstimateCostConfig`](../README.md#estimatecostconfig) | #### Returns @@ -199,7 +199,7 @@ ___ #### Defined in -[SubscriptionManager.ts:471](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L471) +[SubscriptionManager.ts:471](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L471) ___ @@ -211,7 +211,7 @@ ___ | Name | Type | | :------ | :------ | -| `config` | [`SubFundConfig`](../modules.md#subfundconfig) | +| `config` | [`SubFundConfig`](../README.md#subfundconfig) | #### Returns @@ -219,13 +219,13 @@ ___ #### Defined in -[SubscriptionManager.ts:188](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L188) +[SubscriptionManager.ts:188](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L188) ___ ### getSubscriptionInfo -▸ **getSubscriptionInfo**(`subscriptionId`): `Promise`<[`SubscriptionInfo`](../modules.md#subscriptioninfo)\> +▸ **getSubscriptionInfo**(`subscriptionId`): `Promise`<[`SubscriptionInfo`](../README.md#subscriptioninfo)\> #### Parameters @@ -235,11 +235,11 @@ ___ #### Returns -`Promise`<[`SubscriptionInfo`](../modules.md#subscriptioninfo)\> +`Promise`<[`SubscriptionInfo`](../README.md#subscriptioninfo)\> #### Defined in -[SubscriptionManager.ts:248](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L248) +[SubscriptionManager.ts:248](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L248) ___ @@ -253,7 +253,7 @@ ___ #### Defined in -[SubscriptionManager.ts:51](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L51) +[SubscriptionManager.ts:51](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L51) ___ @@ -273,7 +273,7 @@ ___ #### Defined in -[SubscriptionManager.ts:83](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L83) +[SubscriptionManager.ts:83](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L83) ___ @@ -287,7 +287,7 @@ ___ #### Defined in -[SubscriptionManager.ts:75](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L75) +[SubscriptionManager.ts:75](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L75) ___ @@ -299,7 +299,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`SubConsumerConfig`](../modules.md#subconsumerconfig) | +| `«destructured»` | [`SubConsumerConfig`](../README.md#subconsumerconfig) | #### Returns @@ -307,7 +307,7 @@ ___ #### Defined in -[SubscriptionManager.ts:318](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L318) +[SubscriptionManager.ts:318](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L318) ___ @@ -319,7 +319,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`SubTransferConfig`](../modules.md#subtransferconfig) | +| `«destructured»` | [`SubTransferConfig`](../README.md#subtransferconfig) | #### Returns @@ -327,7 +327,7 @@ ___ #### Defined in -[SubscriptionManager.ts:370](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L370) +[SubscriptionManager.ts:370](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L370) ___ @@ -339,7 +339,7 @@ ___ | Name | Type | | :------ | :------ | -| `«destructured»` | [`SubTimeoutConfig`](../modules.md#subtimeoutconfig) | +| `«destructured»` | [`SubTimeoutConfig`](../README.md#subtimeoutconfig) | #### Returns @@ -347,4 +347,4 @@ ___ #### Defined in -[SubscriptionManager.ts:447](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/SubscriptionManager.ts#L447) +[SubscriptionManager.ts:447](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/SubscriptionManager.ts#L447) diff --git a/docs/enums/CodeLanguage.md b/docs/enums/CodeLanguage.md index b7a9ce3..8f624a0 100644 --- a/docs/enums/CodeLanguage.md +++ b/docs/enums/CodeLanguage.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / CodeLanguage +[@chainlink/functions-toolkit](../README.md) / CodeLanguage # Enumeration: CodeLanguage @@ -16,4 +16,4 @@ #### Defined in -[types.ts:10](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L10) +[types.ts:10](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L10) diff --git a/docs/enums/FulfillmentCode.md b/docs/enums/FulfillmentCode.md index 43e9e3f..c01236d 100644 --- a/docs/enums/FulfillmentCode.md +++ b/docs/enums/FulfillmentCode.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / FulfillmentCode +[@chainlink/functions-toolkit](../README.md) / FulfillmentCode # Enumeration: FulfillmentCode @@ -22,7 +22,7 @@ #### Defined in -[types.ts:165](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L165) +[types.ts:165](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L165) ___ @@ -32,7 +32,7 @@ ___ #### Defined in -[types.ts:162](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L162) +[types.ts:162](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L162) ___ @@ -42,7 +42,7 @@ ___ #### Defined in -[types.ts:166](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L166) +[types.ts:166](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L166) ___ @@ -52,7 +52,7 @@ ___ #### Defined in -[types.ts:168](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L168) +[types.ts:168](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L168) ___ @@ -62,7 +62,7 @@ ___ #### Defined in -[types.ts:164](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L164) +[types.ts:164](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L164) ___ @@ -72,7 +72,7 @@ ___ #### Defined in -[types.ts:167](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L167) +[types.ts:167](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L167) ___ @@ -82,4 +82,4 @@ ___ #### Defined in -[types.ts:163](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L163) +[types.ts:163](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L163) diff --git a/docs/enums/Location.md b/docs/enums/Location.md index a23a549..6ba6952 100644 --- a/docs/enums/Location.md +++ b/docs/enums/Location.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / Location +[@chainlink/functions-toolkit](../README.md) / Location # Enumeration: Location @@ -18,7 +18,7 @@ #### Defined in -[types.ts:6](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L6) +[types.ts:6](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L6) ___ @@ -28,7 +28,7 @@ ___ #### Defined in -[types.ts:4](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L4) +[types.ts:4](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L4) ___ @@ -38,4 +38,4 @@ ___ #### Defined in -[types.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L5) +[types.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L5) diff --git a/docs/enums/ReturnType.md b/docs/enums/ReturnType.md index a63d2bb..43ab43d 100644 --- a/docs/enums/ReturnType.md +++ b/docs/enums/ReturnType.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / ReturnType +[@chainlink/functions-toolkit](../README.md) / ReturnType # Enumeration: ReturnType @@ -21,7 +21,7 @@ #### Defined in -[types.ts:19](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L19) +[types.ts:19](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L19) ___ @@ -31,7 +31,7 @@ ___ #### Defined in -[types.ts:16](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L16) +[types.ts:16](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L16) ___ @@ -41,7 +41,7 @@ ___ #### Defined in -[types.ts:17](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L17) +[types.ts:17](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L17) ___ @@ -51,7 +51,7 @@ ___ #### Defined in -[types.ts:18](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L18) +[types.ts:18](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L18) ___ @@ -61,7 +61,7 @@ ___ #### Defined in -[types.ts:14](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L14) +[types.ts:14](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L14) ___ @@ -71,4 +71,4 @@ ___ #### Defined in -[types.ts:15](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L15) +[types.ts:15](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L15) diff --git a/docs/interfaces/RequestEventData.md b/docs/interfaces/RequestEventData.md index 86c0d3c..dd3f115 100644 --- a/docs/interfaces/RequestEventData.md +++ b/docs/interfaces/RequestEventData.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / RequestEventData +[@chainlink/functions-toolkit](../README.md) / RequestEventData # Interface: RequestEventData @@ -25,17 +25,17 @@ #### Defined in -[localFunctionsTestnet.ts:39](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L39) +[localFunctionsTestnet.ts:39](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L39) ___ ### commitment -• **commitment**: [`RequestCommitment`](../modules.md#requestcommitment) +• **commitment**: [`RequestCommitment`](../README.md#requestcommitment) #### Defined in -[localFunctionsTestnet.ts:40](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L40) +[localFunctionsTestnet.ts:40](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L40) ___ @@ -45,7 +45,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:36](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L36) +[localFunctionsTestnet.ts:36](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L36) ___ @@ -55,7 +55,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:37](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L37) +[localFunctionsTestnet.ts:37](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L37) ___ @@ -65,7 +65,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:38](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L38) +[localFunctionsTestnet.ts:38](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L38) ___ @@ -75,7 +75,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:31](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L31) +[localFunctionsTestnet.ts:31](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L31) ___ @@ -85,7 +85,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:33](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L33) +[localFunctionsTestnet.ts:33](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L33) ___ @@ -95,7 +95,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L32) +[localFunctionsTestnet.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L32) ___ @@ -105,7 +105,7 @@ ___ #### Defined in -[localFunctionsTestnet.ts:34](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L34) +[localFunctionsTestnet.ts:34](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L34) ___ @@ -115,4 +115,4 @@ ___ #### Defined in -[localFunctionsTestnet.ts:35](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L35) +[localFunctionsTestnet.ts:35](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/localFunctionsTestnet.ts#L35) diff --git a/docs/interfaces/SimulationInput.md b/docs/interfaces/SimulationInput.md index 90df9e8..5661ec3 100644 --- a/docs/interfaces/SimulationInput.md +++ b/docs/interfaces/SimulationInput.md @@ -1,4 +1,4 @@ -[@chainlink/functions-toolkit](../README.md) / [Exports](../modules.md) / SimulationInput +[@chainlink/functions-toolkit](../README.md) / SimulationInput # Interface: SimulationInput @@ -27,7 +27,7 @@ #### Defined in -[types.ts:183](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L183) +[types.ts:183](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L183) ___ @@ -37,7 +37,7 @@ ___ #### Defined in -[types.ts:184](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L184) +[types.ts:184](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L184) ___ @@ -47,7 +47,7 @@ ___ #### Defined in -[types.ts:187](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L187) +[types.ts:187](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L187) ___ @@ -57,7 +57,7 @@ ___ #### Defined in -[types.ts:188](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L188) +[types.ts:188](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L188) ___ @@ -67,7 +67,7 @@ ___ #### Defined in -[types.ts:186](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L186) +[types.ts:186](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L186) ___ @@ -77,7 +77,7 @@ ___ #### Defined in -[types.ts:190](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L190) +[types.ts:190](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L190) ___ @@ -87,7 +87,7 @@ ___ #### Defined in -[types.ts:192](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L192) +[types.ts:192](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L192) ___ @@ -97,7 +97,7 @@ ___ #### Defined in -[types.ts:193](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L193) +[types.ts:193](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L193) ___ @@ -107,7 +107,7 @@ ___ #### Defined in -[types.ts:191](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L191) +[types.ts:191](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L191) ___ @@ -117,7 +117,7 @@ ___ #### Defined in -[types.ts:189](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L189) +[types.ts:189](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L189) ___ @@ -127,7 +127,7 @@ ___ #### Defined in -[types.ts:185](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L185) +[types.ts:185](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L185) ___ @@ -137,4 +137,4 @@ ___ #### Defined in -[types.ts:182](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L182) +[types.ts:182](https://github.com/smartcontractkit/functions-toolkit/blob/1164b15/src/types.ts#L182) diff --git a/docs/modules.md b/docs/modules.md deleted file mode 100644 index 657d5ac..0000000 --- a/docs/modules.md +++ /dev/null @@ -1,891 +0,0 @@ -[@chainlink/functions-toolkit](README.md) / Exports - -# @chainlink/functions-toolkit - -## Table of contents - -### Enumerations - -- [CodeLanguage](enums/CodeLanguage.md) -- [FulfillmentCode](enums/FulfillmentCode.md) -- [Location](enums/Location.md) -- [ReturnType](enums/ReturnType.md) - -### Classes - -- [ResponseListener](classes/ResponseListener.md) -- [SecretsManager](classes/SecretsManager.md) -- [SubscriptionManager](classes/SubscriptionManager.md) - -### Interfaces - -- [RequestEventData](interfaces/RequestEventData.md) -- [SimulationInput](interfaces/SimulationInput.md) - -### Type Aliases - -- [DONStoragePayload](modules.md#donstoragepayload) -- [DecodedResult](modules.md#decodedresult) -- [EncryptedSecretsEntry](modules.md#encryptedsecretsentry) -- [EstimateCostConfig](modules.md#estimatecostconfig) -- [FunctionsRequestParams](modules.md#functionsrequestparams) -- [FunctionsResponse](modules.md#functionsresponse) -- [GatewayMessage](modules.md#gatewaymessage) -- [GatewayMessageBody](modules.md#gatewaymessagebody) -- [GatewayMessageConfig](modules.md#gatewaymessageconfig) -- [GatewayResponse](modules.md#gatewayresponse) -- [NodeResponse](modules.md#noderesponse) -- [RequestCommitment](modules.md#requestcommitment) -- [SimulationResult](modules.md#simulationresult) -- [SubCancelConfig](modules.md#subcancelconfig) -- [SubConsumerConfig](modules.md#subconsumerconfig) -- [SubCreateConfig](modules.md#subcreateconfig) -- [SubFundConfig](modules.md#subfundconfig) -- [SubTimeoutConfig](modules.md#subtimeoutconfig) -- [SubTransferAcceptConfig](modules.md#subtransferacceptconfig) -- [SubTransferConfig](modules.md#subtransferconfig) -- [SubscriptionInfo](modules.md#subscriptioninfo) -- [ThresholdPublicKey](modules.md#thresholdpublickey) -- [TransactionOptions](modules.md#transactionoptions) - -### Variables - -- [DEFAULT\_MAX\_EXECUTION\_DURATION\_MS](modules.md#default_max_execution_duration_ms) -- [DEFAULT\_MAX\_HTTP\_REQUESTS](modules.md#default_max_http_requests) -- [DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES](modules.md#default_max_http_request_bytes) -- [DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS](modules.md#default_max_http_request_duration_ms) -- [DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH](modules.md#default_max_http_request_url_length) -- [DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES](modules.md#default_max_http_response_bytes) -- [DEFAULT\_MAX\_MEMORY\_USAGE\_MB](modules.md#default_max_memory_usage_mb) -- [DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES](modules.md#default_max_on_chain_response_bytes) -- [callReportGasLimit](modules.md#callreportgaslimit) -- [simulatedAllowListConfig](modules.md#simulatedallowlistconfig) -- [simulatedAllowListId](modules.md#simulatedallowlistid) -- [simulatedCoordinatorConfig](modules.md#simulatedcoordinatorconfig) -- [simulatedDonId](modules.md#simulateddonid) -- [simulatedLinkEthPrice](modules.md#simulatedlinkethprice) -- [simulatedRouterConfig](modules.md#simulatedrouterconfig) -- [simulatedSecretsKeys](modules.md#simulatedsecretskeys) -- [simulatedTransmitters](modules.md#simulatedtransmitters) -- [simulatedWallets](modules.md#simulatedwallets) - -### Functions - -- [buildRequestCBOR](modules.md#buildrequestcbor) -- [createGist](modules.md#creategist) -- [decodeResult](modules.md#decoderesult) -- [deleteGist](modules.md#deletegist) -- [deployFunctionsOracle](modules.md#deployfunctionsoracle) -- [simulateScript](modules.md#simulatescript) -- [startLocalFunctionsTestnet](modules.md#startlocalfunctionstestnet) - -## Type Aliases - -### DONStoragePayload - -Ƭ **DONStoragePayload**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `expiration` | `number` | -| `payload` | `string` | -| `signature` | `string` | -| `slot_id` | `number` | -| `version` | `number` | - -#### Defined in - -[types.ts:112](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L112) - -___ - -### DecodedResult - -Ƭ **DecodedResult**: `BigInt` \| `string` - -#### Defined in - -[decodeResult.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/decodeResult.ts#L3) - -___ - -### EncryptedSecretsEntry - -Ƭ **EncryptedSecretsEntry**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `expiration` | `number` | -| `slot_id` | `number` | -| `version` | `number` | - -#### Defined in - -[types.ts:145](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L145) - -___ - -### EstimateCostConfig - -Ƭ **EstimateCostConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `callbackGasLimit` | `number` | -| `donId` | `string` | -| `gasPriceGwei` | `BigInt` | -| `subscriptionId` | `BigInt` \| `number` \| `string` | - -#### Defined in - -[types.ts:82](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L82) - -___ - -### FunctionsRequestParams - -Ƭ **FunctionsRequestParams**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `args?` | `string`[] | -| `bytesArgs?` | `string`[] | -| `codeLanguage` | [`CodeLanguage`](enums/CodeLanguage.md) | -| `codeLocation` | [`Location`](enums/Location.md) | -| `encryptedSecretsReference?` | `string` | -| `secretsLocation?` | [`Location`](enums/Location.md) | -| `source` | `string` | - -#### Defined in - -[types.ts:22](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L22) - -___ - -### FunctionsResponse - -Ƭ **FunctionsResponse**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `errorString` | `string` | -| `fulfillmentCode` | [`FulfillmentCode`](enums/FulfillmentCode.md) | -| `requestId` | `string` | -| `responseBytesHexstring` | `string` | -| `returnDataBytesHexstring` | `string` | -| `subscriptionId` | `number` | -| `totalCostInJuels` | `BigInt` | - -#### Defined in - -[types.ts:171](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L171) - -___ - -### GatewayMessage - -Ƭ **GatewayMessage**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `id` | `string` | -| `jsonrpc` | ``"2.0"`` | -| `method` | `string` | -| `params` | { `body`: [`GatewayMessageBody`](modules.md#gatewaymessagebody) ; `signature`: `string` } | -| `params.body` | [`GatewayMessageBody`](modules.md#gatewaymessagebody) | -| `params.signature` | `string` | - -#### Defined in - -[types.ts:135](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L135) - -___ - -### GatewayMessageBody - -Ƭ **GatewayMessageBody**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `don_id` | `string` | -| `message_id` | `string` | -| `method` | `string` | -| `payload?` | [`DONStoragePayload`](modules.md#donstoragepayload) | -| `receiver` | `string` | - -#### Defined in - -[types.ts:127](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L127) - -___ - -### GatewayMessageConfig - -Ƭ **GatewayMessageConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `don_id` | `string` | -| `gatewayUrls` | `string`[] | -| `method` | `string` | -| `payload?` | [`DONStoragePayload`](modules.md#donstoragepayload) | - -#### Defined in - -[types.ts:120](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L120) - -___ - -### GatewayResponse - -Ƭ **GatewayResponse**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `gatewayUrl` | `string` | -| `nodeResponses` | [`NodeResponse`](modules.md#noderesponse)[] | - -#### Defined in - -[types.ts:156](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L156) - -___ - -### NodeResponse - -Ƭ **NodeResponse**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `rows?` | [`EncryptedSecretsEntry`](modules.md#encryptedsecretsentry)[] | -| `success` | `boolean` | - -#### Defined in - -[types.ts:151](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L151) - -___ - -### RequestCommitment - -Ƭ **RequestCommitment**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `adminFee` | `BigInt` | -| `callbackGasLimit` | `BigInt` | -| `client` | `string` | -| `coordinator` | `string` | -| `donFee` | `BigInt` | -| `estimatedTotalCostJuels` | `BigInt` | -| `gasOverheadAfterCallback` | `BigInt` | -| `gasOverheadBeforeCallback` | `BigInt` | -| `requestId` | `string` | -| `subscriptionId` | `number` | -| `timeoutTimestamp` | `BigInt` | - -#### Defined in - -[types.ts:98](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L98) - -___ - -### SimulationResult - -Ƭ **SimulationResult**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `capturedTerminalOutput` | `string` | -| `errorString?` | `string` | -| `responseBytesHexstring?` | `string` | - -#### Defined in - -[types.ts:196](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L196) - -___ - -### SubCancelConfig - -Ƭ **SubCancelConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `refundAddress?` | `string` | -| `subscriptionId` | `BigInt` \| `number` \| `string` | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:61](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L61) - -___ - -### SubConsumerConfig - -Ƭ **SubConsumerConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `consumerAddress` | `string` | -| `subscriptionId` | `BigInt` \| `number` \| `string` | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:49](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L49) - -___ - -### SubCreateConfig - -Ƭ **SubCreateConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `consumerAddress?` | `string` | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:44](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L44) - -___ - -### SubFundConfig - -Ƭ **SubFundConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `juelsAmount` | `BigInt` \| `string` | -| `subscriptionId` | `BigInt` \| `number` \| `string` | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:55](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L55) - -___ - -### SubTimeoutConfig - -Ƭ **SubTimeoutConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `requestCommitments` | [`RequestCommitment`](modules.md#requestcommitment)[] | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:77](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L77) - -___ - -### SubTransferAcceptConfig - -Ƭ **SubTransferAcceptConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `subscriptionId` | `BigInt` \| `number` \| `string` | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:72](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L72) - -___ - -### SubTransferConfig - -Ƭ **SubTransferConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `newOwner` | `string` | -| `subscriptionId` | `BigInt` \| `number` \| `string` | -| `txOptions?` | [`TransactionOptions`](modules.md#transactionoptions) | - -#### Defined in - -[types.ts:66](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L66) - -___ - -### SubscriptionInfo - -Ƭ **SubscriptionInfo**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `balance` | `BigInt` | -| `blockedBalance` | `BigInt` | -| `consumers` | `string`[] | -| `flags` | `string` | -| `owner` | `string` | -| `proposedOwner` | `string` | - -#### Defined in - -[types.ts:89](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L89) - -___ - -### ThresholdPublicKey - -Ƭ **ThresholdPublicKey**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `G_bar` | `string` | -| `Group` | `string` | -| `H` | `string` | -| `HArray` | `string`[] | - -#### Defined in - -[types.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L32) - -___ - -### TransactionOptions - -Ƭ **TransactionOptions**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `confirmations?` | `number` | -| `overrides?` | `Overrides` | - -#### Defined in - -[types.ts:39](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/types.ts#L39) - -## Variables - -### DEFAULT\_MAX\_EXECUTION\_DURATION\_MS - -• `Const` **DEFAULT\_MAX\_EXECUTION\_DURATION\_MS**: ``10000`` - -#### Defined in - -[simulationConfig.ts:84](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L84) - -___ - -### DEFAULT\_MAX\_HTTP\_REQUESTS - -• `Const` **DEFAULT\_MAX\_HTTP\_REQUESTS**: ``5`` - -#### Defined in - -[simulationConfig.ts:86](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L86) - -___ - -### DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES - -• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_BYTES**: ``2048`` - -#### Defined in - -[simulationConfig.ts:89](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L89) - -___ - -### DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS - -• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_DURATION\_MS**: ``9000`` - -#### Defined in - -[simulationConfig.ts:87](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L87) - -___ - -### DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH - -• `Const` **DEFAULT\_MAX\_HTTP\_REQUEST\_URL\_LENGTH**: ``2048`` - -#### Defined in - -[simulationConfig.ts:88](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L88) - -___ - -### DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES - -• `Const` **DEFAULT\_MAX\_HTTP\_RESPONSE\_BYTES**: ``2097152`` - -#### Defined in - -[simulationConfig.ts:90](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L90) - -___ - -### DEFAULT\_MAX\_MEMORY\_USAGE\_MB - -• `Const` **DEFAULT\_MAX\_MEMORY\_USAGE\_MB**: ``128`` - -#### Defined in - -[simulationConfig.ts:85](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L85) - -___ - -### DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES - -• `Const` **DEFAULT\_MAX\_ON\_CHAIN\_RESPONSE\_BYTES**: ``256`` - -#### Defined in - -[simulationConfig.ts:83](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L83) - -___ - -### callReportGasLimit - -• `Const` **callReportGasLimit**: ``5000000`` - -#### Defined in - -[simulationConfig.ts:32](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L32) - -___ - -### simulatedAllowListConfig - -• `Const` **simulatedAllowListConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `enabled` | `boolean` | -| `signerPublicKey` | `string` | - -#### Defined in - -[simulationConfig.ts:27](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L27) - -___ - -### simulatedAllowListId - -• `Const` **simulatedAllowListId**: ``"allowlist1"`` - -#### Defined in - -[simulationConfig.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L5) - -___ - -### simulatedCoordinatorConfig - -• `Const` **simulatedCoordinatorConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `donFee` | `number` | -| `fallbackNativePerUnitLink` | `bigint` | -| `feedStalenessSeconds` | `number` | -| `fulfillmentGasPriceOverEstimationBP` | `number` | -| `gasOverheadAfterCallback` | `number` | -| `gasOverheadBeforeCallback` | `number` | -| `maxCallbackGasLimit` | `number` | -| `maxSupportedRequestDataVersion` | `number` | -| `requestTimeoutSeconds` | `number` | - -#### Defined in - -[simulationConfig.ts:15](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L15) - -___ - -### simulatedDonId - -• `Const` **simulatedDonId**: ``"coordinator1"`` - -#### Defined in - -[simulationConfig.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L3) - -___ - -### simulatedLinkEthPrice - -• `Const` **simulatedLinkEthPrice**: `bigint` - -#### Defined in - -[simulationConfig.ts:1](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L1) - -___ - -### simulatedRouterConfig - -• `Const` **simulatedRouterConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `adminFee` | `number` | -| `gasForCallExactCheck` | `number` | -| `handleOracleFulfillmentSelector` | `string` | -| `maxCallbackGasLimits` | `number`[] | -| `maxConsumersPerSubscription` | `number` | - -#### Defined in - -[simulationConfig.ts:7](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L7) - -___ - -### simulatedSecretsKeys - -• `Const` **simulatedSecretsKeys**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `donKey` | { `privateKey`: `string` ; `publicKey`: `string` } | -| `donKey.privateKey` | `string` | -| `donKey.publicKey` | `string` | -| `thresholdKeys` | { `privateKeyShares`: { `[address: string]`: `string`; } ; `publicKey`: `string` } | -| `thresholdKeys.privateKeyShares` | { `[address: string]`: `string`; } | -| `thresholdKeys.publicKey` | `string` | - -#### Defined in - -[simulationConfig.ts:55](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L55) - -___ - -### simulatedTransmitters - -• `Const` **simulatedTransmitters**: `string`[] - -#### Defined in - -[simulationConfig.ts:53](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L53) - -___ - -### simulatedWallets - -• `Const` **simulatedWallets**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `node0` | { `address`: `string` = '0xAe24F6e7e046a0C764DF51F333dE5e2fE360AC72'; `privateKey`: `string` = '0x493f20c367e9c5190b14b8071a6c765da973d41428b841c25e4aaba3577f8ece' } | -| `node0.address` | `string` | -| `node0.privateKey` | `string` | -| `node1` | { `address`: `string` = '0x37d7bf16f6fd8c37b766Fa87e047c68c51dfdf4a'; `privateKey`: `string` = '0x7abd90843922984dda18358a179679e5cabda5ad8d0ebab5714ac044663a6a14' } | -| `node1.address` | `string` | -| `node1.privateKey` | `string` | -| `node2` | { `address`: `string` = '0x6e7EF53D9811B70834902D2D9137DaD2720eAC47'; `privateKey`: `string` = '0xcb8801121add786869aac78ceb4003bf3aa8a68ae8dd31f80d61f5f98eace3c5' } | -| `node2.address` | `string` | -| `node2.privateKey` | `string` | -| `node3` | { `address`: `string` = '0xBe83eA9868AE964f8C46EFa0fea798EbE16441c5'; `privateKey`: `string` = '0x06c7ca21f24edf450251e87097264b1fd184c9570084a78aa3300e937e1954b8' } | -| `node3.address` | `string` | -| `node3.privateKey` | `string` | - -#### Defined in - -[simulationConfig.ts:34](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulationConfig.ts#L34) - -## Functions - -### buildRequestCBOR - -▸ **buildRequestCBOR**(`requestParams`): `string` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `requestParams` | [`FunctionsRequestParams`](modules.md#functionsrequestparams) | - -#### Returns - -`string` - -#### Defined in - -[buildRequestCBOR.ts:8](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/buildRequestCBOR.ts#L8) - -___ - -### createGist - -▸ **createGist**(`githubApiToken`, `content`): `Promise`<`string`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `githubApiToken` | `string` | -| `content` | `string` | - -#### Returns - -`Promise`<`string`\> - -#### Defined in - -[offchain_storage/github.ts:3](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/offchain_storage/github.ts#L3) - -___ - -### decodeResult - -▸ **decodeResult**(`resultHexstring`, `expectedReturnType`): [`DecodedResult`](modules.md#decodedresult) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `resultHexstring` | `string` | -| `expectedReturnType` | [`ReturnType`](enums/ReturnType.md) | - -#### Returns - -[`DecodedResult`](modules.md#decodedresult) - -#### Defined in - -[decodeResult.ts:5](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/decodeResult.ts#L5) - -___ - -### deleteGist - -▸ **deleteGist**(`githubApiToken`, `gistURL`): `Promise`<`boolean`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `githubApiToken` | `string` | -| `gistURL` | `string` | - -#### Returns - -`Promise`<`boolean`\> - -#### Defined in - -[offchain_storage/github.ts:69](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/offchain_storage/github.ts#L69) - -___ - -### deployFunctionsOracle - -▸ **deployFunctionsOracle**(`deployer`): `Promise`<`FunctionsContracts`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `deployer` | `Wallet` | - -#### Returns - -`Promise`<`FunctionsContracts`\> - -#### Defined in - -[localFunctionsTestnet.ts:264](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L264) - -___ - -### simulateScript - -▸ **simulateScript**(`«destructured»`): `Promise`<[`SimulationResult`](modules.md#simulationresult)\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `«destructured»` | [`SimulationInput`](interfaces/SimulationInput.md) | - -#### Returns - -`Promise`<[`SimulationResult`](modules.md#simulationresult)\> - -#### Defined in - -[simulateScript/simulateScript.ts:28](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/simulateScript/simulateScript.ts#L28) - -___ - -### startLocalFunctionsTestnet - -▸ **startLocalFunctionsTestnet**(`port?`): `Promise`<{ `adminWallet`: { `address`: `string` ; `privateKey`: `string` } ; `close`: () => `Promise`<`void`\> ; `getFunds`: (`address`: `string`, `__namedParameters`: { `ethAmount`: `number` ; `linkAmount`: `number` }) => `Promise`<`void`\> ; `server`: `Server`<`EthereumFlavor`\> } & `FunctionsContracts`\> - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `port` | `number` | `8545` | - -#### Returns - -`Promise`<{ `adminWallet`: { `address`: `string` ; `privateKey`: `string` } ; `close`: () => `Promise`<`void`\> ; `getFunds`: (`address`: `string`, `__namedParameters`: { `ethAmount`: `number` ; `linkAmount`: `number` }) => `Promise`<`void`\> ; `server`: `Server`<`EthereumFlavor`\> } & `FunctionsContracts`\> - -#### Defined in - -[localFunctionsTestnet.ts:50](https://github.com/smartcontractkit/functions-toolkit/blob/bbc061a/src/localFunctionsTestnet.ts#L50) diff --git a/package.json b/package.json index 6f73c73..e6dbdf6 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test:package": "jest --config jest.config.package.js", "lint": "prettier --check . && tsc --noEmit", "lint:fix": "npx prettier -w .", - "docgen": "typedoc --plugin typedoc-plugin-markdown" + "docgen": "typedoc --plugin typedoc-plugin-markdown --readme none" }, "repository": { "type": "git",