@ckb-ccc/eip6963 0.0.10-alpha.0 → 0.0.10-alpha.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.
@@ -1,3 +1,3 @@
1
1
  export * as Eip1193A from "./eip1193.advanced";
2
2
  export * as Eip6963A from "./eip6963.advanced";
3
- //# sourceMappingURL=advanced.d.ts.map
3
+ //# 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.Eip6963A = exports.Eip1193A = void 0;
27
48
  exports.Eip1193A = __importStar(require("./eip1193.advanced"));
@@ -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);
@@ -4,85 +4,82 @@ import { Hex } from "@ckb-ccc/core";
4
4
  * @interface
5
5
  */
6
6
  export interface Provider {
7
- /**
8
- * Sends a request to the provider.
9
- * @type {RequestMethod}
10
- */
11
- request: RequestMethod;
12
- /**
13
- * Adds an event listener to the provider.
14
- * @type {OnMethod}
15
- */
16
- on: OnMethod;
17
- /**
18
- * Removes an event listener from the provider.
19
- * @param {string} eventName - The name of the event to remove the listener from.
20
- * @param {(...args: unknown[]) => unknown} listener - The listener function to remove.
21
- * @returns {Provider} The provider instance.
22
- */
23
- removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
7
+ /**
8
+ * Sends a request to the provider.
9
+ * @type {RequestMethod}
10
+ */
11
+ request: RequestMethod;
12
+ /**
13
+ * Adds an event listener to the provider.
14
+ * @type {OnMethod}
15
+ */
16
+ on: OnMethod;
17
+ /**
18
+ * Removes an event listener from the provider.
19
+ * @param {string} eventName - The name of the event to remove the listener from.
20
+ * @param {(...args: unknown[]) => unknown} listener - The listener function to remove.
21
+ * @returns {Provider} The provider instance.
22
+ */
23
+ removeListener(
24
+ eventName: string,
25
+ listener: (...args: unknown[]) => unknown,
26
+ ): Provider;
24
27
  }
25
28
  /**
26
29
  * Interface representing a method to send requests to the provider.
27
30
  * @interface
28
31
  */
29
32
  export interface RequestMethod {
30
- /**
31
- * Signs a message with the personal account.
32
- * @param request - The request object.
33
- * @param request.method - The method name.
34
- * @param request.params - The method parameters.
35
- * @returns A promise that resolves to the signed message.
36
- */
37
- (request: {
38
- method: "personal_sign";
39
- params: [string, Hex];
40
- }): Promise<Hex>;
41
- /**
42
- * Requests the accounts from the provider.
43
- * @param request - The request object.
44
- * @param request.method - The method name.
45
- * @param request.params - The optional method parameters.
46
- * @returns A promise that resolves to an array of account addresses.
47
- */
48
- (request: {
49
- method: "eth_requestAccounts";
50
- params?: undefined;
51
- }): Promise<Hex[]>;
52
- /**
53
- * Gets the accounts from the provider.
54
- * @param request - The request object.
55
- * @param request.method - The method name.
56
- * @param request.params - The optional method parameters.
57
- * @returns A promise that resolves to an array of account addresses.
58
- */
59
- (request: {
60
- method: "eth_accounts";
61
- params?: undefined;
62
- }): Promise<Hex[]>;
63
- /**
64
- * Sends a generic request to the provider.
65
- * @param request - The request object.
66
- * @param request.method - The method name.
67
- * @param request.params - The optional method parameters.
68
- * @returns A promise that resolves to the response from the provider.
69
- */
70
- (request: {
71
- method: string;
72
- params?: Array<unknown> | Record<string, unknown>;
73
- }): Promise<unknown>;
33
+ /**
34
+ * Signs a message with the personal account.
35
+ * @param request - The request object.
36
+ * @param request.method - The method name.
37
+ * @param request.params - The method parameters.
38
+ * @returns A promise that resolves to the signed message.
39
+ */
40
+ (request: { method: "personal_sign"; params: [string, Hex] }): Promise<Hex>;
41
+ /**
42
+ * Requests the accounts from the provider.
43
+ * @param request - The request object.
44
+ * @param request.method - The method name.
45
+ * @param request.params - The optional method parameters.
46
+ * @returns A promise that resolves to an array of account addresses.
47
+ */
48
+ (request: {
49
+ method: "eth_requestAccounts";
50
+ params?: undefined;
51
+ }): Promise<Hex[]>;
52
+ /**
53
+ * Gets the accounts from the provider.
54
+ * @param request - The request object.
55
+ * @param request.method - The method name.
56
+ * @param request.params - The optional method parameters.
57
+ * @returns A promise that resolves to an array of account addresses.
58
+ */
59
+ (request: { method: "eth_accounts"; params?: undefined }): Promise<Hex[]>;
60
+ /**
61
+ * Sends a generic request to the provider.
62
+ * @param request - The request object.
63
+ * @param request.method - The method name.
64
+ * @param request.params - The optional method parameters.
65
+ * @returns A promise that resolves to the response from the provider.
66
+ */
67
+ (request: {
68
+ method: string;
69
+ params?: Array<unknown> | Record<string, unknown>;
70
+ }): Promise<unknown>;
74
71
  }
