@ckb-ccc/core 0.0.7-alpha.1 → 0.0.7-alpha.2

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.
Files changed (118) hide show
  1. package/dist/ckb/transaction.d.ts.map +1 -1
  2. package/dist/ckb/transaction.js +2 -2
  3. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  4. package/dist.commonjs/address/address.advanced.js +89 -115
  5. package/dist.commonjs/address/advanced.d.ts +1 -1
  6. package/dist.commonjs/address/advanced.js +14 -30
  7. package/dist.commonjs/address/index.d.ts +44 -51
  8. package/dist.commonjs/address/index.js +65 -84
  9. package/dist.commonjs/advanced.d.ts +1 -1
  10. package/dist.commonjs/advanced.js +22 -47
  11. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  12. package/dist.commonjs/advancedBarrel.js +14 -30
  13. package/dist.commonjs/barrel.d.ts +1 -1
  14. package/dist.commonjs/barrel.js +14 -30
  15. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  16. package/dist.commonjs/bytes/index.d.ts +3 -9
  17. package/dist.commonjs/bytes/index.js +26 -28
  18. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  19. package/dist.commonjs/ckb/advanced.js +22 -47
  20. package/dist.commonjs/ckb/index.d.ts +1 -1
  21. package/dist.commonjs/ckb/index.js +14 -30
  22. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  23. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  24. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  25. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  26. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  27. package/dist.commonjs/ckb/script.advanced.js +9 -12
  28. package/dist.commonjs/ckb/script.d.ts +117 -121
  29. package/dist.commonjs/ckb/script.js +176 -220
  30. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  31. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  32. package/dist.commonjs/ckb/transaction.d.ts +717 -792
  33. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  34. package/dist.commonjs/ckb/transaction.js +1155 -1383
  35. package/dist.commonjs/client/advanced.d.ts +1 -1
  36. package/dist.commonjs/client/advanced.js +14 -30
  37. package/dist.commonjs/client/client.advanced.d.ts +6 -23
  38. package/dist.commonjs/client/client.advanced.js +61 -89
  39. package/dist.commonjs/client/client.d.ts +53 -113
  40. package/dist.commonjs/client/client.js +181 -214
  41. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
  42. package/dist.commonjs/client/clientPublicMainnet.advanced.js +127 -144
  43. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
  44. package/dist.commonjs/client/clientPublicMainnet.js +15 -17
  45. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
  46. package/dist.commonjs/client/clientPublicTestnet.advanced.js +179 -204
  47. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
  48. package/dist.commonjs/client/clientPublicTestnet.js +13 -13
  49. package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
  50. package/dist.commonjs/client/clientTypes.advanced.js +1 -1
  51. package/dist.commonjs/client/clientTypes.d.ts +26 -51
  52. package/dist.commonjs/client/clientTypes.js +22 -56
  53. package/dist.commonjs/client/index.d.ts +1 -1
  54. package/dist.commonjs/client/index.js +14 -30
  55. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  56. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  57. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
  58. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  59. package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
  60. package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
  61. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  62. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  63. package/dist.commonjs/fixedPoint/index.js +20 -26
  64. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  65. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  66. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  67. package/dist.commonjs/hasher/index.d.ts +36 -36
  68. package/dist.commonjs/hasher/index.js +47 -54
  69. package/dist.commonjs/hex/index.d.ts +1 -1
  70. package/dist.commonjs/hex/index.js +1 -1
  71. package/dist.commonjs/index.d.ts +1 -1
  72. package/dist.commonjs/index.js +22 -47
  73. package/dist.commonjs/num/index.d.ts +1 -1
  74. package/dist.commonjs/num/index.js +27 -39
  75. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  76. package/dist.commonjs/signer/btc/index.js +14 -30
  77. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  78. package/dist.commonjs/signer/btc/signerBtc.js +66 -89
  79. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  80. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  81. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  82. package/dist.commonjs/signer/btc/verify.js +3 -10
  83. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  84. package/dist.commonjs/signer/ckb/index.js +14 -30
  85. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  86. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  87. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
  88. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
  89. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  90. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  91. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  92. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  93. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  94. package/dist.commonjs/signer/dummy/index.js +14 -30
  95. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  96. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  97. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  98. package/dist.commonjs/signer/evm/index.js +14 -30
  99. package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
  100. package/dist.commonjs/signer/evm/signerEvm.js +70 -105
  101. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  102. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  103. package/dist.commonjs/signer/evm/verify.d.ts +2 -6
  104. package/dist.commonjs/signer/evm/verify.js +2 -7
  105. package/dist.commonjs/signer/index.d.ts +1 -1
  106. package/dist.commonjs/signer/index.js +14 -30
  107. package/dist.commonjs/signer/nostr/index.d.ts +1 -1
  108. package/dist.commonjs/signer/nostr/index.js +14 -30
  109. package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
  110. package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
  111. package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
  112. package/dist.commonjs/signer/nostr/verify.js +39 -50
  113. package/dist.commonjs/signer/signer/index.d.ts +150 -156
  114. package/dist.commonjs/signer/signer/index.js +181 -208
  115. package/dist.commonjs/utils/index.d.ts +8 -38
  116. package/dist.commonjs/utils/index.js +12 -18
  117. package/package.json +2 -2
  118. package/src/ckb/transaction.ts +3 -2
