@ckb-ccc/core 0.0.5-alpha.1 → 0.0.5-alpha.10
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/address/index.d.ts +1 -1
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +4 -4
- package/dist/ckb/transaction.d.ts +2 -2
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +2 -3
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +2 -1
- package/dist/client/clientPublicMainnet.d.ts +1 -1
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +1 -1
- package/dist/client/clientPublicTestnet.d.ts +1 -1
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +1 -1
- package/dist/client/jsonRpc/index.d.ts +3 -3
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +4 -4
- package/dist/signer/btc/index.d.ts +1 -0
- package/dist/signer/btc/index.d.ts.map +1 -1
- package/dist/signer/btc/index.js +1 -0
- package/dist/signer/btc/signerBtc.d.ts +9 -1
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +19 -3
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
- package/dist/signer/btc/verify.d.ts +3 -0
- package/dist/signer/btc/verify.d.ts.map +1 -0
- package/dist/signer/btc/verify.js +6 -0
- package/dist/signer/ckb/index.d.ts +1 -0
- package/dist/signer/ckb/index.d.ts.map +1 -1
- package/dist/signer/ckb/index.js +1 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -7
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -10
- package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist/signer/ckb/verifyJoyId.js +12 -0
- package/dist/signer/dummy/alwaysError.d.ts +9 -0
- package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist/signer/dummy/alwaysError.js +10 -0
- package/dist/signer/dummy/dummy.d.ts +12 -0
- package/dist/signer/dummy/dummy.d.ts.map +1 -0
- package/dist/signer/dummy/dummy.js +19 -0
- package/dist/signer/dummy/index.d.ts +4 -0
- package/dist/signer/dummy/index.d.ts.map +1 -0
- package/dist/signer/dummy/index.js +3 -0
- package/dist/signer/dummy/openLink.d.ts +9 -0
- package/dist/signer/dummy/openLink.d.ts.map +1 -0
- package/dist/signer/dummy/openLink.js +10 -0
- package/dist/signer/evm/index.d.ts +1 -0
- package/dist/signer/evm/index.d.ts.map +1 -1
- package/dist/signer/evm/index.js +1 -0
- package/dist/signer/evm/signerEvm.d.ts +3 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +10 -4
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.js +0 -8
- package/dist/signer/evm/verify.d.ts +3 -0
- package/dist/signer/evm/verify.d.ts.map +1 -0
- package/dist/signer/evm/verify.js +6 -0
- package/dist/signer/index.d.ts +1 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +1 -0
- package/{dist.commonjs/signer/signer.d.ts → dist/signer/signer/index.d.ts} +69 -25
- package/dist/signer/signer/index.d.ts.map +1 -0
- package/dist/signer/{signer.js → signer/index.js} +101 -16
- package/dist/utils/index.d.ts +60 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +20 -0
- package/dist.commonjs/address/address.advanced.d.ts +29 -24
- package/dist.commonjs/address/address.advanced.js +114 -92
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +30 -14
- package/dist.commonjs/address/index.d.ts +51 -44
- package/dist.commonjs/address/index.d.ts.map +1 -1
- package/dist.commonjs/address/index.js +87 -68
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +47 -22
- 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/bytes/advanced.d.ts +11 -2
- package/dist.commonjs/bytes/index.d.ts +9 -3
- package/dist.commonjs/bytes/index.js +28 -26
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +47 -22
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +30 -14
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +12 -9
- package/dist.commonjs/ckb/script.d.ts +76 -76
- package/dist.commonjs/ckb/script.js +166 -126
- package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/transaction.advanced.js +4 -4
- package/dist.commonjs/ckb/transaction.d.ts +570 -532
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +839 -723
- package/dist.commonjs/client/advanced.d.ts +1 -1
- package/dist.commonjs/client/advanced.js +30 -14
- package/dist.commonjs/client/client.d.ts +52 -21
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +67 -57
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +5 -2
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +30 -24
- package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -4
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +9 -9
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +5 -2
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +30 -24
- package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -4
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +9 -9
- package/dist.commonjs/client/clientTypes.d.ts +51 -36
- package/dist.commonjs/client/clientTypes.js +34 -19
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +30 -14
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
- package/dist.commonjs/client/jsonRpc/index.d.ts +92 -75
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +135 -108
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +78 -38
- package/dist.commonjs/client/jsonRpc/transformers.js +175 -150
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +9 -3
- package/dist.commonjs/fixedPoint/index.js +26 -20
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +42 -36
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +36 -36
- package/dist.commonjs/hasher/index.js +52 -45
- package/dist.commonjs/hex/index.d.ts +1 -1
- package/dist.commonjs/hex/index.js +1 -1
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +47 -22
- package/dist.commonjs/num/index.d.ts +1 -1
- package/dist.commonjs/num/index.js +30 -19
- package/dist.commonjs/signer/btc/index.d.ts +2 -1
- package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/index.js +31 -14
- package/dist.commonjs/signer/btc/signerBtc.d.ts +48 -40
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +85 -49
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -51
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -60
- package/dist.commonjs/signer/btc/verify.d.ts +7 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/verify.js +13 -0
- package/dist.commonjs/signer/ckb/index.d.ts +2 -1
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +31 -14
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +46 -50
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -58
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +7 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.js +19 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +9 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/alwaysError.js +14 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts +12 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/dummy.js +23 -0
- package/dist.commonjs/signer/dummy/index.d.ts +4 -0
- package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/index.js +35 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts +9 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/openLink.js +14 -0
- package/dist.commonjs/signer/evm/index.d.ts +2 -1
- package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/index.js +31 -14
- package/dist.commonjs/signer/evm/signerEvm.d.ts +43 -37
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +101 -63
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -43
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -50
- package/dist.commonjs/signer/evm/verify.d.ts +7 -0
- package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/verify.js +15 -0
- package/dist.commonjs/signer/index.d.ts +2 -1
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +31 -14
- package/dist.commonjs/signer/signer/index.d.ts +190 -0
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/signer/index.js +234 -0
- package/dist.commonjs/utils/index.d.ts +94 -6
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +33 -5
- package/package.json +6 -3
- package/src/address/index.ts +4 -7
- package/src/ckb/transaction.ts +4 -5
- package/src/client/client.ts +7 -6
- package/src/client/clientPublicMainnet.ts +1 -1
- package/src/client/clientPublicTestnet.ts +1 -1
- package/src/client/jsonRpc/index.ts +3 -3
- package/src/signer/btc/index.ts +1 -0
- package/src/signer/btc/signerBtc.ts +22 -7
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
- package/src/signer/btc/verify.ts +14 -0
- package/src/signer/ckb/index.ts +1 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -11
- package/src/signer/ckb/verifyJoyId.ts +20 -0
- package/src/signer/dummy/alwaysError.ts +17 -0
- package/src/signer/dummy/dummy.ts +28 -0
- package/src/signer/dummy/index.ts +3 -0
- package/src/signer/dummy/openLink.ts +17 -0
- package/src/signer/evm/index.ts +1 -0
- package/src/signer/evm/signerEvm.ts +16 -10
- package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
- package/src/signer/evm/verify.ts +16 -0
- package/src/signer/index.ts +1 -0
- package/src/signer/{signer.ts → signer/index.ts} +135 -25
- package/src/utils/index.ts +108 -0
- package/dist/signer/signer.d.ts +0 -140
- package/dist/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.js +0 -125
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "../../client";
|
|
2
|
+
import { SignerType } from "../signer";
|
|
3
|
+
import { SignerDummy } from "./dummy";
|
|
4
|
+
export declare class SignerOpenLink extends SignerDummy {
|
|
5
|
+
private readonly link;
|
|
6
|
+
constructor(client: Client, type: SignerType, link: string);
|
|
7
|
+
connect(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=openLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openLink.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/openLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,cAAe,SAAQ,WAAW;IAI3C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAFrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EACC,IAAI,EAAE,MAAM;IAKzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC"}
|
package/dist/signer/evm/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { BytesLike } from "../../bytes";
|
|
3
3
|
import { Script, Transaction, TransactionLike } from "../../ckb";
|
|
4
|
-
import { Signer } from "../signer";
|
|
4
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
5
5
|
/**
|
|
6
6
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
7
7
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class SignerEvm extends Signer {
|
|
10
|
+
get type(): SignerType;
|
|
11
|
+
get signType(): SignerSignType;
|
|
10
12
|
/**
|
|
11
13
|
* Gets the EVM account associated with the signer.
|
|
12
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAK9E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAQpC,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5D,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrE;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IASvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAsBlE,iCAAiC,CACrC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;CA6BxB"}
|
|
@@ -4,12 +4,19 @@ import { Transaction, WitnessArgs } from "../../ckb";
|
|
|
4
4
|
import { KnownScript } from "../../client";
|
|
5
5
|
import { hexFrom } from "../../hex";
|
|
6
6
|
import { numToBytes } from "../../num";
|
|
7
|
-
import {
|
|
7
|
+
import { reduceAsync } from "../../utils";
|
|
8
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
8
9
|
/**
|
|
9
10
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
10
11
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
11
12
|
*/
|
|
12
13
|
export class SignerEvm extends Signer {
|
|
14
|
+
get type() {
|
|
15
|
+
return SignerType.EVM;
|
|
16
|
+
}
|
|
17
|
+
get signType() {
|
|
18
|
+
return SignerSignType.EvmPersonal;
|
|
19
|
+
}
|
|
13
20
|
/**
|
|
14
21
|
* Gets the internal address, which is the EVM account in this case.
|
|
15
22
|
*
|
|
@@ -43,8 +50,7 @@ export class SignerEvm extends Signer {
|
|
|
43
50
|
* @returns A promise that resolves to the prepared Transaction object.
|
|
44
51
|
*/
|
|
45
52
|
async prepareTransaction(txLike) {
|
|
46
|
-
|
|
47
|
-
return addresses.reduce((txPromise, { script }) => txPromise.then((tx) => tx.prepareSighashAllWitness(script, 85, this.client)), Promise.resolve(Transaction.from(txLike)));
|
|
53
|
+
return reduceAsync(await this.getAddressObjs(), (tx, { script }) => tx.prepareSighashAllWitness(script, 85, this.client), Transaction.from(txLike));
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
50
56
|
* Signs a transaction without modifying it.
|
|
@@ -66,7 +72,7 @@ export class SignerEvm extends Signer {
|
|
|
66
72
|
if (!info) {
|
|
67
73
|
return tx;
|
|
68
74
|
}
|
|
69
|
-
const signature = bytesFrom(await this.
|
|
75
|
+
const signature = bytesFrom(await this.signMessageRaw(messageTransformer(info.message)));
|
|
70
76
|
if (signature[signature.length - 1] >= 27) {
|
|
71
77
|
signature[signature.length - 1] -= 27;
|
|
72
78
|
}
|
|
@@ -14,12 +14,6 @@ export declare class SignerEvmAddressReadonly extends SignerEvm {
|
|
|
14
14
|
* @param address - The EVM address associated with the signer.
|
|
15
15
|
*/
|
|
16
16
|
constructor(client: Client, address: HexLike);
|
|
17
|
-
/**
|
|
18
|
-
* Construct a new signer with the client replaced.
|
|
19
|
-
*
|
|
20
|
-
* @returns A promise that resolves the new Signer.
|
|
21
|
-
*/
|
|
22
|
-
replaceClient(client: Client): Promise<SignerEvmAddressReadonly>;
|
|
23
17
|
/**
|
|
24
18
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
25
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerEvmAddressReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvmAddressReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAO,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAM;IAE9B;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C
|
|
1
|
+
{"version":3,"file":"signerEvmAddressReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvmAddressReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAO,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAM;IAE9B;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C;;;;;;;;;OASG;IAEG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAGvC"}
|
|
@@ -15,14 +15,6 @@ export class SignerEvmAddressReadonly extends SignerEvm {
|
|
|
15
15
|
super(client);
|
|
16
16
|
this.address = hexFrom(address);
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Construct a new signer with the client replaced.
|
|
20
|
-
*
|
|
21
|
-
* @returns A promise that resolves the new Signer.
|
|
22
|
-
*/
|
|
23
|
-
async replaceClient(client) {
|
|
24
|
-
return new SignerEvmAddressReadonly(client, this.address);
|
|
25
|
-
}
|
|
26
18
|
/**
|
|
27
19
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
28
20
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AAEnD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAQT"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { verifyMessage } from "ethers";
|
|
2
|
+
import { bytesFrom } from "../../bytes";
|
|
3
|
+
export function verifyMessageEvmPersonal(message, signature, address) {
|
|
4
|
+
return (address.toLowerCase() ===
|
|
5
|
+
verifyMessage(typeof message === "string" ? message : bytesFrom(message), signature).toLowerCase());
|
|
6
|
+
}
|
package/dist/signer/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
package/dist/signer/index.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import { Address } from "
|
|
2
|
-
import { BytesLike } from "
|
|
3
|
-
import { Transaction, TransactionLike } from "
|
|
4
|
-
import { Client } from "
|
|
5
|
-
import { Hex } from "
|
|
6
|
-
import { Num } from "
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { BytesLike } from "../../bytes";
|
|
3
|
+
import { Transaction, TransactionLike } from "../../ckb";
|
|
4
|
+
import { Client } from "../../client";
|
|
5
|
+
import { Hex } from "../../hex";
|
|
6
|
+
import { Num } from "../../num";
|
|
7
|
+
export declare enum SignerSignType {
|
|
8
|
+
Unknown = "Unknown",
|
|
9
|
+
BtcEcdsa = "BtcEcdsa",
|
|
10
|
+
EvmPersonal = "EvmPersonal",
|
|
11
|
+
JoyId = "JoyId"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An enumeration of signer display types in wallet.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum SignerType {
|
|
17
|
+
EVM = "EVM",
|
|
18
|
+
BTC = "BTC",
|
|
19
|
+
CKB = "CKB"
|
|
20
|
+
}
|
|
21
|
+
export declare class Signature {
|
|
22
|
+
signature: string;
|
|
23
|
+
identity: string;
|
|
24
|
+
signType: SignerSignType;
|
|
25
|
+
constructor(signature: string, identity: string, signType: SignerSignType);
|
|
26
|
+
}
|
|
7
27
|
/**
|
|
8
28
|
* An abstract class representing a generic signer.
|
|
9
29
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
@@ -11,13 +31,14 @@ import { Num } from "../num";
|
|
|
11
31
|
export declare abstract class Signer {
|
|
12
32
|
protected client_: Client;
|
|
13
33
|
constructor(client_: Client);
|
|
34
|
+
abstract get type(): SignerType;
|
|
35
|
+
abstract get signType(): SignerSignType;
|
|
14
36
|
get client(): Client;
|
|
37
|
+
static verifyMessage(message: string | BytesLike, signature: Signature): Promise<boolean>;
|
|
15
38
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @returns A promise that resolves the new Signer.
|
|
39
|
+
* Replace the current client.
|
|
19
40
|
*/
|
|
20
|
-
|
|
41
|
+
replaceClient(client: Client): Promise<void>;
|
|
21
42
|
/**
|
|
22
43
|
* Connects to the signer.
|
|
23
44
|
*
|
|
@@ -42,6 +63,12 @@ export declare abstract class Signer {
|
|
|
42
63
|
* @returns A promise that resolves to a string representing the internal address.
|
|
43
64
|
*/
|
|
44
65
|
abstract getInternalAddress(): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the identity for verifying signature, usually it's address
|
|
68
|
+
*
|
|
69
|
+
* @returns A promise that resolves to a string representing the identity
|
|
70
|
+
*/
|
|
71
|
+
getIdentity(): Promise<string>;
|
|
45
72
|
/**
|
|
46
73
|
* Gets an array of Address objects associated with the signer.
|
|
47
74
|
*
|
|
@@ -75,13 +102,39 @@ export declare abstract class Signer {
|
|
|
75
102
|
*/
|
|
76
103
|
getBalance(): Promise<Num>;
|
|
77
104
|
/**
|
|
78
|
-
* Signs a message.
|
|
105
|
+
* Signs a message.
|
|
79
106
|
*
|
|
80
107
|
* @param _ - The message to sign, as a string or BytesLike object.
|
|
81
|
-
* @returns A promise that resolves to the
|
|
108
|
+
* @returns A promise that resolves to the signature info.
|
|
82
109
|
* @throws Will throw an error if not implemented.
|
|
83
110
|
*/
|
|
84
|
-
signMessage(
|
|
111
|
+
signMessage(message: string | BytesLike): Promise<Signature>;
|
|
112
|
+
/**
|
|
113
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
114
|
+
*
|
|
115
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
116
|
+
* @returns A promise that resolves to the signature as a string.
|
|
117
|
+
* @throws Will throw an error if not implemented.
|
|
118
|
+
*/
|
|
119
|
+
signMessageRaw(_: string | BytesLike): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Verify a signature.
|
|
122
|
+
*
|
|
123
|
+
* @param _ - The original message.
|
|
124
|
+
* @param _ - The signature to verify.
|
|
125
|
+
* @returns A promise that resolves to the verification result.
|
|
126
|
+
* @throws Will throw an error if not implemented.
|
|
127
|
+
*/
|
|
128
|
+
verifyMessage(message: string | BytesLike, signature: string | Signature): Promise<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
131
|
+
*
|
|
132
|
+
* @param _0 - The original message.
|
|
133
|
+
* @param _1 - The signature to verify.
|
|
134
|
+
* @returns A promise that resolves to the verification result.
|
|
135
|
+
* @throws Will throw an error if not implemented.
|
|
136
|
+
*/
|
|
137
|
+
verifyMessageRaw(_0: string | BytesLike, _1: string): Promise<boolean>;
|
|
85
138
|
/**
|
|
86
139
|
* Sends a transaction after signing it.
|
|
87
140
|
*
|
|
@@ -105,7 +158,7 @@ export declare abstract class Signer {
|
|
|
105
158
|
*/
|
|
106
159
|
prepareTransaction(_: TransactionLike): Promise<Transaction>;
|
|
107
160
|
/**
|
|
108
|
-
* Signs a transaction without
|
|
161
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
109
162
|
*
|
|
110
163
|
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
111
164
|
* @returns A promise that resolves to the signed Transaction object.
|
|
@@ -113,22 +166,13 @@ export declare abstract class Signer {
|
|
|
113
166
|
*/
|
|
114
167
|
signOnlyTransaction(_: TransactionLike): Promise<Transaction>;
|
|
115
168
|
}
|
|
116
|
-
/**
|
|
117
|
-
* An enumeration of signer types.
|
|
118
|
-
*/
|
|
119
|
-
export declare enum SignerType {
|
|
120
|
-
EVM = "EVM",
|
|
121
|
-
BTC = "BTC",
|
|
122
|
-
CKB = "CKB"
|
|
123
|
-
}
|
|
124
169
|
/**
|
|
125
170
|
* A class representing information about a signer, including its type and the signer instance.
|
|
126
171
|
*/
|
|
127
172
|
export declare class SignerInfo {
|
|
128
173
|
name: string;
|
|
129
|
-
type: SignerType;
|
|
130
174
|
signer: Signer;
|
|
131
|
-
constructor(name: string,
|
|
175
|
+
constructor(name: string, signer: Signer);
|
|
132
176
|
}
|
|
133
177
|
/**
|
|
134
178
|
* Represents a wallet with a name, icon, and an array of signer information.
|
|
@@ -137,4 +181,4 @@ export type Wallet = {
|
|
|
137
181
|
name: string;
|
|
138
182
|
icon: string;
|
|
139
183
|
};
|
|
140
|
-
//# sourceMappingURL=
|
|
184
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAKhC,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,qBAAa,SAAS;IAEX,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,cAAc;gBAFxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,cAAc;CAElC;AAED;;;GAGG;AACH,8BAAsB,MAAM;IACd,SAAS,CAAC,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAErC,QAAQ,KAAK,IAAI,IAAI,UAAU,CAAC;IAChC,QAAQ,KAAK,QAAQ,IAAI,cAAc,CAAC;IAExC,IAAI,MAAM,IAAI,MAAM,CAEnB;WAEY,aAAa,CACxB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC;IAyBnB;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAEjC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAEjC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAExC;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAE9C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAE7C;;;;;OAKG;IACG,wBAAwB,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvE;;;;;OAKG;IACG,qBAAqB,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlE;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAMvC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAMhC;;;;;;OAMG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAQlE;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAItD;;;;;;;OAOG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,OAAO,CAAC;IAenB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItE;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxD;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAKhE;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5D;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAG9D;AAED;;GAEG;AACH,qBAAa,UAAU;IAEZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAExB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import { verifyMessageBtcEcdsa } from "../btc";
|
|
2
|
+
import { verifyMessageJoyId } from "../ckb/verifyJoyId";
|
|
3
|
+
import { verifyMessageEvmPersonal } from "../evm/verify";
|
|
4
|
+
export var SignerSignType;
|
|
5
|
+
(function (SignerSignType) {
|
|
6
|
+
SignerSignType["Unknown"] = "Unknown";
|
|
7
|
+
SignerSignType["BtcEcdsa"] = "BtcEcdsa";
|
|
8
|
+
SignerSignType["EvmPersonal"] = "EvmPersonal";
|
|
9
|
+
SignerSignType["JoyId"] = "JoyId";
|
|
10
|
+
})(SignerSignType || (SignerSignType = {}));
|
|
11
|
+
/**
|
|
12
|
+
* An enumeration of signer display types in wallet.
|
|
13
|
+
*/
|
|
14
|
+
export var SignerType;
|
|
15
|
+
(function (SignerType) {
|
|
16
|
+
SignerType["EVM"] = "EVM";
|
|
17
|
+
SignerType["BTC"] = "BTC";
|
|
18
|
+
SignerType["CKB"] = "CKB";
|
|
19
|
+
})(SignerType || (SignerType = {}));
|
|
20
|
+
export class Signature {
|
|
21
|
+
constructor(signature, identity, signType) {
|
|
22
|
+
this.signature = signature;
|
|
23
|
+
this.identity = identity;
|
|
24
|
+
this.signType = signType;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
1
27
|
/**
|
|
2
28
|
* An abstract class representing a generic signer.
|
|
3
29
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
@@ -9,12 +35,38 @@ export class Signer {
|
|
|
9
35
|
get client() {
|
|
10
36
|
return this.client_;
|
|
11
37
|
}
|
|
38
|
+
static async verifyMessage(message, signature) {
|
|
39
|
+
switch (signature.signType) {
|
|
40
|
+
case SignerSignType.EvmPersonal:
|
|
41
|
+
return verifyMessageEvmPersonal(message, signature.signature, signature.identity);
|
|
42
|
+
case SignerSignType.BtcEcdsa:
|
|
43
|
+
return verifyMessageBtcEcdsa(message, signature.signature, signature.identity);
|
|
44
|
+
case SignerSignType.JoyId:
|
|
45
|
+
return verifyMessageJoyId(message, signature.signature, signature.identity);
|
|
46
|
+
case SignerSignType.Unknown:
|
|
47
|
+
throw new Error("Unknown signer sign type");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Replace the current client.
|
|
52
|
+
*/
|
|
53
|
+
async replaceClient(client) {
|
|
54
|
+
this.client_ = client;
|
|
55
|
+
}
|
|
12
56
|
/**
|
|
13
57
|
* Disconnects to the signer.
|
|
14
58
|
*
|
|
15
59
|
* @returns A promise that resolves when disconnected.
|
|
16
60
|
*/
|
|
17
61
|
async disconnect() { }
|
|
62
|
+
/**
|
|
63
|
+
* Gets the identity for verifying signature, usually it's address
|
|
64
|
+
*
|
|
65
|
+
* @returns A promise that resolves to a string representing the identity
|
|
66
|
+
*/
|
|
67
|
+
async getIdentity() {
|
|
68
|
+
return this.getInternalAddress();
|
|
69
|
+
}
|
|
18
70
|
/**
|
|
19
71
|
* Gets the recommended Address object for the signer.
|
|
20
72
|
*
|
|
@@ -50,14 +102,57 @@ export class Signer {
|
|
|
50
102
|
return this.client.getBalance((await this.getAddressObjs()).map(({ script }) => script));
|
|
51
103
|
}
|
|
52
104
|
/**
|
|
53
|
-
* Signs a message.
|
|
105
|
+
* Signs a message.
|
|
106
|
+
*
|
|
107
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
108
|
+
* @returns A promise that resolves to the signature info.
|
|
109
|
+
* @throws Will throw an error if not implemented.
|
|
110
|
+
*/
|
|
111
|
+
async signMessage(message) {
|
|
112
|
+
return {
|
|
113
|
+
signature: await this.signMessageRaw(message),
|
|
114
|
+
identity: await this.getIdentity(),
|
|
115
|
+
signType: this.signType,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
54
120
|
*
|
|
55
121
|
* @param _ - The message to sign, as a string or BytesLike object.
|
|
56
|
-
* @returns A promise that resolves to the
|
|
122
|
+
* @returns A promise that resolves to the signature as a string.
|
|
57
123
|
* @throws Will throw an error if not implemented.
|
|
58
124
|
*/
|
|
59
|
-
|
|
60
|
-
throw Error("Signer.
|
|
125
|
+
signMessageRaw(_) {
|
|
126
|
+
throw Error("Signer.signMessageRaw not implemented");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Verify a signature.
|
|
130
|
+
*
|
|
131
|
+
* @param _ - The original message.
|
|
132
|
+
* @param _ - The signature to verify.
|
|
133
|
+
* @returns A promise that resolves to the verification result.
|
|
134
|
+
* @throws Will throw an error if not implemented.
|
|
135
|
+
*/
|
|
136
|
+
async verifyMessage(message, signature) {
|
|
137
|
+
if (typeof signature === "string") {
|
|
138
|
+
return this.verifyMessageRaw(message, signature);
|
|
139
|
+
}
|
|
140
|
+
if (signature.identity !== (await this.getIdentity()) ||
|
|
141
|
+
![SignerSignType.Unknown, this.signType].includes(signature.signType)) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return this.verifyMessageRaw(message, signature.signature);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
148
|
+
*
|
|
149
|
+
* @param _0 - The original message.
|
|
150
|
+
* @param _1 - The signature to verify.
|
|
151
|
+
* @returns A promise that resolves to the verification result.
|
|
152
|
+
* @throws Will throw an error if not implemented.
|
|
153
|
+
*/
|
|
154
|
+
verifyMessageRaw(_0, _1) {
|
|
155
|
+
throw Error("Signer.verifyMessageRaw not implemented");
|
|
61
156
|
}
|
|
62
157
|
/**
|
|
63
158
|
* Sends a transaction after signing it.
|
|
@@ -89,7 +184,7 @@ export class Signer {
|
|
|
89
184
|
throw Error("Signer.prepareTransaction not implemented");
|
|
90
185
|
}
|
|
91
186
|
/**
|
|
92
|
-
* Signs a transaction without
|
|
187
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
93
188
|
*
|
|
94
189
|
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
95
190
|
* @returns A promise that resolves to the signed Transaction object.
|
|
@@ -99,22 +194,12 @@ export class Signer {
|
|
|
99
194
|
throw Error("Signer.signOnlyTransaction not implemented");
|
|
100
195
|
}
|
|
101
196
|
}
|
|
102
|
-
/**
|
|
103
|
-
* An enumeration of signer types.
|
|
104
|
-
*/
|
|
105
|
-
export var SignerType;
|
|
106
|
-
(function (SignerType) {
|
|
107
|
-
SignerType["EVM"] = "EVM";
|
|
108
|
-
SignerType["BTC"] = "BTC";
|
|
109
|
-
SignerType["CKB"] = "CKB";
|
|
110
|
-
})(SignerType || (SignerType = {}));
|
|
111
197
|
/**
|
|
112
198
|
* A class representing information about a signer, including its type and the signer instance.
|
|
113
199
|
*/
|
|
114
200
|
export class SignerInfo {
|
|
115
|
-
constructor(name,
|
|
201
|
+
constructor(name, signer) {
|
|
116
202
|
this.name = name;
|
|
117
|
-
this.type = type;
|
|
118
203
|
this.signer = signer;
|
|
119
204
|
}
|
|
120
205
|
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
3
|
+
*
|
|
4
|
+
* @param transformer - The transformer.
|
|
5
|
+
* @param value - The value to be transformed.
|
|
6
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
7
|
+
*/
|
|
1
8
|
export declare function apply<T, R>(transformer: (val: T) => R, value: undefined): undefined;
|
|
9
|
+
/**
|
|
10
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
11
|
+
*
|
|
12
|
+
* @param transformer - The transformer.
|
|
13
|
+
* @param value - The value to be transformed.
|
|
14
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
15
|
+
*/
|
|
2
16
|
export declare function apply<T, R>(transformer: (val: T) => R, value: null): null;
|
|
17
|
+
/**
|
|
18
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
19
|
+
*
|
|
20
|
+
* @param transformer - The transformer.
|
|
21
|
+
* @param value - The value to be transformed.
|
|
22
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
23
|
+
*/
|
|
3
24
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
25
|
+
/**
|
|
26
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
27
|
+
*
|
|
28
|
+
* @param transformer - The transformer.
|
|
29
|
+
* @param value - The value to be transformed.
|
|
30
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
31
|
+
*/
|
|
4
32
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | undefined): R | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
35
|
+
*
|
|
36
|
+
* @param transformer - The transformer.
|
|
37
|
+
* @param value - The value to be transformed.
|
|
38
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
39
|
+
*/
|
|
5
40
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | null): R | null;
|
|
41
|
+
/**
|
|
42
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
43
|
+
*
|
|
44
|
+
* @param transformer - The transformer.
|
|
45
|
+
* @param value - The value to be transformed.
|
|
46
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
47
|
+
*/
|
|
6
48
|
export declare function apply<T, R>(transformer: (val: T) => R, value: undefined | null): undefined | null;
|
|
49
|
+
/**
|
|
50
|
+
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
51
|
+
*
|
|
52
|
+
* @param values - The array to be reduced.
|
|
53
|
+
* @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
|
|
54
|
+
* @returns The accumulated result.
|
|
55
|
+
*/
|
|
56
|
+
export declare function reduceAsync<T, V>(values: T[], accumulator: (a: T, b: T) => Promise<T | undefined | null | void> | T | undefined | null | void): Promise<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Similar to Array.reduce, but the accumulator can returns Promise.
|
|
59
|
+
*
|
|
60
|
+
* @param values - The array to be reduced.
|
|
61
|
+
* @param accumulator - A callback to be called for each value. If it returns null, the previous result will be kept.
|
|
62
|
+
* @param init - The initial value.
|
|
63
|
+
* @returns The accumulated result.
|
|
64
|
+
*/
|
|
65
|
+
export declare function reduceAsync<T, V>(values: V[], accumulator: (a: T, b: V) => Promise<T | undefined | null | void> | T | undefined | null | void, init: T): Promise<T>;
|
|
66
|
+
export declare function isWebview(userAgent: string): boolean;
|
|
7
67
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;AAC3E,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,IAAI,CAAC;AACZ,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,GAAG,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;AAC3E;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,IAAI,CAAC;AACZ;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,GAAG,IAAI,CAAC;AAmBpB;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,CACX,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,KACD,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GACtE,OAAO,CAAC,CAAC,CAAC,CAAC;AACd;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,MAAM,EAAE,CAAC,EAAE,EACX,WAAW,EAAE,CACX,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,KACD,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,EACvE,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,CAAC,CAAC,CAAC;AA0Bd,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type safe way to apply a transformer on a value if it's not empty.
|
|
3
|
+
*
|
|
4
|
+
* @param transformer - The transformer.
|
|
5
|
+
* @param value - The value to be transformed.
|
|
6
|
+
* @returns If the value is empty, it remains its type. Otherwise it will be transformed.
|
|
7
|
+
*/
|
|
1
8
|
export function apply(transformer, value) {
|
|
2
9
|
if (value == null) {
|
|
3
10
|
return value;
|
|
4
11
|
}
|
|
5
12
|
return transformer(value);
|
|
6
13
|
}
|
|
14
|
+
export async function reduceAsync(values, accumulator, init) {
|
|
15
|
+
if (init === undefined) {
|
|
16
|
+
if (values.length === 0) {
|
|
17
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
|
18
|
+
}
|
|
19
|
+
init = values[0];
|
|
20
|
+
values = values.slice(1);
|
|
21
|
+
}
|
|
22
|
+
return values.reduce((current, b) => current.then((v) => Promise.resolve(accumulator(v, b)).then((r) => r ?? v)), Promise.resolve(init));
|
|
23
|
+
}
|
|
24
|
+
export function isWebview(userAgent) {
|
|
25
|
+
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(userAgent);
|
|
26
|
+
}
|