Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 committed Sep 10, 2024
1 parent 182573d commit 4333e61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/routes/diamond/[address]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ const buildFacet = async (
facet.abi = parseAbi(abiSigs)
}

const fileredAbi: Abi = facet.abi.filter((item) => {
const filteredAbi: Abi = facet.abi.filter((item) => {
if (item.type !== 'function') return true
if (!item.outputs) {
item.outputs = []
}
return selectors.includes(toFunctionSelector(item))
})

facet.abi = fileredAbi
facet.abi = filteredAbi

return facet
}
30 changes: 11 additions & 19 deletions src/routes/diamond/[address]/json/+server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { FacetData, Contract, Diamond } from '$lib/types'
import {
getCachedContractInformation,
getContractInformation,
getFuncSigBySelector,
} from '$lib/utils'
import { getCachedContractInformation, getFuncSigBySelector } from '$lib/utils'
import { error, json } from '@sveltejs/kit'
import type { RequestHandler } from './$types'
import {
Expand All @@ -17,8 +13,7 @@ import {
} from 'viem'
import type { Chain } from 'viem/chains'
import { chainMap } from '$lib/chains'
import { drizzle, type BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite'
import { Database } from 'bun:sqlite'
import { type BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite'
import { diamonds } from '../../../../schema'
import { sql } from 'drizzle-orm'

Expand Down Expand Up @@ -59,9 +54,7 @@ export const GET: RequestHandler = async ({ params, url, locals }) => {
}

// Udate the database
const sqlite = new Database('./data/louper.db')
const db = drizzle(sqlite)
await db
await locals.db
.insert(diamonds)
.values({
id: `${network}:${address}`,
Expand All @@ -77,14 +70,13 @@ export const GET: RequestHandler = async ({ params, url, locals }) => {
},
})

sqlite.close()
const response = json({
chain: network,
diamond,
diamondAbi,
})

return json({ msg: 'ok' })
// return json({
// chain: network,
// diamond,
// diamondAbi,
// })
return response
} catch (e) {
console.error(e)
throw error(400, { message: 'Unable to fetch diamond details' })
Expand All @@ -108,15 +100,15 @@ const buildFacet = async (
facet.abi = parseAbi(abiSigs)
}

const fileredAbi: Abi = facet.abi.filter((item) => {
const filteredAbi: Abi = facet.abi.filter((item) => {
if (item.type !== 'function') return true
if (!item.outputs) {
item.outputs = []
}
return selectors.includes(toFunctionSelector(item))
})

facet.abi = fileredAbi
facet.abi = filteredAbi

return facet
}

0 comments on commit 4333e61

Please sign in to comment.