75
72
  /**
76
73
  * Interface representing a method to add event listeners to the provider.
77
74
  * @interface
78
75
  */
79
76
  export interface OnMethod {
80
- /**
81
- * Adds an event listener to the provider.
82
- * @param eventName - The name of the event.
83
- * @param listener - The listener function.
84
- * @returns The provider instance.
85
- */
86
- (eventName: string, listener: (...args: unknown[]) => unknown): Provider;
77
+ /**
78
+ * Adds an event listener to the provider.
79
+ * @param eventName - The name of the event.
80
+ * @param listener - The listener function.
81
+ * @returns The provider instance.
82
+ */
83
+ (eventName: string, listener: (...args: unknown[]) => unknown): Provider;
87
84
  }
88
- //# sourceMappingURL=eip1193.advanced.d.ts.map
85
+ //# sourceMappingURL=eip1193.advanced.d.ts.map
@@ -4,52 +4,52 @@ import { Provider as EIP1193Provider } from "./eip1193.advanced";
4
4
  * @interface
5
5
  */
6
6
  export interface AnnounceProviderEvent {
7
- /**
8
- * The detail of the provider.
9
- * @type {ProviderDetail}
10
- */
11
- detail: ProviderDetail;
7
+ /**
8
+ * The detail of the provider.
9
+ * @type {ProviderDetail}
10
+ */
11
+ detail: ProviderDetail;
12
12
  }
13
13
  /**
14
14
  * Interface representing the details of a provider.
15
15
  * @interface
16
16
  */
17
17
  export interface ProviderDetail {
18
- /**
19
- * The information about the provider.
20
- * @type {ProviderInfo}
21
- */
22
- info: ProviderInfo;
23
- /**
24
- * The provider instance compliant with EIP-1193.
25
- * @type {EIP1193Provider}
26
- */
27
- provider: EIP1193Provider;
18
+ /**
19
+ * The information about the provider.
20
+ * @type {ProviderInfo}
21
+ */
22
+ info: ProviderInfo;
23
+ /**
24
+ * The provider instance compliant with EIP-1193.
25
+ * @type {EIP1193Provider}
26
+ */
27
+ provider: EIP1193Provider;
28
28
  }
29
29
  /**
30
30
  * Interface representing information about a provider.
31
31
  * @interface
32
32
  */
33
33
  export interface ProviderInfo {
34
- /**
35
- * The reverse DNS name of the provider.
36
- * @type {string}
37
- */
38
- rdns: string;
39
- /**
40
- * The UUID of the provider.
41
- * @type {string}
42
- */
43
- uuid: string;
44
- /**
45
- * The name of the provider.
46
- * @type {string}
47
- */
48
- name: string;
49
- /**
50
- * The icon URL of the provider.
51
- * @type {string}
52
- */
53
- icon: string;
34
+ /**
35
+ * The reverse DNS name of the provider.
36
+ * @type {string}
37
+ */
38
+ rdns: string;
39
+ /**
40
+ * The UUID of the provider.
41
+ * @type {string}
42
+ */
43
+ uuid: string;
44
+ /**
45
+ * The name of the provider.
46
+ * @type {string}
47
+ */
48
+ name: string;
49
+ /**
50
+ * The icon URL of the provider.
51
+ * @type {string}
52
+ */
53
+ icon: string;
54
54
  }