@@ -8,51 +8,51 @@ import { Signer, SignerSignType, SignerType } from "../signer";
8
8
  * as well as signing transactions.
9
9
  */
10
10
  export declare abstract class SignerBtc extends Signer {
11
- get type(): SignerType;
12
- get signType(): SignerSignType;
13
- /**
14
- * Gets the Bitcoin account associated with the signer.
15
- *
16
- * @returns A promise that resolves to a string representing the Bitcoin account.
17
- */
18
- abstract getBtcAccount(): Promise<string>;
19
- /**
20
- * Gets the Bitcoin public key associated with the signer.
21
- *
22
- * @returns A promise that resolves to a HexLike value representing the Bitcoin public key.
23
- */
24
- abstract getBtcPublicKey(): Promise<HexLike>;
25
- /**
26
- * Gets the internal address, which is the Bitcoin account in this case.
27
- *
28
- * @returns A promise that resolves to a string representing the internal address.
29
- */
30
- getInternalAddress(): Promise<string>;
31
- /**
32
- * Gets the identity, which is the Bitcoin public key in this case.
33
- *
34
- * @returns A promise that resolves to a string representing the identity
35
- */
36
- getIdentity(): Promise<string>;
37
- /**
38
- * Gets an array of Address objects representing the known script addresses for the signer.
39
- *
40
- * @returns A promise that resolves to an array of Address objects.
41
- */
42
- getAddressObjs(): Promise<Address[]>;
43
- /**
44
- * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
45
- *
46
- * @param txLike - The transaction to prepare, represented as a TransactionLike object.
47
- * @returns A promise that resolves to the prepared Transaction object.
48
- */
49
- prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
50
- /**
51
- * Signs a transaction without modifying it.
52
- *
53
- * @param txLike - The transaction to sign, represented as a TransactionLike object.
54
- * @returns A promise that resolves to a signed Transaction object.
55
- */
56
- signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
11
+ get type(): SignerType;
12
+ get signType(): SignerSignType;
13
+ /**
14
+ * Gets the Bitcoin account associated with the signer.
15
+ *
16
+ * @returns A promise that resolves to a string representing the Bitcoin account.
17
+ */
18
+ abstract getBtcAccount(): Promise<string>;
19
+ /**
20
+ * Gets the Bitcoin public key associated with the signer.
21
+ *
22
+ * @returns A promise that resolves to a HexLike value representing the Bitcoin public key.
23
+ */
24
+ abstract getBtcPublicKey(): Promise<HexLike>;
25
+ /**
26
+ * Gets the internal address, which is the Bitcoin account in this case.
27
+ *
28
+ * @returns A promise that resolves to a string representing the internal address.
29
+ */
30
+ getInternalAddress(): Promise<string>;
31
+ /**
32
+ * Gets the identity, which is the Bitcoin public key in this case.
33
+ *
34
+ * @returns A promise that resolves to a string representing the identity
35
+ */
36
+ getIdentity(): Promise<string>;
37
+ /**
38
+ * Gets an array of Address objects representing the known script addresses for the signer.
39
+ *
40
+ * @returns A promise that resolves to an array of Address objects.
41
+ */
42
+ getAddressObjs(): Promise<Address[]>;
43
+ /**
44
+ * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
45
+ *
46
+ * @param txLike - The transaction to prepare, represented as a TransactionLike object.
47
+ * @returns A promise that resolves to the prepared Transaction object.
48
+ */
49
+ prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
50
+ /**
51
+ * Signs a transaction without modifying it.
52
+ *
53
+ * @param txLike - The transaction to sign, represented as a TransactionLike object.
54
+ * @returns A promise that resolves to a signed Transaction object.
55
+ */
56
+ signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
57
57
  }
