From 88c8b300f0d7412b91c71fe7e1fbcea5be886fe8 Mon Sep 17 00:00:00 2001 From: Mathieu Lefebvre Date: Wed, 8 Nov 2023 10:11:27 -0500 Subject: [PATCH] update to new Table format (block,timestamp) --- src/queries.spec.ts | 9 --------- src/queries.ts | 7 +------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/queries.spec.ts b/src/queries.spec.ts index d6f7250..3f35f5d 100644 --- a/src/queries.spec.ts +++ b/src/queries.spec.ts @@ -38,9 +38,6 @@ test("getContracts", () => { formatSQL(`SELECT * FROM Contracts`) ); - expect(formatSQL(getContracts(parameter))).toContain( - formatSQL(`JOIN blocks ON blocks.block_id = Contracts.block_id`) - ); expect(formatSQL(getContracts(parameter))).toContain( formatSQL(`WHERE (chain == '${chain}' AND address == '${address}')`) @@ -107,9 +104,6 @@ test("getTotalSupply", () => { formatSQL(`FROM TotalSupply`) ); - expect(formatSQL(getTotalSupply(parameters))).toContain( - formatSQL(`JOIN blocks ON blocks.block_id = TotalSupply.block_id`) - ); expect(formatSQL(getTotalSupply(parameters))).toContain( formatSQL(`LEFT JOIN Contracts ON Contracts.address = TotalSupply.address`) @@ -167,9 +161,6 @@ test("getBalanceChabge", () => { formatSQL(`FROM balance_changes`) ); - expect(formatSQL(getBalanceChanges(parameters))).toContain( - formatSQL(`JOIN blocks ON blocks.block_id = balance_changes.block_id`) - ); expect(formatSQL(getBalanceChanges(parameters))).toContain( formatSQL( diff --git a/src/queries.ts b/src/queries.ts index e1f6d38..a784b6e 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -42,8 +42,7 @@ export function getTotalSupply(searchParams: URLSearchParams, example?: boolean) FROM ${table} `; - // JOIN block table - query += ` JOIN blocks ON blocks.block_id = ${table}.block_id`; + // JOIN Contracts table query += ` LEFT JOIN Contracts ON ${contractTable}.address = ${table}.address`; if (!example) { // WHERE statements @@ -86,8 +85,6 @@ export function getContracts(searchParams: URLSearchParams, example?: boolean) { let query = `SELECT * FROM ${table} ` - // JOIN block table - query += ` JOIN blocks ON blocks.block_id = ${table}.block_id`; if (!example) { // WHERE statements const where = []; @@ -136,8 +133,6 @@ export function getBalanceChanges(searchParams: URLSearchParams, example?: boole timestamp FROM ${table} `; - // JOIN block table - query += ` JOIN blocks ON blocks.block_id = ${table}.block_id`; query += ` LEFT JOIN Contracts ON ${contractTable}.address = ${table}.contract`; if (!example) {