Skip to content

Commit 98b5364

Browse files
committed
docs: update docs
1 parent e4bc20e commit 98b5364

File tree

350 files changed

+16964
-4615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

350 files changed

+16964
-4615
lines changed

docs/content/docs/getting-started/data/basic-construction.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Learn how to create fundamental Data types using constructors."
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { Data } from "@evolution-sdk/evolution"
8+
import { Bytes, Data } from "@evolution-sdk/evolution"
99

1010
// Create a simple constructor with no fields
1111
const unit = new Data.Constr({ index: 0n, fields: [] })
@@ -14,15 +14,15 @@ console.log("Unit constructor:", unit)
1414
// Create a constructor with primitive fields
1515
const person = new Data.Constr({
1616
index: 1n,
17-
fields: ["416c696365", 30n] // 'Alice' as hex and age
17+
fields: [Bytes.fromHexUnsafe("416c696365"), 30n] // 'Alice' as bytes and age
1818
})
1919
console.log("Person constructor:", person)
2020

2121
// Create a constructor with mixed field types
2222
const record = new Data.Constr({
2323
index: 2n,
2424
fields: [
25-
"deadbeef", // bytes as hex string (ByteArray)
25+
Bytes.fromHexUnsafe("deadbeef"), // bytes as Uint8Array (ByteArray)
2626
42n, // big integer (Int)
2727
[1n, 2n, 3n], // array of big integers (List)
2828
new Data.Constr({ index: 0n, fields: [] }) // nested constructor
@@ -32,7 +32,7 @@ const record = new Data.Constr({
3232
// Verify the construction worked
3333
assert.equal(person.index, 1n)
3434
assert.equal(person.fields.length, 2)
35-
assert.equal(person.fields[0], "416c696365") // 'Alice' in hex
35+
assert.deepEqual(person.fields[0], Bytes.fromHexUnsafe("416c696365")) // 'Alice' in hex
3636
assert.equal(person.fields[1], 30n)
3737

3838
```
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: "Validate bytes"
3-
description: "Quick check for hex-like bytes strings using Data.isBytes."
3+
description: "Quick check for Uint8Array bytes using Data.isBytes."
44
---
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { Data } from "@evolution-sdk/evolution"
8+
import { Bytes, Data } from "@evolution-sdk/evolution"
99

10-
const hex = "deadbeef"
11-
assert.equal(Data.isBytes(hex), true)
10+
const bytes = Bytes.fromHexUnsafe("deadbeef")
11+
assert.equal(Data.isBytes(bytes), true)
1212

13-
const invalid = "not-hex"
13+
const invalid = "not-bytes"
1414
assert.equal(Data.isBytes(invalid), false)
1515

1616
```

docs/content/docs/getting-started/data/cbor-encoding-options.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ description: "Compare different CBOR encoding strategies for the same data."
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { CBOR, Data } from "@evolution-sdk/evolution"
8+
import { Bytes, CBOR, Data } from "@evolution-sdk/evolution"
99

1010
// Create complex data with unsorted elements (Maps should be standalone, not in constructor fields)
1111
const unsortedMap = new Map<Data.Data, Data.Data>([
12-
["7a65627261", 1n], // 'zebra' in hex
13-
["6170706c65", 2n], // 'apple' in hex
14-
["62616e616e61", 3n] // 'banana' in hex
12+
[Bytes.fromHexUnsafe("7a65627261"), 1n], // 'zebra' in hex
13+
[Bytes.fromHexUnsafe("6170706c65"), 2n], // 'apple' in hex
14+
[Bytes.fromHexUnsafe("62616e616e61"), 3n] // 'banana' in hex
1515
])
1616

1717
// Create a constructor with only valid field types
@@ -20,7 +20,7 @@ const complexData = new Data.Constr({
2020
fields: [
2121
// List with mixed order
2222
[100n, 1n, 50n, 25n],
23-
"deadbeef",
23+
Bytes.fromHexUnsafe("deadbeef"),
2424
42n // additional data
2525
]
2626
})

docs/content/docs/getting-started/data/complex-nested-structures.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ description: "Build sophisticated nested data structures with multiple levels an
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { Data } from "@evolution-sdk/evolution"
8+
import { Bytes, Data } from "@evolution-sdk/evolution"
99

1010
// Create a complex user profile with nested data using only valid Data types
1111
const userProfile = new Data.Constr({
1212
index: 0n, // User constructor
1313
fields: [
14-
"616c696365", // username 'alice' in hex
14+
Bytes.fromHexUnsafe("616c696365"), // username 'alice' in hex
1515
new Data.Constr({
1616
index: 1n, // Profile constructor
1717
fields: [
1818
25n, // age
19-
"deadbeef", // some profile data as hex
19+
Bytes.fromHexUnsafe("deadbeef"), // some profile data as hex
2020
// Nested preferences constructor
2121
new Data.Constr({
2222
index: 2n, // Preferences constructor
@@ -35,18 +35,18 @@ const userProfile = new Data.Constr({
3535
const transaction = new Data.Constr({
3636
index: 10n, // Transaction constructor
3737
fields: [
38-
"deadbeef1234", // transaction hash
38+
Bytes.fromHexUnsafe("deadbeef1234"), // transaction hash
3939
1000000n, // amount in microADA
4040
new Data.Constr({
4141
index: 11n, // Address constructor
42-
fields: ["616464723174657374"] // address data in hex
42+
fields: [Bytes.fromHexUnsafe("616464723174657374")] // address data in hex
4343
}),
4444
// Simple metadata as nested constructor
4545
new Data.Constr({
4646
index: 12n, // Metadata constructor
4747
fields: [
4848
1640995200n, // timestamp
49-
"7061796d656e74", // 'payment' as hex string
49+
Bytes.fromHexUnsafe("7061796d656e74"), // 'payment' as hex string
5050
1n // status code
5151
]
5252
})
@@ -55,7 +55,7 @@ const transaction = new Data.Constr({
5555

5656
// Test deep structure access
5757
assert.equal(userProfile.index, 0n)
58-
assert.equal(userProfile.fields[0], "616c696365") // alice in hex
58+
assert.deepEqual(userProfile.fields[0], Bytes.fromHexUnsafe("616c696365")) // alice in hex
5959

6060
// Verify nested constructor
6161
const profileData = userProfile.fields[1] as Data.Constr

docs/content/docs/getting-started/data/data.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: "Data"
77

88
// #region data-nested-canonical
99
import assert from "node:assert/strict"
10-
import { CBOR, Data } from "@evolution-sdk/evolution"
10+
import { Bytes, CBOR, Data } from "@evolution-sdk/evolution"
1111
// Create a complex nested data structure with:
1212
// - Constructor with index 1 containing multiple fields
1313
// - Nested constructors with different indices
@@ -28,9 +28,9 @@ const nestedUnsortedData = new Data.Constr({
2828
}),
2929
// Map with unsorted keys (will be sorted in canonical mode)
3030
new Map<Data.Data, Data.Data>([
31-
["deadbeef01", new Data.Constr({ index: 0n, fields: [] })],
32-
["beef", 19n],
33-
["deadbeef03", new Data.Constr({ index: 1n, fields: [] })]
31+
[Bytes.fromHexUnsafe("deadbeef01"), new Data.Constr({ index: 0n, fields: [] })],
32+
[Bytes.fromHexUnsafe("beef"), 19n],
33+
[Bytes.fromHexUnsafe("deadbeef03"), new Data.Constr({ index: 1n, fields: [] })]
3434
]),
3535
// Array of numbers
3636
[10n, 5n, 2n, 3n, 1n, 4n]

docs/content/docs/getting-started/data/error-handling-patterns.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ description: "Use Either patterns for safe data operations with proper error han
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { Data, Either, pipe } from "@evolution-sdk/evolution"
8+
import { Bytes, Data, Either, pipe } from "@evolution-sdk/evolution"
99

1010
// Use built-in Either-based functions for safe operations
11-
const safeData = new Data.Constr({ index: 0n, fields: ["74657374", 42n] }) // 'test' as hex
11+
const safeData = new Data.Constr({ index: 0n, fields: [Bytes.fromHexUnsafe("74657374"), 42n] }) // 'test' as hex
1212

1313
// Safe encoding using Data.Either namespace
1414
const encodingResult = Data.Either.toCBORHex(safeData)

docs/content/docs/getting-started/data/nested-canonical.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Complex nested Data encoding with canonical CBOR options."
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { CBOR, Data } from "@evolution-sdk/evolution"
8+
import { Bytes, CBOR, Data } from "@evolution-sdk/evolution"
99

1010
const nestedUnsortedData = new Data.Constr({
1111
index: 1n,
@@ -15,9 +15,9 @@ const nestedUnsortedData = new Data.Constr({
1515
fields: [new Data.Constr({ index: 2n, fields: [] })]
1616
}),
1717
new Map<Data.Data, Data.Data>([
18-
["deadbeef01", new Data.Constr({ index: 0n, fields: [] })],
19-
["beef", 19n],
20-
["deadbeef03", new Data.Constr({ index: 1n, fields: [] })]
18+
[Bytes.fromHexUnsafe("deadbeef01"), new Data.Constr({ index: 0n, fields: [] })],
19+
[Bytes.fromHexUnsafe("beef"), 19n],
20+
[Bytes.fromHexUnsafe("deadbeef03"), new Data.Constr({ index: 1n, fields: [] })]
2121
]),
2222
[10n, 5n, 2n, 3n, 1n, 4n]
2323
]

docs/content/docs/getting-started/data/roundtrip.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: "Encode a Data value to CBOR hex and decode back."
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { CBOR, Data } from "@evolution-sdk/evolution"
8+
import { Bytes, CBOR, Data } from "@evolution-sdk/evolution"
99

10-
const original = new Data.Constr({ index: 0n, fields: ["beef", 19n] })
10+
const original = new Data.Constr({ index: 0n, fields: [Bytes.fromHexUnsafe("beef"), 19n] })
1111
const hexCbor = Data.toCBORHex(original, CBOR.CANONICAL_OPTIONS)
1212
const back = Data.fromCBORHex(hexCbor)
1313
assert.deepStrictEqual(back, original)

docs/content/docs/getting-started/data/working-with-maps.mdx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,50 @@ description: "Create and manipulate Data Maps with key-value pairs."
55

66
```typescript
77
import assert from "node:assert/strict"
8-
import { Data } from "@evolution-sdk/evolution"
8+
import { Bytes, Data } from "@evolution-sdk/evolution"
99

10-
// Create a simple map with hex string keys and integer values
10+
// Create byte keys to use consistently
11+
const aliceKey = Bytes.fromHexUnsafe("616c696365") // 'alice' in hex
12+
const bobKey = Bytes.fromHexUnsafe("626f62") // 'bob' in hex
13+
const charlieKey = Bytes.fromHexUnsafe("636861726c6965") // 'charlie' in hex
14+
15+
// Create a simple map with byte keys and integer values
1116
const userAges = new Map<Data.Data, Data.Data>([
12-
["616c696365", 25n], // 'alice' in hex
13-
["626f62", 30n], // 'bob' in hex
14-
["636861726c6965", 35n] // 'charlie' in hex
17+
[aliceKey, 25n],
18+
[bobKey, 30n],
19+
[charlieKey, 35n]
1520
])
1621

1722
console.log("User ages map:", userAges)
1823

19-
// Create a map with constructor keys and hex string values
24+
// Create constructor keys to use consistently
25+
const pendingKey = new Data.Constr({ index: 0n, fields: [] })
26+
const approvedKey = new Data.Constr({ index: 1n, fields: [] })
27+
const rejectedKey = new Data.Constr({ index: 2n, fields: [] })
28+
29+
// Create a map with constructor keys and byte values
2030
const statusMap = new Map<Data.Data, Data.Data>([
21-
[new Data.Constr({ index: 0n, fields: [] }), "70656e64696e67"], // 'pending' in hex
22-
[new Data.Constr({ index: 1n, fields: [] }), "617070726f766564"], // 'approved' in hex
23-
[new Data.Constr({ index: 2n, fields: [] }), "72656a6563746564"] // 'rejected' in hex
31+
[pendingKey, Bytes.fromHexUnsafe("70656e64696e67")], // 'pending' in hex
32+
[approvedKey, Bytes.fromHexUnsafe("617070726f766564")], // 'approved' in hex
33+
[rejectedKey, Bytes.fromHexUnsafe("72656a6563746564")] // 'rejected' in hex
2434
])
2535

26-
// Demonstrate map usage - Maps are Data types themselves, not constructor fields
27-
console.log("Status for constructor 0:", statusMap.get(new Data.Constr({ index: 0n, fields: [] })))
36+
// Demonstrate map usage - use the same key reference for lookups
37+
console.log("Alice's age:", userAges.get(aliceKey))
38+
console.log("Status for pending:", statusMap.get(pendingKey))
2839

29-
// Create a constructor that references the maps via indexes or simple structure
40+
// Create a constructor that contains Data values
3041
const dataRecord = new Data.Constr({
3142
index: 1n,
3243
fields: [
3344
25n, // alice's age directly
34-
"deadbeef", // some data
45+
Bytes.fromHexUnsafe("deadbeef"), // some data
3546
42n // more data
3647
]
3748
})
3849

39-
// Verify map operations
40-
assert.equal(userAges.get("616c696365"), 25n) // alice's age
50+
// Verify map operations - use same key references
51+
assert.deepEqual(userAges.get(aliceKey), 25n) // alice's age
4152
assert.equal(userAges.size, 3)
4253
assert.equal(dataRecord.fields.length, 3)
4354

docs/content/docs/modules/Transaction.mdx

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)