-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck-idl.ts
33 lines (28 loc) · 933 Bytes
/
check-idl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { findIdls } from '../src/mudlands'
// Helper to log IDLs
function parseWrites(writes: { idl: Buffer }[]) {
return writes.map((w) => JSON.parse(w.idl.toString()))
}
const PROGRAM_ID = process.argv[2]
if (PROGRAM_ID == null) {
console.error('Usage: esr check-idl.ts <programId>')
process.exit(1)
}
// May use different RPC provider to avoid getting rate limited
const SOLANA_MAINNET = 'https://api.mainnet-beta.solana.com'
const RPC = process.env.RPC ?? SOLANA_MAINNET
async function main() {
console.error('Checking IDLs on RPC %s', RPC)
const { idls: idlWrites, failures } = await findIdls(PROGRAM_ID, RPC)
console.log(JSON.stringify(parseWrites(idlWrites), null, 2))
console.log('Total of %d idls', idlWrites.length)
if (failures.length > 0) {
console.log('Failures: %O', failures)
}
}
main()
.then(() => process.exit(0))
.catch((err: any) => {
console.error(err)
process.exit(1)
})