@ckb-ccc/joy-id 0.0.6-alpha.0 → 0.0.7-alpha.1
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 +2 -3
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +21 -10
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +40 -19
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +30 -14
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/btc/index.d.ts +63 -56
- package/dist.commonjs/btc/index.js +140 -114
- package/dist.commonjs/ckb/index.d.ts +121 -115
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +307 -239
- package/dist.commonjs/common/index.d.ts +34 -21
- package/dist.commonjs/common/index.js +50 -45
- package/dist.commonjs/connectionsStorage/index.d.ts +53 -44
- package/dist.commonjs/connectionsStorage/index.js +47 -44
- package/dist.commonjs/evm/index.d.ts +67 -61
- package/dist.commonjs/evm/index.js +135 -113
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +40 -19
- package/dist.commonjs/nostr/index.d.ts +48 -42
- package/dist.commonjs/nostr/index.js +110 -91
- package/dist.commonjs/signerFactory/index.d.ts +6 -2
- package/dist.commonjs/signerFactory/index.js +42 -31
- package/package.json +5 -5
- package/src/ckb/index.ts +30 -13
|
@@ -17,37 +17,48 @@ const nostr_1 = require("../nostr");
|
|
|
17
17
|
* @returns {ccc.SignerInfo[]} An array of signer information objects.
|
|
18
18
|
*/
|
|
19
19
|
function getJoyIdSigners(client, name, icon) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
20
|
+
if (
|
|
21
|
+
(0, common_1.isStandaloneBrowser)() ||
|
|
22
|
+
core_1.ccc.isWebview(window.navigator.userAgent)
|
|
23
|
+
) {
|
|
26
24
|
return [
|
|
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
|
-
|
|
25
|
+
core_1.ccc.SignerType.CKB,
|
|
26
|
+
core_1.ccc.SignerType.EVM,
|
|
27
|
+
core_1.ccc.SignerType.BTC,
|
|
28
|
+
].map((type) => ({
|
|
29
|
+
name: type,
|
|
30
|
+
signer: new core_1.ccc.SignerAlwaysError(
|
|
31
|
+
client,
|
|
32
|
+
type,
|
|
33
|
+
"JoyID can only be used with standard browsers",
|
|
34
|
+
),
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
name: "CKB",
|
|
40
|
+
signer: new ckb_1.CkbSigner(client, name, icon),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "BTC",
|
|
44
|
+
signer: new btc_1.BitcoinSigner(client, name, icon),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "Nostr",
|
|
48
|
+
signer: new nostr_1.NostrSigner(client, name, icon),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "EVM",
|
|
52
|
+
signer: new evm_1.EvmSigner(client, name, icon),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "BTC (P2WPKH)",
|
|
56
|
+
signer: new btc_1.BitcoinSigner(client, name, icon, "p2wpkh"),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "BTC (P2TR)",
|
|
60
|
+
signer: new btc_1.BitcoinSigner(client, name, icon, "p2tr"),
|
|
61
|
+
},
|
|
62
|
+
];
|
|
52
63
|
}
|
|
53
64
|
exports.getJoyIdSigners = getJoyIdSigners;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/joy-id",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-alpha.1",
|
|
4
4
|
"description": "Connector's support for JoyID",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@ckb-ccc/core": "0.0.
|
|
42
|
-
"@joyid/ckb": "^0.0
|
|
43
|
-
"@joyid/common": "^0.0
|
|
41
|
+
"@ckb-ccc/core": "0.0.7-alpha.1",
|
|
42
|
+
"@joyid/ckb": "^1.0.0",
|
|
43
|
+
"@joyid/common": "^0.2.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "08978b86747dd8ad7f4abb833c8eb00b98fd0496"
|
|
46
46
|
}
|
package/src/ckb/index.ts
CHANGED
|
@@ -178,6 +178,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
178
178
|
txLike: ccc.TransactionLike,
|
|
179
179
|
): Promise<ccc.Transaction> {
|
|
180
180
|
const tx = ccc.Transaction.from(txLike);
|
|
181
|
+
await tx.addCellDepsOfKnownScripts(this.client, ccc.KnownScript.JoyId);
|
|
181
182
|
const position = await tx.findInputIndexByLock(
|
|
182
183
|
(await this.getAddressObj()).script,
|
|
183
184
|
this.client,
|
|
@@ -187,7 +188,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
const witness = tx.getWitnessArgsAt(position) ?? ccc.WitnessArgs.from({});
|
|
190
|
-
witness.lock = "
|
|
191
|
+
witness.lock = ccc.hexFrom("00".repeat(1000));
|
|
191
192
|
await this.prepareTransactionForSubKey(tx, witness);
|
|
192
193
|
tx.setWitnessArgsAt(position, witness);
|
|
193
194
|
|
|
@@ -197,9 +198,8 @@ export class CkbSigner extends ccc.Signer {
|
|
|
197
198
|
/**
|
|
198
199
|
* Prepares a transaction for a sub key.
|
|
199
200
|
* @private
|
|
200
|
-
* @param
|
|
201
|
-
* @param
|
|
202
|
-
* @returns {Promise<void>}
|
|
201
|
+
* @param tx - The transaction object.
|
|
202
|
+
* @param witness - The witness arguments.
|
|
203
203
|
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
204
204
|
*/
|
|
205
205
|
private async prepareTransactionForSubKey(
|
|
@@ -222,10 +222,10 @@ export class CkbSigner extends ccc.Signer {
|
|
|
222
222
|
witness.outputType = ccc.hexFrom(unlockEntry);
|
|
223
223
|
|
|
224
224
|
const cotaDeps: ccc.CellDep[] = [];
|
|
225
|
-
for await (const cell of this.client.findCellsByLockAndType(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
for await (const cell of this.client.findCellsByLockAndType(
|
|
226
|
+
lock,
|
|
227
|
+
await ccc.Script.fromKnownScript(this.client, ccc.KnownScript.COTA, "0x"),
|
|
228
|
+
)) {
|
|
229
229
|
cotaDeps.push(
|
|
230
230
|
ccc.CellDep.from({
|
|
231
231
|
depType: "code",
|
|
@@ -251,6 +251,27 @@ export class CkbSigner extends ccc.Signer {
|
|
|
251
251
|
): Promise<ccc.Transaction> {
|
|
252
252
|
const tx = ccc.Transaction.from(txLike);
|
|
253
253
|
const { script } = await this.getAddressObj();
|
|
254
|
+
const witnessIndexes = await ccc.reduceAsync(
|
|
255
|
+
tx.inputs,
|
|
256
|
+
async (acc, input, i) => {
|
|
257
|
+
await input.completeExtraInfos(this.client);
|
|
258
|
+
if (!input.cellOutput) {
|
|
259
|
+
throw new Error("Unable to complete input");
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (input.cellOutput.lock.eq(script)) {
|
|
263
|
+
acc.push(i);
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
[] as number[],
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
// Trim unnecessary fields to reduce tx size
|
|
270
|
+
await tx.prepareSighashAllWitness(script, 0, this.client);
|
|
271
|
+
tx.inputs.forEach((i) => {
|
|
272
|
+
i.cellOutput = undefined;
|
|
273
|
+
i.outputData = undefined;
|
|
274
|
+
});
|
|
254
275
|
|
|
255
276
|
const config = this.getConfig();
|
|
256
277
|
const res = await createPopup(
|
|
@@ -259,11 +280,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
259
280
|
...config,
|
|
260
281
|
tx: JSON.parse(tx.stringify()),
|
|
261
282
|
signerAddress: (await this.assertConnection()).address,
|
|
262
|
-
|
|
263
|
-
witnessLastIndex: await tx.findLastInputIndexByLock(
|
|
264
|
-
script,
|
|
265
|
-
this.client,
|
|
266
|
-
),
|
|
283
|
+
witnessIndexes,
|
|
267
284
|
},
|
|
268
285
|
"popup",
|
|
269
286
|
"/sign-ckb-raw-tx",
|