Skip to content

Commit 4f9822b

Browse files
committed
chore: update migration docs - skip deploy
1 parent 871b661 commit 4f9822b

File tree

1 file changed

+78
-76
lines changed

1 file changed

+78
-76
lines changed

docs/MIGRATION.md

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,54 @@ This guide helps you upgrade from any version **before v1.17.2** to **v1.17.x**
88

99
## Table of Contents
1010

11-
- [Breaking Changes](#breaking-changes)
12-
- [1. setMetadata() is Now Async](#1-setmetadata-is-now-async)
13-
- [2. Wallet Strategies Require Explicit Loading](#2-wallet-strategies-require-explicit-loading)
14-
- [3. Buffer Dependency Removed](#3-buffer-dependency-removed)
15-
- [4. Apollo GraphQL Client Removed](#4-apollo-graphql-client-removed)
16-
- [Deprecations](#deprecations)
17-
- [Type Imports from @injectivelabs/ts-types](#type-imports-from-injectivelabtsts-types)
18-
- [Recommended Updates](#recommended-updates)
19-
- [Use Subpath Imports for Better Tree-Shaking](#use-subpath-imports-for-better-tree-shaking)
20-
- [New Features](#new-features)
21-
- [Lazy Loading Methods](#lazy-loading-methods)
22-
- [Encoding Utilities](#encoding-utilities)
23-
- [Migration Checklist](#migration-checklist)
24-
- [Troubleshooting](#troubleshooting)
25-
- [Complete Code Examples](#complete-code-examples)
26-
- [Benefits](#benefits)
27-
- [Resources](#resources)
11+
- [Migration Guide: Upgrading to v1.17.x](#migration-guide-upgrading-to-v117x)
12+
- [Table of Contents](#table-of-contents)
13+
- [Breaking Changes](#breaking-changes)
14+
- [1. setMetadata() is Now Async](#1-setmetadata-is-now-async)
15+
- [❌ Before](#-before)
16+
- [✅ After](#-after)
17+
- [2. Wallet Strategies Require Explicit Loading](#2-wallet-strategies-require-explicit-loading)
18+
- [❌ Before](#-before-1)
19+
- [✅ After](#-after-1)
20+
- [3. Buffer Dependency Removed](#3-buffer-dependency-removed)
21+
- [Migration Table](#migration-table)
22+
- [❌ Before](#-before-2)
23+
- [✅ After](#-after-2)
24+
- [4. Apollo GraphQL Client Removed](#4-apollo-graphql-client-removed)
25+
- [❌ Before](#-before-3)
26+
- [✅ After](#-after-3)
27+
- [Deprecations](#deprecations)
28+
- [Type Imports from @injectivelabs/ts-types](#type-imports-from-injectivelabsts-types)
29+
- [⚠️ Deprecated Types](#️-deprecated-types)
30+
- [❌ Before](#-before-4)
31+
- [✅ After](#-after-4)
32+
- [Recommended Updates](#recommended-updates)
33+
- [Use Subpath Imports for Better Tree-Shaking](#use-subpath-imports-for-better-tree-shaking)
34+
- [💡 Before (Still Works)](#-before-still-works)
35+
- [💡 After (Recommended)](#-after-recommended)
36+
- [Available Subpath Imports](#available-subpath-imports)
37+
- [New Features](#new-features)
38+
- [Lazy Loading Methods](#lazy-loading-methods)
39+
- [Encoding Utilities](#encoding-utilities)
40+
- [Troubleshooting](#troubleshooting)
41+
- [Error: "Wallet X strategy not loaded. Call setWallet() or loadStrategy() first."](#error-wallet-x-strategy-not-loaded-call-setwallet-or-loadstrategy-first)
42+
- [Error: "setMetadata is not a function" or unexpected behavior](#error-setmetadata-is-not-a-function-or-unexpected-behavior)
43+
- [Error: "Buffer is not defined"](#error-buffer-is-not-defined)
44+
- [TypeScript errors: Cannot find module '@injectivelabs/sdk-ts/client/indexer'](#typescript-errors-cannot-find-module-injectivelabssdk-tsclientindexer)
45+
- [Module not found errors after upgrading](#module-not-found-errors-after-upgrading)
46+
- [Complete Code Examples](#complete-code-examples)
47+
- [Full Wallet Strategy Migration](#full-wallet-strategy-migration)
48+
- [❌ Before v1.17.x](#-before-v117x)
49+
- [✅ After v1.17.x](#-after-v117x)
50+
- [Full Trading Application Migration](#full-trading-application-migration)
51+
- [❌ Before v1.17.x](#-before-v117x-1)
52+
- [✅ After v1.17.x (with subpath imports)](#-after-v117x-with-subpath-imports)
53+
- [Benefits](#benefits)
54+
- [Performance Improvements](#performance-improvements)
55+
- [Developer Experience](#developer-experience)
56+
- [Code Quality](#code-quality)
57+
- [Maintenance](#maintenance)
58+
- [Resources](#resources)
2859

2960
---
3061

@@ -201,33 +232,44 @@ const gqlClient = new GqlClient(endpoint)
201232

202233
#### ✅ After
203234

204-
If you were using the GraphQL client, you have two options:
235+
If you were using the GraphQL client, use `HttpClient` for GraphQL queries:
205236

206-
1. **Use the REST/gRPC clients instead** (recommended):
207-
208-
```typescript
209-
import { IndexerGrpcAccountApi } from '@injectivelabs/sdk-ts/client/indexer'
237+
```typescript
238+
import { HttpClient } from '@injectivelabs/utils'
210239

211-
const indexerApi = new IndexerGrpcAccountApi(endpoint)
212-
```
240+
const client = new HttpClient('YOUR_GRAPHQL_ENDPOINT')
213241

214-
2. **Implement your own GraphQL client**:
242+
// Optional: Set auth headers if required
243+
client.setConfig({
244+
headers: {
245+
authorization: 'Bearer YOUR_API_KEY',
246+
},
247+
})
215248

216-
See the official documentation for GraphQL endpoint usage: [Querying GraphQL Endpoints](https://docs.injective.network/developers-native/query-ethereum#querying-graphql-endpoints)
249+
// Make a query
250+
const query = JSON.stringify({
251+
query: `
252+
query GetData($id: ID!) {
253+
entity(id: $id) {
254+
id
255+
name
256+
value
257+
}
258+
}
259+
`,
260+
variables: { id: '123' },
261+
})
217262

218-
```typescript
219-
import { ApolloClient, InMemoryCache } from '@apollo/client'
263+
const response = await client.post<string, { data: { data: YourResponseType } }>('', query)
264+
console.log(response.data.data)
265+
```
220266

221-
const client = new ApolloClient({
222-
uri: endpoint,
223-
cache: new InMemoryCache(),
224-
})
225-
```
267+
**Full documentation**: [Querying GraphQL Endpoints](https://docs.injective.network/developers-native/query-ethereum#querying-graphql-endpoints)
226268

227269
**Action Required**:
228270

229-
- If using GraphQL client, migrate to gRPC/REST APIs or implement your own Apollo client
230-
- See [GraphQL documentation](https://docs.injective.network/developers-native/query-ethereum#querying-graphql-endpoints) for implementation guidance
271+
- If using GraphQL client, use `HttpClient` from `@injectivelabs/utils`
272+
- See [GraphQL documentation](https://docs.injective.network/developers-native/query-ethereum#querying-graphql-endpoints) for complete implementation examples
231273
- Remove any imports from `@injectivelabs/sdk-ts/client/gql`
232274

233275
---
@@ -367,46 +409,6 @@ const hex = uint8ArrayToHex(bytes)
367409

368410
---
369411

370-
## Migration Checklist
371-
372-
Use this checklist to ensure a complete migration:
373-
374-
### Critical (Must Fix)
375-
376-
- [ ] **Search for `setMetadata(`** in your codebase
377-
- [ ] Add `await` before each call
378-
- [ ] Ensure containing functions are `async`
379-
380-
- [ ] **Update wallet initialization**
381-
- [ ] Remove `wallet` option from `WalletStrategy` constructor
382-
- [ ] Add `await walletStrategy.setWallet(Wallet.YourWallet)` after construction
383-
- [ ] Move wallet method calls after `setWallet()`
384-
385-
- [ ] **Replace Buffer usage**
386-
- [ ] Search for `Buffer.from(`
387-
- [ ] Search for `.toString('hex')`, `.toString('base64')`, etc.
388-
- [ ] Replace with encoding utilities from migration table
389-
- [ ] Add imports: `import { ... } from '@injectivelabs/sdk-ts/utils'`
390-
391-
- [ ] **Remove GraphQL client usage** (if applicable)
392-
- [ ] Replace with gRPC/REST clients or implement own Apollo client
393-
- [ ] Remove imports from `@injectivelabs/sdk-ts/client/gql`
394-
395-
### Recommended (Avoid Future Deprecation)
396-
397-
- [ ] **Update deprecated type imports**
398-
- [ ] Search for `from '@injectivelabs/ts-types'`
399-
- [ ] Replace with `from '@injectivelabs/sdk-ts/types'`
400-
401-
### Optional (Performance Benefits)
402-
403-
- [ ] **Migrate to subpath imports**
404-
- [ ] Update imports to use subpath patterns
405-
- [ ] Measure bundle size improvements
406-
- [ ] Configure IDE to prefer subpath imports
407-
408-
---
409-
410412
## Troubleshooting
411413

412414
### Error: "Wallet X strategy not loaded. Call setWallet() or loadStrategy() first."
@@ -672,7 +674,7 @@ Upgrading to v1.17.x provides several benefits:
672674
- [`packages/ts-types/src/trade.ts`](../packages/ts-types/src/trade.ts)
673675
- [`packages/ts-types/src/common.ts`](../packages/ts-types/src/common.ts)
674676
- **Wallet Strategy Source**: [`packages/wallets/wallet-strategy/src/strategy/index.ts`](../packages/wallets/wallet-strategy/src/strategy/index.ts)
675-
- **Documentation PR**: [injective-docs #18](https://github.com/InjectiveLabs/injective-docs/pull/18) - Real-world migration examples
677+
- **Documentation**: [injective-docs](https://docs.injective.network/)
676678

677679
---
678680

0 commit comments

Comments
 (0)