55
- //# sourceMappingURL=eip6963.advanced.d.ts.map
55
+ //# sourceMappingURL=eip6963.advanced.d.ts.map
@@ -1,2 +1,2 @@
1
1
  export * as Eip6963 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.Eip6963 = void 0;
27
48
  exports.Eip6963 = __importStar(require("./barrel"));
@@ -6,35 +6,35 @@ import { ProviderDetail as EIP6963ProviderDetail } from "./eip6963.advanced";
6
6
  * @extends {ccc.SignerEvm}
7
7
  */
8
8
  export declare class Signer extends ccc.SignerEvm {
9
- readonly detail: EIP6963ProviderDetail;
10
- private accountCache?;
11
- /**
12
- * Creates an instance of Signer.
13
- * @param {ccc.Client} client - The client instance.
14
- * @param {EIP6963ProviderDetail} detail - The provider detail.
15
- */
16
- constructor(client: ccc.Client, detail: EIP6963ProviderDetail);
17
- /**
18
- * Gets the EVM account address.
19
- * @returns A promise that resolves to the EVM account address.
20
- */
21
- getEvmAccount(): Promise<ccc.Hex>;
22
- /**
23
- * Connects to the provider by requesting accounts.
24
- * @returns {Promise<void>} A promise that resolves when the connection is established.
25
- */
26
- connect(): Promise<void>;
27
- onReplaced(listener: () => void): () => void;
28
- /**
29
- * Checks if the provider is connected.
30
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
31
- */
32
- isConnected(): Promise<boolean>;
33
- /**
34
- * Signs a raw message with the personal account.
35
- * @param {string | ccc.BytesLike} message - The message to sign.
36
- * @returns {Promise<ccc.Hex>} A promise that resolves to the signed message.
37
- */
38
- signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
9
+ readonly detail: EIP6963ProviderDetail;
10
+ private accountCache?;
11
+ /**
12
+ * Creates an instance of Signer.
13
+ * @param {ccc.Client} client - The client instance.
14
+ * @param {EIP6963ProviderDetail} detail - The provider detail.
15
+ */
16
+ constructor(client: ccc.Client, detail: EIP6963ProviderDetail);
17
+ /**
18
+ * Gets the EVM account address.
19
+ * @returns A promise that resolves to the EVM account address.
20
+ */
21
+ getEvmAccount(): Promise<ccc.Hex>;
22
+ /**
23
+ * Connects to the provider by requesting accounts.
24
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
25
+ */
26
+ connect(): Promise<void>;
27
+ onReplaced(listener: () => void): () => void;
28
+ /**
29
+ * Checks if the provider is connected.
30
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
31
+ */
32
+ isConnected(): Promise<boolean>;
33
+ /**
34
+ * Signs a raw message with the personal account.
35
+ * @param {string | ccc.BytesLike} message - The message to sign.
36
+ * @returns {Promise<ccc.Hex>} A promise that resolves to the signed message.
37
+ */
38
+ signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
39
39
  }
40
- //# sourceMappingURL=signer.d.ts.map
40
+ //# sourceMappingURL=signer.d.ts.map
@@ -8,65 +8,72 @@ const core_1 = require("@ckb-ccc/core");
8
8
  * @extends {ccc.SignerEvm}
9
9
  */
