@ckb-ccc/core 0.0.4-alpha.8 → 0.0.5-alpha.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/README.md +6 -0
- package/dist/ckb/transaction.d.ts +85 -2
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +152 -7
- package/dist/client/client.d.ts +8 -3
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +29 -2
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +4 -0
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +4 -0
- package/dist/client/clientTypes.d.ts +48 -1
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +27 -1
- package/dist/client/jsonRpc/index.d.ts +9 -1
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +15 -1
- package/dist/client/jsonRpc/transformers.d.ts +17 -3
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +37 -3
- package/dist/client/jsonRpc/types.d.ts +15 -0
- package/dist/client/jsonRpc/types.d.ts.map +1 -1
- package/dist/fixedPoint/index.d.ts.map +1 -1
- package/dist/fixedPoint/index.js +4 -1
- package/dist/fixedPoint/index.test.d.ts +2 -0
- package/dist/fixedPoint/index.test.d.ts.map +1 -0
- package/dist/fixedPoint/index.test.js +43 -0
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +2 -3
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +12 -0
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/btc/signerBtcPublicKeyReadonly.js +16 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +12 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +16 -0
- package/dist/signer/evm/signerEvm.d.ts +5 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +21 -8
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +13 -1
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.js +16 -0
- package/dist/signer/index.d.ts +0 -1
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +0 -1
- package/dist/signer/signer.d.ts +26 -6
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +14 -3
- package/dist.commonjs/address/address.advanced.d.ts +65 -0
- package/dist.commonjs/address/address.advanced.d.ts.map +1 -0
- package/dist.commonjs/address/address.advanced.js +149 -0
- package/dist.commonjs/address/advanced.d.ts +2 -0
- package/dist.commonjs/address/advanced.d.ts.map +1 -0
- package/dist.commonjs/address/advanced.js +17 -0
- package/dist.commonjs/address/index.d.ts +54 -0
- package/dist.commonjs/address/index.d.ts.map +1 -0
- package/dist.commonjs/address/index.js +84 -0
- package/dist.commonjs/advanced.d.ts +3 -0
- package/dist.commonjs/advanced.d.ts.map +1 -0
- package/dist.commonjs/advanced.js +31 -0
- package/dist.commonjs/advancedBarrel.d.ts +5 -0
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -0
- package/dist.commonjs/advancedBarrel.js +20 -0
- package/dist.commonjs/barrel.d.ts +11 -0
- package/dist.commonjs/barrel.d.ts.map +1 -0
- package/dist.commonjs/barrel.js +26 -0
- package/dist.commonjs/bytes/advanced.d.ts +5 -0
- package/dist.commonjs/bytes/advanced.d.ts.map +1 -0
- package/dist.commonjs/bytes/advanced.js +2 -0
- package/dist.commonjs/bytes/index.d.ts +64 -0
- package/dist.commonjs/bytes/index.d.ts.map +1 -0
- package/dist.commonjs/bytes/index.js +97 -0
- package/dist.commonjs/ckb/advanced.d.ts +4 -0
- package/dist.commonjs/ckb/advanced.d.ts.map +1 -0
- package/dist.commonjs/ckb/advanced.js +32 -0
- package/dist.commonjs/ckb/index.d.ts +3 -0
- package/dist.commonjs/ckb/index.d.ts.map +1 -0
- package/dist.commonjs/ckb/index.js +18 -0
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +355 -0
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts.map +1 -0
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -0
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +6 -0
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts.map +1 -0
- package/dist.commonjs/ckb/molecule.advanced/index.js +25 -0
- package/dist.commonjs/ckb/script.advanced.d.ts +5 -0
- package/dist.commonjs/ckb/script.advanced.d.ts.map +1 -0
- package/dist.commonjs/ckb/script.advanced.js +16 -0
- package/dist.commonjs/ckb/script.d.ts +126 -0
- package/dist.commonjs/ckb/script.d.ts.map +1 -0
- package/dist.commonjs/ckb/script.js +188 -0
- package/dist.commonjs/ckb/transaction.advanced.d.ts +5 -0
- package/dist.commonjs/ckb/transaction.advanced.d.ts.map +1 -0
- package/dist.commonjs/ckb/transaction.advanced.js +12 -0
- package/dist.commonjs/ckb/transaction.d.ts +616 -0
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -0
- package/dist.commonjs/ckb/transaction.js +810 -0
- package/dist.commonjs/client/advanced.d.ts +4 -0
- package/dist.commonjs/client/advanced.d.ts.map +1 -0
- package/dist.commonjs/client/advanced.js +19 -0
- package/dist.commonjs/client/client.d.ts +24 -0
- package/dist.commonjs/client/client.d.ts.map +1 -0
- package/dist.commonjs/client/client.js +57 -0
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -0
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +30 -0
- package/dist.commonjs/client/clientPublicMainnet.d.ts +9 -0
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicMainnet.js +17 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +4 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +30 -0
- package/dist.commonjs/client/clientPublicTestnet.d.ts +9 -0
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicTestnet.js +17 -0
- package/dist.commonjs/client/clientTypes.d.ts +55 -0
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -0
- package/dist.commonjs/client/clientTypes.js +31 -0
- package/dist.commonjs/client/index.d.ts +6 -0
- package/dist.commonjs/client/index.d.ts.map +1 -0
- package/dist.commonjs/client/index.js +21 -0
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +3 -0
- package/dist.commonjs/client/jsonRpc/advanced.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/advanced.js +18 -0
- package/dist.commonjs/client/jsonRpc/index.d.ts +76 -0
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/index.js +142 -0
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +42 -0
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/transformers.js +160 -0
- package/dist.commonjs/client/jsonRpc/types.d.ts +56 -0
- package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/types.js +2 -0
- package/dist.commonjs/fixedPoint/index.d.ts +49 -0
- package/dist.commonjs/fixedPoint/index.d.ts.map +1 -0
- package/dist.commonjs/fixedPoint/index.js +68 -0
- package/dist.commonjs/fixedPoint/index.test.d.ts +2 -0
- package/dist.commonjs/fixedPoint/index.test.d.ts.map +1 -0
- package/dist.commonjs/fixedPoint/index.test.js +45 -0
- package/dist.commonjs/hasher/advanced.d.ts +2 -0
- package/dist.commonjs/hasher/advanced.d.ts.map +1 -0
- package/dist.commonjs/hasher/advanced.js +4 -0
- package/dist.commonjs/hasher/index.d.ts +52 -0
- package/dist.commonjs/hasher/index.d.ts.map +1 -0
- package/dist.commonjs/hasher/index.js +68 -0
- package/dist.commonjs/hex/index.d.ts +24 -0
- package/dist.commonjs/hex/index.d.ts.map +1 -0
- package/dist.commonjs/hex/index.js +20 -0
- package/dist.commonjs/index.d.ts +3 -0
- package/dist.commonjs/index.d.ts.map +1 -0
- package/dist.commonjs/index.js +31 -0
- package/dist.commonjs/num/index.d.ts +112 -0
- package/dist.commonjs/num/index.d.ts.map +1 -0
- package/dist.commonjs/num/index.js +139 -0
- package/dist.commonjs/signer/btc/index.d.ts +3 -0
- package/dist.commonjs/signer/btc/index.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/index.js +18 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts +50 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/signerBtc.js +70 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +60 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +72 -0
- package/dist.commonjs/signer/ckb/index.d.ts +2 -0
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/index.js +17 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +59 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +71 -0
- package/dist.commonjs/signer/evm/index.d.ts +3 -0
- package/dist.commonjs/signer/evm/index.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/index.js +18 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts +46 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/signerEvm.js +82 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +52 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +62 -0
- package/dist.commonjs/signer/index.d.ts +5 -0
- package/dist.commonjs/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/index.js +20 -0
- package/dist.commonjs/signer/signer.d.ts +133 -0
- package/dist.commonjs/signer/signer.d.ts.map +1 -0
- package/dist.commonjs/signer/signer.js +117 -0
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +1 -0
- package/dist.commonjs/utils/index.d.ts +7 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -0
- package/dist.commonjs/utils/index.js +10 -0
- package/jest.config.js +5 -0
- package/package.json +24 -7
- package/src/ckb/transaction.ts +198 -3
- package/src/client/client.ts +64 -3
- package/src/client/clientPublicMainnet.advanced.ts +5 -0
- package/src/client/clientPublicTestnet.advanced.ts +5 -0
- package/src/client/clientTypes.ts +70 -1
- package/src/client/jsonRpc/index.ts +38 -2
- package/src/client/jsonRpc/transformers.ts +73 -4
- package/src/client/jsonRpc/types.ts +16 -0
- package/src/fixedPoint/index.test.ts +55 -0
- package/src/fixedPoint/index.ts +7 -1
- package/src/signer/btc/signerBtc.ts +6 -3
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +18 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +18 -0
- package/src/signer/evm/signerEvm.ts +56 -14
- package/src/signer/evm/signerEvmAddressReadonly.ts +19 -1
- package/src/signer/index.ts +0 -1
- package/src/signer/signer.ts +29 -3
- package/dist/signer/helpers.d.ts +0 -40
- package/dist/signer/helpers.d.ts.map +0 -1
- package/dist/signer/helpers.js +0 -90
- package/src/signer/helpers.ts +0 -122
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ccc = void 0;
|
|
30
|
+
__exportStar(require("./barrel"), exports);
|
|
31
|
+
exports.ccc = __importStar(require("./barrel"));
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Bytes, BytesLike } from "../bytes";
|
|
2
|
+
import { Hex, HexLike } from "../hex";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a numeric value as a bigint.
|
|
5
|
+
*/
|
|
6
|
+
export type Num = bigint;
|
|
7
|
+
/**
|
|
8
|
+
* Represents a value that can be converted to a numeric value.
|
|
9
|
+
* It can be a string, number, bigint, or HexLike.
|
|
10
|
+
*/
|
|
11
|
+
export type NumLike = string | number | bigint | HexLike;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a NumLike value to a Num (bigint).
|
|
14
|
+
*
|
|
15
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
16
|
+
* @returns A Num (bigint) representing the value.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const num = numFrom("12345"); // Outputs 12345n
|
|
21
|
+
* const numFromHex = numFrom("0x3039"); // Outputs 12345n
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function numFrom(val: NumLike): Num;
|
|
25
|
+
/**
|
|
26
|
+
* Converts a NumLike value to a hexadecimal string.
|
|
27
|
+
*
|
|
28
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
29
|
+
* @returns A Hex string representing the numeric value.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const hex = numToHex(12345); // Outputs "0x3039"
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function numToHex(val: NumLike): Hex;
|
|
37
|
+
/**
|
|
38
|
+
* Converts a NumLike value to a byte array in little-endian order.
|
|
39
|
+
*
|
|
40
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
41
|
+
* @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
|
|
42
|
+
* @returns A Uint8Array containing the byte representation of the numeric value.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const bytes = numToBytes(12345, 4); // Outputs Uint8Array [57, 48, 0, 0]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function numToBytes(val: NumLike, bytes?: number): Bytes;
|
|
50
|
+
/**
|
|
51
|
+
* Converts a NumLike value to a byte array in little-endian order.
|
|
52
|
+
*
|
|
53
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
54
|
+
* @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
|
|
55
|
+
* @returns A Uint8Array containing the byte representation of the numeric value.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const bytes = numLeToBytes(12345, 4); // Outputs Uint8Array [57, 48, 0, 0]
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function numLeToBytes(val: NumLike, bytes?: number): Bytes;
|
|
63
|
+
/**
|
|
64
|
+
* Converts a NumLike value to a byte array in big-endian order.
|
|
65
|
+
*
|
|
66
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
67
|
+
* @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
|
|
68
|
+
* @returns A Uint8Array containing the byte representation of the numeric value.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const bytes = numBeToBytes(12345, 4); // Outputs Uint8Array [0, 0, 48, 57]
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function numBeToBytes(val: NumLike, bytes?: number): Bytes;
|
|
76
|
+
/**
|
|
77
|
+
* Converts a byte array to a Num (bigint) assuming little-endian order.
|
|
78
|
+
*
|
|
79
|
+
* @param val - The byte array to convert.
|
|
80
|
+
* @returns A Num (bigint) representing the numeric value.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const num = numFromBytes(new Uint8Array([57, 48, 0, 0])); // Outputs 12345n
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function numFromBytes(val: BytesLike): Num;
|
|
88
|
+
/**
|
|
89
|
+
* Converts a byte array to a Num (bigint) assuming little-endian order.
|
|
90
|
+
*
|
|
91
|
+
* @param val - The byte array to convert.
|
|
92
|
+
* @returns A Num (bigint) representing the numeric value.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const num = numLeFromBytes(new Uint8Array([57, 48, 0, 0])); // Outputs 12345n
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function numLeFromBytes(val: BytesLike): Num;
|
|
100
|
+
/**
|
|
101
|
+
* Converts a byte array to a Num (bigint) assuming big-endian order.
|
|
102
|
+
*
|
|
103
|
+
* @param val - The byte array to convert.
|
|
104
|
+
* @returns A Num (bigint) representing the numeric value.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const num = numBeFromBytes(new Uint8Array([0, 0, 48, 57])); // Outputs 12345n
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function numBeFromBytes(val: BytesLike): Num;
|
|
112
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/num/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAA0B,MAAM,UAAU,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAUzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAE1C;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAE9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAEhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAUhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAElD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAElD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.numBeFromBytes = exports.numLeFromBytes = exports.numFromBytes = exports.numBeToBytes = exports.numLeToBytes = exports.numToBytes = exports.numToHex = exports.numFrom = void 0;
|
|
4
|
+
const bytes_1 = require("../bytes");
|
|
5
|
+
const hex_1 = require("../hex");
|
|
6
|
+
/**
|
|
7
|
+
* Converts a NumLike value to a Num (bigint).
|
|
8
|
+
*
|
|
9
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
10
|
+
* @returns A Num (bigint) representing the value.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const num = numFrom("12345"); // Outputs 12345n
|
|
15
|
+
* const numFromHex = numFrom("0x3039"); // Outputs 12345n
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function numFrom(val) {
|
|
19
|
+
if (typeof val === "bigint") {
|
|
20
|
+
return val;
|
|
21
|
+
}
|
|
22
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
23
|
+
return BigInt(val);
|
|
24
|
+
}
|
|
25
|
+
return BigInt((0, hex_1.hexFrom)(val));
|
|
26
|
+
}
|
|
27
|
+
exports.numFrom = numFrom;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a NumLike value to a hexadecimal string.
|
|
30
|
+
*
|
|
31
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
32
|
+
* @returns A Hex string representing the numeric value.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const hex = numToHex(12345); // Outputs "0x3039"
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function numToHex(val) {
|
|
40
|
+
return `0x${numFrom(val).toString(16)}`;
|
|
41
|
+
}
|
|
42
|
+
exports.numToHex = numToHex;
|
|
43
|
+
/**
|
|
44
|
+
* Converts a NumLike value to a byte array in little-endian order.
|
|
45
|
+
*
|
|
46
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
47
|
+
* @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
|
|
48
|
+
* @returns A Uint8Array containing the byte representation of the numeric value.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const bytes = numToBytes(12345, 4); // Outputs Uint8Array [57, 48, 0, 0]
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function numToBytes(val, bytes) {
|
|
56
|
+
return numLeToBytes(val, bytes);
|
|
57
|
+
}
|
|
58
|
+
exports.numToBytes = numToBytes;
|
|
59
|
+
/**
|
|
60
|
+
* Converts a NumLike value to a byte array in little-endian order.
|
|
61
|
+
*
|
|
62
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
63
|
+
* @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
|
|
64
|
+
* @returns A Uint8Array containing the byte representation of the numeric value.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const bytes = numLeToBytes(12345, 4); // Outputs Uint8Array [57, 48, 0, 0]
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function numLeToBytes(val, bytes) {
|
|
72
|
+
return numBeToBytes(val, bytes).reverse();
|
|
73
|
+
}
|
|
74
|
+
exports.numLeToBytes = numLeToBytes;
|
|
75
|
+
/**
|
|
76
|
+
* Converts a NumLike value to a byte array in big-endian order.
|
|
77
|
+
*
|
|
78
|
+
* @param val - The value to convert, which can be a string, number, bigint, or HexLike.
|
|
79
|
+
* @param bytes - The number of bytes to use for the representation. If not provided, the exact number of bytes needed is used.
|
|
80
|
+
* @returns A Uint8Array containing the byte representation of the numeric value.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const bytes = numBeToBytes(12345, 4); // Outputs Uint8Array [0, 0, 48, 57]
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function numBeToBytes(val, bytes) {
|
|
88
|
+
const rawBytes = (0, bytes_1.bytesFrom)(numFrom(val).toString(16));
|
|
89
|
+
if (bytes == null) {
|
|
90
|
+
return rawBytes;
|
|
91
|
+
}
|
|
92
|
+
return (0, bytes_1.bytesConcat)(Array.from(Array(bytes - rawBytes.length), () => 0), rawBytes);
|
|
93
|
+
}
|
|
94
|
+
exports.numBeToBytes = numBeToBytes;
|
|
95
|
+
/**
|
|
96
|
+
* Converts a byte array to a Num (bigint) assuming little-endian order.
|
|
97
|
+
*
|
|
98
|
+
* @param val - The byte array to convert.
|
|
99
|
+
* @returns A Num (bigint) representing the numeric value.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const num = numFromBytes(new Uint8Array([57, 48, 0, 0])); // Outputs 12345n
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
function numFromBytes(val) {
|
|
107
|
+
return numLeFromBytes(val);
|
|
108
|
+
}
|
|
109
|
+
exports.numFromBytes = numFromBytes;
|
|
110
|
+
/**
|
|
111
|
+
* Converts a byte array to a Num (bigint) assuming little-endian order.
|
|
112
|
+
*
|
|
113
|
+
* @param val - The byte array to convert.
|
|
114
|
+
* @returns A Num (bigint) representing the numeric value.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const num = numLeFromBytes(new Uint8Array([57, 48, 0, 0])); // Outputs 12345n
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
function numLeFromBytes(val) {
|
|
122
|
+
return numBeFromBytes((0, bytes_1.bytesFrom)(val).reverse());
|
|
123
|
+
}
|
|
124
|
+
exports.numLeFromBytes = numLeFromBytes;
|
|
125
|
+
/**
|
|
126
|
+
* Converts a byte array to a Num (bigint) assuming big-endian order.
|
|
127
|
+
*
|
|
128
|
+
* @param val - The byte array to convert.
|
|
129
|
+
* @returns A Num (bigint) representing the numeric value.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const num = numBeFromBytes(new Uint8Array([0, 0, 48, 57])); // Outputs 12345n
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
function numBeFromBytes(val) {
|
|
137
|
+
return numFrom((0, bytes_1.bytesFrom)(val));
|
|
138
|
+
}
|
|
139
|
+
exports.numBeFromBytes = numBeFromBytes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./signerBtc"), exports);
|
|
18
|
+
__exportStar(require("./signerBtcPublicKeyReadonly"), exports);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { Transaction, TransactionLike } from "../../ckb";
|
|
3
|
+
import { HexLike } from "../../hex";
|
|
4
|
+
import { Signer } from "../signer";
|
|
5
|
+
/**
|
|
6
|
+
* An abstract class extending the Signer class for Bitcoin-like signing operations.
|
|
7
|
+
* This class provides methods to get Bitcoin account, public key, and internal address,
|
|
8
|
+
* as well as signing transactions.
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class SignerBtc extends Signer {
|
|
11
|
+
/**
|
|
12
|
+
* Gets the Bitcoin account associated with the signer.
|
|
13
|
+
*
|
|
14
|
+
* @returns A promise that resolves to a string representing the Bitcoin account.
|
|
15
|
+
*/
|
|
16
|
+
abstract getBtcAccount(): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the Bitcoin public key associated with the signer.
|
|
19
|
+
*
|
|
20
|
+
* @returns A promise that resolves to a HexLike value representing the Bitcoin public key.
|
|
21
|
+
*/
|
|
22
|
+
abstract getBtcPublicKey(): Promise<HexLike>;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the internal address, which is the Bitcoin account in this case.
|
|
25
|
+
*
|
|
26
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
27
|
+
*/
|
|
28
|
+
getInternalAddress(): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
31
|
+
*
|
|
32
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
33
|
+
*/
|
|
34
|
+
getAddressObjs(): Promise<Address[]>;
|
|
35
|
+
/**
|
|
36
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
37
|
+
*
|
|
38
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
39
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
40
|
+
*/
|
|
41
|
+
prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
42
|
+
/**
|
|
43
|
+
* Signs a transaction without modifying it.
|
|
44
|
+
*
|
|
45
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
46
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
47
|
+
*/
|
|
48
|
+
signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=signerBtc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IASvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerBtc = void 0;
|
|
4
|
+
const ripemd160_1 = require("@noble/hashes/ripemd160");
|
|
5
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
6
|
+
const address_1 = require("../../address");
|
|
7
|
+
const bytes_1 = require("../../bytes");
|
|
8
|
+
const ckb_1 = require("../../ckb");
|
|
9
|
+
const client_1 = require("../../client");
|
|
10
|
+
const hex_1 = require("../../hex");
|
|
11
|
+
const num_1 = require("../../num");
|
|
12
|
+
const signer_1 = require("../signer");
|
|
13
|
+
/**
|
|
14
|
+
* An abstract class extending the Signer class for Bitcoin-like signing operations.
|
|
15
|
+
* This class provides methods to get Bitcoin account, public key, and internal address,
|
|
16
|
+
* as well as signing transactions.
|
|
17
|
+
*/
|
|
18
|
+
class SignerBtc extends signer_1.Signer {
|
|
19
|
+
/**
|
|
20
|
+
* Gets the internal address, which is the Bitcoin account in this case.
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
23
|
+
*/
|
|
24
|
+
async getInternalAddress() {
|
|
25
|
+
return this.getBtcAccount();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
29
|
+
*
|
|
30
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
31
|
+
*/
|
|
32
|
+
async getAddressObjs() {
|
|
33
|
+
const publicKey = await this.getBtcPublicKey();
|
|
34
|
+
const hash = (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)((0, bytes_1.bytesFrom)(publicKey)));
|
|
35
|
+
return [
|
|
36
|
+
await address_1.Address.fromKnownScript(client_1.KnownScript.OmniLock, (0, hex_1.hexFrom)([0x04, ...hash, 0x00]), this.client),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
41
|
+
*
|
|
42
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
43
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
44
|
+
*/
|
|
45
|
+
async prepareTransaction(txLike) {
|
|
46
|
+
const { script } = await this.getRecommendedAddressObj();
|
|
47
|
+
return ckb_1.Transaction.from(txLike).prepareSighashAllWitness(script, 85, this.client);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Signs a transaction without modifying it.
|
|
51
|
+
*
|
|
52
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
53
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
54
|
+
*/
|
|
55
|
+
async signOnlyTransaction(txLike) {
|
|
56
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
57
|
+
const { script } = await this.getRecommendedAddressObj();
|
|
58
|
+
const info = await tx.getSignHashInfo(script, this.client);
|
|
59
|
+
if (!info) {
|
|
60
|
+
return tx;
|
|
61
|
+
}
|
|
62
|
+
const signature = (0, bytes_1.bytesFrom)(await this.signMessage(`CKB (Bitcoin Layer) transaction: ${info.message}`), "base64");
|
|
63
|
+
signature[0] = 31 + ((signature[0] - 27) % 4);
|
|
64
|
+
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
65
|
+
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));
|
|
66
|
+
tx.witnesses[info.position] = (0, hex_1.hexFrom)(witness.toBytes());
|
|
67
|
+
return tx;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.SignerBtc = SignerBtc;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Client } from "../../client";
|
|
2
|
+
import { Hex, HexLike } from "../../hex";
|
|
3
|
+
import { SignerBtc } from "./signerBtc";
|
|
4
|
+
/**
|
|
5
|
+
* A class extending SignerBtc that provides read-only access to a Bitcoin public key and account.
|
|
6
|
+
* This class does not support signing operations.
|
|
7
|
+
*/
|
|
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
|
+
* Construct a new signer with the client replaced.
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise that resolves the new Signer.
|
|
23
|
+
*/
|
|
24
|
+
replaceClient(client: Client): Promise<SignerBtcPublicKeyReadonly>;
|
|
25
|
+
/**
|
|
26
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
27
|
+
*
|
|
28
|
+
* @returns A promise that resolves when the connection is complete.
|
|
29
|
+
*/
|
|
30
|
+
connect(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if the signer is connected.
|
|
33
|
+
*
|
|
34
|
+
* @returns A promise that resolves the connection status.
|
|
35
|
+
*/
|
|
36
|
+
isConnected(): Promise<boolean>;
|
|
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
|
+
getBtcAccount(): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the Bitcoin public key associated with the signer.
|
|
50
|
+
*
|
|
51
|
+
* @returns A promise that resolves to a Hex string representing the Bitcoin public key.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
getBtcPublicKey(): Promise<Hex>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIxE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAGtC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerBtcPublicKeyReadonly = void 0;
|
|
4
|
+
const hex_1 = require("../../hex");
|
|
5
|
+
const signerBtc_1 = require("./signerBtc");
|
|
6
|
+
/**
|
|
7
|
+
* A class extending SignerBtc that provides read-only access to a Bitcoin public key and account.
|
|
8
|
+
* This class does not support signing operations.
|
|
9
|
+
*/
|
|
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
|
+
* Construct a new signer with the client replaced.
|
|
25
|
+
*
|
|
26
|
+
* @returns A promise that resolves the new Signer.
|
|
27
|
+
*/
|
|
28
|
+
async replaceClient(client) {
|
|
29
|
+
return new SignerBtcPublicKeyReadonly(client, this.account, this.publicKey);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
33
|
+
*
|
|
34
|
+
* @returns A promise that resolves when the connection is complete.
|
|
35
|
+
*/
|
|
36
|
+
async connect() { }
|
|
37
|
+
/**
|
|
38
|
+
* Check if the signer is connected.
|
|
39
|
+
*
|
|
40
|
+
* @returns A promise that resolves the connection status.
|
|
41
|
+
*/
|
|
42
|
+
async isConnected() {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the Bitcoin account associated with the signer.
|
|
47
|
+
*
|
|
48
|
+
* @returns A promise that resolves to a string representing the Bitcoin account.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async getBtcAccount() {
|
|
56
|
+
return this.account;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the Bitcoin public key associated with the signer.
|
|
60
|
+
*
|
|
61
|
+
* @returns A promise that resolves to a Hex string representing the Bitcoin public key.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
async getBtcPublicKey() {
|
|
69
|
+
return this.publicKey;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.SignerBtcPublicKeyReadonly = SignerBtcPublicKeyReadonly;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./signerCkbScriptReadonly"), exports);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { ScriptLike } from "../../ckb";
|
|
3
|
+
import { Client } from "../../client";
|
|
4
|
+
import { Signer } from "../signer";
|
|
5
|
+
/**
|
|
6
|
+
* A class extending Signer that provides read-only access to a CKB script.
|
|
7
|
+
* This class does not support signing operations.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SignerCkbScriptReadonly extends Signer {
|
|
10
|
+
private readonly script;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of SignerCkbScriptReadonly.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The client instance used for communication.
|
|
15
|
+
* @param script - The script associated with the signer.
|
|
16
|
+
*/
|
|
17
|
+
constructor(client: Client, script: ScriptLike);
|
|
18
|
+
/**
|
|
19
|
+
* Construct a new signer with the client replaced.
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves the new Signer.
|
|
22
|
+
*/
|
|
23
|
+
replaceClient(client: Client): Promise<SignerCkbScriptReadonly>;
|
|
24
|
+
/**
|
|
25
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
26
|
+
*
|
|
27
|
+
* @returns A promise that resolves when the connection is complete.
|
|
28
|
+
*/
|
|
29
|
+
connect(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if the signer is connected.
|
|
32
|
+
*
|
|
33
|
+
* @returns A promise that resolves the connection status.
|
|
34
|
+
*/
|
|
35
|
+
isConnected(): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the internal address for the script.
|
|
38
|
+
*
|
|
39
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const internalAddress = await signer.getInternalAddress(); // Outputs the internal address
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
getInternalAddress(): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Gets an array of Address objects representing the script address.
|
|
49
|
+
*
|
|
50
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const addressObjs = await signer.getAddressObjs(); // Outputs the array of Address objects
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
getAddressObjs(): Promise<Address[]>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=signerCkbScriptReadonly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAIrE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IAEG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|