@ckb-ccc/core 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/bytes/index.d.ts +4 -0
- package/dist/bytes/index.d.ts.map +1 -1
- package/dist/bytes/index.js +4 -0
- package/dist/ckb/transaction.d.ts +11 -0
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +35 -11
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +15 -0
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +15 -0
- package/dist/client/clientTypes.js +1 -1
- package/dist/client/knownScript.d.ts +1 -0
- package/dist/client/knownScript.d.ts.map +1 -1
- package/dist/client/knownScript.js +1 -0
- package/dist/molecule/codec.d.ts +9 -3
- package/dist/molecule/codec.d.ts.map +1 -1
- package/dist/molecule/codec.js +38 -23
- package/dist/molecule/entity.d.ts +1 -8
- package/dist/molecule/entity.d.ts.map +1 -1
- package/dist/molecule/entity.js +11 -14
- package/dist/signer/nostr/signerNostrPrivateKey.d.ts +4 -0
- package/dist/signer/nostr/signerNostrPrivateKey.d.ts.map +1 -1
- package/dist/signer/nostr/signerNostrPrivateKey.js +13 -1
- package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts +4 -0
- package/dist/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/nostr/signerNostrPublicKeyReadonly.js +4 -0
- package/dist.commonjs/bytes/index.d.ts +4 -0
- package/dist.commonjs/bytes/index.d.ts.map +1 -1
- package/dist.commonjs/bytes/index.js +5 -0
- package/dist.commonjs/ckb/transaction.d.ts +11 -0
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +35 -11
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +15 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +15 -0
- package/dist.commonjs/client/clientTypes.js +1 -1
- package/dist.commonjs/client/knownScript.d.ts +1 -0
- package/dist.commonjs/client/knownScript.d.ts.map +1 -1
- package/dist.commonjs/client/knownScript.js +1 -0
- package/dist.commonjs/molecule/codec.d.ts +9 -3
- package/dist.commonjs/molecule/codec.d.ts.map +1 -1
- package/dist.commonjs/molecule/codec.js +38 -23
- package/dist.commonjs/molecule/entity.d.ts +1 -8
- package/dist.commonjs/molecule/entity.d.ts.map +1 -1
- package/dist.commonjs/molecule/entity.js +11 -14
- package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts +4 -0
- package/dist.commonjs/signer/nostr/signerNostrPrivateKey.d.ts.map +1 -1
- package/dist.commonjs/signer/nostr/signerNostrPrivateKey.js +13 -1
- package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts +4 -0
- package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/nostr/signerNostrPublicKeyReadonly.js +4 -0
- package/package.json +9 -10
- package/prettier.config.mjs +13 -0
- package/src/bytes/index.ts +4 -0
- package/src/ckb/transaction.ts +44 -11
- package/src/client/clientPublicMainnet.advanced.ts +17 -0
- package/src/client/clientPublicTestnet.advanced.ts +17 -0
- package/src/client/clientTypes.ts +1 -1
- package/src/client/knownScript.ts +1 -0
- package/src/molecule/codec.ts +57 -25
- package/src/molecule/entity.ts +11 -12
- package/src/signer/nostr/signerNostrPrivateKey.ts +17 -1
- package/src/signer/nostr/signerNostrPublicKeyReadonly.ts +4 -0
- package/vitest.config.ts +10 -0
- package/jest.config.js +0 -5
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { schnorr } from "@noble/curves/secp256k1";
|
|
2
|
+
import { bech32 } from "bech32";
|
|
2
3
|
import { Client } from "../../client/index.js";
|
|
3
4
|
import { Hex, hexFrom, HexLike } from "../../hex/index.js";
|
|
4
5
|
import { NostrEvent } from "./signerNostr.js";
|
|
5
6
|
import { SignerNostrPublicKeyReadonly } from "./signerNostrPublicKeyReadonly.js";
|
|
6
7
|
import { nostrEventHash } from "./verify.js";
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Signer from Nostr private key
|
|
11
|
+
* Support nsec and hex format
|
|
12
|
+
*/
|
|
8
13
|
export class SignerNostrPrivateKey extends SignerNostrPublicKeyReadonly {
|
|
9
14
|
private readonly privateKey: Hex;
|
|
10
15
|
|
|
11
16
|
constructor(client: Client, privateKeyLike: HexLike) {
|
|
12
|
-
const privateKey =
|
|
17
|
+
const privateKey = (() => {
|
|
18
|
+
if (
|
|
19
|
+
typeof privateKeyLike === "string" &&
|
|
20
|
+
privateKeyLike.startsWith("nsec")
|
|
21
|
+
) {
|
|
22
|
+
const { words } = bech32.decode(privateKeyLike);
|
|
23
|
+
return hexFrom(bech32.fromWords(words));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return hexFrom(privateKeyLike);
|
|
27
|
+
})();
|
|
28
|
+
|
|
13
29
|
super(client, schnorr.getPublicKey(privateKey.slice(2)));
|
|
14
30
|
|
|
15
31
|
this.privateKey = privateKey;
|
|
@@ -3,6 +3,10 @@ import { Client } from "../../client/index.js";
|
|
|
3
3
|
import { Hex, hexFrom, HexLike } from "../../hex/index.js";
|
|
4
4
|
import { SignerNostr } from "./signerNostr.js";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Signer from Nostr public key
|
|
8
|
+
* Support npub and hex format
|
|
9
|
+
*/
|
|
6
10
|
export class SignerNostrPublicKeyReadonly extends SignerNostr {
|
|
7
11
|
public readonly publicKey: Hex;
|
|
8
12
|
|
package/vitest.config.ts
ADDED