@ckb-ccc/joy-id 0.0.12-alpha.1 → 0.0.13-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.
- package/CHANGELOG.md +15 -0
- package/README.md +10 -7
- package/dist/btc/index.d.ts +9 -12
- package/dist/btc/index.d.ts.map +1 -1
- package/dist/btc/index.js +9 -12
- package/dist/ckb/index.d.ts +26 -33
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +26 -33
- package/dist/common/index.d.ts +3 -4
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -3
- package/dist/connectionsStorage/index.d.ts +31 -26
- package/dist/connectionsStorage/index.d.ts.map +1 -1
- package/dist/connectionsStorage/index.js +11 -13
- package/dist/evm/index.d.ts +11 -16
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +11 -16
- package/dist/nostr/index.d.ts +9 -14
- package/dist/nostr/index.d.ts.map +1 -1
- package/dist/nostr/index.js +9 -14
- package/dist/signerFactory/index.d.ts +6 -4
- package/dist/signerFactory/index.d.ts.map +1 -1
- package/dist/signerFactory/index.js +6 -4
- package/dist.commonjs/btc/index.d.ts +9 -12
- package/dist.commonjs/btc/index.d.ts.map +1 -1
- package/dist.commonjs/btc/index.js +9 -12
- package/dist.commonjs/ckb/index.d.ts +26 -33
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +26 -33
- package/dist.commonjs/common/index.d.ts +3 -4
- package/dist.commonjs/common/index.d.ts.map +1 -1
- package/dist.commonjs/common/index.js +3 -3
- package/dist.commonjs/connectionsStorage/index.d.ts +31 -26
- package/dist.commonjs/connectionsStorage/index.d.ts.map +1 -1
- package/dist.commonjs/connectionsStorage/index.js +11 -13
- package/dist.commonjs/evm/index.d.ts +11 -16
- package/dist.commonjs/evm/index.d.ts.map +1 -1
- package/dist.commonjs/evm/index.js +11 -16
- package/dist.commonjs/nostr/index.d.ts +9 -14
- package/dist.commonjs/nostr/index.d.ts.map +1 -1
- package/dist.commonjs/nostr/index.js +9 -14
- package/dist.commonjs/signerFactory/index.d.ts +6 -4
- package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
- package/dist.commonjs/signerFactory/index.js +6 -4
- package/package.json +9 -10
- package/src/btc/index.ts +9 -12
- package/src/ckb/index.ts +26 -33
- package/src/common/index.ts +3 -4
- package/src/connectionsStorage/index.ts +31 -26
- package/src/evm/index.ts +11 -16
- package/src/nostr/index.ts +9 -14
- package/src/signerFactory/index.ts +6 -4
- package/typedoc.json +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @ckb-ccc/joy-id
|
|
2
|
+
|
|
3
|
+
## 0.0.13-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`600cc13`](https://github.com/ckb-ecofund/ccc/commit/600cc137ac6eb7c5b2533670de6df29d82f1b9e1)]:
|
|
8
|
+
- @ckb-ccc/core@0.0.13-alpha.0
|
|
9
|
+
|
|
10
|
+
## 0.0.12
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies []:
|
|
15
|
+
- @ckb-ccc/core@0.0.12
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://ckbccc
|
|
2
|
+
<a href="https://app.ckbccc.com/">
|
|
3
3
|
<img alt="Logo" src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/logo.svg" width="20%" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
/></a>
|
|
15
15
|
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-ecofund/ccc" />
|
|
16
16
|
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-ecofund/ccc/master" />
|
|
17
|
-
<img alt="GitHub
|
|
18
|
-
<a href="https://ckbccc
|
|
19
|
-
alt="
|
|
17
|
+
<img alt="GitHub branch check runs" src="https://img.shields.io/github/check-runs/ckb-ecofund/ccc/master" />
|
|
18
|
+
<a href="https://app.ckbccc.com/"><img
|
|
19
|
+
alt="App" src="https://img.shields.io/website?url=https%3A%2F%2Fapp.ckbccc.com%2F&label=App"
|
|
20
|
+
/></a>
|
|
21
|
+
<a href="https://docs.ckbccc.com/"><img
|
|
22
|
+
alt="Docs" src="https://img.shields.io/website?url=https%3A%2F%2Fdocs.ckbccc.com%2F&label=Docs"
|
|
20
23
|
/></a>
|
|
21
24
|
</p>
|
|
22
25
|
|
|
@@ -33,13 +36,13 @@
|
|
|
33
36
|
## Preview
|
|
34
37
|
|
|
35
38
|
<p align="center">
|
|
36
|
-
<a href="https://ckbccc
|
|
39
|
+
<a href="https://app.ckbccc.com/">
|
|
37
40
|
<img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
|
|
38
41
|
</a>
|
|
39
42
|
</p>
|
|
40
43
|
|
|
41
|
-
This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc
|
|
44
|
+
This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://app.ckbccc.com/). It showcases how to use CCC for some basic scenarios in CKB.
|
|
42
45
|
|
|
43
46
|
<h3 align="center">
|
|
44
|
-
Read more about CCC on
|
|
47
|
+
Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-ecofund/ccc">GitHub Repo</a>.
|
|
45
48
|
</h3>
|
package/dist/btc/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.SignerBtc}
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
9
8
|
readonly name: string;
|
|
@@ -16,9 +15,8 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
16
15
|
private network;
|
|
17
16
|
/**
|
|
18
17
|
* Ensures that the signer is connected and returns the connection.
|
|
19
|
-
* @private
|
|
20
18
|
* @throws Will throw an error if not connected.
|
|
21
|
-
* @returns
|
|
19
|
+
* @returns The current connection.
|
|
22
20
|
*/
|
|
23
21
|
private assertConnection;
|
|
24
22
|
/**
|
|
@@ -33,35 +31,34 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
33
31
|
constructor(client: ccc.Client, name: string, icon: string, preferredNetworks?: ccc.NetworkPreference[], addressType?: "auto" | "p2wpkh" | "p2tr", _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
34
32
|
/**
|
|
35
33
|
* Gets the configuration for JoyID.
|
|
36
|
-
* @private
|
|
37
34
|
* @returns The configuration object.
|
|
38
35
|
*/
|
|
39
36
|
private getConfig;
|
|
40
37
|
disconnect(): Promise<void>;
|
|
41
38
|
/**
|
|
42
39
|
* Gets the Bitcoin account address.
|
|
43
|
-
* @returns
|
|
40
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
44
41
|
*/
|
|
45
42
|
getBtcAccount(): Promise<string>;
|
|
46
43
|
/**
|
|
47
44
|
* Gets the Bitcoin public key.
|
|
48
|
-
* @returns
|
|
45
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
49
46
|
*/
|
|
50
47
|
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
51
48
|
/**
|
|
52
49
|
* Connects to the provider by requesting authentication.
|
|
53
|
-
* @returns
|
|
50
|
+
* @returns A promise that resolves when the connection is established.
|
|
54
51
|
*/
|
|
55
52
|
connect(): Promise<void>;
|
|
56
53
|
/**
|
|
57
54
|
* Checks if the signer is connected.
|
|
58
|
-
* @returns
|
|
55
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
59
56
|
*/
|
|
60
57
|
isConnected(): Promise<boolean>;
|
|
61
58
|
/**
|
|
62
59
|
* Signs a raw message with the Bitcoin account.
|
|
63
|
-
* @param
|
|
64
|
-
* @returns
|
|
60
|
+
* @param message - The message to sign.
|
|
61
|
+
* @returns A promise that resolves to the signed message.
|
|
65
62
|
*/
|
|
66
63
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
67
64
|
}
|
package/dist/btc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;aA4B5B,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;aAYlB,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IA3ClC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;OAQG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACX,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD,EACe,WAAW,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAe,EAC/C,OAAO,CAAC,oBAAQ,EAChB,eAAe,GAAE,eAAmD;IAKvF;;;OAGG;IACH,OAAO,CAAC,SAAS;IA6BX,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAKzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBvE"}
|
package/dist/btc/index.js
CHANGED
|
@@ -3,16 +3,14 @@ import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
|
3
3
|
import { createPopup } from "../common/index.js";
|
|
4
4
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage/index.js";
|
|
5
5
|
/**
|
|
6
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
7
|
-
* @
|
|
8
|
-
* @extends {ccc.SignerBtc}
|
|
6
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
7
|
+
* @public
|
|
9
8
|
*/
|
|
10
9
|
export class BitcoinSigner extends ccc.SignerBtc {
|
|
11
10
|
/**
|
|
12
11
|
* Ensures that the signer is connected and returns the connection.
|
|
13
|
-
* @private
|
|
14
12
|
* @throws Will throw an error if not connected.
|
|
15
|
-
* @returns
|
|
13
|
+
* @returns The current connection.
|
|
16
14
|
*/
|
|
17
15
|
assertConnection() {
|
|
18
16
|
if (!this.isConnected() || !this.connection) {
|
|
@@ -52,7 +50,6 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
52
50
|
}
|
|
53
51
|
/**
|
|
54
52
|
* Gets the configuration for JoyID.
|
|
55
|
-
* @private
|
|
56
53
|
* @returns The configuration object.
|
|
57
54
|
*/
|
|
58
55
|
getConfig() {
|
|
@@ -82,7 +79,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
82
79
|
}
|
|
83
80
|
/**
|
|
84
81
|
* Gets the Bitcoin account address.
|
|
85
|
-
* @returns
|
|
82
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
86
83
|
*/
|
|
87
84
|
async getBtcAccount() {
|
|
88
85
|
const { address } = this.assertConnection();
|
|
@@ -90,7 +87,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
90
87
|
}
|
|
91
88
|
/**
|
|
92
89
|
* Gets the Bitcoin public key.
|
|
93
|
-
* @returns
|
|
90
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
94
91
|
*/
|
|
95
92
|
async getBtcPublicKey() {
|
|
96
93
|
const { publicKey } = this.assertConnection();
|
|
@@ -98,7 +95,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
98
95
|
}
|
|
99
96
|
/**
|
|
100
97
|
* Connects to the provider by requesting authentication.
|
|
101
|
-
* @returns
|
|
98
|
+
* @returns A promise that resolves when the connection is established.
|
|
102
99
|
*/
|
|
103
100
|
async connect() {
|
|
104
101
|
const config = this.getConfig();
|
|
@@ -124,7 +121,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
124
121
|
}
|
|
125
122
|
/**
|
|
126
123
|
* Checks if the signer is connected.
|
|
127
|
-
* @returns
|
|
124
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
128
125
|
*/
|
|
129
126
|
async isConnected() {
|
|
130
127
|
if (this.connection) {
|
|
@@ -138,8 +135,8 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
138
135
|
}
|
|
139
136
|
/**
|
|
140
137
|
* Signs a raw message with the Bitcoin account.
|
|
141
|
-
* @param
|
|
142
|
-
* @returns
|
|
138
|
+
* @param message - The message to sign.
|
|
139
|
+
* @returns A promise that resolves to the signed message.
|
|
143
140
|
*/
|
|
144
141
|
async signMessageRaw(message) {
|
|
145
142
|
const { address } = this.assertConnection();
|
package/dist/ckb/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Class representing a CKB signer that extends Signer
|
|
5
|
-
* @
|
|
6
|
-
* @extends {ccc.Signer}
|
|
4
|
+
* Class representing a CKB signer that extends Signer
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
export declare class CkbSigner extends ccc.Signer {
|
|
9
8
|
private readonly name;
|
|
@@ -13,84 +12,80 @@ export declare class CkbSigner extends ccc.Signer {
|
|
|
13
12
|
private readonly connectionsRepo;
|
|
14
13
|
/**
|
|
15
14
|
* Gets the signer type.
|
|
16
|
-
* @returns
|
|
15
|
+
* @returns The type of the signer.
|
|
17
16
|
*/
|
|
18
17
|
get type(): ccc.SignerType;
|
|
19
18
|
/**
|
|
20
19
|
* Gets the sign type.
|
|
21
|
-
* @returns
|
|
20
|
+
* @returns The sign type.
|
|
22
21
|
*/
|
|
23
22
|
get signType(): ccc.SignerSignType;
|
|
24
23
|
private connection?;
|
|
25
24
|
/**
|
|
26
25
|
* Ensures that the signer is connected and returns the connection.
|
|
27
|
-
* @private
|
|
28
26
|
* @throws Will throw an error if not connected.
|
|
29
|
-
* @returns
|
|
27
|
+
* @returns A promise that resolves to the current connection.
|
|
30
28
|
*/
|
|
31
29
|
private assertConnection;
|
|
32
30
|
/**
|
|
33
31
|
* Creates an instance of CkbSigner.
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
32
|
+
* @param client - The client instance.
|
|
33
|
+
* @param name - The name of the signer.
|
|
34
|
+
* @param icon - The icon URL of the signer.
|
|
35
|
+
* @param _appUri - The application URI.
|
|
36
|
+
* @param _aggregatorUri - The aggregator URI.
|
|
37
|
+
* @param connectionsRepo - The connections repository.
|
|
40
38
|
*/
|
|
41
39
|
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, _aggregatorUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
42
40
|
/**
|
|
43
41
|
* Gets the configuration for JoyID.
|
|
44
|
-
* @private
|
|
45
42
|
* @returns The configuration object.
|
|
46
43
|
*/
|
|
47
44
|
private getConfig;
|
|
48
45
|
/**
|
|
49
46
|
* Gets the aggregator URI.
|
|
50
|
-
* @
|
|
51
|
-
* @returns {string} The aggregator URI.
|
|
47
|
+
* @returns The aggregator URI.
|
|
52
48
|
*/
|
|
53
49
|
private getAggregatorUri;
|
|
54
50
|
/**
|
|
55
51
|
* Connects to the provider by requesting authentication.
|
|
56
|
-
* @returns
|
|
52
|
+
* @returns A promise that resolves when the connection is established.
|
|
57
53
|
*/
|
|
58
54
|
connect(): Promise<void>;
|
|
59
55
|
disconnect(): Promise<void>;
|
|
60
56
|
/**
|
|
61
57
|
* Checks if the signer is connected.
|
|
62
|
-
* @returns
|
|
58
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
63
59
|
*/
|
|
64
60
|
isConnected(): Promise<boolean>;
|
|
65
61
|
/**
|
|
66
62
|
* Gets the internal address.
|
|
67
|
-
* @returns
|
|
63
|
+
* @returns A promise that resolves to the internal address.
|
|
68
64
|
*/
|
|
69
65
|
getInternalAddress(): Promise<string>;
|
|
70
66
|
/**
|
|
71
67
|
* Gets the identity of the signer.
|
|
72
|
-
* @returns
|
|
68
|
+
* @returns A promise that resolves to the identity.
|
|
73
69
|
*/
|
|
74
70
|
getIdentity(): Promise<string>;
|
|
75
71
|
/**
|
|
76
72
|
* Gets the address object.
|
|
77
|
-
* @returns
|
|
73
|
+
* @returns A promise that resolves to the address object.
|
|
78
74
|
*/
|
|
79
75
|
getAddressObj(): Promise<ccc.Address>;
|
|
80
76
|
/**
|
|
81
77
|
* Gets the address objects.
|
|
82
|
-
* @returns
|
|
78
|
+
* @returns A promise that resolves to an array of address objects.
|
|
83
79
|
*/
|
|
84
80
|
getAddressObjs(): Promise<ccc.Address[]>;
|
|
85
81
|
/**
|
|
86
82
|
* Prepares a transaction.
|
|
87
|
-
* @param
|
|
88
|
-
* @returns
|
|
83
|
+
* @param txLike - The transaction-like object.
|
|
84
|
+
* @returns A promise that resolves to the prepared transaction.
|
|
89
85
|
*/
|
|
90
86
|
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
91
87
|
/**
|
|
92
88
|
* Prepares a transaction for a sub key.
|
|
93
|
-
* @private
|
|
94
89
|
* @param tx - The transaction object.
|
|
95
90
|
* @param witness - The witness arguments.
|
|
96
91
|
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
@@ -98,26 +93,24 @@ export declare class CkbSigner extends ccc.Signer {
|
|
|
98
93
|
private prepareTransactionForSubKey;
|
|
99
94
|
/**
|
|
100
95
|
* Signs a transaction.
|
|
101
|
-
* @param
|
|
102
|
-
* @returns
|
|
96
|
+
* @param txLike - The transaction-like object.
|
|
97
|
+
* @returns A promise that resolves to the signed transaction.
|
|
103
98
|
*/
|
|
104
99
|
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
105
100
|
/**
|
|
106
101
|
* Signs a raw message with the account.
|
|
107
|
-
* @param
|
|
108
|
-
* @returns
|
|
102
|
+
* @param message - The message to sign.
|
|
103
|
+
* @returns A promise that resolves to the signed message.
|
|
109
104
|
*/
|
|
110
105
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
111
106
|
/**
|
|
112
107
|
* Saves the current connection.
|
|
113
|
-
* @
|
|
114
|
-
* @returns {Promise<void>}
|
|
108
|
+
* @returns
|
|
115
109
|
*/
|
|
116
110
|
private saveConnection;
|
|
117
111
|
/**
|
|
118
112
|
* Restores the previous connection.
|
|
119
|
-
* @
|
|
120
|
-
* @returns {Promise<void>}
|
|
113
|
+
* @returns
|
|
121
114
|
*/
|
|
122
115
|
private restoreConnection;
|
|
123
116
|
}
|
package/dist/ckb/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAEL,eAAe,EAEhB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;IA2CrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe;IA9ClC;;;OAGG;IACH,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,CAEzB;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,GAAG,CAAC,cAAc,CAEjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC;;;;OAIG;YACW,gBAAgB;IAQ9B;;;;;;;;OAQG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,oBAAQ,EAChB,cAAc,CAAC,oBAAQ,EACvB,eAAe,GAAE,eAAmD;IAKvF;;;OAGG;IACH,OAAO,CAAC,SAAS;IAYjB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQrC;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAQpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAO3C;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAI9C;;;;OAIG;IACG,kBAAkB,CACtB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAmB3B;;;;;OAKG;YACW,2BAA2B;IA0CzC;;;;OAIG;IACG,mBAAmB,CACvB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IA8C3B;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BtE;;;OAGG;YACW,cAAc;IAU5B;;;OAGG;YACW,iBAAiB;CAMhC"}
|
package/dist/ckb/index.js
CHANGED
|
@@ -4,30 +4,28 @@ import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
|
4
4
|
import { createPopup } from "../common/index.js";
|
|
5
5
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage/index.js";
|
|
6
6
|
/**
|
|
7
|
-
* Class representing a CKB signer that extends Signer
|
|
8
|
-
* @
|
|
9
|
-
* @extends {ccc.Signer}
|
|
7
|
+
* Class representing a CKB signer that extends Signer
|
|
8
|
+
* @public
|
|
10
9
|
*/
|
|
11
10
|
export class CkbSigner extends ccc.Signer {
|
|
12
11
|
/**
|
|
13
12
|
* Gets the signer type.
|
|
14
|
-
* @returns
|
|
13
|
+
* @returns The type of the signer.
|
|
15
14
|
*/
|
|
16
15
|
get type() {
|
|
17
16
|
return ccc.SignerType.CKB;
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
19
|
* Gets the sign type.
|
|
21
|
-
* @returns
|
|
20
|
+
* @returns The sign type.
|
|
22
21
|
*/
|
|
23
22
|
get signType() {
|
|
24
23
|
return ccc.SignerSignType.JoyId;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* Ensures that the signer is connected and returns the connection.
|
|
28
|
-
* @private
|
|
29
27
|
* @throws Will throw an error if not connected.
|
|
30
|
-
* @returns
|
|
28
|
+
* @returns A promise that resolves to the current connection.
|
|
31
29
|
*/
|
|
32
30
|
async assertConnection() {
|
|
33
31
|
if (!(await this.isConnected()) || !this.connection) {
|
|
@@ -37,12 +35,12 @@ export class CkbSigner extends ccc.Signer {
|
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Creates an instance of CkbSigner.
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
38
|
+
* @param client - The client instance.
|
|
39
|
+
* @param name - The name of the signer.
|
|
40
|
+
* @param icon - The icon URL of the signer.
|
|
41
|
+
* @param _appUri - The application URI.
|
|
42
|
+
* @param _aggregatorUri - The aggregator URI.
|
|
43
|
+
* @param connectionsRepo - The connections repository.
|
|
46
44
|
*/
|
|
47
45
|
constructor(client, name, icon, _appUri, _aggregatorUri, connectionsRepo = new ConnectionsRepoLocalStorage()) {
|
|
48
46
|
super(client);
|
|
@@ -54,7 +52,6 @@ export class CkbSigner extends ccc.Signer {
|
|
|
54
52
|
}
|
|
55
53
|
/**
|
|
56
54
|
* Gets the configuration for JoyID.
|
|
57
|
-
* @private
|
|
58
55
|
* @returns The configuration object.
|
|
59
56
|
*/
|
|
60
57
|
getConfig() {
|
|
@@ -69,8 +66,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
69
66
|
}
|
|
70
67
|
/**
|
|
71
68
|
* Gets the aggregator URI.
|
|
72
|
-
* @
|
|
73
|
-
* @returns {string} The aggregator URI.
|
|
69
|
+
* @returns The aggregator URI.
|
|
74
70
|
*/
|
|
75
71
|
getAggregatorUri() {
|
|
76
72
|
if (this._aggregatorUri) {
|
|
@@ -82,7 +78,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
82
78
|
}
|
|
83
79
|
/**
|
|
84
80
|
* Connects to the provider by requesting authentication.
|
|
85
|
-
* @returns
|
|
81
|
+
* @returns A promise that resolves when the connection is established.
|
|
86
82
|
*/
|
|
87
83
|
async connect() {
|
|
88
84
|
const config = this.getConfig();
|
|
@@ -104,7 +100,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
104
100
|
}
|
|
105
101
|
/**
|
|
106
102
|
* Checks if the signer is connected.
|
|
107
|
-
* @returns
|
|
103
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
108
104
|
*/
|
|
109
105
|
async isConnected() {
|
|
110
106
|
if (this.connection) {
|
|
@@ -115,14 +111,14 @@ export class CkbSigner extends ccc.Signer {
|
|
|
115
111
|
}
|
|
116
112
|
/**
|
|
117
113
|
* Gets the internal address.
|
|
118
|
-
* @returns
|
|
114
|
+
* @returns A promise that resolves to the internal address.
|
|
119
115
|
*/
|
|
120
116
|
async getInternalAddress() {
|
|
121
117
|
return (await this.assertConnection()).address;
|
|
122
118
|
}
|
|
123
119
|
/**
|
|
124
120
|
* Gets the identity of the signer.
|
|
125
|
-
* @returns
|
|
121
|
+
* @returns A promise that resolves to the identity.
|
|
126
122
|
*/
|
|
127
123
|
async getIdentity() {
|
|
128
124
|
const connection = await this.assertConnection();
|
|
@@ -133,22 +129,22 @@ export class CkbSigner extends ccc.Signer {
|
|
|
133
129
|
}
|
|
134
130
|
/**
|
|
135
131
|
* Gets the address object.
|
|
136
|
-
* @returns
|
|
132
|
+
* @returns A promise that resolves to the address object.
|
|
137
133
|
*/
|
|
138
134
|
async getAddressObj() {
|
|
139
135
|
return await ccc.Address.fromString(await this.getInternalAddress(), this.client);
|
|
140
136
|
}
|
|
141
137
|
/**
|
|
142
138
|
* Gets the address objects.
|
|
143
|
-
* @returns
|
|
139
|
+
* @returns A promise that resolves to an array of address objects.
|
|
144
140
|
*/
|
|
145
141
|
async getAddressObjs() {
|
|
146
142
|
return [await this.getAddressObj()];
|
|
147
143
|
}
|
|
148
144
|
/**
|
|
149
145
|
* Prepares a transaction.
|
|
150
|
-
* @param
|
|
151
|
-
* @returns
|
|
146
|
+
* @param txLike - The transaction-like object.
|
|
147
|
+
* @returns A promise that resolves to the prepared transaction.
|
|
152
148
|
*/
|
|
153
149
|
async prepareTransaction(txLike) {
|
|
154
150
|
const tx = ccc.Transaction.from(txLike);
|
|
@@ -165,7 +161,6 @@ export class CkbSigner extends ccc.Signer {
|
|
|
165
161
|
}
|
|
166
162
|
/**
|
|
167
163
|
* Prepares a transaction for a sub key.
|
|
168
|
-
* @private
|
|
169
164
|
* @param tx - The transaction object.
|
|
170
165
|
* @param witness - The witness arguments.
|
|
171
166
|
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
@@ -198,8 +193,8 @@ export class CkbSigner extends ccc.Signer {
|
|
|
198
193
|
}
|
|
199
194
|
/**
|
|
200
195
|
* Signs a transaction.
|
|
201
|
-
* @param
|
|
202
|
-
* @returns
|
|
196
|
+
* @param txLike - The transaction-like object.
|
|
197
|
+
* @returns A promise that resolves to the signed transaction.
|
|
203
198
|
*/
|
|
204
199
|
async signOnlyTransaction(txLike) {
|
|
205
200
|
const tx = ccc.Transaction.from(txLike);
|
|
@@ -233,8 +228,8 @@ export class CkbSigner extends ccc.Signer {
|
|
|
233
228
|
}
|
|
234
229
|
/**
|
|
235
230
|
* Signs a raw message with the account.
|
|
236
|
-
* @param
|
|
237
|
-
* @returns
|
|
231
|
+
* @param message - The message to sign.
|
|
232
|
+
* @returns A promise that resolves to the signed message.
|
|
238
233
|
*/
|
|
239
234
|
async signMessageRaw(message) {
|
|
240
235
|
const { address } = await this.assertConnection();
|
|
@@ -254,8 +249,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
254
249
|
}
|
|
255
250
|
/**
|
|
256
251
|
* Saves the current connection.
|
|
257
|
-
* @
|
|
258
|
-
* @returns {Promise<void>}
|
|
252
|
+
* @returns
|
|
259
253
|
*/
|
|
260
254
|
async saveConnection() {
|
|
261
255
|
return this.connectionsRepo.set({
|
|
@@ -265,8 +259,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
265
259
|
}
|
|
266
260
|
/**
|
|
267
261
|
* Restores the previous connection.
|
|
268
|
-
* @
|
|
269
|
-
* @returns {Promise<void>}
|
|
262
|
+
* @returns
|
|
270
263
|
*/
|
|
271
264
|
async restoreConnection() {
|
|
272
265
|
this.connection = await this.connectionsRepo.get({
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AuthResponseData, DappRequestType, EvmWeb2LoginResponse, PopupConfigOptions, SignCkbTxResponseData, SignCotaNFTResponseData, SignEvmTxResponseData, SignMessageResponseData, SignNostrEventData } from "@joyid/common";
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing the return type for various Dapp request types.
|
|
4
|
-
* @interface
|
|
5
4
|
*/
|
|
6
5
|
export interface PopupReturnType {
|
|
7
6
|
[DappRequestType.Auth]: AuthResponseData;
|
|
@@ -24,9 +23,9 @@ export interface PopupReturnType {
|
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
25
|
* Creates a popup window for JoyID Dapp requests.
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @returns
|
|
26
|
+
* @param url - The URL to open in the popup.
|
|
27
|
+
* @param config - The popup configuration options.
|
|
28
|
+
* @returns A promise that resolves to the response data of the requested type.
|
|
30
29
|
* @throws {PopupNotSupportedError} If popups are not supported in the current browser.
|
|
31
30
|
* @throws {PopupCancelledError} If the popup is closed by the user.
|
|
32
31
|
* @throws {PopupTimeoutError} If the popup operation times out.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EAEpB,kBAAkB,EAGlB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAEvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EAEpB,kBAAkB,EAGlB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACzC,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACvD,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IACjD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAClD,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE;QAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;IACF,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IACnD,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACvD,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACtD,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACrD,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC3C,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC3C,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IACnC,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IACtC,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,GAAG,CAAC;IAC1C,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACtD;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,eAAe,EACzD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CA0D7B"}
|
package/dist/common/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DappRequestType, PopupCancelledError, PopupNotSupportedError, PopupTimeoutError, createBlockDialog, isStandaloneBrowser, openPopup, } from "@joyid/common";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a popup window for JoyID Dapp requests.
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @returns
|
|
4
|
+
* @param url - The URL to open in the popup.
|
|
5
|
+
* @param config - The popup configuration options.
|
|
6
|
+
* @returns A promise that resolves to the response data of the requested type.
|
|
7
7
|
* @throws {PopupNotSupportedError} If popups are not supported in the current browser.
|
|
8
8
|
* @throws {PopupCancelledError} If the popup is closed by the user.
|
|
9
9
|
* @throws {PopupTimeoutError} If the popup operation times out.
|