@ckb-ccc/uni-sat 0.0.7-alpha.2 → 0.0.8-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,11 +21,13 @@
21
21
  </p>
22
22
 
23
23
  <p align="center">
24
- "Common Chains Connector" is where CCC begins.
24
+ "CCC - CKBers' Codebase" is the next step of "Common Chains Connector".
25
25
  <br />
26
- CCC helps you to interoperate wallets from different chain ecosystems with CKB,
26
+ Empower yourself with CCC to discover the unlimited potential of CKB.
27
27
  <br />
28
- fully enabling CKB's cryptographic freedom power.
28
+ Interoperate with wallets from different chain ecosystems.
29
+ <br />
30
+ Fully enabling CKB's Turing completeness and cryptographic freedom power.
29
31
  </p>
30
32
 
31
33
  ## Preview
@@ -36,7 +38,7 @@
36
38
  </a>
37
39
  </p>
38
40
 
39
- This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc-demo.vercel.app/).
41
+ This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc-demo.vercel.app/). It showcases how to use CCC for some basic scenarios in CKB.
40
42
 
41
43
  <h3 align="center">
42
44
  Read more about CCC on its <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
@@ -1,2 +1,2 @@
1
1
  export * as UniSatA from "./advancedBarrel";
2
- //# sourceMappingURL=advanced.d.ts.map
2
+ //# sourceMappingURL=advanced.d.ts.map
@@ -1,27 +1,48 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __setModuleDefault =
26
+ (this && this.__setModuleDefault) ||
27
+ (Object.create
28
+ ? function (o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }
31
+ : function (o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar =
35
+ (this && this.__importStar) ||
36
+ function (mod) {
19
37
  if (mod && mod.__esModule) return mod;
20
38
  var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
+ if (mod != null)
40
+ for (var k in mod)
41
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
42
+ __createBinding(result, mod, k);
22
43
  __setModuleDefault(result, mod);
23
44
  return result;
24
- };
45
+ };
25
46
  Object.defineProperty(exports, "__esModule", { value: true });
26
47
  exports.UniSatA = void 0;
27
48
  exports.UniSatA = __importStar(require("./advancedBarrel"));
@@ -3,52 +3,55 @@
3
3
  * @interface
4
4
  */
5
5
  export interface Provider {
6
- /**
7
- * Requests user accounts.
8
- * @returns {Promise<string[]>} A promise that resolves to an array of account addresses.
9
- */
10
- requestAccounts(): Promise<string[]>;
11
- /**
12
- * Gets the current accounts.
13
- * @returns {Promise<string[]>} A promise that resolves to an array of account addresses.
14
- */
15
- getAccounts(): Promise<string[]>;
16
- /**
17
- * Gets the public key of the account.
18
- * @returns {Promise<string>} A promise that resolves to the public key.
19
- */
20
- getPublicKey(): Promise<string>;
21
- /**
22
- * Signs a message with the specified type.
23
- * @param {string} msg - The message to sign.
24
- * @param {"ecdsa" | "bip322-simple"} type - The type of signature.
25
- * @returns {Promise<string>} A promise that resolves to the signed message.
26
- */
27
- signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise<string>;
28
- /**
29
- * Adds an event listener to the provider.
30
- * @type {OnMethod}
31
- */
32
- on: OnMethod;
33
- /**
34
- * Removes an event listener from the provider.
35
- * @param {string} eventName - The name of the event to remove the listener from.
36
- * @param {(...args: unknown[]) => unknown} listener - The listener function to remove.
37
- * @returns {Provider} The provider instance.
38
- */
39
- removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
6
+ /**
7
+ * Requests user accounts.
8
+ * @returns {Promise<string[]>} A promise that resolves to an array of account addresses.
9
+ */
10
+ requestAccounts(): Promise<string[]>;
11
+ /**
12
+ * Gets the current accounts.
13
+ * @returns {Promise<string[]>} A promise that resolves to an array of account addresses.
14
+ */
15
+ getAccounts(): Promise<string[]>;
16
+ /**
17
+ * Gets the public key of the account.
18
+ * @returns {Promise<string>} A promise that resolves to the public key.
19
+ */
20
+ getPublicKey(): Promise<string>;
21
+ /**
22
+ * Signs a message with the specified type.
23
+ * @param {string} msg - The message to sign.
24
+ * @param {"ecdsa" | "bip322-simple"} type - The type of signature.
25
+ * @returns {Promise<string>} A promise that resolves to the signed message.
26
+ */
27
+ signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise<string>;
28
+ /**
29
+ * Adds an event listener to the provider.
30
+ * @type {OnMethod}
31
+ */
32
+ on: OnMethod;
33
+ /**
34
+ * Removes an event listener from the provider.
35
+ * @param {string} eventName - The name of the event to remove the listener from.
36
+ * @param {(...args: unknown[]) => unknown} listener - The listener function to remove.
37
+ * @returns {Provider} The provider instance.
38
+ */
39
+ removeListener(
40
+ eventName: string,
41
+ listener: (...args: unknown[]) => unknown,
42
+ ): Provider;
40
43
  }
41
44
  /**
42
45
  * Interface representing a method to add event listeners to the provider.
43
46
  * @interface
44
47
  */
45
48
  export interface OnMethod {
46
- /**
47
- * Adds an event listener to the provider.
48
- * @param {string} eventName - The name of the event.
49
- * @param {(...args: unknown[]) => unknown} listener - The listener function.
50
- * @returns {Provider} The provider instance.
51
- */
52
- (eventName: string, listener: (...args: unknown[]) => unknown): Provider;
49
+ /**
50
+ * Adds an event listener to the provider.
51
+ * @param {string} eventName - The name of the event.
52
+ * @param {(...args: unknown[]) => unknown} listener - The listener function.
53
+ * @returns {Provider} The provider instance.
54
+ */
55
+ (eventName: string, listener: (...args: unknown[]) => unknown): Provider;
53
56
  }
54
- //# sourceMappingURL=advancedBarrel.d.ts.map
57
+ //# sourceMappingURL=advancedBarrel.d.ts.map
@@ -1,3 +1,3 @@
1
1
  export * from "./signer";
2
2
  export * from "./signersFactory";
3
- //# sourceMappingURL=barrel.d.ts.map
3
+ //# sourceMappingURL=barrel.d.ts.map
@@ -1,18 +1,34 @@
1
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
- };
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __exportStar =
26
+ (this && this.__exportStar) ||
27
+ function (m, exports) {
28
+ for (var p in m)
29
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
30
+ __createBinding(exports, m, p);
31
+ };
16
32
  Object.defineProperty(exports, "__esModule", { value: true });
