From 3a6a5bae75873c64d6a6648a81e852156738e833 Mon Sep 17 00:00:00 2001 From: Derek Croote Date: Sun, 5 Mar 2023 10:23:19 -0800 Subject: [PATCH] Combine airnode-examples http gateway integrations into one --- .changeset/silver-parents-design.md | 5 + packages/airnode-examples/README.md | 8 +- .../Requester.sol | 0 .../coingecko-testable/Requester.sol | 41 ---- .../README.md | 56 ++++- .../config.example.json | 12 +- .../create-config.ts | 12 +- .../create-secrets.ts | 0 .../request-utils.ts | 0 .../secrets.example.env | 0 .../integrations/coingecko-testable/README.md | 43 ---- .../coingecko-testable/config.example.json | 218 ---------------- .../coingecko-testable/create-config.ts | 232 ------------------ .../coingecko-testable/create-secrets.ts | 9 - .../coingecko-testable/request-utils.ts | 39 --- .../coingecko-testable/secrets.example.env | 2 - 16 files changed, 74 insertions(+), 603 deletions(-) create mode 100644 .changeset/silver-parents-design.md rename packages/airnode-examples/contracts/{coingecko-signed-data => coingecko-http-gateways}/Requester.sol (100%) delete mode 100644 packages/airnode-examples/contracts/coingecko-testable/Requester.sol rename packages/airnode-examples/integrations/{coingecko-signed-data => coingecko-http-gateways}/README.md (67%) rename packages/airnode-examples/integrations/{coingecko-signed-data => coingecko-http-gateways}/config.example.json (94%) rename packages/airnode-examples/integrations/{coingecko-signed-data => coingecko-http-gateways}/create-config.ts (95%) rename packages/airnode-examples/integrations/{coingecko-signed-data => coingecko-http-gateways}/create-secrets.ts (100%) rename packages/airnode-examples/integrations/{coingecko-signed-data => coingecko-http-gateways}/request-utils.ts (100%) rename packages/airnode-examples/integrations/{coingecko-signed-data => coingecko-http-gateways}/secrets.example.env (100%) delete mode 100644 packages/airnode-examples/integrations/coingecko-testable/README.md delete mode 100644 packages/airnode-examples/integrations/coingecko-testable/config.example.json delete mode 100644 packages/airnode-examples/integrations/coingecko-testable/create-config.ts delete mode 100644 packages/airnode-examples/integrations/coingecko-testable/create-secrets.ts delete mode 100644 packages/airnode-examples/integrations/coingecko-testable/request-utils.ts delete mode 100644 packages/airnode-examples/integrations/coingecko-testable/secrets.example.env diff --git a/.changeset/silver-parents-design.md b/.changeset/silver-parents-design.md new file mode 100644 index 0000000000..4ed17bb814 --- /dev/null +++ b/.changeset/silver-parents-design.md @@ -0,0 +1,5 @@ +--- +'@api3/airnode-examples': minor +--- + +Combine http gateway integrations into a single integration diff --git a/packages/airnode-examples/README.md b/packages/airnode-examples/README.md index b285c71aa0..af0414a880 100644 --- a/packages/airnode-examples/README.md +++ b/packages/airnode-examples/README.md @@ -42,13 +42,11 @@ reserved parameters. The following list orders integrations alphabetically: demonstration of the [post-processing](https://docs.api3.org/ois/latest/processing.html) feature. - [coingecko-pre-processing](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/coingecko-pre-processing) - demonstration of the [pre-processing](https://docs.api3.org/ois/latest/processing.html) feature. -- [coingecko-signed-data](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/coingecko-signed-data) - - demonstration of signed data retrieval for beacon updates. +- [coingecko-http-gateways](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/coingecko-http-gateways) - + demonstration of the + [HTTP gateway and HTTP signed data gateway](https://docs.api3.org/airnode/latest/grp-providers/guides/build-an-airnode/http-gateways.html). - [coingecko-template](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/coingecko-template) - demonstration of [template](https://docs.api3.org/airnode/latest/grp-developers/using-templates.html) requests. -- [coingecko-testable](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/coingecko-testable) - - demonstration of how to test the endpoint using the - [HTTP gateway](https://docs.api3.org/airnode/latest/grp-providers/guides/build-an-airnode/http-gateways.html). - [failing-example](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/failing-example) - demonstration of Airnode error handling through an invalid request. - [relay-security-schemes](https://github.com/api3dao/airnode/tree/master/packages/airnode-examples/integrations/relay-security-schemes) - diff --git a/packages/airnode-examples/contracts/coingecko-signed-data/Requester.sol b/packages/airnode-examples/contracts/coingecko-http-gateways/Requester.sol similarity index 100% rename from packages/airnode-examples/contracts/coingecko-signed-data/Requester.sol rename to packages/airnode-examples/contracts/coingecko-http-gateways/Requester.sol diff --git a/packages/airnode-examples/contracts/coingecko-testable/Requester.sol b/packages/airnode-examples/contracts/coingecko-testable/Requester.sol deleted file mode 100644 index 1f0aa33800..0000000000 --- a/packages/airnode-examples/contracts/coingecko-testable/Requester.sol +++ /dev/null @@ -1,41 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity 0.8.9; - -import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol"; - -// An example requester which expects the response from Airnode to be a single int256 value. -contract Requester is RrpRequesterV0 { - mapping(bytes32 => bool) public incomingFulfillments; - mapping(bytes32 => int256) public fulfilledData; - - constructor(address airnodeRrp) RrpRequesterV0(airnodeRrp) {} - - function makeRequest( - address airnode, - bytes32 endpointId, - address sponsor, - address sponsorWallet, - bytes calldata parameters - ) external { - bytes32 requestId = airnodeRrp.makeFullRequest( - airnode, - endpointId, - sponsor, - sponsorWallet, - address(this), - this.fulfill.selector, - parameters - ); - incomingFulfillments[requestId] = true; - } - - function fulfill(bytes32 requestId, bytes calldata data) - external - onlyAirnodeRrp - { - require(incomingFulfillments[requestId], "No such request made"); - delete incomingFulfillments[requestId]; - int256 decodedData = abi.decode(data, (int256)); - fulfilledData[requestId] = decodedData; - } -} diff --git a/packages/airnode-examples/integrations/coingecko-signed-data/README.md b/packages/airnode-examples/integrations/coingecko-http-gateways/README.md similarity index 67% rename from packages/airnode-examples/integrations/coingecko-signed-data/README.md rename to packages/airnode-examples/integrations/coingecko-http-gateways/README.md index fd3079dd14..6c890c25ad 100644 --- a/packages/airnode-examples/integrations/coingecko-signed-data/README.md +++ b/packages/airnode-examples/integrations/coingecko-http-gateways/README.md @@ -2,15 +2,51 @@ This example contains the same API integration as `../coingecko`. -The only difference is that this integration allows the endpoint to return signed data that can be then submitted on -chain. +The only difference is that this integration allows the endpoint to return either unsigned or signed data via the HTTP +gateway or HTTP signed data gateway, respectively. -See the documentation for the -[signed data gateway](https://docs.api3.org/airnode/latest/grp-providers/guides/build-an-airnode/http-gateways.html#http-signed-data-gateway). +For more details, see the documentation for the +[HTTP gateways](https://docs.api3.org/airnode/latest/grp-providers/guides/build-an-airnode/http-gateways.html). -## Encode parameters +## HTTP gateway -The coingecko requests expects a parameter `coinId` which needs to be passed to the gateway encoded using +### Trigger a request + +You can trigger the API call with a POST request. For example, you can use `curl` in the terminal: + +```sh +curl -X POST -H 'Content-Type: application/json' -d '{"parameters": {"coinId": "bitcoin"}}' '/' +``` + +#### When deployed on cloud + +Before making the request, you need to replace the example values: + +- `` - You can find this value as part of the terminal output of the `yarn deploy-airnode` command +- `` - You can find this value in `config.json` under `triggers.rrp[0].endpointId` path + +The correct command may look like this: + +```sh +curl -X POST -H 'Content-Type: application/json' -d '{"parameters": {"coinId": "bitcoin"}}' 'https://x9sidy9ln0.execute-api.us-east-1.amazonaws.com/v1/d6ed7e8b-40fa-1392-3e4a-37e225ccda20/0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4' +``` + +#### When running Airnode locally + +When Airnode is run locally, the HTTP gateway endpoint is always +`http://localhost:/http-data/01234567-abcd-abcd-abcd-012345678abc/`. + +For example: + +```sh +curl -X POST -H 'Content-Type: application/json' -d '{"parameters": {"coinId": "bitcoin"}}' 'http://localhost:3000/http-data/01234567-abcd-abcd-abcd-012345678abc/0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4' +``` + +## HTTP signed data gateway + +### Encode parameters + +The coingecko endpoint expects a parameter `coinId` which needs to be passed to the signed data gateway encoded using [Airnode ABI](https://docs.api3.org/airnode/latest/reference/specifications/airnode-abi-specifications.html). We have encoded two basic parameter types: @@ -22,7 +58,7 @@ We have encoded two basic parameter types: Feel free to encode a different parameter type to make a different request. -## Trigger a request +### Trigger a request You can trigger the API call with a POST request. For example, you can use `curl` in the terminal: @@ -30,7 +66,7 @@ You can trigger the API call with a POST request. For example, you can use `curl curl -X POST -H 'Content-Type: application/json' -d '{"encodedParameters": "0x3173000000000000000000000000000000000000000000000000000000000000636f696e49640000000000000000000000000000000000000000000000000000626974636f696e00000000000000000000000000000000000000000000000000"}' '/' ``` -### When deployed on cloud +#### When deployed on cloud Before making the request, you need to replace the following placeholders: @@ -46,7 +82,7 @@ The correct command may look like this: curl -X POST -H 'Content-Type: application/json' -d '{"encodedParameters": "0x3173000000000000000000000000000000000000000000000000000000000000636f696e49640000000000000000000000000000000000000000000000000000626974636f696e00000000000000000000000000000000000000000000000000"}' 'https://am6ncplkx4.execute-api.us-east-1.amazonaws.com/v1/d6ed7e8b-40fa-1392-3e4a-37e225ccda20/0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4' ``` -### When running Airnode locally +#### When running Airnode locally When Airnode is run locally, the HTTP signed data gateway endpoint is always `http://localhost:/http-signed-data/01234567-abcd-abcd-abcd-012345678abc/`. For now, `PORT` number is @@ -58,7 +94,7 @@ For example: curl -X POST -H 'Content-Type: application/json' -d '{"encodedParameters": "0x3173000000000000000000000000000000000000000000000000000000000000636f696e49640000000000000000000000000000000000000000000000000000626974636f696e00000000000000000000000000000000000000000000000000"}' 'http://localhost:3000/http-signed-data/01234567-abcd-abcd-abcd-012345678abc/0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4' ``` -## Output +### Output The example output might look like this: diff --git a/packages/airnode-examples/integrations/coingecko-signed-data/config.example.json b/packages/airnode-examples/integrations/coingecko-http-gateways/config.example.json similarity index 94% rename from packages/airnode-examples/integrations/coingecko-signed-data/config.example.json rename to packages/airnode-examples/integrations/coingecko-http-gateways/config.example.json index 0dab5c3209..4916439183 100644 --- a/packages/airnode-examples/integrations/coingecko-signed-data/config.example.json +++ b/packages/airnode-examples/integrations/coingecko-http-gateways/config.example.json @@ -53,7 +53,9 @@ "enabled": false }, "httpGateway": { - "enabled": false + "enabled": true, + "maxConcurrency": 20, + "corsOrigins": [] }, "httpSignedDataGateway": { "enabled": true, @@ -74,7 +76,13 @@ "cacheResponses": false } ], - "http": [], + "http": [ + { + "endpointId": "0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4", + "oisTitle": "CoinGecko basic request", + "endpointName": "coinMarketData" + } + ], "httpSignedData": [ { "endpointId": "0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4", diff --git a/packages/airnode-examples/integrations/coingecko-signed-data/create-config.ts b/packages/airnode-examples/integrations/coingecko-http-gateways/create-config.ts similarity index 95% rename from packages/airnode-examples/integrations/coingecko-signed-data/create-config.ts rename to packages/airnode-examples/integrations/coingecko-http-gateways/create-config.ts index 6e171fe4ab..a68a68234b 100644 --- a/packages/airnode-examples/integrations/coingecko-signed-data/create-config.ts +++ b/packages/airnode-examples/integrations/coingecko-http-gateways/create-config.ts @@ -60,7 +60,9 @@ const createConfig = async (generateExampleFile: boolean): Promise => ({ enabled: false, }, httpGateway: { - enabled: false, + enabled: true, + maxConcurrency: 20, + corsOrigins: [], }, httpSignedDataGateway: { enabled: true, @@ -81,7 +83,13 @@ const createConfig = async (generateExampleFile: boolean): Promise => ({ cacheResponses: false, }, ], - http: [], + http: [ + { + endpointId: '0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4', + oisTitle: 'CoinGecko basic request', + endpointName: 'coinMarketData', + }, + ], httpSignedData: [ { endpointId: '0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4', diff --git a/packages/airnode-examples/integrations/coingecko-signed-data/create-secrets.ts b/packages/airnode-examples/integrations/coingecko-http-gateways/create-secrets.ts similarity index 100% rename from packages/airnode-examples/integrations/coingecko-signed-data/create-secrets.ts rename to packages/airnode-examples/integrations/coingecko-http-gateways/create-secrets.ts diff --git a/packages/airnode-examples/integrations/coingecko-signed-data/request-utils.ts b/packages/airnode-examples/integrations/coingecko-http-gateways/request-utils.ts similarity index 100% rename from packages/airnode-examples/integrations/coingecko-signed-data/request-utils.ts rename to packages/airnode-examples/integrations/coingecko-http-gateways/request-utils.ts diff --git a/packages/airnode-examples/integrations/coingecko-signed-data/secrets.example.env b/packages/airnode-examples/integrations/coingecko-http-gateways/secrets.example.env similarity index 100% rename from packages/airnode-examples/integrations/coingecko-signed-data/secrets.example.env rename to packages/airnode-examples/integrations/coingecko-http-gateways/secrets.example.env diff --git a/packages/airnode-examples/integrations/coingecko-testable/README.md b/packages/airnode-examples/integrations/coingecko-testable/README.md deleted file mode 100644 index 3ad1e75f76..0000000000 --- a/packages/airnode-examples/integrations/coingecko-testable/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Coingecko-testable example integration - -This example contains the same API integration as `../coingecko`. - -The only difference is that this integration allows the endpoint to be tested. First deploy Airnode on cloud provider or -run locally using -[Airnode client docker image](https://docs.api3.org/airnode/latest/grp-providers/docker/client-image.html). Then make an -API request to Airnode. - -Refer to the [docs](https://docs.api3.org/airnode/latest/grp-providers/guides/build-an-airnode/http-gateways.html) for -more information. - -## Testing the API call - -You can trigger the API call with a POST request. For example, you can use `curl` in the terminal: - -```sh -curl -X POST -H 'Content-Type: application/json' -d '{"parameters": {"coinId": "bitcoin"}}' '/' -``` - -### When deployed on cloud - -Before making the request, you need to replace the example values: - -- `` - You can find this value as part of the terminal output of the `yarn deploy-airnode` command -- `` - You can find this value in `config.json` under `triggers.rrp[0].endpointId` path - -The correct command may look like this: - -```sh -curl -X POST -H 'Content-Type: application/json' -d '{"parameters": {"coinId": "bitcoin"}}' 'https://x9sidy9ln0.execute-api.us-east-1.amazonaws.com/v1/d6ed7e8b-40fa-1392-3e4a-37e225ccda20/0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4' -``` - -### When running Airnode locally - -When Airnode is run locally, the HTTP gateway endpoint is always -`http://localhost:/http-data/01234567-abcd-abcd-abcd-012345678abc/`. - -For example: - -```sh -curl -X POST -H 'Content-Type: application/json' -d '{"parameters": {"coinId": "bitcoin"}}' 'http://localhost:3000/http-data/01234567-abcd-abcd-abcd-012345678abc/0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4' -``` diff --git a/packages/airnode-examples/integrations/coingecko-testable/config.example.json b/packages/airnode-examples/integrations/coingecko-testable/config.example.json deleted file mode 100644 index 690c7bcf05..0000000000 --- a/packages/airnode-examples/integrations/coingecko-testable/config.example.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "chains": [ - { - "maxConcurrency": 100, - "authorizers": { - "requesterEndpointAuthorizers": [], - "crossChainRequesterAuthorizers": [] - }, - "authorizations": { - "requesterEndpointAuthorizations": {} - }, - "contracts": { - "AirnodeRrp": "0x5FbDB2315678afecb367f032d93F642f64180aa3" - }, - "id": "31337", - "providers": { - "exampleProvider": { - "url": "${PROVIDER_URL}" - } - }, - "type": "evm", - "options": { - "fulfillmentGasLimit": 500000, - "gasPriceOracle": [ - { - "gasPriceStrategy": "latestBlockPercentileGasPrice", - "percentile": 60, - "minTransactionCount": 20, - "pastToCompareInBlocks": 20, - "maxDeviationMultiplier": 2 - }, - { - "gasPriceStrategy": "providerRecommendedGasPrice", - "recommendedGasPriceMultiplier": 1.2 - }, - { - "gasPriceStrategy": "constantGasPrice", - "gasPrice": { - "value": 10, - "unit": "gwei" - } - } - ] - } - } - ], - "nodeSettings": { - "cloudProvider": { - "type": "local" - }, - "airnodeWalletMnemonic": "${AIRNODE_WALLET_MNEMONIC}", - "heartbeat": { - "enabled": false - }, - "httpGateway": { - "enabled": true, - "maxConcurrency": 20, - "corsOrigins": [] - }, - "httpSignedDataGateway": { - "enabled": false - }, - "logFormat": "plain", - "logLevel": "DEBUG", - "nodeVersion": "0.10.0", - "stage": "dev" - }, - "triggers": { - "rrp": [ - { - "endpointId": "0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4", - "oisTitle": "CoinGecko basic request", - "endpointName": "coinMarketData", - "cacheResponses": false - } - ], - "http": [ - { - "endpointId": "0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4", - "oisTitle": "CoinGecko basic request", - "endpointName": "coinMarketData" - } - ], - "httpSignedData": [] - }, - "templates": [], - "ois": [ - { - "oisFormat": "2.0.0", - "title": "CoinGecko basic request", - "version": "1.0.0", - "apiSpecifications": { - "servers": [ - { - "url": "https://api.coingecko.com/api/v3" - } - ], - "paths": { - "/coins/{id}": { - "get": { - "parameters": [ - { - "in": "path", - "name": "id" - }, - { - "in": "query", - "name": "localization" - }, - { - "in": "query", - "name": "tickers" - }, - { - "in": "query", - "name": "market_data" - }, - { - "in": "query", - "name": "community_data" - }, - { - "in": "query", - "name": "developer_data" - }, - { - "in": "query", - "name": "sparkline" - } - ] - } - } - }, - "components": { - "securitySchemes": {} - }, - "security": {} - }, - "endpoints": [ - { - "name": "coinMarketData", - "operation": { - "method": "get", - "path": "/coins/{id}" - }, - "fixedOperationParameters": [ - { - "operationParameter": { - "in": "query", - "name": "localization" - }, - "value": "false" - }, - { - "operationParameter": { - "in": "query", - "name": "tickers" - }, - "value": "false" - }, - { - "operationParameter": { - "in": "query", - "name": "market_data" - }, - "value": "true" - }, - { - "operationParameter": { - "in": "query", - "name": "community_data" - }, - "value": "false" - }, - { - "operationParameter": { - "in": "query", - "name": "developer_data" - }, - "value": "false" - }, - { - "operationParameter": { - "in": "query", - "name": "sparkline" - }, - "value": "false" - } - ], - "reservedParameters": [ - { - "name": "_type", - "fixed": "int256" - }, - { - "name": "_path", - "fixed": "market_data.current_price.usd" - }, - { - "name": "_times", - "fixed": "1000000" - } - ], - "parameters": [ - { - "name": "coinId", - "operationParameter": { - "in": "path", - "name": "id" - } - } - ] - } - ] - } - ], - "apiCredentials": [] -} diff --git a/packages/airnode-examples/integrations/coingecko-testable/create-config.ts b/packages/airnode-examples/integrations/coingecko-testable/create-config.ts deleted file mode 100644 index cb0172d542..0000000000 --- a/packages/airnode-examples/integrations/coingecko-testable/create-config.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { Config } from '@api3/airnode-node'; -import { - createCloudProviderConfiguration, - createNodeVersion, - generateConfigFile, - getAirnodeRrpAddress, - getChainId, -} from '../config-utils'; - -const createConfig = async (generateExampleFile: boolean): Promise => ({ - chains: [ - { - maxConcurrency: 100, - authorizers: { - requesterEndpointAuthorizers: [], - crossChainRequesterAuthorizers: [], - }, - authorizations: { - requesterEndpointAuthorizations: {}, - }, - contracts: { - AirnodeRrp: await getAirnodeRrpAddress(generateExampleFile), - }, - id: await getChainId(generateExampleFile), - providers: { - exampleProvider: { - url: '${PROVIDER_URL}', - }, - }, - type: 'evm', - options: { - fulfillmentGasLimit: 500_000, - gasPriceOracle: [ - { - gasPriceStrategy: 'latestBlockPercentileGasPrice', - percentile: 60, - minTransactionCount: 20, - pastToCompareInBlocks: 20, - maxDeviationMultiplier: 2, - }, - { - gasPriceStrategy: 'providerRecommendedGasPrice', - recommendedGasPriceMultiplier: 1.2, - }, - { - gasPriceStrategy: 'constantGasPrice', - gasPrice: { - value: 10, - unit: 'gwei', - }, - }, - ], - }, - }, - ], - nodeSettings: { - cloudProvider: createCloudProviderConfiguration(generateExampleFile), - airnodeWalletMnemonic: '${AIRNODE_WALLET_MNEMONIC}', - heartbeat: { - enabled: false, - }, - httpGateway: { - enabled: true, - maxConcurrency: 20, - corsOrigins: [], - }, - httpSignedDataGateway: { - enabled: false, - }, - logFormat: 'plain', - logLevel: 'DEBUG', - nodeVersion: createNodeVersion(), - stage: 'dev', - }, - triggers: { - rrp: [ - { - endpointId: '0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4', - oisTitle: 'CoinGecko basic request', - endpointName: 'coinMarketData', - cacheResponses: false, - }, - ], - http: [ - { - endpointId: '0xfb87102cdabadf905321521ba0b3cbf74ad09c5d400ac2eccdbef8d6143e78c4', - oisTitle: 'CoinGecko basic request', - endpointName: 'coinMarketData', - }, - ], - httpSignedData: [], - }, - templates: [], - ois: [ - { - oisFormat: '2.0.0', - title: 'CoinGecko basic request', - version: '1.0.0', - apiSpecifications: { - servers: [ - { - url: 'https://api.coingecko.com/api/v3', - }, - ], - paths: { - '/coins/{id}': { - get: { - parameters: [ - { - in: 'path', - name: 'id', - }, - { - in: 'query', - name: 'localization', - }, - { - in: 'query', - name: 'tickers', - }, - { - in: 'query', - name: 'market_data', - }, - { - in: 'query', - name: 'community_data', - }, - { - in: 'query', - name: 'developer_data', - }, - { - in: 'query', - name: 'sparkline', - }, - ], - }, - }, - }, - components: { - securitySchemes: {}, - }, - security: {}, - }, - endpoints: [ - { - name: 'coinMarketData', - operation: { - method: 'get', - path: '/coins/{id}', - }, - fixedOperationParameters: [ - { - operationParameter: { - in: 'query', - name: 'localization', - }, - value: 'false', - }, - { - operationParameter: { - in: 'query', - name: 'tickers', - }, - value: 'false', - }, - { - operationParameter: { - in: 'query', - name: 'market_data', - }, - value: 'true', - }, - { - operationParameter: { - in: 'query', - name: 'community_data', - }, - value: 'false', - }, - { - operationParameter: { - in: 'query', - name: 'developer_data', - }, - value: 'false', - }, - { - operationParameter: { - in: 'query', - name: 'sparkline', - }, - value: 'false', - }, - ], - reservedParameters: [ - { - name: '_type', - fixed: 'int256', - }, - { - name: '_path', - fixed: 'market_data.current_price.usd', - }, - { - name: '_times', - fixed: '1000000', - }, - ], - parameters: [ - { - name: 'coinId', - operationParameter: { - in: 'path', - name: 'id', - }, - }, - ], - }, - ], - }, - ], - apiCredentials: [], -}); - -const generateConfig = async (generateExampleFile = false) => { - const config = await createConfig(generateExampleFile); - generateConfigFile(__dirname, config, generateExampleFile); -}; - -export default generateConfig; diff --git a/packages/airnode-examples/integrations/coingecko-testable/create-secrets.ts b/packages/airnode-examples/integrations/coingecko-testable/create-secrets.ts deleted file mode 100644 index 4805ae86de..0000000000 --- a/packages/airnode-examples/integrations/coingecko-testable/create-secrets.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { getCommonSecrets, writeSecrets } from '../secrets-utils'; - -const createSecrets = async (generateExampleFile = false) => { - const secrets = await getCommonSecrets(generateExampleFile); - - writeSecrets(__dirname, secrets, generateExampleFile); -}; - -export default createSecrets; diff --git a/packages/airnode-examples/integrations/coingecko-testable/request-utils.ts b/packages/airnode-examples/integrations/coingecko-testable/request-utils.ts deleted file mode 100644 index 0a11179d8e..0000000000 --- a/packages/airnode-examples/integrations/coingecko-testable/request-utils.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { encode } from '@api3/airnode-abi'; -import { deriveAirnodeXpub, deriveSponsorWalletAddress } from '@api3/airnode-admin'; -import { ethers } from 'ethers'; -import { cliPrint, getAirnodeWallet, getDeployedContract, readConfig, readIntegrationInfo } from '../../src'; - -const coinLabel = 'Ethereum'; -const coinId = coinLabel.toLowerCase(); - -const getEncodedParameters = () => encode([{ name: 'coinId', type: 'string32', value: coinId }]); - -export const makeRequest = async () => { - const integrationInfo = readIntegrationInfo(); - const requester = await getDeployedContract(`contracts/${integrationInfo.integration}/Requester.sol`); - const airnodeWallet = getAirnodeWallet(); - const sponsor = ethers.Wallet.fromMnemonic(integrationInfo.mnemonic); - const endpointId = readConfig().triggers.rrp[0].endpointId; - const sponsorWalletAddress = await deriveSponsorWalletAddress( - deriveAirnodeXpub(airnodeWallet.mnemonic.phrase), - airnodeWallet.address, - sponsor.address - ); - - // Trigger the Airnode request - return requester.makeRequest( - airnodeWallet.address, - endpointId, - sponsor.address, - sponsorWalletAddress, - getEncodedParameters() - ); -}; - -export const printResponse = async (requestId: string) => { - const integrationInfo = readIntegrationInfo(); - const requester = await getDeployedContract(`contracts/${integrationInfo.integration}/Requester.sol`); - - // Divided by 1e6, because the response value is multiplied with 1e6 by Airnode - cliPrint.info(`${coinLabel} price is ${(await requester.fulfilledData(requestId)) / 1e6} USD`); -}; diff --git a/packages/airnode-examples/integrations/coingecko-testable/secrets.example.env b/packages/airnode-examples/integrations/coingecko-testable/secrets.example.env deleted file mode 100644 index 31bd3e3f06..0000000000 --- a/packages/airnode-examples/integrations/coingecko-testable/secrets.example.env +++ /dev/null @@ -1,2 +0,0 @@ -AIRNODE_WALLET_MNEMONIC=tube spin artefact salad slab lumber foot bitter wash reward vote cook -PROVIDER_URL=http://127.0.0.1:8545/