docs: polish address section#55
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR polishes the address documentation section and refactors the address-related code. The main changes include:
- Core module reorganization: Renamed
AddressStructuretoAddressand restructured address-related exports - Assets API enhancement: Made
lovelacefield optional and added helper functions (getLovelace,setLovelace, etc.) - Documentation restructure: Reorganized address documentation with clearer separation between SDK and Core layers
- Dependency updates: Updated Effect and platform dependencies to newer versions
Reviewed Changes
Copilot reviewed 52 out of 53 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
packages/evolution/src/core/Address.ts |
Renamed AddressStructure class to Address and updated error class names |
packages/evolution/src/sdk/Assets.ts |
Made lovelace optional, added helper functions, and new schema transformations |
packages/evolution/src/sdk/Address.ts |
Simplified to provide SDK-level string-based address API |
packages/evolution/src/sdk/AddressDetails.ts |
New file providing rich address details with network/type information |
packages/evolution/src/index.ts |
Reorganized exports with Core namespace and SDK modules |
docs/content/docs/addresses/* |
Complete documentation restructure with new organization |
| Test files | Updated to use Assets.getLovelace() instead of direct property access |
| Package dependencies | Updated Effect platform packages |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expect(result.selectedUtxos).toHaveLength(2) | ||
|
|
||
| const totalLovelace = result.selectedUtxos.reduce((sum, u) => sum + u.assets.lovelace, 0n) | ||
| const totalLovelace = UTxO.getTotalLovelace([...result.selectedUtxos]) |
There was a problem hiding this comment.
The function UTxO.getTotalLovelace is being called but there's no evidence this function exists in the codebase. The import shows import * as UTxO from \"../src/sdk/UTxO.js\" but this function hasn't been added to the UTxO module. This will cause a runtime error.
| expect(result.selectedUtxos).toHaveLength(3) | ||
|
|
||
| const total = result.selectedUtxos.reduce((sum, u) => sum + u.assets.lovelace, 0n) | ||
| const total = UTxO.getTotalLovelace([...result.selectedUtxos]) |
There was a problem hiding this comment.
Same issue as above - UTxO.getTotalLovelace function doesn't exist. This should either use the reduce pattern with Assets.getLovelace or the function needs to be implemented in the UTxO module.
| export const AssetsSchema = Schema.Struct({ | ||
| lovelace: Schema.optional(Schema.BigIntFromSelf) | ||
| }).pipe(Schema.extend(Schema.Record({ key: Schema.String, value: Schema.BigIntFromSelf }))) |
There was a problem hiding this comment.
Making lovelace optional in the schema creates inconsistency. The AssetsSchema now allows lovelace to be undefined, but many existing functions like empty() explicitly set it to 0n. This could lead to confusion about whether assets without lovelace should have lovelace: undefined or lovelace: 0n. Consider either making it always required with a default of 0n, or ensure all constructor functions consistently use undefined when there's no lovelace.
| }).annotations({ | ||
| identifier: "Mint", | ||
| title: "Token Mint Operations", | ||
| description: "A collection of token minting/burning operations grouped by policy ID" | ||
| }) |
There was a problem hiding this comment.
The .pipe(Schema.brand(\"Mint\")) call was removed but the type Mint is still exported as typeof Mint.Type which would have relied on the brand. This breaks the type definition. The brand should be restored or the type export needs to be updated to match the new schema definition.
|
|
||
| /** | ||
| * Check if a value is a valid NonZeroInt64. |
There was a problem hiding this comment.
The make constructor function was removed without explanation. If this was intentional to encourage using Schema.decodeSync(NonZeroInt64) directly, this breaking change should be documented. Otherwise, the helper function should be restored for developer convenience.
| return { | ||
| _tag: "KeyHash" as const, | ||
| hash: Bytes.toHex(this.hash) | ||
| } |
There was a problem hiding this comment.
Changing the toJSON() return type from a string to an object is a breaking change in the serialization format. Code that previously expected toJSON() to return a hex string will break. This should either be reverted or clearly documented as a breaking change with migration instructions.
| return { | |
| _tag: "KeyHash" as const, | |
| hash: Bytes.toHex(this.hash) | |
| } | |
| return Bytes.toHex(this.hash) |
| const map = new Map(entries.map(([policyId, assetEntries]) => [policyId, new Map(assetEntries)])) as Mint | ||
| // Validate the constructed Mint | ||
| if (!is(map)) { | ||
| throw new MintError({ message: "Invalid Mint structure" }) | ||
| } | ||
| return map |
There was a problem hiding this comment.
is function is called but not defined or imported in this file. This will cause a runtime error. Should be Mint.is(map) or the is predicate needs to be imported from the Mint schema.
No description provided.