From b14da1cc32f332cf78abf23be8de37ead89dc34e Mon Sep 17 00:00:00 2001 From: mul53 Date: Thu, 25 Jul 2024 11:00:11 +0200 Subject: [PATCH] refactor getNewToken --- scripts/analyze.js | 13 +------------ scripts/helpers/getNewToken.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 scripts/helpers/getNewToken.js diff --git a/scripts/analyze.js b/scripts/analyze.js index 934dbe7..78e5203 100644 --- a/scripts/analyze.js +++ b/scripts/analyze.js @@ -7,18 +7,7 @@ const isNameValid = require('./helpers/isNameValid') const isSymbolValid = require('./helpers/isSymbolValid') const getNewTokenList = require('./helpers/getNewTokenList') const getCurrentTokenList = require('./helpers/getCurrentTokenList') - -async function getNewToken(newTokenList, currentTokenList) { - const currentIds = new Set( - currentTokenList.tokens.map((token) => token.address), - ) - - const newTokens = newTokenList.tokens.filter( - (token) => !currentIds.has(token.address), - ) - - return newTokens[0] -} +const getNewToken = require('./helpers/getNewToken') async function analyze() { const errors = [] diff --git a/scripts/helpers/getNewToken.js b/scripts/helpers/getNewToken.js new file mode 100644 index 0000000..0a5c3be --- /dev/null +++ b/scripts/helpers/getNewToken.js @@ -0,0 +1,11 @@ +module.exports = async function getNewToken(newTokenList, currentTokenList) { + const currentIds = new Set( + currentTokenList.tokens.map((token) => token.address), + ) + + const newTokens = newTokenList.tokens.filter( + (token) => !currentIds.has(token.address), + ) + + return newTokens[0] +}