17
33
  __exportStar(require("./signer"), exports);
18
34
  __exportStar(require("./signersFactory"), exports);
@@ -1,2 +1,2 @@
1
1
  export * as UniSat from "./barrel";
2
- //# sourceMappingURL=index.d.ts.map
2
+ //# sourceMappingURL=index.d.ts.map
@@ -1,27 +1,48 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __setModuleDefault =
26
+ (this && this.__setModuleDefault) ||
27
+ (Object.create
28
+ ? function (o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }
31
+ : function (o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar =
35
+ (this && this.__importStar) ||
36
+ function (mod) {
19
37
  if (mod && mod.__esModule) return mod;
20
38
  var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
+ if (mod != null)
40
+ for (var k in mod)
41
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
42
+ __createBinding(result, mod, k);
22
43
  __setModuleDefault(result, mod);
23
44
  return result;
24
- };
45
+ };
25
46
  Object.defineProperty(exports, "__esModule", { value: true });
26
47
  exports.UniSat = void 0;
27
48
  exports.UniSat = __importStar(require("./barrel"));
@@ -6,38 +6,38 @@ import { Provider } from "./advancedBarrel";
6
6
  * @extends {ccc.SignerBtc}
7
7
  */
8
8
  export declare class Signer extends ccc.SignerBtc {
9
- readonly provider: Provider;
10
- /**
11
- * Creates an instance of Signer.
12
- * @param {ccc.Client} client - The client instance.
13
- * @param {Provider} provider - The provider instance.
14
- */
15
- constructor(client: ccc.Client, provider: Provider);
16
- /**
17
- * Gets the Bitcoin account address.
18
- * @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
19
- */
20
- getBtcAccount(): Promise<string>;
21
- /**
22
- * Gets the Bitcoin public key.
23
- * @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
24
- */
25
- getBtcPublicKey(): Promise<ccc.Hex>;
26
- /**
27
- * Connects to the provider by requesting accounts.
28
- * @returns {Promise<void>} A promise that resolves when the connection is established.
29
- */
30
- connect(): Promise<void>;
31
- /**
32
- * Checks if the signer is connected.
33
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
34
- */
35
- isConnected(): Promise<boolean>;
36
- /**
37
- * Signs a raw message with the Bitcoin account.
38
- * @param {string | ccc.BytesLike} message - The message to sign.
39
- * @returns {Promise<string>} A promise that resolves to the signed message.
40
- */
41
- signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
9
+ readonly provider: Provider;
10
+ /**
11
+ * Creates an instance of Signer.
12
+ * @param {ccc.Client} client - The client instance.
13
+ * @param {Provider} provider - The provider instance.
14
+ */
15
+ constructor(client: ccc.Client, provider: Provider);
16
+ /**
17
+ * Gets the Bitcoin account address.
18
+ * @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
19
+ */
20
+ getBtcAccount(): Promise<string>;
21
+ /**
22
+ * Gets the Bitcoin public key.
23
+ * @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
24
+ */
25
+ getBtcPublicKey(): Promise<ccc.Hex>;
26
+ /**
27
+ * Connects to the provider by requesting accounts.
28
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
29
+ */
30
+ connect(): Promise<void>;
31
+ /**
32
+ * Checks if the signer is connected.
33
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
34
+ */
35
+ isConnected(): Promise<boolean>;
36
+ /**
37
+ * Signs a raw message with the Bitcoin account.
38
+ * @param {string | ccc.BytesLike} message - The message to sign.
39
+ * @returns {Promise<string>} A promise that resolves to the signed message.
40
+ */
41
+ signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
42
42
  }
43
- //# sourceMappingURL=signer.d.ts.map
43
+ //# sourceMappingURL=signer.d.ts.map
@@ -8,51 +8,54 @@ const core_1 = require("@ckb-ccc/core");
8
8
  * @extends {ccc.SignerBtc}
9
9
  */
10
10
  class Signer extends core_1.ccc.SignerBtc {
11
- /**
12
- * Creates an instance of Signer.
13
- * @param {ccc.Client} client - The client instance.
14
- * @param {Provider} provider - The provider instance.
15
- */
16
- constructor(client, provider) {
17
- super(client);
18
- this.provider = provider;
19
- }
20
- /**
21
- * Gets the Bitcoin account address.
22
- * @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
23
- */
24
- async getBtcAccount() {
25
- return (await this.provider.getAccounts())[0];
26
- }
27
- /**
28
- * Gets the Bitcoin public key.
29
- * @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
30
- */
31
- async getBtcPublicKey() {
32
- return core_1.ccc.hexFrom(await this.provider.getPublicKey());
33
- }
34
- /**
35
- * Connects to the provider by requesting accounts.
36
- * @returns {Promise<void>} A promise that resolves when the connection is established.
37
- */
38
- async connect() {
39
- await this.provider.requestAccounts();
40
- }
41
- /**
42
- * Checks if the signer is connected.
43
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
44
- */
45
- async isConnected() {
46
- return (await this.provider.getAccounts()).length !== 0;
47
- }
48
- /**
49
- * Signs a raw message with the Bitcoin account.
50
- * @param {string | ccc.BytesLike} message - The message to sign.
51
- * @returns {Promise<string>} A promise that resolves to the signed message.
52
- */
53
- async signMessageRaw(message) {
54
- const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
55
- return this.provider.signMessage(challenge, "ecdsa");
56
- }
11
+ /**
12
+ * Creates an instance of Signer.
13
+ * @param {ccc.Client} client - The client instance.
14
+ * @param {Provider} provider - The provider instance.
15
+ */
16
+ constructor(client, provider) {
17
+ super(client);
18
+ this.provider = provider;
19
+ }
20
+ /**
21
+ * Gets the Bitcoin account address.
22
+ * @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
23
+ */
24
+ async getBtcAccount() {
25
+ return (await this.provider.getAccounts())[0];
26
+ }
27
+ /**
28
+ * Gets the Bitcoin public key.
29
+ * @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
30
+ */
31
+ async getBtcPublicKey() {
32
+ return core_1.ccc.hexFrom(await this.provider.getPublicKey());
33
+ }
34
+ /**
35
+ * Connects to the provider by requesting accounts.
36
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
37
+ */
38
+ async connect() {
39
+ await this.provider.requestAccounts();
40
+ }
41
+ /**
42
+ * Checks if the signer is connected.
43
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
44
+ */
45
+ async isConnected() {
46
+ return (await this.provider.getAccounts()).length !== 0;
47
+ }
48
+ /**
49
+ * Signs a raw message with the Bitcoin account.
50
+ * @param {string | ccc.BytesLike} message - The message to sign.
51
+ * @returns {Promise<string>} A promise that resolves to the signed message.
52
+ */
53
+ async signMessageRaw(message) {
54
+ const challenge =
55
+ typeof message === "string"
56
+ ? message
57
+ : core_1.ccc.hexFrom(message).slice(2);
58
+ return this.provider.signMessage(challenge, "ecdsa");
59
+ }
57
60
  }
58
61
  exports.Signer = Signer;
@@ -6,4 +6,4 @@ import { Signer } from "./signer";
6
6
  * @returns {Signer | undefined} The Signer instance if the UniSat provider is available, otherwise undefined.
7
7
  */
8
8
  export declare function getUniSatSigner(client: ccc.Client): Signer | undefined;
9
- //# sourceMappingURL=signersFactory.d.ts.map
9
+ //# sourceMappingURL=signersFactory.d.ts.map
@@ -8,10 +8,10 @@ const signer_1 = require("./signer");
8
8
  * @returns {Signer | undefined} The Signer instance if the UniSat provider is available, otherwise undefined.
9
9
  */
10
10
  function getUniSatSigner(client) {
11
- const windowRef = window;
12
- if (typeof windowRef.unisat === "undefined") {
13
- return undefined;
14
- }
15
- return new signer_1.Signer(client, windowRef.unisat);
11
+ const windowRef = window;
12
+ if (typeof windowRef.unisat === "undefined") {
13
+ return undefined;
14
+ }
15
+ return new signer_1.Signer(client, windowRef.unisat);
16
16
  }
17
17
  exports.getUniSatSigner = getUniSatSigner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/uni-sat",
3
- "version": "0.0.7-alpha.2",
3
+ "version": "0.0.8-alpha.3",
4
4
  "description": "Common Chains Connector's support for UniSat",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@ckb-ccc/core": "0.0.7-alpha.2"
53
+ "@ckb-ccc/core": "0.0.8-alpha.3"
54
54
  },
55
- "gitHead": "4b773c10f39944c6380d556dbf0b35e911935d13"
55
+ "gitHead": "bddfa3e5631252194dfde32b79ee589703f18afb"
56
56
  }