@ckb-ccc/core 0.0.12-alpha.1 → 0.0.13-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/CHANGELOG.md +15 -0
- package/README.md +10 -7
- package/dist/address/index.d.ts +4 -0
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +1 -0
- package/dist/advancedBarrel.d.ts +1 -0
- package/dist/advancedBarrel.d.ts.map +1 -1
- package/dist/advancedBarrel.js +1 -0
- package/dist/bytes/advanced.d.ts +1 -0
- package/dist/bytes/advanced.d.ts.map +1 -1
- package/dist/bytes/index.d.ts +9 -0
- package/dist/bytes/index.d.ts.map +1 -1
- package/dist/bytes/index.js +3 -0
- package/dist/ckb/index.d.ts +1 -0
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +1 -0
- package/dist/ckb/script.d.ts +15 -0
- package/dist/ckb/script.d.ts.map +1 -1
- package/dist/ckb/script.js +6 -0
- package/dist/ckb/transaction.d.ts +65 -11
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +41 -14
- package/dist/ckb/transactionLumos.d.ts +29 -0
- package/dist/ckb/transactionLumos.d.ts.map +1 -0
- package/dist/ckb/transactionLumos.js +1 -0
- package/dist/client/client.d.ts +13 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +10 -1
- package/dist/client/clientPublicMainnet.d.ts +3 -0
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +3 -0
- package/dist/client/clientPublicTestnet.d.ts +3 -0
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +3 -0
- package/dist/client/clientTypes.d.ts +50 -0
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +9 -0
- package/dist/client/jsonRpc/index.d.ts +6 -6
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +3 -3
- package/dist/client/jsonRpc/transformers.d.ts +7 -2
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +7 -1
- package/dist/fixedPoint/index.d.ts +6 -0
- package/dist/fixedPoint/index.d.ts.map +1 -1
- package/dist/fixedPoint/index.js +5 -0
- package/dist/hasher/hasher.d.ts +3 -0
- package/dist/hasher/hasher.d.ts.map +1 -1
- package/dist/hasher/hasherCkb.d.ts +6 -1
- package/dist/hasher/hasherCkb.d.ts.map +1 -1
- package/dist/hasher/hasherCkb.js +6 -1
- package/dist/hasher/hasherKeecak256.d.ts +3 -0
- package/dist/hasher/hasherKeecak256.d.ts.map +1 -1
- package/dist/hasher/hasherKeecak256.js +3 -0
- package/dist/hex/index.d.ts +3 -0
- package/dist/hex/index.d.ts.map +1 -1
- package/dist/hex/index.js +1 -0
- package/dist/keystore/index.d.ts +6 -0
- package/dist/keystore/index.d.ts.map +1 -1
- package/dist/keystore/index.js +6 -0
- package/dist/num/index.d.ts +11 -0
- package/dist/num/index.d.ts.map +1 -1
- package/dist/num/index.js +9 -0
- package/dist/package.json +1 -1
- package/dist/signer/btc/signerBtc.d.ts +1 -0
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +1 -0
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +1 -0
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/btc/signerBtcPublicKeyReadonly.js +1 -0
- package/dist/signer/btc/verify.d.ts +3 -0
- package/dist/signer/btc/verify.d.ts.map +1 -1
- package/dist/signer/btc/verify.js +3 -0
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts +3 -0
- package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbPrivateKey.js +3 -0
- package/dist/signer/ckb/signerCkbPublicKey.d.ts +3 -0
- package/dist/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbPublicKey.js +3 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +1 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +1 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.d.ts +6 -0
- package/dist/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -1
- package/dist/signer/ckb/verifyCkbSecp256k1.js +6 -0
- package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -1
- package/dist/signer/ckb/verifyJoyId.js +3 -0
- package/dist/signer/dummy/alwaysError.d.ts +3 -0
- package/dist/signer/dummy/alwaysError.d.ts.map +1 -1
- package/dist/signer/dummy/alwaysError.js +3 -0
- package/dist/signer/dummy/dummy.d.ts +3 -0
- package/dist/signer/dummy/dummy.d.ts.map +1 -1
- package/dist/signer/dummy/dummy.js +3 -0
- package/dist/signer/dummy/openLink.d.ts +3 -0
- package/dist/signer/dummy/openLink.d.ts.map +1 -1
- package/dist/signer/dummy/openLink.js +3 -0
- package/dist/signer/evm/signerEvm.d.ts +1 -0
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +1 -0
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +1 -0
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.js +1 -0
- package/dist/signer/evm/verify.d.ts +3 -0
- package/dist/signer/evm/verify.d.ts.map +1 -1
- package/dist/signer/evm/verify.js +3 -0
- package/dist/signer/nostr/signerNostr.d.ts +6 -0
- package/dist/signer/nostr/signerNostr.d.ts.map +1 -1
- package/dist/signer/nostr/signerNostr.js +3 -0
- package/dist/signer/nostr/verify.d.ts +3 -0
- package/dist/signer/nostr/verify.d.ts.map +1 -1
- package/dist/signer/nostr/verify.js +3 -0
- package/dist/signer/signer/index.d.ts +26 -3
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +12 -3
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +13 -0
- package/dist.commonjs/address/index.d.ts +4 -0
- package/dist.commonjs/address/index.d.ts.map +1 -1
- package/dist.commonjs/address/index.js +1 -0
- package/dist.commonjs/advancedBarrel.d.ts +1 -0
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
- package/dist.commonjs/advancedBarrel.js +1 -0
- package/dist.commonjs/bytes/advanced.d.ts +1 -0
- package/dist.commonjs/bytes/advanced.d.ts.map +1 -1
- package/dist.commonjs/bytes/index.d.ts +9 -0
- package/dist.commonjs/bytes/index.d.ts.map +1 -1
- package/dist.commonjs/bytes/index.js +3 -0
- package/dist.commonjs/ckb/index.d.ts +1 -0
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +1 -0
- package/dist.commonjs/ckb/script.d.ts +15 -0
- package/dist.commonjs/ckb/script.d.ts.map +1 -1
- package/dist.commonjs/ckb/script.js +6 -0
- package/dist.commonjs/ckb/transaction.d.ts +65 -11
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +41 -14
- package/dist.commonjs/ckb/transactionLumos.d.ts +29 -0
- package/dist.commonjs/ckb/transactionLumos.d.ts.map +1 -0
- package/dist.commonjs/ckb/transactionLumos.js +2 -0
- package/dist.commonjs/client/client.d.ts +13 -1
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +10 -1
- package/dist.commonjs/client/clientPublicMainnet.d.ts +3 -0
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +3 -0
- package/dist.commonjs/client/clientPublicTestnet.d.ts +3 -0
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +3 -0
- package/dist.commonjs/client/clientTypes.d.ts +50 -0
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.js +9 -0
- package/dist.commonjs/client/jsonRpc/index.d.ts +6 -6
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +3 -3
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +7 -2
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.js +35 -29
- package/dist.commonjs/fixedPoint/index.d.ts +6 -0
- package/dist.commonjs/fixedPoint/index.d.ts.map +1 -1
- package/dist.commonjs/fixedPoint/index.js +5 -0
- package/dist.commonjs/hasher/hasher.d.ts +3 -0
- package/dist.commonjs/hasher/hasher.d.ts.map +1 -1
- package/dist.commonjs/hasher/hasherCkb.d.ts +6 -1
- package/dist.commonjs/hasher/hasherCkb.d.ts.map +1 -1
- package/dist.commonjs/hasher/hasherCkb.js +6 -1
- package/dist.commonjs/hasher/hasherKeecak256.d.ts +3 -0
- package/dist.commonjs/hasher/hasherKeecak256.d.ts.map +1 -1
- package/dist.commonjs/hasher/hasherKeecak256.js +3 -0
- package/dist.commonjs/hex/index.d.ts +3 -0
- package/dist.commonjs/hex/index.d.ts.map +1 -1
- package/dist.commonjs/hex/index.js +1 -0
- package/dist.commonjs/keystore/index.d.ts +6 -0
- package/dist.commonjs/keystore/index.d.ts.map +1 -1
- package/dist.commonjs/keystore/index.js +6 -0
- package/dist.commonjs/num/index.d.ts +11 -0
- package/dist.commonjs/num/index.d.ts.map +1 -1
- package/dist.commonjs/num/index.js +9 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts +1 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +1 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +1 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +1 -0
- package/dist.commonjs/signer/btc/verify.d.ts +3 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/verify.js +3 -0
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +3 -0
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +3 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +3 -0
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +3 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +1 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +1 -0
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +6 -0
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +6 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/verifyJoyId.js +3 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +3 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -1
- package/dist.commonjs/signer/dummy/alwaysError.js +3 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts +3 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -1
- package/dist.commonjs/signer/dummy/dummy.js +3 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts +3 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -1
- package/dist.commonjs/signer/dummy/openLink.js +3 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts +1 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +1 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +1 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +1 -0
- package/dist.commonjs/signer/evm/verify.d.ts +3 -0
- package/dist.commonjs/signer/evm/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/verify.js +3 -0
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +6 -0
- package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -1
- package/dist.commonjs/signer/nostr/signerNostr.js +3 -0
- package/dist.commonjs/signer/nostr/verify.d.ts +3 -0
- package/dist.commonjs/signer/nostr/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/nostr/verify.js +3 -0
- package/dist.commonjs/signer/signer/index.d.ts +26 -3
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +12 -3
- package/dist.commonjs/utils/index.d.ts +12 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +13 -0
- package/package.json +8 -10
- package/src/address/index.ts +4 -1
- package/src/advancedBarrel.ts +1 -0
- package/src/bytes/advanced.ts +1 -0
- package/src/bytes/index.ts +9 -0
- package/src/ckb/index.ts +1 -0
- package/src/ckb/script.ts +15 -0
- package/src/ckb/transaction.ts +72 -16
- package/src/ckb/transactionLumos.ts +26 -0
- package/src/client/client.ts +13 -1
- package/src/client/clientPublicMainnet.ts +3 -0
- package/src/client/clientPublicTestnet.ts +3 -0
- package/src/client/clientTypes.ts +50 -0
- package/src/client/jsonRpc/index.ts +5 -6
- package/src/client/jsonRpc/transformers.ts +16 -3
- package/src/fixedPoint/index.ts +6 -0
- package/src/hasher/hasher.ts +3 -0
- package/src/hasher/hasherCkb.ts +6 -1
- package/src/hasher/hasherKeecak256.ts +3 -0
- package/src/hex/index.ts +3 -0
- package/src/keystore/index.ts +6 -0
- package/src/num/index.ts +11 -0
- package/src/signer/btc/signerBtc.ts +1 -0
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +1 -0
- package/src/signer/btc/verify.ts +3 -0
- package/src/signer/ckb/signerCkbPrivateKey.ts +3 -0
- package/src/signer/ckb/signerCkbPublicKey.ts +3 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +1 -0
- package/src/signer/ckb/verifyCkbSecp256k1.ts +6 -0
- package/src/signer/ckb/verifyJoyId.ts +3 -0
- package/src/signer/dummy/alwaysError.ts +3 -0
- package/src/signer/dummy/dummy.ts +3 -0
- package/src/signer/dummy/openLink.ts +3 -0
- package/src/signer/evm/signerEvm.ts +1 -0
- package/src/signer/evm/signerEvmAddressReadonly.ts +1 -0
- package/src/signer/evm/verify.ts +3 -0
- package/src/signer/nostr/signerNostr.ts +6 -0
- package/src/signer/nostr/verify.ts +3 -0
- package/src/signer/signer/index.ts +26 -14
- package/src/utils/index.ts +22 -0
- package/typedoc.json +6 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
3
|
+
* @public
|
|
3
4
|
*
|
|
4
5
|
* @param transformer - The transformer.
|
|
5
6
|
* @param value - The value to be transformed.
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
export declare function apply<T, R>(transformer: (val: T) => R, value: undefined): undefined;
|
|
9
10
|
/**
|
|
10
11
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
12
|
+
* @public
|
|
11
13
|
*
|
|
12
14
|
* @param transformer - The transformer.
|
|
13
15
|
* @param value - The value to be transformed.
|
|
@@ -16,6 +18,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: undefined
|
|
|
16
18
|
export declare function apply<T, R>(transformer: (val: T) => R, value: null): undefined;
|
|
17
19
|
/**
|
|
18
20
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
21
|
+
* @public
|
|
19
22
|
*
|
|
20
23
|
* @param transformer - The transformer.
|
|
21
24
|
* @param value - The value to be transformed.
|
|
@@ -24,6 +27,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: null): un
|
|
|
24
27
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
25
28
|
/**
|
|
26
29
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
30
|
+
* @public
|
|
27
31
|
*
|
|
28
32
|
* @param transformer - The transformer.
|
|
29
33
|
* @param value - The value to be transformed.
|
|
@@ -32,6 +36,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
|
32
36
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | undefined): R | undefined;
|
|
33
37
|
/**
|
|
34
38
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
39
|
+
* @public
|
|
35
40
|
*
|
|
36
41
|
* @param transformer - The transformer.
|
|
37
42
|
* @param value - The value to be transformed.
|
|
@@ -40,6 +45,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T | undef
|
|
|
40
45
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | null): R | undefined;
|
|
41
46
|
/**
|
|
42
47
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
48
|
+
* @public
|
|
43
49
|
*
|
|
44
50
|
* @param transformer - The transformer.
|
|
45
51
|
* @param value - The value to be transformed.
|
|
@@ -49,6 +55,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: undefined
|
|
|
49
55
|
/**
|
|
50
56
|
/**
|
|
51
57
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
58
|
+
* @public
|
|
52
59
|
*
|
|
53
60
|
* @param transformer - The transformer.
|
|
54
61
|
* @param value - The value to be transformed.
|
|
@@ -57,6 +64,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: undefined
|
|
|
57
64
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | undefined | null): R | undefined;
|
|
58
65
|
/**
|
|
59
66
|
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
67
|
+
* @public
|
|
60
68
|
*
|
|
61
69
|
* @param values - The array to be reduced.
|
|
62
70
|
* @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
|
|
@@ -65,6 +73,7 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T | undef
|
|
|
65
73
|
export declare function reduceAsync<T, V>(values: T[], accumulator: (a: T, b: T) => Promise<T | undefined | null | void> | T | undefined | null | void): Promise<T>;
|
|
66
74
|
/**
|
|
67
75
|
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
76
|
+
* @public
|
|
68
77
|
*
|
|
69
78
|
* @param values - The array to be reduced.
|
|
70
79
|
* @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
|
|
@@ -72,5 +81,8 @@ export declare function reduceAsync<T, V>(values: T[], accumulator: (a: T, b: T)
|
|
|
72
81
|
* @returns The accumulated result.
|
|
73
82
|
*/
|
|
74
83
|
export declare function reduceAsync<T, V>(values: V[], accumulator: (a: T, b: V, i: number, values: V[]) => Promise<T | undefined | null | void> | T | undefined | null | void, init: T | Promise<T>): Promise<T>;
|
|
84
|
+
/**
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
75
87
|
export declare function isWebview(userAgent: string): boolean;
|
|
76
88
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS,CAAC;AAChF;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,SAAS,CAAC;AACjB;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,CAAC;AACb;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,IAAI,GAC1B,CAAC,GAAG,SAAS,CAAC;AAoBjB;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,CACX,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,KACD,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GACtE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,CACX,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,CAAC,EAAE,KACR,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,EACvE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAAC;AAqCd;;GAEG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isWebview = exports.reduceAsync = exports.apply = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* A type safe way to apply a transformer on a value if it's not empty.
|
|
6
|
+
* @public
|
|
6
7
|
*
|
|
7
8
|
* @param transformer - The transformer.
|
|
8
9
|
* @param value - The value to be transformed.
|
|
@@ -15,6 +16,15 @@ function apply(transformer, value) {
|
|
|
15
16
|
return transformer(value);
|
|
16
17
|
}
|
|
17
18
|
exports.apply = apply;
|
|
19
|
+
/**
|
|
20
|
+
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
21
|
+
* @public
|
|
22
|
+
*
|
|
23
|
+
* @param values - The array to be reduced.
|
|
24
|
+
* @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
|
|
25
|
+
* @param init - The initial value.
|
|
26
|
+
* @returns The accumulated result.
|
|
27
|
+
*/
|
|
18
28
|
async function reduceAsync(values, accumulator, init) {
|
|
19
29
|
if (init === undefined) {
|
|
20
30
|
if (values.length === 0) {
|
|
@@ -26,6 +36,9 @@ async function reduceAsync(values, accumulator, init) {
|
|
|
26
36
|
return values.reduce((current, b, i, array) => current.then((v) => Promise.resolve(accumulator(v, b, i, array)).then((r) => r ?? v)), Promise.resolve(init));
|
|
27
37
|
}
|
|
28
38
|
exports.reduceAsync = reduceAsync;
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
29
42
|
function isWebview(userAgent) {
|
|
30
43
|
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
|
|
31
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-alpha.0",
|
|
4
4
|
"description": "Core of CCC - CKBer's Codebase",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,12 +30,6 @@
|
|
|
30
30
|
"default": "./dist.commonjs/advanced.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"test": "jest",
|
|
35
|
-
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
|
36
|
-
"lint": "eslint",
|
|
37
|
-
"format": "prettier --write . && eslint --fix"
|
|
38
|
-
},
|
|
39
33
|
"devDependencies": {
|
|
40
34
|
"@eslint/js": "^9.1.1",
|
|
41
35
|
"@types/blake2b": "^2.1.3",
|
|
@@ -57,7 +51,6 @@
|
|
|
57
51
|
"access": "public"
|
|
58
52
|
},
|
|
59
53
|
"dependencies": {
|
|
60
|
-
"@ckb-lumos/helpers": "^0.22.2",
|
|
61
54
|
"@joyid/ckb": "^1.0.1",
|
|
62
55
|
"@noble/ciphers": "^0.5.3",
|
|
63
56
|
"@noble/curves": "^1.4.2",
|
|
@@ -69,5 +62,10 @@
|
|
|
69
62
|
"cross-fetch": "^4.0.0",
|
|
70
63
|
"ethers": "^6.13.1"
|
|
71
64
|
},
|
|
72
|
-
"
|
|
73
|
-
|
|
65
|
+
"scripts": {
|
|
66
|
+
"test": "jest",
|
|
67
|
+
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
|
68
|
+
"lint": "eslint",
|
|
69
|
+
"format": "prettier --write . && eslint --fix"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/address/index.ts
CHANGED
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
addressPayloadFromString,
|
|
11
11
|
} from "./address.advanced.js";
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
13
16
|
export type AddressLike = {
|
|
14
17
|
script: ScriptLike;
|
|
15
18
|
prefix: string;
|
|
@@ -17,8 +20,8 @@ export type AddressLike = {
|
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* Represents a ckb address with associated script and prefix.
|
|
23
|
+
* @public
|
|
20
24
|
*/
|
|
21
|
-
|
|
22
25
|
export class Address {
|
|
23
26
|
/**
|
|
24
27
|
* Creates an instance of Address.
|
package/src/advancedBarrel.ts
CHANGED
package/src/bytes/advanced.ts
CHANGED
package/src/bytes/index.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Buffer } from "buffer/index.js";
|
|
2
2
|
import { BytesFromEncoding } from "./advanced.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
4
7
|
export type Bytes = Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
5
11
|
export type BytesLike = string | Uint8Array | ArrayBuffer | number[];
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* Concatenates multiple byte-like arrays into a single byte array.
|
|
15
|
+
* @public
|
|
9
16
|
*
|
|
10
17
|
* @param args - The byte-like arrays to concatenate.
|
|
11
18
|
* @returns A Uint8Array containing the concatenated bytes.
|
|
@@ -33,6 +40,7 @@ export function bytesConcat(...args: BytesLike[]): Bytes {
|
|
|
33
40
|
|
|
34
41
|
/**
|
|
35
42
|
* Converts a byte-like value to a string using the specified encoding.
|
|
43
|
+
* @public
|
|
36
44
|
*
|
|
37
45
|
* @param val - The byte-like value to convert.
|
|
38
46
|
* @param encoding - The encoding to use for the conversion, as defined by the BytesFromEncoding type.
|
|
@@ -54,6 +62,7 @@ export function bytesTo(val: BytesLike, encoding: BytesFromEncoding): string {
|
|
|
54
62
|
|
|
55
63
|
/**
|
|
56
64
|
* Converts various types of byte-like values to a Uint8Array.
|
|
65
|
+
* @public
|
|
57
66
|
*
|
|
58
67
|
* @param bytes - The byte-like value to convert. It can be a string, Uint8Array, ArrayBuffer, or number array.
|
|
59
68
|
* @param encoding - Optional encoding to use if the input is a string. Defaults to hexadecimal if not specified.
|
package/src/ckb/index.ts
CHANGED
package/src/ckb/script.ts
CHANGED
|
@@ -9,11 +9,18 @@ import {
|
|
|
9
9
|
NUM_TO_HASH_TYPE,
|
|
10
10
|
} from "./script.advanced.js";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
12
15
|
export type HashTypeLike = string | number | bigint;
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
13
19
|
export type HashType = "type" | "data" | "data1" | "data2";
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
22
|
* Converts a HashTypeLike value to a HashType.
|
|
23
|
+
* @public
|
|
17
24
|
*
|
|
18
25
|
* @param val - The value to convert, which can be a string, number, or bigint.
|
|
19
26
|
* @returns The corresponding HashType.
|
|
@@ -50,6 +57,7 @@ export function hashTypeFrom(val: HashTypeLike): HashType {
|
|
|
50
57
|
|
|
51
58
|
/**
|
|
52
59
|
* Converts a HashTypeLike value to its corresponding byte representation.
|
|
60
|
+
* @public
|
|
53
61
|
*
|
|
54
62
|
* @param hashType - The hash type value to convert.
|
|
55
63
|
* @returns A Uint8Array containing the byte representation of the hash type.
|
|
@@ -66,6 +74,7 @@ export function hashTypeToBytes(hashType: HashTypeLike): Bytes {
|
|
|
66
74
|
|
|
67
75
|
/**
|
|
68
76
|
* Converts a byte-like value to a HashType.
|
|
77
|
+
* @public
|
|
69
78
|
*
|
|
70
79
|
* @param bytes - The byte-like value to convert.
|
|
71
80
|
* @returns The corresponding HashType.
|
|
@@ -82,11 +91,17 @@ export function hashTypeFromBytes(bytes: BytesLike): HashType {
|
|
|
82
91
|
return NUM_TO_HASH_TYPE[bytesFrom(bytes)[0]];
|
|
83
92
|
}
|
|
84
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
85
97
|
export type ScriptLike = {
|
|
86
98
|
codeHash: BytesLike;
|
|
87
99
|
hashType: HashTypeLike;
|
|
88
100
|
args: BytesLike;
|
|
89
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
90
105
|
export class Script {
|
|
91
106
|
/**
|
|
92
107
|
* Creates an instance of Script.
|
package/src/ckb/transaction.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TransactionSkeletonType } from "@ckb-lumos/helpers";
|
|
2
1
|
import { ClientCollectableSearchKeyFilterLike } from "../advancedBarrel.js";
|
|
3
2
|
import { Bytes, BytesLike, bytesFrom } from "../bytes/index.js";
|
|
4
3
|
import { CellDepInfoLike, Client, KnownScript } from "../client/index.js";
|
|
@@ -22,12 +21,20 @@ import { apply, reduceAsync } from "../utils/index.js";
|
|
|
22
21
|
import * as mol from "./molecule.advanced/index.js";
|
|
23
22
|
import { Script, ScriptLike } from "./script.js";
|
|
24
23
|
import { DEP_TYPE_TO_NUM, NUM_TO_DEP_TYPE } from "./transaction.advanced.js";
|
|
24
|
+
import { LumosTransactionSkeletonType } from "./transactionLumos.js";
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
26
29
|
export type DepTypeLike = string | number | bigint;
|
|
30
|
+
/**
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
27
33
|
export type DepType = "depGroup" | "code";
|
|
28
34
|
|
|
29
35
|
/**
|
|
30
36
|
* Converts a DepTypeLike value to a DepType.
|
|
37
|
+
* @public
|
|
31
38
|
*
|
|
32
39
|
* @param val - The value to convert, which can be a string, number, or bigint.
|
|
33
40
|
* @returns The corresponding DepType.
|
|
@@ -61,6 +68,7 @@ export function depTypeFrom(val: DepTypeLike): DepType {
|
|
|
61
68
|
|
|
62
69
|
/**
|
|
63
70
|
* Converts a DepTypeLike value to its corresponding byte representation.
|
|
71
|
+
* @public
|
|
64
72
|
*
|
|
65
73
|
* @param depType - The dep type value to convert.
|
|
66
74
|
* @returns A Uint8Array containing the byte representation of the dep type.
|
|
@@ -77,6 +85,7 @@ export function depTypeToBytes(depType: DepTypeLike): Bytes {
|
|
|
77
85
|
|
|
78
86
|
/**
|
|
79
87
|
* Converts a byte-like value to a DepType.
|
|
88
|
+
* @public
|
|
80
89
|
*
|
|
81
90
|
* @param bytes - The byte-like value to convert.
|
|
82
91
|
* @returns The corresponding DepType.
|
|
@@ -93,10 +102,16 @@ export function depTypeFromBytes(bytes: BytesLike): DepType {
|
|
|
93
102
|
return NUM_TO_DEP_TYPE[bytesFrom(bytes)[0]];
|
|
94
103
|
}
|
|
95
104
|
|
|
105
|
+
/**
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
96
108
|
export type OutPointLike = {
|
|
97
109
|
txHash: HexLike;
|
|
98
110
|
index: NumLike;
|
|
99
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
100
115
|
export class OutPoint {
|
|
101
116
|
/**
|
|
102
117
|
* Creates an instance of OutPoint.
|
|
@@ -211,11 +226,17 @@ export class OutPoint {
|
|
|
211
226
|
}
|
|
212
227
|
}
|
|
213
228
|
|
|
229
|
+
/**
|
|
230
|
+
* @public
|
|
231
|
+
*/
|
|
214
232
|
export type CellOutputLike = {
|
|
215
233
|
capacity: NumLike;
|
|
216
234
|
lock: ScriptLike;
|
|
217
235
|
type?: ScriptLike | null;
|
|
218
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
219
240
|
export class CellOutput {
|
|
220
241
|
/**
|
|
221
242
|
* Creates an instance of CellOutput.
|
|
@@ -331,11 +352,17 @@ export class CellOutput {
|
|
|
331
352
|
}
|
|
332
353
|
}
|
|
333
354
|
|
|
355
|
+
/**
|
|
356
|
+
* @public
|
|
357
|
+
*/
|
|
334
358
|
export type CellLike = {
|
|
335
359
|
outPoint: OutPointLike;
|
|
336
360
|
cellOutput: CellOutputLike;
|
|
337
361
|
outputData: HexLike;
|
|
338
362
|
};
|
|
363
|
+
/**
|
|
364
|
+
* @public
|
|
365
|
+
*/
|
|
339
366
|
export class Cell {
|
|
340
367
|
/**
|
|
341
368
|
* Creates an instance of Cell.
|
|
@@ -389,12 +416,18 @@ export class Cell {
|
|
|
389
416
|
}
|
|
390
417
|
}
|
|
391
418
|
|
|
419
|
+
/**
|
|
420
|
+
* @public
|
|
421
|
+
*/
|
|
392
422
|
export type CellInputLike = {
|
|
393
423
|
previousOutput: OutPointLike;
|
|
394
424
|
since?: NumLike | null;
|
|
395
425
|
cellOutput?: CellOutputLike | null;
|
|
396
426
|
outputData?: HexLike | null;
|
|
397
427
|
};
|
|
428
|
+
/**
|
|
429
|
+
* @public
|
|
430
|
+
*/
|
|
398
431
|
export class CellInput {
|
|
399
432
|
/**
|
|
400
433
|
* Creates an instance of CellInput.
|
|
@@ -535,10 +568,16 @@ export class CellInput {
|
|
|
535
568
|
}
|
|
536
569
|
}
|
|
537
570
|
|
|
571
|
+
/**
|
|
572
|
+
* @public
|
|
573
|
+
*/
|
|
538
574
|
export type CellDepLike = {
|
|
539
575
|
outPoint: OutPointLike;
|
|
540
576
|
depType: DepTypeLike;
|
|
541
577
|
};
|
|
578
|
+
/**
|
|
579
|
+
* @public
|
|
580
|
+
*/
|
|
542
581
|
export class CellDep {
|
|
543
582
|
/**
|
|
544
583
|
* Creates an instance of CellDep.
|
|
@@ -662,11 +701,17 @@ export class CellDep {
|
|
|
662
701
|
}
|
|
663
702
|
}
|
|
664
703
|
|
|
704
|
+
/**
|
|
705
|
+
* @public
|
|
706
|
+
*/
|
|
665
707
|
export type WitnessArgsLike = {
|
|
666
708
|
lock?: HexLike | null;
|
|
667
709
|
inputType?: HexLike | null;
|
|
668
710
|
outputType?: HexLike | null;
|
|
669
711
|
};
|
|
712
|
+
/**
|
|
713
|
+
* @public
|
|
714
|
+
*/
|
|
670
715
|
export class WitnessArgs {
|
|
671
716
|
/**
|
|
672
717
|
* Creates an instance of WitnessArgs.
|
|
@@ -765,6 +810,9 @@ export class WitnessArgs {
|
|
|
765
810
|
}
|
|
766
811
|
}
|
|
767
812
|
|
|
813
|
+
/**
|
|
814
|
+
* @public
|
|
815
|
+
*/
|
|
768
816
|
export function udtBalanceFrom(dataLike: BytesLike): Num {
|
|
769
817
|
const data = bytesFrom(dataLike).slice(0, 16);
|
|
770
818
|
if (data.length !== 16) {
|
|
@@ -774,6 +822,9 @@ export function udtBalanceFrom(dataLike: BytesLike): Num {
|
|
|
774
822
|
return numFromBytes(data);
|
|
775
823
|
}
|
|
776
824
|
|
|
825
|
+
/**
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
777
828
|
export type TransactionLike = {
|
|
778
829
|
version?: NumLike | null;
|
|
779
830
|
cellDeps?: CellDepLike[] | null;
|
|
@@ -786,6 +837,9 @@ export type TransactionLike = {
|
|
|
786
837
|
outputsData?: HexLike[] | null;
|
|
787
838
|
witnesses?: HexLike[] | null;
|
|
788
839
|
};
|
|
840
|
+
/**
|
|
841
|
+
* @public
|
|
842
|
+
*/
|
|
789
843
|
export class Transaction {
|
|
790
844
|
/**
|
|
791
845
|
* Creates an instance of Transaction.
|
|
@@ -936,7 +990,9 @@ export class Transaction {
|
|
|
936
990
|
* ```
|
|
937
991
|
*/
|
|
938
992
|
|
|
939
|
-
static fromLumosSkeleton(
|
|
993
|
+
static fromLumosSkeleton(
|
|
994
|
+
skeleton: LumosTransactionSkeletonType,
|
|
995
|
+
): Transaction {
|
|
940
996
|
return Transaction.from({
|
|
941
997
|
version: 0n,
|
|
942
998
|
cellDeps: skeleton.cellDeps.toArray(),
|
|
@@ -1124,10 +1180,10 @@ export class Transaction {
|
|
|
1124
1180
|
* ```
|
|
1125
1181
|
*/
|
|
1126
1182
|
async findInputIndexByLockId(
|
|
1127
|
-
|
|
1183
|
+
scriptIdLike: Pick<ScriptLike, "codeHash" | "hashType">,
|
|
1128
1184
|
client: Client,
|
|
1129
1185
|
): Promise<number | undefined> {
|
|
1130
|
-
const script = Script.from({ ...
|
|
1186
|
+
const script = Script.from({ ...scriptIdLike, args: "0x" });
|
|
1131
1187
|
|
|
1132
1188
|
for (let i = 0; i < this.inputs.length; i += 1) {
|
|
1133
1189
|
const input = this.inputs[i];
|
|
@@ -1217,8 +1273,8 @@ export class Transaction {
|
|
|
1217
1273
|
* tx.addCellDeps(cellDep);
|
|
1218
1274
|
* ```
|
|
1219
1275
|
*/
|
|
1220
|
-
addCellDeps(...
|
|
1221
|
-
|
|
1276
|
+
addCellDeps(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void {
|
|
1277
|
+
cellDepLikes.flat().forEach((cellDepLike) => {
|
|
1222
1278
|
const cellDep = CellDep.from(cellDepLike);
|
|
1223
1279
|
if (this.cellDeps.some((c) => c.eq(cellDep))) {
|
|
1224
1280
|
return;
|
|
@@ -1238,8 +1294,8 @@ export class Transaction {
|
|
|
1238
1294
|
* tx.addCellDepsAtBegin(cellDep);
|
|
1239
1295
|
* ```
|
|
1240
1296
|
*/
|
|
1241
|
-
addCellDepsAtStart(...
|
|
1242
|
-
|
|
1297
|
+
addCellDepsAtStart(...cellDepLikes: (CellDepLike | CellDepLike[])[]): void {
|
|
1298
|
+
cellDepLikes.flat().forEach((cellDepLike) => {
|
|
1243
1299
|
const cellDep = CellDep.from(cellDepLike);
|
|
1244
1300
|
if (this.cellDeps.some((c) => c.eq(cellDep))) {
|
|
1245
1301
|
return;
|
|
@@ -1253,7 +1309,7 @@ export class Transaction {
|
|
|
1253
1309
|
* Add cell dep from infos if they are not existed
|
|
1254
1310
|
*
|
|
1255
1311
|
* @param client - A client for searching cell deps
|
|
1256
|
-
* @param
|
|
1312
|
+
* @param cellDepInfoLikes - The cell dep infos to add
|
|
1257
1313
|
*
|
|
1258
1314
|
* @example
|
|
1259
1315
|
* ```typescript
|
|
@@ -1262,9 +1318,9 @@ export class Transaction {
|
|
|
1262
1318
|
*/
|
|
1263
1319
|
async addCellDepInfos(
|
|
1264
1320
|
client: Client,
|
|
1265
|
-
...
|
|
1321
|
+
...cellDepInfoLikes: (CellDepInfoLike | CellDepInfoLike[])[]
|
|
1266
1322
|
): Promise<void> {
|
|
1267
|
-
this.addCellDeps(await client.getCellDeps(...
|
|
1323
|
+
this.addCellDeps(await client.getCellDeps(...cellDepInfoLikes));
|
|
1268
1324
|
}
|
|
1269
1325
|
|
|
1270
1326
|
/**
|
|
@@ -1302,10 +1358,10 @@ export class Transaction {
|
|
|
1302
1358
|
*
|
|
1303
1359
|
* @example
|
|
1304
1360
|
* ```typescript
|
|
1305
|
-
* await tx.
|
|
1361
|
+
* await tx.setOutputDataAt(0, "0x00");
|
|
1306
1362
|
* ```
|
|
1307
1363
|
*/
|
|
1308
|
-
setOutputDataAt(index: number,
|
|
1364
|
+
setOutputDataAt(index: number, witness: HexLike): void {
|
|
1309
1365
|
if (this.outputsData.length < index) {
|
|
1310
1366
|
this.outputsData.push(
|
|
1311
1367
|
...Array.from(
|
|
@@ -1315,14 +1371,14 @@ export class Transaction {
|
|
|
1315
1371
|
);
|
|
1316
1372
|
}
|
|
1317
1373
|
|
|
1318
|
-
this.outputsData[index] = hexFrom(
|
|
1374
|
+
this.outputsData[index] = hexFrom(witness);
|
|
1319
1375
|
}
|
|
1320
1376
|
|
|
1321
1377
|
/**
|
|
1322
1378
|
* Add output
|
|
1323
1379
|
*
|
|
1324
|
-
* @param
|
|
1325
|
-
* @param
|
|
1380
|
+
* @param outputLike - The cell output to add
|
|
1381
|
+
* @param outputData - optional output data
|
|
1326
1382
|
*
|
|
1327
1383
|
* @example
|
|
1328
1384
|
* ```typescript
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CellDepLike, CellOutputLike, HexLike, OutPointLike } from "../barrel";
|
|
2
|
+
|
|
3
|
+
export interface LumosTransactionSkeletonType {
|
|
4
|
+
cellDeps: {
|
|
5
|
+
toArray(): CellDepLike[];
|
|
6
|
+
};
|
|
7
|
+
headerDeps: {
|
|
8
|
+
toArray(): HexLike[];
|
|
9
|
+
};
|
|
10
|
+
inputs: {
|
|
11
|
+
toArray(): {
|
|
12
|
+
outPoint?: OutPointLike;
|
|
13
|
+
cellOutput: CellOutputLike;
|
|
14
|
+
data: HexLike;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
inputSinces: {
|
|
18
|
+
get(i: number, defaultVal: string): HexLike;
|
|
19
|
+
};
|
|
20
|
+
outputs: {
|
|
21
|
+
toArray(): { cellOutput: CellOutputLike; data: HexLike }[];
|
|
22
|
+
};
|
|
23
|
+
witnesses: {
|
|
24
|
+
toArray(): HexLike[];
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/client/client.ts
CHANGED
|
@@ -28,6 +28,9 @@ import {
|
|
|
28
28
|
OutputsValidator,
|
|
29
29
|
} from "./clientTypes.js";
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
31
34
|
export enum KnownScript {
|
|
32
35
|
Secp256k1Blake160 = "Secp256k1Blake160",
|
|
33
36
|
Secp256k1Multisig = "Secp256k1Multisig",
|
|
@@ -44,11 +47,17 @@ export enum KnownScript {
|
|
|
44
47
|
OutputTypeProxyLock = "OutputTypeProxyLock",
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
47
53
|
export type CellDepInfoLike = {
|
|
48
54
|
cellDep: CellDepLike;
|
|
49
55
|
type?: ScriptLike | null;
|
|
50
56
|
};
|
|
51
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
52
61
|
export class CellDepInfo {
|
|
53
62
|
constructor(
|
|
54
63
|
public cellDep: CellDep,
|
|
@@ -63,6 +72,9 @@ export class CellDepInfo {
|
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
66
78
|
export abstract class Client {
|
|
67
79
|
private readonly cachedTransactions: Transaction[] = [];
|
|
68
80
|
private readonly unusableOutPoints: OutPoint[] = [];
|
|
@@ -190,7 +202,7 @@ export abstract class Client {
|
|
|
190
202
|
/**
|
|
191
203
|
* Find cells by search key designed for collectable cells.
|
|
192
204
|
*
|
|
193
|
-
* @param
|
|
205
|
+
* @param keyLike - The search key.
|
|
194
206
|
* @returns A async generator for yielding cells.
|
|
195
207
|
*/
|
|
196
208
|
async *findCellsByCollectableSearchKey(
|
|
@@ -3,6 +3,9 @@ import { CellDepInfo, KnownScript } from "./client.js";
|
|
|
3
3
|
import { MAINNET_SCRIPTS } from "./clientPublicMainnet.advanced.js";
|
|
4
4
|
import { ClientJsonRpc } from "./jsonRpc/index.js";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
6
9
|
export class ClientPublicMainnet extends ClientJsonRpc {
|
|
7
10
|
constructor(
|
|
8
11
|
url = "https://mainnet.ckb.dev/",
|
|
@@ -3,6 +3,9 @@ import { CellDepInfo, KnownScript } from "./client.js";
|
|
|
3
3
|
import { TESTNET_SCRIPTS } from "./clientPublicTestnet.advanced.js";
|
|
4
4
|
import { ClientJsonRpc } from "./jsonRpc/index.js";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
6
9
|
export class ClientPublicTestnet extends ClientJsonRpc {
|
|
7
10
|
constructor(
|
|
8
11
|
url = "https://testnet.ckb.dev/",
|