58
- //# sourceMappingURL=signerBtc.d.ts.map
58
+ //# sourceMappingURL=signerBtc.d.ts.map
@@ -16,95 +16,72 @@ const signer_1 = require("../signer");
16
16
  * as well as signing transactions.
17
17
  */
18
18
  class SignerBtc extends signer_1.Signer {
19
- get type() {
20
- return signer_1.SignerType.BTC;
21
- }
22
- get signType() {
23
- return signer_1.SignerSignType.BtcEcdsa;
24
- }
25
- /**
26
- * Gets the internal address, which is the Bitcoin account in this case.
27
- *
28
- * @returns A promise that resolves to a string representing the internal address.
29
- */
30
- async getInternalAddress() {
31
- return this.getBtcAccount();
32
- }
33
- /**
34
- * Gets the identity, which is the Bitcoin public key in this case.
35
- *
36
- * @returns A promise that resolves to a string representing the identity
37
- */
38
- async getIdentity() {
39
- return (0, hex_1.hexFrom)(await this.getBtcPublicKey()).slice(2);
40
- }
41
- /**
42
- * Gets an array of Address objects representing the known script addresses for the signer.
43
- *
44
- * @returns A promise that resolves to an array of Address objects.
45
- */
46
- async getAddressObjs() {
47
- const publicKey = await this.getBtcPublicKey();
48
- const hash = (0, ripemd160_1.ripemd160)(
49
- (0, sha256_1.sha256)((0, bytes_1.bytesFrom)(publicKey)),
50
- );
51
- return [
52
- await address_1.Address.fromKnownScript(
53
- this.client,
54
- client_1.KnownScript.OmniLock,
55
- (0, hex_1.hexFrom)([0x04, ...hash, 0x00]),
56
- ),
57
- ];
58
- }
59
- /**
60
- * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
61
- *
62
- * @param txLike - The transaction to prepare, represented as a TransactionLike object.
63
- * @returns A promise that resolves to the prepared Transaction object.
64
- */
65
- async prepareTransaction(txLike) {
66
- const tx = ckb_1.Transaction.from(txLike);
67
- const { script } = await this.getRecommendedAddressObj();
68
- await tx.addCellDepsOfKnownScripts(
69
- this.client,
70
- client_1.KnownScript.OmniLock,
71
- );
72
- await tx.prepareSighashAllWitness(script, 85, this.client);
73
- return tx;
74
- }
75
- /**
76
- * Signs a transaction without modifying it.
77
- *
78
- * @param txLike - The transaction to sign, represented as a TransactionLike object.
79
- * @returns A promise that resolves to a signed Transaction object.
80
- */
81
- async signOnlyTransaction(txLike) {
82
- const tx = ckb_1.Transaction.from(txLike);
83
- const { script } = await this.getRecommendedAddressObj();
84
- const info = await tx.getSignHashInfo(script, this.client);
85
- if (!info) {
86
- return tx;
19
+ get type() {
20
+ return signer_1.SignerType.BTC;
21
+ }
22
+ get signType() {
23
+ return signer_1.SignerSignType.BtcEcdsa;
24
+ }
25
+ /**
26
+ * Gets the internal address, which is the Bitcoin account in this case.
27
+ *
28
+ * @returns A promise that resolves to a string representing the internal address.
29
+ */
30
+ async getInternalAddress() {
31
+ return this.getBtcAccount();
32
+ }
33
+ /**
34
+ * Gets the identity, which is the Bitcoin public key in this case.
35
+ *
36
+ * @returns A promise that resolves to a string representing the identity
37
+ */
38
+ async getIdentity() {
39
+ return (0, hex_1.hexFrom)(await this.getBtcPublicKey()).slice(2);
40
+ }
41
+ /**
42
+ * Gets an array of Address objects representing the known script addresses for the signer.
43
+ *
44
+ * @returns A promise that resolves to an array of Address objects.
45
+ */
46
+ async getAddressObjs() {
47
+ const publicKey = await this.getBtcPublicKey();
48
+ const hash = (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)((0, bytes_1.bytesFrom)(publicKey)));
49
+ return [
50
+ await address_1.Address.fromKnownScript(this.client, client_1.KnownScript.OmniLock, (0, hex_1.hexFrom)([0x04, ...hash, 0x00])),
51
+ ];
52
+ }
53
+ /**
54
+ * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
55
+ *
56
+ * @param txLike - The transaction to prepare, represented as a TransactionLike object.
57
+ * @returns A promise that resolves to the prepared Transaction object.
58
+ */
59
+ async prepareTransaction(txLike) {
60
+ const tx = ckb_1.Transaction.from(txLike);
61
+ const { script } = await this.getRecommendedAddressObj();
62
+ await tx.addCellDepsOfKnownScripts(this.client, client_1.KnownScript.OmniLock);
63
+ await tx.prepareSighashAllWitness(script, 85, this.client);
64
+ return tx;
65
+ }
66
+ /**
67
+ * Signs a transaction without modifying it.
68
+ *
69
+ * @param txLike - The transaction to sign, represented as a TransactionLike object.
70
+ * @returns A promise that resolves to a signed Transaction object.
71
+ */
72
+ async signOnlyTransaction(txLike) {
73
+ const tx = ckb_1.Transaction.from(txLike);
74
+ const { script } = await this.getRecommendedAddressObj();
75
+ const info = await tx.getSignHashInfo(script, this.client);
76
+ if (!info) {
77
+ return tx;
78
+ }
79
+ const signature = (0, bytes_1.bytesFrom)(await this.signMessageRaw(`CKB (Bitcoin Layer) transaction: ${info.message}`), "base64");
80
+ signature[0] = 31 + ((signature[0] - 27) % 4);
81
+ const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
82
+ witness.lock = (0, hex_1.hexFrom)((0, bytes_1.bytesConcat)((0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(4 * 4, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(signature.length, 4), signature));
83
+ tx.setWitnessArgsAt(info.position, witness);
84
+ return tx;
87
85
  }
88
- const signature = (0, bytes_1.bytesFrom)(
89
- await this.signMessageRaw(
90
- `CKB (Bitcoin Layer) transaction: ${info.message}`,
91
- ),
92
- "base64",
93
- );
94
- signature[0] = 31 + ((signature[0] - 27) % 4);
95
- const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
96
- witness.lock = (0, hex_1.hexFrom)(
97
- (0, bytes_1.bytesConcat)(
98
- (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
99
- (0, num_1.numToBytes)(4 * 4, 4),
100
- (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
101
- (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
102
- (0, num_1.numToBytes)(signature.length, 4),
103
- signature,
104
- ),
105
- );
106
- tx.setWitnessArgsAt(info.position, witness);
107
- return tx;
108
- }
109
86
  }
110
87
  exports.SignerBtc = SignerBtc;
@@ -6,49 +6,49 @@ import { SignerBtc } from "./signerBtc";
6
6
  * This class does not support signing operations.
7
7
  */
8
8
  export declare class SignerBtcPublicKeyReadonly extends SignerBtc {
9
- private readonly account;
10
- private readonly publicKey;
11
- /**
12
- * Creates an instance of SignerBtcPublicKeyReadonly.
13
- *
14
- * @param client - The client instance used for communication.
15
- * @param account - The Bitcoin account associated with the signer.
16
- * @param publicKey - The public key associated with the signer.
17
- */
18
- constructor(client: Client, account: string, publicKey: HexLike);
19
- /**
20
- * Connects to the client. This implementation does nothing as the class is read-only.
21
- *
22
- * @returns A promise that resolves when the connection is complete.
23
- */
24
- connect(): Promise<void>;
25
- /**
26
- * Check if the signer is connected.
27
- *
28
- * @returns A promise that resolves the connection status.
29
- */
30
- isConnected(): Promise<boolean>;
31
- /**
32
- * Gets the Bitcoin account associated with the signer.
33
- *
34
- * @returns A promise that resolves to a string representing the Bitcoin account.
35
- *
36
- * @example
37
- * ```typescript
38
- * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
39
- * ```
40
- */
41
- getBtcAccount(): Promise<string>;
42
- /**
43
- * Gets the Bitcoin public key associated with the signer.
44
- *
45
- * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
46
- *
47
- * @example
48
- * ```typescript
49
- * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
50
- * ```
51
- */
52
- getBtcPublicKey(): Promise<Hex>;
9
+ private readonly account;
10
+ private readonly publicKey;
11
+ /**
12
+ * Creates an instance of SignerBtcPublicKeyReadonly.
13
+ *
14
+ * @param client - The client instance used for communication.
15
+ * @param account - The Bitcoin account associated with the signer.
16
+ * @param publicKey - The public key associated with the signer.
17
+ */
18
+ constructor(client: Client, account: string, publicKey: HexLike);
19
+ /**
20
+ * Connects to the client. This implementation does nothing as the class is read-only.
21
+ *
22
+ * @returns A promise that resolves when the connection is complete.
23
+ */
24
+ connect(): Promise<void>;
25
+ /**
26
+ * Check if the signer is connected.
27
+ *
28
+ * @returns A promise that resolves the connection status.
29
+ */
30
+ isConnected(): Promise<boolean>;
31
+ /**
32
+ * Gets the Bitcoin account associated with the signer.
33
+ *
34
+ * @returns A promise that resolves to a string representing the Bitcoin account.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
39
+ * ```
40
+ */
41
+ getBtcAccount(): Promise<string>;
42
+ /**
43
+ * Gets the Bitcoin public key associated with the signer.
44
+ *
45
+ * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
50
+ * ```
51
+ */
52
+ getBtcPublicKey(): Promise<Hex>;
53
53
  }
54
- //# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
54
+ //# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
@@ -8,57 +8,57 @@ const signerBtc_1 = require("./signerBtc");
8
8
  * This class does not support signing operations.
9
9
  */
10
10
  class SignerBtcPublicKeyReadonly extends signerBtc_1.SignerBtc {
11
- /**
12
- * Creates an instance of SignerBtcPublicKeyReadonly.
13
- *
14
- * @param client - The client instance used for communication.
15
- * @param account - The Bitcoin account associated with the signer.
16
- * @param publicKey - The public key associated with the signer.
17
- */
18
- constructor(client, account, publicKey) {
19
- super(client);
20
- this.account = account;
21
- this.publicKey = (0, hex_1.hexFrom)(publicKey);
22
- }
23
- /**
24
- * Connects to the client. This implementation does nothing as the class is read-only.
25
- *
26
- * @returns A promise that resolves when the connection is complete.
27
- */
28
- async connect() {}
29
- /**
30
- * Check if the signer is connected.
31
- *
32
- * @returns A promise that resolves the connection status.
33
- */
34
- async isConnected() {
35
- return true;
36
- }
37
- /**
38
- * Gets the Bitcoin account associated with the signer.
39
- *
40
- * @returns A promise that resolves to a string representing the Bitcoin account.
41
- *
42
- * @example
43
- * ```typescript
44
- * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
45
- * ```
46
- */
47
- async getBtcAccount() {
48
- return this.account;
49
- }
50
- /**
51
- * Gets the Bitcoin public key associated with the signer.
52
- *
53
- * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
54
- *
55
- * @example
56
- * ```typescript
57
- * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
58
- * ```
59
- */
60
- async getBtcPublicKey() {
61
- return this.publicKey;
62
- }
11
+ /**
12
+ * Creates an instance of SignerBtcPublicKeyReadonly.
13
+ *
14
+ * @param client - The client instance used for communication.
15
+ * @param account - The Bitcoin account associated with the signer.
16
+ * @param publicKey - The public key associated with the signer.
17
+ */
18
+ constructor(client, account, publicKey) {
19
+ super(client);
20
+ this.account = account;
21
+ this.publicKey = (0, hex_1.hexFrom)(publicKey);
22
+ }
23
+ /**
24
+ * Connects to the client. This implementation does nothing as the class is read-only.
25
+ *
26
+ * @returns A promise that resolves when the connection is complete.
27
+ */
28
+ async connect() { }
29
+ /**
30
+ * Check if the signer is connected.
31
+ *
32
+ * @returns A promise that resolves the connection status.
33
+ */
34
+ async isConnected() {
35
+ return true;
36
+ }
37
+ /**
38
+ * Gets the Bitcoin account associated with the signer.
39
+ *
40
+ * @returns A promise that resolves to a string representing the Bitcoin account.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
45
+ * ```
46
+ */
47
+ async getBtcAccount() {
48
+ return this.account;
49
+ }
50
+ /**
51
+ * Gets the Bitcoin public key associated with the signer.
52
+ *
53
+ * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
58
+ * ```
59
+ */
60
+ async getBtcPublicKey() {
61
+ return this.publicKey;
62
+ }
63
63
  }
64
64
  exports.SignerBtcPublicKeyReadonly = SignerBtcPublicKeyReadonly;
@@ -1,7 +1,3 @@
1
1
  import { BytesLike } from "../../bytes";
2
- export declare function verifyMessageBtcEcdsa(
3
- message: string | BytesLike,
4
- signature: string,
5
- publicKey: string,
6
- ): boolean;
7
- //# sourceMappingURL=verify.d.ts.map
2
+ export declare function verifyMessageBtcEcdsa(message: string | BytesLike, signature: string, publicKey: string): boolean;
3
+ //# sourceMappingURL=verify.d.ts.map
@@ -6,15 +6,8 @@ const bitcoinjs_message_1 = require("bitcoinjs-message");
6
6
  const bytes_1 = require("../../bytes");
7
7
  const hex_1 = require("../../hex");
8
8
  function verifyMessageBtcEcdsa(message, signature, publicKey) {
9
- const challenge =
10
- typeof message === "string"
11
- ? message
12
- : (0, hex_1.hexFrom)(message).slice(2);
13
- const [_, ...rawSign] = (0, bytes_1.bytesFrom)(signature, "base64");
14
- return secp256k1_1.secp256k1.verify(
15
- (0, bytes_1.bytesFrom)(rawSign),
16
- (0, bitcoinjs_message_1.magicHash)(challenge),
17
- publicKey,
18
- );
9
+ const challenge = typeof message === "string" ? message : (0, hex_1.hexFrom)(message).slice(2);
10
+ const [_, ...rawSign] = (0, bytes_1.bytesFrom)(signature, "base64");
11
+ return secp256k1_1.secp256k1.verify((0, bytes_1.bytesFrom)(rawSign), (0, bitcoinjs_message_1.magicHash)(challenge), publicKey);
19
12
  }
20
13
  exports.verifyMessageBtcEcdsa = verifyMessageBtcEcdsa;
@@ -1,3 +1,3 @@
1
1
  export * from "./signerCkbScriptReadonly";
2
2
  export * from "./verifyJoyId";
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -1,34 +1,18 @@
1
1
  "use strict";
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (
9
- !desc ||
10
- ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
- ) {
12
- desc = {
13
- enumerable: true,
14
- get: function () {
15
- return m[k];
16
- },
17
- };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }
21
- : function (o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- });
25
- var __exportStar =
26
- (this && this.__exportStar) ||
27
- function (m, exports) {
28
- for (var p in m)
29
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
30
- __createBinding(exports, m, p);
31
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
32
16
  Object.defineProperty(exports, "__esModule", { value: true });
33
17
  __exportStar(require("./signerCkbScriptReadonly"), exports);
34
18
  __exportStar(require("./verifyJoyId"), exports);
@@ -7,49 +7,49 @@ import { Signer, SignerSignType, SignerType } from "../signer";
7
7
  * This class does not support signing operations.
8
8
  */
9
9
  export declare class SignerCkbScriptReadonly extends Signer {
10
- get type(): SignerType;
11
- get signType(): SignerSignType;
12
- private readonly script;
13
- /**
14
- * Creates an instance of SignerCkbScriptReadonly.
15
- *
16
- * @param client - The client instance used for communication.
17
- * @param script - The script associated with the signer.
18
- */
19
- constructor(client: Client, script: ScriptLike);
20
- /**
21
- * Connects to the client. This implementation does nothing as the class is read-only.
22
- *
23
- * @returns A promise that resolves when the connection is complete.
24
- */
25
- connect(): Promise<void>;
26
- /**
27
- * Check if the signer is connected.
28
- *
29
- * @returns A promise that resolves the connection status.
30
- */
31
- isConnected(): Promise<boolean>;
32
- /**
33
- * Gets the internal address for the script.
34
- *
35
- * @returns A promise that resolves to a string representing the internal address.
36
- *
37
- * @example
38
- * ```typescript
39
- * const internalAddress = await signer.getInternalAddress(); // Outputs the internal address
40
- * ```
41
- */
42
- getInternalAddress(): Promise<string>;
43
- /**
44
- * Gets an array of Address objects representing the script address.
45
- *
46
- * @returns A promise that resolves to an array of Address objects.
47
- *
48
- * @example
49
- * ```typescript
50
- * const addressObjs = await signer.getAddressObjs(); // Outputs the array of Address objects
51
- * ```
52
- */
53
- getAddressObjs(): Promise<Address[]>;
10
+ get type(): SignerType;
11
+ get signType(): SignerSignType;
12
+ private readonly script;
13
+ /**
14
+ * Creates an instance of SignerCkbScriptReadonly.
15
+ *
16
+ * @param client - The client instance used for communication.
17
+ * @param script - The script associated with the signer.
18
+ */
19
+ constructor(client: Client, script: ScriptLike);
20
+ /**
21
+ * Connects to the client. This implementation does nothing as the class is read-only.
22
+ *
23
+ * @returns A promise that resolves when the connection is complete.
24
+ */
25
+ connect(): Promise<void>;
26
+ /**
27
+ * Check if the signer is connected.
28
+ *
29
+ * @returns A promise that resolves the connection status.
30
+ */
31
+ isConnected(): Promise<boolean>;
32
+ /**
33
+ * Gets the internal address for the script.
34
+ *
35
+ * @returns A promise that resolves to a string representing the internal address.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const internalAddress = await signer.getInternalAddress(); // Outputs the internal address
40
+ * ```
41
+ */
42
+ getInternalAddress(): Promise<string>;
43
+ /**
44
+ * Gets an array of Address objects representing the script address.
45
+ *
46
+ * @returns A promise that resolves to an array of Address objects.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const addressObjs = await signer.getAddressObjs(); // Outputs the array of Address objects
51
+ * ```
52
+ */
53
+ getAddressObjs(): Promise<Address[]>;
54
54
  }
55
- //# sourceMappingURL=signerCkbScriptReadonly.d.ts.map
55
+ //# sourceMappingURL=signerCkbScriptReadonly.d.ts.map