From 3585a4f4653d88697eec5c4a0f85cae37d46373d Mon Sep 17 00:00:00 2001 From: Shubham Singhal Date: Thu, 26 Oct 2023 11:59:49 +0530 Subject: [PATCH] Updated 1Inch API URL and request handling --- CHANGELOG.md | 3 ++- constants/index.js | 5 +++-- index.js | 2 +- package-lock.json | 2 +- package.json | 2 +- utils/helper.js | 3 ++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f95f536..69c9644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,5 +13,6 @@ - Updated getSupportedTokens method to accept dex as a parameter and return tokens only for the selected dex +### 1.0.4 (2023-10-26) - +- Updated 1Inch API URL and request handling \ No newline at end of file diff --git a/constants/index.js b/constants/index.js index 382098c..f980c31 100644 --- a/constants/index.js +++ b/constants/index.js @@ -1,9 +1,10 @@ module.exports ={ supportedChains : ['ethereum', 'polygon', 'bsc' ], - oneInchBaseURL : "https://api-safle.1inch.io/v5.0", + oneInchBaseURL : "https://api.1inch.dev/swap/v5.2", pancakeBaseURL: "https://tokens.pancakeswap.finance/pancakeswap-extended.json", uniswapBaseURL: "https://tokens.uniswap.org/", errorMessages:{ INVALID_CHAIN: "Invalid chain selected" - } + }, + oneinchAuthToken: 'I00gf2qW3ebQSNZrcLrfmZelxmLxqdyL' } \ No newline at end of file diff --git a/index.js b/index.js index c0cc198..22953db 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ async function getTokensOneInch(chain) { } else { return { error: config.errorMessages.INVALID_CHAIN }; } - const { response, error } = await helper.getRequest({ url: `${url}/tokens` }); + const { response, error } = await helper.getRequest({ url: `${url}/tokens`, headers: {Authorization: `Bearer ${config.oneinchAuthToken}` }}); if (error) { return error; } diff --git a/package-lock.json b/package-lock.json index 3211020..220a936 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-token-lists", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 7e0ac0d..4ff9200 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-token-lists", - "version": "1.0.3", + "version": "1.0.4", "description": "This is a JS SDK catering to supported tokens list on safle swaps fetched from all the supported DEXs on different chains.", "main": "index.js", "scripts": { diff --git a/utils/helper.js b/utils/helper.js index 1ee85d2..6b7c80b 100644 --- a/utils/helper.js +++ b/utils/helper.js @@ -1,10 +1,11 @@ const axios = require('axios') -const getRequest = async ({ url }) => { +const getRequest = async ({ url, headers }) => { try { const response = await axios({ url: `${url}`, method: 'GET', + headers }); return { response: response.data }; } catch (error) {