@ckb-ccc/core 0.0.4-alpha.8 → 0.0.4
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/signer/btc/signerBtcPublicKeyReadonly.d.ts +12 -0
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/btc/signerBtcPublicKeyReadonly.js +16 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +12 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +16 -0
- package/dist/signer/evm/signerEvm.d.ts +5 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +20 -6
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +13 -1
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.js +16 -0
- package/dist/signer/helpers.d.ts.map +1 -1
- package/dist/signer/helpers.js +3 -2
- package/dist/signer/signer.d.ts +16 -4
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +5 -2
- package/dist.commonjs/address/address.advanced.d.ts +65 -0
- package/dist.commonjs/address/address.advanced.d.ts.map +1 -0
- package/dist.commonjs/address/address.advanced.js +149 -0
- package/dist.commonjs/address/advanced.d.ts +2 -0
- package/dist.commonjs/address/advanced.d.ts.map +1 -0
- package/dist.commonjs/address/advanced.js +17 -0
- package/dist.commonjs/address/index.d.ts +54 -0
- package/dist.commonjs/address/index.d.ts.map +1 -0
- package/dist.commonjs/address/index.js +84 -0
- package/dist.commonjs/advanced.d.ts +3 -0
- package/dist.commonjs/advanced.d.ts.map +1 -0
- package/dist.commonjs/advanced.js +31 -0
- package/dist.commonjs/advancedBarrel.d.ts +5 -0
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -0
- package/dist.commonjs/advancedBarrel.js +20 -0
- package/dist.commonjs/barrel.d.ts +11 -0
- package/dist.commonjs/barrel.d.ts.map +1 -0
- package/dist.commonjs/barrel.js +26 -0
- package/dist.commonjs/bytes/advanced.d.ts +5 -0
- package/dist.commonjs/bytes/advanced.d.ts.map +1 -0
- package/dist.commonjs/bytes/advanced.js +2 -0
- package/dist.commonjs/bytes/index.d.ts +64 -0
- package/dist.commonjs/bytes/index.d.ts.map +1 -0
- package/dist.commonjs/bytes/index.js +97 -0
- package/dist.commonjs/ckb/advanced.d.ts +4 -0
- package/dist.commonjs/ckb/advanced.d.ts.map +1 -0
- package/dist.commonjs/ckb/advanced.js +32 -0
- package/dist.commonjs/ckb/index.d.ts +3 -0
- package/dist.commonjs/ckb/index.d.ts.map +1 -0
- package/dist.commonjs/ckb/index.js +18 -0
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +355 -0
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts.map +1 -0
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -0
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +6 -0
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts.map +1 -0
- package/dist.commonjs/ckb/molecule.advanced/index.js +25 -0
- package/dist.commonjs/ckb/script.advanced.d.ts +5 -0
- package/dist.commonjs/ckb/script.advanced.d.ts.map +1 -0
- package/dist.commonjs/ckb/script.advanced.js +16 -0
- package/dist.commonjs/ckb/script.d.ts +126 -0
- package/dist.commonjs/ckb/script.d.ts.map +1 -0
- package/dist.commonjs/ckb/script.js +188 -0
- package/dist.commonjs/ckb/transaction.advanced.d.ts +5 -0
- package/dist.commonjs/ckb/transaction.advanced.d.ts.map +1 -0
- package/dist.commonjs/ckb/transaction.advanced.js +12 -0
- package/dist.commonjs/ckb/transaction.d.ts +533 -0
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -0
- package/dist.commonjs/ckb/transaction.js +665 -0
- package/dist.commonjs/client/advanced.d.ts +4 -0
- package/dist.commonjs/client/advanced.d.ts.map +1 -0
- package/dist.commonjs/client/advanced.js +19 -0
- package/dist.commonjs/client/client.d.ts +19 -0
- package/dist.commonjs/client/client.d.ts.map +1 -0
- package/dist.commonjs/client/client.js +30 -0
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -0
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +26 -0
- package/dist.commonjs/client/clientPublicMainnet.d.ts +9 -0
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicMainnet.js +17 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +4 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +26 -0
- package/dist.commonjs/client/clientPublicTestnet.d.ts +9 -0
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -0
- package/dist.commonjs/client/clientPublicTestnet.js +17 -0
- package/dist.commonjs/client/clientTypes.d.ts +8 -0
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -0
- package/dist.commonjs/client/clientTypes.js +2 -0
- package/dist.commonjs/client/index.d.ts +6 -0
- package/dist.commonjs/client/index.d.ts.map +1 -0
- package/dist.commonjs/client/index.js +21 -0
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +3 -0
- package/dist.commonjs/client/jsonRpc/advanced.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/advanced.js +18 -0
- package/dist.commonjs/client/jsonRpc/index.d.ts +68 -0
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/index.js +128 -0
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +28 -0
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/transformers.js +126 -0
- package/dist.commonjs/client/jsonRpc/types.d.ts +41 -0
- package/dist.commonjs/client/jsonRpc/types.d.ts.map +1 -0
- package/dist.commonjs/client/jsonRpc/types.js +2 -0
- package/dist.commonjs/fixedPoint/index.d.ts +49 -0
- package/dist.commonjs/fixedPoint/index.d.ts.map +1 -0
- package/dist.commonjs/fixedPoint/index.js +65 -0
- package/dist.commonjs/hasher/advanced.d.ts +2 -0
- package/dist.commonjs/hasher/advanced.d.ts.map +1 -0
- package/dist.commonjs/hasher/advanced.js +4 -0
- package/dist.commonjs/hasher/index.d.ts +52 -0
- package/dist.commonjs/hasher/index.d.ts.map +1 -0
- package/dist.commonjs/hasher/index.js +68 -0
- package/dist.commonjs/hex/index.d.ts +24 -0
- package/dist.commonjs/hex/index.d.ts.map +1 -0
- package/dist.commonjs/hex/index.js +20 -0
- package/dist.commonjs/index.d.ts +3 -0
- package/dist.commonjs/index.d.ts.map +1 -0
- package/dist.commonjs/index.js +31 -0
- package/dist.commonjs/num/index.d.ts +112 -0
- package/dist.commonjs/num/index.d.ts.map +1 -0
- package/dist.commonjs/num/index.js +139 -0
- package/dist.commonjs/signer/btc/index.d.ts +3 -0
- package/dist.commonjs/signer/btc/index.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/index.js +18 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts +50 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/signerBtc.js +71 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +60 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +72 -0
- package/dist.commonjs/signer/ckb/index.d.ts +2 -0
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/index.js +17 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +59 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +71 -0
- package/dist.commonjs/signer/evm/index.d.ts +3 -0
- package/dist.commonjs/signer/evm/index.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/index.js +18 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts +46 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/signerEvm.js +83 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +52 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +62 -0
- package/dist.commonjs/signer/helpers.d.ts +40 -0
- package/dist.commonjs/signer/helpers.d.ts.map +1 -0
- package/dist.commonjs/signer/helpers.js +96 -0
- package/dist.commonjs/signer/index.d.ts +6 -0
- package/dist.commonjs/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/index.js +21 -0
- package/dist.commonjs/signer/signer.d.ts +125 -0
- package/dist.commonjs/signer/signer.d.ts.map +1 -0
- package/dist.commonjs/signer/signer.js +109 -0
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +1 -0
- package/dist.commonjs/utils/index.d.ts +7 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -0
- package/dist.commonjs/utils/index.js +10 -0
- package/package.json +20 -7
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +18 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +18 -0
- package/src/signer/evm/signerEvm.ts +55 -12
- package/src/signer/evm/signerEvmAddressReadonly.ts +19 -1
- package/src/signer/helpers.ts +5 -3
- package/src/signer/signer.ts +20 -3
- package/tsconfig.base.json +21 -0
- package/tsconfig.commonjs.json +8 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Cell, OutPointLike, Script, TransactionLike } from "../ckb";
|
|
2
|
+
import { Hex, HexLike } from "../hex";
|
|
3
|
+
import { ClientTransactionResponse, OutputsValidator } from "./clientTypes";
|
|
4
|
+
export declare enum KnownScript {
|
|
5
|
+
Secp256k1Blake160 = 0,
|
|
6
|
+
Secp256k1Multisig = 1,
|
|
7
|
+
AnyoneCanPay = 2,
|
|
8
|
+
JoyId = 3,
|
|
9
|
+
OmniLock = 4
|
|
10
|
+
}
|
|
11
|
+
export declare abstract class Client {
|
|
12
|
+
abstract getUrl(): string;
|
|
13
|
+
abstract getAddressPrefix(): Promise<string>;
|
|
14
|
+
abstract getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
|
|
15
|
+
abstract sendTransaction(transaction: TransactionLike, validator?: OutputsValidator): Promise<Hex>;
|
|
16
|
+
abstract getTransaction(txHash: HexLike): Promise<ClientTransactionResponse | null>;
|
|
17
|
+
getCell(outPoint: OutPointLike): Promise<Cell | null>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE5E,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,QAAQ,IAAA;CACT;AAED,8BAAsB,MAAM;IAC1B,QAAQ,CAAC,MAAM,IAAI,MAAM;IAEzB,QAAQ,CAAC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAC5C,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;IAEjD,QAAQ,CAAC,eAAe,CACtB,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC;IACf,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAEtC,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;CAgB5D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Client = exports.KnownScript = void 0;
|
|
4
|
+
const ckb_1 = require("../ckb");
|
|
5
|
+
const num_1 = require("../num");
|
|
6
|
+
var KnownScript;
|
|
7
|
+
(function (KnownScript) {
|
|
8
|
+
KnownScript[KnownScript["Secp256k1Blake160"] = 0] = "Secp256k1Blake160";
|
|
9
|
+
KnownScript[KnownScript["Secp256k1Multisig"] = 1] = "Secp256k1Multisig";
|
|
10
|
+
KnownScript[KnownScript["AnyoneCanPay"] = 2] = "AnyoneCanPay";
|
|
11
|
+
KnownScript[KnownScript["JoyId"] = 3] = "JoyId";
|
|
12
|
+
KnownScript[KnownScript["OmniLock"] = 4] = "OmniLock";
|
|
13
|
+
})(KnownScript || (exports.KnownScript = KnownScript = {}));
|
|
14
|
+
class Client {
|
|
15
|
+
async getCell(outPoint) {
|
|
16
|
+
const transaction = await this.getTransaction(outPoint.txHash);
|
|
17
|
+
if (!transaction) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const index = Number((0, num_1.numFrom)(outPoint.index));
|
|
21
|
+
if (index >= transaction.transaction.outputs.length) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return ckb_1.Cell.from({
|
|
25
|
+
cellOutput: transaction.transaction.outputs[index],
|
|
26
|
+
outputData: transaction.transaction.outputsData[index] ?? "0x",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Client = Client;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CA2BtC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAINNET_SCRIPTS = void 0;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
exports.MAINNET_SCRIPTS = {
|
|
6
|
+
[client_1.KnownScript.Secp256k1Blake160]: {
|
|
7
|
+
codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
8
|
+
hashType: "type",
|
|
9
|
+
},
|
|
10
|
+
[client_1.KnownScript.Secp256k1Multisig]: {
|
|
11
|
+
codeHash: "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",
|
|
12
|
+
hashType: "type",
|
|
13
|
+
},
|
|
14
|
+
[client_1.KnownScript.AnyoneCanPay]: {
|
|
15
|
+
codeHash: "0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354",
|
|
16
|
+
hashType: "type",
|
|
17
|
+
},
|
|
18
|
+
[client_1.KnownScript.JoyId]: {
|
|
19
|
+
codeHash: "0xd00c84f0ec8fd441c38bc3f87a371f547190f2fcff88e642bc5bf54b9e318323",
|
|
20
|
+
hashType: "type",
|
|
21
|
+
},
|
|
22
|
+
[client_1.KnownScript.OmniLock]: {
|
|
23
|
+
codeHash: "0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26",
|
|
24
|
+
hashType: "type",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Script } from "../ckb";
|
|
2
|
+
import { KnownScript } from "./client";
|
|
3
|
+
import { ClientJsonRpc } from "./jsonRpc";
|
|
4
|
+
export declare class ClientPublicMainnet extends ClientJsonRpc {
|
|
5
|
+
constructor(url?: string, timeout?: number);
|
|
6
|
+
getAddressPrefix(): Promise<string>;
|
|
7
|
+
getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=clientPublicMainnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAI3D,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientPublicMainnet = void 0;
|
|
4
|
+
const clientPublicMainnet_advanced_1 = require("./clientPublicMainnet.advanced");
|
|
5
|
+
const jsonRpc_1 = require("./jsonRpc");
|
|
6
|
+
class ClientPublicMainnet extends jsonRpc_1.ClientJsonRpc {
|
|
7
|
+
constructor(url = "https://mainnet.ckbapp.dev/", timeout) {
|
|
8
|
+
super(url, timeout);
|
|
9
|
+
}
|
|
10
|
+
async getAddressPrefix() {
|
|
11
|
+
return "ckb";
|
|
12
|
+
}
|
|
13
|
+
async getKnownScript(script) {
|
|
14
|
+
return { ...clientPublicMainnet_advanced_1.MAINNET_SCRIPTS[script] };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ClientPublicMainnet = ClientPublicMainnet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CA2BtC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TESTNET_SCRIPTS = void 0;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
exports.TESTNET_SCRIPTS = {
|
|
6
|
+
[client_1.KnownScript.Secp256k1Blake160]: {
|
|
7
|
+
codeHash: "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
|
|
8
|
+
hashType: "type",
|
|
9
|
+
},
|
|
10
|
+
[client_1.KnownScript.Secp256k1Multisig]: {
|
|
11
|
+
codeHash: "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",
|
|
12
|
+
hashType: "type",
|
|
13
|
+
},
|
|
14
|
+
[client_1.KnownScript.AnyoneCanPay]: {
|
|
15
|
+
codeHash: "0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356",
|
|
16
|
+
hashType: "type",
|
|
17
|
+
},
|
|
18
|
+
[client_1.KnownScript.JoyId]: {
|
|
19
|
+
codeHash: "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac",
|
|
20
|
+
hashType: "type",
|
|
21
|
+
},
|
|
22
|
+
[client_1.KnownScript.OmniLock]: {
|
|
23
|
+
codeHash: "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
|
|
24
|
+
hashType: "type",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Script } from "../ckb";
|
|
2
|
+
import { KnownScript } from "./client";
|
|
3
|
+
import { ClientJsonRpc } from "./jsonRpc";
|
|
4
|
+
export declare class ClientPublicTestnet extends ClientJsonRpc {
|
|
5
|
+
constructor(url?: string, timeout?: number);
|
|
6
|
+
getAddressPrefix(): Promise<string>;
|
|
7
|
+
getKnownScript(script: KnownScript): Promise<Pick<Script, "codeHash" | "hashType">>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=clientPublicTestnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAI3D,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CAGlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientPublicTestnet = void 0;
|
|
4
|
+
const clientPublicTestnet_advanced_1 = require("./clientPublicTestnet.advanced");
|
|
5
|
+
const jsonRpc_1 = require("./jsonRpc");
|
|
6
|
+
class ClientPublicTestnet extends jsonRpc_1.ClientJsonRpc {
|
|
7
|
+
constructor(url = "https://testnet.ckbapp.dev/", timeout) {
|
|
8
|
+
super(url, timeout);
|
|
9
|
+
}
|
|
10
|
+
async getAddressPrefix() {
|
|
11
|
+
return "ckt";
|
|
12
|
+
}
|
|
13
|
+
async getKnownScript(script) {
|
|
14
|
+
return { ...clientPublicTestnet_advanced_1.TESTNET_SCRIPTS[script] };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ClientPublicTestnet = ClientPublicTestnet;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transaction } from "../ckb";
|
|
2
|
+
export type OutputsValidator = "passthrough" | "well_known_scripts_only";
|
|
3
|
+
export type TransactionStatus = "pending" | "proposed" | "committed" | "unknown" | "rejected";
|
|
4
|
+
export type ClientTransactionResponse = {
|
|
5
|
+
transaction: Transaction;
|
|
6
|
+
status: TransactionStatus;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=clientTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientTypes.d.ts","sourceRoot":"","sources":["../../src/client/clientTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,yBAAyB,CAAC;AAEzE,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AACf,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./client"), exports);
|
|
18
|
+
__exportStar(require("./clientPublicMainnet"), exports);
|
|
19
|
+
__exportStar(require("./clientPublicTestnet"), exports);
|
|
20
|
+
__exportStar(require("./clientTypes"), exports);
|
|
21
|
+
__exportStar(require("./jsonRpc"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,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("./transformers"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TransactionLike } from "../../ckb";
|
|
2
|
+
import { Hex, HexLike } from "../../hex";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
import { ClientTransactionResponse, OutputsValidator } from "../clientTypes";
|
|
5
|
+
import { JsonRpcPayload } from "./advanced";
|
|
6
|
+
/**
|
|
7
|
+
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
8
|
+
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class ClientJsonRpc extends Client {
|
|
11
|
+
private readonly url;
|
|
12
|
+
private readonly timeout;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of ClientJsonRpc.
|
|
15
|
+
*
|
|
16
|
+
* @param url - The URL of the JSON-RPC server.
|
|
17
|
+
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
18
|
+
*/
|
|
19
|
+
constructor(url: string, timeout?: number);
|
|
20
|
+
/**
|
|
21
|
+
* Returns the URL of the JSON-RPC server.
|
|
22
|
+
*
|
|
23
|
+
* @returns The URL of the JSON-RPC server.
|
|
24
|
+
*/
|
|
25
|
+
getUrl(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Send a transaction to node.
|
|
28
|
+
*
|
|
29
|
+
* @param transaction - The transaction to send.
|
|
30
|
+
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
31
|
+
* @returns Transaction hash.
|
|
32
|
+
*/
|
|
33
|
+
sendTransaction: (transaction: TransactionLike, validator?: OutputsValidator | undefined) => Promise<Hex>;
|
|
34
|
+
/**
|
|
35
|
+
* Get a transaction from node.
|
|
36
|
+
*
|
|
37
|
+
* @param txHash - The hash of the transaction.
|
|
38
|
+
* @returns The transaction with status.
|
|
39
|
+
*/
|
|
40
|
+
getTransaction: (txHash: HexLike) => Promise<ClientTransactionResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Builds a sender function for a JSON-RPC method.
|
|
43
|
+
*
|
|
44
|
+
* @param rpcMethod - The JSON-RPC method.
|
|
45
|
+
* @param inTransformers - An array of input transformers.
|
|
46
|
+
* @param outTransformer - An output transformer function.
|
|
47
|
+
* @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
|
|
48
|
+
*/
|
|
49
|
+
buildSender(rpcMethod: string, inTransformers: (((_: any) => unknown) | undefined)[], outTransformer?: (_: any) => unknown): (...req: unknown[]) => Promise<unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* Sends a JSON-RPC request to the server.
|
|
52
|
+
*
|
|
53
|
+
* @param payload - The JSON-RPC payload to send.
|
|
54
|
+
* @returns The result of the JSON-RPC request.
|
|
55
|
+
*
|
|
56
|
+
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
57
|
+
*/
|
|
58
|
+
send(payload: JsonRpcPayload): Promise<unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* Builds a JSON-RPC payload for the given method and parameters.
|
|
61
|
+
*
|
|
62
|
+
* @param method - The JSON-RPC method name.
|
|
63
|
+
* @param req - The parameters for the JSON-RPC method.
|
|
64
|
+
* @returns The JSON-RPC payload.
|
|
65
|
+
*/
|
|
66
|
+
static buildPayload(method: string, req: unknown[]): JsonRpcPayload;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AA0BjE;;;GAGG;AAEH,8BAAsB,aAAc,SAAQ,MAAM;IAS9C,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAT1B;;;;;OAKG;gBAGgB,GAAG,EAAE,MAAM,EACX,OAAO,SAAQ;IAKlC;;;;OAIG;IAEH,MAAM;IAIN;;;;;;OAMG;IAEH,eAAe,gBAKA,eAAe,cAChB,gBAAgB,GAAG,SAAS,KACrC,QAAQ,GAAG,CAAC,CAAC;IAElB;;;;;OAKG;IAEH,cAAc,WAIA,OAAO,KAAK,QAAQ,yBAAyB,CAAC,CAAC;IAE7D;;;;;;;OAOG;IAEH,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EACrD,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,YAEd,OAAO,EAAE;IAUjC;;;;;;;OAOG;IAEG,IAAI,CAAC,OAAO,EAAE,cAAc;IA4BlC;;;;;;OAMG;IAEH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc;CAQpE"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ClientJsonRpc = void 0;
|
|
7
|
+
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
+
const hex_1 = require("../../hex");
|
|
9
|
+
const client_1 = require("../client");
|
|
10
|
+
const advanced_1 = require("./advanced");
|
|
11
|
+
/**
|
|
12
|
+
* Applies a transformation function to a value if the transformer is provided.
|
|
13
|
+
*
|
|
14
|
+
* @param value - The value to be transformed.
|
|
15
|
+
* @param transformer - An optional transformation function.
|
|
16
|
+
* @returns The transformed value if a transformer is provided, otherwise the original value.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const result = await transform(5, (x) => x * 2); // Outputs 10
|
|
21
|
+
* const resultWithoutTransformer = await transform(5); // Outputs 5
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
async function transform(value, transformer) {
|
|
25
|
+
if (transformer) {
|
|
26
|
+
return transformer(value);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An abstract class implementing JSON-RPC client functionality for a specific URL and timeout.
|
|
32
|
+
* Provides methods for sending transactions and building JSON-RPC payloads.
|
|
33
|
+
*/
|
|
34
|
+
class ClientJsonRpc extends client_1.Client {
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of ClientJsonRpc.
|
|
37
|
+
*
|
|
38
|
+
* @param url - The URL of the JSON-RPC server.
|
|
39
|
+
* @param timeout - The timeout for requests in milliseconds, default is 30000.
|
|
40
|
+
*/
|
|
41
|
+
constructor(url, timeout = 30000) {
|
|
42
|
+
super();
|
|
43
|
+
this.url = url;
|
|
44
|
+
this.timeout = timeout;
|
|
45
|
+
/**
|
|
46
|
+
* Send a transaction to node.
|
|
47
|
+
*
|
|
48
|
+
* @param transaction - The transaction to send.
|
|
49
|
+
* @param validator - "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.
|
|
50
|
+
* @returns Transaction hash.
|
|
51
|
+
*/
|
|
52
|
+
this.sendTransaction = this.buildSender("send_transaction", [advanced_1.JsonRpcTransformers.transactionFrom], hex_1.hexFrom);
|
|
53
|
+
/**
|
|
54
|
+
* Get a transaction from node.
|
|
55
|
+
*
|
|
56
|
+
* @param txHash - The hash of the transaction.
|
|
57
|
+
* @returns The transaction with status.
|
|
58
|
+
*/
|
|
59
|
+
this.getTransaction = this.buildSender("get_transaction", [hex_1.hexFrom], advanced_1.JsonRpcTransformers.transactionResponseTo);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the URL of the JSON-RPC server.
|
|
63
|
+
*
|
|
64
|
+
* @returns The URL of the JSON-RPC server.
|
|
65
|
+
*/
|
|
66
|
+
getUrl() {
|
|
67
|
+
return this.url;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Builds a sender function for a JSON-RPC method.
|
|
71
|
+
*
|
|
72
|
+
* @param rpcMethod - The JSON-RPC method.
|
|
73
|
+
* @param inTransformers - An array of input transformers.
|
|
74
|
+
* @param outTransformer - An output transformer function.
|
|
75
|
+
* @returns A function that sends a JSON-RPC request with the given method and transformed parameters.
|
|
76
|
+
*/
|
|
77
|
+
buildSender(rpcMethod, inTransformers, outTransformer) {
|
|
78
|
+
return async (...req) => {
|
|
79
|
+
const payload = ClientJsonRpc.buildPayload(rpcMethod, await Promise.all(req.map((v, i) => transform(v, inTransformers[i]))));
|
|
80
|
+
return transform(await this.send(payload), outTransformer);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sends a JSON-RPC request to the server.
|
|
85
|
+
*
|
|
86
|
+
* @param payload - The JSON-RPC payload to send.
|
|
87
|
+
* @returns The result of the JSON-RPC request.
|
|
88
|
+
*
|
|
89
|
+
* @throws Will throw an error if the response ID does not match the request ID, or if the response contains an error.
|
|
90
|
+
*/
|
|
91
|
+
async send(payload) {
|
|
92
|
+
const aborter = new AbortController();
|
|
93
|
+
const abortTimer = setTimeout(() => aborter.abort(), this.timeout);
|
|
94
|
+
const raw = await (0, cross_fetch_1.default)(this.url, {
|
|
95
|
+
method: "POST",
|
|
96
|
+
headers: {
|
|
97
|
+
"content-type": "application/json",
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify(payload),
|
|
100
|
+
signal: aborter.signal,
|
|
101
|
+
});
|
|
102
|
+
clearTimeout(abortTimer);
|
|
103
|
+
const res = (await raw.json());
|
|
104
|
+
if (res.id !== payload.id) {
|
|
105
|
+
throw new Error(`Id mismatched, got ${res.id}, expected ${payload.id}`);
|
|
106
|
+
}
|
|
107
|
+
if (res.error) {
|
|
108
|
+
throw res.error;
|
|
109
|
+
}
|
|
110
|
+
return res.result;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Builds a JSON-RPC payload for the given method and parameters.
|
|
114
|
+
*
|
|
115
|
+
* @param method - The JSON-RPC method name.
|
|
116
|
+
* @param req - The parameters for the JSON-RPC method.
|
|
117
|
+
* @returns The JSON-RPC payload.
|
|
118
|
+
*/
|
|
119
|
+
static buildPayload(method, req) {
|
|
120
|
+
return {
|
|
121
|
+
id: Math.round(Math.random() * 10000),
|
|
122
|
+
method,
|
|
123
|
+
params: req,
|
|
124
|
+
jsonrpc: "2.0",
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.ClientJsonRpc = ClientJsonRpc;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CellDep, CellDepLike, CellInput, CellInputLike, CellOutput, CellOutputLike, DepType, DepTypeLike, HashType, HashTypeLike, OutPoint, OutPointLike, Script, ScriptLike, Transaction, TransactionLike } from "../../ckb";
|
|
2
|
+
import { ClientTransactionResponse, TransactionStatus } from "../clientTypes";
|
|
3
|
+
import { JsonRpcCellDep, JsonRpcCellInput, JsonRpcCellOutput, JsonRpcDepType, JsonRpcHashType, JsonRpcOutPoint, JsonRpcScript, JsonRpcTransaction } from "./types";
|
|
4
|
+
export declare class JsonRpcTransformers {
|
|
5
|
+
static hashTypeFrom(hashType: HashTypeLike): JsonRpcHashType;
|
|
6
|
+
static hashTypeTo(hashType: JsonRpcHashType): HashType;
|
|
7
|
+
static depTypeFrom(depType: DepTypeLike): JsonRpcDepType;
|
|
8
|
+
static depTypeTo(depType: JsonRpcDepType): DepType;
|
|
9
|
+
static scriptFrom(scriptLike: ScriptLike): JsonRpcScript;
|
|
10
|
+
static scriptTo(script: JsonRpcScript): Script;
|
|
11
|
+
static outPointFrom(outPointLike: OutPointLike): JsonRpcOutPoint;
|
|
12
|
+
static outPointTo(outPoint: JsonRpcOutPoint): OutPoint;
|
|
13
|
+
static cellInputFrom(cellInput: CellInputLike): JsonRpcCellInput;
|
|
14
|
+
static cellInputTo(cellInput: JsonRpcCellInput): CellInput;
|
|
15
|
+
static cellOutputFrom(cellOutput: CellOutputLike): JsonRpcCellOutput;
|
|
16
|
+
static cellOutputTo(cellOutput: JsonRpcCellOutput): CellOutput;
|
|
17
|
+
static cellDepFrom(cellDep: CellDepLike): JsonRpcCellDep;
|
|
18
|
+
static cellDepTo(cellDep: JsonRpcCellDep): CellDep;
|
|
19
|
+
static transactionFrom(txLike: TransactionLike): JsonRpcTransaction;
|
|
20
|
+
static transactionTo(tx: JsonRpcTransaction): Transaction;
|
|
21
|
+
static transactionResponseTo({ tx_status: { status }, transaction, }: {
|
|
22
|
+
tx_status: {
|
|
23
|
+
status: TransactionStatus;
|
|
24
|
+
};
|
|
25
|
+
transaction: JsonRpcTransaction;
|
|
26
|
+
}): ClientTransactionResponse;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/client/jsonRpc/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,WAAW,EACX,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,eAAe,EAGhB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,eAAe;IAG5D,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ;IAGtD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc;IAQxD,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAQlD,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;IAQxD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IAO9C,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,eAAe;IAOhE,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ;IAMtD,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,GAAG,gBAAgB;IAQhE,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,gBAAgB,GAAG,SAAS;IAM1D,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,GAAG,iBAAiB;IAOpE,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,UAAU;IAO9D,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc;IAMxD,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAMlD,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB;IAYnE,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,kBAAkB,GAAG,WAAW;IAWzD,MAAM,CAAC,qBAAqB,CAAC,EAC3B,SAAS,EAAE,EAAE,MAAM,EAAE,EACrB,WAAW,GACZ,EAAE;QACD,SAAS,EAAE;YAAE,MAAM,EAAE,iBAAiB,CAAA;SAAE,CAAC;QACzC,WAAW,EAAE,kBAAkB,CAAC;KACjC,GAAG,yBAAyB;CAM9B"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonRpcTransformers = void 0;
|
|
4
|
+
const ckb_1 = require("../../ckb");
|
|
5
|
+
const num_1 = require("../../num");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
class JsonRpcTransformers {
|
|
8
|
+
static hashTypeFrom(hashType) {
|
|
9
|
+
return (0, ckb_1.hashTypeFrom)(hashType);
|
|
10
|
+
}
|
|
11
|
+
static hashTypeTo(hashType) {
|
|
12
|
+
return hashType;
|
|
13
|
+
}
|
|
14
|
+
static depTypeFrom(depType) {
|
|
15
|
+
switch ((0, ckb_1.depTypeFrom)(depType)) {
|
|
16
|
+
case "code":
|
|
17
|
+
return "code";
|
|
18
|
+
case "depGroup":
|
|
19
|
+
return "dep_group";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
static depTypeTo(depType) {
|
|
23
|
+
switch (depType) {
|
|
24
|
+
case "code":
|
|
25
|
+
return "code";
|
|
26
|
+
case "dep_group":
|
|
27
|
+
return "depGroup";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static scriptFrom(scriptLike) {
|
|
31
|
+
const script = ckb_1.Script.from(scriptLike);
|
|
32
|
+
return {
|
|
33
|
+
code_hash: script.codeHash,
|
|
34
|
+
hash_type: JsonRpcTransformers.hashTypeFrom(script.hashType),
|
|
35
|
+
args: script.args,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
static scriptTo(script) {
|
|
39
|
+
return ckb_1.Script.from({
|
|
40
|
+
codeHash: script.code_hash,
|
|
41
|
+
hashType: JsonRpcTransformers.hashTypeTo(script.hash_type),
|
|
42
|
+
args: script.args,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
static outPointFrom(outPointLike) {
|
|
46
|
+
const outPoint = ckb_1.OutPoint.from(outPointLike);
|
|
47
|
+
return {
|
|
48
|
+
index: (0, num_1.numToHex)(outPoint.index),
|
|
49
|
+
tx_hash: outPoint.txHash,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static outPointTo(outPoint) {
|
|
53
|
+
return ckb_1.OutPoint.from({
|
|
54
|
+
index: outPoint.index,
|
|
55
|
+
txHash: outPoint.tx_hash,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
static cellInputFrom(cellInput) {
|
|
59
|
+
return {
|
|
60
|
+
previous_output: JsonRpcTransformers.outPointFrom(cellInput.previousOutput),
|
|
61
|
+
since: (0, num_1.numToHex)(cellInput.since),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static cellInputTo(cellInput) {
|
|
65
|
+
return ckb_1.CellInput.from({
|
|
66
|
+
previousOutput: JsonRpcTransformers.outPointTo(cellInput.previous_output),
|
|
67
|
+
since: cellInput.since,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
static cellOutputFrom(cellOutput) {
|
|
71
|
+
return {
|
|
72
|
+
capacity: (0, num_1.numToHex)(cellOutput.capacity),
|
|
73
|
+
lock: JsonRpcTransformers.scriptFrom(cellOutput.lock),
|
|
74
|
+
type: (0, utils_1.apply)(JsonRpcTransformers.scriptFrom, cellOutput.type),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static cellOutputTo(cellOutput) {
|
|
78
|
+
return ckb_1.CellOutput.from({
|
|
79
|
+
capacity: cellOutput.capacity,
|
|
80
|
+
lock: JsonRpcTransformers.scriptTo(cellOutput.lock),
|
|
81
|
+
type: (0, utils_1.apply)(JsonRpcTransformers.scriptTo, cellOutput.type),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static cellDepFrom(cellDep) {
|
|
85
|
+
return {
|
|
86
|
+
out_point: JsonRpcTransformers.outPointFrom(cellDep.outPoint),
|
|
87
|
+
dep_type: JsonRpcTransformers.depTypeFrom(cellDep.depType),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
static cellDepTo(cellDep) {
|
|
91
|
+
return ckb_1.CellDep.from({
|
|
92
|
+
outPoint: JsonRpcTransformers.outPointTo(cellDep.out_point),
|
|
93
|
+
depType: JsonRpcTransformers.depTypeTo(cellDep.dep_type),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
static transactionFrom(txLike) {
|
|
97
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
98
|
+
return {
|
|
99
|
+
version: (0, num_1.numToHex)(tx.version),
|
|
100
|
+
cell_deps: tx.cellDeps.map((c) => JsonRpcTransformers.cellDepFrom(c)),
|
|
101
|
+
header_deps: tx.headerDeps,
|
|
102
|
+
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputFrom(i)),
|
|
103
|
+
outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputFrom(o)),
|
|
104
|
+
outputs_data: tx.outputsData,
|
|
105
|
+
witnesses: tx.witnesses,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
static transactionTo(tx) {
|
|
109
|
+
return ckb_1.Transaction.from({
|
|
110
|
+
version: tx.version,
|
|
111
|
+
cellDeps: tx.cell_deps.map((c) => JsonRpcTransformers.cellDepTo(c)),
|
|
112
|
+
headerDeps: tx.header_deps,
|
|
113
|
+
inputs: tx.inputs.map((i) => JsonRpcTransformers.cellInputTo(i)),
|
|
114
|
+
outputs: tx.outputs.map((o) => JsonRpcTransformers.cellOutputTo(o)),
|
|
115
|
+
outputsData: tx.outputs_data,
|
|
116
|
+
witnesses: tx.witnesses,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
static transactionResponseTo({ tx_status: { status }, transaction, }) {
|
|
120
|
+
return {
|
|
121
|
+
transaction: JsonRpcTransformers.transactionTo(transaction),
|
|
122
|
+
status,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.JsonRpcTransformers = JsonRpcTransformers;
|