Skip to content

Commit b112b53

Browse files
Update CONVENTIONS.md
Co-authored-by: Otto Allmendinger <otto.allmendinger@googlemail.com>
1 parent 0b91344 commit b112b53

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

CONVENTIONS.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ This file documents API design and architecture patterns from code reviews. Foll
55
These are hard rules, not suggestions. If you're unsure about a pattern, check the existing implementations in wasm-utxo.
66
---
77

8-
## 1. Uint8Array everywhere, no hex/base64 on Transaction
8+
## 1. Prefer Uint8Array, avoid unnecessary base conversions
99

10-
**What:** Transaction objects work exclusively with `Uint8Array` for binary data. No hex strings, no base64 strings.
10+
**What:** Generally, binary formats like transactions should use `Uint8Array` . Avoid base conversions in the wasm interface.
1111

12-
**Why:** Type safety at the boundary. If a method accepts or returns transaction bytes, it's always `Uint8Array`. String encodings (hex, base64) belong in serialization/API layers, not in the core transaction model. This prevents silent bugs where someone passes hex to a function expecting raw bytes.
12+
**Why:** Type safety at the boundary. If a method accepts or returns transaction bytes, it's always `Uint8Array`. String encodings (hex, base64) belong in serialization/API layers, not in the core transaction model. This prevents API bloat where we have to add encoding and decoding variants for various base conversion formats, as well as inefficiencies due to round-tripping binary data through two base conversions.
13+
14+
Exceptions are allowed for instances where a hex encoded representations are conventional (Ethereum addresses for instance)
1315

1416
**Good:**
1517
```typescript

0 commit comments

Comments
 (0)