10
10
  class Signer extends core_1.ccc.SignerEvm {
11
- /**
12
- * Creates an instance of Signer.
13
- * @param {ccc.Client} client - The client instance.
14
- * @param {EIP6963ProviderDetail} detail - The provider detail.
15
- */
16
- constructor(client, detail) {
17
- super(client);
18
- this.detail = detail;
19
- this.accountCache = undefined;
20
- }
21
- /**
22
- * Gets the EVM account address.
23
- * @returns A promise that resolves to the EVM account address.
24
- */
25
- async getEvmAccount() {
26
- this.accountCache = (await this.detail.provider.request({ method: "eth_accounts" }))[0];
27
- return this.accountCache;
28
- }
29
- /**
30
- * Connects to the provider by requesting accounts.
31
- * @returns {Promise<void>} A promise that resolves when the connection is established.
32
- */
33
- async connect() {
34
- await this.detail.provider.request({ method: "eth_requestAccounts" });
35
- }
36
- onReplaced(listener) {
37
- const stop = [];
38
- const replacer = async () => {
39
- listener();
40
- stop[0]?.();
41
- };
42
- stop.push(() => {
43
- this.detail.provider.removeListener("accountsChanged", replacer);
44
- this.detail.provider.removeListener("disconnect", replacer);
45
- });
46
- this.detail.provider.on("accountsChanged", replacer);
47
- this.detail.provider.on("disconnect", replacer);
48
- return stop[0];
49
- }
50
- /**
51
- * Checks if the provider is connected.
52
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
53
- */
54
- async isConnected() {
55
- return ((await this.detail.provider.request({ method: "eth_accounts" }))
56
- .length !== 0);
57
- }
58
- /**
59
- * Signs a raw message with the personal account.
60
- * @param {string | ccc.BytesLike} message - The message to sign.
61
- * @returns {Promise<ccc.Hex>} A promise that resolves to the signed message.
62
- */
63
- async signMessageRaw(message) {
64
- const challenge = typeof message === "string" ? core_1.ccc.bytesFrom(message, "utf8") : message;
65
- const account = this.accountCache ?? (await this.getEvmAccount());
66
- return this.detail.provider.request({
67
- method: "personal_sign",
68
- params: [core_1.ccc.hexFrom(challenge), account],
69
- });
70
- }
11
+ /**
12
+ * Creates an instance of Signer.
13
+ * @param {ccc.Client} client - The client instance.
14
+ * @param {EIP6963ProviderDetail} detail - The provider detail.
15
+ */
16
+ constructor(client, detail) {
17
+ super(client);
18
+ this.detail = detail;
19
+ this.accountCache = undefined;
20
+ }
21
+ /**
22
+ * Gets the EVM account address.
23
+ * @returns A promise that resolves to the EVM account address.
24
+ */
25
+ async getEvmAccount() {
26
+ this.accountCache = (
27
+ await this.detail.provider.request({ method: "eth_accounts" })
28
+ )[0];
29
+ return this.accountCache;
30
+ }
31
+ /**
32
+ * Connects to the provider by requesting accounts.
33
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
34
+ */
35
+ async connect() {
36
+ await this.detail.provider.request({ method: "eth_requestAccounts" });
37
+ }
38
+ onReplaced(listener) {
39
+ const stop = [];
40
+ const replacer = async () => {
41
+ listener();
42
+ stop[0]?.();
43
+ };
44
+ stop.push(() => {
45
+ this.detail.provider.removeListener("accountsChanged", replacer);
46
+ this.detail.provider.removeListener("disconnect", replacer);
47
+ });
48
+ this.detail.provider.on("accountsChanged", replacer);
49
+ this.detail.provider.on("disconnect", replacer);
50
+ return stop[0];
51
+ }
52
+ /**
53
+ * Checks if the provider is connected.
54
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
55
+ */
56
+ async isConnected() {
57
+ return (
58
+ (await this.detail.provider.request({ method: "eth_accounts" }))
59
+ .length !== 0
60
+ );
61
+ }
62
+ /**
63
+ * Signs a raw message with the personal account.
64
+ * @param {string | ccc.BytesLike} message - The message to sign.
65
+ * @returns {Promise<ccc.Hex>} A promise that resolves to the signed message.
66
+ */
67
+ async signMessageRaw(message) {
68
+ const challenge =
69
+ typeof message === "string"
70
+ ? core_1.ccc.bytesFrom(message, "utf8")
71
+ : message;
72
+ const account = this.accountCache ?? (await this.getEvmAccount());
73
+ return this.detail.provider.request({
74
+ method: "personal_sign",
75
+ params: [core_1.ccc.hexFrom(challenge), account],
76
+ });
77
+ }
71
78
  }
72
79
  exports.Signer = Signer;
@@ -5,18 +5,18 @@ import { Signer as EIP6963Signer } from "./signer";
5
5
  * @class
6
6
  */
