Skip to content

Commit f4c22f1

Browse files
stalniyclaude
andauthored
docs: replace deprecated SDL class with generateManifest in SDK docs (#1053)
The SDL class in @akashnetwork/chain-sdk is deprecated. Updated all TypeScript examples to use the new generateManifest, generateManifestVersion, yaml template tag, and SDLInput type. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 449cd64 commit f4c22f1

File tree

3 files changed

+122
-68
lines changed

3 files changed

+122
-68
lines changed

src/content/Docs/api-documentation/sdk/api-reference/index.mdx

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,36 @@ func main() {
112112
{
113113
language: "typescript",
114114
label: "TypeScript",
115-
code: `import { SDL } from "@akashnetwork/chain-sdk";
116-
117-
// Parse SDL from YAML string
118-
const sdl = SDL.fromString(yamlString, "beta3", "mainnet");
119-
120-
// Get deployment manifest
121-
const manifest = sdl.manifest();
122-
// Returns: Array of deployment groups with service definitions
123-
124-
// Get deployment groups
125-
const groups = sdl.groups();
126-
// Returns: Array of GroupSpec objects for blockchain submission`
115+
code: `import { generateManifest, generateManifestVersion, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
116+
117+
// Define SDL using the yaml template tag
118+
const sdl: SDLInput = yaml\`
119+
version: "2.0"
120+
services:
121+
web:
122+
image: nginx
123+
expose:
124+
- port: 80
125+
as: 80
126+
to:
127+
- global: true
128+
\`;
129+
130+
// Generate manifest and deployment groups
131+
const result = generateManifest(sdl);
132+
133+
if (!result.ok) {
134+
console.error("Validation errors:", result.value);
135+
} else {
136+
// Get deployment manifest (Array of groups with service definitions)
137+
const manifest = result.value.groups;
138+
139+
// Get deployment groups (Array of GroupSpec for blockchain submission)
140+
const groupSpecs = result.value.groupSpecs;
141+
142+
// Get SDL version hash (SHA-256)
143+
const version = await generateManifestVersion(manifest);
144+
}`
127145
},
128146
{
129147
language: "go",
@@ -150,13 +168,16 @@ version, err := sdlDoc.Version()
150168
]}
151169
/>
152170

153-
**TypeScript Methods:**
154-
- `SDL.fromString(yaml, version?, networkId?)` - Parse SDL from YAML
155-
- `yaml`: YAML string
156-
- `version`: "beta2" | "beta3" (default: "beta3")
171+
**TypeScript Functions:**
172+
- `generateManifest(sdl, networkId?)` - Generate manifest and deployment groups
173+
- `sdl`: `SDLInput` - Parsed SDL object (use the `yaml` template tag)
157174
- `networkId`: "mainnet" | "testnet" | "sandbox" (default: "mainnet")
158-
- `sdl.manifest()` - Get deployment manifest
159-
- `sdl.groups()` - Get deployment groups for blockchain
175+
- Returns `{ ok: true, value: { groups, groupSpecs } }` on success
176+
- Returns `{ ok: false, value: ValidationError[] }` on validation failure
177+
- `generateManifestVersion(manifest)` - Get SHA-256 hash of manifest
178+
- `manifest`: `Manifest` - The `groups` array from `generateManifest` result
179+
- Returns `Promise<Uint8Array>`
180+
- `` yaml`...` `` - Template tag for defining SDL with interpolation support
160181

161182
**Go Functions:**
162183
- `sdl.ReadFile(path)` - Read SDL from file
@@ -240,10 +261,16 @@ dep, err := client.Query().Deployment().Deployment(ctx,
240261
{
241262
language: "typescript",
242263
label: "TypeScript",
243-
code: `import { SDL } from "@akashnetwork/chain-sdk";
264+
code: `import { generateManifest, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
244265
245-
const sdl = SDL.fromString(yamlString);
246-
const groups = sdl.groups();
266+
const sdl: SDLInput = yaml\`...\`; // Your SDL definition
267+
const result = generateManifest(sdl);
268+
269+
if (!result.ok) {
270+
throw new Error("SDL validation failed: " + JSON.stringify(result.value));
271+
}
272+
273+
const { groupSpecs } = result.value;
247274
248275
// Get current block height for dseq
249276
const status = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock({});
@@ -253,12 +280,12 @@ const dseq = status.block.header.height;
253280
const accounts = await wallet.getAccounts();
254281
255282
// Create deployment
256-
const result = await sdk.akash.deployment.v1beta4.createDeployment({
283+
const deployResult = await sdk.akash.deployment.v1beta4.createDeployment({
257284
id: {
258285
owner: accounts[0].address,
259286
dseq: dseq
260287
},
261-
groups: groups,
288+
groups: groupSpecs,
262289
deposit: {
263290
denom: "uakt",
264291
amount: "5000000" // 5 AKT
@@ -311,15 +338,21 @@ resp, err := client.Tx().BroadcastMsgs(ctx, []sdk.Msg{msg})`
311338
{
312339
language: "typescript",
313340
label: "TypeScript",
314-
code: `const sdl = SDL.fromString(newYamlString);
315-
const groups = sdl.groups();
341+
code: `import { generateManifest, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
342+
343+
const newSdl: SDLInput = yaml\`...\`; // Your updated SDL definition
344+
const result = generateManifest(newSdl);
345+
346+
if (!result.ok) {
347+
throw new Error("SDL validation failed: " + JSON.stringify(result.value));
348+
}
316349
317-
const result = await sdk.akash.deployment.v1beta4.updateDeployment({
350+
const updateResult = await sdk.akash.deployment.v1beta4.updateDeployment({
318351
id: {
319352
owner: accounts[0].address,
320353
dseq: "1234567"
321354
},
322-
groups: groups
355+
groups: result.value.groupSpecs
323356
});`
324357
},
325358
{

src/content/Docs/api-documentation/sdk/examples/index.mdx

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ func main() {
135135
{
136136
language: "typescript",
137137
label: "TypeScript",
138-
code: `import { SDL } from "@akashnetwork/chain-sdk";
138+
code: `import { generateManifest, generateManifestVersion, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
139139
140-
const yaml = \`
140+
const sdl: SDLInput = yaml\`
141141
version: "2.0"
142142
services:
143143
web:
@@ -170,16 +170,22 @@ deployment:
170170
count: 1
171171
\`;
172172
173-
// Parse SDL from YAML string
174-
const sdl = SDL.fromString(yaml, "beta3", "mainnet");
173+
// Generate manifest and deployment groups
174+
const result = generateManifest(sdl);
175175
176-
// Get deployment manifest
177-
const manifest = sdl.manifest();
178-
console.log("Manifest:", manifest);
176+
if (!result.ok) {
177+
console.error("Validation errors:", result.value);
178+
} else {
179+
// Deployment manifest
180+
console.log("Manifest:", result.value.groups);
179181
180-
// Get deployment groups
181-
const groups = sdl.groups();
182-
console.log("Groups:", groups);`
182+
// Deployment groups for blockchain submission
183+
console.log("Group Specs:", result.value.groupSpecs);
184+
185+
// Get SDL version hash (SHA-256)
186+
const version = await generateManifestVersion(result.value.groups);
187+
console.log("Version:", version);
188+
}`
183189
}
184190
]}
185191
/>
@@ -415,10 +421,10 @@ func createDeployment(ctx context.Context, client v1beta3.Client, sdlPath string
415421
{
416422
language: "typescript",
417423
label: "TypeScript",
418-
code: `import { SDL } from "@akashnetwork/chain-sdk";
424+
code: `import { generateManifest, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
419425
420-
// Parse SDL
421-
const yaml = \`
426+
// Define SDL
427+
const sdl: SDLInput = yaml\`
422428
version: "2.0"
423429
services:
424430
web:
@@ -451,8 +457,13 @@ deployment:
451457
count: 1
452458
\`;
453459
454-
const sdl = SDL.fromString(yaml, "beta3", "mainnet");
455-
const groups = sdl.groups();
460+
const result = generateManifest(sdl);
461+
462+
if (!result.ok) {
463+
throw new Error("SDL validation failed: " + JSON.stringify(result.value));
464+
}
465+
466+
const { groupSpecs } = result.value;
456467
457468
// Get current block height for dseq
458469
const status = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock({});
@@ -462,20 +473,20 @@ const dseq = status.block.header.height;
462473
const accounts = await wallet.getAccounts();
463474
464475
// Create deployment
465-
const result = await sdk.akash.deployment.v1beta4.createDeployment({
476+
const deployResult = await sdk.akash.deployment.v1beta4.createDeployment({
466477
id: {
467478
owner: accounts[0].address,
468479
dseq: dseq
469480
},
470-
groups: groups,
481+
groups: groupSpecs,
471482
deposit: {
472483
denom: "uakt",
473484
amount: "5000000" // 5 AKT
474485
},
475486
depositor: accounts[0].address
476487
});
477488
478-
console.log("Deployment created:", result);`
489+
console.log("Deployment created:", deployResult);`
479490
}
480491
]}
481492
/>
@@ -866,16 +877,16 @@ func useJWT(token string, dseq uint64) {
866877
language: "typescript",
867878
label: "TypeScript",
868879
code: `import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
869-
import { createChainNodeSDK, SDL } from "@akashnetwork/chain-sdk";
880+
import { createChainNodeSDK, generateManifest, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
870881
871882
async function deployToAkash() {
872883
// 1. Initialize wallet
873884
const mnemonic = "your mnemonic phrase here";
874-
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
875-
prefix: "akash"
885+
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
886+
prefix: "akash"
876887
});
877888
const accounts = await wallet.getAccounts();
878-
889+
879890
// 2. Initialize SDK
880891
const sdk = createChainNodeSDK({
881892
query: {
@@ -886,9 +897,9 @@ async function deployToAkash() {
886897
signer: wallet,
887898
},
888899
});
889-
890-
// 3. Parse SDL
891-
const yaml = \`
900+
901+
// 3. Define and generate manifest from SDL
902+
const sdl: SDLInput = yaml\`
892903
version: "2.0"
893904
services:
894905
web:
@@ -920,21 +931,26 @@ deployment:
920931
profile: web
921932
count: 1
922933
\`;
923-
924-
const sdl = SDL.fromString(yaml, "beta3", "mainnet");
925-
const groups = sdl.groups();
926-
934+
935+
const result = generateManifest(sdl);
936+
937+
if (!result.ok) {
938+
throw new Error("SDL validation failed: " + JSON.stringify(result.value));
939+
}
940+
941+
const { groupSpecs } = result.value;
942+
927943
// 4. Get current block height
928944
const status = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock({});
929945
const dseq = status.block.header.height;
930-
946+
931947
// 5. Create deployment
932948
const deployment = await sdk.akash.deployment.v1beta4.createDeployment({
933949
id: {
934950
owner: accounts[0].address,
935951
dseq: dseq
936952
},
937-
groups: groups,
953+
groups: groupSpecs,
938954
deposit: {
939955
denom: "uakt",
940956
amount: "5000000"

src/content/Docs/api-documentation/sdk/quick-start/index.mdx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Before you begin, ensure you have:
5656
language: "typescript",
5757
label: "TypeScript",
5858
code: `import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
59-
import { createChainNodeSDK, SDL } from "@akashnetwork/chain-sdk";
59+
import { createChainNodeSDK, generateManifest, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
6060
6161
// Initialize wallet from mnemonic
6262
const mnemonic = "your mnemonic phrase here";
@@ -192,10 +192,10 @@ deployment:
192192
{
193193
language: "typescript",
194194
label: "TypeScript",
195-
code: `import { SDL } from "@akashnetwork/chain-sdk";
195+
code: `import { generateManifest, yaml, type SDLInput } from "@akashnetwork/chain-sdk";
196196
197-
// Read SDL file (or use string directly)
198-
const yamlContent = \`
197+
// Define SDL using the yaml template tag
198+
const sdl: SDLInput = yaml\`
199199
version: "2.0"
200200
services:
201201
web:
@@ -228,9 +228,14 @@ deployment:
228228
count: 1
229229
\`;
230230
231-
// Parse SDL
232-
const sdl = SDL.fromString(yamlContent, "beta3", "sandbox");
233-
const groups = sdl.groups();
231+
// Generate manifest and deployment groups
232+
const result = generateManifest(sdl, "sandbox");
233+
234+
if (!result.ok) {
235+
throw new Error("SDL validation failed: " + JSON.stringify(result.value));
236+
}
237+
238+
const { groups, groupSpecs } = result.value;
234239
235240
console.log("SDL parsed successfully");
236241
@@ -246,7 +251,7 @@ const deployment = await sdk.akash.deployment.v1beta4.createDeployment({
246251
owner: accounts[0].address,
247252
dseq: dseq
248253
},
249-
groups: groups,
254+
groups: groupSpecs,
250255
deposit: {
251256
denom: "uakt",
252257
amount: "5000000" // 5 AKT deposit
@@ -472,8 +477,8 @@ const token = await tokenManager.generateToken({
472477
leases: { access: "full" }
473478
});
474479
475-
// Get manifest from SDL
476-
const manifest = sdl.manifest();
480+
// Use manifest from earlier generateManifest result (groups = manifest)
481+
const manifest = groups;
477482
478483
// Send manifest to provider
479484
const providerUrl = selectedBid.bidId.provider; // Get provider URL from chain

0 commit comments

Comments
 (0)