Skip to content
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

[Web Client] Policy.GENESIS_BLOCK_NUMBER returns 0 #2956

Open
onmax opened this issue Oct 7, 2024 · 2 comments
Open

[Web Client] Policy.GENESIS_BLOCK_NUMBER returns 0 #2956

onmax opened this issue Oct 7, 2024 · 2 comments
Labels

Comments

@onmax
Copy link
Member

onmax commented Oct 7, 2024

The static property GENESIS_BLOCK_NUMBER is 0 in the Policy class

import init, { Policy } from '@nimiq/core/web'

await init() // Nees to wait otherwise Policy is undefined

const app = document.querySelector<HTMLDivElement>('#app')!
app.innerHTML = `
    Genesis Block Number is ${Policy.GENESIS_BLOCK_NUMBER}<br/>
    Slots ${Policy.SLOTS}<br/>
    Batches per epoch ${Policy.BATCHES_PER_EPOCH}
`

Prints the following:

Genesis Block Number is 0
Slots 512
Batches per epoch 720

Code in the Playground

Using the getPolicyConstant method from the RPC, the Genesis block number is 3032010.

Am I using the web client incorrectly? Thank you!

@onmax onmax added the WASM label Oct 7, 2024
@sisou
Copy link
Member

sisou commented Oct 7, 2024

The genesis block number depends on the Network. So I'm guessing that part doesn't work? The Policy needs to be initialized somehow first.

@hrxi
Copy link
Contributor

hrxi commented Oct 7, 2024

I guess optimally, the genesis block number would not be part of the policy, since the genesis block can be fed at runtime. The way Policy can currently return the genesis block number is made possible by some late-initialization hacks, which didn't work out here, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants