Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 30 additions & 0 deletions .changeset/lazy-pandas-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
"@evolution-sdk/evolution": patch
---

**BREAKING CHANGE:** Remove `Core` namespace, flatten package structure

### What changed
- Moved all modules from `src/core/` to `src/`
- Removed the `Core` namespace export
- Added `Cardano` namespace for API discovery/exploration
- Individual module exports remain available for tree-shaking

### Migration

**Before:**
```typescript
import { Core } from "@evolution-sdk/evolution"
const address = Core.Address.fromBech32("addr...")
```

**After (namespace style):**
```typescript
import { Cardano } from "@evolution-sdk/evolution"
const address = Cardano.Address.fromBech32("addr...")
```

**After (individual imports - recommended for production):**
```typescript
import { Address } from "@evolution-sdk/evolution"
const address = Address.fromBech32("addr...")
6 changes: 3 additions & 3 deletions docs/app/playground/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ const decodeCode = (encoded: string): string | null => {
}
}

const defaultCode = `import { Core } from "@evolution-sdk/evolution"
const defaultCode = `import { Address } from "@evolution-sdk/evolution"

const bech32 = "addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp"

// Parse from Bech32
const address = Core.Address.fromBech32(bech32)
const address = Address.fromBech32(bech32)

console.log("Address:", address)
console.log("Network ID:", address.networkId)
console.log("Payment credential:", address.paymentCredential)
console.log("Has staking:", address.stakingCredential !== undefined)

// Check if it's an enterprise address
console.log("Is enterprise:", Core.Address.isEnterprise(address))`
console.log("Is enterprise:", Address.isEnterprise(address))`

export default function PlaygroundPage() {
const [code, setCode] = useState<string | undefined>()
Expand Down
14 changes: 7 additions & 7 deletions docs/app/tools/tx-decoder/transaction-decoder.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useState } from 'react'
import { Core, Schema } from "@evolution-sdk/evolution"
import { Transaction, TransactionWitnessSet, Data, Schema } from "@evolution-sdk/evolution"

type DecodeType = 'transaction' | 'witnessSet' | 'data'

Expand All @@ -24,16 +24,16 @@ export function TransactionDecoder() {
}

if (decodeType === 'transaction') {
const tx = Core.Transaction.fromCBORHex(cleanHex)
const json = Schema.encodeSync(Schema.parseJson(Core.Transaction.Transaction, {space: 2}))(tx)
const tx = Transaction.fromCBORHex(cleanHex)
const json = Schema.encodeSync(Schema.parseJson(Transaction.Transaction, {space: 2}))(tx)
setDecodedJson(json)
} else if (decodeType === 'witnessSet') {
const witnessSet = Core.TransactionWitnessSet.fromCBORHex(cleanHex)
const json = Schema.encodeSync(Schema.parseJson(Core.TransactionWitnessSet.TransactionWitnessSet, {space: 2}))(witnessSet)
const witnessSet = TransactionWitnessSet.fromCBORHex(cleanHex)
const json = Schema.encodeSync(Schema.parseJson(TransactionWitnessSet.TransactionWitnessSet, {space: 2}))(witnessSet)
setDecodedJson(json)
} else {
const data = Core.Data.fromCBORHex(cleanHex)
const json = Schema.encodeSync(Schema.parseJson(Core.Data.DataSchema, {space: 2}))(data)
const data = Data.fromCBORHex(cleanHex)
const json = Schema.encodeSync(Schema.parseJson(Data.DataSchema, {space: 2}))(data)
setDecodedJson(json)
}
} catch (err) {
Expand Down
8 changes: 4 additions & 4 deletions docs/app/tools/uplc-decoder/uplc-decoder.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useState } from 'react'
import { Core } from "@evolution-sdk/evolution"
import { UPLC } from "@evolution-sdk/evolution"
import JsonView from 'react18-json-view'
import 'react18-json-view/src/style.css'

Expand Down Expand Up @@ -50,13 +50,13 @@ export function UplcDecoder() {
}

// Decode using fromCborHexToProgram which handles all encoding levels
const program = Core.UPLC.fromCborHexToProgram(cleanHex)
const program = UPLC.fromCborHexToProgram(cleanHex)

// Get encoding level
const encodingLevel = Core.UPLC.getCborEncodingLevel(cleanHex)
const encodingLevel = UPLC.getCborEncodingLevel(cleanHex)

// Get flat hex representation
const flatHex = Core.UPLC.toFlatHex(program)
const flatHex = UPLC.toFlatHex(program)

// Convert to JSON object
const jsonData = program.toJSON()
Expand Down
24 changes: 12 additions & 12 deletions docs/content/docs/addresses/address-types/base.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ Both credentials are typically derived from the same wallet, but can come from d
Create base addresses by instantiating the `BaseAddress` class:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, BaseAddress, KeyHash, ScriptHash } from "@evolution-sdk/evolution";

const address = new Core.BaseAddress.BaseAddress({
const address = new BaseAddress.BaseAddress({
networkId: 1, // mainnet
paymentCredential: new Core.KeyHash.KeyHash({
paymentCredential: new KeyHash.KeyHash({
hash: new Uint8Array(28)
}),
stakeCredential: new Core.KeyHash.KeyHash({
stakeCredential: new KeyHash.KeyHash({
hash: new Uint8Array(28)
})
});

// Convert to Bech32 string
const bech32 = Core.AddressEras.toBech32(address);
const bech32 = AddressEras.toBech32(address);
console.log(bech32); // "addr1..."
```

