o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
493 stars 108 forks source link

Fetch `networkId` automatically from GraphQL endpoint #1492

Open L-as opened 5 months ago

L-as commented 5 months ago

That way when using custom networks you don't have to set the salt for both account update hashing and signatures manually.

L-as commented 5 months ago

https://github.com/MinaProtocol/mina/blob/f16675abd2cee3c39a10f450bdc6fa3f6c998404/graphql_schema.json#L15319 for reference

Trivo25 commented 5 months ago

Right now, you will have to specify a custom network like this

Mina.Network({
    // ...
    networkId: 'mainnet',
});

// mina-signer
let client = new Client({ network: 'mainnet' });

Which the developer will have to do once they publish their zkApp on a website or somewhere else. Do you think fetching would still be better? I like the explicit declaration of the network, especially since it's a tiny change - it clearly marks what network you want to interact with (default being the testnet)

L-as commented 5 months ago

Even if it's made explicit, at the very least it should automatically be checked against what the endpoint returns. FWIW signatureKind might be the correct thing to fetch, since multiple networks might use same signatures, OTOH, that should optimally never be the case.