Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added wip watcher reporting script #9

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/sdk-quickstart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
},
"dependencies": {
"@ethersproject/bignumber": "^5.6.0",
"@nomad-xyz/sdk": "^2.0.0-rc.4",
"@nomad-xyz/sdk-bridge": "^1.0.0-rc.4",
"@nomad-xyz/sdk": "2.0.0-rc.4",
"@nomad-xyz/sdk-bridge": "1.0.0-rc.4",
"ethers": "^5.5.3"
},
"devDependencies": {
Expand Down
40 changes: 40 additions & 0 deletions packages/sdk-quickstart/scripts/checkWatchers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { BridgeContext, TransferMessage } from "@nomad-xyz/sdk-bridge";
import { configureRpcs } from "../lib/registerRpc";
import { BigNumber } from "@ethersproject/bignumber";
import { ethers } from "ethers";
import { getEvents } from "@nomad-xyz/sdk";

async function main(){
// This uses a helper function defined in ./registerRpcs.ts
// to register RPCs placed in environment variables
const context = configureRpcs("production")

// Which domains are registered?
console.log(`Registered Domains: ${context.domainNames}`)

for (const domain of context.domainNames) {
if(domain=="moonbeam")
continue
console.log(`Fetching Watcher configuration for ${domain}`);

const core = context.mustGetCore(domain);
const connectionManager = core.xAppConnectionManager
const permissionEventFilter = connectionManager.filters.WatcherPermissionSet()

const permissionEvents = await getEvents(
context,
domain,
connectionManager,
permissionEventFilter
)

for (const event of permissionEvents) {
const domainName = context.resolveDomainName(event.args[0])
console.log(`Watcher Permission Event: \n\t Domain: ${domainName} \n\t Address: ${event.args[1]} \n\t Access: ${event.args[2]}`)
}
}
}

(async () => {
await main()
})()