@ckb-ccc/okx 0.0.8-alpha.3 → 0.0.9-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/dist/advancedBarrel.d.ts +19 -2
- package/dist/advancedBarrel.d.ts.map +1 -1
- package/dist/barrel.d.ts +1 -1
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +1 -1
- package/dist/btc/index.d.ts +55 -0
- package/dist/btc/index.d.ts.map +1 -0
- package/dist/btc/index.js +89 -0
- package/dist/nostr/index.d.ts +17 -0
- package/dist/nostr/index.d.ts.map +1 -0
- package/dist/nostr/index.js +30 -0
- package/dist/signersFactory.d.ts +1 -2
- package/dist/signersFactory.d.ts.map +1 -1
- package/dist/signersFactory.js +8 -4
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +19 -40
- package/dist.commonjs/advancedBarrel.d.ts +21 -3
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.d.ts +2 -2
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +15 -31
- package/dist.commonjs/btc/index.d.ts +55 -0
- package/dist.commonjs/btc/index.d.ts.map +1 -0
- package/dist.commonjs/btc/index.js +93 -0
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +19 -40
- package/dist.commonjs/nostr/index.d.ts +17 -0
- package/dist.commonjs/nostr/index.d.ts.map +1 -0
- package/dist.commonjs/nostr/index.js +34 -0
- package/dist.commonjs/signersFactory.d.ts +2 -5
- package/dist.commonjs/signersFactory.d.ts.map +1 -1
- package/dist.commonjs/signersFactory.js +11 -7
- package/package.json +5 -5
- package/src/advancedBarrel.ts +20 -2
- package/src/barrel.ts +1 -1
- package/src/btc/index.ts +112 -0
- package/src/nostr/index.ts +42 -0
- package/src/signersFactory.ts +13 -6
- package/dist/signer.d.ts +0 -18
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -17
- package/dist.commonjs/signer.d.ts +0 -18
- package/dist.commonjs/signer.d.ts.map +0 -1
- package/dist.commonjs/signer.js +0 -21
- package/src/signer.ts +0 -22
package/dist/advancedBarrel.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface BitcoinProvider
|
|
1
|
+
import { Nip07A } from "@ckb-ccc/nip07/advanced";
|
|
2
|
+
export interface BitcoinProvider {
|
|
3
|
+
connect(): Promise<{
|
|
4
|
+
address: string;
|
|
5
|
+
publicKey: string;
|
|
6
|
+
compressedPublicKey: string;
|
|
7
|
+
}>;
|
|
8
|
+
getSelectedAccount(): Promise<{
|
|
9
|
+
address: string;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
compressedPublicKey: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
export interface NostrProvider extends Nip07A.Provider {
|
|
16
|
+
selectedAccount: {
|
|
17
|
+
address: string;
|
|
18
|
+
publicKey: string;
|
|
19
|
+
} | null;
|
|
3
20
|
}
|
|
4
21
|
//# sourceMappingURL=advancedBarrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,OAAO,IAAI,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,kBAAkB,IAAI,OAAO,CAAC;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,IAAI,CAAC,CAAC;IAEV,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,QAAQ;IACpD,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChE"}
|
package/dist/barrel.d.ts
CHANGED
package/dist/barrel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,kBAAkB,CAAC"}
|
package/dist/barrel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./btc";
|
|
2
2
|
export * from "./signersFactory";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ccc, Client } from "@ckb-ccc/core";
|
|
2
|
+
import { BitcoinProvider } from "../advancedBarrel";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {ccc.SignerBtc}
|
|
7
|
+
*/
|
|
8
|
+
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
9
|
+
readonly providers: Record<string, BitcoinProvider>;
|
|
10
|
+
private readonly preferredNetworks;
|
|
11
|
+
private network;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of Signer.
|
|
14
|
+
* @param {ccc.Client} client - The client instance.
|
|
15
|
+
* @param {Provider} provider - The provider instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(client: ccc.Client, providers: Record<string, BitcoinProvider>, preferredNetworks: ccc.NetworkPreference[]);
|
|
18
|
+
get provider(): BitcoinProvider;
|
|
19
|
+
/**
|
|
20
|
+
* Get account info if the signer is connected.
|
|
21
|
+
* @returns Account information
|
|
22
|
+
*/
|
|
23
|
+
assertConnection(): Promise<{
|
|
24
|
+
address: string;
|
|
25
|
+
publicKey: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the Bitcoin account address.
|
|
29
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
30
|
+
*/
|
|
31
|
+
getBtcAccount(): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the Bitcoin public key.
|
|
34
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
35
|
+
*/
|
|
36
|
+
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
37
|
+
/**
|
|
38
|
+
* Connects to the provider by requesting accounts.
|
|
39
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
40
|
+
*/
|
|
41
|
+
connect(): Promise<void>;
|
|
42
|
+
replaceClient(client: Client): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the signer is connected.
|
|
45
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
46
|
+
*/
|
|
47
|
+
isConnected(): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Signs a raw message with the Bitcoin account.
|
|
50
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
51
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
52
|
+
*/
|
|
53
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;aAU5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAVpC,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,EAAE;IAK7D,IAAI,QAAQ,IAAI,eAAe,CAwB9B;IAED;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAQzE;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAIzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMrD;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAMvE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
4
|
+
* @class
|
|
5
|
+
* @extends {ccc.SignerBtc}
|
|
6
|
+
*/
|
|
7
|
+
export class BitcoinSigner extends ccc.SignerBtc {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Signer.
|
|
10
|
+
* @param {ccc.Client} client - The client instance.
|
|
11
|
+
* @param {Provider} provider - The provider instance.
|
|
12
|
+
*/
|
|
13
|
+
constructor(client, providers, preferredNetworks) {
|
|
14
|
+
super(client);
|
|
15
|
+
this.providers = providers;
|
|
16
|
+
this.preferredNetworks = preferredNetworks;
|
|
17
|
+
this.network = "btcTestnet";
|
|
18
|
+
}
|
|
19
|
+
get provider() {
|
|
20
|
+
const { network } = this.matchNetworkPreference(this.preferredNetworks, this.network) ?? { network: this.network };
|
|
21
|
+
this.network = network;
|
|
22
|
+
const chain = {
|
|
23
|
+
btc: "bitcoin",
|
|
24
|
+
btcTestnet: "bitcoinTestnet",
|
|
25
|
+
btcSignet: "bitcoinSignet",
|
|
26
|
+
}[network];
|
|
27
|
+
if (!chain) {
|
|
28
|
+
throw new Error(`OKX wallet doesn't support the requested chain ${this.network}`);
|
|
29
|
+
}
|
|
30
|
+
const provider = this.providers[chain];
|
|
31
|
+
if (!provider) {
|
|
32
|
+
throw new Error(`OKX wallet doesn't support the requested chain ${this.network}`);
|
|
33
|
+
}
|
|
34
|
+
return provider;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get account info if the signer is connected.
|
|
38
|
+
* @returns Account information
|
|
39
|
+
*/
|
|
40
|
+
async assertConnection() {
|
|
41
|
+
const account = await this.provider.getSelectedAccount();
|
|
42
|
+
if (!account) {
|
|
43
|
+
throw Error("Not connected");
|
|
44
|
+
}
|
|
45
|
+
return account;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets the Bitcoin account address.
|
|
49
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
50
|
+
*/
|
|
51
|
+
async getBtcAccount() {
|
|
52
|
+
return (await this.assertConnection()).address;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the Bitcoin public key.
|
|
56
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
57
|
+
*/
|
|
58
|
+
async getBtcPublicKey() {
|
|
59
|
+
return ccc.hexFrom((await this.assertConnection()).publicKey);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Connects to the provider by requesting accounts.
|
|
63
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
64
|
+
*/
|
|
65
|
+
async connect() {
|
|
66
|
+
await this.provider.connect();
|
|
67
|
+
}
|
|
68
|
+
async replaceClient(client) {
|
|
69
|
+
const res = await super.replaceClient(client);
|
|
70
|
+
this.provider; // Check if the network is valid
|
|
71
|
+
return res;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Checks if the signer is connected.
|
|
75
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
76
|
+
*/
|
|
77
|
+
async isConnected() {
|
|
78
|
+
return (await this.provider.getSelectedAccount()) !== null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Signs a raw message with the Bitcoin account.
|
|
82
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
83
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
84
|
+
*/
|
|
85
|
+
async signMessageRaw(message) {
|
|
86
|
+
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
87
|
+
return this.provider.signMessage(challenge, "ecdsa");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { NostrProvider } from "../advancedBarrel";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {ccc.SignerBtc}
|
|
7
|
+
*/
|
|
8
|
+
export declare class SignerNostr extends ccc.SignerNostr {
|
|
9
|
+
readonly provider: NostrProvider;
|
|
10
|
+
constructor(client: ccc.Client, provider: NostrProvider);
|
|
11
|
+
replaceClient(client: ccc.Client): Promise<boolean>;
|
|
12
|
+
getNostrPublicKey(): Promise<ccc.Hex>;
|
|
13
|
+
signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
isConnected(): Promise<boolean>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,mBAAmB,CAAC;AAElD;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,GAAG,CAAC,WAAW;aAG5B,QAAQ,EAAE,aAAa;gBADvC,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,aAAa;IAKnC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAQrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAI9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
4
|
+
* @class
|
|
5
|
+
* @extends {ccc.SignerBtc}
|
|
6
|
+
*/
|
|
7
|
+
export class SignerNostr extends ccc.SignerNostr {
|
|
8
|
+
constructor(client, provider) {
|
|
9
|
+
super(client);
|
|
10
|
+
this.provider = provider;
|
|
11
|
+
}
|
|
12
|
+
async replaceClient(client) {
|
|
13
|
+
return super.replaceClient(client);
|
|
14
|
+
}
|
|
15
|
+
async getNostrPublicKey() {
|
|
16
|
+
if (!this.provider.selectedAccount) {
|
|
17
|
+
throw new Error("Not connected");
|
|
18
|
+
}
|
|
19
|
+
return ccc.hexFrom(this.provider.selectedAccount.publicKey);
|
|
20
|
+
}
|
|
21
|
+
async signNostrEvent(event) {
|
|
22
|
+
return this.provider.signEvent(event);
|
|
23
|
+
}
|
|
24
|
+
async connect() {
|
|
25
|
+
await this.provider.getPublicKey();
|
|
26
|
+
}
|
|
27
|
+
async isConnected() {
|
|
28
|
+
return this.provider.selectedAccount !== null;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/signersFactory.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { BitcoinSigner } from "./signer";
|
|
3
2
|
/**
|
|
4
3
|
* Retrieves the OKX Bitcoin signer if available.
|
|
5
4
|
* @param {ccc.Client} client - The client instance.
|
|
6
5
|
* @returns {BitcoinSigner | undefined} The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
7
6
|
*/
|
|
8
|
-
export declare function getOKXBitcoinSigner(client: ccc.Client):
|
|
7
|
+
export declare function getOKXBitcoinSigner(client: ccc.Client, preferredNetworks: ccc.NetworkPreference[]): ccc.Signer[];
|
|
9
8
|
//# 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;
|
|
1
|
+
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,EAAE,GACzC,GAAG,CAAC,MAAM,EAAE,CAad"}
|
package/dist/signersFactory.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { BitcoinSigner } from "./
|
|
1
|
+
import { BitcoinSigner } from "./btc";
|
|
2
|
+
import { SignerNostr } from "./nostr";
|
|
2
3
|
/**
|
|
3
4
|
* Retrieves the OKX Bitcoin signer if available.
|
|
4
5
|
* @param {ccc.Client} client - The client instance.
|
|
5
6
|
* @returns {BitcoinSigner | undefined} The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
6
7
|
*/
|
|
7
|
-
export function getOKXBitcoinSigner(client) {
|
|
8
|
+
export function getOKXBitcoinSigner(client, preferredNetworks) {
|
|
8
9
|
const windowRef = window;
|
|
9
10
|
if (typeof windowRef.okxwallet === "undefined") {
|
|
10
|
-
return
|
|
11
|
+
return [];
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return [
|
|
14
|
+
new BitcoinSigner(client, windowRef.okxwallet, preferredNetworks),
|
|
15
|
+
new SignerNostr(client, windowRef.okxwallet.nostr),
|
|
16
|
+
];
|
|
13
17
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as OkxA from "./advancedBarrel";
|
|
2
|
-
//# sourceMappingURL=advanced.d.ts.map
|
|
2
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) {
|
|
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) {
|
|
37
19
|
if (mod && mod.__esModule) return mod;
|
|
38
20
|
var result = {};
|
|
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);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
43
22
|
__setModuleDefault(result, mod);
|
|
44
23
|
return result;
|
|
45
|
-
|
|
24
|
+
};
|
|
46
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
26
|
exports.OkxA = void 0;
|
|
48
27
|
exports.OkxA = __importStar(require("./advancedBarrel"));
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface BitcoinProvider
|
|
3
|
-
|
|
1
|
+
import { Nip07A } from "@ckb-ccc/nip07/advanced";
|
|
2
|
+
export interface BitcoinProvider {
|
|
3
|
+
connect(): Promise<{
|
|
4
|
+
address: string;
|
|
5
|
+
publicKey: string;
|
|
6
|
+
compressedPublicKey: string;
|
|
7
|
+
}>;
|
|
8
|
+
getSelectedAccount(): Promise<{
|
|
9
|
+
address: string;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
compressedPublicKey: string;
|
|
12
|
+
} | null>;
|
|
13
|
+
signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
export interface NostrProvider extends Nip07A.Provider {
|
|
16
|
+
selectedAccount: {
|
|
17
|
+
address: string;
|
|
18
|
+
publicKey: string;
|
|
19
|
+
} | null;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=advancedBarrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,OAAO,IAAI,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;IAEH,kBAAkB,IAAI,OAAO,CAAC;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,GAAG,IAAI,CAAC,CAAC;IAEV,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,QAAQ;IACpD,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./btc";
|
|
2
2
|
export * from "./signersFactory";
|
|
3
|
-
//# sourceMappingURL=barrel.d.ts.map
|
|
3
|
+
//# sourceMappingURL=barrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,kBAAkB,CAAC"}
|
package/dist.commonjs/barrel.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
};
|
|
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
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./btc"), exports);
|
|
34
18
|
__exportStar(require("./signersFactory"), exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ccc, Client } from "@ckb-ccc/core";
|
|
2
|
+
import { BitcoinProvider } from "../advancedBarrel";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {ccc.SignerBtc}
|
|
7
|
+
*/
|
|
8
|
+
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
9
|
+
readonly providers: Record<string, BitcoinProvider>;
|
|
10
|
+
private readonly preferredNetworks;
|
|
11
|
+
private network;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of Signer.
|
|
14
|
+
* @param {ccc.Client} client - The client instance.
|
|
15
|
+
* @param {Provider} provider - The provider instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(client: ccc.Client, providers: Record<string, BitcoinProvider>, preferredNetworks: ccc.NetworkPreference[]);
|
|
18
|
+
get provider(): BitcoinProvider;
|
|
19
|
+
/**
|
|
20
|
+
* Get account info if the signer is connected.
|
|
21
|
+
* @returns Account information
|
|
22
|
+
*/
|
|
23
|
+
assertConnection(): Promise<{
|
|
24
|
+
address: string;
|
|
25
|
+
publicKey: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the Bitcoin account address.
|
|
29
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
30
|
+
*/
|
|
31
|
+
getBtcAccount(): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the Bitcoin public key.
|
|
34
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
35
|
+
*/
|
|
36
|
+
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
37
|
+
/**
|
|
38
|
+
* Connects to the provider by requesting accounts.
|
|
39
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
40
|
+
*/
|
|
41
|
+
connect(): Promise<void>;
|
|
42
|
+
replaceClient(client: Client): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the signer is connected.
|
|
45
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
46
|
+
*/
|
|
47
|
+
isConnected(): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Signs a raw message with the Bitcoin account.
|
|
50
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
51
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
52
|
+
*/
|
|
53
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;aAU5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAC1D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAVpC,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,EAAE;IAK7D,IAAI,QAAQ,IAAI,eAAe,CAwB9B;IAED;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAQzE;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAIzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMrD;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAMvE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinSigner = void 0;
|
|
4
|
+
const core_1 = require("@ckb-ccc/core");
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
7
|
+
* @class
|
|
8
|
+
* @extends {ccc.SignerBtc}
|
|
9
|
+
*/
|
|
10
|
+
class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of Signer.
|
|
13
|
+
* @param {ccc.Client} client - The client instance.
|
|
14
|
+
* @param {Provider} provider - The provider instance.
|
|
15
|
+
*/
|
|
16
|
+
constructor(client, providers, preferredNetworks) {
|
|
17
|
+
super(client);
|
|
18
|
+
this.providers = providers;
|
|
19
|
+
this.preferredNetworks = preferredNetworks;
|
|
20
|
+
this.network = "btcTestnet";
|
|
21
|
+
}
|
|
22
|
+
get provider() {
|
|
23
|
+
const { network } = this.matchNetworkPreference(this.preferredNetworks, this.network) ?? { network: this.network };
|
|
24
|
+
this.network = network;
|
|
25
|
+
const chain = {
|
|
26
|
+
btc: "bitcoin",
|
|
27
|
+
btcTestnet: "bitcoinTestnet",
|
|
28
|
+
btcSignet: "bitcoinSignet",
|
|
29
|
+
}[network];
|
|
30
|
+
if (!chain) {
|
|
31
|
+
throw new Error(`OKX wallet doesn't support the requested chain ${this.network}`);
|
|
32
|
+
}
|
|
33
|
+
const provider = this.providers[chain];
|
|
34
|
+
if (!provider) {
|
|
35
|
+
throw new Error(`OKX wallet doesn't support the requested chain ${this.network}`);
|
|
36
|
+
}
|
|
37
|
+
return provider;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get account info if the signer is connected.
|
|
41
|
+
* @returns Account information
|
|
42
|
+
*/
|
|
43
|
+
async assertConnection() {
|
|
44
|
+
const account = await this.provider.getSelectedAccount();
|
|
45
|
+
if (!account) {
|
|
46
|
+
throw Error("Not connected");
|
|
47
|
+
}
|
|
48
|
+
return account;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the Bitcoin account address.
|
|
52
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
53
|
+
*/
|
|
54
|
+
async getBtcAccount() {
|
|
55
|
+
return (await this.assertConnection()).address;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the Bitcoin public key.
|
|
59
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
60
|
+
*/
|
|
61
|
+
async getBtcPublicKey() {
|
|
62
|
+
return core_1.ccc.hexFrom((await this.assertConnection()).publicKey);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Connects to the provider by requesting accounts.
|
|
66
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
67
|
+
*/
|
|
68
|
+
async connect() {
|
|
69
|
+
await this.provider.connect();
|
|
70
|
+
}
|
|
71
|
+
async replaceClient(client) {
|
|
72
|
+
const res = await super.replaceClient(client);
|
|
73
|
+
this.provider; // Check if the network is valid
|
|
74
|
+
return res;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Checks if the signer is connected.
|
|
78
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
79
|
+
*/
|
|
80
|
+
async isConnected() {
|
|
81
|
+
return (await this.provider.getSelectedAccount()) !== null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Signs a raw message with the Bitcoin account.
|
|
85
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
86
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
87
|
+
*/
|
|
88
|
+
async signMessageRaw(message) {
|
|
89
|
+
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
90
|
+
return this.provider.signMessage(challenge, "ecdsa");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.BitcoinSigner = BitcoinSigner;
|
package/dist.commonjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as Okx from "./barrel";
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist.commonjs/index.js
CHANGED
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) {
|
|
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) {
|
|
37
19
|
if (mod && mod.__esModule) return mod;
|
|
38
20
|
var result = {};
|
|
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);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
43
22
|
__setModuleDefault(result, mod);
|
|
44
23
|
return result;
|
|
45
|
-
|
|
24
|
+
};
|
|
46
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
26
|
exports.Okx = void 0;
|
|
48
27
|
exports.Okx = __importStar(require("./barrel"));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { NostrProvider } from "../advancedBarrel";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {ccc.SignerBtc}
|
|
7
|
+
*/
|
|
8
|
+
export declare class SignerNostr extends ccc.SignerNostr {
|
|
9
|
+
readonly provider: NostrProvider;
|
|
10
|
+
constructor(client: ccc.Client, provider: NostrProvider);
|
|
11
|
+
replaceClient(client: ccc.Client): Promise<boolean>;
|
|
12
|
+
getNostrPublicKey(): Promise<ccc.Hex>;
|
|
13
|
+
signNostrEvent(event: ccc.NostrEvent): Promise<Required<ccc.NostrEvent>>;
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
isConnected(): Promise<boolean>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,mBAAmB,CAAC;AAElD;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,GAAG,CAAC,WAAW;aAG5B,QAAQ,EAAE,aAAa;gBADvC,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,aAAa;IAKnC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAQrC,cAAc,CAClB,KAAK,EAAE,GAAG,CAAC,UAAU,GACpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAI9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGtC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerNostr = void 0;
|
|
4
|
+
const core_1 = require("@ckb-ccc/core");
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
7
|
+
* @class
|
|
8
|
+
* @extends {ccc.SignerBtc}
|
|
9
|
+
*/
|
|
10
|
+
class SignerNostr extends core_1.ccc.SignerNostr {
|
|
11
|
+
constructor(client, provider) {
|
|
12
|
+
super(client);
|
|
13
|
+
this.provider = provider;
|
|
14
|
+
}
|
|
15
|
+
async replaceClient(client) {
|
|
16
|
+
return super.replaceClient(client);
|
|
17
|
+
}
|
|
18
|
+
async getNostrPublicKey() {
|
|
19
|
+
if (!this.provider.selectedAccount) {
|
|
20
|
+
throw new Error("Not connected");
|
|
21
|
+
}
|
|
22
|
+
return core_1.ccc.hexFrom(this.provider.selectedAccount.publicKey);
|
|
23
|
+
}
|
|
24
|
+
async signNostrEvent(event) {
|
|
25
|
+
return this.provider.signEvent(event);
|
|
26
|
+
}
|
|
27
|
+
async connect() {
|
|
28
|
+
await this.provider.getPublicKey();
|
|
29
|
+
}
|
|
30
|
+
async isConnected() {
|
|
31
|
+
return this.provider.selectedAccount !== null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.SignerNostr = SignerNostr;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { BitcoinSigner } from "./signer";
|
|
3
2
|
/**
|
|
4
3
|
* Retrieves the OKX Bitcoin signer if available.
|
|
5
4
|
* @param {ccc.Client} client - The client instance.
|
|
6
5
|
* @returns {BitcoinSigner | undefined} The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
7
6
|
*/
|
|
8
|
-
export declare function getOKXBitcoinSigner(
|
|
9
|
-
|
|
10
|
-
): BitcoinSigner | undefined;
|
|
11
|
-
//# sourceMappingURL=signersFactory.d.ts.map
|
|
7
|
+
export declare function getOKXBitcoinSigner(client: ccc.Client, preferredNetworks: ccc.NetworkPreference[]): ccc.Signer[];
|
|
8
|
+
//# 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;
|
|
1
|
+
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,EAAE,GACzC,GAAG,CAAC,MAAM,EAAE,CAad"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOKXBitcoinSigner = void 0;
|
|
4
|
-
const
|
|
4
|
+
const btc_1 = require("./btc");
|
|
5
|
+
const nostr_1 = require("./nostr");
|
|
5
6
|
/**
|
|
6
7
|
* Retrieves the OKX Bitcoin signer if available.
|
|
7
8
|
* @param {ccc.Client} client - The client instance.
|
|
8
9
|
* @returns {BitcoinSigner | undefined} The BitcoinSigner instance if the OKX wallet is available, otherwise undefined.
|
|
9
10
|
*/
|
|
10
|
-
function getOKXBitcoinSigner(client) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
function getOKXBitcoinSigner(client, preferredNetworks) {
|
|
12
|
+
const windowRef = window;
|
|
13
|
+
if (typeof windowRef.okxwallet === "undefined") {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return [
|
|
17
|
+
new btc_1.BitcoinSigner(client, windowRef.okxwallet, preferredNetworks),
|
|
18
|
+
new nostr_1.SignerNostr(client, windowRef.okxwallet.nostr),
|
|
19
|
+
];
|
|
16
20
|
}
|
|
17
21
|
exports.getOKXBitcoinSigner = getOKXBitcoinSigner;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/okx",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Common Chains Connector's support for OKX",
|
|
3
|
+
"version": "0.0.9-alpha.0",
|
|
4
|
+
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for OKX",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ckb-ccc/core": "0.0.
|
|
46
|
-
"@ckb-ccc/
|
|
45
|
+
"@ckb-ccc/core": "0.0.9-alpha.0",
|
|
46
|
+
"@ckb-ccc/nip07": "0.0.9-alpha.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ac4435006da9c9e48b3b66fc329e6f539156b252"
|
|
49
49
|
}
|
package/src/advancedBarrel.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Nip07A } from "@ckb-ccc/nip07/advanced";
|
|
2
2
|
|
|
3
|
-
export interface BitcoinProvider
|
|
3
|
+
export interface BitcoinProvider {
|
|
4
|
+
connect(): Promise<{
|
|
5
|
+
address: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
compressedPublicKey: string;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
getSelectedAccount(): Promise<{
|
|
11
|
+
address: string;
|
|
12
|
+
publicKey: string;
|
|
13
|
+
compressedPublicKey: string;
|
|
14
|
+
} | null>;
|
|
15
|
+
|
|
16
|
+
signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NostrProvider extends Nip07A.Provider {
|
|
20
|
+
selectedAccount: { address: string; publicKey: string } | null;
|
|
21
|
+
}
|
package/src/barrel.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./btc";
|
|
2
2
|
export * from "./signersFactory";
|
package/src/btc/index.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { ccc, Client } from "@ckb-ccc/core";
|
|
2
|
+
import { BitcoinProvider } from "../advancedBarrel";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
6
|
+
* @class
|
|
7
|
+
* @extends {ccc.SignerBtc}
|
|
8
|
+
*/
|
|
9
|
+
export class BitcoinSigner extends ccc.SignerBtc {
|
|
10
|
+
private network = "btcTestnet";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of Signer.
|
|
14
|
+
* @param {ccc.Client} client - The client instance.
|
|
15
|
+
* @param {Provider} provider - The provider instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
client: ccc.Client,
|
|
19
|
+
public readonly providers: Record<string, BitcoinProvider>,
|
|
20
|
+
private readonly preferredNetworks: ccc.NetworkPreference[],
|
|
21
|
+
) {
|
|
22
|
+
super(client);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get provider(): BitcoinProvider {
|
|
26
|
+
const { network } = this.matchNetworkPreference(
|
|
27
|
+
this.preferredNetworks,
|
|
28
|
+
this.network,
|
|
29
|
+
) ?? { network: this.network };
|
|
30
|
+
this.network = network;
|
|
31
|
+
|
|
32
|
+
const chain = {
|
|
33
|
+
btc: "bitcoin",
|
|
34
|
+
btcTestnet: "bitcoinTestnet",
|
|
35
|
+
btcSignet: "bitcoinSignet",
|
|
36
|
+
}[network];
|
|
37
|
+
if (!chain) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`OKX wallet doesn't support the requested chain ${this.network}`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const provider = this.providers[chain];
|
|
43
|
+
if (!provider) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`OKX wallet doesn't support the requested chain ${this.network}`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return provider;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get account info if the signer is connected.
|
|
53
|
+
* @returns Account information
|
|
54
|
+
*/
|
|
55
|
+
async assertConnection(): Promise<{ address: string; publicKey: string }> {
|
|
56
|
+
const account = await this.provider.getSelectedAccount();
|
|
57
|
+
if (!account) {
|
|
58
|
+
throw Error("Not connected");
|
|
59
|
+
}
|
|
60
|
+
return account;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Gets the Bitcoin account address.
|
|
65
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
66
|
+
*/
|
|
67
|
+
async getBtcAccount(): Promise<string> {
|
|
68
|
+
return (await this.assertConnection()).address;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the Bitcoin public key.
|
|
73
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
74
|
+
*/
|
|
75
|
+
async getBtcPublicKey(): Promise<ccc.Hex> {
|
|
76
|
+
return ccc.hexFrom((await this.assertConnection()).publicKey);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Connects to the provider by requesting accounts.
|
|
81
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
82
|
+
*/
|
|
83
|
+
async connect(): Promise<void> {
|
|
84
|
+
await this.provider.connect();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async replaceClient(client: Client): Promise<boolean> {
|
|
88
|
+
const res = await super.replaceClient(client);
|
|
89
|
+
this.provider; // Check if the network is valid
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Checks if the signer is connected.
|
|
95
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
96
|
+
*/
|
|
97
|
+
async isConnected(): Promise<boolean> {
|
|
98
|
+
return (await this.provider.getSelectedAccount()) !== null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Signs a raw message with the Bitcoin account.
|
|
103
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
104
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
105
|
+
*/
|
|
106
|
+
async signMessageRaw(message: string | ccc.BytesLike): Promise<string> {
|
|
107
|
+
const challenge =
|
|
108
|
+
typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
109
|
+
|
|
110
|
+
return this.provider.signMessage(challenge, "ecdsa");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { NostrProvider } from "../advancedBarrel";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
6
|
+
* @class
|
|
7
|
+
* @extends {ccc.SignerBtc}
|
|
8
|
+
*/
|
|
9
|
+
export class SignerNostr extends ccc.SignerNostr {
|
|
10
|
+
constructor(
|
|
11
|
+
client: ccc.Client,
|
|
12
|
+
public readonly provider: NostrProvider,
|
|
13
|
+
) {
|
|
14
|
+
super(client);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async replaceClient(client: ccc.Client): Promise<boolean> {
|
|
18
|
+
return super.replaceClient(client);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getNostrPublicKey(): Promise<ccc.Hex> {
|
|
22
|
+
if (!this.provider.selectedAccount) {
|
|
23
|
+
throw new Error("Not connected");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return ccc.hexFrom(this.provider.selectedAccount.publicKey);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async signNostrEvent(
|
|
30
|
+
event: ccc.NostrEvent,
|
|
31
|
+
): Promise<Required<ccc.NostrEvent>> {
|
|
32
|
+
return this.provider.signEvent(event);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async connect(): Promise<void> {
|
|
36
|
+
await this.provider.getPublicKey();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async isConnected(): Promise<boolean> {
|
|
40
|
+
return this.provider.selectedAccount !== null;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/signersFactory.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { BitcoinProvider } from "./advancedBarrel";
|
|
3
|
-
import { BitcoinSigner } from "./
|
|
2
|
+
import { BitcoinProvider, NostrProvider } from "./advancedBarrel";
|
|
3
|
+
import { BitcoinSigner } from "./btc";
|
|
4
|
+
import { SignerNostr } from "./nostr";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Retrieves the OKX Bitcoin signer if available.
|
|
@@ -9,12 +10,18 @@ import { BitcoinSigner } from "./signer";
|
|
|
9
10
|
*/
|
|
10
11
|
export function getOKXBitcoinSigner(
|
|
11
12
|
client: ccc.Client,
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
preferredNetworks: ccc.NetworkPreference[],
|
|
14
|
+
): ccc.Signer[] {
|
|
15
|
+
const windowRef = window as {
|
|
16
|
+
okxwallet?: Record<string, BitcoinProvider> & { nostr: NostrProvider };
|
|
17
|
+
};
|
|
14
18
|
|
|
15
19
|
if (typeof windowRef.okxwallet === "undefined") {
|
|
16
|
-
return
|
|
20
|
+
return [];
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
return
|
|
23
|
+
return [
|
|
24
|
+
new BitcoinSigner(client, windowRef.okxwallet, preferredNetworks),
|
|
25
|
+
new SignerNostr(client, windowRef.okxwallet.nostr),
|
|
26
|
+
];
|
|
20
27
|
}
|
package/dist/signer.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { UniSat } from "@ckb-ccc/uni-sat";
|
|
3
|
-
import { BitcoinProvider } from "./advancedBarrel";
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a Bitcoin signer that extends the UniSat Signer.
|
|
6
|
-
* @class
|
|
7
|
-
* @extends {UniSat.Signer}
|
|
8
|
-
*/
|
|
9
|
-
export declare class BitcoinSigner extends UniSat.Signer {
|
|
10
|
-
readonly provider: BitcoinProvider;
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of BitcoinSigner.
|
|
13
|
-
* @param {ccc.Client} client - The client instance.
|
|
14
|
-
* @param {BitcoinProvider} provider - The Bitcoin provider.
|
|
15
|
-
*/
|
|
16
|
-
constructor(client: ccc.Client, provider: BitcoinProvider);
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=signer.d.ts.map
|
package/dist/signer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,MAAM;aAQ5B,QAAQ,EAAE,eAAe;IAP3C;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,eAAe;CAI5C"}
|
package/dist/signer.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { UniSat } from "@ckb-ccc/uni-sat";
|
|
2
|
-
/**
|
|
3
|
-
* Class representing a Bitcoin signer that extends the UniSat Signer.
|
|
4
|
-
* @class
|
|
5
|
-
* @extends {UniSat.Signer}
|
|
6
|
-
*/
|
|
7
|
-
export class BitcoinSigner extends UniSat.Signer {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of BitcoinSigner.
|
|
10
|
-
* @param {ccc.Client} client - The client instance.
|
|
11
|
-
* @param {BitcoinProvider} provider - The Bitcoin provider.
|
|
12
|
-
*/
|
|
13
|
-
constructor(client, provider) {
|
|
14
|
-
super(client, provider);
|
|
15
|
-
this.provider = provider;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { UniSat } from "@ckb-ccc/uni-sat";
|
|
3
|
-
import { BitcoinProvider } from "./advancedBarrel";
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a Bitcoin signer that extends the UniSat Signer.
|
|
6
|
-
* @class
|
|
7
|
-
* @extends {UniSat.Signer}
|
|
8
|
-
*/
|
|
9
|
-
export declare class BitcoinSigner extends UniSat.Signer {
|
|
10
|
-
readonly provider: BitcoinProvider;
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of BitcoinSigner.
|
|
13
|
-
* @param {ccc.Client} client - The client instance.
|
|
14
|
-
* @param {BitcoinProvider} provider - The Bitcoin provider.
|
|
15
|
-
*/
|
|
16
|
-
constructor(client: ccc.Client, provider: BitcoinProvider);
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,MAAM;aAQ5B,QAAQ,EAAE,eAAe;IAP3C;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,eAAe;CAI5C"}
|
package/dist.commonjs/signer.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinSigner = void 0;
|
|
4
|
-
const uni_sat_1 = require("@ckb-ccc/uni-sat");
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a Bitcoin signer that extends the UniSat Signer.
|
|
7
|
-
* @class
|
|
8
|
-
* @extends {UniSat.Signer}
|
|
9
|
-
*/
|
|
10
|
-
class BitcoinSigner extends uni_sat_1.UniSat.Signer {
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of BitcoinSigner.
|
|
13
|
-
* @param {ccc.Client} client - The client instance.
|
|
14
|
-
* @param {BitcoinProvider} provider - The Bitcoin provider.
|
|
15
|
-
*/
|
|
16
|
-
constructor(client, provider) {
|
|
17
|
-
super(client, provider);
|
|
18
|
-
this.provider = provider;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.BitcoinSigner = BitcoinSigner;
|
package/src/signer.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { UniSat } from "@ckb-ccc/uni-sat";
|
|
3
|
-
import { BitcoinProvider } from "./advancedBarrel";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a Bitcoin signer that extends the UniSat Signer.
|
|
7
|
-
* @class
|
|
8
|
-
* @extends {UniSat.Signer}
|
|
9
|
-
*/
|
|
10
|
-
export class BitcoinSigner extends UniSat.Signer {
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of BitcoinSigner.
|
|
13
|
-
* @param {ccc.Client} client - The client instance.
|
|
14
|
-
* @param {BitcoinProvider} provider - The Bitcoin provider.
|
|
15
|
-
*/
|
|
16
|
-
constructor(
|
|
17
|
-
client: ccc.Client,
|
|
18
|
-
public readonly provider: BitcoinProvider,
|
|
19
|
-
) {
|
|
20
|
-
super(client, provider);
|
|
21
|
-
}
|
|
22
|
-
}
|