-
Notifications
You must be signed in to change notification settings - Fork 25
feat(client): replace NetworkId with Chain descriptor #223
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
ca54a58
a25cb01
342da47
3866c80
c5abca1
80d7339
7422aaa
a97ee5a
2c7c6f2
8eff4d0
5fbf1fa
8d5fa70
bbc243d
95a39d1
0e7af2e
285dc9d
29082e0
3d09065
3f31d90
9bf968c
6b81331
18368c8
ad56853
f1861de
a91d8c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| --- | ||
| "@evolution-sdk/evolution": patch | ||
| "@evolution-sdk/devnet": patch | ||
| --- | ||
|
|
||
| `createClient` now requires an explicit `chain` field instead of the optional `network?: string` field. | ||
|
|
||
| Previously, selecting a network required passing a string identifier and, separately, a `slotConfig` object for slot/time conversions. There was no single source of truth that tied network identity, magic number, and timing parameters together: | ||
|
|
||
| ```ts | ||
| // Before | ||
| createClient({ | ||
| network: "preprod", | ||
| slotConfig: { zeroTime: 1655769600000n, zeroSlot: 86400n, slotLength: 1000 }, | ||
| provider: { ... }, | ||
| wallet: { ... } | ||
| }) | ||
| ``` | ||
|
|
||
| Now the `chain` field is a rich descriptor that carries all of this together. Three built-in constants are exported from the top-level package: | ||
|
|
||
| ```ts | ||
| // After | ||
| import { createClient, preprod } from "@evolution-sdk/evolution" | ||
|
|
||
| createClient({ | ||
| chain: preprod, | ||
| provider: { ... }, | ||
| wallet: { ... } | ||
| }) | ||
| ``` | ||
|
|
||
| For custom networks — local devnets, private chains, or future forks — use `defineChain`: | ||
|
|
||
| ```ts | ||
| import { defineChain } from "@evolution-sdk/evolution" | ||
|
|
||
| const devnet = defineChain({ | ||
| name: "Devnet", | ||
| id: 0, | ||
| networkMagic: 42, | ||
| slotConfig: { zeroTime: 0n, zeroSlot: 0n, slotLength: 1000 }, | ||
| epochLength: 432000, | ||
| }) | ||
| ``` | ||
|
|
||
| The `networkId: number | string` property on client objects is replaced with `chain: Chain`. The `@evolution-sdk/devnet` package adds `getChain(cluster)` and `BOOTSTRAP_CHAIN` for constructing a `Chain` from a running local devnet. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,10 +30,12 @@ Different combinations create different client types with distinct capabilities. | |
| All clients use `createClient` with different configurations: | ||
|
|
||
| ```typescript | ||
| import { mainnet, preprod, preview, defineChain } from "@evolution-sdk/evolution"; | ||
|
|
||
| createClient({ | ||
| network: "mainnet" | "preprod" | "preview", | ||
| provider?: ProviderConfig, // Optional | ||
| wallet?: WalletConfig // Optional | ||
| chain: mainnet | preprod | preview, // or a custom chain via defineChain(...) | ||
| provider?: ProviderConfig, // Optional | ||
| wallet?: WalletConfig // Optional | ||
| }) | ||
|
||
| ``` | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changeset marks the release as a patch, but replacing
network?: NetworkIdwith requiredchain: Chain(and removingcreateClient()/ default-network behavior) is a breaking public API change. The changeset should be a major bump (or at least follow the repo’s documented semver policy for breaking changes).