-
Notifications
You must be signed in to change notification settings - Fork 2
feat: scripts to inspect on-chain state #19
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
base: main
Are you sure you want to change the base?
Changes from all commits
3b1c459
2fc2921
aaa1783
919fc6f
6c32a39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { ethers } from 'ethers' | ||
| import assert from 'node:assert' | ||
| import { pandoraServiceAbi } from './index.js' | ||
|
|
||
| const { | ||
| GLIF_TOKEN, | ||
| RPC_URL = 'https://api.calibration.node.glif.io/', | ||
| PANDORA_SERVICE_ADDRESS = '0xf49ba5eaCdFD5EE3744efEdf413791935FE4D4c5', | ||
| } = process.env | ||
|
|
||
| const [proofSetIdString] = process.argv.slice(2) | ||
| assert(proofSetIdString, 'Proof Set ID is required as the first argument') | ||
| const proofSetId = BigInt(proofSetIdString) | ||
|
|
||
| const fetchRequest = new ethers.FetchRequest(RPC_URL) | ||
| if (GLIF_TOKEN) { | ||
| fetchRequest.setHeader('Authorization', `Bearer ${GLIF_TOKEN}`) | ||
| } | ||
| const provider = new ethers.JsonRpcProvider(fetchRequest, undefined, { | ||
| polling: true, | ||
| }) | ||
|
|
||
| /** @type {import('../index.js').PandoraService} */ | ||
| const pandoraService = /** @type {any} */ ( | ||
| new ethers.Contract(PANDORA_SERVICE_ADDRESS, pandoraServiceAbi, provider) | ||
| ) | ||
|
|
||
| const proofSetInfo = await pandoraService.getProofSet(proofSetId) | ||
| console.log('PROOF SET PANDORA INFO: %o', { | ||
| railId: proofSetInfo.railId, | ||
| payer: proofSetInfo.payer, | ||
| payee: proofSetInfo.payee, | ||
| commissionBps: proofSetInfo.commissionBps, | ||
| metadata: proofSetInfo.metadata, | ||
| // rootMetadata: proofSetInfo.rootMetadata, | ||
| clientDataSetId: proofSetInfo.clientDataSetId, | ||
| withCDN: proofSetInfo.withCDN, | ||
| }) | ||
|
|
||
| const owner = proofSetInfo.payee | ||
| console.log('OWNER ADDRESS: %s', owner) | ||
| const providerId = await pandoraService.getProviderIdByAddress(owner) | ||
| const providerInfo = await pandoraService.getApprovedProvider(providerId) | ||
|
|
||
| console.log('PANDORA APPROVED PROVIDER INFO: %o', { | ||
| owner: providerInfo.owner, | ||
| pdpUrl: providerInfo.pdpUrl, | ||
| pieceRetrievalUrl: providerInfo.pieceRetrievalUrl, | ||
| registeredAt: providerInfo.registeredAt, | ||
| approvedAt: providerInfo.approvedAt, | ||
|
Comment on lines
+49
to
+50
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we present these two timestamps as ISO date strings? |
||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { ethers } from 'ethers' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, this should be covered by https://pdp.vxb.ai/calibration/providers really |
||
| import { pandoraServiceAbi } from './index.js' | ||
|
|
||
| const { | ||
| GLIF_TOKEN, | ||
| RPC_URL = 'https://api.calibration.node.glif.io/', | ||
| PANDORA_SERVICE_ADDRESS = '0xf49ba5eaCdFD5EE3744efEdf413791935FE4D4c5', | ||
| } = process.env | ||
|
|
||
| const fetchRequest = new ethers.FetchRequest(RPC_URL) | ||
| if (GLIF_TOKEN) { | ||
| fetchRequest.setHeader('Authorization', `Bearer ${GLIF_TOKEN}`) | ||
| } | ||
| const provider = new ethers.JsonRpcProvider(fetchRequest, undefined, { | ||
| polling: true, | ||
| }) | ||
|
|
||
| /** @type {import('../index.js').PandoraService} */ | ||
| const pandoraService = /** @type {any} */ ( | ||
| new ethers.Contract(PANDORA_SERVICE_ADDRESS, pandoraServiceAbi, provider) | ||
| ) | ||
|
|
||
| const providers = await pandoraService.getAllApprovedProviders() | ||
|
|
||
| for (const providerInfo of providers) { | ||
| console.log('%o', { | ||
| owner: providerInfo.owner.toLowerCase(), | ||
| pdpUrl: providerInfo.pdpUrl, | ||
| pieceRetrievalUrl: providerInfo.pieceRetrievalUrl, | ||
| registeredAt: providerInfo.registeredAt, | ||
| approvedAt: providerInfo.approvedAt, | ||
|
Comment on lines
+30
to
+31
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we present these two timestamps as ISO date strings? |
||
| }) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information would be cool to be exposed by the PDP explorer. That is the default place for checking out a proof set. Either in the UI, or in their UI. I suggest opening an issue in https://github.com/FilOzone/pdp-explorer, listening which properties were missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See for example https://pdp.vxb.ai/calibration/proofsets/484