@ckb-ccc/core 0.0.2-alpha.2 → 0.0.2-alpha.3
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 +69 -22
- package/dist/address/advanced.d.ts +1 -28
- package/dist/address/advanced.d.ts.map +1 -1
- package/dist/address/advanced.js +3 -61
- package/dist/address/index.d.ts +10 -13
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +18 -18
- package/dist/advancedBarrel.d.ts +1 -0
- package/dist/advancedBarrel.d.ts.map +1 -1
- package/dist/advancedBarrel.js +1 -0
- package/dist/barrel.d.ts +4 -2
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +4 -2
- package/dist/bytes/index.d.ts +7 -0
- package/dist/bytes/index.d.ts.map +1 -0
- package/dist/bytes/index.js +41 -0
- package/dist/ckb/advanced.d.ts +3 -2
- package/dist/ckb/advanced.d.ts.map +1 -1
- package/dist/ckb/advanced.js +16 -2
- package/dist/ckb/index.d.ts +2 -3
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +2 -3
- package/dist/ckb/molecule.advanced/generated.d.ts.map +1 -0
- package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +378 -97
- package/dist/ckb/molecule.advanced/index.d.ts +6 -0
- package/dist/ckb/molecule.advanced/index.d.ts.map +1 -0
- package/dist/ckb/{types/molecule.advanced → molecule.advanced}/index.js +8 -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/{types/script.advanced.js → script.advanced.js} +2 -1
- package/dist/ckb/script.d.ts +29 -0
- package/dist/ckb/script.d.ts.map +1 -0
- package/dist/ckb/script.js +91 -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/{types/transaction.advanced.js → transaction.advanced.js} +2 -1
- package/dist/ckb/transaction.d.ts +142 -0
- package/dist/ckb/transaction.d.ts.map +1 -0
- package/dist/ckb/transaction.js +262 -0
- package/dist/client/client.d.ts +4 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.d.ts +2 -2
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.d.ts +2 -2
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts +2 -2
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.d.ts +2 -2
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- 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 +11 -11
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +0 -1
- package/dist/fixedPoint/index.d.ts +7 -0
- package/dist/fixedPoint/index.d.ts.map +1 -0
- package/dist/{fixedPoint.js → fixedPoint/index.js} +9 -12
- 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/{ckb/hasher.js → hasher/index.js} +4 -4
- package/dist/hex/index.d.ts +5 -0
- package/dist/hex/index.d.ts.map +1 -0
- package/dist/hex/index.js +9 -0
- package/dist/num/index.d.ts +13 -0
- package/dist/num/index.d.ts.map +1 -0
- package/dist/num/index.js +47 -0
- package/dist/signer/helpers.d.ts +3 -3
- package/dist/signer/helpers.d.ts.map +1 -1
- package/dist/signer/helpers.js +7 -4
- package/dist/signer/index.d.ts +2 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +2 -0
- package/dist/signer/signer.d.ts +12 -3
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +13 -2
- package/dist/signer/signerReadonly.d.ts +8 -0
- package/dist/signer/signerReadonly.d.ts.map +1 -0
- package/dist/signer/signerReadonly.js +13 -0
- package/dist/{ckb/viewerCkbScript.d.ts → signer/signerReadonlyCkbScript.d.ts} +6 -5
- package/dist/signer/signerReadonlyCkbScript.d.ts.map +1 -0
- package/dist/{ckb/viewerCkbScript.js → signer/signerReadonlyCkbScript.js} +7 -4
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -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 +4 -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/{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.d.ts.map +0 -1
- 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/script.advanced.d.ts.map +0 -1
- 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.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/fixedPoint.d.ts +0 -9
- package/dist/fixedPoint.d.ts.map +0 -1
- 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/dist/{ckb/hasher.advanced.js → hasher/advanced.js} +0 -0
- /package/src/ckb/{types/molecule.advanced → molecule.advanced}/blockchain.mol +0 -0
- /package/src/{ckb/hasher.advanced.ts → hasher/advanced.ts} +0 -0
|
@@ -1,127 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/ckb/types/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,UAAU,CAAC;AAS5C,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;AAE5C,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAE1C,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAE1D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AI7B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAUhC,OAAO,CAAC,MAAM,CAAC,eAAe;IAY9B,OAAO,CAAC,MAAM,CAAC,eAAe;IAY9B,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"}
|
|
@@ -1,266 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/fixedPoint.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function composeFixedPoint(val: undefined | null, decimals?: number): null;
|
|
2
|
-
export declare function composeFixedPoint(val: bigint, decimals?: number): string;
|
|
3
|
-
export declare function composeFixedPoint(val: bigint | undefined | null, decimals?: number): string | null;
|
|
4
|
-
export declare function parseFixedPoint(ori: undefined | null, decimals?: number): null;
|
|
5
|
-
export declare function parseFixedPoint(ori: string | number, decimals?: number): bigint;
|
|
6
|
-
export declare function parseFixedPoint(ori: string | number | undefined | null, decimals?: number): bigint | null;
|
|
7
|
-
export declare const Zero = 0n;
|
|
8
|
-
export declare const One: bigint;
|
|
9
|
-
//# sourceMappingURL=fixedPoint.d.ts.map
|
package/dist/fixedPoint.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fixedPoint.d.ts","sourceRoot":"","sources":["../src/fixedPoint.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,SAAS,GAAG,IAAI,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC;AACR,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AAC1E,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAAC;AAkBjB,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;AAChF,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAAC;AACV,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,EACvC,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAAC;AAiBjB,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,GAAG,QAAuB,CAAC"}
|
package/dist/primitive.d.ts
DELETED
package/dist/primitive.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive.d.ts","sourceRoot":"","sources":["../src/primitive.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,SAAS,GACjB,GAAG,GACH,UAAU,GACV,WAAW,GACX,MAAM,EAAE,CAAC;AACb,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
package/dist/primitive.js
DELETED
package/dist/viewer.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Address } from "./address";
|
|
2
|
-
import { Client } from "./client";
|
|
3
|
-
export declare abstract class Viewer {
|
|
4
|
-
readonly client: Client;
|
|
5
|
-
constructor(client: Client);
|
|
6
|
-
abstract getInternalAddress(): Promise<string>;
|
|
7
|
-
abstract getAddressObjs(): Promise<Address[]>;
|
|
8
|
-
getRecommendedAddressObj(_preference?: unknown): Promise<Address>;
|
|
9
|
-
getRecommendedAddress(preference?: unknown): Promise<string>;
|
|
10
|
-
getAddresses(): Promise<string[]>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=viewer.d.ts.map
|
package/dist/viewer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,8BAAsB,MAAM;aACE,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;IAE1C,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAE9C,QAAQ,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IACvC,wBAAwB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjE,qBAAqB,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAG5D,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKxC"}
|
package/dist/viewer.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Viewer = void 0;
|
|
4
|
-
const address_1 = require("./address");
|
|
5
|
-
class Viewer {
|
|
6
|
-
constructor(client) {
|
|
7
|
-
this.client = client;
|
|
8
|
-
}
|
|
9
|
-
async getRecommendedAddressObj(_preference) {
|
|
10
|
-
return (await this.getAddressObjs())[0];
|
|
11
|
-
}
|
|
12
|
-
async getRecommendedAddress(preference) {
|
|
13
|
-
return address_1.Address.toString(await this.getRecommendedAddressObj(preference));
|
|
14
|
-
}
|
|
15
|
-
async getAddresses() {
|
|
16
|
-
return this.getAddressObjs().then((addresses) => addresses.map((address) => address_1.Address.toString(address)));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.Viewer = Viewer;
|
package/src/bytes.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { BytesLike, Hex, HexLike, NumberLike } from "./primitive";
|
|
2
|
-
import { Buffer } from "buffer/";
|
|
3
|
-
|
|
4
|
-
export function concatBytes(...args: BytesLike[]): Uint8Array {
|
|
5
|
-
return new Uint8Array(
|
|
6
|
-
args.reduce((acc: number[], v) => {
|
|
7
|
-
acc.push(...toBytes(v));
|
|
8
|
-
return acc;
|
|
9
|
-
}, []),
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function encodeUtf8(val: string): Uint8Array {
|
|
14
|
-
return Buffer.from(val, "utf-8");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function decodeUtf8(val: BytesLike): string {
|
|
18
|
-
return Buffer.from(toBytes(val)).toString("utf-8");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function toBytes(bytes: BytesLike): Uint8Array {
|
|
22
|
-
if (bytes instanceof Uint8Array) {
|
|
23
|
-
return bytes;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (bytes instanceof ArrayBuffer) {
|
|
27
|
-
return new Uint8Array(bytes);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (Array.isArray(bytes)) {
|
|
31
|
-
if (bytes.some((v) => v < 0 || 0xff < v)) {
|
|
32
|
-
throw new Error(`Invalid bytes ${JSON.stringify(bytes)}`);
|
|
33
|
-
}
|
|
34
|
-
return new Uint8Array(bytes);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const str = bytes.length % 2 === 0 ? bytes.slice(2) : `0${bytes.slice(2)}`;
|
|
38
|
-
const data = Buffer.from(str, "hex");
|
|
39
|
-
if (data.length * 2 !== str.length) {
|
|
40
|
-
throw new Error(`Invalid bytes ${bytes}`);
|
|
41
|
-
}
|
|
42
|
-
return data;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function toHexFromHex(bytes: HexLike): Hex {
|
|
46
|
-
if (typeof bytes === "string" && !bytes.startsWith("0x")) {
|
|
47
|
-
return `0x${bytes}`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return toHex(bytes);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function toHex(bytes: HexLike): Hex {
|
|
54
|
-
if (typeof bytes === "number") {
|
|
55
|
-
return `0x${bytes.toString(16)}`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (typeof bytes === "string" && !bytes.startsWith("0x")) {
|
|
59
|
-
return `0x${BigInt(bytes).toString(16)}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return `0x${Buffer.from(toBytes(bytes as BytesLike)).toString("hex")}`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function toNumber(val: NumberLike): string {
|
|
66
|
-
return BigInt(val).toString();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function toBytesFromNumber(val: NumberLike, bytes?: number): Uint8Array {
|
|
70
|
-
return toBytesFromLENumber(val, bytes);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function toBytesFromLENumber(
|
|
74
|
-
val: NumberLike,
|
|
75
|
-
bytes?: number,
|
|
76
|
-
): Uint8Array {
|
|
77
|
-
return toBytesFromBENumber(val, bytes).reverse();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function toBytesFromBENumber(
|
|
81
|
-
val: NumberLike,
|
|
82
|
-
bytes?: number,
|
|
83
|
-
): Uint8Array {
|
|
84
|
-
let valStr = val;
|
|
85
|
-
if (typeof valStr === "number" || typeof valStr === "bigint") {
|
|
86
|
-
valStr = valStr.toString(16);
|
|
87
|
-
} else if (typeof valStr === "string") {
|
|
88
|
-
if (valStr.startsWith("0x")) {
|
|
89
|
-
valStr = valStr.slice(2);
|
|
90
|
-
} else {
|
|
91
|
-
valStr = BigInt(valStr).toString(16);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (valStr.length % 2 !== 0) {
|
|
96
|
-
valStr = `0${valStr}`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const res = toBytes(`0x${valStr}`);
|
|
100
|
-
if (bytes == null) {
|
|
101
|
-
return res;
|
|
102
|
-
}
|
|
103
|
-
if (res.length > bytes) {
|
|
104
|
-
return res.slice(res.length - bytes);
|
|
105
|
-
}
|
|
106
|
-
return new Uint8Array([
|
|
107
|
-
...Array.from(Array(bytes - res.length), () => 0),
|
|
108
|
-
...res,
|
|
109
|
-
]);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function toNumberFromBytes(val: BytesLike): string {
|
|
113
|
-
return toLENumberFromBytes(val);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function toLENumberFromBytes(val: BytesLike): string {
|
|
117
|
-
return toBENumberFromBytes(toBytes(val).reverse());
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function toBENumberFromBytes(val: BytesLike): string {
|
|
121
|
-
const str = toHex(val).replace(/0x0*/, "0x");
|
|
122
|
-
if (str.length === 2) {
|
|
123
|
-
return "0";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return BigInt(str).toString();
|
|
127
|
-
}
|
package/src/ckb/types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./generated";
|
package/src/ckb/types/script.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { DeepReadonly } from "ts-essentials";
|
|
2
|
-
import { toBytes, toHex } from "../../bytes";
|
|
3
|
-
import { BytesLike, Hex } from "../../primitive";
|
|
4
|
-
import { HASH_TYPE_TO_NUM, NUM_TO_HASH_TYPE } from "./script.advanced";
|
|
5
|
-
import * as mol from "./molecule.advanced";
|
|
6
|
-
|
|
7
|
-
export type HashType = "type" | "data" | "data1" | "data2";
|
|
8
|
-
|
|
9
|
-
export function encodeHashType(hashType: HashType): Uint8Array {
|
|
10
|
-
return toBytes([HASH_TYPE_TO_NUM[hashType]]);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function decodeHashType(bytes: BytesLike): HashType {
|
|
14
|
-
return NUM_TO_HASH_TYPE[toBytes(bytes)[0]];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class Script {
|
|
18
|
-
constructor(
|
|
19
|
-
public codeHash: Hex,
|
|
20
|
-
public hashType: HashType,
|
|
21
|
-
public args: Hex,
|
|
22
|
-
) {}
|
|
23
|
-
|
|
24
|
-
static from({
|
|
25
|
-
codeHash,
|
|
26
|
-
hashType,
|
|
27
|
-
args,
|
|
28
|
-
}: {
|
|
29
|
-
codeHash: BytesLike;
|
|
30
|
-
hashType: string;
|
|
31
|
-
args: BytesLike;
|
|
32
|
-
}): Script {
|
|
33
|
-
return {
|
|
34
|
-
codeHash: toHex(codeHash),
|
|
35
|
-
hashType: hashType as HashType,
|
|
36
|
-
args: toHex(args),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static _toMolData(script: DeepReadonly<Script>) {
|
|
41
|
-
return {
|
|
42
|
-
codeHash: toBytes(script.codeHash),
|
|
43
|
-
hashType: encodeHashType(script.hashType),
|
|
44
|
-
args: toBytes(script.args),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static encode(script: DeepReadonly<Script>): Uint8Array {
|
|
49
|
-
return toBytes(mol.SerializeScript(Script._toMolData(script)));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static decode(bytes: BytesLike | mol.Script): Script {
|
|
53
|
-
const view =
|
|
54
|
-
bytes instanceof mol.Script ? bytes : new mol.Script(toBytes(bytes));
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
codeHash: toHex(view.getCodeHash().raw()),
|
|
58
|
-
hashType: decodeHashType([view.getHashType()]),
|
|
59
|
-
args: toHex(view.getArgs().raw()),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static eq(a: Script, b: Script): boolean {
|
|
64
|
-
return (
|
|
65
|
-
a.codeHash === b.codeHash &&
|
|
66
|
-
a.args === b.args &&
|
|
67
|
-
a.hashType === b.hashType
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|