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

docs: add docs for v0.30 #716

Merged
merged 4 commits into from
Jun 25, 2024
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
2 changes: 0 additions & 2 deletions website/docs/01-run-lumos-in-the-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ sidebar_position: 2
Lumos was originally run on NodeJS only. To run on browser, we replaced native indexer with ckb-indexer, added BI which
is a big number library, and a series of other upgrades.

Also, we need polyfill the NodeJS API(such as `crypto`), and change your build toolchain config to support.

The following example of getting the balance will show you how to use lumos in your web project.

```shell
Expand Down
5 changes: 0 additions & 5 deletions website/docs/migrations/migrate-to-v0.20.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Migration to Lumos 0.20

## Browser shiming

If you are using Lumos in the browser, please add configuration according to
this [doc](../recipes/cra-vite-webpack-or-other)

## Remove `computeScriptHash` Second Parameter

In an early version, we make the second parameter be ignored in it's implement.
Expand Down
74 changes: 74 additions & 0 deletions website/docs/migrations/migrate-to-v0.30.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Migrate to Lumos v0.30

## BREAKING: Buffer replaced by Uint8Array

**Lumos can now run in browsers without any extra configs / polyfills with vite, webpack or create-react-app.**

### `Buffer` was return type

Methods / functions used to return a `Buffer` now returns a `Uint8Array`, e.g. In `@ckb-lumos/hd`

```diff
- export function privateToPublic(privateKey: Buffer | HexString): Buffer | HexString
+ export function privateToPublic(privateKey: Uint8Array | HexString): Uint8Array | HexString

- export function mnemonicToSeedSync(mnemonic = "", password = ""): Buffer
+ export function mnemonicToSeedSync(mnemonic = "", password = ""): Uint8Array

- export function mnemonicToSeed(mnemonic = "", password = ""): Promise<Buffer>
+ export function mnemonicToSeed(mnemonic = "", password = ""): Promise<Uint8Array>
```

You can use the `hexify` method from `@ckb-lumos/lumos/codec` to replace `buffer.toString('hex')`

```diff
- "0x" + privateToPublick(privKey).toString('hex')
+ hexify(privateToPublic(privKey))
```

**Notice:** `hexify` returns `HexString` which starts with `'0x'` while `buffer.toString('hex')` result has **no** `'0x'` prefix.

Same for `@ckb-lumos/hd/KeyStore`

```diff
export default class Keystore {
...
- derivedKey(password: string): Buffer
+ derivedKey(password: string): Uint8Array
...
}
```

### `Buffer` was parameter type

You can still pass in `Buffer` because `Buffer` is a subclass of `Uint8Array`, but using `Uint8Array` is recomended.

`@ckb-lumos/hd/KeyChain`

```diff
export default class Keychain {
...
- constructor(privateKey: Buffer, chainCode: Buffer)
+ constructor(privateKey: Uint8Array, chainCode: Uint8Array)
homura marked this conversation as resolved.
Show resolved Hide resolved
...
- hash160(data: Buffer): Buffer
+ hash160(data: Uint8Array): Uint8Array
}
```

`@ckb-lumos/hd/KeyStore`

```diff
export default class Keystore {
...
static create(
extendedPrivateKey: ExtendedPrivateKey,
password: string,
- options: { salt?: Buffer; iv?: Buffer } = {}
+ options: { salt?: Uint8Array; iv?: Uint8Array } = {}
): Keystore
...
- static mac(derivedKey: Buffer, ciphertext: Buffer): HexStringWithoutPrefix
+ static mac(derivedKey: Uint8Array, ciphertext: Uint8Array): HexStringWithoutPrefix
}
```
177 changes: 0 additions & 177 deletions website/docs/recipes/cra-vite-webpack-or-other.md

This file was deleted.

Loading