Skip to content

Comments

feat: add support for starknet network#476

Merged
wa0x6e merged 8 commits intomasterfrom
feat-return-starknet-block
Jul 3, 2025
Merged

feat: add support for starknet network#476
wa0x6e merged 8 commits intomasterfrom
feat-return-starknet-block

Conversation

@wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented May 30, 2025

Toward https://github.com/snapshot-labs/workflow/issues/562

This PR will add support for starknet network.

Tests

query {
  blocks (where: { ts: 1640000000, network_in: ["0x534e5f4d41494e", "1"] }) {
    network
    number
  }
}

This should return

{
  "data": {
    "blocks": [
      {
        "network": "1",
        "number": 13841761
      },
      {
        "network": "0x534e5f4d41494e",
        "number": 407
      }
    ]
  }
}

It is returning blocks, matching the timestamp (Monday, December 20, 2021 11:33:20 AM)

Note

Depends on snapshot-labs/snapshot.js#1155

@wa0x6e wa0x6e requested a review from Copilot May 30, 2025 14:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for the Starknet network to the block‐fetching utilities, refactors the cache helpers to use the new util, and provides integration tests plus a dedicated test script.

  • Introduce getBlockNumber/interpretResult with Starknet‐specific field mapping
  • Refactor getBlock/getRange in cache.ts to leverage getBlockNumber
  • Add integration tests for getBlockNumber and a test:integration npm script

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
test/integration/helpers/utils.test.ts New integration tests for getBlockNumber, including Starknet
src/helpers/utils.ts Implements getBlockNumber and interpretResult logic
src/helpers/cache.ts Refactors cache functions to call getBlockNumber
package.json Adds test:integration script and updates the main test command
Comments suppressed due to low confidence (3)

test/integration/helpers/utils.test.ts:44

  • Only the first Starknet network ID is tested. Add a case for the second ID (0x534e5f5345504f4c4941) to ensure full Starknet coverage.
it('should handle starknet specific block', async () => {

src/helpers/cache.ts:5

  • [nitpick] The name starts is vague. Consider renaming to startBlockByNetwork for clarity.
const starts: Record<string, number> = {};

src/helpers/cache.ts:10

  • [nitpick] blocks could be misread. Rename to blockCache or similar to reflect its purpose as a timestamp‐indexed cache.
const blocks: Record<string, Record<string, number>> = {};

wa0x6e and others added 5 commits May 30, 2025 23:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@wa0x6e wa0x6e requested a review from ChaituVR June 21, 2025 18:19
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jun 30, 2025

Will wait for snapshot-labs/snapshot.js#1165

@ChaituVR
Copy link
Member

ChaituVR commented Jul 1, 2025

Updated blockfinder #484

@wa0x6e wa0x6e requested a review from ChaituVR July 1, 2025 15:16
@ChaituVR
Copy link
Member

ChaituVR commented Jul 2, 2025

Something weird in my local, i tried above request but it give me 0 block instead of 407
I also tried same time for 1000 block = 1644428894 it still give me 0 🤔 is it same for you?

@ChaituVR
Copy link
Member

ChaituVR commented Jul 2, 2025

image
Also it is returning latest if i pass latest timestamp, is it expected?

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jul 3, 2025

image Also it is returning latest if i pass latest timestamp, is it expected?

You get the same latest result, even on network 1, when the ts is very close to the current time.

Starknet block takes a little more time than eth

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jul 3, 2025

After a few refresh, it finally returns a block number, it can take up to 1 min

Copy link
Member

@ChaituVR ChaituVR left a comment

Choose a reason for hiding this comment

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

tAck

@wa0x6e wa0x6e merged commit 4efb570 into master Jul 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants