@ckb-ccc/core 0.0.2-alpha.0 → 0.0.2-alpha.1
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/dist/address/address.advanced.d.ts +5 -0
- package/dist/address/address.advanced.d.ts.map +1 -0
- package/dist/address/address.advanced.js +68 -0
- package/dist/address/advanced.d.ts +7 -9
- package/dist/address/advanced.d.ts.map +1 -1
- package/dist/address/advanced.js +50 -38
- package/dist/address/index.d.ts +20 -5
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +43 -32
- package/dist/advanced.d.ts +3 -0
- package/dist/advanced.d.ts.map +1 -0
- package/dist/{types/index.js → advanced.js} +3 -9
- package/dist/advancedBarrel.d.ts +4 -0
- package/dist/advancedBarrel.d.ts.map +1 -0
- package/dist/advancedBarrel.js +19 -0
- package/dist/barrel.d.ts +3 -2
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +3 -2
- package/dist/bytes.d.ts +15 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +114 -0
- package/dist/ckb/advanced.d.ts +3 -0
- package/dist/ckb/advanced.d.ts.map +1 -0
- package/dist/ckb/advanced.js +18 -0
- package/dist/ckb/hasher.advanced.d.ts +2 -0
- package/dist/ckb/hasher.advanced.d.ts.map +1 -0
- package/dist/ckb/hasher.advanced.js +4 -0
- package/dist/ckb/hasher.d.ts +10 -0
- package/dist/ckb/hasher.d.ts.map +1 -0
- package/dist/ckb/hasher.js +26 -0
- package/dist/ckb/index.d.ts +3 -1
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +3 -1
- package/dist/ckb/types/advanced.d.ts +4 -0
- package/dist/ckb/types/advanced.d.ts.map +1 -0
- package/dist/ckb/types/advanced.js +32 -0
- package/dist/ckb/types/index.d.ts +3 -0
- package/dist/ckb/types/index.d.ts.map +1 -0
- package/dist/{codec → ckb/types}/index.js +1 -2
- package/dist/ckb/types/molecule.advanced/generated.d.ts +355 -0
- package/dist/ckb/types/molecule.advanced/generated.d.ts.map +1 -0
- package/dist/ckb/types/molecule.advanced/generated.js +1255 -0
- package/dist/ckb/types/molecule.advanced/index.d.ts +2 -0
- package/dist/ckb/types/molecule.advanced/index.d.ts.map +1 -0
- package/dist/ckb/types/molecule.advanced/index.js +17 -0
- package/dist/ckb/types/script.advanced.d.ts +4 -0
- package/dist/ckb/types/script.advanced.d.ts.map +1 -0
- package/dist/{types/ckb.advanced.js → ckb/types/script.advanced.js} +3 -3
- package/dist/ckb/types/script.d.ts +26 -0
- package/dist/ckb/types/script.d.ts.map +1 -0
- package/dist/ckb/types/script.js +75 -0
- package/dist/ckb/types/transaction.advanced.d.ts +4 -0
- package/dist/ckb/types/transaction.advanced.d.ts.map +1 -0
- package/dist/ckb/types/transaction.advanced.js +11 -0
- package/dist/ckb/types/transaction.d.ts +127 -0
- package/dist/ckb/types/transaction.d.ts.map +1 -0
- package/dist/ckb/types/transaction.js +266 -0
- package/dist/ckb/viewerCkbScript.d.ts +11 -0
- package/dist/ckb/viewerCkbScript.d.ts.map +1 -0
- package/dist/ckb/viewerCkbScript.js +18 -0
- package/dist/client/advanced.d.ts +3 -0
- package/dist/client/advanced.d.ts.map +1 -0
- package/dist/client/advanced.js +18 -0
- package/dist/client/client.d.ts +7 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +1 -4
- package/dist/client/clientPublicMainnet.advanced.d.ts +1 -1
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.d.ts +5 -3
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +6 -3
- package/dist/client/clientPublicTestnet.advanced.d.ts +1 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.d.ts +5 -3
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +6 -3
- package/dist/client/clientTypes.d.ts +2 -0
- package/dist/client/clientTypes.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -19
- package/dist/client/jsonRpc/advanced.d.ts +88 -0
- package/dist/client/jsonRpc/advanced.d.ts.map +1 -0
- package/dist/client/jsonRpc/advanced.js +69 -0
- package/dist/client/jsonRpc/index.d.ts +14 -0
- package/dist/client/jsonRpc/index.d.ts.map +1 -0
- package/dist/client/jsonRpc/index.js +63 -0
- package/dist/fixedPoint.d.ts +9 -0
- package/dist/fixedPoint.d.ts.map +1 -0
- package/dist/fixedPoint.js +30 -0
- package/dist/primitive.d.ts +5 -0
- package/dist/primitive.d.ts.map +1 -0
- package/dist/signer/helpers.d.ts +7 -0
- package/dist/signer/helpers.d.ts.map +1 -0
- package/dist/signer/helpers.js +35 -0
- package/dist/signer/index.d.ts +3 -0
- package/dist/signer/index.d.ts.map +1 -0
- package/dist/signer/index.js +18 -0
- package/dist/signer/signer.d.ts +11 -0
- package/dist/signer/signer.d.ts.map +1 -0
- package/dist/signer/signer.js +13 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/viewer.d.ts +8 -5
- package/dist/viewer.d.ts.map +1 -1
- package/dist/viewer.js +13 -0
- package/package.json +13 -5
- package/src/address/address.advanced.ts +88 -0
- package/src/address/advanced.ts +30 -45
- package/src/address/index.ts +70 -5
- package/src/advanced.ts +2 -0
- package/src/advancedBarrel.ts +3 -0
- package/src/barrel.ts +3 -2
- package/src/bytes.ts +127 -0
- package/src/ckb/advanced.ts +2 -0
- package/src/ckb/hasher.advanced.ts +1 -0
- package/src/ckb/hasher.ts +30 -0
- package/src/ckb/index.ts +3 -1
- package/src/ckb/types/advanced.ts +3 -0
- package/src/ckb/types/index.ts +2 -0
- package/src/ckb/types/molecule.advanced/blockchain.mol +118 -0
- package/src/ckb/types/molecule.advanced/generated.d.ts +433 -0
- package/src/ckb/types/molecule.advanced/generated.js +1376 -0
- package/src/ckb/types/molecule.advanced/index.ts +1 -0
- package/src/ckb/types/script.advanced.ts +14 -0
- package/src/ckb/types/script.ts +70 -0
- package/src/ckb/types/transaction.advanced.ts +10 -0
- package/src/ckb/types/transaction.ts +366 -0
- package/src/ckb/viewerCkbScript.ts +21 -0
- package/src/client/advanced.ts +2 -0
- package/src/client/client.ts +11 -4
- package/src/client/clientPublicMainnet.advanced.ts +1 -1
- package/src/client/clientPublicMainnet.ts +9 -4
- package/src/client/clientPublicTestnet.advanced.ts +1 -1
- package/src/client/clientPublicTestnet.ts +9 -4
- package/src/client/clientTypes.ts +1 -0
- package/src/client/index.ts +1 -7
- package/src/client/jsonRpc/advanced.ts +93 -0
- package/src/client/jsonRpc/index.ts +83 -0
- package/src/fixedPoint.ts +53 -0
- package/src/primitive.ts +8 -0
- package/src/signer/helpers.ts +43 -0
- package/src/signer/index.ts +2 -0
- package/src/signer/signer.ts +19 -0
- package/src/viewer.ts +16 -8
- package/dist/address/address.d.ts +0 -8
- package/dist/address/address.d.ts.map +0 -1
- package/dist/address/address.js +0 -6
- package/dist/address/addressKnownScript.d.ts +0 -13
- package/dist/address/addressKnownScript.d.ts.map +0 -1
- package/dist/address/addressKnownScript.js +0 -27
- package/dist/address/addressPlain.d.ts +0 -12
- package/dist/address/addressPlain.d.ts.map +0 -1
- package/dist/address/addressPlain.js +0 -23
- package/dist/address/converter.d.ts +0 -8
- package/dist/address/converter.d.ts.map +0 -1
- package/dist/address/converter.js +0 -65
- package/dist/bundle.d.ts +0 -9
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -25
- package/dist/ckb/viewerCkbAddress.d.ts +0 -14
- package/dist/ckb/viewerCkbAddress.d.ts.map +0 -1
- package/dist/ckb/viewerCkbAddress.js +0 -28
- package/dist/codec/bytes.d.ts +0 -4
- package/dist/codec/bytes.d.ts.map +0 -1
- package/dist/codec/bytes.js +0 -29
- package/dist/codec/hashType.d.ts +0 -4
- package/dist/codec/hashType.d.ts.map +0 -1
- package/dist/codec/hashType.js +0 -13
- package/dist/codec/index.d.ts +0 -4
- package/dist/codec/index.d.ts.map +0 -1
- package/dist/codec/script.d.ts +0 -4
- package/dist/codec/script.d.ts.map +0 -1
- package/dist/codec/script.js +0 -22
- package/dist/signer.d.ts +0 -9
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -12
- package/dist/types/cell.d.ts +0 -5
- package/dist/types/cell.d.ts.map +0 -1
- package/dist/types/cell.js +0 -8
- package/dist/types/ckb.advanced.d.ts +0 -4
- package/dist/types/ckb.advanced.d.ts.map +0 -1
- package/dist/types/ckb.d.ts +0 -16
- package/dist/types/ckb.d.ts.map +0 -1
- package/dist/types/ckb.js +0 -36
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/lumos.d.ts +0 -90
- package/dist/types/lumos.d.ts.map +0 -1
- package/dist/types/primitive.d.ts +0 -3
- package/dist/types/primitive.d.ts.map +0 -1
- package/src/address/address.ts +0 -9
- package/src/address/addressKnownScript.ts +0 -31
- package/src/address/addressPlain.ts +0 -27
- package/src/address/converter.ts +0 -93
- package/src/ckb/viewerCkbAddress.ts +0 -34
- package/src/codec/bytes.ts +0 -30
- package/src/codec/hashType.ts +0 -10
- package/src/codec/index.ts +0 -3
- package/src/codec/script.ts +0 -21
- package/src/signer.ts +0 -20
- package/src/types/cell.ts +0 -5
- package/src/types/ckb.advanced.ts +0 -14
- package/src/types/ckb.ts +0 -47
- package/src/types/index.ts +0 -9
- package/src/types/lumos.ts +0 -101
- package/src/types/primitive.ts +0 -2
- /package/dist/{types/lumos.js → client/clientTypes.js} +0 -0
- /package/dist/{types/primitive.js → primitive.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ckb/types/molecule.advanced/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,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("./generated"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.advanced.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/script.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAKrD,CAAC;AACF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAKrD,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.NUM_TO_HASH_TYPE = exports.HASH_TYPE_TO_NUM = void 0;
|
|
4
|
+
exports.HASH_TYPE_TO_NUM = {
|
|
5
5
|
type: 0x01,
|
|
6
6
|
data: 0x00,
|
|
7
7
|
data1: 0x02,
|
|
8
8
|
data2: 0x04,
|
|
9
9
|
};
|
|
10
|
-
exports.
|
|
10
|
+
exports.NUM_TO_HASH_TYPE = {
|
|
11
11
|
0x01: "type",
|
|
12
12
|
0x00: "data",
|
|
13
13
|
0x02: "data1",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeepReadonly } from "ts-essentials";
|
|
2
|
+
import { BytesLike, Hex } from "../../primitive";
|
|
3
|
+
import * as mol from "./molecule.advanced";
|
|
4
|
+
export type HashType = "type" | "data" | "data1" | "data2";
|
|
5
|
+
export declare function encodeHashType(hashType: HashType): Uint8Array;
|
|
6
|
+
export declare function decodeHashType(bytes: BytesLike): HashType;
|
|
7
|
+
export declare class Script {
|
|
8
|
+
codeHash: Hex;
|
|
9
|
+
hashType: HashType;
|
|
10
|
+
args: Hex;
|
|
11
|
+
constructor(codeHash: Hex, hashType: HashType, args: Hex);
|
|
12
|
+
static from({ codeHash, hashType, args, }: {
|
|
13
|
+
codeHash: BytesLike;
|
|
14
|
+
hashType: string;
|
|
15
|
+
args: BytesLike;
|
|
16
|
+
}): Script;
|
|
17
|
+
static _toMolData(script: DeepReadonly<Script>): {
|
|
18
|
+
codeHash: Uint8Array;
|
|
19
|
+
hashType: Uint8Array;
|
|
20
|
+
args: Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
static encode(script: DeepReadonly<Script>): Uint8Array;
|
|
23
|
+
static decode(bytes: BytesLike | mol.Script): Script;
|
|
24
|
+
static eq(a: Script, b: Script): boolean;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAE7D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,CAEzD;AAED,qBAAa,MAAM;IAER,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,GAAG;gBAFT,QAAQ,EAAE,GAAG,EACb,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,GAAG;IAGlB,MAAM,CAAC,IAAI,CAAC,EACV,QAAQ,EACR,QAAQ,EACR,IAAI,GACL,EAAE;QACD,QAAQ,EAAE,SAAS,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,SAAS,CAAC;KACjB,GAAG,MAAM;IAQV,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC;;;;;IAQ9C,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,UAAU;IAIvD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM;IAWpD,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;CAOzC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Script = exports.decodeHashType = exports.encodeHashType = void 0;
|
|
27
|
+
const bytes_1 = require("../../bytes");
|
|
28
|
+
const script_advanced_1 = require("./script.advanced");
|
|
29
|
+
const mol = __importStar(require("./molecule.advanced"));
|
|
30
|
+
function encodeHashType(hashType) {
|
|
31
|
+
return (0, bytes_1.toBytes)([script_advanced_1.HASH_TYPE_TO_NUM[hashType]]);
|
|
32
|
+
}
|
|
33
|
+
exports.encodeHashType = encodeHashType;
|
|
34
|
+
function decodeHashType(bytes) {
|
|
35
|
+
return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.toBytes)(bytes)[0]];
|
|
36
|
+
}
|
|
37
|
+
exports.decodeHashType = decodeHashType;
|
|
38
|
+
class Script {
|
|
39
|
+
constructor(codeHash, hashType, args) {
|
|
40
|
+
this.codeHash = codeHash;
|
|
41
|
+
this.hashType = hashType;
|
|
42
|
+
this.args = args;
|
|
43
|
+
}
|
|
44
|
+
static from({ codeHash, hashType, args, }) {
|
|
45
|
+
return {
|
|
46
|
+
codeHash: (0, bytes_1.toHex)(codeHash),
|
|
47
|
+
hashType: hashType,
|
|
48
|
+
args: (0, bytes_1.toHex)(args),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static _toMolData(script) {
|
|
52
|
+
return {
|
|
53
|
+
codeHash: (0, bytes_1.toBytes)(script.codeHash),
|
|
54
|
+
hashType: encodeHashType(script.hashType),
|
|
55
|
+
args: (0, bytes_1.toBytes)(script.args),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
static encode(script) {
|
|
59
|
+
return (0, bytes_1.toBytes)(mol.SerializeScript(Script._toMolData(script)));
|
|
60
|
+
}
|
|
61
|
+
static decode(bytes) {
|
|
62
|
+
const view = bytes instanceof mol.Script ? bytes : new mol.Script((0, bytes_1.toBytes)(bytes));
|
|
63
|
+
return {
|
|
64
|
+
codeHash: (0, bytes_1.toHex)(view.getCodeHash().raw()),
|
|
65
|
+
hashType: decodeHashType([view.getHashType()]),
|
|
66
|
+
args: (0, bytes_1.toHex)(view.getArgs().raw()),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static eq(a, b) {
|
|
70
|
+
return (a.codeHash === b.codeHash &&
|
|
71
|
+
a.args === b.args &&
|
|
72
|
+
a.hashType === b.hashType);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Script = Script;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.advanced.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/transaction.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAGnD,CAAC;AACF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAGnD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NUM_TO_DEP_TYPE = exports.DEP_TYPE_TO_NUM = void 0;
|
|
4
|
+
exports.DEP_TYPE_TO_NUM = {
|
|
5
|
+
code: 0x00,
|
|
6
|
+
depGroup: 0x01,
|
|
7
|
+
};
|
|
8
|
+
exports.NUM_TO_DEP_TYPE = {
|
|
9
|
+
0x00: "code",
|
|
10
|
+
0x01: "depGroup",
|
|
11
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Script } from "./script";
|
|
2
|
+
import { BytesLike, Hex, NumberLike } from "../../primitive";
|
|
3
|
+
import type { TransactionSkeletonType } from "@ckb-lumos/helpers";
|
|
4
|
+
import { DeepReadonly } from "ts-essentials";
|
|
5
|
+
import * as mol from "./molecule.advanced";
|
|
6
|
+
import { Hasher } from "../hasher";
|
|
7
|
+
export type DepType = "depGroup" | "code";
|
|
8
|
+
export declare function encodeDepType(depType: DepType): Uint8Array;
|
|
9
|
+
export declare function decodeDepType(bytes: BytesLike): DepType;
|
|
10
|
+
export declare class OutPoint {
|
|
11
|
+
txHash: Hex;
|
|
12
|
+
index: string;
|
|
13
|
+
constructor(txHash: Hex, index: string);
|
|
14
|
+
static from({ txHash, index, }: {
|
|
15
|
+
txHash: BytesLike;
|
|
16
|
+
index: NumberLike;
|
|
17
|
+
}): OutPoint;
|
|
18
|
+
static _toMolData(outPoint: DeepReadonly<OutPoint>): {
|
|
19
|
+
txHash: Uint8Array;
|
|
20
|
+
index: Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
static encode(outPoint: DeepReadonly<OutPoint>): Uint8Array;
|
|
23
|
+
static decode(bytes: BytesLike | mol.OutPoint): OutPoint;
|
|
24
|
+
}
|
|
25
|
+
export declare class CellOutput {
|
|
26
|
+
capacity: string;
|
|
27
|
+
lock: Script;
|
|
28
|
+
type?: Script | undefined;
|
|
29
|
+
constructor(capacity: string, lock: Script, type?: Script | undefined);
|
|
30
|
+
static from({ capacity, lock, type, }: {
|
|
31
|
+
capacity: NumberLike;
|
|
32
|
+
lock: Parameters<typeof Script.from>[0];
|
|
33
|
+
type?: Parameters<typeof Script.from>[0];
|
|
34
|
+
}): CellOutput;
|
|
35
|
+
static _toMolData(cellOutput: DeepReadonly<CellOutput>): {
|
|
36
|
+
capacity: Uint8Array;
|
|
37
|
+
lock: {
|
|
38
|
+
codeHash: Uint8Array;
|
|
39
|
+
hashType: Uint8Array;
|
|
40
|
+
args: Uint8Array;
|
|
41
|
+
};
|
|
42
|
+
type: {
|
|
43
|
+
codeHash: Uint8Array;
|
|
44
|
+
hashType: Uint8Array;
|
|
45
|
+
args: Uint8Array;
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
static encode(cellOutput: DeepReadonly<CellOutput>): Uint8Array;
|
|
49
|
+
static decode(bytes: BytesLike | mol.CellOutput): CellOutput;
|
|
50
|
+
}
|
|
51
|
+
export declare class CellInput {
|
|
52
|
+
previousOutput: OutPoint;
|
|
53
|
+
since: string;
|
|
54
|
+
cellOutput?: CellOutput | undefined;
|
|
55
|
+
outputData?: `0x${string}` | undefined;
|
|
56
|
+
constructor(previousOutput: OutPoint, since: string, cellOutput?: CellOutput | undefined, outputData?: `0x${string}` | undefined);
|
|
57
|
+
static from({ previousOutput, since, cellOutput, outputData, }: {
|
|
58
|
+
previousOutput: Parameters<typeof OutPoint.from>[0];
|
|
59
|
+
since: NumberLike;
|
|
60
|
+
cellOutput?: Parameters<typeof CellOutput.from>[0];
|
|
61
|
+
outputData?: BytesLike;
|
|
62
|
+
}): CellInput;
|
|
63
|
+
static _toMolData(cellInput: DeepReadonly<CellInput>): {
|
|
64
|
+
previousOutput: {
|
|
65
|
+
txHash: Uint8Array;
|
|
66
|
+
index: Uint8Array;
|
|
67
|
+
};
|
|
68
|
+
since: Uint8Array;
|
|
69
|
+
};
|
|
70
|
+
static encode(cellInput: DeepReadonly<CellInput>): Uint8Array;
|
|
71
|
+
static decode(bytes: BytesLike | mol.CellInput): CellInput;
|
|
72
|
+
}
|
|
73
|
+
export declare class CellDep {
|
|
74
|
+
outPoint: OutPoint;
|
|
75
|
+
depType: DepType;
|
|
76
|
+
constructor(outPoint: OutPoint, depType: DepType);
|
|
77
|
+
static from({ outPoint, depType, }: {
|
|
78
|
+
outPoint: Parameters<typeof OutPoint.from>[0];
|
|
79
|
+
depType: DepType;
|
|
80
|
+
}): CellDep;
|
|
81
|
+
static _toMolData(cellDep: DeepReadonly<CellDep>): {
|
|
82
|
+
outPoint: {
|
|
83
|
+
txHash: Uint8Array;
|
|
84
|
+
index: Uint8Array;
|
|
85
|
+
};
|
|
86
|
+
depType: Uint8Array;
|
|
87
|
+
};
|
|
88
|
+
static encode(cellDep: DeepReadonly<CellDep>): Uint8Array;
|
|
89
|
+
static decode(bytes: BytesLike | mol.CellDep): CellDep;
|
|
90
|
+
}
|
|
91
|
+
export declare class WitnessArgs {
|
|
92
|
+
lock?: `0x${string}` | undefined;
|
|
93
|
+
inputType?: `0x${string}` | undefined;
|
|
94
|
+
outputType?: `0x${string}` | undefined;
|
|
95
|
+
constructor(lock?: `0x${string}` | undefined, inputType?: `0x${string}` | undefined, outputType?: `0x${string}` | undefined);
|
|
96
|
+
static from({ lock, inputType, outputType, }: {
|
|
97
|
+
lock?: BytesLike;
|
|
98
|
+
inputType?: BytesLike;
|
|
99
|
+
outputType?: BytesLike;
|
|
100
|
+
}): WitnessArgs;
|
|
101
|
+
static _toMolData(witnessArgs: DeepReadonly<WitnessArgs>): {
|
|
102
|
+
lock: Uint8Array | undefined;
|
|
103
|
+
inputType: Uint8Array | undefined;
|
|
104
|
+
outputType: Uint8Array | undefined;
|
|
105
|
+
};
|
|
106
|
+
static encode(witnessArgs: DeepReadonly<WitnessArgs>): Uint8Array;
|
|
107
|
+
static decode(bytes: BytesLike | mol.WitnessArgs): WitnessArgs;
|
|
108
|
+
}
|
|
109
|
+
export declare class Transaction {
|
|
110
|
+
version: string;
|
|
111
|
+
cellDeps: CellDep[];
|
|
112
|
+
headerDeps: Hex[];
|
|
113
|
+
inputs: CellInput[];
|
|
114
|
+
outputs: CellOutput[];
|
|
115
|
+
outputsData: Hex[];
|
|
116
|
+
witnesses: Hex[];
|
|
117
|
+
constructor(version: string, cellDeps: CellDep[], headerDeps: Hex[], inputs: CellInput[], outputs: CellOutput[], outputsData: Hex[], witnesses: Hex[]);
|
|
118
|
+
static default(): Transaction;
|
|
119
|
+
private static fromLumosOutPoint;
|
|
120
|
+
private static fromLumosScript;
|
|
121
|
+
private static fromLumosOutput;
|
|
122
|
+
static fromLumosSkeleton(skeleton: TransactionSkeletonType): Transaction;
|
|
123
|
+
static encodeRaw(transaction: Readonly<Omit<Transaction, "witnesses">>): Uint8Array;
|
|
124
|
+
static hashRaw(transaction: Omit<Transaction, "witnesses">): `0x${string}`;
|
|
125
|
+
static hashWitnessToHasher(witness: Hex, hasher: Hasher): void;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,UAAU,CAAC;AAU5C,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAW,MAAM,WAAW,CAAC;AAG5C,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAE1C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAE1D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEvD;AAED,qBAAa,QAAQ;IAEV,MAAM,EAAE,GAAG;IACX,KAAK,E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,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,WAAW;IAgCxE,MAAM,CAAC,SAAS,CACd,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,GACpD,UAAU;IAab,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAI1D,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM;CAKxD"}
|
|
@@ -0,0 +1,266 @@
|
|
|
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 __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Transaction = exports.WitnessArgs = exports.CellDep = exports.CellInput = exports.CellOutput = exports.OutPoint = exports.decodeDepType = exports.encodeDepType = void 0;
|
|
27
|
+
const script_1 = require("./script");
|
|
28
|
+
const bytes_1 = require("../../bytes");
|
|
29
|
+
const mol = __importStar(require("./molecule.advanced"));
|
|
30
|
+
const transaction_advanced_1 = require("./transaction.advanced");
|
|
31
|
+
const hasher_1 = require("../hasher");
|
|
32
|
+
function encodeDepType(depType) {
|
|
33
|
+
return (0, bytes_1.toBytes)([transaction_advanced_1.DEP_TYPE_TO_NUM[depType]]);
|
|
34
|
+
}
|
|
35
|
+
exports.encodeDepType = encodeDepType;
|
|
36
|
+
function decodeDepType(bytes) {
|
|
37
|
+
return transaction_advanced_1.NUM_TO_DEP_TYPE[(0, bytes_1.toBytes)(bytes)[0]];
|
|
38
|
+
}
|
|
39
|
+
exports.decodeDepType = decodeDepType;
|
|
40
|
+
class OutPoint {
|
|
41
|
+
constructor(txHash, index) {
|
|
42
|
+
this.txHash = txHash;
|
|
43
|
+
this.index = index;
|
|
44
|
+
}
|
|
45
|
+
static from({ txHash, index, }) {
|
|
46
|
+
return new OutPoint((0, bytes_1.toHex)(txHash), (0, bytes_1.toNumber)(index));
|
|
47
|
+
}
|
|
48
|
+
static _toMolData(outPoint) {
|
|
49
|
+
return {
|
|
50
|
+
txHash: (0, bytes_1.toBytes)(outPoint.txHash),
|
|
51
|
+
index: (0, bytes_1.toBytesFromNumber)(outPoint.index, 4),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
static encode(outPoint) {
|
|
55
|
+
return (0, bytes_1.toBytes)(mol.SerializeOutPoint(OutPoint._toMolData(outPoint)));
|
|
56
|
+
}
|
|
57
|
+
static decode(bytes) {
|
|
58
|
+
const view = bytes instanceof mol.OutPoint ? bytes : new mol.OutPoint((0, bytes_1.toBytes)(bytes));
|
|
59
|
+
return {
|
|
60
|
+
txHash: (0, bytes_1.toHex)(view.getTxHash().raw()),
|
|
61
|
+
index: (0, bytes_1.toNumberFromBytes)(view.getIndex().raw()),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.OutPoint = OutPoint;
|
|
66
|
+
class CellOutput {
|
|
67
|
+
constructor(capacity, lock, type) {
|
|
68
|
+
this.capacity = capacity;
|
|
69
|
+
this.lock = lock;
|
|
70
|
+
this.type = type;
|
|
71
|
+
}
|
|
72
|
+
static from({ capacity, lock, type, }) {
|
|
73
|
+
return new CellOutput((0, bytes_1.toNumber)(capacity), script_1.Script.from(lock), type ? script_1.Script.from(type) : undefined);
|
|
74
|
+
}
|
|
75
|
+
static _toMolData(cellOutput) {
|
|
76
|
+
return {
|
|
77
|
+
capacity: (0, bytes_1.toBytesFromNumber)(cellOutput.capacity, 8),
|
|
78
|
+
lock: script_1.Script._toMolData(cellOutput.lock),
|
|
79
|
+
type: cellOutput.type ? script_1.Script._toMolData(cellOutput.type) : undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static encode(cellOutput) {
|
|
83
|
+
return (0, bytes_1.toBytes)(mol.SerializeCellOutput(CellOutput._toMolData(cellOutput)));
|
|
84
|
+
}
|
|
85
|
+
static decode(bytes) {
|
|
86
|
+
const view = bytes instanceof mol.CellOutput
|
|
87
|
+
? bytes
|
|
88
|
+
: new mol.CellOutput((0, bytes_1.toBytes)(bytes));
|
|
89
|
+
const type = view.getType();
|
|
90
|
+
return {
|
|
91
|
+
capacity: (0, bytes_1.toNumberFromBytes)(view.getCapacity().raw()),
|
|
92
|
+
lock: script_1.Script.decode(view.getLock()),
|
|
93
|
+
type: type.hasValue() ? script_1.Script.decode(type.value()) : undefined,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.CellOutput = CellOutput;
|
|
98
|
+
class CellInput {
|
|
99
|
+
constructor(previousOutput, since, cellOutput, outputData) {
|
|
100
|
+
this.previousOutput = previousOutput;
|
|
101
|
+
this.since = since;
|
|
102
|
+
this.cellOutput = cellOutput;
|
|
103
|
+
this.outputData = outputData;
|
|
104
|
+
}
|
|
105
|
+
static from({ previousOutput, since, cellOutput, outputData, }) {
|
|
106
|
+
return new CellInput(OutPoint.from(previousOutput), (0, bytes_1.toNumber)(since), cellOutput ? CellOutput.from(cellOutput) : undefined, outputData ? (0, bytes_1.toHex)(outputData) : undefined);
|
|
107
|
+
}
|
|
108
|
+
static _toMolData(cellInput) {
|
|
109
|
+
return {
|
|
110
|
+
previousOutput: OutPoint._toMolData(cellInput.previousOutput),
|
|
111
|
+
since: (0, bytes_1.toBytesFromNumber)(cellInput.since, 8),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
static encode(cellInput) {
|
|
115
|
+
return (0, bytes_1.toBytes)(mol.SerializeCellInput(CellInput._toMolData(cellInput)));
|
|
116
|
+
}
|
|
117
|
+
static decode(bytes) {
|
|
118
|
+
const view = bytes instanceof mol.CellInput
|
|
119
|
+
? bytes
|
|
120
|
+
: new mol.CellInput((0, bytes_1.toBytes)(bytes));
|
|
121
|
+
return {
|
|
122
|
+
previousOutput: OutPoint.decode(view.getPreviousOutput()),
|
|
123
|
+
since: (0, bytes_1.toNumberFromBytes)(view.getSince().raw()),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.CellInput = CellInput;
|
|
128
|
+
class CellDep {
|
|
129
|
+
constructor(outPoint, depType) {
|
|
130
|
+
this.outPoint = outPoint;
|
|
131
|
+
this.depType = depType;
|
|
132
|
+
}
|
|
133
|
+
static from({ outPoint, depType, }) {
|
|
134
|
+
return new CellDep(OutPoint.from(outPoint), depType);
|
|
135
|
+
}
|
|
136
|
+
static _toMolData(cellDep) {
|
|
137
|
+
return {
|
|
138
|
+
outPoint: OutPoint._toMolData(cellDep.outPoint),
|
|
139
|
+
depType: encodeDepType(cellDep.depType),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
static encode(cellDep) {
|
|
143
|
+
return (0, bytes_1.toBytes)(mol.SerializeCellDep(CellDep._toMolData(cellDep)));
|
|
144
|
+
}
|
|
145
|
+
static decode(bytes) {
|
|
146
|
+
const view = bytes instanceof mol.CellDep ? bytes : new mol.CellDep((0, bytes_1.toBytes)(bytes));
|
|
147
|
+
return {
|
|
148
|
+
outPoint: OutPoint.decode(view.getOutPoint()),
|
|
149
|
+
depType: decodeDepType([view.getDepType()]),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.CellDep = CellDep;
|
|
154
|
+
class WitnessArgs {
|
|
155
|
+
constructor(lock, inputType, outputType) {
|
|
156
|
+
this.lock = lock;
|
|
157
|
+
this.inputType = inputType;
|
|
158
|
+
this.outputType = outputType;
|
|
159
|
+
}
|
|
160
|
+
static from({ lock, inputType, outputType, }) {
|
|
161
|
+
return new WitnessArgs(lock ? (0, bytes_1.toHex)(lock) : undefined, inputType ? (0, bytes_1.toHex)(inputType) : undefined, outputType ? (0, bytes_1.toHex)(outputType) : undefined);
|
|
162
|
+
}
|
|
163
|
+
static _toMolData(witnessArgs) {
|
|
164
|
+
return {
|
|
165
|
+
lock: witnessArgs.lock ? (0, bytes_1.toBytes)(witnessArgs.lock) : undefined,
|
|
166
|
+
inputType: witnessArgs.inputType
|
|
167
|
+
? (0, bytes_1.toBytes)(witnessArgs.inputType)
|
|
168
|
+
: undefined,
|
|
169
|
+
outputType: witnessArgs.outputType
|
|
170
|
+
? (0, bytes_1.toBytes)(witnessArgs.outputType)
|
|
171
|
+
: undefined,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
static encode(witnessArgs) {
|
|
175
|
+
return (0, bytes_1.toBytes)(mol.SerializeWitnessArgs(WitnessArgs._toMolData(witnessArgs)));
|
|
176
|
+
}
|
|
177
|
+
static decode(bytes) {
|
|
178
|
+
const view = bytes instanceof mol.WitnessArgs
|
|
179
|
+
? bytes
|
|
180
|
+
: new mol.WitnessArgs((0, bytes_1.toBytes)(bytes));
|
|
181
|
+
const lock = view.getLock();
|
|
182
|
+
const inputType = view.getInputType();
|
|
183
|
+
const outputType = view.getOutputType();
|
|
184
|
+
return {
|
|
185
|
+
lock: lock.hasValue() ? (0, bytes_1.toHex)(lock.value().raw()) : undefined,
|
|
186
|
+
inputType: inputType.hasValue()
|
|
187
|
+
? (0, bytes_1.toHex)(inputType.value().raw())
|
|
188
|
+
: undefined,
|
|
189
|
+
outputType: outputType.hasValue()
|
|
190
|
+
? (0, bytes_1.toHex)(outputType.value().raw())
|
|
191
|
+
: undefined,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.WitnessArgs = WitnessArgs;
|
|
196
|
+
class Transaction {
|
|
197
|
+
constructor(version, cellDeps, headerDeps, inputs, outputs, outputsData, witnesses) {
|
|
198
|
+
this.version = version;
|
|
199
|
+
this.cellDeps = cellDeps;
|
|
200
|
+
this.headerDeps = headerDeps;
|
|
201
|
+
this.inputs = inputs;
|
|
202
|
+
this.outputs = outputs;
|
|
203
|
+
this.outputsData = outputsData;
|
|
204
|
+
this.witnesses = witnesses;
|
|
205
|
+
}
|
|
206
|
+
static default() {
|
|
207
|
+
return new Transaction("0", [], [], [], [], [], []);
|
|
208
|
+
}
|
|
209
|
+
static fromLumosOutPoint(outPoint) {
|
|
210
|
+
return {
|
|
211
|
+
...outPoint,
|
|
212
|
+
txHash: (0, bytes_1.toHexFromHex)(outPoint.txHash),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
static fromLumosScript(script) {
|
|
216
|
+
return {
|
|
217
|
+
codeHash: (0, bytes_1.toHexFromHex)(script.codeHash),
|
|
218
|
+
args: (0, bytes_1.toHexFromHex)(script.args),
|
|
219
|
+
hashType: script.hashType,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
static fromLumosOutput(output) {
|
|
223
|
+
return {
|
|
224
|
+
lock: Transaction.fromLumosScript(output.lock),
|
|
225
|
+
type: output.type ? Transaction.fromLumosScript(output.type) : undefined,
|
|
226
|
+
capacity: (0, bytes_1.toNumber)(output.capacity),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
static fromLumosSkeleton(skeleton) {
|
|
230
|
+
return new Transaction("0", skeleton.cellDeps.toArray().map((cellDep) => CellDep.from({
|
|
231
|
+
...cellDep,
|
|
232
|
+
outPoint: Transaction.fromLumosOutPoint(cellDep.outPoint),
|
|
233
|
+
})), skeleton.headerDeps.toArray().map(bytes_1.toHex), skeleton.inputs.toArray().map((input, i) => {
|
|
234
|
+
if (!input.outPoint) {
|
|
235
|
+
throw new Error("outPoint is required in input");
|
|
236
|
+
}
|
|
237
|
+
return CellInput.from({
|
|
238
|
+
previousOutput: Transaction.fromLumosOutPoint(input.outPoint),
|
|
239
|
+
since: skeleton.inputSinces.get(i, "0x00"),
|
|
240
|
+
cellOutput: Transaction.fromLumosOutput(input.cellOutput),
|
|
241
|
+
outputData: (0, bytes_1.toHexFromHex)(input.data),
|
|
242
|
+
});
|
|
243
|
+
}), skeleton.outputs
|
|
244
|
+
.toArray()
|
|
245
|
+
.map((output) => CellOutput.from(Transaction.fromLumosOutput(output.cellOutput))), skeleton.outputs.toArray().map((output) => (0, bytes_1.toHex)(output.data)), skeleton.witnesses.toArray().map(bytes_1.toHex));
|
|
246
|
+
}
|
|
247
|
+
static encodeRaw(transaction) {
|
|
248
|
+
return (0, bytes_1.toBytes)(mol.SerializeRawTransaction({
|
|
249
|
+
version: (0, bytes_1.toBytesFromNumber)(transaction.version, 4),
|
|
250
|
+
cellDeps: transaction.cellDeps.map(CellDep._toMolData),
|
|
251
|
+
headerDeps: transaction.headerDeps.map(bytes_1.toBytes),
|
|
252
|
+
inputs: transaction.inputs.map(CellInput._toMolData),
|
|
253
|
+
outputs: transaction.outputs.map(CellOutput._toMolData),
|
|
254
|
+
outputsData: transaction.outputsData.map(bytes_1.toBytes),
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
static hashRaw(transaction) {
|
|
258
|
+
return (0, hasher_1.ckbHash)(Transaction.encodeRaw(transaction));
|
|
259
|
+
}
|
|
260
|
+
static hashWitnessToHasher(witness, hasher) {
|
|
261
|
+
const raw = (0, bytes_1.toBytes)(witness);
|
|
262
|
+
hasher.update((0, bytes_1.toBytesFromNumber)(raw.length, 8));
|
|
263
|
+
hasher.update(raw);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.Transaction = Transaction;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client } from "../client";
|
|
2
|
+
import { Script } from "./types";
|
|
3
|
+
import { Viewer } from "../viewer";
|
|
4
|
+
import { Address } from "../address";
|
|
5
|
+
export declare class ViewerCkbScript extends Viewer {
|
|
6
|
+
private readonly script;
|
|
7
|
+
constructor(script: Script, client: Client);
|
|
8
|
+
getInternalAddress(): Promise<string>;
|
|
9
|
+
getAddressObjs(): Promise<Address[]>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=viewerCkbScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerCkbScript.d.ts","sourceRoot":"","sources":["../../src/ckb/viewerCkbScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,qBAAa,eAAgB,SAAQ,MAAM;IAEvC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM,EAC/B,MAAM,EAAE,MAAM;IAKV,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewerCkbScript = void 0;
|
|
4
|
+
const viewer_1 = require("../viewer");
|
|
5
|
+
const address_1 = require("../address");
|
|
6
|
+
class ViewerCkbScript extends viewer_1.Viewer {
|
|
7
|
+
constructor(script, client) {
|
|
8
|
+
super(client);
|
|
9
|
+
this.script = script;
|
|
10
|
+
}
|
|
11
|
+
async getInternalAddress() {
|
|
12
|
+
return this.getRecommendedAddress();
|
|
13
|
+
}
|
|
14
|
+
async getAddressObjs() {
|
|
15
|
+
return [await address_1.Address.fromScript(this.script, this.client)];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ViewerCkbScript = ViewerCkbScript;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/client/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,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("./clientPublicMainnet.advanced"), exports);
|
|
18
|
+
__exportStar(require("./clientPublicTestnet.advanced"), exports);
|