Skip to content
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
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export const pandoraServiceAbi = [
uint256 registeredAt,
uint256 approvedAt,
) memory)`,
`function getAllApprovedProviders() external view returns (tuple(
address owner,
string pdpUrl,
string pieceRetrievalUrl,
uint256 registeredAt,
uint256 approvedAt,
)[] memory)`,
]

/**
Expand Down Expand Up @@ -94,6 +101,7 @@ export const pandoraServiceAbi = [
* isProviderApproved(provider: string): Promise<boolean>
* getProviderIdByAddress(provider: string): Promise<BigInt>
* getApprovedProvider(providerId: BigInt): Promise<ApprovedProviderInfo>
* getAllApprovedProviders(): Promise<ApprovedProviderInfo[]>
* }} PandoraService
*/

Expand Down
51 changes: 51 additions & 0 deletions inspect-proofset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ethers } from 'ethers'
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we present these two timestamps as ISO date strings?

})
33 changes: 33 additions & 0 deletions list-approved-providers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ethers } from 'ethers'
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we present these two timestamps as ISO date strings?

})
}