|
| 1 | +# Migration Guide |
| 2 | + |
| 3 | +## Migrating from v1.x to v2.0.0 |
| 4 | + |
| 5 | +Version 2.0.0 introduces breaking changes to prepare the SDK for multi-VM support. All EVM-specific code has been |
| 6 | +namespaced under `evm` to allow future expansion to other VMs (like Solana). |
| 7 | + |
| 8 | +### Breaking Changes |
| 9 | + |
| 10 | +#### 1. Sablier API Renamed |
| 11 | + |
| 12 | +The `sablier` object properties have been renamed to include the `evm` prefix: |
| 13 | + |
| 14 | +**Before (v1.x)**: |
| 15 | + |
| 16 | +```typescript |
| 17 | +import { sablier } from "sablier"; |
| 18 | + |
| 19 | +const chain = sablier.chains.get({ chainId: 1 }); |
| 20 | +const contract = sablier.contracts.get({ |
| 21 | + name: "SablierLockup", |
| 22 | + release: releases.lockup["v2.0"], |
| 23 | + chainId: 1, |
| 24 | +}); |
| 25 | +const releases = sablier.releases.getAll(); |
| 26 | +const deployment = sablier.deployments.get({ |
| 27 | + chainId: 1, |
| 28 | + release: releases.lockup["v2.0"], |
| 29 | +}); |
| 30 | +``` |
| 31 | + |
| 32 | +**After (v2.0.0)**: |
| 33 | + |
| 34 | +```typescript |
| 35 | +import { sablier } from "sablier"; |
| 36 | + |
| 37 | +const chain = sablier.evmChains.get({ chainId: 1 }); |
| 38 | +const contract = sablier.evmContracts.get({ |
| 39 | + name: "SablierLockup", |
| 40 | + release: releases.lockup["v2.0"], |
| 41 | + chainId: 1, |
| 42 | +}); |
| 43 | +const releases = sablier.evmReleases.getAll(); |
| 44 | +const deployment = sablier.evmDeployments.get({ |
| 45 | + chainId: 1, |
| 46 | + release: releases.lockup["v2.0"], |
| 47 | +}); |
| 48 | +``` |
| 49 | + |
| 50 | +**Quick Replace**: |
| 51 | + |
| 52 | +- `sablier.chains` → `sablier.evmChains` |
| 53 | +- `sablier.contracts` → `sablier.evmContracts` |
| 54 | +- `sablier.releases` → `sablier.evmReleases` |
| 55 | +- `sablier.deployments` → `sablier.evmDeployments` |
| 56 | + |
| 57 | +#### 2. Import Paths Changed |
| 58 | + |
| 59 | +If you were using direct imports from subpaths, the paths have changed: |
| 60 | + |
| 61 | +**Before (v1.x)**: |
| 62 | + |
| 63 | +```typescript |
| 64 | +import { chains } from "sablier/chains"; |
| 65 | +import { contracts } from "sablier/contracts"; |
| 66 | +import { releases } from "sablier/releases"; |
| 67 | +``` |
| 68 | + |
| 69 | +**After (v2.0.0)**: |
| 70 | + |
| 71 | +```typescript |
| 72 | +// Option 1: Import from main entry point |
| 73 | +import { chains, contracts, releases } from "sablier"; |
| 74 | + |
| 75 | +// Option 2: Import from EVM-specific paths |
| 76 | +import { chains } from "sablier/evm/chains"; |
| 77 | +import { contracts } from "sablier/evm/contracts"; |
| 78 | +import { releases } from "sablier/evm/releases"; |
| 79 | + |
| 80 | +// Option 3: Import everything from evm |
| 81 | +import { chains, contracts, releases } from "sablier/evm"; |
| 82 | +``` |
| 83 | + |
| 84 | +**Recommendation**: Use Option 1 (main entry point) unless you need to optimize bundle size. |
| 85 | + |
| 86 | +#### 3. Type Namespace Updated |
| 87 | + |
| 88 | +All EVM-specific types are now under the `Sablier.EVM` namespace: |
| 89 | + |
| 90 | +**Before (v1.x)**: |
| 91 | + |
| 92 | +```typescript |
| 93 | +import type { Sablier } from "sablier"; |
| 94 | + |
| 95 | +type Address = Sablier.Address; |
| 96 | +type Chain = Sablier.Chain; |
| 97 | +type Contract = Sablier.Contract; |
| 98 | +type Release = Sablier.Release; |
| 99 | +type Deployment = Sablier.Deployment; |
| 100 | +type Protocol = Sablier.Protocol; |
| 101 | +type Version = Sablier.Version; |
| 102 | +``` |
| 103 | + |
| 104 | +**After (v2.0.0)**: |
| 105 | + |
| 106 | +```typescript |
| 107 | +import type { Sablier } from "sablier"; |
| 108 | + |
| 109 | +type Address = Sablier.EVM.Address; |
| 110 | +type Chain = Sablier.EVM.Chain; |
| 111 | +type Contract = Sablier.EVM.Contract; |
| 112 | +type Release = Sablier.EVM.Release; |
| 113 | +type Deployment = Sablier.EVM.Deployment; |
| 114 | +type Protocol = Sablier.EVM.Protocol; |
| 115 | +type Version = Sablier.EVM.Version; |
| 116 | +``` |
| 117 | + |
| 118 | +**Quick Replace in TypeScript files**: |
| 119 | + |
| 120 | +- `Sablier.Address` → `Sablier.EVM.Address` |
| 121 | +- `Sablier.Chain` → `Sablier.EVM.Chain` |
| 122 | +- `Sablier.Contract` → `Sablier.EVM.Contract` |
| 123 | +- `Sablier.Release` → `Sablier.EVM.Release` |
| 124 | +- `Sablier.Deployment` → `Sablier.EVM.Deployment` |
| 125 | +- `Sablier.Protocol` → `Sablier.EVM.Protocol` |
| 126 | +- `Sablier.Version` → `Sablier.EVM.Version` |
| 127 | + |
| 128 | +### Non-Breaking Changes |
| 129 | + |
| 130 | +The following imports continue to work without changes: |
| 131 | + |
| 132 | +```typescript |
| 133 | +// These still work exactly the same |
| 134 | +import { chains } from "sablier"; |
| 135 | +import { contracts } from "sablier"; |
| 136 | +import { releases } from "sablier"; |
| 137 | +import { sablier } from "sablier"; |
| 138 | + |
| 139 | +// Direct exports like these are unchanged |
| 140 | +import { mainnet, arbitrum, polygon } from "sablier"; |
| 141 | +import { Protocol, Version } from "sablier"; |
| 142 | +``` |
| 143 | + |
| 144 | +### Migration Checklist |
| 145 | + |
| 146 | +Use this checklist to ensure you've updated everything: |
| 147 | + |
| 148 | +- [ ] Update all `sablier.chains.*` to `sablier.evmChains.*` |
| 149 | +- [ ] Update all `sablier.contracts.*` to `sablier.evmContracts.*` |
| 150 | +- [ ] Update all `sablier.releases.*` to `sablier.evmReleases.*` |
| 151 | +- [ ] Update all `sablier.deployments.*` to `sablier.evmDeployments.*` |
| 152 | +- [ ] Update all `Sablier.Address` type references to `Sablier.EVM.Address` |
| 153 | +- [ ] Update all `Sablier.Chain` type references to `Sablier.EVM.Chain` |
| 154 | +- [ ] Update all `Sablier.Contract` type references to `Sablier.EVM.Contract` |
| 155 | +- [ ] Update all `Sablier.Release` type references to `Sablier.EVM.Release` |
| 156 | +- [ ] Update all `Sablier.Deployment` type references to `Sablier.EVM.Deployment` |
| 157 | +- [ ] Update any direct import paths from `sablier/chains` to `sablier/evm/chains` (or use main entry) |
| 158 | +- [ ] Run TypeScript compiler to catch any remaining type errors |
| 159 | +- [ ] Test your application thoroughly |
| 160 | + |
| 161 | +### Automated Migration |
| 162 | + |
| 163 | +You can use find-and-replace to automate most of the migration: |
| 164 | + |
| 165 | +#### Runtime Code: |
| 166 | + |
| 167 | +```bash |
| 168 | +# Find and replace in your codebase |
| 169 | +sablier.chains → sablier.evmChains |
| 170 | +sablier.contracts → sablier.evmContracts |
| 171 | +sablier.releases → sablier.evmReleases |
| 172 | +sablier.deployments → sablier.evmDeployments |
| 173 | +``` |
| 174 | + |
| 175 | +#### Type Definitions: |
| 176 | + |
| 177 | +```bash |
| 178 | +# Find and replace type references |
| 179 | +Sablier.Address → Sablier.EVM.Address |
| 180 | +Sablier.Chain → Sablier.EVM.Chain |
| 181 | +Sablier.Contract → Sablier.EVM.Contract |
| 182 | +Sablier.Release → Sablier.EVM.Release |
| 183 | +Sablier.Deployment → Sablier.EVM.Deployment |
| 184 | +Sablier.Protocol → Sablier.EVM.Protocol |
| 185 | +Sablier.Version → Sablier.EVM.Version |
| 186 | +``` |
| 187 | + |
| 188 | +#### Import Paths: |
| 189 | + |
| 190 | +```bash |
| 191 | +# If you used direct imports (optional) |
| 192 | +"sablier/chains" → "sablier/evm/chains" |
| 193 | +"sablier/contracts" → "sablier/evm/contracts" |
| 194 | +"sablier/releases" → "sablier/evm/releases" |
| 195 | +``` |
| 196 | + |
| 197 | +### Why This Change? |
| 198 | + |
| 199 | +This refactor prepares the SDK for multi-VM support. The EVM namespace makes it explicit which blockchain VM you're |
| 200 | +working with and allows us to add support for other VMs in the future: |
| 201 | + |
| 202 | +```typescript |
| 203 | +// Future (planned): |
| 204 | +sablier.evmChains; // Ethereum, Arbitrum, Polygon, etc. |
| 205 | +sablier.solanaChains; // Solana mainnet, devnet, testnet |
| 206 | +sablier.evmContracts; // EVM smart contracts |
| 207 | +sablier.solanaPrograms; // Solana programs |
| 208 | +``` |
| 209 | + |
| 210 | +By namespacing everything under `evm`, we're making the codebase more maintainable and preparing for a multi-chain |
| 211 | +future. |
| 212 | + |
| 213 | +### Need Help? |
| 214 | + |
| 215 | +If you encounter any issues during migration: |
| 216 | + |
| 217 | +1. Check the [README](./README.md) for updated examples |
| 218 | +2. Review the [CHANGELOG](./CHANGELOG.md) for detailed changes |
| 219 | +3. Open a [discussion](https://github.com/sablier-labs/sdk/discussions) on GitHub |
| 220 | +4. Join our [Discord](https://discord.sablier.com) for community support |
| 221 | + |
| 222 | +### Example Migration |
| 223 | + |
| 224 | +Here's a complete before/after example: |
| 225 | + |
| 226 | +**Before (v1.x)**: |
| 227 | + |
| 228 | +```typescript |
| 229 | +import { sablier, releases, chains } from "sablier"; |
| 230 | +import type { Sablier } from "sablier"; |
| 231 | + |
| 232 | +function getContractInfo(chainId: number): { |
| 233 | + chain: Sablier.Chain; |
| 234 | + contract: Sablier.Contract; |
| 235 | +} { |
| 236 | + const chain = sablier.chains.get({ chainId }); |
| 237 | + const contract = sablier.contracts.get({ |
| 238 | + name: "SablierLockup", |
| 239 | + release: releases.lockup["v2.0"], |
| 240 | + chainId, |
| 241 | + }); |
| 242 | + |
| 243 | + return { chain, contract }; |
| 244 | +} |
| 245 | +``` |
| 246 | + |
| 247 | +**After (v2.0.0)**: |
| 248 | + |
| 249 | +```typescript |
| 250 | +import { sablier, releases, chains } from "sablier"; |
| 251 | +import type { Sablier } from "sablier"; |
| 252 | + |
| 253 | +function getContractInfo(chainId: number): { |
| 254 | + chain: Sablier.EVM.Chain; |
| 255 | + contract: Sablier.EVM.Contract; |
| 256 | +} { |
| 257 | + const chain = sablier.evmChains.get({ chainId }); |
| 258 | + const contract = sablier.evmContracts.get({ |
| 259 | + name: "SablierLockup", |
| 260 | + release: releases.lockup["v2.0"], |
| 261 | + chainId, |
| 262 | + }); |
| 263 | + |
| 264 | + return { chain, contract }; |
| 265 | +} |
| 266 | +``` |
| 267 | + |
| 268 | +Notice the changes: |
| 269 | + |
| 270 | +1. `sablier.chains` → `sablier.evmChains` |
| 271 | +2. `sablier.contracts` → `sablier.evmContracts` |
| 272 | +3. `Sablier.Chain` → `Sablier.EVM.Chain` |
| 273 | +4. `Sablier.Contract` → `Sablier.EVM.Contract` |
0 commit comments