Skip to content

Commit

Permalink
feat(smartsale-contracts): use plain objects
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Feb 7, 2024
1 parent 4982943 commit 12c1776
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 325 deletions.
9 changes: 5 additions & 4 deletions apps/indexer/src/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseEventLogs, Log, Address } from 'viem'
import { Log } from 'viem'
import { client } from './evm-client'
import { TestnetEasyAuction } from 'smartsale-contracts'
import { bigintToPostgresTimestamp, getTokenDetails, runPromisesInSeries } from './lib'
import { bigintToPostgresTimestamp, getEvents, getTokenDetails, runPromisesInSeries } from './lib'
import { PrismaClient } from '@prisma/client'
import { NewAuctionEvent } from './types'
const prisma = new PrismaClient()
Expand All @@ -12,8 +12,9 @@ export async function startIndexer() {
// await writeToFile(stringify(TestnetEasyAuction.getEvents(), null, 2), './events.json')
// Get historical event logs
const blockNumber = await client.getBlockNumber()
const events = getEvents(TestnetEasyAuction)
const logs = await client.getLogs({
events: TestnetEasyAuction.getEvents(),
events,
fromBlock: BigInt(TestnetEasyAuction.indexFromBlock),
toBlock: blockNumber,
})
Expand All @@ -28,7 +29,7 @@ export async function startIndexer() {

// Watch for new event logs
client.watchEvent({
events: TestnetEasyAuction.getEvents(),
events,
onLogs: (logs) => {
const filteredlogs = logs.filter((log) => log.eventName !== 'OwnershipTransferred')
// console.log(
Expand Down
5 changes: 4 additions & 1 deletion apps/indexer/src/lib.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs/promises'
import { erc20Abi } from 'abitype/abis'
import { client } from './evm-client'
import { Address } from 'viem'
import { Abi, Address } from 'viem'

export async function writeToFile(data: string, filePath: string) {
try {
Expand Down Expand Up @@ -51,3 +51,6 @@ export function bigintToPostgresTimestamp(timestamp: bigint): string {
const date = new Date(Number(timestamp) * 1000); // Convert seconds to milliseconds
return date.toISOString().replace('T', ' ').replace('Z', ''); // Convert to PostgreSQL timestamp format
}


export const getEvents = (abi: Abi) => abi.filter(item => item.type === 'event');
4 changes: 2 additions & 2 deletions apps/webapp/app/[project]/auction/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export default function AuctionPage({
<Countdown auctionId={project.auctionId} />
</div>
<div className="w-full md:w-1/3">
<React.Suspense fallback={<div>Loading ...</div>}>
<React.Suspense fallback={<div>Loading ...</div>}>
<AuctionBids project={project} />
</React.Suspense>
</React.Suspense>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/components/auction/auction-bids.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function AuctionBids({ project }: AuctionBidsProps) {

return (
<div>
<form onSubmit={handleSubmit}>
<form >
<Table>
<TableHeader>
<TableRow>
Expand Down
6 changes: 3 additions & 3 deletions packages/smartsale-contracts/src/testnet-allow-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContractData } from "./types";
import { ContractData } from "./types";

export const TestnetAllowList = createContractData({
export const TestnetAllowList : ContractData = {
"address": "0x3D18904711fe451356eBA461B7747EA3Abff6c93",
"indexFromBlock": 12241046,
"abi": [
Expand Down Expand Up @@ -86,4 +86,4 @@ export const TestnetAllowList = createContractData({
"type": "function"
}
]
})
}
6 changes: 3 additions & 3 deletions packages/smartsale-contracts/src/testnet-deposit-order.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContractData } from "./types";
import { ContractData } from "./types";

export const TestnetDepositOrder = createContractData({
export const TestnetDepositOrder : ContractData = {
"address": "0x4faA684A1E0Cdd7cb271b5424a12A2D039624D78",
"indexFromBlock": 12240840,
"abi": [
Expand Down Expand Up @@ -81,4 +81,4 @@ export const TestnetDepositOrder = createContractData({
"type": "function"
}
]
})
}
6 changes: 3 additions & 3 deletions packages/smartsale-contracts/src/testnet-easy-auction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContractData } from "./types";
import { ContractData } from "./types";

export const TestnetEasyAuction = createContractData({
export const TestnetEasyAuction : ContractData = {
"address": "0x8d37219725eB0088360f744A5d894035D0f88F82",
"indexFromBlock": 12239067,
"abi": [
Expand Down Expand Up @@ -858,4 +858,4 @@ export const TestnetEasyAuction = createContractData({
"type": "function"
}
]
})
}
Loading

0 comments on commit 12c1776

Please sign in to comment.