-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pablo Maldonado <[email protected]>
- Loading branch information
Showing
6 changed files
with
71 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// This script queries the events of the spoke pool and prints them in a human readable format. | ||
import { AnchorProvider } from "@coral-xyz/anchor"; | ||
import { address, createSolanaRpc } from "@solana/web3-v2.js"; | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { readProgramEventsV2, stringifyCpiEvent, SvmSpokeIdl } from "../../src/svm"; | ||
|
||
// Set up the provider | ||
const provider = AnchorProvider.env(); | ||
|
||
const argvPromise = yargs(hideBin(process.argv)) | ||
.option("eventName", { | ||
type: "string", | ||
demandOption: false, | ||
describe: "Name of the event to query", | ||
choices: [ | ||
"any", | ||
"FilledV3Relay", | ||
"V3FundsDeposited", | ||
"EnabledDepositRoute", | ||
"RelayedRootBundle", | ||
"ExecutedRelayerRefundRoot", | ||
"BridgedToHubPool", | ||
"PausedDeposits", | ||
"PausedFills", | ||
"SetXDomainAdmin", | ||
"EmergencyDeletedRootBundle", | ||
"RequestedV3SlowFill", | ||
"ClaimedRelayerRefund", | ||
"TokensBridged", | ||
], | ||
}) | ||
.option("programId", { | ||
type: "string", | ||
demandOption: true, | ||
describe: "SvmSpokeProgram ID to query events from", | ||
}).argv; | ||
|
||
async function queryEvents(): Promise<void> { | ||
const argv = await argvPromise; | ||
const eventName = argv.eventName || "any"; | ||
const programId = argv.programId; | ||
const rpc = createSolanaRpc(provider.connection.rpcEndpoint); | ||
const events = await readProgramEventsV2(rpc, address(programId), SvmSpokeIdl, "confirmed"); | ||
const filteredEvents = events.filter((event) => (eventName == "any" ? true : event.name == eventName)); | ||
const formattedEvents = filteredEvents.map((event) => stringifyCpiEvent(event)); | ||
|
||
console.log(JSON.stringify(formattedEvents, null, 2)); | ||
} | ||
|
||
// Run the queryEvents function | ||
queryEvents(); |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./web3-v1"; | ||
export * from "./web3-v2"; | ||
export * from "./assets"; | ||
export * from "./clients"; |
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 @@ | ||
export * from "./solanaProgramUtils"; |
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