Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Make serialize methods return hex-encoded strings, instead of bytes #1657

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/.husky/commitlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"header-max-length": [0, "always"],
"scope-max-length": [0, "always"],
"subject-max-length": [0, "always"],
"type-max-length": [0, "always"]
"type-max-length": [0, "always"],

"subject-case": [0, "always", "sentence-case"]
}
}
40 changes: 40 additions & 0 deletions .github/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- [StacksNodeApi](#stacksnodeapi)
- [StacksNetwork to StacksNodeApi](#stacksnetwork-to-stacksnodeapi)
- [Clarity Representation](#clarity-representation)
- [`serialize` methods](#serialize-methods)
- [Asset Helper Methods](#asset-helper-methods)
- [Stacks.js (\<=4.x.x) → (5.x.x)](#stacksjs-4xx--5xx)
- [Breaking Changes](#breaking-changes-1)
- [Buffer to Uint8Array](#buffer-to-uint8array)
Expand All @@ -26,6 +28,8 @@

- The `@stacks/network` `new StacksNetwork()` objects were removed. Instead `@stacks/network` now exports the objects `STACKS_MAINNET`, `STACKS_TESNET`, and `STACKS_DEVNET`, which are static (and shouldn't be changed for most use-cases). [Read more...](#stacks-network)
- The `ClarityType` enum was replaced by a readable version. The previous (wire format compatible) enum is still available as `ClarityWireType`. [Read more...](#clarity-representation)
- The `serializeXyz` methods were changed to return `string` (hex-encoded) instead of `Uint8Array`. Compatible `serializeXzyBytes` methods were added to ease the migration. [Read more...](#serialize-methods)
- The `AssetInfo` type was renamed to `Asset` for accuracy. The `Asset` helper methods were also renamed to to remove the `Info` suffix. [Read more...](#asset-helper-methods)

### Stacks Network

Expand Down Expand Up @@ -144,6 +148,42 @@ For `bigint` values, the type of the `value` property is a now `string`, for bet
}
```

### `serialize` methods

Existing methods now use hex-encoded strings instead of `Uint8Array`s.
For easier migrating, renaming the following methods is possible to keep the previous behavior:

- `serializeCV` → `serializeCVBytes`
- `serializeAddress` → `serializeAddressBytes`
- `deserializeAddress` → `deserializeAddressBytes`
- `serializeLPList` → `serializeLPListBytes`
- `deserializeLPList` → `deserializeLPListBytes`
- `serializeLPString` → `serializeLPStringBytes`
- `deserializeLPString` → `deserializeLPStringBytes`
- `serializePayload` → `serializePayloadBytes`
- `deserializePayload` → `deserializePayloadBytes`
- `serializePublicKey` → `serializePublicKeyBytes`
- `deserializePublicKey` → `deserializePublicKeyBytes`
- `serializeStacksMessage` → `serializeStacksMessageBytes`
- `deserializeStacksMessage` → `deserializeStacksMessageBytes`
- `serializeMemoString` → `serializeMemoStringBytes`
- `deserializeMemoString` → `deserializeMemoStringBytes`
- `serializeTransactionAuthField` → `serializeTransactionAuthFieldBytes`
- `deserializeTransactionAuthField` → `deserializeTransactionAuthFieldBytes`
- `serializeMessageSignature` → `serializeMessageSignatureBytes`
- `deserializeMessageSignature` → `deserializeMessageSignatureBytes`
- `serializePostCondition` → `serializePostConditionBytes`
- `deserializePostCondition` → `deserializePostConditionBytes`

### Asset Helper Methods

The following interfaces and methods were renamed:

- `AssetInfo` → `Asset`
- `StacksMessageType.AssetInfo` → `StacksMessageType.Asset`
- `createAssetInfo` → `createAsset`
- `parseAssetInfoString` → `parseAssetString`

## Stacks.js (&lt;=4.x.x) → (5.x.x)

### Breaking Changes
Expand Down
Loading
Loading