@ckb-ccc/core 0.0.2-alpha.2 → 0.0.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.
- package/.prettierignore +12 -0
- package/dist/address/address.advanced.d.ts +29 -3
- package/dist/address/address.advanced.d.ts.map +1 -1
- package/dist/address/address.advanced.js +70 -28
- package/dist/address/advanced.d.ts +1 -28
- package/dist/address/advanced.d.ts.map +1 -1
- package/dist/address/advanced.js +1 -75
- package/dist/address/index.d.ts +10 -13
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +21 -25
- package/dist/advanced.js +2 -31
- package/dist/advancedBarrel.d.ts +1 -0
- package/dist/advancedBarrel.d.ts.map +1 -1
- package/dist/advancedBarrel.js +4 -19
- package/dist/barrel.d.ts +4 -2
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +10 -24
- package/dist/bytes/index.d.ts +7 -0
- package/dist/bytes/index.d.ts.map +1 -0
- package/dist/bytes/index.js +34 -0
- package/dist/ckb/advanced.d.ts +3 -2
- package/dist/ckb/advanced.d.ts.map +1 -1
- package/dist/ckb/advanced.js +3 -18
- package/dist/ckb/index.d.ts +2 -3
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +2 -19
- package/dist/ckb/molecule.advanced/generated.d.ts.map +1 -0
- package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +444 -231
- package/dist/ckb/molecule.advanced/index.d.ts +6 -0
- package/dist/ckb/molecule.advanced/index.d.ts.map +1 -0
- package/dist/ckb/molecule.advanced/index.js +7 -0
- package/dist/ckb/{types/script.advanced.d.ts → script.advanced.d.ts} +1 -0
- package/dist/ckb/script.advanced.d.ts.map +1 -0
- package/dist/ckb/script.advanced.js +13 -0
- package/dist/ckb/script.d.ts +29 -0
- package/dist/ckb/script.d.ts.map +1 -0
- package/dist/ckb/script.js +61 -0
- package/dist/ckb/{types/transaction.advanced.d.ts → transaction.advanced.d.ts} +1 -0
- package/dist/ckb/transaction.advanced.d.ts.map +1 -0
- package/dist/ckb/transaction.advanced.js +9 -0
- package/dist/ckb/transaction.d.ts +142 -0
- package/dist/ckb/transaction.d.ts.map +1 -0
- package/dist/ckb/transaction.js +227 -0
- package/dist/client/advanced.js +2 -18
- package/dist/client/client.d.ts +5 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +2 -5
- package/dist/client/clientPublicMainnet.advanced.d.ts +2 -2
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +7 -10
- package/dist/client/clientPublicMainnet.d.ts +2 -2
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +4 -8
- package/dist/client/clientPublicTestnet.advanced.d.ts +2 -2
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +7 -10
- package/dist/client/clientPublicTestnet.d.ts +2 -2
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +4 -8
- package/dist/client/clientTypes.js +1 -2
- package/dist/client/index.js +4 -20
- package/dist/client/jsonRpc/advanced.d.ts +36 -36
- package/dist/client/jsonRpc/advanced.d.ts.map +1 -1
- package/dist/client/jsonRpc/advanced.js +13 -17
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +5 -13
- package/dist/fixedPoint/index.d.ts +7 -0
- package/dist/fixedPoint/index.d.ts.map +1 -0
- package/dist/fixedPoint/index.js +22 -0
- package/dist/{ckb/hasher.advanced.d.ts → hasher/advanced.d.ts} +1 -1
- package/dist/hasher/advanced.d.ts.map +1 -0
- package/dist/{ckb/hasher.d.ts → hasher/index.d.ts} +3 -2
- package/dist/hasher/index.d.ts.map +1 -0
- package/dist/hasher/index.js +18 -0
- package/dist/hex/index.d.ts +5 -0
- package/dist/hex/index.d.ts.map +1 -0
- package/dist/hex/index.js +5 -0
- package/dist/index.js +2 -31
- package/dist/num/index.d.ts +13 -0
- package/dist/num/index.d.ts.map +1 -0
- package/dist/num/index.js +36 -0
- package/dist/signer/helpers.d.ts +3 -3
- package/dist/signer/helpers.d.ts.map +1 -1
- package/dist/signer/helpers.js +9 -10
- package/dist/signer/index.d.ts +2 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +4 -18
- package/dist/signer/signer.d.ts +12 -3
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +13 -6
- package/dist/signer/signerReadonly.d.ts +8 -0
- package/dist/signer/signerReadonly.d.ts.map +1 -0
- package/dist/signer/signerReadonly.js +9 -0
- package/dist/{ckb/viewerCkbScript.d.ts → signer/signerReadonlyCkbScript.d.ts} +6 -5
- package/dist/signer/signerReadonlyCkbScript.d.ts.map +1 -0
- package/dist/signer/signerReadonlyCkbScript.js +17 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/package.json +5 -3
- package/src/address/address.advanced.ts +76 -19
- package/src/address/advanced.ts +1 -59
- package/src/address/index.ts +46 -28
- package/src/advancedBarrel.ts +1 -0
- package/src/barrel.ts +4 -2
- package/src/bytes/index.ts +46 -0
- package/src/ckb/advanced.ts +3 -2
- package/src/ckb/index.ts +2 -3
- package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +18 -7
- package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +551 -123
- package/src/ckb/molecule.advanced/index.ts +11 -0
- package/src/ckb/{types/script.advanced.ts → script.advanced.ts} +1 -0
- package/src/ckb/script.ts +94 -0
- package/src/ckb/{types/transaction.advanced.ts → transaction.advanced.ts} +1 -0
- package/src/ckb/transaction.ts +357 -0
- package/src/client/client.ts +6 -4
- package/src/client/clientPublicMainnet.advanced.ts +2 -2
- package/src/client/clientPublicMainnet.ts +2 -2
- package/src/client/clientPublicTestnet.advanced.ts +2 -2
- package/src/client/clientPublicTestnet.ts +2 -2
- package/src/client/clientTypes.ts +1 -1
- package/src/client/jsonRpc/advanced.ts +25 -25
- package/src/client/jsonRpc/index.ts +1 -3
- package/src/fixedPoint/index.ts +30 -0
- package/src/hasher/advanced.ts +1 -0
- package/src/{ckb/hasher.ts → hasher/index.ts} +5 -5
- package/src/hex/index.ts +9 -0
- package/src/index.ts +1 -1
- package/src/num/index.ts +53 -0
- package/src/signer/helpers.ts +9 -6
- package/src/signer/index.ts +3 -1
- package/src/signer/signer.ts +23 -3
- package/src/signer/signerReadonly.ts +13 -0
- package/src/{ckb/viewerCkbScript.ts → signer/signerReadonlyCkbScript.ts} +8 -4
- package/src/utils/index.ts +28 -0
- package/dist/bytes.d.ts +0 -15
- package/dist/bytes.d.ts.map +0 -1
- package/dist/bytes.js +0 -114
- package/dist/ckb/hasher.advanced.d.ts.map +0 -1
- package/dist/ckb/hasher.advanced.js +0 -4
- package/dist/ckb/hasher.d.ts.map +0 -1
- package/dist/ckb/hasher.js +0 -26
- package/dist/ckb/types/advanced.d.ts +0 -4
- package/dist/ckb/types/advanced.d.ts.map +0 -1
- package/dist/ckb/types/advanced.js +0 -32
- package/dist/ckb/types/index.d.ts +0 -3
- package/dist/ckb/types/index.d.ts.map +0 -1
- package/dist/ckb/types/index.js +0 -18
- package/dist/ckb/types/molecule.advanced/generated.d.ts.map +0 -1
- package/dist/ckb/types/molecule.advanced/index.d.ts +0 -2
- package/dist/ckb/types/molecule.advanced/index.d.ts.map +0 -1
- package/dist/ckb/types/molecule.advanced/index.js +0 -17
- package/dist/ckb/types/script.advanced.d.ts.map +0 -1
- package/dist/ckb/types/script.advanced.js +0 -15
- package/dist/ckb/types/script.d.ts +0 -26
- package/dist/ckb/types/script.d.ts.map +0 -1
- package/dist/ckb/types/script.js +0 -75
- package/dist/ckb/types/transaction.advanced.d.ts.map +0 -1
- package/dist/ckb/types/transaction.advanced.js +0 -11
- package/dist/ckb/types/transaction.d.ts +0 -127
- package/dist/ckb/types/transaction.d.ts.map +0 -1
- package/dist/ckb/types/transaction.js +0 -266
- package/dist/ckb/viewerCkbScript.d.ts.map +0 -1
- package/dist/ckb/viewerCkbScript.js +0 -18
- package/dist/fixedPoint.d.ts +0 -9
- package/dist/fixedPoint.d.ts.map +0 -1
- package/dist/fixedPoint.js +0 -30
- package/dist/primitive.d.ts +0 -5
- package/dist/primitive.d.ts.map +0 -1
- package/dist/primitive.js +0 -2
- package/dist/viewer.d.ts +0 -12
- package/dist/viewer.d.ts.map +0 -1
- package/dist/viewer.js +0 -19
- package/src/bytes.ts +0 -127
- package/src/ckb/types/advanced.ts +0 -3
- package/src/ckb/types/index.ts +0 -2
- package/src/ckb/types/molecule.advanced/index.ts +0 -1
- package/src/ckb/types/script.ts +0 -70
- package/src/ckb/types/transaction.ts +0 -366
- package/src/fixedPoint.ts +0 -53
- package/src/primitive.ts +0 -8
- package/src/viewer.ts +0 -22
- /package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +0 -0
- /package/{src/ckb/hasher.advanced.ts → dist/hasher/advanced.js} +0 -0
- /package/src/ckb/{types/molecule.advanced → molecule.advanced}/blockchain.mol +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,CAAC,EAAE,MAAM;IAItB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;CAG7E"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const clientPublicMainnet_advanced_1 = require("./clientPublicMainnet.advanced");
|
|
5
|
-
const jsonRpc_1 = require("./jsonRpc");
|
|
6
|
-
class ClientPublicMainnet extends jsonRpc_1.ClientJsonRpc {
|
|
1
|
+
import { MAINNET_SCRIPTS } from "./clientPublicMainnet.advanced";
|
|
2
|
+
import { ClientJsonRpc } from "./jsonRpc";
|
|
3
|
+
export class ClientPublicMainnet extends ClientJsonRpc {
|
|
7
4
|
constructor(timeout) {
|
|
8
5
|
super("https://mainnet.ckbapp.dev/", timeout);
|
|
9
6
|
}
|
|
@@ -11,7 +8,6 @@ class ClientPublicMainnet extends jsonRpc_1.ClientJsonRpc {
|
|
|
11
8
|
return "ckb";
|
|
12
9
|
}
|
|
13
10
|
async getKnownScript(script) {
|
|
14
|
-
return { ...
|
|
11
|
+
return { ...MAINNET_SCRIPTS[script] };
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.ClientPublicMainnet = ClientPublicMainnet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScriptLike } from "../ckb";
|
|
2
2
|
import { KnownScript } from "./client";
|
|
3
|
-
export declare const TESTNET_SCRIPTS: Record<KnownScript, Omit<
|
|
3
|
+
export declare const TESTNET_SCRIPTS: Record<KnownScript, Omit<ScriptLike, "args">>;
|
|
4
4
|
//# sourceMappingURL=clientPublicTestnet.advanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CA0BzE,CAAC"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const client_1 = require("./client");
|
|
5
|
-
exports.TESTNET_SCRIPTS = {
|
|
6
|
-
[client_1.KnownScript.Secp256k1Blake160]: {
|
|
1
|
+
import { KnownScript } from "./client";
|
|
2
|
+
export const TESTNET_SCRIPTS = {
|
|
3
|
+
[KnownScript.Secp256k1Blake160]: {
|
|
7
4
|
codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
8
5
|
hashType: "type",
|
|
9
6
|
},
|
|
10
|
-
[
|
|
7
|
+
[KnownScript.Secp256k1Multisig]: {
|
|
11
8
|
codeHash: "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",
|
|
12
9
|
hashType: "type",
|
|
13
10
|
},
|
|
14
|
-
[
|
|
11
|
+
[KnownScript.AnyoneCanPay]: {
|
|
15
12
|
codeHash: "0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356",
|
|
16
13
|
hashType: "type",
|
|
17
14
|
},
|
|
18
|
-
[
|
|
15
|
+
[KnownScript.JoyId]: {
|
|
19
16
|
codeHash: "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac",
|
|
20
17
|
hashType: "type",
|
|
21
18
|
},
|
|
22
|
-
[
|
|
19
|
+
[KnownScript.OmniLock]: {
|
|
23
20
|
codeHash: "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
|
|
24
21
|
hashType: "type",
|
|
25
22
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScriptLike } from "../ckb";
|
|
2
2
|
import { KnownScript } from "./client";
|
|
3
3
|
import { ClientJsonRpc } from "./jsonRpc";
|
|
4
4
|
export declare class ClientPublicTestnet extends ClientJsonRpc {
|
|
5
5
|
constructor(timeout?: number);
|
|
6
6
|
getAddressPrefix(): Promise<string>;
|
|
7
|
-
getKnownScript(script: KnownScript): Promise<Omit<
|
|
7
|
+
getKnownScript(script: KnownScript): Promise<Omit<ScriptLike, "args">>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=clientPublicTestnet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,CAAC,EAAE,MAAM;IAItB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;CAG7E"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const clientPublicTestnet_advanced_1 = require("./clientPublicTestnet.advanced");
|
|
5
|
-
const jsonRpc_1 = require("./jsonRpc");
|
|
6
|
-
class ClientPublicTestnet extends jsonRpc_1.ClientJsonRpc {
|
|
1
|
+
import { TESTNET_SCRIPTS } from "./clientPublicTestnet.advanced";
|
|
2
|
+
import { ClientJsonRpc } from "./jsonRpc";
|
|
3
|
+
export class ClientPublicTestnet extends ClientJsonRpc {
|
|
7
4
|
constructor(timeout) {
|
|
8
5
|
super("https://testnet.ckbapp.dev/", timeout);
|
|
9
6
|
}
|
|
@@ -11,7 +8,6 @@ class ClientPublicTestnet extends jsonRpc_1.ClientJsonRpc {
|
|
|
11
8
|
return "ckt";
|
|
12
9
|
}
|
|
13
10
|
async getKnownScript(script) {
|
|
14
|
-
return { ...
|
|
11
|
+
return { ...TESTNET_SCRIPTS[script] };
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.ClientPublicTestnet = ClientPublicTestnet;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/client/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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("./client"), exports);
|
|
18
|
-
__exportStar(require("./clientPublicMainnet"), exports);
|
|
19
|
-
__exportStar(require("./clientPublicTestnet"), exports);
|
|
20
|
-
__exportStar(require("./clientTypes"), exports);
|
|
1
|
+
export * from "./client";
|
|
2
|
+
export * from "./clientPublicMainnet";
|
|
3
|
+
export * from "./clientPublicTestnet";
|
|
4
|
+
export * from "./clientTypes";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CellDepLike, CellInputLike, CellOutputLike, DepTypeLike, OutPointLike, ScriptLike, TransactionLike } from "../../ckb";
|
|
2
2
|
import type { Client } from "../client";
|
|
3
3
|
export type JsonRpcPayload = {
|
|
4
4
|
id: number;
|
|
@@ -13,75 +13,75 @@ export type JsonRpcMethod = {
|
|
|
13
13
|
outTransformer?: (_: any) => unknown;
|
|
14
14
|
};
|
|
15
15
|
export declare class JsonRpcTransformers {
|
|
16
|
-
static toDepType(depType:
|
|
17
|
-
static toScript(script
|
|
18
|
-
code_hash:
|
|
19
|
-
hash_type: import("../../ckb").
|
|
20
|
-
args:
|
|
21
|
-
}
|
|
22
|
-
static toOutPoint(outPoint:
|
|
16
|
+
static toDepType(depType: DepTypeLike): "code" | "dep_group";
|
|
17
|
+
static toScript(script: ScriptLike): {
|
|
18
|
+
code_hash: import("../..").BytesLike;
|
|
19
|
+
hash_type: import("../../ckb").HashTypeLike;
|
|
20
|
+
args: import("../..").BytesLike;
|
|
21
|
+
};
|
|
22
|
+
static toOutPoint(outPoint: OutPointLike): {
|
|
23
23
|
index: `0x${string}`;
|
|
24
|
-
tx_hash:
|
|
24
|
+
tx_hash: import("../..").BytesLike;
|
|
25
25
|
};
|
|
26
|
-
static toCellInput(cellInput:
|
|
26
|
+
static toCellInput(cellInput: CellInputLike): {
|
|
27
27
|
previous_output: {
|
|
28
28
|
index: `0x${string}`;
|
|
29
|
-
tx_hash:
|
|
29
|
+
tx_hash: import("../..").BytesLike;
|
|
30
30
|
};
|
|
31
31
|
since: `0x${string}`;
|
|
32
32
|
};
|
|
33
|
-
static toCellOutput(cellOutput:
|
|
33
|
+
static toCellOutput(cellOutput: CellOutputLike): {
|
|
34
34
|
capacity: `0x${string}`;
|
|
35
35
|
lock: {
|
|
36
|
-
code_hash:
|
|
37
|
-
hash_type: import("../../ckb").
|
|
38
|
-
args:
|
|
39
|
-
}
|
|
36
|
+
code_hash: import("../..").BytesLike;
|
|
37
|
+
hash_type: import("../../ckb").HashTypeLike;
|
|
38
|
+
args: import("../..").BytesLike;
|
|
39
|
+
};
|
|
40
40
|
type: {
|
|
41
|
-
code_hash:
|
|
42
|
-
hash_type: import("../../ckb").
|
|
43
|
-
args:
|
|
44
|
-
} |
|
|
41
|
+
code_hash: import("../..").BytesLike;
|
|
42
|
+
hash_type: import("../../ckb").HashTypeLike;
|
|
43
|
+
args: import("../..").BytesLike;
|
|
44
|
+
} | undefined;
|
|
45
45
|
};
|
|
46
|
-
static toCellDep(cellDep:
|
|
46
|
+
static toCellDep(cellDep: CellDepLike): {
|
|
47
47
|
out_point: {
|
|
48
48
|
index: `0x${string}`;
|
|
49
|
-
tx_hash:
|
|
49
|
+
tx_hash: import("../..").BytesLike;
|
|
50
50
|
};
|
|
51
51
|
dep_type: string;
|
|
52
52
|
};
|
|
53
|
-
static toTransaction(tx:
|
|
53
|
+
static toTransaction(tx: TransactionLike): {
|
|
54
54
|
version: `0x${string}`;
|
|
55
55
|
cell_deps: {
|
|
56
56
|
out_point: {
|
|
57
57
|
index: `0x${string}`;
|
|
58
|
-
tx_hash:
|
|
58
|
+
tx_hash: import("../..").BytesLike;
|
|
59
59
|
};
|
|
60
60
|
dep_type: string;
|
|
61
61
|
}[];
|
|
62
|
-
header_deps:
|
|
62
|
+
header_deps: import("../..").BytesLike[];
|
|
63
63
|
inputs: {
|
|
64
64
|
previous_output: {
|
|
65
65
|
index: `0x${string}`;
|
|
66
|
-
tx_hash:
|
|
66
|
+
tx_hash: import("../..").BytesLike;
|
|
67
67
|
};
|
|
68
68
|
since: `0x${string}`;
|
|
69
69
|
}[];
|
|
70
70
|
outputs: {
|
|
71
71
|
capacity: `0x${string}`;
|
|
72
72
|
lock: {
|
|
73
|
-
code_hash:
|
|
74
|
-
hash_type: import("../../ckb").
|
|
75
|
-
args:
|
|
76
|
-
}
|
|
73
|
+
code_hash: import("../..").BytesLike;
|
|
74
|
+
hash_type: import("../../ckb").HashTypeLike;
|
|
75
|
+
args: import("../..").BytesLike;
|
|
76
|
+
};
|
|
77
77
|
type: {
|
|
78
|
-
code_hash:
|
|
79
|
-
hash_type: import("../../ckb").
|
|
80
|
-
args:
|
|
81
|
-
} |
|
|
78
|
+
code_hash: import("../..").BytesLike;
|
|
79
|
+
hash_type: import("../../ckb").HashTypeLike;
|
|
80
|
+
args: import("../..").BytesLike;
|
|
81
|
+
} | undefined;
|
|
82
82
|
}[];
|
|
83
|
-
outputs_data:
|
|
84
|
-
witnesses:
|
|
83
|
+
outputs_data: import("../..").BytesLike[];
|
|
84
|
+
witnesses: import("../..").BytesLike[];
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
export declare const CkbRpcMethods: JsonRpcMethod[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EAEhB,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IAEtD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC;CACtC,CAAC;AAEF,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW;IAQrC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU;;;;;IAOlC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY;;;;IAMxC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,aAAa;;;;;;;IAM3C,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,cAAc;;;;;;;;;;;;;IAO9C,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW;;;;;;;IAMrC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWzC;AAED,eAAO,MAAM,aAAa,EAAE,aAAa,EAOxC,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class JsonRpcTransformers {
|
|
1
|
+
import { depTypeFrom, } from "../../ckb";
|
|
2
|
+
import { hexFrom } from "../../hex";
|
|
3
|
+
import { numToHex } from "../../num";
|
|
4
|
+
import { apply } from "../../utils";
|
|
5
|
+
export class JsonRpcTransformers {
|
|
6
6
|
static toDepType(depType) {
|
|
7
|
-
switch (depType) {
|
|
7
|
+
switch (depTypeFrom(depType)) {
|
|
8
8
|
case "code":
|
|
9
9
|
return "code";
|
|
10
10
|
case "depGroup":
|
|
@@ -12,9 +12,6 @@ class JsonRpcTransformers {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
static toScript(script) {
|
|
15
|
-
if (!script) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
15
|
return {
|
|
19
16
|
code_hash: script.codeHash,
|
|
20
17
|
hash_type: script.hashType,
|
|
@@ -23,21 +20,21 @@ class JsonRpcTransformers {
|
|
|
23
20
|
}
|
|
24
21
|
static toOutPoint(outPoint) {
|
|
25
22
|
return {
|
|
26
|
-
index: (
|
|
23
|
+
index: numToHex(outPoint.index),
|
|
27
24
|
tx_hash: outPoint.txHash,
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
static toCellInput(cellInput) {
|
|
31
28
|
return {
|
|
32
29
|
previous_output: JsonRpcTransformers.toOutPoint(cellInput.previousOutput),
|
|
33
|
-
since: (
|
|
30
|
+
since: numToHex(cellInput.since),
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
33
|
static toCellOutput(cellOutput) {
|
|
37
34
|
return {
|
|
38
|
-
capacity: (
|
|
35
|
+
capacity: numToHex(cellOutput.capacity),
|
|
39
36
|
lock: JsonRpcTransformers.toScript(cellOutput.lock),
|
|
40
|
-
type: JsonRpcTransformers.toScript
|
|
37
|
+
type: apply(JsonRpcTransformers.toScript, cellOutput.type),
|
|
41
38
|
};
|
|
42
39
|
}
|
|
43
40
|
static toCellDep(cellDep) {
|
|
@@ -48,7 +45,7 @@ class JsonRpcTransformers {
|
|
|
48
45
|
}
|
|
49
46
|
static toTransaction(tx) {
|
|
50
47
|
return {
|
|
51
|
-
version: (
|
|
48
|
+
version: numToHex(tx.version),
|
|
52
49
|
cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.toCellDep(c)),
|
|
53
50
|
header_deps: tx.headerDeps,
|
|
54
51
|
inputs: tx.inputs.map((i) => JsonRpcTransformers.toCellInput(i)),
|
|
@@ -58,12 +55,11 @@ class JsonRpcTransformers {
|
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
exports.CkbRpcMethods = [
|
|
58
|
+
export const CkbRpcMethods = [
|
|
63
59
|
{
|
|
64
60
|
method: "sendTransaction",
|
|
65
61
|
rpcMethod: "send_transaction",
|
|
66
62
|
inTransformers: [JsonRpcTransformers.toTransaction],
|
|
67
|
-
outTransformer:
|
|
63
|
+
outTransformer: hexFrom,
|
|
68
64
|
},
|
|
69
65
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAiB,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1E,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC;CAAG;AAYzE,8BAAsB,aAAc,YAAW,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAE1E,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,GAAG,EAAE,MAAM,EACX,OAAO,SAAQ;IAUlC,MAAM;IAIN,WAAW,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,EAAE,aAAa,YAChD,OAAO,EAAE;IAU3B,IAAI,CAAC,OAAO,EAAE,cAAc;IA4BlC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQpE"}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ClientJsonRpc = void 0;
|
|
7
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
-
const advanced_1 = require("./advanced");
|
|
1
|
+
import fetch from "cross-fetch";
|
|
2
|
+
import { CkbRpcMethods } from "./advanced";
|
|
9
3
|
async function transform(value, transformer) {
|
|
10
4
|
if (transformer) {
|
|
11
5
|
return transformer(value);
|
|
12
6
|
}
|
|
13
7
|
return value;
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
class ClientJsonRpc {
|
|
9
|
+
export class ClientJsonRpc {
|
|
17
10
|
constructor(url, timeout = 30000) {
|
|
18
11
|
this.url = url;
|
|
19
12
|
this.timeout = timeout;
|
|
20
|
-
|
|
13
|
+
CkbRpcMethods.map((method) => Object.defineProperty(this, method.method, {
|
|
21
14
|
value: this.buildSender(method),
|
|
22
15
|
enumerable: true,
|
|
23
16
|
}));
|
|
@@ -34,7 +27,7 @@ class ClientJsonRpc {
|
|
|
34
27
|
async send(payload) {
|
|
35
28
|
const aborter = new AbortController();
|
|
36
29
|
const abortTimer = setTimeout(() => aborter.abort(), this.timeout);
|
|
37
|
-
const raw = await (
|
|
30
|
+
const raw = await fetch(this.url, {
|
|
38
31
|
method: "POST",
|
|
39
32
|
headers: {
|
|
40
33
|
"content-type": "application/json",
|
|
@@ -61,4 +54,3 @@ class ClientJsonRpc {
|
|
|
61
54
|
};
|
|
62
55
|
}
|
|
63
56
|
}
|
|
64
|
-
exports.ClientJsonRpc = ClientJsonRpc;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type FixedPoint = bigint;
|
|
2
|
+
export type FixedPointLike = bigint | string | number;
|
|
3
|
+
export declare function fixedPointToString(val: FixedPoint, decimals?: number): string;
|
|
4
|
+
export declare function fixedPointFrom(val: FixedPointLike, decimals?: number): FixedPoint;
|
|
5
|
+
export declare const Zero = 0n;
|
|
6
|
+
export declare const One: bigint;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixedPoint/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,SAAI,GAAG,MAAM,CASxE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,SAAI,GAAG,UAAU,CAY5E;AAED,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,GAAG,QAAsB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function fixedPointToString(val, decimals = 8) {
|
|
2
|
+
const str = val.toString();
|
|
3
|
+
const l = str.length <= decimals ? "0" : str.slice(0, -decimals);
|
|
4
|
+
const r = str.slice(-decimals).padStart(decimals, "0").replace(/0*$/, "");
|
|
5
|
+
if (r === "") {
|
|
6
|
+
return l;
|
|
7
|
+
}
|
|
8
|
+
return `${l}.${r}`;
|
|
9
|
+
}
|
|
10
|
+
export function fixedPointFrom(val, decimals = 8) {
|
|
11
|
+
if (typeof val === "bigint") {
|
|
12
|
+
return val;
|
|
13
|
+
}
|
|
14
|
+
const [l, r] = val.toString().split(".");
|
|
15
|
+
const lVal = BigInt(l.padEnd(l.length + decimals, "0"));
|
|
16
|
+
if (r === undefined) {
|
|
17
|
+
return lVal;
|
|
18
|
+
}
|
|
19
|
+
return lVal + BigInt(r.slice(0, decimals).padEnd(decimals, "0"));
|
|
20
|
+
}
|
|
21
|
+
export const Zero = 0n;
|
|
22
|
+
export const One = fixedPointFrom("1");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const CKB_BLAKE2B_PERSONAL = "ckb-default-hash";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/hasher/advanced.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Blake2b } from "blake2b";
|
|
2
|
-
import { BytesLike
|
|
2
|
+
import { BytesLike } from "../bytes";
|
|
3
|
+
import { Hex } from "../hex";
|
|
3
4
|
export declare class Hasher {
|
|
4
5
|
hasher: Blake2b;
|
|
5
6
|
constructor(outLength?: number, personal?: string);
|
|
@@ -7,4 +8,4 @@ export declare class Hasher {
|
|
|
7
8
|
digest(): Hex;
|
|
8
9
|
}
|
|
9
10
|
export declare function ckbHash(data: BytesLike): Hex;
|
|
10
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAA4B,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAG7B,qBAAa,MAAM;IACjB,MAAM,EAAE,OAAO,CAAC;gBAEJ,SAAS,SAAK,EAAE,QAAQ,SAAuB;IAS3D,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM;IAK/B,MAAM,IAAI,GAAG;CAGd;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,GAAG,CAE5C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import blake2b from "blake2b";
|
|
2
|
+
import { bytesFrom, bytesFromUtf8 } from "../bytes";
|
|
3
|
+
import { CKB_BLAKE2B_PERSONAL } from "./advanced";
|
|
4
|
+
export class Hasher {
|
|
5
|
+
constructor(outLength = 32, personal = CKB_BLAKE2B_PERSONAL) {
|
|
6
|
+
this.hasher = blake2b(outLength, undefined, undefined, bytesFromUtf8(personal));
|
|
7
|
+
}
|
|
8
|
+
update(data) {
|
|
9
|
+
this.hasher.update(bytesFrom(data));
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
digest() {
|
|
13
|
+
return `0x${this.hasher.digest("hex")}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function ckbHash(data) {
|
|
17
|
+
return new Hasher().update(data).digest();
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hex/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC;AAEhC,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAEzC"}
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"));
|
|
1
|
+
export * from "./barrel";
|
|
2
|
+
export * as ccc from "./barrel";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Bytes, BytesLike } from "../bytes";
|
|
2
|
+
import { Hex, HexLike } from "../hex";
|
|
3
|
+
export type Num = bigint;
|
|
4
|
+
export type NumLike = string | number | bigint | HexLike;
|
|
5
|
+
export declare function numFrom(val: NumLike): Num;
|
|
6
|
+
export declare function numToHex(val: NumLike): Hex;
|
|
7
|
+
export declare function numToBytes(val: NumLike, bytes?: number): Bytes;
|
|
8
|
+
export declare function numLeToBytes(val: NumLike, bytes?: number): Bytes;
|
|
9
|
+
export declare function numBeToBytes(val: NumLike, bytes?: number): Bytes;
|
|
10
|
+
export declare function numFromBytes(val: BytesLike): Num;
|
|
11
|
+
export declare function numLeFromBytes(val: BytesLike): Num;
|
|
12
|
+
export declare function numBeFromBytes(val: BytesLike): Num;
|
|
13
|
+
//# 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,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AACzB,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzD,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAUzC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAE1C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAE9D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAEhE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAUhE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAEhD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAElD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,GAAG,CAElD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { bytesConcat, bytesFrom } from "../bytes";
|
|
2
|
+
import { hexFrom } from "../hex";
|
|
3
|
+
export function numFrom(val) {
|
|
4
|
+
if (typeof val === "bigint") {
|
|
5
|
+
return val;
|
|
6
|
+
}
|
|
7
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
8
|
+
return BigInt(val);
|
|
9
|
+
}
|
|
10
|
+
return BigInt(hexFrom(val));
|
|
11
|
+
}
|
|
12
|
+
export function numToHex(val) {
|
|
13
|
+
return `0x${numFrom(val).toString(16)}`;
|
|
14
|
+
}
|
|
15
|
+
export function numToBytes(val, bytes) {
|
|
16
|
+
return numLeToBytes(val, bytes);
|
|
17
|
+
}
|
|
18
|
+
export function numLeToBytes(val, bytes) {
|
|
19
|
+
return numBeToBytes(val, bytes).reverse();
|
|
20
|
+
}
|
|
21
|
+
export function numBeToBytes(val, bytes) {
|
|
22
|
+
const rawBytes = bytesFrom(numFrom(val).toString(16));
|
|
23
|
+
if (bytes == null) {
|
|
24
|
+
return rawBytes;
|
|
25
|
+
}
|
|
26
|
+
return bytesConcat(Array.from(Array(bytes - rawBytes.length), () => 0), rawBytes);
|
|
27
|
+
}
|
|
28
|
+
export function numFromBytes(val) {
|
|
29
|
+
return numLeFromBytes(val);
|
|
30
|
+
}
|
|
31
|
+
export function numLeFromBytes(val) {
|
|
32
|
+
return numBeFromBytes(bytesFrom(val).reverse());
|
|
33
|
+
}
|
|
34
|
+
export function numBeFromBytes(val) {
|
|
35
|
+
return numFrom(bytesFrom(val));
|
|
36
|
+
}
|
package/dist/signer/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Hex } from "../
|
|
3
|
-
export declare function getSignHashInfo(
|
|
1
|
+
import { ScriptLike, TransactionLike } from "../ckb";
|
|
2
|
+
import { Hex } from "../hex";
|
|
3
|
+
export declare function getSignHashInfo(txLike: TransactionLike, scriptLike: ScriptLike): Promise<{
|
|
4
4
|
message: Hex;
|
|
5
5
|
position: number;
|
|
6
6
|
} | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/signer/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/signer/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAe,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAsCzD"}
|