@ckb-ccc/core 0.0.2-alpha.0

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.
Files changed (117) hide show
  1. package/dist/address/address.d.ts +8 -0
  2. package/dist/address/address.d.ts.map +1 -0
  3. package/dist/address/address.js +6 -0
  4. package/dist/address/addressKnownScript.d.ts +13 -0
  5. package/dist/address/addressKnownScript.d.ts.map +1 -0
  6. package/dist/address/addressKnownScript.js +27 -0
  7. package/dist/address/addressPlain.d.ts +12 -0
  8. package/dist/address/addressPlain.d.ts.map +1 -0
  9. package/dist/address/addressPlain.js +23 -0
  10. package/dist/address/advanced.d.ts +31 -0
  11. package/dist/address/advanced.d.ts.map +1 -0
  12. package/dist/address/advanced.js +63 -0
  13. package/dist/address/converter.d.ts +8 -0
  14. package/dist/address/converter.d.ts.map +1 -0
  15. package/dist/address/converter.js +65 -0
  16. package/dist/address/index.d.ts +6 -0
  17. package/dist/address/index.d.ts.map +1 -0
  18. package/dist/address/index.js +34 -0
  19. package/dist/barrel.d.ts +8 -0
  20. package/dist/barrel.d.ts.map +1 -0
  21. package/dist/barrel.js +23 -0
  22. package/dist/bundle.d.ts +9 -0
  23. package/dist/bundle.d.ts.map +1 -0
  24. package/dist/bundle.js +25 -0
  25. package/dist/ckb/index.d.ts +2 -0
  26. package/dist/ckb/index.d.ts.map +1 -0
  27. package/dist/ckb/index.js +17 -0
  28. package/dist/ckb/viewerCkbAddress.d.ts +14 -0
  29. package/dist/ckb/viewerCkbAddress.d.ts.map +1 -0
  30. package/dist/ckb/viewerCkbAddress.js +28 -0
  31. package/dist/client/client.d.ts +13 -0
  32. package/dist/client/client.d.ts.map +1 -0
  33. package/dist/client/client.js +14 -0
  34. package/dist/client/clientPublicMainnet.advanced.d.ts +4 -0
  35. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -0
  36. package/dist/client/clientPublicMainnet.advanced.js +26 -0
  37. package/dist/client/clientPublicMainnet.d.ts +7 -0
  38. package/dist/client/clientPublicMainnet.d.ts.map +1 -0
  39. package/dist/client/clientPublicMainnet.js +14 -0
  40. package/dist/client/clientPublicTestnet.advanced.d.ts +4 -0
  41. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -0
  42. package/dist/client/clientPublicTestnet.advanced.js +26 -0
  43. package/dist/client/clientPublicTestnet.d.ts +7 -0
  44. package/dist/client/clientPublicTestnet.d.ts.map +1 -0
  45. package/dist/client/clientPublicTestnet.js +14 -0
  46. package/dist/client/index.d.ts +8 -0
  47. package/dist/client/index.d.ts.map +1 -0
  48. package/dist/client/index.js +38 -0
  49. package/dist/codec/bytes.d.ts +4 -0
  50. package/dist/codec/bytes.d.ts.map +1 -0
  51. package/dist/codec/bytes.js +29 -0
  52. package/dist/codec/hashType.d.ts +4 -0
  53. package/dist/codec/hashType.d.ts.map +1 -0
  54. package/dist/codec/hashType.js +13 -0
  55. package/dist/codec/index.d.ts +4 -0
  56. package/dist/codec/index.d.ts.map +1 -0
  57. package/dist/codec/index.js +19 -0
  58. package/dist/codec/script.d.ts +4 -0
  59. package/dist/codec/script.d.ts.map +1 -0
  60. package/dist/codec/script.js +22 -0
  61. package/dist/index.d.ts +3 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +31 -0
  64. package/dist/signer.d.ts +9 -0
  65. package/dist/signer.d.ts.map +1 -0
  66. package/dist/signer.js +12 -0
  67. package/dist/tsconfig.tsbuildinfo +1 -0
  68. package/dist/types/cell.d.ts +5 -0
  69. package/dist/types/cell.d.ts.map +1 -0
  70. package/dist/types/cell.js +8 -0
  71. package/dist/types/ckb.advanced.d.ts +4 -0
  72. package/dist/types/ckb.advanced.d.ts.map +1 -0
  73. package/dist/types/ckb.advanced.js +15 -0
  74. package/dist/types/ckb.d.ts +16 -0
  75. package/dist/types/ckb.d.ts.map +1 -0
  76. package/dist/types/ckb.js +36 -0
  77. package/dist/types/index.d.ts +9 -0
  78. package/dist/types/index.d.ts.map +1 -0
  79. package/dist/types/index.js +37 -0
  80. package/dist/types/lumos.d.ts +90 -0
  81. package/dist/types/lumos.d.ts.map +1 -0
  82. package/dist/types/lumos.js +2 -0
  83. package/dist/types/primitive.d.ts +3 -0
  84. package/dist/types/primitive.d.ts.map +1 -0
  85. package/dist/types/primitive.js +2 -0
  86. package/dist/viewer.d.ts +9 -0
  87. package/dist/viewer.d.ts.map +1 -0
  88. package/dist/viewer.js +6 -0
  89. package/package.json +35 -0
  90. package/src/address/address.ts +9 -0
  91. package/src/address/addressKnownScript.ts +31 -0
  92. package/src/address/addressPlain.ts +27 -0
  93. package/src/address/advanced.ts +74 -0
  94. package/src/address/converter.ts +93 -0
  95. package/src/address/index.ts +5 -0
  96. package/src/barrel.ts +7 -0
  97. package/src/ckb/index.ts +1 -0
  98. package/src/ckb/viewerCkbAddress.ts +34 -0
  99. package/src/client/client.ts +14 -0
  100. package/src/client/clientPublicMainnet.advanced.ts +30 -0
  101. package/src/client/clientPublicMainnet.ts +13 -0
  102. package/src/client/clientPublicTestnet.advanced.ts +30 -0
  103. package/src/client/clientPublicTestnet.ts +13 -0
  104. package/src/client/index.ts +10 -0
  105. package/src/codec/bytes.ts +30 -0
  106. package/src/codec/hashType.ts +10 -0
  107. package/src/codec/index.ts +3 -0
  108. package/src/codec/script.ts +21 -0
  109. package/src/index.ts +2 -0
  110. package/src/signer.ts +20 -0
  111. package/src/types/cell.ts +5 -0
  112. package/src/types/ckb.advanced.ts +14 -0
  113. package/src/types/ckb.ts +47 -0
  114. package/src/types/index.ts +9 -0
  115. package/src/types/lumos.ts +101 -0
  116. package/src/types/primitive.ts +2 -0
  117. package/src/viewer.ts +14 -0
