-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
264 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Provider } from "ethers"; | ||
|
||
// Function to check if an address is in the data | ||
function containsAddress(data: string, address: string): boolean { | ||
const addressWithoutPrefix = address.toLowerCase().substring(2); | ||
return data.toLowerCase().includes(addressWithoutPrefix); | ||
} | ||
|
||
// Function to get the oracle's transaction hash | ||
export async function getOracleTransactionHash( | ||
oracleAddress: string, | ||
provider: Provider | ||
): Promise<string | null> { | ||
const filter = { | ||
address: "0x3A7bB36Ee3f3eE32A60e9f2b33c1e5f2E83ad766", | ||
fromBlock: 18000000, | ||
toBlock: "latest", | ||
}; | ||
|
||
// Fetch logs | ||
const logs = await provider.getLogs(filter); | ||
|
||
// Find the first log containing the oracle address | ||
const log = logs.find((log: any) => containsAddress(log.data, oracleAddress)); | ||
|
||
// Return the transaction hash if found, otherwise null | ||
return log ? log.transactionHash : null; | ||
} |
Oops, something went wrong.