@ckb-ccc/joy-id 0.0.5-alpha.10 → 0.0.5-alpha.11
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/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +11 -1
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +19 -40
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +14 -30
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +14 -30
- package/dist.commonjs/btc/index.d.ts +15 -22
- package/dist.commonjs/btc/index.js +73 -99
- package/dist.commonjs/ckb/index.d.ts +26 -33
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +171 -204
- package/dist.commonjs/common/index.d.ts +21 -34
- package/dist.commonjs/common/index.js +45 -50
- package/dist.commonjs/connectionsStorage/index.d.ts +14 -23
- package/dist.commonjs/connectionsStorage/index.js +25 -28
- package/dist.commonjs/evm/index.d.ts +15 -21
- package/dist.commonjs/evm/index.js +67 -89
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +19 -40
- package/dist.commonjs/signerFactory/index.d.ts +2 -6
- package/dist.commonjs/signerFactory/index.js +27 -38
- package/package.json +3 -3
- package/src/ckb/index.ts +16 -1
|
@@ -7,209 +7,176 @@ const common_1 = require("@joyid/common");
|
|
|
7
7
|
const common_2 = require("../common");
|
|
8
8
|
const connectionsStorage_1 = require("../connectionsStorage");
|
|
9
9
|
class CkbSigner extends core_1.ccc.Signer {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
(0, common_1.buildJoyIDURL)(
|
|
182
|
-
{
|
|
183
|
-
...config,
|
|
184
|
-
challenge,
|
|
185
|
-
isData: typeof message !== "string",
|
|
186
|
-
address,
|
|
187
|
-
},
|
|
188
|
-
"popup",
|
|
189
|
-
"/sign-message",
|
|
190
|
-
),
|
|
191
|
-
{ ...config, type: common_1.DappRequestType.SignMessage },
|
|
192
|
-
);
|
|
193
|
-
return JSON.stringify({
|
|
194
|
-
signature: res.signature,
|
|
195
|
-
alg: res.alg,
|
|
196
|
-
message: res.message,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
async saveConnection() {
|
|
200
|
-
return this.connectionsRepo.set(
|
|
201
|
-
{
|
|
202
|
-
uri: this.getConfig().joyidAppURL,
|
|
203
|
-
addressType: "ckb",
|
|
204
|
-
},
|
|
205
|
-
this.connection,
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
async restoreConnection() {
|
|
209
|
-
this.connection = await this.connectionsRepo.get({
|
|
210
|
-
uri: this.getConfig().joyidAppURL,
|
|
211
|
-
addressType: "ckb",
|
|
212
|
-
});
|
|
213
|
-
}
|
|
10
|
+
get type() {
|
|
11
|
+
return core_1.ccc.SignerType.CKB;
|
|
12
|
+
}
|
|
13
|
+
get signType() {
|
|
14
|
+
return core_1.ccc.SignerSignType.JoyId;
|
|
15
|
+
}
|
|
16
|
+
async assertConnection() {
|
|
17
|
+
if (!(await this.isConnected()) || !this.connection) {
|
|
18
|
+
throw new Error("Not connected");
|
|
19
|
+
}
|
|
20
|
+
return this.connection;
|
|
21
|
+
}
|
|
22
|
+
constructor(client, name, icon, _appUri, _aggregatorUri, connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage()) {
|
|
23
|
+
super(client);
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.icon = icon;
|
|
26
|
+
this._appUri = _appUri;
|
|
27
|
+
this._aggregatorUri = _aggregatorUri;
|
|
28
|
+
this.connectionsRepo = connectionsRepo;
|
|
29
|
+
}
|
|
30
|
+
getConfig() {
|
|
31
|
+
return {
|
|
32
|
+
redirectURL: location.href,
|
|
33
|
+
joyidAppURL: this._appUri ?? this.client.addressPrefix === "ckb"
|
|
34
|
+
? "https://app.joy.id"
|
|
35
|
+
: "https://testnet.joyid.dev",
|
|
36
|
+
name: this.name,
|
|
37
|
+
logo: this.icon,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
getAggregatorUri() {
|
|
41
|
+
if (this._aggregatorUri) {
|
|
42
|
+
return this._aggregatorUri;
|
|
43
|
+
}
|
|
44
|
+
return this.client.addressPrefix === "ckb"
|
|
45
|
+
? "https://cota.nervina.dev/mainnet-aggregator"
|
|
46
|
+
: "https://cota.nervina.dev/aggregator";
|
|
47
|
+
}
|
|
48
|
+
async connect() {
|
|
49
|
+
const config = this.getConfig();
|
|
50
|
+
const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
|
|
51
|
+
...config,
|
|
52
|
+
type: common_1.DappRequestType.Auth,
|
|
53
|
+
});
|
|
54
|
+
this.connection = {
|
|
55
|
+
address: res.address,
|
|
56
|
+
publicKey: core_1.ccc.hexFrom(res.pubkey),
|
|
57
|
+
keyType: res.keyType,
|
|
58
|
+
};
|
|
59
|
+
await this.saveConnection();
|
|
60
|
+
}
|
|
61
|
+
async disconnect() {
|
|
62
|
+
this.connection = undefined;
|
|
63
|
+
await this.saveConnection();
|
|
64
|
+
}
|
|
65
|
+
async isConnected() {
|
|
66
|
+
if (this.connection) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
await this.restoreConnection();
|
|
70
|
+
return this.connection !== undefined;
|
|
71
|
+
}
|
|
72
|
+
async getInternalAddress() {
|
|
73
|
+
return (await this.assertConnection()).address;
|
|
74
|
+
}
|
|
75
|
+
async getIdentity() {
|
|
76
|
+
const connection = await this.assertConnection();
|
|
77
|
+
return JSON.stringify({
|
|
78
|
+
keyType: connection.keyType,
|
|
79
|
+
publicKey: connection.publicKey.slice(2),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async getAddressObj() {
|
|
83
|
+
return await core_1.ccc.Address.fromString(await this.getInternalAddress(), this.client);
|
|
84
|
+
}
|
|
85
|
+
async getAddressObjs() {
|
|
86
|
+
return [await this.getAddressObj()];
|
|
87
|
+
}
|
|
88
|
+
async prepareTransaction(txLike) {
|
|
89
|
+
const tx = core_1.ccc.Transaction.from(txLike);
|
|
90
|
+
const position = await tx.findInputIndexByLock((await this.getAddressObj()).script, this.client);
|
|
91
|
+
if (position === undefined) {
|
|
92
|
+
return tx;
|
|
93
|
+
}
|
|
94
|
+
const witness = tx.getWitnessArgsAt(position) ?? core_1.ccc.WitnessArgs.from({});
|
|
95
|
+
witness.lock = "0x";
|
|
96
|
+
await this.prepareTransactionForSubKey(tx, witness);
|
|
97
|
+
tx.setWitnessArgsAt(position, witness);
|
|
98
|
+
return tx;
|
|
99
|
+
}
|
|
100
|
+
async prepareTransactionForSubKey(tx, witness) {
|
|
101
|
+
if (this.connection?.keyType !== "sub_key") {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const pubkeyHash = core_1.ccc.ckbHash(this.connection.publicKey).substring(0, 42);
|
|
105
|
+
const lock = (await this.getAddressObj()).script;
|
|
106
|
+
const aggregator = new ckb_1.Aggregator(await this.getAggregatorUri());
|
|
107
|
+
const { unlock_entry: unlockEntry } = await aggregator.generateSubkeyUnlockSmt({
|
|
108
|
+
alg_index: 1,
|
|
109
|
+
pubkey_hash: pubkeyHash,
|
|
110
|
+
lock_script: core_1.ccc.hexFrom(lock.toBytes()),
|
|
111
|
+
});
|
|
112
|
+
witness.outputType = core_1.ccc.hexFrom(unlockEntry);
|
|
113
|
+
const cotaDeps = [];
|
|
114
|
+
for await (const cell of this.client.findCellsByLockAndType(lock, {
|
|
115
|
+
...(await this.client.getKnownScript(core_1.ccc.KnownScript.COTA)),
|
|
116
|
+
args: "0x",
|
|
117
|
+
})) {
|
|
118
|
+
cotaDeps.push(core_1.ccc.CellDep.from({
|
|
119
|
+
depType: "code",
|
|
120
|
+
outPoint: cell.outPoint,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
if (cotaDeps.length === 0) {
|
|
124
|
+
throw new Error("No COTA cells for sub key wallet");
|
|
125
|
+
}
|
|
126
|
+
tx.cellDeps.unshift(...cotaDeps);
|
|
127
|
+
}
|
|
128
|
+
async signOnlyTransaction(txLike) {
|
|
129
|
+
const tx = core_1.ccc.Transaction.from(txLike);
|
|
130
|
+
const { script } = await this.getAddressObj();
|
|
131
|
+
const config = this.getConfig();
|
|
132
|
+
const witnessIndexes = await tx.inputs.map(async (input, i) => {
|
|
133
|
+
await input.completeExtraInfos(this.client);
|
|
134
|
+
if (!input.cellOutput) {
|
|
135
|
+
throw Error("Unable to resolve inputs info");
|
|
136
|
+
}
|
|
137
|
+
if (!script.eq(input.cellOutput.lock)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
return i;
|
|
141
|
+
});
|
|
142
|
+
const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({
|
|
143
|
+
...config,
|
|
144
|
+
tx: JSON.parse(tx.stringify()),
|
|
145
|
+
signerAddress: (await this.assertConnection()).address,
|
|
146
|
+
witnessIndexes: witnessIndexes.filter((i) => i !== undefined),
|
|
147
|
+
}, "popup", "/sign-ckb-raw-tx"), {
|
|
148
|
+
...config,
|
|
149
|
+
type: common_1.DappRequestType.SignCkbRawTx,
|
|
150
|
+
});
|
|
151
|
+
return core_1.ccc.Transaction.from(res.tx);
|
|
152
|
+
}
|
|
153
|
+
async signMessageRaw(message) {
|
|
154
|
+
const { address } = await this.assertConnection();
|
|
155
|
+
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
156
|
+
const config = this.getConfig();
|
|
157
|
+
const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({
|
|
158
|
+
...config,
|
|
159
|
+
challenge,
|
|
160
|
+
isData: typeof message !== "string",
|
|
161
|
+
address,
|
|
162
|
+
}, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
|
|
163
|
+
return JSON.stringify({
|
|
164
|
+
signature: res.signature,
|
|
165
|
+
alg: res.alg,
|
|
166
|
+
message: res.message,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
async saveConnection() {
|
|
170
|
+
return this.connectionsRepo.set({
|
|
171
|
+
uri: this.getConfig().joyidAppURL,
|
|
172
|
+
addressType: "ckb",
|
|
173
|
+
}, this.connection);
|
|
174
|
+
}
|
|
175
|
+
async restoreConnection() {
|
|
176
|
+
this.connection = await this.connectionsRepo.get({
|
|
177
|
+
uri: this.getConfig().joyidAppURL,
|
|
178
|
+
addressType: "ckb",
|
|
179
|
+
});
|
|
180
|
+
}
|
|
214
181
|
}
|
|
215
182
|
exports.CkbSigner = CkbSigner;
|
|
@@ -1,37 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthResponseData,
|
|
3
|
-
DappRequestType,
|
|
4
|
-
EvmWeb2LoginResponse,
|
|
5
|
-
PopupConfigOptions,
|
|
6
|
-
SignCkbTxResponseData,
|
|
7
|
-
SignCotaNFTResponseData,
|
|
8
|
-
SignEvmTxResponseData,
|
|
9
|
-
SignMessageResponseData,
|
|
10
|
-
SignNostrEventData,
|
|
11
|
-
} from "@joyid/common";
|
|
1
|
+
import { AuthResponseData, DappRequestType, EvmWeb2LoginResponse, PopupConfigOptions, SignCkbTxResponseData, SignCotaNFTResponseData, SignEvmTxResponseData, SignMessageResponseData, SignNostrEventData } from "@joyid/common";
|
|
12
2
|
export interface PopupReturnType {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
[DappRequestType.Auth]: AuthResponseData;
|
|
4
|
+
[DappRequestType.SignMessage]: SignMessageResponseData;
|
|
5
|
+
[DappRequestType.SignEvm]: SignEvmTxResponseData;
|
|
6
|
+
[DappRequestType.SignPsbt]: SignEvmTxResponseData;
|
|
7
|
+
[DappRequestType.BatchSignPsbt]: {
|
|
8
|
+
psbts: string[];
|
|
9
|
+
};
|
|
10
|
+
[DappRequestType.SignCkbTx]: SignCkbTxResponseData;
|
|
11
|
+
[DappRequestType.SignCotaNFT]: SignCotaNFTResponseData;
|
|
12
|
+
[DappRequestType.SignCkbRawTx]: SignCkbTxResponseData;
|
|
13
|
+
[DappRequestType.SignNostrEvent]: SignNostrEventData;
|
|
14
|
+
[DappRequestType.EncryptNostrMessage]: any;
|
|
15
|
+
[DappRequestType.DecryptNostrMessage]: any;
|
|
16
|
+
[DappRequestType.AuthMiniApp]: any;
|
|
17
|
+
[DappRequestType.SignMiniAppEvm]: any;
|
|
18
|
+
[DappRequestType.SignMiniAppMessage]: any;
|
|
19
|
+
[DappRequestType.EvmWeb2Login]: EvmWeb2LoginResponse;
|
|
30
20
|
}
|
|
31
|
-
export declare function createPopup<T extends DappRequestType>(
|
|
32
|
-
url: string,
|
|
33
|
-
config: PopupConfigOptions<T> & {
|
|
21
|
+
export declare function createPopup<T extends DappRequestType>(url: string, config: PopupConfigOptions<T> & {
|
|
34
22
|
joyidAppURL: string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
|
23
|
+
}): Promise<PopupReturnType[T]>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,57 +3,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPopup = void 0;
|
|
4
4
|
const common_1 = require("@joyid/common");
|
|
5
5
|
async function createPopup(url, config) {
|
|
6
|
-
if (config.popup == null) {
|
|
7
|
-
config.popup = (0, common_1.openPopup)("");
|
|
8
6
|
if (config.popup == null) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
config.popup = (0, common_1.openPopup)("");
|
|
8
|
+
if (config.popup == null) {
|
|
9
|
+
return (0, common_1.createBlockDialog)(async () => createPopup(url, config));
|
|
10
|
+
}
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
resolve(e.data.data);
|
|
55
|
-
};
|
|
56
|
-
window.addEventListener("message", popupEventListener);
|
|
57
|
-
});
|
|
12
|
+
config.popup.location.href = url;
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
if ((0, common_1.isStandaloneBrowser)()) {
|
|
15
|
+
reject(new common_1.PopupNotSupportedError(config.popup));
|
|
16
|
+
}
|
|
17
|
+
let popupEventListener;
|
|
18
|
+
let timeoutId;
|
|
19
|
+
// Check each second if the popup is closed triggering a PopupCancelledError
|
|
20
|
+
const popupTimer = setInterval(() => {
|
|
21
|
+
if (config.popup?.closed) {
|
|
22
|
+
clearInterval(popupTimer);
|
|
23
|
+
clearTimeout(timeoutId);
|
|
24
|
+
window.removeEventListener("message", popupEventListener, false);
|
|
25
|
+
reject(new common_1.PopupCancelledError(config.popup));
|
|
26
|
+
}
|
|
27
|
+
}, 1000);
|
|
28
|
+
timeoutId = setTimeout(() => {
|
|
29
|
+
clearInterval(popupTimer);
|
|
30
|
+
reject(new common_1.PopupTimeoutError(config.popup));
|
|
31
|
+
window.removeEventListener("message", popupEventListener, false);
|
|
32
|
+
}, (config.timeoutInSeconds ?? 3000) * 1000);
|
|
33
|
+
popupEventListener = (e) => {
|
|
34
|
+
const { joyidAppURL } = config;
|
|
35
|
+
const appURL = new URL(joyidAppURL);
|
|
36
|
+
if (e.origin !== appURL.origin) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!e.data || e.data?.type !== config.type) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
clearTimeout(timeoutId);
|
|
43
|
+
clearInterval(popupTimer);
|
|
44
|
+
window.removeEventListener("message", popupEventListener, false);
|
|
45
|
+
config.popup.close();
|
|
46
|
+
if (e.data.error) {
|
|
47
|
+
reject(new Error(e.data.error));
|
|
48
|
+
}
|
|
49
|
+
resolve(e.data.data);
|
|
50
|
+
};
|
|
51
|
+
window.addEventListener("message", popupEventListener);
|
|
52
|
+
});
|
|
58
53
|
}
|
|
59
54
|
exports.createPopup = createPopup;
|
|
@@ -1,32 +1,23 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
export type AccountSelector = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
uri: string;
|
|
4
|
+
addressType: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function isSelectorEq(
|
|
7
|
-
a: AccountSelector,
|
|
8
|
-
b: AccountSelector,
|
|
9
|
-
): boolean;
|
|
6
|
+
export declare function isSelectorEq(a: AccountSelector, b: AccountSelector): boolean;
|
|
10
7
|
export type Connection = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
readonly address: string;
|
|
9
|
+
readonly publicKey: ccc.Hex;
|
|
10
|
+
readonly keyType: string;
|
|
14
11
|
};
|
|
15
12
|
export interface ConnectionsRepo {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
selector: AccountSelector,
|
|
19
|
-
connection: Connection | undefined,
|
|
20
|
-
): Promise<void>;
|
|
13
|
+
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
14
|
+
set(selector: AccountSelector, connection: Connection | undefined): Promise<void>;
|
|
21
15
|
}
|
|
22
16
|
export declare class ConnectionsRepoLocalStorage implements ConnectionsRepo {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
selector: AccountSelector,
|
|
29
|
-
connection: Connection | undefined,
|
|
30
|
-
): Promise<void>;
|
|
17
|
+
private readonly storageKey;
|
|
18
|
+
constructor(storageKey?: string);
|
|
19
|
+
readConnections(): Promise<[AccountSelector, Connection][]>;
|
|
20
|
+
get(selector: AccountSelector): Promise<Connection | undefined>;
|
|
21
|
+
set(selector: AccountSelector, connection: Connection | undefined): Promise<void>;
|
|
31
22
|
}
|
|
32
|
-
//# sourceMappingURL=index.d.ts.map
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|