7
7
  export declare class SignerFactory {
8
- private readonly client;
9
- private readonly existedUuids;
10
- /**
11
- * Creates an instance of SignerFactory.
12
- * @param {ccc.Client} client - The client instance.
13
- */
14
- constructor(client: ccc.Client);
15
- /**
16
- * Subscribes to new signers and triggers a callback when a new signer is available.
17
- * @param {(newSigner: EIP6963Signer) => unknown} callback - The callback to trigger with the new signer.
18
- * @returns {() => void} A function to unsubscribe from the signer events.
19
- */
20
- subscribeSigners(callback: (newSigner: EIP6963Signer) => unknown): () => void;
8
+ private readonly client;
9
+ private readonly existedUuids;
10
+ /**
11
+ * Creates an instance of SignerFactory.
12
+ * @param {ccc.Client} client - The client instance.
13
+ */
14
+ constructor(client: ccc.Client);
15
+ /**
16
+ * Subscribes to new signers and triggers a callback when a new signer is available.
17
+ * @param {(newSigner: EIP6963Signer) => unknown} callback - The callback to trigger with the new signer.
18
+ * @returns {() => void} A function to unsubscribe from the signer events.
19
+ */
20
+ subscribeSigners(callback: (newSigner: EIP6963Signer) => unknown): () => void;
21
21
  }
22
- //# sourceMappingURL=signersFactory.d.ts.map
22
+ //# sourceMappingURL=signersFactory.d.ts.map
@@ -7,33 +7,34 @@ const signer_1 = require("./signer");
7
7
  * @class
8
8
  */
9
9
  class SignerFactory {
10
- /**
11
- * Creates an instance of SignerFactory.
12
- * @param {ccc.Client} client - The client instance.
13
- */
14
- constructor(client) {
15
- this.client = client;
16
- this.existedUuids = [];
17
- }
18
- /**
19
- * Subscribes to new signers and triggers a callback when a new signer is available.
20
- * @param {(newSigner: EIP6963Signer) => unknown} callback - The callback to trigger with the new signer.
21
- * @returns {() => void} A function to unsubscribe from the signer events.
22
- */
23
- subscribeSigners(callback) {
24
- const onNewProvider = (event) => {
25
- const { detail } = event;
26
- const { uuid } = detail.info;
27
- if (this.existedUuids.includes(uuid)) {
28
- return;
29
- }
30
- this.existedUuids.push(uuid);
31
- const signer = new signer_1.Signer(this.client, detail);
32
- callback(signer);
33
- };
34
- window.addEventListener("eip6963:announceProvider", onNewProvider);
35
- window.dispatchEvent(new Event("eip6963:requestProvider"));
36
- return () => window.removeEventListener("eip6963:announceProvider", onNewProvider);
37
- }
10
+ /**
11
+ * Creates an instance of SignerFactory.
12
+ * @param {ccc.Client} client - The client instance.
13
+ */
14
+ constructor(client) {
15
+ this.client = client;
16
+ this.existedUuids = [];
17
+ }
18
+ /**
19
+ * Subscribes to new signers and triggers a callback when a new signer is available.
20
+ * @param {(newSigner: EIP6963Signer) => unknown} callback - The callback to trigger with the new signer.
21
+ * @returns {() => void} A function to unsubscribe from the signer events.
22
+ */
23
+ subscribeSigners(callback) {
24
+ const onNewProvider = (event) => {
25
+ const { detail } = event;
26
+ const { uuid } = detail.info;
27
+ if (this.existedUuids.includes(uuid)) {
28
+ return;
29
+ }
30
+ this.existedUuids.push(uuid);
31
+ const signer = new signer_1.Signer(this.client, detail);
32
+ callback(signer);
33
+ };
34
+ window.addEventListener("eip6963:announceProvider", onNewProvider);
35
+ window.dispatchEvent(new Event("eip6963:requestProvider"));
36
+ return () =>
37
+ window.removeEventListener("eip6963:announceProvider", onNewProvider);
38
+ }
38
39
  }
39
40
  exports.SignerFactory = SignerFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/eip6963",
3
- "version": "0.0.10-alpha.0",
3
+ "version": "0.0.10-alpha.4",
4
4
  "description": "CCC - CKBer's Codebase. Common Chains Connector's support for EIP6963",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@ckb-ccc/core": "0.0.10-alpha.0"
45
+ "@ckb-ccc/core": "0.0.10-alpha.4"
46
46
  },
47
- "gitHead": "8a4c789419f5e12e1f230cead213c59373834a1a"
47
+ "gitHead": "61228337bbf4bdc0bc082e3c9530f843c2182106"
48
48
  }