Expand All @@ -45,11 +45,11 @@ console.log(bech32); // "addr1..."
Parse a Bech32 address string into a `BaseAddress` instance:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, BaseAddress, KeyHash, ScriptHash } from "@evolution-sdk/evolution";

const bech32 = "addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd";

const address = Core.AddressEras.fromBech32(bech32) as Core.BaseAddress.BaseAddress;
const address = AddressEras.fromBech32(bech32) as BaseAddress.BaseAddress;

console.log("Network ID:", address.networkId);
console.log("Payment:", address.paymentCredential);
Expand All @@ -61,20 +61,20 @@ console.log("Stake:", address.stakeCredential);
Base addresses can use script hashes for payment and/or staking credentials:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, BaseAddress, KeyHash, ScriptHash } from "@evolution-sdk/evolution";

// Address with script credentials
const scriptAddress = new Core.BaseAddress.BaseAddress({
const scriptAddress = new BaseAddress.BaseAddress({
networkId: 1, // mainnet
paymentCredential: new Core.ScriptHash.ScriptHash({
paymentCredential: new ScriptHash.ScriptHash({
hash: new Uint8Array(28) // 28-byte payment script hash
}),
stakeCredential: new Core.ScriptHash.ScriptHash({
stakeCredential: new ScriptHash.ScriptHash({
hash: new Uint8Array(28) // 28-byte stake script hash
})
});

const bech32 = Core.AddressEras.toBech32(scriptAddress);
const bech32 = AddressEras.toBech32(scriptAddress);
console.log("Script-based address:", bech32);
```

Expand Down
20 changes: 10 additions & 10 deletions docs/content/docs/addresses/address-types/enterprise.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ Enterprise Address = Payment Credential Only
Create enterprise addresses by instantiating the `EnterpriseAddress` class:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, EnterpriseAddress, KeyHash, ScriptHash } from "@evolution-sdk/evolution";

const address = new Core.EnterpriseAddress.EnterpriseAddress({
const address = new EnterpriseAddress.EnterpriseAddress({
networkId: 1, // mainnet
paymentCredential: new Core.KeyHash.KeyHash({
paymentCredential: new KeyHash.KeyHash({
hash: new Uint8Array(28)
})
});

// Convert to Bech32 string
const bech32 = Core.AddressEras.toBech32(address);
const bech32 = AddressEras.toBech32(address);
console.log(bech32); // "addr1..."
```

Expand All @@ -40,11 +40,11 @@ console.log(bech32); // "addr1..."
Parse a Bech32 address string into an `EnterpriseAddress` instance:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, EnterpriseAddress, KeyHash, ScriptHash } from "@evolution-sdk/evolution";

const bech32 = "addr1vx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz6cevnrgl";

const address = Core.AddressEras.fromBech32(bech32) as Core.EnterpriseAddress.EnterpriseAddress;
const address = AddressEras.fromBech32(bech32) as EnterpriseAddress.EnterpriseAddress;

console.log("Network ID:", address.networkId);
console.log("Payment:", address.paymentCredential);
Expand All @@ -55,18 +55,18 @@ console.log("Payment:", address.paymentCredential);
Enterprise addresses can use script hashes as payment credentials:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, EnterpriseAddress, KeyHash, ScriptHash } from "@evolution-sdk/evolution";

// Script address example
const scriptAddr = new Core.EnterpriseAddress.EnterpriseAddress({
const scriptAddr = new EnterpriseAddress.EnterpriseAddress({
networkId: 1, // mainnet
paymentCredential: new Core.ScriptHash.ScriptHash({
paymentCredential: new ScriptHash.ScriptHash({
hash: new Uint8Array(28) // 28-byte script hash
})
});

// Convert to Bech32 string
const bech32 = Core.AddressEras.toBech32(scriptAddr);
const bech32 = AddressEras.toBech32(scriptAddr);
console.log("Script enterprise address:", bech32);
```

Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/addresses/address-types/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ The Evolution SDK implements all Cardano address formats as defined in the ledge

Evolution SDK provides two interfaces for working with addresses:

**Core Address Module (`Core.Address`)**: A unified API for common address operations.
**Core Address Module (`Address`)**: A unified API for common address operations.
- Handles `Payment Credential + Optional Staking Credential`
- Automatically serializes as Base Address (with staking) or Enterprise Address (without staking)
- Simplifies most serialization tasks

**Type-Specific Modules**: Complete implementations for protocol compliance.
- `Core.BaseAddress`, `Core.EnterpriseAddress`, `Core.RewardAddress`, `Core.PointerAddress`, `Core.ByronAddress`
- `BaseAddress`, `EnterpriseAddress`, `RewardAddress`, `PointerAddress`, `ByronAddress`
- Required for exact CBOR encoding/decoding
- Used for protocol-level operations and blockchain tooling

Expand Down
14 changes: 7 additions & 7 deletions docs/content/docs/addresses/address-types/pointer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ Pointer Address = Payment Credential + Pointer (slot, txIndex, certIndex)

## Parsing Pointer Addresses (Legacy)

> **Note**: `Core.Address` does not support pointer addresses as they are deprecated. Use `Core.AddressEras` for historical parsing.
> **Note**: `Address` does not support pointer addresses as they are deprecated. Use `AddressEras` for historical parsing.

If you encounter a pointer address in historical data, you can parse it using `AddressEras`:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, KeyHash, Pointer, PointerAddress } from "@evolution-sdk/evolution";

// Parse a pointer address from Bech32 using AddressEras (legacy support)
const address = Core.AddressEras.fromBech32("addr_test1gz2n8fvzgmyhnqlpnv2340v09943nr7pz5af2rwqrra8ncsm0tdz8");
const address = AddressEras.fromBech32("addr_test1gz2n8fvzgmyhnqlpnv2340v09943nr7pz5af2rwqrra8ncsm0tdz8");

if (address._tag === "PointerAddress") {
// Type narrowed to PointerAddress - access pointer-specific properties
Expand Down Expand Up @@ -87,24 +87,24 @@ If any of these fail, the address is invalid.
This example shows the structure for completeness. **Do not use in production**:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { AddressEras, KeyHash, Pointer, PointerAddress } from "@evolution-sdk/evolution";

// Create payment credential (key hash)
const paymentCred = new Core.KeyHash.KeyHash({
const paymentCred = new KeyHash.KeyHash({
hash: new Uint8Array(28).fill(0)
});

// Create pointer to stake registration certificate
// Note: Pointer uses numbers, not bigint
const pointer = new Core.Pointer.Pointer({
const pointer = new Pointer.Pointer({
slot: 12345,
txIndex: 2,
certIndex: 0
});

// Construct pointer address (rarely used in practice)
// PointerAddress is a separate class from regular Address
const pointerAddr = new Core.PointerAddress.PointerAddress({
const pointerAddr = new PointerAddress.PointerAddress({
networkId: 0,
paymentCredential: paymentCred,
pointer: pointer
Expand Down
20 changes: 10 additions & 10 deletions docs/content/docs/addresses/address-types/reward.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ Reward Address = Staking Credential Only
Create reward addresses by instantiating the `RewardAccount` class:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { KeyHash, RewardAccount, ScriptHash } from "@evolution-sdk/evolution";

const rewardAccount = new Core.RewardAccount.RewardAccount({
const rewardAccount = new RewardAccount.RewardAccount({
networkId: 1, // mainnet
stakeCredential: new Core.KeyHash.KeyHash({
stakeCredential: new KeyHash.KeyHash({
hash: new Uint8Array(28)
})
});

// Convert to Bech32 string
const bech32 = Core.RewardAccount.toBech32(rewardAccount);
const bech32 = RewardAccount.toBech32(rewardAccount);
console.log(bech32); // "stake1..."
```

Expand All @@ -40,11 +40,11 @@ console.log(bech32); // "stake1..."
Parse a Bech32 stake address string into a `RewardAccount` instance:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { KeyHash, RewardAccount, ScriptHash } from "@evolution-sdk/evolution";

const bech32 = "stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw";

const address = Core.RewardAccount.fromBech32(bech32);
const address = RewardAccount.fromBech32(bech32);

console.log("Network ID:", address.networkId);
console.log("Stake credential:", address.stakeCredential);
Expand All @@ -55,17 +55,17 @@ console.log("Stake credential:", address.stakeCredential);
Reward addresses can use script hashes for the staking credential:

```typescript twoslash
import { Core } from "@evolution-sdk/evolution";
import { KeyHash, RewardAccount, ScriptHash } from "@evolution-sdk/evolution";

// Reward address with script credential
const scriptRewardAccount = new Core.RewardAccount.RewardAccount({
const scriptRewardAccount = new RewardAccount.RewardAccount({
networkId: 1, // mainnet
stakeCredential: new Core.ScriptHash.ScriptHash({
stakeCredential: new ScriptHash.ScriptHash({
hash: new Uint8Array(28) // 28-byte stake script hash
})
});

const bech32 = Core.RewardAccount.toBech32(scriptRewardAccount);
const bech32 = RewardAccount.toBech32(scriptRewardAccount);
console.log("Script-based reward address:", bech32);
```

Expand Down
Loading