Skip to content

Commit

Permalink
Updated etherscan api requests to use sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
Oluwateniayomi authored and Oluwateniayomi committed Jan 6, 2025
1 parent d4918e7 commit dd8a4f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/App/IQHolders/IQHolder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ class IQHolderService {
const startTimestamp = 1616112000
const endTimestamp = startTimestamp + oneDayInSeconds
const key = this.etherScanApiKey()
const rootUrl = `https://api${
this.provider().includes('mainnet') ? '' : '-goerli'
}`
const mainnet = this.provider().includes('mainnet')
const buildUrl = (fallbackTimestamp: number, timestamp?: number) =>
`${rootUrl}.etherscan.io/api?module=block&action=getblocknobytime&timestamp=${
`https://api.etherscan.io/api?${
!mainnet && 'chainid=11155111'
}module=block&action=getblocknobytime&timestamp=${
timestamp || fallbackTimestamp
}&closest=before&apikey=${key}`

Expand All @@ -215,7 +215,9 @@ class IQHolderService {
} catch (e: any) {
console.error('Error requesting block number', e.data)
}
const transactionsFor1Day = `${rootUrl}.etherscan.io/api?module=account&action=txlist&address=${IQContract}&startBlock=${blockNumberForQuery1}&endBlock=${blockNumberForQuery2}&page=1&offset=1000&sort=asc&apikey=${key}`
const transactionsFor1Day = `https://api.etherscan.io/api?${
!mainnet && 'chainid=11155111'
}module=account&action=txlist&address=${IQContract}&startBlock=${blockNumberForQuery1}&endBlock=${blockNumberForQuery2}&page=1&offset=1000&sort=asc&apikey=${key}`

let transactions
try {
Expand Down
9 changes: 5 additions & 4 deletions src/App/StakedIQ/stakedIQ.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { existRecord, stopJob, getDates, insertOldData } from './stakedIQ.utils'
@Injectable()
class StakedIQService {
constructor(
private repo: StakedIQRepository,
private repo: StakedIQRepository,
private configService: ConfigService,
private httpService: HttpService,
private schedulerRegistry: SchedulerRegistry,
Expand Down Expand Up @@ -76,9 +76,10 @@ class StakedIQService {
const { time, incomingDate } = await getDates(this.repo)

const key = this.etherScanApiKey()
const url = `https://api${
this.provider().includes('mainnet') ? '' : '-goerli'
}.etherscan.io/api?module=block&action=getblocknobytime&timestamp=${time}&closest=before&apikey=${key}`
const mainnet = this.provider().includes('mainnet')
const url = `https://api.etherscan.io/api?${
!mainnet && 'chainid=11155111'
}module=block&action=getblocknobytime&timestamp=${time}&closest=before&apikey=${key}`

let blockNumberForQuery
try {
Expand Down

0 comments on commit dd8a4f4

Please sign in to comment.