From 194cb21ff63c4d4c9fa0b09e4c81e752d3d83842 Mon Sep 17 00:00:00 2001 From: franz Date: Tue, 16 Jan 2024 15:44:54 +0100 Subject: [PATCH] remove wrapped linear token propery --- modules/content/github-content.service.ts | 10 ++++++++-- modules/content/sanity-content.service.ts | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/content/github-content.service.ts b/modules/content/github-content.service.ts index ac798a5d5..053052a89 100644 --- a/modules/content/github-content.service.ts +++ b/modules/content/github-content.service.ts @@ -151,11 +151,11 @@ export class GithubContentService implements ContentService { }); } - const linearPool = pools.find( + const wrappedLinearPoolToken = pools.find( (pool) => pool.linearData && pool.tokens[pool.linearData.wrappedIndex]?.address === token.address, ); - if (linearPool && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) { + if (wrappedLinearPoolToken && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) { types.push({ id: `${token.address}-linear-wrapped`, chain: networkContext.chain, @@ -163,6 +163,12 @@ export class GithubContentService implements ContentService { tokenAddress: token.address, }); } + + if (!wrappedLinearPoolToken && tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) { + prisma.prismaTokenType.delete({ + where: { id_chain: { id: `${token.address}-linear-wrapped`, chain: networkContext.chain } }, + }); + } } await prisma.prismaTokenType.createMany({ skipDuplicates: true, data: types }); diff --git a/modules/content/sanity-content.service.ts b/modules/content/sanity-content.service.ts index e512718e9..bbbe66707 100644 --- a/modules/content/sanity-content.service.ts +++ b/modules/content/sanity-content.service.ts @@ -11,6 +11,7 @@ import { import SanityClient from '@sanity/client'; import { env } from '../../app/env'; import { chainToIdMap } from '../network/network-config'; +import { wrap } from 'module'; interface SanityToken { name: string; @@ -184,11 +185,11 @@ export class SanityContentService implements ContentService { }); } - const linearPool = pools.find( + const wrappedLinearPoolToken = pools.find( (pool) => pool.linearData && pool.tokens[pool.linearData.wrappedIndex].address === token.address, ); - if (linearPool && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) { + if (wrappedLinearPoolToken && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) { types.push({ id: `${token.address}-linear-wrapped`, chain: this.chain, @@ -196,6 +197,12 @@ export class SanityContentService implements ContentService { tokenAddress: token.address, }); } + + if (!wrappedLinearPoolToken && tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) { + prisma.prismaTokenType.delete({ + where: { id_chain: { id: `${token.address}-linear-wrapped`, chain: this.chain } }, + }); + } } await prisma.prismaTokenType.createMany({ skipDuplicates: true, data: types });