@ckb-ccc/okx 0.0.12-alpha.6 → 0.0.12
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 +20 -0
- package/README.md +5 -5
- package/dist/advancedBarrel.d.ts +0 -1
- package/dist/advancedBarrel.d.ts.map +1 -1
- package/dist/btc/index.d.ts +11 -11
- package/dist/btc/index.d.ts.map +1 -1
- package/dist/btc/index.js +11 -11
- package/dist/nostr/index.d.ts +2 -3
- package/dist/nostr/index.d.ts.map +1 -1
- package/dist/nostr/index.js +17 -4
- package/dist/signersFactory.d.ts +4 -2
- package/dist/signersFactory.d.ts.map +1 -1
- package/dist/signersFactory.js +4 -2
- package/dist.commonjs/advancedBarrel.d.ts +0 -1
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
- package/dist.commonjs/btc/index.d.ts +11 -11
- package/dist.commonjs/btc/index.d.ts.map +1 -1
- package/dist.commonjs/btc/index.js +11 -11
- package/dist.commonjs/nostr/index.d.ts +2 -3
- package/dist.commonjs/nostr/index.d.ts.map +1 -1
- package/dist.commonjs/nostr/index.js +17 -4
- package/dist.commonjs/signersFactory.d.ts +4 -2
- package/dist.commonjs/signersFactory.d.ts.map +1 -1
- package/dist.commonjs/signersFactory.js +4 -2
- package/package.json +10 -11
- package/src/advancedBarrel.ts +0 -1
- package/src/btc/index.ts +11 -11
- package/src/nostr/index.ts +20 -4
- package/src/signersFactory.ts +4 -2
- package/typedoc.json +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @ckb-ccc/okx
|
|
2
|
+
|
|
3
|
+
## 0.0.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6bee006`](https://github.com/ckb-ecofund/ccc/commit/6bee006fbcb96986c65ca4d2d896fca21db2503b) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector): catch connecting error
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6bee006`](https://github.com/ckb-ecofund/ccc/commit/6bee006fbcb96986c65ca4d2d896fca21db2503b)]:
|
|
10
|
+
- @ckb-ccc/nip07@0.0.12
|
|
11
|
+
- @ckb-ccc/core@0.0.12
|
|
12
|
+
- @ckb-ccc/uni-sat@0.0.12
|
|
13
|
+
|
|
14
|
+
## 0.0.12-alpha.7
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- fix(connector): catch connecting error
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @ckb-ccc/nip07@0.0.12-alpha.2
|
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>
|
|
@@ -15,7 +15,7 @@
|
|
|
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
17
|
<img alt="GitHub deployments" src="https://img.shields.io/github/deployments/ckb-ecofund/ccc/production" />
|
|
18
|
-
<a href="https://ckbccc
|
|
18
|
+
<a href="https://app.ckbccc.com/"><img
|
|
19
19
|
alt="Demo" src="https://img.shields.io/website?url=https%3A%2F%2Fckbccc-demo.vercel.app%2F&label=Demo"
|
|
20
20
|
/></a>
|
|
21
21
|
</p>
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
## Preview
|
|
34
34
|
|
|
35
35
|
<p align="center">
|
|
36
|
-
<a href="https://ckbccc
|
|
36
|
+
<a href="https://app.ckbccc.com/">
|
|
37
37
|
<img src="https://raw.githubusercontent.com/ckb-ecofund/ccc/master/assets/preview.png" width="30%" />
|
|
38
38
|
</a>
|
|
39
39
|
</p>
|
|
40
40
|
|
|
41
|
-
This project is still under active development, and we are looking forward to your feedback. [Try its demo now here](https://ckbccc
|
|
41
|
+
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
42
|
|
|
43
43
|
<h3 align="center">
|
|
44
|
-
Read more about CCC on
|
|
44
|
+
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
45
|
</h3>
|
package/dist/advancedBarrel.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,EACrE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,OAAO,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,kBAAkB,CAAC,IAAI,OAAO,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,IAAI,CAAC,CAAC;CACX;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,QAAQ;IACpD,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,EAAE,EAAE,aAAa,CAAC;IAElB;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,aAAa,CAAC;CAClB;AAED
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,EACrE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,OAAO,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,kBAAkB,CAAC,IAAI,OAAO,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,IAAI,CAAC,CAAC;CACX;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,QAAQ;IACpD,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,EAAE,EAAE,aAAa,CAAC;IAElB;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,aAAa,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E"}
|
package/dist/btc/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { BitcoinProvider } from "../advancedBarrel.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 providers: Record<string, BitcoinProvider>;
|
|
@@ -11,36 +10,37 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
11
10
|
private network;
|
|
12
11
|
/**
|
|
13
12
|
* Creates an instance of Signer.
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
13
|
+
* @param client - The client instance.
|
|
14
|
+
* @param providers - The providers instance.
|
|
15
|
+
* @param preferredNetworks - All preferred networks
|
|
16
16
|
*/
|
|
17
17
|
constructor(client: ccc.Client, providers: Record<string, BitcoinProvider>, preferredNetworks?: ccc.NetworkPreference[]);
|
|
18
18
|
get provider(): BitcoinProvider;
|
|
19
19
|
/**
|
|
20
20
|
* Gets the Bitcoin account address.
|
|
21
|
-
* @returns
|
|
21
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
22
22
|
*/
|
|
23
23
|
getBtcAccount(): Promise<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Gets the Bitcoin public key.
|
|
26
|
-
* @returns
|
|
26
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
27
27
|
*/
|
|
28
28
|
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
29
29
|
/**
|
|
30
30
|
* Connects to the provider by requesting accounts.
|
|
31
|
-
* @returns
|
|
31
|
+
* @returns A promise that resolves when the connection is established.
|
|
32
32
|
*/
|
|
33
33
|
connect(): Promise<void>;
|
|
34
34
|
onReplaced(listener: () => void): () => void;
|
|
35
35
|
/**
|
|
36
36
|
* Checks if the signer is connected.
|
|
37
|
-
* @returns
|
|
37
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
38
38
|
*/
|
|
39
39
|
isConnected(): Promise<boolean>;
|
|
40
40
|
/**
|
|
41
41
|
* Signs a raw message with the Bitcoin account.
|
|
42
|
-
* @param
|
|
43
|
-
* @returns
|
|
42
|
+
* @param message - The message to sign.
|
|
43
|
+
* @returns A promise that resolves to the signed message.
|
|
44
44
|
*/
|
|
45
45
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
46
46
|
}
|
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;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;aAW5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAXpC,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;;OAKG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD;IAKH,IAAI,QAAQ,IAAI,eAAe,CAwB9B;IAED;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAoBtC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAgBzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAc9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAe5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAqBrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAMvE"}
|
package/dist/btc/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
4
|
-
* @
|
|
5
|
-
* @extends {ccc.SignerBtc}
|
|
3
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export class BitcoinSigner extends ccc.SignerBtc {
|
|
8
7
|
/**
|
|
9
8
|
* Creates an instance of Signer.
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
9
|
+
* @param client - The client instance.
|
|
10
|
+
* @param providers - The providers instance.
|
|
11
|
+
* @param preferredNetworks - All preferred networks
|
|
12
12
|
*/
|
|
13
13
|
constructor(client, providers, preferredNetworks = [
|
|
14
14
|
{
|
|
@@ -46,7 +46,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Gets the Bitcoin account address.
|
|
49
|
-
* @returns
|
|
49
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
50
50
|
*/
|
|
51
51
|
async getBtcAccount() {
|
|
52
52
|
if (this.provider.getAccounts) {
|
|
@@ -67,7 +67,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Gets the Bitcoin public key.
|
|
70
|
-
* @returns
|
|
70
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
71
71
|
*/
|
|
72
72
|
async getBtcPublicKey() {
|
|
73
73
|
if (this.provider.getPublicKey) {
|
|
@@ -84,7 +84,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Connects to the provider by requesting accounts.
|
|
87
|
-
* @returns
|
|
87
|
+
* @returns A promise that resolves when the connection is established.
|
|
88
88
|
*/
|
|
89
89
|
async connect() {
|
|
90
90
|
if (this.provider.requestAccounts) {
|
|
@@ -111,7 +111,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Checks if the signer is connected.
|
|
114
|
-
* @returns
|
|
114
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
115
115
|
*/
|
|
116
116
|
async isConnected() {
|
|
117
117
|
try {
|
|
@@ -135,8 +135,8 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Signs a raw message with the Bitcoin account.
|
|
138
|
-
* @param
|
|
139
|
-
* @returns
|
|
138
|
+
* @param message - The message to sign.
|
|
139
|
+
* @returns A promise that resolves to the signed message.
|
|
140
140
|
*/
|
|
141
141
|
async signMessageRaw(message) {
|
|
142
142
|
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
package/dist/nostr/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { NostrProvider } from "../advancedBarrel.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 NostrSigner extends ccc.SignerNostr {
|
|
9
8
|
readonly provider: NostrProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nostr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nostr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;GAGG;AACH,qBAAa,WAAY,SAAQ,GAAG,CAAC,WAAW;aAK5B,QAAQ,EAAE,aAAa;IAJzC,OAAO,CAAC,cAAc,CAAC,CAA8B;gBAGnD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,aAAa;IAKnC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAsBrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAO9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAetC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
package/dist/nostr/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
4
|
-
* @
|
|
5
|
-
* @extends {ccc.SignerBtc}
|
|
3
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
4
|
+
* @public
|
|
6
5
|
*/
|
|
7
6
|
export class NostrSigner extends ccc.SignerNostr {
|
|
8
7
|
constructor(client, provider) {
|
|
@@ -12,7 +11,20 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
12
11
|
}
|
|
13
12
|
async getNostrPublicKey() {
|
|
14
13
|
if (!this.publicKeyCache) {
|
|
15
|
-
this.publicKeyCache = this.provider
|
|
14
|
+
this.publicKeyCache = this.provider
|
|
15
|
+
.getPublicKey()
|
|
16
|
+
.then((v) => {
|
|
17
|
+
// For some account types of OKX Wallet, this might returns null
|
|
18
|
+
// e.g. Keyless accounts
|
|
19
|
+
if (v) {
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
22
|
+
throw Error("This OKX Wallet account does not support Nostr");
|
|
23
|
+
})
|
|
24
|
+
.catch((e) => {
|
|
25
|
+
this.publicKeyCache = undefined;
|
|
26
|
+
throw e;
|
|
27
|
+
});
|
|
16
28
|
}
|
|
17
29
|
return ccc.hexFrom(await this.publicKeyCache);
|
|
18
30
|
}
|
|
@@ -24,6 +36,7 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
24
36
|
}
|
|
25
37
|
async connect() {
|
|
26
38
|
await this.provider.connect?.(); // Help extension to switch network
|
|
39
|
+
await this.getNostrPublicKey();
|
|
27
40
|
}
|
|
28
41
|
onReplaced(listener) {
|
|
29
42
|
const stop = [];
|
package/dist/signersFactory.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the OKX Bitcoin signer if available.
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
4
|
+
* @public
|
|
5
|
+
*
|
|
6
|
+
* @param client - The client instance.
|
|
7
|
+
* @returns The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
6
8
|
*/
|
|
7
9
|
export declare function getOKXSigners(client: ccc.Client, preferredNetworks?: ccc.NetworkPreference[]): ccc.SignerInfo[];
|
|
8
10
|
//# sourceMappingURL=signersFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC
|
|
1
|
+
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAC1C,GAAG,CAAC,UAAU,EAAE,CAmBlB"}
|
package/dist/signersFactory.js
CHANGED
|
@@ -2,8 +2,10 @@ import { BitcoinSigner } from "./btc/index.js";
|
|
|
2
2
|
import { NostrSigner } from "./nostr/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the OKX Bitcoin signer if available.
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
5
|
+
* @public
|
|
6
|
+
*
|
|
7
|
+
* @param client - The client instance.
|
|
8
|
+
* @returns The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
7
9
|
*/
|
|
8
10
|
export function getOKXSigners(client, preferredNetworks) {
|
|
9
11
|
const windowRef = window;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,EACrE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,OAAO,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,kBAAkB,CAAC,IAAI,OAAO,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,IAAI,CAAC,CAAC;CACX;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,QAAQ;IACpD,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,EAAE,EAAE,aAAa,CAAC;IAElB;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,aAAa,CAAC;CAClB;AAED
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,EACrE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,OAAO,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,kBAAkB,CAAC,IAAI,OAAO,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,IAAI,CAAC,CAAC;CACX;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,QAAQ;IACpD,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;OAEG;IACH,EAAE,EAAE,aAAa,CAAC;IAElB;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,aAAa,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { BitcoinProvider } from "../advancedBarrel.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 providers: Record<string, BitcoinProvider>;
|
|
@@ -11,36 +10,37 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
11
10
|
private network;
|
|
12
11
|
/**
|
|
13
12
|
* Creates an instance of Signer.
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
13
|
+
* @param client - The client instance.
|
|
14
|
+
* @param providers - The providers instance.
|
|
15
|
+
* @param preferredNetworks - All preferred networks
|
|
16
16
|
*/
|
|
17
17
|
constructor(client: ccc.Client, providers: Record<string, BitcoinProvider>, preferredNetworks?: ccc.NetworkPreference[]);
|
|
18
18
|
get provider(): BitcoinProvider;
|
|
19
19
|
/**
|
|
20
20
|
* Gets the Bitcoin account address.
|
|
21
|
-
* @returns
|
|
21
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
22
22
|
*/
|
|
23
23
|
getBtcAccount(): Promise<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Gets the Bitcoin public key.
|
|
26
|
-
* @returns
|
|
26
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
27
27
|
*/
|
|
28
28
|
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
29
29
|
/**
|
|
30
30
|
* Connects to the provider by requesting accounts.
|
|
31
|
-
* @returns
|
|
31
|
+
* @returns A promise that resolves when the connection is established.
|
|
32
32
|
*/
|
|
33
33
|
connect(): Promise<void>;
|
|
34
34
|
onReplaced(listener: () => void): () => void;
|
|
35
35
|
/**
|
|
36
36
|
* Checks if the signer is connected.
|
|
37
|
-
* @returns
|
|
37
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
38
38
|
*/
|
|
39
39
|
isConnected(): Promise<boolean>;
|
|
40
40
|
/**
|
|
41
41
|
* Signs a raw message with the Bitcoin account.
|
|
42
|
-
* @param
|
|
43
|
-
* @returns
|
|
42
|
+
* @param message - The message to sign.
|
|
43
|
+
* @returns A promise that resolves to the signed message.
|
|
44
44
|
*/
|
|
45
45
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
46
46
|
}
|
|
@@ -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;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;aAW5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAXpC,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;;OAKG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD;IAKH,IAAI,QAAQ,IAAI,eAAe,CAwB9B;IAED;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAoBtC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAgBzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAc9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAe5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAqBrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAMvE"}
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BitcoinSigner = void 0;
|
|
4
4
|
const core_1 = require("@ckb-ccc/core");
|
|
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
|
class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
11
10
|
/**
|
|
12
11
|
* Creates an instance of Signer.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
12
|
+
* @param client - The client instance.
|
|
13
|
+
* @param providers - The providers instance.
|
|
14
|
+
* @param preferredNetworks - All preferred networks
|
|
15
15
|
*/
|
|
16
16
|
constructor(client, providers, preferredNetworks = [
|
|
17
17
|
{
|
|
@@ -49,7 +49,7 @@ class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Gets the Bitcoin account address.
|
|
52
|
-
* @returns
|
|
52
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
53
53
|
*/
|
|
54
54
|
async getBtcAccount() {
|
|
55
55
|
if (this.provider.getAccounts) {
|
|
@@ -70,7 +70,7 @@ class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Gets the Bitcoin public key.
|
|
73
|
-
* @returns
|
|
73
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
74
74
|
*/
|
|
75
75
|
async getBtcPublicKey() {
|
|
76
76
|
if (this.provider.getPublicKey) {
|
|
@@ -87,7 +87,7 @@ class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Connects to the provider by requesting accounts.
|
|
90
|
-
* @returns
|
|
90
|
+
* @returns A promise that resolves when the connection is established.
|
|
91
91
|
*/
|
|
92
92
|
async connect() {
|
|
93
93
|
if (this.provider.requestAccounts) {
|
|
@@ -114,7 +114,7 @@ class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Checks if the signer is connected.
|
|
117
|
-
* @returns
|
|
117
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
118
118
|
*/
|
|
119
119
|
async isConnected() {
|
|
120
120
|
try {
|
|
@@ -138,8 +138,8 @@ class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Signs a raw message with the Bitcoin account.
|
|
141
|
-
* @param
|
|
142
|
-
* @returns
|
|
141
|
+
* @param message - The message to sign.
|
|
142
|
+
* @returns A promise that resolves to the signed message.
|
|
143
143
|
*/
|
|
144
144
|
async signMessageRaw(message) {
|
|
145
145
|
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { NostrProvider } from "../advancedBarrel.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 NostrSigner extends ccc.SignerNostr {
|
|
9
8
|
readonly provider: NostrProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nostr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nostr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;GAGG;AACH,qBAAa,WAAY,SAAQ,GAAG,CAAC,WAAW;aAK5B,QAAQ,EAAE,aAAa;IAJzC,OAAO,CAAC,cAAc,CAAC,CAA8B;gBAGnD,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,aAAa;IAKnC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAsBrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAO9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAetC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
|
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NostrSigner = void 0;
|
|
4
4
|
const core_1 = require("@ckb-ccc/core");
|
|
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
|
class NostrSigner extends core_1.ccc.SignerNostr {
|
|
11
10
|
constructor(client, provider) {
|
|
@@ -15,7 +14,20 @@ class NostrSigner extends core_1.ccc.SignerNostr {
|
|
|
15
14
|
}
|
|
16
15
|
async getNostrPublicKey() {
|
|
17
16
|
if (!this.publicKeyCache) {
|
|
18
|
-
this.publicKeyCache = this.provider
|
|
17
|
+
this.publicKeyCache = this.provider
|
|
18
|
+
.getPublicKey()
|
|
19
|
+
.then((v) => {
|
|
20
|
+
// For some account types of OKX Wallet, this might returns null
|
|
21
|
+
// e.g. Keyless accounts
|
|
22
|
+
if (v) {
|
|
23
|
+
return v;
|
|
24
|
+
}
|
|
25
|
+
throw Error("This OKX Wallet account does not support Nostr");
|
|
26
|
+
})
|
|
27
|
+
.catch((e) => {
|
|
28
|
+
this.publicKeyCache = undefined;
|
|
29
|
+
throw e;
|
|
30
|
+
});
|
|
19
31
|
}
|
|
20
32
|
return core_1.ccc.hexFrom(await this.publicKeyCache);
|
|
21
33
|
}
|
|
@@ -27,6 +39,7 @@ class NostrSigner extends core_1.ccc.SignerNostr {
|
|
|
27
39
|
}
|
|
28
40
|
async connect() {
|
|
29
41
|
await this.provider.connect?.(); // Help extension to switch network
|
|
42
|
+
await this.getNostrPublicKey();
|
|
30
43
|
}
|
|
31
44
|
onReplaced(listener) {
|
|
32
45
|
const stop = [];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the OKX Bitcoin signer if available.
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
4
|
+
* @public
|
|
5
|
+
*
|
|
6
|
+
* @param client - The client instance.
|
|
7
|
+
* @returns The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
6
8
|
*/
|
|
7
9
|
export declare function getOKXSigners(client: ccc.Client, preferredNetworks?: ccc.NetworkPreference[]): ccc.SignerInfo[];
|
|
8
10
|
//# sourceMappingURL=signersFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC
|
|
1
|
+
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAC1C,GAAG,CAAC,UAAU,EAAE,CAmBlB"}
|
|
@@ -5,8 +5,10 @@ const index_js_1 = require("./btc/index.js");
|
|
|
5
5
|
const index_js_2 = require("./nostr/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Retrieves the OKX Bitcoin signer if available.
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
8
|
+
* @public
|
|
9
|
+
*
|
|
10
|
+
* @param client - The client instance.
|
|
11
|
+
* @returns The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
10
12
|
*/
|
|
11
13
|
function getOKXSigners(client, preferredNetworks) {
|
|
12
14
|
const windowRef = window;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/okx",
|
|
3
|
-
"version": "0.0.12
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for OKX",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,11 +22,6 @@
|
|
|
22
22
|
"default": "./dist.commonjs/advanced.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
|
27
|
-
"lint": "eslint",
|
|
28
|
-
"format": "prettier --write . && eslint --fix"
|
|
29
|
-
},
|
|
30
25
|
"devDependencies": {
|
|
31
26
|
"@eslint/js": "^9.1.1",
|
|
32
27
|
"copyfiles": "^2.4.1",
|
|
@@ -43,9 +38,13 @@
|
|
|
43
38
|
"access": "public"
|
|
44
39
|
},
|
|
45
40
|
"dependencies": {
|
|
46
|
-
"@ckb-ccc/
|
|
47
|
-
"@ckb-ccc/
|
|
48
|
-
"@ckb-ccc/
|
|
41
|
+
"@ckb-ccc/uni-sat": "0.0.12",
|
|
42
|
+
"@ckb-ccc/core": "0.0.12",
|
|
43
|
+
"@ckb-ccc/nip07": "0.0.12"
|
|
49
44
|
},
|
|
50
|
-
"
|
|
51
|
-
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
|
|
47
|
+
"lint": "eslint",
|
|
48
|
+
"format": "prettier --write . && eslint --fix"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/advancedBarrel.ts
CHANGED
package/src/btc/index.ts
CHANGED
|
@@ -2,17 +2,17 @@ import { ccc } from "@ckb-ccc/core";
|
|
|
2
2
|
import { BitcoinProvider } from "../advancedBarrel.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
6
|
-
* @
|
|
7
|
-
* @extends {ccc.SignerBtc}
|
|
5
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
6
|
+
* @public
|
|
8
7
|
*/
|
|
9
8
|
export class BitcoinSigner extends ccc.SignerBtc {
|
|
10
9
|
private network = "btcTestnet";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Creates an instance of Signer.
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
13
|
+
* @param client - The client instance.
|
|
14
|
+
* @param providers - The providers instance.
|
|
15
|
+
* @param preferredNetworks - All preferred networks
|
|
16
16
|
*/
|
|
17
17
|
constructor(
|
|
18
18
|
client: ccc.Client,
|
|
@@ -61,7 +61,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Gets the Bitcoin account address.
|
|
64
|
-
* @returns
|
|
64
|
+
* @returns A promise that resolves to the Bitcoin account address.
|
|
65
65
|
*/
|
|
66
66
|
async getBtcAccount(): Promise<string> {
|
|
67
67
|
if (this.provider.getAccounts) {
|
|
@@ -85,7 +85,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Gets the Bitcoin public key.
|
|
88
|
-
* @returns
|
|
88
|
+
* @returns A promise that resolves to the Bitcoin public key.
|
|
89
89
|
*/
|
|
90
90
|
async getBtcPublicKey(): Promise<ccc.Hex> {
|
|
91
91
|
if (this.provider.getPublicKey) {
|
|
@@ -105,7 +105,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Connects to the provider by requesting accounts.
|
|
108
|
-
* @returns
|
|
108
|
+
* @returns A promise that resolves when the connection is established.
|
|
109
109
|
*/
|
|
110
110
|
async connect(): Promise<void> {
|
|
111
111
|
if (this.provider.requestAccounts) {
|
|
@@ -138,7 +138,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Checks if the signer is connected.
|
|
141
|
-
* @returns
|
|
141
|
+
* @returns A promise that resolves to true if connected, false otherwise.
|
|
142
142
|
*/
|
|
143
143
|
async isConnected(): Promise<boolean> {
|
|
144
144
|
try {
|
|
@@ -163,8 +163,8 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
165
|
* Signs a raw message with the Bitcoin account.
|
|
166
|
-
* @param
|
|
167
|
-
* @returns
|
|
166
|
+
* @param message - The message to sign.
|
|
167
|
+
* @returns A promise that resolves to the signed message.
|
|
168
168
|
*/
|
|
169
169
|
async signMessageRaw(message: string | ccc.BytesLike): Promise<string> {
|
|
170
170
|
const challenge =
|
package/src/nostr/index.ts
CHANGED
|
@@ -2,9 +2,8 @@ import { ccc } from "@ckb-ccc/core";
|
|
|
2
2
|
import { NostrProvider } from "../advancedBarrel.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
6
|
-
* @
|
|
7
|
-
* @extends {ccc.SignerBtc}
|
|
5
|
+
* Class representing a Bitcoin signer that extends SignerBtc
|
|
6
|
+
* @public
|
|
8
7
|
*/
|
|
9
8
|
export class NostrSigner extends ccc.SignerNostr {
|
|
10
9
|
private publicKeyCache?: Promise<string> = undefined;
|
|
@@ -18,8 +17,23 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
18
17
|
|
|
19
18
|
async getNostrPublicKey(): Promise<ccc.Hex> {
|
|
20
19
|
if (!this.publicKeyCache) {
|
|
21
|
-
this.publicKeyCache = this.provider
|
|
20
|
+
this.publicKeyCache = this.provider
|
|
21
|
+
.getPublicKey()
|
|
22
|
+
.then((v) => {
|
|
23
|
+
// For some account types of OKX Wallet, this might returns null
|
|
24
|
+
// e.g. Keyless accounts
|
|
25
|
+
if (v) {
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw Error("This OKX Wallet account does not support Nostr");
|
|
30
|
+
})
|
|
31
|
+
.catch((e) => {
|
|
32
|
+
this.publicKeyCache = undefined;
|
|
33
|
+
throw e;
|
|
34
|
+
});
|
|
22
35
|
}
|
|
36
|
+
|
|
23
37
|
return ccc.hexFrom(await this.publicKeyCache);
|
|
24
38
|
}
|
|
25
39
|
|
|
@@ -34,6 +48,8 @@ export class NostrSigner extends ccc.SignerNostr {
|
|
|
34
48
|
|
|
35
49
|
async connect(): Promise<void> {
|
|
36
50
|
await this.provider.connect?.(); // Help extension to switch network
|
|
51
|
+
|
|
52
|
+
await this.getNostrPublicKey();
|
|
37
53
|
}
|
|
38
54
|
|
|
39
55
|
onReplaced(listener: () => void): () => void {
|
package/src/signersFactory.ts
CHANGED
|
@@ -5,8 +5,10 @@ import { NostrSigner } from "./nostr/index.js";
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Retrieves the OKX Bitcoin signer if available.
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
8
|
+
* @public
|
|
9
|
+
*
|
|
10
|
+
* @param client - The client instance.
|
|
11
|
+
* @returns The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
10
12
|
*/
|
|
11
13
|
export function getOKXSigners(
|
|
12
14
|
client: ccc.Client,
|