@ckb-ccc/core 0.0.5-alpha.2 → 0.0.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ckb/transaction.d.ts +17 -6
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +39 -15
- package/dist/client/client.d.ts +7 -6
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +9 -7
- package/dist/client/clientPublicMainnet.advanced.d.ts +1 -1
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +1 -0
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +5 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +4 -0
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +4 -2
- 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.map +1 -1
- package/dist/signer/btc/verify.js +5 -2
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +0 -6
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +0 -8
- 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/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +3 -3
- 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/index.d.ts +2 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +2 -0
- package/dist/signer/nostr/index.d.ts +2 -0
- package/dist/signer/nostr/index.d.ts.map +1 -0
- package/dist/signer/nostr/index.js +1 -0
- package/dist/signer/nostr/signerNostr.d.ts +66 -0
- package/dist/signer/nostr/signerNostr.d.ts.map +1 -0
- package/dist/signer/nostr/signerNostr.js +84 -0
- package/dist/signer/nostr/verify.d.ts +5 -0
- package/dist/signer/nostr/verify.d.ts.map +1 -0
- package/dist/signer/nostr/verify.js +48 -0
- package/dist/signer/{signer.d.ts → signer/index.d.ts} +14 -19
- package/dist/signer/signer/index.d.ts.map +1 -0
- package/dist/signer/{signer.js → signer/index.js} +14 -7
- 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/ckb/transaction.d.ts +17 -6
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +39 -15
- package/dist.commonjs/client/client.d.ts +7 -6
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +9 -7
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +1 -0
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +5 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +4 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +4 -2
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/verify.js +5 -2
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +0 -6
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +0 -8
- 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 +19 -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/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +3 -3
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +0 -8
- package/dist.commonjs/signer/index.d.ts +2 -0
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +2 -0
- package/dist.commonjs/signer/nostr/index.d.ts +2 -0
- package/dist.commonjs/signer/nostr/index.d.ts.map +1 -0
- package/dist.commonjs/signer/nostr/index.js +17 -0
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +66 -0
- package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -0
- package/dist.commonjs/signer/nostr/signerNostr.js +88 -0
- package/dist.commonjs/signer/nostr/verify.d.ts +5 -0
- package/dist.commonjs/signer/nostr/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/nostr/verify.js +53 -0
- package/dist.commonjs/signer/{signer.d.ts → signer/index.d.ts} +14 -19
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/{signer.js → signer/index.js} +14 -7
- package/dist.commonjs/utils/index.d.ts +60 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +23 -1
- package/package.json +4 -3
- package/src/ckb/transaction.ts +50 -18
- package/src/client/client.ts +12 -10
- package/src/client/clientPublicMainnet.advanced.ts +2 -1
- package/src/client/clientPublicMainnet.ts +7 -1
- package/src/client/clientPublicTestnet.advanced.ts +5 -0
- package/src/signer/btc/signerBtc.ts +4 -7
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
- package/src/signer/btc/verify.ts +6 -3
- package/src/signer/ckb/signerCkbScriptReadonly.ts +0 -9
- 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/signerEvm.ts +7 -9
- package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
- package/src/signer/index.ts +2 -0
- package/src/signer/nostr/index.ts +1 -0
- package/src/signer/nostr/signerNostr.ts +134 -0
- package/src/signer/nostr/verify.ts +63 -0
- package/src/signer/{signer.ts → signer/index.ts} +24 -20
- package/src/utils/index.ts +108 -0
- package/dist/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,EACV,eAAe,EAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,UAAU,EACV,eAAe,EAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,QAAQ,CAAC;AAE/C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,oBAAY,WAAW;IACrB,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;IAC7B,KAAK,UAAU;IACf,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED,8BAAsB,MAAM;IAC1B,QAAQ,KAAK,GAAG,IAAI,MAAM,CAAC;IAC3B,QAAQ,KAAK,aAAa,IAAI,MAAM,CAAC;IAErC,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;IAEjD,QAAQ,CAAC,eAAe,CACtB,WAAW,EAAE,eAAe,EAC5B,SAAS,CAAC,EAAE,gBAAgB,GAC3B,OAAO,CAAC,GAAG,CAAC;IACf,QAAQ,CAAC,cAAc,CACrB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAEtC,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB3D,QAAQ,CAAC,cAAc,CACrB,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,CAAC,EAAE,OAAO,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,uBAAuB,CAAC;IAE5B,SAAS,CACd,GAAG,EAAE,0BAA0B,EAC/B,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,EACtB,KAAK,SAAK,GACT,cAAc,CAAC,IAAI,CAAC;IAoBvB,sBAAsB,CACpB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,QAAQ,UAAO,GACd,cAAc,CAAC,IAAI,CAAC;IAYvB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,EAAE,0BAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAElE,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC;IAYhD,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAOpD"}
|
|
@@ -4,14 +4,16 @@ exports.Client = exports.KnownScript = void 0;
|
|
|
4
4
|
const ckb_1 = require("../ckb");
|
|
5
5
|
const fixedPoint_1 = require("../fixedPoint");
|
|
6
6
|
const num_1 = require("../num");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
7
8
|
var KnownScript;
|
|
8
9
|
(function (KnownScript) {
|
|
9
|
-
KnownScript[
|
|
10
|
-
KnownScript[
|
|
11
|
-
KnownScript[
|
|
12
|
-
KnownScript[
|
|
13
|
-
KnownScript[
|
|
14
|
-
KnownScript[
|
|
10
|
+
KnownScript["Secp256k1Blake160"] = "Secp256k1Blake160";
|
|
11
|
+
KnownScript["Secp256k1Multisig"] = "Secp256k1Multisig";
|
|
12
|
+
KnownScript["AnyoneCanPay"] = "AnyoneCanPay";
|
|
13
|
+
KnownScript["JoyId"] = "JoyId";
|
|
14
|
+
KnownScript["COTA"] = "COTA";
|
|
15
|
+
KnownScript["OmniLock"] = "OmniLock";
|
|
16
|
+
KnownScript["NostrLock"] = "NostrLock";
|
|
15
17
|
})(KnownScript || (exports.KnownScript = KnownScript = {}));
|
|
16
18
|
class Client {
|
|
17
19
|
async getCell(outPoint) {
|
|
@@ -66,7 +68,7 @@ class Client {
|
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
async getBalance(locks) {
|
|
69
|
-
return
|
|
71
|
+
return (0, utils_1.reduceAsync)(locks, async (acc, lock) => acc + (await this.getBalanceSingle(lock)), fixedPoint_1.Zero);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
exports.Client = Client;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Script } from "../ckb";
|
|
2
2
|
import { KnownScript } from "./client";
|
|
3
|
-
export declare const MAINNET_SCRIPTS: Record<KnownScript, Pick<Script, "codeHash" | "hashType"
|
|
3
|
+
export declare const MAINNET_SCRIPTS: Record<KnownScript, Pick<Script, "codeHash" | "hashType"> | undefined>;
|
|
4
4
|
//# sourceMappingURL=clientPublicMainnet.advanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicMainnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG,SAAS,CAiClD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAIjE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"clientPublicMainnet.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,GAAG,SAAgC,EAAE,OAAO,CAAC,EAAE,MAAM;IAIjE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,cAAc,CAClB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;CASlD"}
|
|
@@ -11,7 +11,11 @@ class ClientPublicMainnet extends jsonRpc_1.ClientJsonRpc {
|
|
|
11
11
|
return "ckb";
|
|
12
12
|
}
|
|
13
13
|
async getKnownScript(script) {
|
|
14
|
-
|
|
14
|
+
const found = clientPublicMainnet_advanced_1.MAINNET_SCRIPTS[script];
|
|
15
|
+
if (!found) {
|
|
16
|
+
throw new Error(`No script information was found for ${script} on ${this.addressPrefix}`);
|
|
17
|
+
}
|
|
18
|
+
return { ...found };
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
exports.ClientPublicMainnet = ClientPublicMainnet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"clientPublicTestnet.advanced.d.ts","sourceRoot":"","sources":["../../src/client/clientPublicTestnet.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAqCtC,CAAC"}
|
|
@@ -27,4 +27,8 @@ exports.TESTNET_SCRIPTS = {
|
|
|
27
27
|
codeHash: "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
|
|
28
28
|
hashType: "type",
|
|
29
29
|
},
|
|
30
|
+
[client_1.KnownScript.NostrLock]: {
|
|
31
|
+
codeHash: "0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5",
|
|
32
|
+
hashType: "type",
|
|
33
|
+
},
|
|
30
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;GAIG;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;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;GAIG;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;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAOvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA+BzE"}
|
|
@@ -57,8 +57,10 @@ class SignerBtc extends signer_1.Signer {
|
|
|
57
57
|
* @returns A promise that resolves to the prepared Transaction object.
|
|
58
58
|
*/
|
|
59
59
|
async prepareTransaction(txLike) {
|
|
60
|
+
const tx = ckb_1.Transaction.from(txLike);
|
|
60
61
|
const { script } = await this.getRecommendedAddressObj();
|
|
61
|
-
|
|
62
|
+
await tx.prepareSighashAllWitness(script, 85, this.client);
|
|
63
|
+
return tx;
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* Signs a transaction without modifying it.
|
|
@@ -77,7 +79,7 @@ class SignerBtc extends signer_1.Signer {
|
|
|
77
79
|
signature[0] = 31 + ((signature[0] - 27) % 4);
|
|
78
80
|
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
79
81
|
witness.lock = (0, hex_1.hexFrom)((0, bytes_1.bytesConcat)((0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(4 * 4, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(signature.length, 4), signature));
|
|
80
|
-
tx.
|
|
82
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
81
83
|
return tx;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
@@ -16,12 +16,6 @@ export declare class SignerBtcPublicKeyReadonly extends SignerBtc {
|
|
|
16
16
|
* @param publicKey - The public key associated with the signer.
|
|
17
17
|
*/
|
|
18
18
|
constructor(client: Client, account: string, publicKey: HexLike);
|
|
19
|
-
/**
|
|
20
|
-
* Construct a new signer with the client replaced.
|
|
21
|
-
*
|
|
22
|
-
* @returns A promise that resolves the new Signer.
|
|
23
|
-
*/
|
|
24
|
-
replaceClient(client: Client): Promise<SignerBtcPublicKeyReadonly>;
|
|
25
19
|
/**
|
|
26
20
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
27
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,
|
|
1
|
+
{"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAGtC"}
|
|
@@ -20,14 +20,6 @@ class SignerBtcPublicKeyReadonly extends signerBtc_1.SignerBtc {
|
|
|
20
20
|
this.account = account;
|
|
21
21
|
this.publicKey = (0, hex_1.hexFrom)(publicKey);
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Construct a new signer with the client replaced.
|
|
25
|
-
*
|
|
26
|
-
* @returns A promise that resolves the new Signer.
|
|
27
|
-
*/
|
|
28
|
-
async replaceClient(client) {
|
|
29
|
-
return new SignerBtcPublicKeyReadonly(client, this.account, this.publicKey);
|
|
30
|
-
}
|
|
31
23
|
/**
|
|
32
24
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
33
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AAGnD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAOT"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyMessageBtcEcdsa = void 0;
|
|
4
|
-
const
|
|
4
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
5
|
+
const bitcoinjs_message_1 = require("bitcoinjs-message");
|
|
6
|
+
const bytes_1 = require("../../bytes");
|
|
5
7
|
const hex_1 = require("../../hex");
|
|
6
8
|
function verifyMessageBtcEcdsa(message, signature, publicKey) {
|
|
7
9
|
const challenge = typeof message === "string" ? message : (0, hex_1.hexFrom)(message).slice(2);
|
|
8
|
-
|
|
10
|
+
const [_, ...rawSign] = (0, bytes_1.bytesFrom)(signature, "base64");
|
|
11
|
+
return secp256k1_1.secp256k1.verify((0, bytes_1.bytesFrom)(rawSign), (0, bitcoinjs_message_1.magicHash)(challenge), publicKey);
|
|
9
12
|
}
|
|
10
13
|
exports.verifyMessageBtcEcdsa = verifyMessageBtcEcdsa;
|
|
@@ -17,12 +17,6 @@ export declare class SignerCkbScriptReadonly extends Signer {
|
|
|
17
17
|
* @param script - The script associated with the signer.
|
|
18
18
|
*/
|
|
19
19
|
constructor(client: Client, script: ScriptLike);
|
|
20
|
-
/**
|
|
21
|
-
* Construct a new signer with the client replaced.
|
|
22
|
-
*
|
|
23
|
-
* @returns A promise that resolves the new Signer.
|
|
24
|
-
*/
|
|
25
|
-
replaceClient(client: Client): Promise<SignerCkbScriptReadonly>;
|
|
26
20
|
/**
|
|
27
21
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
28
22
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,
|
|
1
|
+
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IAEG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|
|
@@ -25,14 +25,6 @@ class SignerCkbScriptReadonly extends signer_1.Signer {
|
|
|
25
25
|
super(client);
|
|
26
26
|
this.script = ckb_1.Script.from(script);
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Construct a new signer with the client replaced.
|
|
30
|
-
*
|
|
31
|
-
* @returns A promise that resolves the new Signer.
|
|
32
|
-
*/
|
|
33
|
-
async replaceClient(client) {
|
|
34
|
-
return new SignerCkbScriptReadonly(client, this.script);
|
|
35
|
-
}
|
|
36
28
|
/**
|
|
37
29
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
38
30
|
*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "../../client";
|
|
2
|
+
import { SignerType } from "../signer";
|
|
3
|
+
import { SignerDummy } from "./dummy";
|
|
4
|
+
export declare class SignerAlwaysError extends SignerDummy {
|
|
5
|
+
private readonly message;
|
|
6
|
+
constructor(client: Client, type: SignerType, message: string);
|
|
7
|
+
connect(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=alwaysError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alwaysError.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/alwaysError.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,iBAAkB,SAAQ,WAAW;IAI9C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EACC,OAAO,EAAE,MAAM;IAK5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerAlwaysError = void 0;
|
|
4
|
+
const dummy_1 = require("./dummy");
|
|
5
|
+
class SignerAlwaysError extends dummy_1.SignerDummy {
|
|
6
|
+
constructor(client, type, message) {
|
|
7
|
+
super(client, type);
|
|
8
|
+
this.message = message;
|
|
9
|
+
}
|
|
10
|
+
async connect() {
|
|
11
|
+
throw new Error(this.message);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.SignerAlwaysError = SignerAlwaysError;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { Client } from "../../client";
|
|
3
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
4
|
+
export declare abstract class SignerDummy extends Signer {
|
|
5
|
+
readonly type: SignerType;
|
|
6
|
+
get signType(): SignerSignType;
|
|
7
|
+
constructor(client: Client, type: SignerType);
|
|
8
|
+
isConnected(): Promise<boolean>;
|
|
9
|
+
getInternalAddress(): Promise<string>;
|
|
10
|
+
getAddressObjs(): Promise<Address[]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=dummy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dummy.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/dummy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D,8BAAsB,WAAY,SAAQ,MAAM;aAO5B,IAAI,EAAE,UAAU;IANlC,IAAI,QAAQ,IAAI,cAAc,CAE7B;gBAGC,MAAM,EAAE,MAAM,EACE,IAAI,EAAE,UAAU;IAK5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerDummy = void 0;
|
|
4
|
+
const signer_1 = require("../signer");
|
|
5
|
+
class SignerDummy extends signer_1.Signer {
|
|
6
|
+
get signType() {
|
|
7
|
+
return signer_1.SignerSignType.Unknown;
|
|
8
|
+
}
|
|
9
|
+
constructor(client, type) {
|
|
10
|
+
super(client);
|
|
11
|
+
this.type = type;
|
|
12
|
+
}
|
|
13
|
+
async isConnected() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
async getInternalAddress() {
|
|
17
|
+
throw new Error("Can't get address from SignerDummy");
|
|
18
|
+
}
|
|
19
|
+
async getAddressObjs() {
|
|
20
|
+
throw new Error("Can't get addresses from SignerDummy");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.SignerDummy = SignerDummy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./alwaysError"), exports);
|
|
18
|
+
__exportStar(require("./dummy"), exports);
|
|
19
|
+
__exportStar(require("./openLink"), exports);
|
|
@@ -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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerOpenLink = void 0;
|
|
4
|
+
const dummy_1 = require("./dummy");
|
|
5
|
+
class SignerOpenLink extends dummy_1.SignerDummy {
|
|
6
|
+
constructor(client, type, link) {
|
|
7
|
+
super(client, type);
|
|
8
|
+
this.link = link;
|
|
9
|
+
}
|
|
10
|
+
async connect() {
|
|
11
|
+
window.open(this.link, "_blank")?.focus();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.SignerOpenLink = SignerOpenLink;
|
|
@@ -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"}
|
|
@@ -7,6 +7,7 @@ const ckb_1 = require("../../ckb");
|
|
|
7
7
|
const client_1 = require("../../client");
|
|
8
8
|
const hex_1 = require("../../hex");
|
|
9
9
|
const num_1 = require("../../num");
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
10
11
|
const signer_1 = require("../signer");
|
|
11
12
|
/**
|
|
12
13
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
@@ -52,8 +53,7 @@ class SignerEvm extends signer_1.Signer {
|
|
|
52
53
|
* @returns A promise that resolves to the prepared Transaction object.
|
|
53
54
|
*/
|
|
54
55
|
async prepareTransaction(txLike) {
|
|
55
|
-
|
|
56
|
-
return addresses.reduce((txPromise, { script }) => txPromise.then((tx) => tx.prepareSighashAllWitness(script, 85, this.client)), Promise.resolve(ckb_1.Transaction.from(txLike)));
|
|
56
|
+
return (0, utils_1.reduceAsync)(await this.getAddressObjs(), (tx, { script }) => tx.prepareSighashAllWitness(script, 85, this.client), ckb_1.Transaction.from(txLike));
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Signs a transaction without modifying it.
|
|
@@ -81,7 +81,7 @@ class SignerEvm extends signer_1.Signer {
|
|
|
81
81
|
}
|
|
82
82
|
const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
83
83
|
witness.lock = (0, hex_1.hexFrom)((0, bytes_1.bytesConcat)((0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(4 * 4, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(signature.length, 4), signature));
|
|
84
|
-
tx.
|
|
84
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
85
85
|
return tx;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -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"}
|
|
@@ -18,14 +18,6 @@ class SignerEvmAddressReadonly extends signerEvm_1.SignerEvm {
|
|
|
18
18
|
super(client);
|
|
19
19
|
this.address = (0, hex_1.hexFrom)(address);
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Construct a new signer with the client replaced.
|
|
23
|
-
*
|
|
24
|
-
* @returns A promise that resolves the new Signer.
|
|
25
|
-
*/
|
|
26
|
-
async replaceClient(client) {
|
|
27
|
-
return new SignerEvmAddressReadonly(client, this.address);
|
|
28
|
-
}
|
|
29
21
|
/**
|
|
30
22
|
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
31
23
|
*
|
|
@@ -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,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
|
@@ -16,5 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./btc"), exports);
|
|
18
18
|
__exportStar(require("./ckb"), exports);
|
|
19
|
+
__exportStar(require("./dummy"), exports);
|
|
19
20
|
__exportStar(require("./evm"), exports);
|
|
21
|
+
__exportStar(require("./nostr"), exports);
|
|
20
22
|
__exportStar(require("./signer"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/nostr/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./signerNostr"), exports);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { BytesLike } from "../../bytes";
|
|
3
|
+
import { Transaction, TransactionLike } from "../../ckb";
|
|
4
|
+
import { Hex } from "../../hex";
|
|
5
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
6
|
+
export interface NostrEvent {
|
|
7
|
+
id?: string;
|
|
8
|
+
pubkey?: string;
|
|
9
|
+
sig?: string;
|
|
10
|
+
created_at: number;
|
|
11
|
+
kind: number;
|
|
12
|
+
tags: string[][];
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class SignerNostr extends Signer {
|
|
16
|
+
static CKB_SIG_HASH_ALL_TAG: string;
|
|
17
|
+
static CKB_UNLOCK_EVENT_KIND: number;
|
|
18
|
+
static CKB_UNLOCK_EVENT_CONTENT: string;
|
|
19
|
+
get type(): SignerType;
|
|
20
|
+
get signType(): SignerSignType;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the Nostr public key associated with the signer.
|
|
23
|
+
*
|
|
24
|
+
* @returns A promise that resolves to a string representing the Nostr public key.
|
|
25
|
+
*/
|
|
26
|
+
abstract getNostrPublicKey(): Promise<Hex>;
|
|
27
|
+
/**
|
|
28
|
+
* Sign a nostr event.
|
|
29
|
+
*
|
|
30
|
+
* @returns A promise that resolves to the signed event.
|
|
31
|
+
*/
|
|
32
|
+
abstract signNostrEvent(event: NostrEvent): Promise<Required<NostrEvent>>;
|
|
33
|
+
/**
|
|
34
|
+
* Sign a message.
|
|
35
|
+
*
|
|
36
|
+
* @returns A promise that resolves to the signature.
|
|
37
|
+
*/
|
|
38
|
+
signMessageRaw(message: string | BytesLike): Promise<Hex>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the internal address, which is the EVM account in this case.
|
|
41
|
+
*
|
|
42
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
43
|
+
*/
|
|
44
|
+
getInternalAddress(): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
47
|
+
*
|
|
48
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
49
|
+
*/
|
|
50
|
+
getAddressObjs(): Promise<Address[]>;
|
|
51
|
+
/**
|
|
52
|
+
* prepare a transaction before signing.
|
|
53
|
+
*
|
|
54
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
55
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
56
|
+
*/
|
|
57
|
+
prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
58
|
+
/**
|
|
59
|
+
* Signs a transaction without modifying it.
|
|
60
|
+
*
|
|
61
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
62
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
63
|
+
*/
|
|
64
|
+
signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=signerNostr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerNostr.d.ts","sourceRoot":"","sources":["../../../src/signer/nostr/signerNostr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAGtE,OAAO,EAAE,GAAG,EAAW,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG/D,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8BAAsB,WAAY,SAAQ,MAAM;IAC9C,MAAM,CAAC,oBAAoB,SAAqB;IAChD,MAAM,CAAC,qBAAqB,SAAS;IACrC,MAAM,CAAC,wBAAwB,SACkH;IAEjJ,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEzE;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAM/D;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAO3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAW1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAOvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA2BzE"}
|