@ckb-ccc/joy-id 1.0.33 → 1.1.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 +13 -0
- package/dist/advanced.d.mts +2 -0
- package/dist/advanced.mjs +1 -0
- package/dist/advancedBarrel.d.mts +44 -0
- package/dist/advancedBarrel.d.mts.map +1 -0
- package/dist/advancedBarrel.mjs +2 -0
- package/dist/advancedBarrel.mjs.map +1 -0
- package/dist/barrel.d.mts +339 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +2 -0
- package/dist/barrel.mjs.map +1 -0
- package/dist/connectionsStorage-BloUSPun.mjs +2 -0
- package/dist/connectionsStorage-BloUSPun.mjs.map +1 -0
- package/dist/index-DGqAOLbu.d.mts +91 -0
- package/dist/index-DGqAOLbu.d.mts.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/dist.commonjs/advanced.d.ts +2 -2
- package/dist.commonjs/advanced.js +1 -37
- package/dist.commonjs/advancedBarrel.d.ts +43 -2
- package/dist.commonjs/advancedBarrel.d.ts.map +1 -1
- package/dist.commonjs/advancedBarrel.js +2 -18
- package/dist.commonjs/advancedBarrel.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +338 -5
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +2 -21
- package/dist.commonjs/barrel.js.map +1 -0
- package/dist.commonjs/connectionsStorage-CQE3XNWI.js +2 -0
- package/dist.commonjs/connectionsStorage-CQE3XNWI.js.map +1 -0
- package/dist.commonjs/index-CJeW3ePH.d.ts +93 -0
- package/dist.commonjs/index-CJeW3ePH.d.ts.map +1 -0
- package/dist.commonjs/index.d.ts +2 -2
- package/dist.commonjs/index.js +1 -37
- package/package.json +32 -20
- package/tsdown.config.mts +43 -0
- package/dist/advanced.d.ts +0 -2
- package/dist/advanced.d.ts.map +0 -1
- package/dist/advanced.js +0 -1
- package/dist/advancedBarrel.d.ts +0 -3
- package/dist/advancedBarrel.d.ts.map +0 -1
- package/dist/advancedBarrel.js +0 -2
- package/dist/barrel.d.ts +0 -6
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -5
- package/dist/btc/index.d.ts +0 -81
- package/dist/btc/index.d.ts.map +0 -1
- package/dist/btc/index.js +0 -197
- package/dist/ckb/index.d.ts +0 -117
- package/dist/ckb/index.d.ts.map +0 -1
- package/dist/ckb/index.js +0 -267
- package/dist/common/index.d.ts +0 -36
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js +0 -61
- package/dist/connectionsStorage/index.d.ts +0 -87
- package/dist/connectionsStorage/index.d.ts.map +0 -1
- package/dist/connectionsStorage/index.js +0 -65
- package/dist/evm/index.d.ts +0 -66
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js +0 -129
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/nostr/index.d.ts +0 -57
- package/dist/nostr/index.d.ts.map +0 -1
- package/dist/nostr/index.js +0 -116
- package/dist/signerFactory/index.d.ts +0 -14
- package/dist/signerFactory/index.d.ts.map +0 -1
- package/dist/signerFactory/index.js +0 -51
- package/dist.commonjs/advanced.d.ts.map +0 -1
- package/dist.commonjs/btc/index.d.ts +0 -81
- package/dist.commonjs/btc/index.d.ts.map +0 -1
- package/dist.commonjs/btc/index.js +0 -201
- package/dist.commonjs/ckb/index.d.ts +0 -117
- package/dist.commonjs/ckb/index.d.ts.map +0 -1
- package/dist.commonjs/ckb/index.js +0 -271
- package/dist.commonjs/common/index.d.ts +0 -36
- package/dist.commonjs/common/index.d.ts.map +0 -1
- package/dist.commonjs/common/index.js +0 -64
- package/dist.commonjs/connectionsStorage/index.d.ts +0 -87
- package/dist.commonjs/connectionsStorage/index.d.ts.map +0 -1
- package/dist.commonjs/connectionsStorage/index.js +0 -70
- package/dist.commonjs/evm/index.d.ts +0 -66
- package/dist.commonjs/evm/index.d.ts.map +0 -1
- package/dist.commonjs/evm/index.js +0 -133
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/nostr/index.d.ts +0 -57
- package/dist.commonjs/nostr/index.d.ts.map +0 -1
- package/dist.commonjs/nostr/index.js +0 -120
- package/dist.commonjs/signerFactory/index.d.ts +0 -14
- package/dist.commonjs/signerFactory/index.d.ts.map +0 -1
- package/dist.commonjs/signerFactory/index.js +0 -54
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
8
|
-
readonly name: string;
|
|
9
|
-
readonly icon: string;
|
|
10
|
-
private readonly preferredNetworks;
|
|
11
|
-
readonly addressType: "auto" | "p2wpkh" | "p2tr";
|
|
12
|
-
private readonly _appUri?;
|
|
13
|
-
private readonly connectionsRepo;
|
|
14
|
-
private connection?;
|
|
15
|
-
private network;
|
|
16
|
-
/**
|
|
17
|
-
* Ensures that the signer is connected and returns the connection.
|
|
18
|
-
* @throws Will throw an error if not connected.
|
|
19
|
-
* @returns The current connection.
|
|
20
|
-
*/
|
|
21
|
-
private assertConnection;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an instance of BitcoinSigner.
|
|
24
|
-
* @param client - The client instance.
|
|
25
|
-
* @param name - The name of the signer.
|
|
26
|
-
* @param icon - The icon URL of the signer.
|
|
27
|
-
* @param addressType - The address type.
|
|
28
|
-
* @param _appUri - The application URI.
|
|
29
|
-
* @param connectionsRepo - The connections repository.
|
|
30
|
-
*/
|
|
31
|
-
constructor(client: ccc.Client, name: string, icon: string, preferredNetworks?: ccc.NetworkPreference[], addressType?: "auto" | "p2wpkh" | "p2tr", _appUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
32
|
-
/**
|
|
33
|
-
* Gets the configuration for JoyID.
|
|
34
|
-
* @returns The configuration object.
|
|
35
|
-
*/
|
|
36
|
-
private getConfig;
|
|
37
|
-
disconnect(): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Gets the Bitcoin account address.
|
|
40
|
-
* @returns A promise that resolves to the Bitcoin account address.
|
|
41
|
-
*/
|
|
42
|
-
getBtcAccount(): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Gets the Bitcoin public key.
|
|
45
|
-
* @returns A promise that resolves to the Bitcoin public key.
|
|
46
|
-
*/
|
|
47
|
-
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
48
|
-
/**
|
|
49
|
-
* Connects to the provider by requesting authentication.
|
|
50
|
-
* @returns A promise that resolves when the connection is established.
|
|
51
|
-
*/
|
|
52
|
-
connect(): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Checks if the signer is connected.
|
|
55
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
56
|
-
*/
|
|
57
|
-
isConnected(): Promise<boolean>;
|
|
58
|
-
/**
|
|
59
|
-
* Signs a raw message with the Bitcoin account.
|
|
60
|
-
* @param message - The message to sign.
|
|
61
|
-
* @returns A promise that resolves to the signed message.
|
|
62
|
-
*/
|
|
63
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
64
|
-
/**
|
|
65
|
-
* Signs a PSBT using JoyID wallet.
|
|
66
|
-
*
|
|
67
|
-
* @param psbtHex - The hex string of PSBT to sign.
|
|
68
|
-
* @returns A promise that resolves to the signed PSBT as a Hex string.
|
|
69
|
-
*/
|
|
70
|
-
signPsbt(psbtHex: ccc.HexLike, options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
|
|
71
|
-
/**
|
|
72
|
-
* Broadcasts a PSBT to the Bitcoin network.
|
|
73
|
-
*
|
|
74
|
-
* @remarks
|
|
75
|
-
* JoyID does not support broadcasting a signed PSBT directly.
|
|
76
|
-
* It only supports "Sign and Broadcast" as a single atomic operation via `signAndBroadcastPsbt`.
|
|
77
|
-
*/
|
|
78
|
-
broadcastPsbt(_psbtHex: ccc.HexLike, _options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
|
|
79
|
-
signAndBroadcastPsbt(psbtHex: ccc.HexLike, options?: ccc.SignPsbtOptionsLike): Promise<ccc.Hex>;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;YACW,gBAAgB;IAQ9B;;;;;;;;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,EAAE,MAAM,YAAA,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;IAuBtE;;;;;OAKG;IACG,QAAQ,CACZ,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,OAAO,CAAC,EAAE,GAAG,CAAC,mBAAmB,GAChC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAuBnB;;;;;;OAMG;IACG,aAAa,CACjB,QAAQ,EAAE,GAAG,CAAC,OAAO,EACrB,QAAQ,CAAC,EAAE,GAAG,CAAC,mBAAmB,GACjC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAMb,oBAAoB,CACxB,OAAO,EAAE,GAAG,CAAC,OAAO,EACpB,OAAO,CAAC,EAAE,GAAG,CAAC,mBAAmB,GAChC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAwBpB"}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinSigner = void 0;
|
|
4
|
-
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
const common_1 = require("@joyid/common");
|
|
6
|
-
const index_js_1 = require("../common/index.js");
|
|
7
|
-
const index_js_2 = require("../connectionsStorage/index.js");
|
|
8
|
-
/**
|
|
9
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
13
|
-
/**
|
|
14
|
-
* Ensures that the signer is connected and returns the connection.
|
|
15
|
-
* @throws Will throw an error if not connected.
|
|
16
|
-
* @returns The current connection.
|
|
17
|
-
*/
|
|
18
|
-
async assertConnection() {
|
|
19
|
-
if (!(await this.isConnected()) || !this.connection) {
|
|
20
|
-
throw new Error("Not connected");
|
|
21
|
-
}
|
|
22
|
-
return this.connection;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Creates an instance of BitcoinSigner.
|
|
26
|
-
* @param client - The client instance.
|
|
27
|
-
* @param name - The name of the signer.
|
|
28
|
-
* @param icon - The icon URL of the signer.
|
|
29
|
-
* @param addressType - The address type.
|
|
30
|
-
* @param _appUri - The application URI.
|
|
31
|
-
* @param connectionsRepo - The connections repository.
|
|
32
|
-
*/
|
|
33
|
-
constructor(client, name, icon, preferredNetworks = [
|
|
34
|
-
{
|
|
35
|
-
addressPrefix: "ckb",
|
|
36
|
-
signerType: core_1.ccc.SignerType.BTC,
|
|
37
|
-
network: "btc",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
addressPrefix: "ckt",
|
|
41
|
-
signerType: core_1.ccc.SignerType.BTC,
|
|
42
|
-
network: "btcTestnet",
|
|
43
|
-
},
|
|
44
|
-
], addressType = "auto", _appUri, connectionsRepo = new index_js_2.ConnectionsRepoLocalStorage()) {
|
|
45
|
-
super(client);
|
|
46
|
-
this.name = name;
|
|
47
|
-
this.icon = icon;
|
|
48
|
-
this.preferredNetworks = preferredNetworks;
|
|
49
|
-
this.addressType = addressType;
|
|
50
|
-
this._appUri = _appUri;
|
|
51
|
-
this.connectionsRepo = connectionsRepo;
|
|
52
|
-
this.network = "btcTestnet";
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Gets the configuration for JoyID.
|
|
56
|
-
* @returns The configuration object.
|
|
57
|
-
*/
|
|
58
|
-
getConfig() {
|
|
59
|
-
const { network } = this.matchNetworkPreference(this.preferredNetworks, this.network) ?? { network: this.network };
|
|
60
|
-
if (this.network !== network) {
|
|
61
|
-
this.connection = undefined;
|
|
62
|
-
}
|
|
63
|
-
this.network = network;
|
|
64
|
-
const url = {
|
|
65
|
-
btc: "https://app.joy.id",
|
|
66
|
-
btcTestnet: "https://testnet.joyid.dev",
|
|
67
|
-
}[network];
|
|
68
|
-
if (!url) {
|
|
69
|
-
throw new Error(`JoyID wallet doesn't support the requested chain ${this.network}`);
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
redirectURL: location.href,
|
|
73
|
-
joyidAppURL: this._appUri ?? url,
|
|
74
|
-
requestNetwork: `btc-${this.addressType}`,
|
|
75
|
-
name: this.name,
|
|
76
|
-
logo: this.icon,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
async disconnect() {
|
|
80
|
-
await super.disconnect();
|
|
81
|
-
await this.connectionsRepo.set({ uri: this.getConfig().joyidAppURL, addressType: "btc" }, undefined);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Gets the Bitcoin account address.
|
|
85
|
-
* @returns A promise that resolves to the Bitcoin account address.
|
|
86
|
-
*/
|
|
87
|
-
async getBtcAccount() {
|
|
88
|
-
const { address } = await this.assertConnection();
|
|
89
|
-
return address;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Gets the Bitcoin public key.
|
|
93
|
-
* @returns A promise that resolves to the Bitcoin public key.
|
|
94
|
-
*/
|
|
95
|
-
async getBtcPublicKey() {
|
|
96
|
-
const { publicKey } = await this.assertConnection();
|
|
97
|
-
return publicKey;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Connects to the provider by requesting authentication.
|
|
101
|
-
* @returns A promise that resolves when the connection is established.
|
|
102
|
-
*/
|
|
103
|
-
async connect() {
|
|
104
|
-
const config = this.getConfig();
|
|
105
|
-
const res = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
|
|
106
|
-
...config,
|
|
107
|
-
type: common_1.DappRequestType.Auth,
|
|
108
|
-
});
|
|
109
|
-
const { address, pubkey } = (() => {
|
|
110
|
-
if (this.addressType === "auto") {
|
|
111
|
-
return res.btcAddressType === "p2wpkh" ? res.nativeSegwit : res.taproot;
|
|
112
|
-
}
|
|
113
|
-
return this.addressType === "p2wpkh" ? res.nativeSegwit : res.taproot;
|
|
114
|
-
})();
|
|
115
|
-
this.connection = {
|
|
116
|
-
address,
|
|
117
|
-
publicKey: core_1.ccc.hexFrom(pubkey),
|
|
118
|
-
keyType: res.keyType,
|
|
119
|
-
};
|
|
120
|
-
await Promise.all([
|
|
121
|
-
this.connectionsRepo.set({ uri: config.joyidAppURL, addressType: `btc-${this.addressType}` }, this.connection),
|
|
122
|
-
this.connectionsRepo.set({ uri: config.joyidAppURL, addressType: "btc-auto" }, this.connection),
|
|
123
|
-
]);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Checks if the signer is connected.
|
|
127
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
128
|
-
*/
|
|
129
|
-
async isConnected() {
|
|
130
|
-
if (this.connection) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
this.connection = await this.connectionsRepo.get({
|
|
134
|
-
uri: this.getConfig().joyidAppURL,
|
|
135
|
-
addressType: `btc-${this.addressType}`,
|
|
136
|
-
});
|
|
137
|
-
return this.connection !== undefined;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Signs a raw message with the Bitcoin account.
|
|
141
|
-
* @param message - The message to sign.
|
|
142
|
-
* @returns A promise that resolves to the signed message.
|
|
143
|
-
*/
|
|
144
|
-
async signMessageRaw(message) {
|
|
145
|
-
const { address } = await this.assertConnection();
|
|
146
|
-
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
147
|
-
const config = this.getConfig();
|
|
148
|
-
const { signature } = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)({
|
|
149
|
-
...config,
|
|
150
|
-
challenge,
|
|
151
|
-
address,
|
|
152
|
-
signMessageType: "ecdsa",
|
|
153
|
-
}, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
|
|
154
|
-
return signature;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Signs a PSBT using JoyID wallet.
|
|
158
|
-
*
|
|
159
|
-
* @param psbtHex - The hex string of PSBT to sign.
|
|
160
|
-
* @returns A promise that resolves to the signed PSBT as a Hex string.
|
|
161
|
-
*/
|
|
162
|
-
async signPsbt(psbtHex, options) {
|
|
163
|
-
const { address } = await this.assertConnection();
|
|
164
|
-
const formattedOptions = core_1.ccc.SignPsbtOptions.from(options);
|
|
165
|
-
const config = this.getConfig();
|
|
166
|
-
const { tx: signedPsbtHex } = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)({
|
|
167
|
-
...config,
|
|
168
|
-
tx: core_1.ccc.hexFrom(psbtHex).slice(2),
|
|
169
|
-
options: formattedOptions,
|
|
170
|
-
signerAddress: address,
|
|
171
|
-
autoFinalized: formattedOptions.autoFinalized,
|
|
172
|
-
}, "popup", "/sign-psbt"), { ...config, type: common_1.DappRequestType.SignPsbt });
|
|
173
|
-
return core_1.ccc.hexFrom(signedPsbtHex);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Broadcasts a PSBT to the Bitcoin network.
|
|
177
|
-
*
|
|
178
|
-
* @remarks
|
|
179
|
-
* JoyID does not support broadcasting a signed PSBT directly.
|
|
180
|
-
* It only supports "Sign and Broadcast" as a single atomic operation via `signAndBroadcastPsbt`.
|
|
181
|
-
*/
|
|
182
|
-
async broadcastPsbt(_psbtHex, _options) {
|
|
183
|
-
throw new Error("JoyID does not support broadcasting signed PSBTs directly. Use signAndBroadcastPsbt instead.");
|
|
184
|
-
}
|
|
185
|
-
async signAndBroadcastPsbt(psbtHex, options) {
|
|
186
|
-
const { address } = await this.assertConnection();
|
|
187
|
-
const formattedOptions = core_1.ccc.SignPsbtOptions.from(options);
|
|
188
|
-
const config = this.getConfig();
|
|
189
|
-
// ccc.hexFrom adds 0x prefix, but BTC expects non-0x
|
|
190
|
-
const { tx: txid } = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)({
|
|
191
|
-
...config,
|
|
192
|
-
tx: core_1.ccc.hexFrom(psbtHex).slice(2),
|
|
193
|
-
options: formattedOptions,
|
|
194
|
-
signerAddress: address,
|
|
195
|
-
autoFinalized: true, // sendPsbt always finalizes
|
|
196
|
-
isSend: true,
|
|
197
|
-
}, "popup", "/sign-psbt"), { ...config, type: common_1.DappRequestType.SignPsbt });
|
|
198
|
-
return core_1.ccc.hexFrom(txid);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
exports.BitcoinSigner = BitcoinSigner;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { ConnectionsRepo } from "../connectionsStorage/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class representing a CKB signer that extends Signer
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare class CkbSigner extends ccc.Signer {
|
|
8
|
-
private readonly name;
|
|
9
|
-
private readonly icon;
|
|
10
|
-
private readonly _appUri?;
|
|
11
|
-
private readonly _aggregatorUri?;
|
|
12
|
-
private readonly connectionsRepo;
|
|
13
|
-
/**
|
|
14
|
-
* Gets the signer type.
|
|
15
|
-
* @returns The type of the signer.
|
|
16
|
-
*/
|
|
17
|
-
get type(): ccc.SignerType;
|
|
18
|
-
/**
|
|
19
|
-
* Gets the sign type.
|
|
20
|
-
* @returns The sign type.
|
|
21
|
-
*/
|
|
22
|
-
get signType(): ccc.SignerSignType;
|
|
23
|
-
private connection?;
|
|
24
|
-
/**
|
|
25
|
-
* Ensures that the signer is connected and returns the connection.
|
|
26
|
-
* @throws Will throw an error if not connected.
|
|
27
|
-
* @returns A promise that resolves to the current connection.
|
|
28
|
-
*/
|
|
29
|
-
private assertConnection;
|
|
30
|
-
/**
|
|
31
|
-
* Creates an instance of CkbSigner.
|
|
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.
|
|
38
|
-
*/
|
|
39
|
-
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, _aggregatorUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
40
|
-
/**
|
|
41
|
-
* Gets the configuration for JoyID.
|
|
42
|
-
* @returns The configuration object.
|
|
43
|
-
*/
|
|
44
|
-
private getConfig;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the aggregator URI.
|
|
47
|
-
* @returns The aggregator URI.
|
|
48
|
-
*/
|
|
49
|
-
private getAggregatorUri;
|
|
50
|
-
/**
|
|
51
|
-
* Connects to the provider by requesting authentication.
|
|
52
|
-
* @returns A promise that resolves when the connection is established.
|
|
53
|
-
*/
|
|
54
|
-
connect(): Promise<void>;
|
|
55
|
-
disconnect(): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Checks if the signer is connected.
|
|
58
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
59
|
-
*/
|
|
60
|
-
isConnected(): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* Gets the internal address.
|
|
63
|
-
* @returns A promise that resolves to the internal address.
|
|
64
|
-
*/
|
|
65
|
-
getInternalAddress(): Promise<string>;
|
|
66
|
-
/**
|
|
67
|
-
* Gets the identity of the signer.
|
|
68
|
-
* @returns A promise that resolves to the identity.
|
|
69
|
-
*/
|
|
70
|
-
getIdentity(): Promise<string>;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the address object.
|
|
73
|
-
* @returns A promise that resolves to the address object.
|
|
74
|
-
*/
|
|
75
|
-
getAddressObj(): Promise<ccc.Address>;
|
|
76
|
-
/**
|
|
77
|
-
* Gets the address objects.
|
|
78
|
-
* @returns A promise that resolves to an array of address objects.
|
|
79
|
-
*/
|
|
80
|
-
getAddressObjs(): Promise<ccc.Address[]>;
|
|
81
|
-
/**
|
|
82
|
-
* Prepares a transaction.
|
|
83
|
-
* @param txLike - The transaction-like object.
|
|
84
|
-
* @returns A promise that resolves to the prepared transaction.
|
|
85
|
-
*/
|
|
86
|
-
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
87
|
-
/**
|
|
88
|
-
* Prepares a transaction for a sub key.
|
|
89
|
-
* @param tx - The transaction object.
|
|
90
|
-
* @param witness - The witness arguments.
|
|
91
|
-
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
92
|
-
*/
|
|
93
|
-
private prepareTransactionForSubKey;
|
|
94
|
-
/**
|
|
95
|
-
* Signs a transaction.
|
|
96
|
-
* @param txLike - The transaction-like object.
|
|
97
|
-
* @returns A promise that resolves to the signed transaction.
|
|
98
|
-
*/
|
|
99
|
-
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
100
|
-
/**
|
|
101
|
-
* Signs a raw message with the account.
|
|
102
|
-
* @param message - The message to sign.
|
|
103
|
-
* @returns A promise that resolves to the signed message.
|
|
104
|
-
*/
|
|
105
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
106
|
-
/**
|
|
107
|
-
* Saves the current connection.
|
|
108
|
-
* @returns
|
|
109
|
-
*/
|
|
110
|
-
private saveConnection;
|
|
111
|
-
/**
|
|
112
|
-
* Restores the previous connection.
|
|
113
|
-
* @returns
|
|
114
|
-
*/
|
|
115
|
-
private restoreConnection;
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,MAAM,YAAA,EAChB,cAAc,CAAC,EAAE,MAAM,YAAA,EACvB,eAAe,GAAE,eAAmD;IAKvF;;;OAGG;IACH,OAAO,CAAC,SAAS;IAajB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;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;IA4C3B;;;;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"}
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CkbSigner = void 0;
|
|
4
|
-
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
const ckb_1 = require("@joyid/ckb");
|
|
6
|
-
const common_1 = require("@joyid/common");
|
|
7
|
-
const index_js_1 = require("../common/index.js");
|
|
8
|
-
const index_js_2 = require("../connectionsStorage/index.js");
|
|
9
|
-
/**
|
|
10
|
-
* Class representing a CKB signer that extends Signer
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
class CkbSigner extends core_1.ccc.Signer {
|
|
14
|
-
/**
|
|
15
|
-
* Gets the signer type.
|
|
16
|
-
* @returns The type of the signer.
|
|
17
|
-
*/
|
|
18
|
-
get type() {
|
|
19
|
-
return core_1.ccc.SignerType.CKB;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Gets the sign type.
|
|
23
|
-
* @returns The sign type.
|
|
24
|
-
*/
|
|
25
|
-
get signType() {
|
|
26
|
-
return core_1.ccc.SignerSignType.JoyId;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Ensures that the signer is connected and returns the connection.
|
|
30
|
-
* @throws Will throw an error if not connected.
|
|
31
|
-
* @returns A promise that resolves to the current connection.
|
|
32
|
-
*/
|
|
33
|
-
async assertConnection() {
|
|
34
|
-
if (!(await this.isConnected()) || !this.connection) {
|
|
35
|
-
throw new Error("Not connected");
|
|
36
|
-
}
|
|
37
|
-
return this.connection;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Creates an instance of CkbSigner.
|
|
41
|
-
* @param client - The client instance.
|
|
42
|
-
* @param name - The name of the signer.
|
|
43
|
-
* @param icon - The icon URL of the signer.
|
|
44
|
-
* @param _appUri - The application URI.
|
|
45
|
-
* @param _aggregatorUri - The aggregator URI.
|
|
46
|
-
* @param connectionsRepo - The connections repository.
|
|
47
|
-
*/
|
|
48
|
-
constructor(client, name, icon, _appUri, _aggregatorUri, connectionsRepo = new index_js_2.ConnectionsRepoLocalStorage()) {
|
|
49
|
-
super(client);
|
|
50
|
-
this.name = name;
|
|
51
|
-
this.icon = icon;
|
|
52
|
-
this._appUri = _appUri;
|
|
53
|
-
this._aggregatorUri = _aggregatorUri;
|
|
54
|
-
this.connectionsRepo = connectionsRepo;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Gets the configuration for JoyID.
|
|
58
|
-
* @returns The configuration object.
|
|
59
|
-
*/
|
|
60
|
-
getConfig() {
|
|
61
|
-
return {
|
|
62
|
-
redirectURL: location.href,
|
|
63
|
-
joyidAppURL: this._appUri ??
|
|
64
|
-
(this.client.addressPrefix === "ckb"
|
|
65
|
-
? "https://app.joy.id"
|
|
66
|
-
: "https://testnet.joyid.dev"),
|
|
67
|
-
name: this.name,
|
|
68
|
-
logo: this.icon,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Gets the aggregator URI.
|
|
73
|
-
* @returns The aggregator URI.
|
|
74
|
-
*/
|
|
75
|
-
getAggregatorUri() {
|
|
76
|
-
return (this._aggregatorUri ??
|
|
77
|
-
(this.client.addressPrefix === "ckb"
|
|
78
|
-
? "https://cota.nervina.dev/mainnet-aggregator"
|
|
79
|
-
: "https://cota.nervina.dev/aggregator"));
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Connects to the provider by requesting authentication.
|
|
83
|
-
* @returns A promise that resolves when the connection is established.
|
|
84
|
-
*/
|
|
85
|
-
async connect() {
|
|
86
|
-
const config = this.getConfig();
|
|
87
|
-
const res = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
|
|
88
|
-
...config,
|
|
89
|
-
type: common_1.DappRequestType.Auth,
|
|
90
|
-
});
|
|
91
|
-
this.connection = {
|
|
92
|
-
address: res.address,
|
|
93
|
-
publicKey: core_1.ccc.hexFrom(res.pubkey),
|
|
94
|
-
keyType: res.keyType,
|
|
95
|
-
};
|
|
96
|
-
await this.saveConnection();
|
|
97
|
-
}
|
|
98
|
-
async disconnect() {
|
|
99
|
-
await super.disconnect();
|
|
100
|
-
this.connection = undefined;
|
|
101
|
-
await this.saveConnection();
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Checks if the signer is connected.
|
|
105
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
106
|
-
*/
|
|
107
|
-
async isConnected() {
|
|
108
|
-
if (this.connection) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
await this.restoreConnection();
|
|
112
|
-
return this.connection !== undefined;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Gets the internal address.
|
|
116
|
-
* @returns A promise that resolves to the internal address.
|
|
117
|
-
*/
|
|
118
|
-
async getInternalAddress() {
|
|
119
|
-
return (await this.assertConnection()).address;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Gets the identity of the signer.
|
|
123
|
-
* @returns A promise that resolves to the identity.
|
|
124
|
-
*/
|
|
125
|
-
async getIdentity() {
|
|
126
|
-
const connection = await this.assertConnection();
|
|
127
|
-
return JSON.stringify({
|
|
128
|
-
keyType: connection.keyType,
|
|
129
|
-
publicKey: connection.publicKey.slice(2),
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Gets the address object.
|
|
134
|
-
* @returns A promise that resolves to the address object.
|
|
135
|
-
*/
|
|
136
|
-
async getAddressObj() {
|
|
137
|
-
return await core_1.ccc.Address.fromString(await this.getInternalAddress(), this.client);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Gets the address objects.
|
|
141
|
-
* @returns A promise that resolves to an array of address objects.
|
|
142
|
-
*/
|
|
143
|
-
async getAddressObjs() {
|
|
144
|
-
return [await this.getAddressObj()];
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Prepares a transaction.
|
|
148
|
-
* @param txLike - The transaction-like object.
|
|
149
|
-
* @returns A promise that resolves to the prepared transaction.
|
|
150
|
-
*/
|
|
151
|
-
async prepareTransaction(txLike) {
|
|
152
|
-
const tx = core_1.ccc.Transaction.from(txLike);
|
|
153
|
-
await tx.addCellDepsOfKnownScripts(this.client, core_1.ccc.KnownScript.JoyId);
|
|
154
|
-
const position = await tx.findInputIndexByLock((await this.getAddressObj()).script, this.client);
|
|
155
|
-
if (position === undefined) {
|
|
156
|
-
return tx;
|
|
157
|
-
}
|
|
158
|
-
const witness = tx.getWitnessArgsAt(position) ?? core_1.ccc.WitnessArgs.from({});
|
|
159
|
-
witness.lock = core_1.ccc.hexFrom("00".repeat(1000));
|
|
160
|
-
await this.prepareTransactionForSubKey(tx, witness);
|
|
161
|
-
tx.setWitnessArgsAt(position, witness);
|
|
162
|
-
return tx;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Prepares a transaction for a sub key.
|
|
166
|
-
* @param tx - The transaction object.
|
|
167
|
-
* @param witness - The witness arguments.
|
|
168
|
-
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
169
|
-
*/
|
|
170
|
-
async prepareTransactionForSubKey(tx, witness) {
|
|
171
|
-
if (this.connection?.keyType !== "sub_key" ||
|
|
172
|
-
(witness.outputType ?? "0x") !== "0x") {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const pubkeyHash = core_1.ccc.hashCkb(this.connection.publicKey).substring(0, 42);
|
|
176
|
-
const lock = (await this.getAddressObj()).script;
|
|
177
|
-
const aggregator = new ckb_1.Aggregator(this.getAggregatorUri());
|
|
178
|
-
const { unlock_entry: unlockEntry } = await aggregator.generateSubkeyUnlockSmt({
|
|
179
|
-
alg_index: 1,
|
|
180
|
-
pubkey_hash: pubkeyHash,
|
|
181
|
-
lock_script: core_1.ccc.hexFrom(lock.toBytes()),
|
|
182
|
-
});
|
|
183
|
-
witness.outputType = core_1.ccc.hexFrom(unlockEntry);
|
|
184
|
-
const cotaDeps = [];
|
|
185
|
-
for await (const cell of this.client.findCellsByLock(lock, await core_1.ccc.Script.fromKnownScript(this.client, core_1.ccc.KnownScript.COTA, "0x"))) {
|
|
186
|
-
cotaDeps.push(core_1.ccc.CellDep.from({
|
|
187
|
-
depType: "code",
|
|
188
|
-
outPoint: cell.outPoint,
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
if (cotaDeps.length === 0) {
|
|
192
|
-
throw new Error("No COTA cells for sub key wallet");
|
|
193
|
-
}
|
|
194
|
-
tx.addCellDepsAtStart(cotaDeps);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Signs a transaction.
|
|
198
|
-
* @param txLike - The transaction-like object.
|
|
199
|
-
* @returns A promise that resolves to the signed transaction.
|
|
200
|
-
*/
|
|
201
|
-
async signOnlyTransaction(txLike) {
|
|
202
|
-
const tx = core_1.ccc.Transaction.from(txLike);
|
|
203
|
-
const { script } = await this.getAddressObj();
|
|
204
|
-
const witnessIndexes = await core_1.ccc.reduceAsync(tx.inputs, async (acc, input, i) => {
|
|
205
|
-
const { cellOutput } = await input.getCell(this.client);
|
|
206
|
-
if (cellOutput.lock.eq(script)) {
|
|
207
|
-
acc.push(i);
|
|
208
|
-
}
|
|
209
|
-
}, []);
|
|
210
|
-
// Trim unnecessary fields to reduce tx size
|
|
211
|
-
await tx.prepareSighashAllWitness(script, 0, this.client);
|
|
212
|
-
tx.inputs.forEach((i) => {
|
|
213
|
-
i.cellOutput = undefined;
|
|
214
|
-
i.outputData = undefined;
|
|
215
|
-
});
|
|
216
|
-
const config = this.getConfig();
|
|
217
|
-
const res = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)({
|
|
218
|
-
...config,
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
220
|
-
tx: JSON.parse(tx.stringify()),
|
|
221
|
-
signerAddress: (await this.assertConnection()).address,
|
|
222
|
-
witnessIndexes,
|
|
223
|
-
}, "popup", "/sign-ckb-raw-tx"), {
|
|
224
|
-
...config,
|
|
225
|
-
type: common_1.DappRequestType.SignCkbRawTx,
|
|
226
|
-
});
|
|
227
|
-
return core_1.ccc.Transaction.from(res.tx);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Signs a raw message with the account.
|
|
231
|
-
* @param message - The message to sign.
|
|
232
|
-
* @returns A promise that resolves to the signed message.
|
|
233
|
-
*/
|
|
234
|
-
async signMessageRaw(message) {
|
|
235
|
-
const { address } = await this.assertConnection();
|
|
236
|
-
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
237
|
-
const config = this.getConfig();
|
|
238
|
-
const res = await (0, index_js_1.createPopup)((0, common_1.buildJoyIDURL)({
|
|
239
|
-
...config,
|
|
240
|
-
challenge,
|
|
241
|
-
isData: typeof message !== "string",
|
|
242
|
-
address,
|
|
243
|
-
}, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
|
|
244
|
-
return JSON.stringify({
|
|
245
|
-
signature: res.signature,
|
|
246
|
-
alg: res.alg,
|
|
247
|
-
message: res.message,
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Saves the current connection.
|
|
252
|
-
* @returns
|
|
253
|
-
*/
|
|
254
|
-
async saveConnection() {
|
|
255
|
-
return this.connectionsRepo.set({
|
|
256
|
-
uri: this.getConfig().joyidAppURL,
|
|
257
|
-
addressType: "ckb",
|
|
258
|
-
}, this.connection);
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Restores the previous connection.
|
|
262
|
-
* @returns
|
|
263
|
-
*/
|
|
264
|
-
async restoreConnection() {
|
|
265
|
-
this.connection = await this.connectionsRepo.get({
|
|
266
|
-
uri: this.getConfig().joyidAppURL,
|
|
267
|
-
addressType: "ckb",
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
exports.CkbSigner = CkbSigner;
|