Skip to content

Conversation

@pyropy
Copy link
Member

@pyropy pyropy commented Nov 12, 2025

Extends existing Synapse SDK API with FilBeam service allowing for querying the remaining data set egress.

Closes #392

@pyropy pyropy self-assigned this Nov 12, 2025
@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Nov 12, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 12, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev 8be35a1 Commit Preview URL

Branch Preview URL
Nov 13 2025, 06:42 PM

)
}

const data = (await response.json()) as { cdnEgressQuota: string; cacheMissEgressQuota: string }
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, sure, but also maybe it's not this type?
elsewhere in the SDK we do actual validation, not just type assertion, it shouldn't be hard to add an object check and two string typeof's in here, even just make it a function that becomes a type guard and throws appropriately if it's not what you expect; cause you're doing some BigInt down below and those could fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 2c8d4f7

}

// Create FilBeamService
const filbeamService = await FilBeamService.create(provider)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should change this to just take network, not provider because that's all you're using it for. Then it doesn't need to be async, you can just use a constructor instead of the async factory, and you don't have yet another getNetworkType call in the Synapse initialisation path (it should be cached, but we don't have a guarantee of that). Nice and fast to get this set up.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to keep the create signature similar to other services but since we're not using the provider for anything else I think you made a fair point. Fixed in 2c8d4f7

- Validate data set stats response from Filbeam stats API
- Change create signature to accept network instead of provider
@pyropy pyropy requested a review from rvagg November 12, 2025 17:30
@pyropy pyropy moved this from 📌 Triage to ⌨️ In Progress in FS Nov 12, 2025
Copy link

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

Let's also update the relevant documentation, please. Show Synapse SDK users how to use this new API.

I am not sure if the current docs mention the withCDN option at all. If it does not, then let's create a follow-up issue to address the problem of the missing docs holistically.

@pyropy
Copy link
Member Author

pyropy commented Nov 12, 2025

Let's also update the relevant documentation, please. Show Synapse SDK users how to use this new API.

I am not sure if the current docs mention the withCDN option at all. If it does not, then let's create a follow-up issue to address the problem of the missing docs holistically.

Great point! I've generated some docs that you can preview here

* const service = FilBeamService.create('mainnet')
* ```
*/
static create(network: FilecoinNetworkType, fetchImpl?: typeof fetch): FilBeamService {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wouldn't bother with this, the only reason we use a factory in other places is to deal with async initialisation, but where you only have sync you really just need a constructor, so you've now got two constructors here

@socket-security
Copy link

socket-security bot commented Nov 13, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedp-defer@​4.0.11001007677100
Added@​types/​chai@​5.2.31001007785100
Addedchai@​6.2.110010010087100
Added@​sentry/​browser@​10.25.010010091100100
Addedmsw@​2.10.59310010094100
Added@​sentry/​node@​10.25.0100100100100100

View full report

…:FilOzone/synapse-sdk into feat/api-to-query-remaining-egress-stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⌨️ In Progress

Development

Successfully merging this pull request may close these issues.

API to query the remaining egress allowances for a given data set

4 participants