Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-pots-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@3loop/transaction-decoder': patch
---

Change primary key for sql cache table
12 changes: 9 additions & 3 deletions packages/transaction-decoder/src/sql/abi-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ export const make = (strategies: AbiStore['strategies']) =>
Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient

const table = sql('_loop_decoder_contract_abi_')
const table = sql('_loop_decoder_contract_abi_v2')
const id = sql.onDialectOrElse({
sqlite: () => sql`id INTEGER PRIMARY KEY AUTOINCREMENT,`,
pg: () => sql`id SERIAL PRIMARY KEY,`,
mysql: () => sql`id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id),`,
orElse: () => sql``,
})

// TODO; add timestamp to the table
yield* sql`
CREATE TABLE IF NOT EXISTS ${table} (
${id}
type TEXT NOT NULL,
address TEXT,
event TEXT,
signature TEXT,
chain INTEGER,
abi TEXT,
status TEXT NOT NULL,
timestamp TEXT DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (address, chain)
timestamp TEXT DEFAULT CURRENT_TIMESTAMP
)
`.pipe(
Effect.tapError(Effect.logError),
Expand Down
Loading