Skip to content

Commit

Permalink
chore: use viem v2 in indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Feb 4, 2024
1 parent 66f40a0 commit 960c390
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
4 changes: 1 addition & 3 deletions apps/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@dfuse/client": "^0.3.21",
"@sentry/node": "^7.98.0",
"lodash": "^4.17.21",
"nexus": "^1.3.0",
"node-fetch": "3.3"
"viem": "latest"
}
}
4 changes: 2 additions & 2 deletions apps/indexer/src/evm-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { http, createPublicClient } from 'viem'
import { http, createPublicClient, PublicClient } from 'viem'
import { eosEvmTestnet } from 'smartsale-chains'

export const client = createPublicClient({
export const client: PublicClient = createPublicClient({
chain: eosEvmTestnet,
transport: http(),
})
21 changes: 12 additions & 9 deletions apps/indexer/src/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { stringify } from 'viem'
import { stringify, parseEventLogs } from 'viem'
import { client } from './evm-client'
import { TestnetEasyAuction } from 'smartsale-abis'

export async function startIndexer(){
export async function startIndexer() {
console.log('indexing starting')

// await writeToFile(stringify(TestnetEasyAuction.getEvents(), null, 2), './events.json')
Expand All @@ -13,17 +13,20 @@ export async function startIndexer(){
fromBlock: BigInt(TestnetEasyAuction.indexFromBlock),
toBlock: blockNumber,
})
// console.log(stringify(logs, null, 2))
// await writeToFile(stringify(logs.filter((log) => log.eventName !== 'OwnershipTransferred'), null, 2), './logs.json')
const filteredlogs = logs.filter((log) => log.eventName !== 'OwnershipTransferred')
console.log(
stringify(parseEventLogs({ abi: TestnetEasyAuction.abi, logs: filteredlogs }), null, 2),
)
// await writeToFile(stringify(, null, 2), './logs.json')

// Watch for new event logs
client.watchEvent({
events: TestnetEasyAuction.getEvents(),
onLogs: (logs) => {
console.log(stringify(logs, null, 2))
}
const filteredlogs = logs.filter((log) => log.eventName !== 'OwnershipTransferred')
console.log(
stringify(parseEventLogs({ abi: TestnetEasyAuction.abi, logs: filteredlogs }), null, 2),
)
},
})
}



Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"**/vite",
"**/vite/**",
"**/supabase",
"**/supabase/**"
"**/supabase/**",
"**/viem",
"**/viem/**"
]
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/smartsale-chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"viem": "^1.20.3"
"viem": "latest"
},
"devDependencies": {
"tsconfig": "workspace:*",
Expand Down
5 changes: 2 additions & 3 deletions packages/smartsale-chains/src/chains.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Chain } from "viem";

export const eosEvmTestnet : Chain = {
network: 'eos',
export const eosEvmTestnet: Chain = {
nativeCurrency: {
name: 'EOS',
symbol: 'EOS',
Expand All @@ -20,4 +19,4 @@ export const eosEvmTestnet : Chain = {
};

export const smartsaleChainsTestnet = [eosEvmTestnet]
export const smartsaleChainsMainnet = [eosEvmTestnet]
export const smartsaleChainsMainnet = []

0 comments on commit 960c390

Please sign in to comment.