@@ -0,0 +1,8 @@
1
+ import { Client } from "../client";
2
+ import { Script } from "../types";
3
+ export declare abstract class Address {
4
+ abstract getClient(): Promise<Client>;
5
+ abstract getAddress(): Promise<string>;
6
+ abstract getScript(): Promise<Script>;
7
+ }
8
+ //# sourceMappingURL=address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,8BAAsB,OAAO;IAC3B,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAErC,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IACtC,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CACtC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Address = void 0;
4
+ class Address {
5
+ }
6
+ exports.Address = Address;
@@ -0,0 +1,13 @@
1
+ import { Client, KnownScript } from "../client";
2
+ import { Script } from "../types";
3
+ import { Address } from "./address";
4
+ export declare class AddressKnownScript extends Address {
5
+ private readonly script;
6
+ private readonly args;
7
+ private readonly client;
8
+ constructor(script: KnownScript, args: Script["args"], client: Client);
9
+ getClient(): Promise<Client>;
10
+ getAddress(): Promise<string>;
11
+ getScript(): Promise<Script>;
12
+ }
13
+ //# sourceMappingURL=addressKnownScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressKnownScript.d.ts","sourceRoot":"","sources":["../../src/address/addressKnownScript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,qBAAa,kBAAmB,SAAQ,OAAO;IAE3C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EACpB,MAAM,EAAE,MAAM;IAK3B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAM7B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CAMnC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddressKnownScript = void 0;
4
+ const address_1 = require("./address");
5
+ const converter_1 = require("./converter");
6
+ class AddressKnownScript extends address_1.Address {
7
+ constructor(script, args, client) {
8
+ super();
9
+ this.script = script;
10
+ this.args = args;
11
+ this.client = client;
12
+ }
13
+ async getClient() {
14
+ return this.client;
15
+ }
16
+ async getAddress() {
17
+ const prefix = await (await this.getClient()).getAddressPrefix();
18
+ return (0, converter_1.encodeScriptToAddress)(prefix, await this.getScript());
19
+ }
20
+ async getScript() {
21
+ return {
22
+ ...(await this.client.getKnownScript(this.script)),
23
+ args: this.args,
24
+ };
25
+ }
26
+ }
27
+ exports.AddressKnownScript = AddressKnownScript;
@@ -0,0 +1,12 @@
1
+ import { Client } from "../client";
2
+ import { Script } from "../types";
3
+ import { Address } from "./address";
4
+ export declare class AddressPlain extends Address {
5
+ private readonly script;
6
+ private readonly client;
7
+ constructor(script: Script, client: Client);
8
+ getClient(): Promise<Client>;
9
+ getAddress(): Promise<string>;
10
+ getScript(): Promise<Script>;
11
+ }
12
+ //# sourceMappingURL=addressPlain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressPlain.d.ts","sourceRoot":"","sources":["../../src/address/addressPlain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,qBAAa,YAAa,SAAQ,OAAO;IAErC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAK3B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAM7B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CAGnC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddressPlain = void 0;
4
+ const address_1 = require("./address");
5
+ const converter_1 = require("./converter");
6
+ class AddressPlain extends address_1.Address {
7
+ constructor(script, client) {
8
+ super();
9
+ this.script = script;
10
+ this.client = client;
11
+ }
12
+ async getClient() {
13
+ return this.client;
14
+ }
15
+ async getAddress() {
16
+ const prefix = await (await this.getClient()).getAddressPrefix();
17
+ return (0, converter_1.encodeScriptToAddress)(prefix, this.script);
18
+ }
19
+ async getScript() {
20
+ return this.script;
21
+ }
22
+ }
23
+ exports.AddressPlain = AddressPlain;
@@ -0,0 +1,31 @@
1
+ import { Client } from "../client";
2
+ export declare const BECH32_LIMIT = 1023;
3
+ export declare enum AddressFormat {
4
+ /**
5
+ * full version identifies the hashType
6
+ */
7
+ Full = 0,
8
+ /**
9
+ * @deprecated
10
+ * short version for locks with Known codeHash, deprecated
11
+ */
12
+ Short = 1,
13
+ /**
14
+ * @deprecated
15
+ * full version with hashType = "Data", deprecated
16
+ */
17
+ FullData = 2,
18
+ /**
19
+ * @deprecated
20
+ * full version with hashType = "Type", deprecated
21
+ */
22
+ FullType = 4
23
+ }
24
+ export declare function parseAddress(address: string): {
25
+ prefix: string;
26
+ format: AddressFormat;
27
+ body: number[];
28
+ };
29
+ export declare function decodeAddressInfo(format: AddressFormat, body: number[]): void;
30
+ export declare function getClientFromAddressPrefix(prefix: string): Client | undefined;
31
+ //# sourceMappingURL=advanced.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/address/advanced.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,oBAAY,aAAa;IACvB;;OAEG;IACH,IAAI,IAAO;IACX;;;OAGG;IACH,KAAK,IAAO;IACZ;;;OAGG;IACH,QAAQ,IAAO;IACf;;;OAGG;IACH,QAAQ,IAAO;CAChB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CA2BA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,QAAI;AAE3E,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ7E"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getClientFromAddressPrefix = exports.decodeAddressInfo = exports.parseAddress = exports.AddressFormat = exports.BECH32_LIMIT = void 0;
4
+ const bech32_1 = require("bech32");
5
+ const client_1 = require("../client");
6
+ exports.BECH32_LIMIT = 1023;
7
+ var AddressFormat;
8
+ (function (AddressFormat) {
9
+ /**
10
+ * full version identifies the hashType
11
+ */
12
+ AddressFormat[AddressFormat["Full"] = 0] = "Full";
13
+ /**
14
+ * @deprecated
15
+ * short version for locks with Known codeHash, deprecated
16
+ */
17
+ AddressFormat[AddressFormat["Short"] = 1] = "Short";
18
+ /**
19
+ * @deprecated
20
+ * full version with hashType = "Data", deprecated
21
+ */
22
+ AddressFormat[AddressFormat["FullData"] = 2] = "FullData";
23
+ /**
24
+ * @deprecated
25
+ * full version with hashType = "Type", deprecated
26
+ */
27
+ AddressFormat[AddressFormat["FullType"] = 4] = "FullType";
28
+ })(AddressFormat || (exports.AddressFormat = AddressFormat = {}));
29
+ function parseAddress(address) {
30
+ // Try parse full format address
31
+ {
32
+ const { words, prefix } = bech32_1.bech32m.decode(address, exports.BECH32_LIMIT);
33
+ const [formatType, ...body] = bech32_1.bech32m.fromWords(words);
34
+ if (formatType === AddressFormat.Full) {
35
+ return { prefix, format: AddressFormat.Full, body };
36
+ }
37
+ }
38
+ // Try parse legacy 2019 format address
39
+ {
40
+ const { prefix, words } = bech32_1.bech32.decode(address, exports.BECH32_LIMIT);
41
+ const [formatType, ...body] = bech32_1.bech32.fromWords(words);
42
+ if ([
43
+ AddressFormat.FullData,
44
+ AddressFormat.FullType,
45
+ AddressFormat.Short,
46
+ ].includes(formatType)) {
47
+ return { prefix, format: formatType, body };
48
+ }
49
+ }
50
+ throw Error(`Unknown address format ${address}`);
51
+ }
52
+ exports.parseAddress = parseAddress;
53
+ function decodeAddressInfo(format, body) { }
54
+ exports.decodeAddressInfo = decodeAddressInfo;
55
+ function getClientFromAddressPrefix(prefix) {
56
+ if (prefix === "ckb") {
57
+ return new client_1.ClientPublicMainnet();
58
+ }
59
+ if (prefix === "ckt") {
60
+ return new client_1.ClientPublicTestnet();
61
+ }
62
+ }
63
+ exports.getClientFromAddressPrefix = getClientFromAddressPrefix;
@@ -0,0 +1,8 @@
1
+ import { Client } from "../client";
2
+ import { Script } from "../types";
3
+ import { AddressPlain } from "./addressPlain";
4
+ import { Address } from "./address";
5
+ export declare function decodeAddressFromString(address: string, getClient?: (prefix: string) => Client | undefined): Address;
6
+ export declare function decodeAddressFromScript(script: Script, client: Client): AddressPlain;
7
+ export declare function encodeScriptToAddress(prefix: string, script: Script): string;
8
+ //# sourceMappingURL=converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../src/address/converter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GACjD,OAAO,CA8DT;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,YAAY,CAEd;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAInE"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeScriptToAddress = exports.decodeAddressFromScript = exports.decodeAddressFromString = void 0;
4
+ const client_1 = require("../client");
5
+ const codec_1 = require("../codec");
6
+ const addressPlain_1 = require("./addressPlain");
7
+ const advanced_1 = require("./advanced");
8
+ const addressKnownScript_1 = require("./addressKnownScript");
9
+ const bech32_1 = require("bech32");
10
+ function decodeAddressFromString(address, getClient) {
11
+ const { prefix, format, body } = (0, advanced_1.parseAddress)(address);
12
+ const client = getClient?.(prefix) ?? (0, advanced_1.getClientFromAddressPrefix)(prefix);
13
+ if (!client) {
14
+ throw new Error(`Unknown address prefix ${prefix}`);
15
+ }
16
+ if (format === advanced_1.AddressFormat.Full) {
17
+ if (body.length < 32 + 1) {
18
+ throw new Error(`Invalid address without enough payload ${address}`);
19
+ }
20
+ return new addressPlain_1.AddressPlain((0, codec_1.decodeScript)(body), client);
21
+ }
22
+ if (format === advanced_1.AddressFormat.FullData) {
23
+ if (body.length < 32) {
24
+ throw new Error(`Invalid address without enough payload ${address}`);
25
+ }
26
+ return new addressPlain_1.AddressPlain({
27
+ codeHash: (0, codec_1.toHex)(body.slice(0, 32)),
28
+ hashType: "data",
29
+ args: (0, codec_1.toHex)(body.slice(32)),
30
+ }, client);
31
+ }
32
+ if (format === advanced_1.AddressFormat.FullType) {
33
+ if (body.length < 32) {
34
+ throw new Error(`Invalid address without enough payload ${address}`);
35
+ }
36
+ return new addressPlain_1.AddressPlain({
37
+ codeHash: (0, codec_1.toHex)(body.slice(0, 32)),
38
+ hashType: "type",
39
+ args: (0, codec_1.toHex)(body.slice(32)),
40
+ }, client);
41
+ }
42
+ // format === AddressFormat.Short
43
+ if (body.length !== 21) {
44
+ throw new Error(`Invalid address without enough payload ${address}`);
45
+ }
46
+ const script = [
47
+ client_1.KnownScript.Secp256k1Blake160,
48
+ client_1.KnownScript.Secp256k1Multisig,
49
+ client_1.KnownScript.AnyoneCanPay,
50
+ ][body[0]];
51
+ if (script === undefined) {
52
+ throw new Error(`Invalid short format address with unknown script ${address}`);
53
+ }
54
+ return new addressKnownScript_1.AddressKnownScript(script, (0, codec_1.toHex)(body.slice(1)), client);
55
+ }
56
+ exports.decodeAddressFromString = decodeAddressFromString;
57
+ function decodeAddressFromScript(script, client) {
58
+ return new addressPlain_1.AddressPlain(script, client);
59
+ }
60
+ exports.decodeAddressFromScript = decodeAddressFromScript;
61
+ function encodeScriptToAddress(prefix, script) {
62
+ const data = [advanced_1.AddressFormat.Full, ...(0, codec_1.encodeScript)(script)];
63
+ return bech32_1.bech32m.encode(prefix, bech32_1.bech32m.toWords(data), advanced_1.BECH32_LIMIT);
64
+ }
65
+ exports.encodeScriptToAddress = encodeScriptToAddress;
@@ -0,0 +1,6 @@
1
+ export * from "./address";
2
+ export * from "./addressPlain";
3
+ export * from "./addressKnownScript";
4
+ export * as AdvancedAddress from "./advanced";
5
+ export * from "./converter";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,eAAe,MAAM,YAAY,CAAC;AAC9C,cAAc,aAAa,CAAC"}
@@ -0,0 +1,34 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.AdvancedAddress = void 0;
30
+ __exportStar(require("./address"), exports);
31
+ __exportStar(require("./addressPlain"), exports);
32
+ __exportStar(require("./addressKnownScript"), exports);
33
+ exports.AdvancedAddress = __importStar(require("./advanced"));
34
+ __exportStar(require("./converter"), exports);
@@ -0,0 +1,8 @@
1
+ export * from "./address";
2
+ export * from "./ckb";
3
+ export * from "./client";
4
+ export * from "./codec";
5
+ export * from "./types";
6
+ export * from "./signer";
7
+ export * from "./viewer";
8
+ //# sourceMappingURL=barrel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
package/dist/barrel.js ADDED
@@ -0,0 +1,23 @@
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("./address"), exports);
18
+ __exportStar(require("./ckb"), exports);
19
+ __exportStar(require("./client"), exports);
20
+ __exportStar(require("./codec"), exports);
21
+ __exportStar(require("./types"), exports);
22
+ __exportStar(require("./signer"), exports);
23
+ __exportStar(require("./viewer"), exports);
@@ -0,0 +1,9 @@
1
+ export * from "./address";
2
+ export * from "./ckb";
3
+ export * from "./client";
4
+ export * from "./codec";
5
+ export * from "./types";
6
+ export * from "./signer";
7
+ export * from "./viewer";
8
+ export declare const test = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
9
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,eAAO,MAAM,IAAI,qgCACm/B,CAAC"}
package/dist/bundle.js ADDED
@@ -0,0 +1,25 @@
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
+ exports.test = void 0;
18
+ __exportStar(require("./address"), exports);
19
+ __exportStar(require("./ckb"), exports);
20
+ __exportStar(require("./client"), exports);
21
+ __exportStar(require("./codec"), exports);
22
+ __exportStar(require("./types"), exports);
23
+ __exportStar(require("./signer"), exports);
24
+ __exportStar(require("./viewer"), exports);
25
+ exports.test = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
@@ -0,0 +1,2 @@
1
+ export * from "./viewerCkbAddress";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./viewerCkbAddress"), exports);
@@ -0,0 +1,14 @@
1
+ import { Client } from "../client";
2
+ import { Script } from "../types";
3
+ import { Viewer } from "../viewer";
4
+ import { TransactionSkeletonType } from "../types/lumos";
5
+ export declare class ViewerCkbAddress extends Viewer {
6
+ private readonly script;
7
+ private readonly client;
8
+ constructor(script: Script, client: Client);
9
+ getClient(): Promise<Client>;
10
+ getRecommendedAddress(): Promise<string>;
11
+ getAddresses(): Promise<string[]>;
12
+ completeLumosTransaction(tx: TransactionSkeletonType): Promise<TransactionSkeletonType>;
13
+ }
14
+ //# sourceMappingURL=viewerCkbAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewerCkbAddress.d.ts","sourceRoot":"","sources":["../../src/ckb/viewerCkbAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,qBAAa,gBAAiB,SAAQ,MAAM;IAExC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAK3B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;IAGxC,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAOjC,wBAAwB,CAC5B,EAAE,EAAE,uBAAuB,GAC1B,OAAO,CAAC,uBAAuB,CAAC;CAGpC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewerCkbAddress = void 0;
4
+ const address_1 = require("../address");
5
+ const viewer_1 = require("../viewer");
6
+ class ViewerCkbAddress extends viewer_1.Viewer {
7
+ constructor(script, client) {
8
+ super();
9
+ this.script = script;
10
+ this.client = client;
11
+ }
12
+ async getClient() {
13
+ return this.client;
14
+ }
15
+ async getRecommendedAddress() {
16
+ return (await this.getAddresses())[0];
17
+ }
18
+ async getAddresses() {
19
+ return [
20
+ (0, address_1.encodeScriptToAddress)(await this.client.getAddressPrefix(), this.script),
21
+ ];
22
+ }
23
+ // Will be deprecated in the future
24
+ async completeLumosTransaction(tx) {
25
+ return tx;
26
+ }
27
+ }
28
+ exports.ViewerCkbAddress = ViewerCkbAddress;
@@ -0,0 +1,13 @@
1
+ import { Script } from "../types";
2
+ export declare enum KnownScript {
3
+ Secp256k1Blake160 = 0,
4
+ Secp256k1Multisig = 1,
5
+ AnyoneCanPay = 2,
6
+ JoyId = 3,
7
+ OmniLock = 4
8
+ }
9
+ export declare abstract class Client {
10
+ abstract getAddressPrefix(): Promise<string>;
11
+ abstract getKnownScript(script: KnownScript): Promise<Omit<Script, "args">>;
12
+ }
13
+ //# 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,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,oBAAY,WAAW;IACrB,iBAAiB,IAAA;IACjB,iBAAiB,IAAA;IACjB,YAAY,IAAA;IACZ,KAAK,IAAA;IACL,QAAQ,IAAA;CACT;AAED,8BAAsB,MAAM;IAC1B,QAAQ,CAAC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAC5C,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5E"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = exports.KnownScript = void 0;
4
+ var KnownScript;
5
+ (function (KnownScript) {
6
+ KnownScript[KnownScript["Secp256k1Blake160"] = 0] = "Secp256k1Blake160";
7
+ KnownScript[KnownScript["Secp256k1Multisig"] = 1] = "Secp256k1Multisig";
8
+ KnownScript[KnownScript["AnyoneCanPay"] = 2] = "AnyoneCanPay";
9
+ KnownScript[KnownScript["JoyId"] = 3] = "JoyId";
10
+ KnownScript[KnownScript["OmniLock"] = 4] = "OmniLock";
11
+ })(KnownScript || (exports.KnownScript = KnownScript = {}));
12
+ class Client {
13
+ }
14
+ exports.Client = Client;
@@ -0,0 +1,4 @@
1
+ import { Script } from "../types";
2
+ import { KnownScript } from "./client";
3
+ export declare const MAINNET_SCRIPTS: Record<KnownScript, Omit<Script, "args">>;
4
+ //# sourceMappingURL=clientPublicMainnet.advanced.d.ts.map
@@ -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,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BrE,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,7 @@
1
+ import { Script } from "../types";
2
+ import { Client, KnownScript } from "./client";
3
+ export declare class ClientPublicMainnet extends Client {
4
+ getAddressPrefix(): Promise<string>;
5
+ getKnownScript(script: KnownScript): Promise<Omit<Script, "args">>;
6
+ }
7
+ //# 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,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG/C,qBAAa,mBAAoB,SAAQ,MAAM;IACvC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAGzE"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientPublicMainnet = void 0;
4
+ const client_1 = require("./client");
5
+ const clientPublicMainnet_advanced_1 = require("./clientPublicMainnet.advanced");
6
+ class ClientPublicMainnet extends client_1.Client {
7
+ async getAddressPrefix() {
8
+ return "ckb";
9
+ }
10
+ async getKnownScript(script) {
11
+ return clientPublicMainnet_advanced_1.MAINNET_SCRIPTS[script];
12
+ }
13
+ }
14
+ exports.ClientPublicMainnet = ClientPublicMainnet;
@@ -0,0 +1,4 @@
1
+ import { Script } from "../types";
2
+ import { KnownScript } from "./client";
3
+ export declare const TESTNET_SCRIPTS: Record<KnownScript, Omit<Script, "args">>;
4
+ //# sourceMappingURL=clientPublicTestnet.advanced.d.ts.map
@@ -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,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BrE,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,7 @@
1
+ import { Script } from "../types";
2
+ import { Client, KnownScript } from "./client";
3
+ export declare class ClientPublicTestnet extends Client {
4
+ getAddressPrefix(): Promise<string>;
5
+ getKnownScript(script: KnownScript): Promise<Omit<Script, "args">>;
6
+ }
7
+ //# sourceMappingURL=clientPublicTestnet.d.ts.map