@ckb-ccc/core 0.0.2-alpha.3 → 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/dist/address/address.advanced.js +29 -34
- package/dist/address/advanced.js +1 -17
- package/dist/address/index.js +12 -16
- package/dist/advanced.js +2 -31
- package/dist/advancedBarrel.js +4 -20
- package/dist/barrel.js +10 -26
- package/dist/bytes/index.js +8 -15
- package/dist/ckb/advanced.js +3 -32
- package/dist/ckb/index.js +2 -18
- package/dist/ckb/molecule.advanced/generated.js +64 -132
- package/dist/ckb/molecule.advanced/index.js +2 -20
- package/dist/ckb/script.advanced.js +3 -6
- package/dist/ckb/script.js +19 -49
- package/dist/ckb/transaction.advanced.js +3 -6
- package/dist/ckb/transaction.js +54 -89
- package/dist/client/advanced.js +2 -18
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +2 -5
- package/dist/client/clientPublicMainnet.advanced.js +7 -10
- package/dist/client/clientPublicMainnet.js +4 -8
- package/dist/client/clientPublicTestnet.advanced.js +7 -10
- 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.js +13 -17
- package/dist/client/jsonRpc/index.js +5 -12
- package/dist/fixedPoint/index.js +4 -9
- package/dist/hasher/advanced.js +1 -4
- package/dist/hasher/index.js +8 -16
- package/dist/hex/index.js +4 -8
- package/dist/index.js +2 -31
- package/dist/num/index.js +15 -26
- package/dist/signer/helpers.js +7 -11
- package/dist/signer/index.js +4 -20
- package/dist/signer/signer.js +1 -5
- package/dist/signer/signerReadonly.js +2 -6
- package/dist/signer/signerReadonlyCkbScript.js +4 -8
- package/dist/utils/index.js +1 -5
- package/package.json +2 -2
- package/src/client/client.ts +2 -0
package/dist/ckb/script.js
CHANGED
|
@@ -1,42 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.hashTypeFromBytes = exports.hashTypeToBytes = exports.hashTypeFrom = void 0;
|
|
27
|
-
const bytes_1 = require("../bytes");
|
|
28
|
-
const hex_1 = require("../hex");
|
|
29
|
-
const mol = __importStar(require("./molecule.advanced"));
|
|
30
|
-
const script_advanced_1 = require("./script.advanced");
|
|
31
|
-
function hashTypeFrom(val) {
|
|
1
|
+
import { bytesFrom } from "../bytes";
|
|
2
|
+
import { hexFrom } from "../hex";
|
|
3
|
+
import * as mol from "./molecule.advanced";
|
|
4
|
+
import { HASH_TYPES, HASH_TYPE_TO_NUM, NUM_TO_HASH_TYPE, } from "./script.advanced";
|
|
5
|
+
export function hashTypeFrom(val) {
|
|
32
6
|
const hashType = (() => {
|
|
33
7
|
if (typeof val === "number") {
|
|
34
|
-
return
|
|
8
|
+
return NUM_TO_HASH_TYPE[val];
|
|
35
9
|
}
|
|
36
10
|
if (typeof val === "bigint") {
|
|
37
|
-
return
|
|
11
|
+
return NUM_TO_HASH_TYPE[Number(val)];
|
|
38
12
|
}
|
|
39
|
-
if (!
|
|
13
|
+
if (!HASH_TYPES.includes(val)) {
|
|
40
14
|
return;
|
|
41
15
|
}
|
|
42
16
|
return val;
|
|
@@ -46,16 +20,13 @@ function hashTypeFrom(val) {
|
|
|
46
20
|
}
|
|
47
21
|
return hashType;
|
|
48
22
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return (0, bytes_1.bytesFrom)([script_advanced_1.HASH_TYPE_TO_NUM[hashType]]);
|
|
23
|
+
export function hashTypeToBytes(hashType) {
|
|
24
|
+
return bytesFrom([HASH_TYPE_TO_NUM[hashType]]);
|
|
52
25
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return script_advanced_1.NUM_TO_HASH_TYPE[(0, bytes_1.bytesFrom)(bytes)[0]];
|
|
26
|
+
export function hashTypeFromBytes(bytes) {
|
|
27
|
+
return NUM_TO_HASH_TYPE[bytesFrom(bytes)[0]];
|
|
56
28
|
}
|
|
57
|
-
|
|
58
|
-
class Script {
|
|
29
|
+
export class Script {
|
|
59
30
|
constructor(codeHash, hashType, args) {
|
|
60
31
|
this.codeHash = codeHash;
|
|
61
32
|
this.hashType = hashType;
|
|
@@ -65,21 +36,21 @@ class Script {
|
|
|
65
36
|
if (script instanceof Script) {
|
|
66
37
|
return script;
|
|
67
38
|
}
|
|
68
|
-
return new Script(
|
|
39
|
+
return new Script(hexFrom(script.codeHash), hashTypeFrom(script.hashType), hexFrom(script.args));
|
|
69
40
|
}
|
|
70
41
|
_toMolData() {
|
|
71
42
|
return {
|
|
72
|
-
codeHash:
|
|
43
|
+
codeHash: bytesFrom(this.codeHash),
|
|
73
44
|
hashType: hashTypeToBytes(this.hashType),
|
|
74
|
-
args:
|
|
45
|
+
args: bytesFrom(this.args),
|
|
75
46
|
};
|
|
76
47
|
}
|
|
77
48
|
toBytes() {
|
|
78
|
-
return
|
|
49
|
+
return bytesFrom(mol.SerializeScript(this._toMolData()));
|
|
79
50
|
}
|
|
80
51
|
static fromBytes(bytes) {
|
|
81
|
-
const view = bytes instanceof mol.Script ? bytes : new mol.Script(
|
|
82
|
-
return new Script(
|
|
52
|
+
const view = bytes instanceof mol.Script ? bytes : new mol.Script(bytesFrom(bytes));
|
|
53
|
+
return new Script(hexFrom(view.getCodeHash().raw()), hashTypeFromBytes([view.getHashType()]), hexFrom(view.getArgs().raw()));
|
|
83
54
|
}
|
|
84
55
|
eq(val) {
|
|
85
56
|
const script = Script.from(val);
|
|
@@ -88,4 +59,3 @@ class Script {
|
|
|
88
59
|
this.hashType === script.hashType);
|
|
89
60
|
}
|
|
90
61
|
}
|
|
91
|
-
exports.Script = Script;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEP_TYPES = exports.NUM_TO_DEP_TYPE = exports.DEP_TYPE_TO_NUM = void 0;
|
|
4
|
-
exports.DEP_TYPE_TO_NUM = {
|
|
1
|
+
export const DEP_TYPE_TO_NUM = {
|
|
5
2
|
code: 0x00,
|
|
6
3
|
depGroup: 0x01,
|
|
7
4
|
};
|
|
8
|
-
|
|
5
|
+
export const NUM_TO_DEP_TYPE = {
|
|
9
6
|
0x00: "code",
|
|
10
7
|
0x01: "depGroup",
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
export const DEP_TYPES = Object.keys(DEP_TYPE_TO_NUM);
|
package/dist/ckb/transaction.js
CHANGED
|
@@ -1,44 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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.depTypeFromBytes = exports.depTypeToBytes = exports.depTypeFrom = void 0;
|
|
27
|
-
const bytes_1 = require("../bytes");
|
|
28
|
-
const hasher_1 = require("../hasher");
|
|
29
|
-
const hex_1 = require("../hex");
|
|
30
|
-
const num_1 = require("../num");
|
|
31
|
-
const utils_1 = require("../utils");
|
|
32
|
-
const mol = __importStar(require("./molecule.advanced"));
|
|
33
|
-
const script_1 = require("./script");
|
|
34
|
-
const transaction_advanced_1 = require("./transaction.advanced");
|
|
35
|
-
function depTypeFrom(val) {
|
|
1
|
+
import { bytesFrom } from "../bytes";
|
|
2
|
+
import { ckbHash } from "../hasher";
|
|
3
|
+
import { hexFrom } from "../hex";
|
|
4
|
+
import { numFrom, numFromBytes, numToBytes } from "../num";
|
|
5
|
+
import { apply } from "../utils";
|
|
6
|
+
import * as mol from "./molecule.advanced";
|
|
7
|
+
import { Script } from "./script";
|
|
8
|
+
import { DEP_TYPE_TO_NUM, NUM_TO_DEP_TYPE } from "./transaction.advanced";
|
|
9
|
+
export function depTypeFrom(val) {
|
|
36
10
|
const depType = (() => {
|
|
37
11
|
if (typeof val === "number") {
|
|
38
|
-
return
|
|
12
|
+
return NUM_TO_DEP_TYPE[val];
|
|
39
13
|
}
|
|
40
14
|
if (typeof val === "bigint") {
|
|
41
|
-
return
|
|
15
|
+
return NUM_TO_DEP_TYPE[Number(val)];
|
|
42
16
|
}
|
|
43
17
|
return val;
|
|
44
18
|
})();
|
|
@@ -47,16 +21,13 @@ function depTypeFrom(val) {
|
|
|
47
21
|
}
|
|
48
22
|
return depType;
|
|
49
23
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return (0, bytes_1.bytesFrom)([transaction_advanced_1.DEP_TYPE_TO_NUM[depType]]);
|
|
24
|
+
export function depTypeToBytes(depType) {
|
|
25
|
+
return bytesFrom([DEP_TYPE_TO_NUM[depType]]);
|
|
53
26
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return transaction_advanced_1.NUM_TO_DEP_TYPE[(0, bytes_1.bytesFrom)(bytes)[0]];
|
|
27
|
+
export function depTypeFromBytes(bytes) {
|
|
28
|
+
return NUM_TO_DEP_TYPE[bytesFrom(bytes)[0]];
|
|
57
29
|
}
|
|
58
|
-
|
|
59
|
-
class OutPoint {
|
|
30
|
+
export class OutPoint {
|
|
60
31
|
constructor(txHash, index) {
|
|
61
32
|
this.txHash = txHash;
|
|
62
33
|
this.index = index;
|
|
@@ -65,26 +36,25 @@ class OutPoint {
|
|
|
65
36
|
if (outPoint instanceof OutPoint) {
|
|
66
37
|
return outPoint;
|
|
67
38
|
}
|
|
68
|
-
return new OutPoint(
|
|
39
|
+
return new OutPoint(hexFrom(outPoint.txHash), numFrom(outPoint.index));
|
|
69
40
|
}
|
|
70
41
|
_toMolData() {
|
|
71
42
|
return {
|
|
72
|
-
txHash:
|
|
73
|
-
index:
|
|
43
|
+
txHash: bytesFrom(this.txHash),
|
|
44
|
+
index: numToBytes(this.index, 4),
|
|
74
45
|
};
|
|
75
46
|
}
|
|
76
47
|
encode() {
|
|
77
|
-
return
|
|
48
|
+
return bytesFrom(mol.SerializeOutPoint(this._toMolData()));
|
|
78
49
|
}
|
|
79
50
|
static fromBytes(bytes) {
|
|
80
51
|
const view = bytes instanceof mol.OutPoint
|
|
81
52
|
? bytes
|
|
82
|
-
: new mol.OutPoint(
|
|
83
|
-
return new OutPoint(
|
|
53
|
+
: new mol.OutPoint(bytesFrom(bytes));
|
|
54
|
+
return new OutPoint(hexFrom(view.getTxHash().raw()), numFromBytes(view.getIndex().raw()));
|
|
84
55
|
}
|
|
85
56
|
}
|
|
86
|
-
|
|
87
|
-
class CellOutput {
|
|
57
|
+
export class CellOutput {
|
|
88
58
|
constructor(capacity, lock, type) {
|
|
89
59
|
this.capacity = capacity;
|
|
90
60
|
this.lock = lock;
|
|
@@ -94,27 +64,26 @@ class CellOutput {
|
|
|
94
64
|
if (cellOutput instanceof CellOutput) {
|
|
95
65
|
return cellOutput;
|
|
96
66
|
}
|
|
97
|
-
return new CellOutput(
|
|
67
|
+
return new CellOutput(numFrom(cellOutput.capacity), Script.from(cellOutput.lock), apply(Script.from, cellOutput.type));
|
|
98
68
|
}
|
|
99
69
|
_toMolData() {
|
|
100
70
|
return {
|
|
101
|
-
capacity:
|
|
71
|
+
capacity: numToBytes(this.capacity, 8),
|
|
102
72
|
lock: this.lock._toMolData(),
|
|
103
73
|
type: this.type?._toMolData(),
|
|
104
74
|
};
|
|
105
75
|
}
|
|
106
76
|
toBytes() {
|
|
107
|
-
return
|
|
77
|
+
return bytesFrom(mol.SerializeCellOutput(this._toMolData()));
|
|
108
78
|
}
|
|
109
79
|
static fromBytes(bytes) {
|
|
110
80
|
const view = bytes instanceof mol.CellOutput
|
|
111
81
|
? bytes
|
|
112
|
-
: new mol.CellOutput(
|
|
113
|
-
return new CellOutput(
|
|
82
|
+
: new mol.CellOutput(bytesFrom(bytes));
|
|
83
|
+
return new CellOutput(numFromBytes(view.getCapacity().raw()), Script.fromBytes(view.getLock()), apply(Script.fromBytes, mol.molOptional(view.getType())));
|
|
114
84
|
}
|
|
115
85
|
}
|
|
116
|
-
|
|
117
|
-
class CellInput {
|
|
86
|
+
export class CellInput {
|
|
118
87
|
constructor(previousOutput, since, cellOutput, outputData) {
|
|
119
88
|
this.previousOutput = previousOutput;
|
|
120
89
|
this.since = since;
|
|
@@ -125,26 +94,25 @@ class CellInput {
|
|
|
125
94
|
if (cellInput instanceof CellInput) {
|
|
126
95
|
return cellInput;
|
|
127
96
|
}
|
|
128
|
-
return new CellInput(OutPoint.from(cellInput.previousOutput),
|
|
97
|
+
return new CellInput(OutPoint.from(cellInput.previousOutput), numFrom(cellInput.since), apply(CellOutput.from, cellInput.cellOutput), apply(hexFrom, cellInput.outputData));
|
|
129
98
|
}
|
|
130
99
|
_toMolData() {
|
|
131
100
|
return {
|
|
132
101
|
previousOutput: this.previousOutput._toMolData(),
|
|
133
|
-
since:
|
|
102
|
+
since: numToBytes(this.since, 8),
|
|
134
103
|
};
|
|
135
104
|
}
|
|
136
105
|
toBytes() {
|
|
137
|
-
return
|
|
106
|
+
return bytesFrom(mol.SerializeCellInput(this._toMolData()));
|
|
138
107
|
}
|
|
139
108
|
static fromBytes(bytes) {
|
|
140
109
|
const view = bytes instanceof mol.CellInput
|
|
141
110
|
? bytes
|
|
142
|
-
: new mol.CellInput(
|
|
143
|
-
return new CellInput(OutPoint.fromBytes(view.getPreviousOutput()),
|
|
111
|
+
: new mol.CellInput(bytesFrom(bytes));
|
|
112
|
+
return new CellInput(OutPoint.fromBytes(view.getPreviousOutput()), numFromBytes(view.getSince().raw()));
|
|
144
113
|
}
|
|
145
114
|
}
|
|
146
|
-
|
|
147
|
-
class CellDep {
|
|
115
|
+
export class CellDep {
|
|
148
116
|
constructor(outPoint, depType) {
|
|
149
117
|
this.outPoint = outPoint;
|
|
150
118
|
this.depType = depType;
|
|
@@ -162,15 +130,14 @@ class CellDep {
|
|
|
162
130
|
};
|
|
163
131
|
}
|
|
164
132
|
toBytes() {
|
|
165
|
-
return
|
|
133
|
+
return bytesFrom(mol.SerializeCellDep(this._toMolData()));
|
|
166
134
|
}
|
|
167
135
|
fromBytes(bytes) {
|
|
168
|
-
const view = bytes instanceof mol.CellDep ? bytes : new mol.CellDep(
|
|
136
|
+
const view = bytes instanceof mol.CellDep ? bytes : new mol.CellDep(bytesFrom(bytes));
|
|
169
137
|
return new CellDep(OutPoint.fromBytes(view.getOutPoint()), depTypeFromBytes([view.getDepType()]));
|
|
170
138
|
}
|
|
171
139
|
}
|
|
172
|
-
|
|
173
|
-
class WitnessArgs {
|
|
140
|
+
export class WitnessArgs {
|
|
174
141
|
constructor(lock, inputType, outputType) {
|
|
175
142
|
this.lock = lock;
|
|
176
143
|
this.inputType = inputType;
|
|
@@ -180,27 +147,26 @@ class WitnessArgs {
|
|
|
180
147
|
if (witnessArgs instanceof WitnessArgs) {
|
|
181
148
|
return witnessArgs;
|
|
182
149
|
}
|
|
183
|
-
return new WitnessArgs(
|
|
150
|
+
return new WitnessArgs(apply(hexFrom, witnessArgs.lock), apply(hexFrom, witnessArgs.inputType), apply(hexFrom, witnessArgs.outputType));
|
|
184
151
|
}
|
|
185
152
|
_toMolData() {
|
|
186
153
|
return {
|
|
187
|
-
lock:
|
|
188
|
-
inputType:
|
|
189
|
-
outputType:
|
|
154
|
+
lock: apply(bytesFrom, this.lock),
|
|
155
|
+
inputType: apply(bytesFrom, this.inputType),
|
|
156
|
+
outputType: apply(bytesFrom, this.outputType),
|
|
190
157
|
};
|
|
191
158
|
}
|
|
192
159
|
toBytes() {
|
|
193
|
-
return
|
|
160
|
+
return bytesFrom(mol.SerializeWitnessArgs(this._toMolData()));
|
|
194
161
|
}
|
|
195
162
|
static fromBytes(bytes) {
|
|
196
163
|
const view = bytes instanceof mol.WitnessArgs
|
|
197
164
|
? bytes
|
|
198
|
-
: new mol.WitnessArgs(
|
|
199
|
-
return new WitnessArgs(
|
|
165
|
+
: new mol.WitnessArgs(bytesFrom(bytes));
|
|
166
|
+
return new WitnessArgs(apply(hexFrom, mol.molOptional(view.getLock())?.raw()), apply(hexFrom, mol.molOptional(view.getInputType())?.raw()), apply(hexFrom, mol.molOptional(view.getOutputType())?.raw()));
|
|
200
167
|
}
|
|
201
168
|
}
|
|
202
|
-
|
|
203
|
-
class Transaction {
|
|
169
|
+
export class Transaction {
|
|
204
170
|
constructor(version, cellDeps, headerDeps, inputs, outputs, outputsData, witnesses) {
|
|
205
171
|
this.version = version;
|
|
206
172
|
this.cellDeps = cellDeps;
|
|
@@ -217,7 +183,7 @@ class Transaction {
|
|
|
217
183
|
if (tx instanceof Transaction) {
|
|
218
184
|
return tx;
|
|
219
185
|
}
|
|
220
|
-
return new Transaction(
|
|
186
|
+
return new Transaction(numFrom(tx.version), tx.cellDeps.map((cellDep) => CellDep.from(cellDep)), tx.headerDeps.map(hexFrom), tx.inputs.map((input) => CellInput.from(input)), tx.outputs.map((output) => CellOutput.from(output)), tx.outputsData.map(hexFrom), tx.witnesses.map(hexFrom));
|
|
221
187
|
}
|
|
222
188
|
static fromLumosSkeleton(skeleton) {
|
|
223
189
|
return Transaction.from({
|
|
@@ -241,22 +207,21 @@ class Transaction {
|
|
|
241
207
|
});
|
|
242
208
|
}
|
|
243
209
|
rawToBytes() {
|
|
244
|
-
return
|
|
245
|
-
version:
|
|
210
|
+
return bytesFrom(mol.SerializeRawTransaction({
|
|
211
|
+
version: numToBytes(this.version, 4),
|
|
246
212
|
cellDeps: this.cellDeps.map((d) => d._toMolData()),
|
|
247
|
-
headerDeps: this.headerDeps.map(
|
|
213
|
+
headerDeps: this.headerDeps.map(bytesFrom),
|
|
248
214
|
inputs: this.inputs.map((i) => i._toMolData()),
|
|
249
215
|
outputs: this.outputs.map((o) => o._toMolData()),
|
|
250
|
-
outputsData: this.outputsData.map(
|
|
216
|
+
outputsData: this.outputsData.map(bytesFrom),
|
|
251
217
|
}));
|
|
252
218
|
}
|
|
253
219
|
hash() {
|
|
254
|
-
return
|
|
220
|
+
return ckbHash(this.rawToBytes());
|
|
255
221
|
}
|
|
256
222
|
static hashWitnessToHasher(witness, hasher) {
|
|
257
|
-
const raw =
|
|
258
|
-
hasher.update(
|
|
223
|
+
const raw = bytesFrom(hexFrom(witness));
|
|
224
|
+
hasher.update(numToBytes(raw.length, 8));
|
|
259
225
|
hasher.update(raw);
|
|
260
226
|
}
|
|
261
227
|
}
|
|
262
|
-
exports.Transaction = Transaction;
|
package/dist/client/advanced.js
CHANGED
|
@@ -1,18 +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 __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);
|
|
1
|
+
export * from "./clientPublicMainnet.advanced";
|
|
2
|
+
export * from "./clientPublicTestnet.advanced";
|
package/dist/client/client.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare enum KnownScript {
|
|
|
9
9
|
OmniLock = 4
|
|
10
10
|
}
|
|
11
11
|
export interface Client {
|
|
12
|
+
getUrl(): string;
|
|
12
13
|
getAddressPrefix(): Promise<string>;
|
|
13
14
|
getKnownScript(script: KnownScript): Promise<Omit<ScriptLike, "args">>;
|
|
14
15
|
sendTransaction(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,QAAQ,IAAA;CACT;AAED,MAAM,WAAW,MAAM;IACrB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvE,eAAe,CACb,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC,CAAC;CACjB"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,QAAQ,IAAA;CACT;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,IAAI,MAAM,CAAC;IAEjB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvE,eAAe,CACb,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC,CAAC;CACjB"}
|
package/dist/client/client.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KnownScript = void 0;
|
|
4
|
-
var KnownScript;
|
|
1
|
+
export var KnownScript;
|
|
5
2
|
(function (KnownScript) {
|
|
6
3
|
KnownScript[KnownScript["Secp256k1Blake160"] = 0] = "Secp256k1Blake160";
|
|
7
4
|
KnownScript[KnownScript["Secp256k1Multisig"] = 1] = "Secp256k1Multisig";
|
|
8
5
|
KnownScript[KnownScript["AnyoneCanPay"] = 2] = "AnyoneCanPay";
|
|
9
6
|
KnownScript[KnownScript["JoyId"] = 3] = "JoyId";
|
|
10
7
|
KnownScript[KnownScript["OmniLock"] = 4] = "OmniLock";
|
|
11
|
-
})(KnownScript || (
|
|
8
|
+
})(KnownScript || (KnownScript = {}));
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const client_1 = require("./client");
|
|
5
|
-
exports.MAINNET_SCRIPTS = {
|
|
6
|
-
[client_1.KnownScript.Secp256k1Blake160]: {
|
|
1
|
+
import { KnownScript } from "./client";
|
|
2
|
+
export const MAINNET_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: "0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354",
|
|
16
13
|
hashType: "type",
|
|
17
14
|
},
|
|
18
|
-
[
|
|
15
|
+
[KnownScript.JoyId]: {
|
|
19
16
|
codeHash: "0xd00c84f0ec8fd441c38bc3f87a371f547190f2fcff88e642bc5bf54b9e318323",
|
|
20
17
|
hashType: "type",
|
|
21
18
|
},
|
|
22
|
-
[
|
|
19
|
+
[KnownScript.OmniLock]: {
|
|
23
20
|
codeHash: "0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26",
|
|
24
21
|
hashType: "type",
|
|
25
22
|
},
|
|
@@ -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,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,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";
|