@ckb-ccc/uni-sat 1.0.32 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/advanced.d.mts +2 -0
- package/dist/advanced.mjs +1 -0
- package/dist/advancedBarrel-6fyDO_pc.d.mts +100 -0
- package/dist/advancedBarrel-6fyDO_pc.d.mts.map +1 -0
- package/dist/advancedBarrel.d.mts +2 -0
- package/dist/advancedBarrel.mjs +2 -0
- package/dist/advancedBarrel.mjs.map +1 -0
- package/dist/barrel.d.mts +81 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +2 -0
- package/dist/barrel.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/rolldown-runtime-DK3Fl9T5.mjs +1 -0
- package/dist.commonjs/advanced.d.ts +2 -2
- package/dist.commonjs/advanced.js +1 -37
- package/dist.commonjs/advancedBarrel-C8SL2uu7.d.ts +100 -0
- package/dist.commonjs/advancedBarrel-C8SL2uu7.d.ts.map +1 -0
- package/dist.commonjs/advancedBarrel.d.ts +2 -77
- package/dist.commonjs/advancedBarrel.js +2 -2
- package/dist.commonjs/advancedBarrel.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +80 -2
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +2 -18
- package/dist.commonjs/barrel.js.map +1 -0
- package/dist.commonjs/index.d.ts +2 -2
- package/dist.commonjs/index.js +1 -37
- package/dist.commonjs/rolldown-runtime-BIInC43l.js +1 -0
- package/package.json +26 -29
- package/src/advancedBarrel.ts +19 -0
- package/src/signer.ts +30 -0
- package/tsdown.config.mts +43 -0
- package/dist/advanced.d.ts +0 -2
- package/dist/advanced.d.ts.map +0 -1
- package/dist/advanced.js +0 -1
- package/dist/advancedBarrel.d.ts +0 -77
- package/dist/advancedBarrel.d.ts.map +0 -1
- package/dist/advancedBarrel.js +0 -1
- package/dist/barrel.d.ts +0 -3
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/signer.d.ts +0 -49
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -127
- package/dist/signersFactory.d.ts +0 -10
- package/dist/signersFactory.d.ts.map +0 -1
- package/dist/signersFactory.js +0 -20
- package/dist.commonjs/advanced.d.ts.map +0 -1
- package/dist.commonjs/advancedBarrel.d.ts.map +0 -1
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/signer.d.ts +0 -49
- package/dist.commonjs/signer.d.ts.map +0 -1
- package/dist.commonjs/signer.js +0 -131
- package/dist.commonjs/signersFactory.d.ts +0 -10
- package/dist.commonjs/signersFactory.d.ts.map +0 -1
- package/dist.commonjs/signersFactory.js +0 -23
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.js","names":["ccc"],"sources":["../src/signer.ts","../src/signersFactory.ts","../src/barrel.ts"],"sourcesContent":["import { ccc } from \"@ckb-ccc/core\";\nimport { Provider } from \"./advancedBarrel.js\";\n\n/**\n * Class representing a Bitcoin signer that extends SignerBtc\n * @public\n */\nexport class Signer extends ccc.SignerBtc {\n /**\n * Creates an instance of Signer.\n * @param client - The client instance.\n * @param provider - The provider instance.\n */\n constructor(\n client: ccc.Client,\n public readonly provider: Provider,\n private readonly preferredNetworks: ccc.NetworkPreference[] = [\n {\n addressPrefix: \"ckb\",\n signerType: ccc.SignerType.BTC,\n network: \"btc\",\n },\n {\n addressPrefix: \"ckt\",\n signerType: ccc.SignerType.BTC,\n network: \"btcTestnet\",\n },\n ],\n ) {\n super(client);\n }\n\n async _getNetworkToChange(): Promise<string | undefined> {\n const currentNetwork = await (async () => {\n if (this.provider.getChain) {\n return (\n {\n BITCOIN_MAINNET: \"btc\",\n BITCOIN_TESTNET: \"btcTestnet\",\n FRACTAL_BITCOIN_MAINNET: \"fractalBtc\",\n }[(await this.provider.getChain()).enum] ?? \"\"\n );\n }\n return (await this.provider.getNetwork()) === \"livenet\"\n ? \"btc\"\n : \"btcTestnet\";\n })();\n const { network } = this.matchNetworkPreference(\n this.preferredNetworks,\n currentNetwork,\n ) ?? { network: currentNetwork };\n if (network === currentNetwork) {\n return;\n }\n\n return network;\n }\n\n /**\n * Ensure the BTC network is the same as CKB network.\n */\n async ensureNetwork(): Promise<void> {\n const network = await this._getNetworkToChange();\n if (!network) {\n return;\n }\n if (this.provider.switchChain) {\n const chain = {\n btc: \"BITCOIN_MAINNET\",\n btcTestnet: \"BITCOIN_TESTNET\",\n fractalBtc: \"FRACTAL_BITCOIN_MAINNET\",\n }[network];\n if (chain) {\n await this.provider.switchChain(chain);\n return;\n }\n } else if (network === \"btc\" || network === \"btcTestnet\") {\n await this.provider.switchNetwork(\n network === \"btc\" ? \"livenet\" : \"testnet\",\n );\n return;\n }\n\n throw new Error(\n `UniSat wallet doesn't support the requested chain ${network}`,\n );\n }\n\n /**\n * Gets the Bitcoin account address.\n * @returns A promise that resolves to the Bitcoin account address.\n */\n async getBtcAccount(): Promise<string> {\n return (await this.provider.getAccounts())[0];\n }\n\n /**\n * Gets the Bitcoin public key.\n * @returns A promise that resolves to the Bitcoin public key.\n */\n async getBtcPublicKey(): Promise<ccc.Hex> {\n return ccc.hexFrom(await this.provider.getPublicKey());\n }\n\n /**\n * Connects to the provider by requesting accounts.\n * @returns A promise that resolves when the connection is established.\n */\n async connect(): Promise<void> {\n await this.provider.requestAccounts();\n await this.ensureNetwork();\n }\n\n onReplaced(listener: () => void): () => void {\n const stop: (() => void)[] = [];\n const replacer = async () => {\n listener();\n stop[0]?.();\n };\n stop.push(() => {\n this.provider.removeListener(\"accountsChanged\", replacer);\n this.provider.removeListener(\"networkChanged\", replacer);\n });\n\n this.provider.on(\"accountsChanged\", replacer);\n this.provider.on(\"networkChanged\", replacer);\n\n return stop[0];\n }\n\n /**\n * Checks if the signer is connected.\n * @returns A promise that resolves to true if connected, false otherwise.\n */\n async isConnected(): Promise<boolean> {\n if (await this._getNetworkToChange()) {\n return false;\n }\n return (await this.provider.getAccounts()).length !== 0;\n }\n\n /**\n * Signs a raw message with the Bitcoin account.\n * @param message - The message to sign.\n * @returns A promise that resolves to the signed message.\n */\n async signMessageRaw(message: string | ccc.BytesLike): Promise<string> {\n const challenge =\n typeof message === \"string\" ? message : ccc.hexFrom(message).slice(2);\n\n return this.provider.signMessage(challenge, \"ecdsa\");\n }\n\n /**\n * Signs a PSBT using UniSat wallet.\n *\n * @param psbtHex - The hex string of PSBT to sign.\n * @param options - Options for signing the PSBT\n * @returns A promise that resolves to the signed PSBT as a Hex string\n */\n async signPsbt(\n psbtHex: ccc.HexLike,\n options?: ccc.SignPsbtOptionsLike,\n ): Promise<ccc.Hex> {\n return ccc.hexFrom(\n await this.provider.signPsbt(ccc.hexFrom(psbtHex).slice(2), options),\n );\n }\n\n /**\n * Broadcasts a signed PSBT to the Bitcoin network.\n *\n * @param psbtHex - The hex string of signed PSBT to broadcast.\n * @returns A promise that resolves to the transaction ID as a Hex string\n */\n async broadcastPsbt(\n psbtHex: ccc.HexLike,\n _options?: ccc.SignPsbtOptionsLike,\n ): Promise<ccc.Hex> {\n const txid = await this.provider.pushPsbt(ccc.hexFrom(psbtHex).slice(2));\n return ccc.hexFrom(txid);\n }\n}\n","import { ccc } from \"@ckb-ccc/core\";\nimport { Provider } from \"./advancedBarrel.js\";\nimport { Signer } from \"./signer.js\";\n\n/**\n * Retrieves the UniSat signer if available.\n * @public\n *\n * @param client - The client instance.\n * @returns The Signer instance if the UniSat provider is available, otherwise undefined.\n */\nexport function getUniSatSigners(\n client: ccc.Client,\n preferredNetworks?: ccc.NetworkPreference[],\n): ccc.SignerInfo[] {\n const windowRef = window as { unisat?: Provider };\n\n if (typeof windowRef.unisat === \"undefined\") {\n return [];\n }\n\n return [\n {\n signer: new Signer(client, windowRef.unisat, preferredNetworks),\n name: \"BTC\",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|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as barrel_d_exports } from "./barrel.js";
|
|
2
|
+
export { barrel_d_exports as UniSat };
|
package/dist.commonjs/index.js
CHANGED
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.UniSat = void 0;
|
|
37
|
-
exports.UniSat = __importStar(require("./barrel.js"));
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./barrel.js");Object.defineProperty(exports,"UniSat",{enumerable:!0,get:function(){return e.t}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/uni-sat",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for UniSat",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,50 +11,47 @@
|
|
|
11
11
|
"url": "git://github.com/ckb-devrel/ccc.git"
|
|
12
12
|
},
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"main": "dist.commonjs/index.js",
|
|
15
|
-
"module": "dist/index.
|
|
14
|
+
"main": "./dist.commonjs/index.js",
|
|
15
|
+
"module": "./dist/index.mjs",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"import": "./dist/index.
|
|
19
|
-
"require": "./dist.commonjs/index.js"
|
|
20
|
-
"default": "./dist.commonjs/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./barrel": {
|
|
23
|
-
"import": "./dist/barrel.js",
|
|
24
|
-
"require": "./dist.commonjs/barrel.js",
|
|
25
|
-
"default": "./dist.commonjs/barrel.js"
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist.commonjs/index.js"
|
|
26
20
|
},
|
|
27
21
|
"./advanced": {
|
|
28
|
-
"import": "./dist/advanced.
|
|
29
|
-
"require": "./dist.commonjs/advanced.js"
|
|
30
|
-
"default": "./dist.commonjs/advanced.js"
|
|
22
|
+
"import": "./dist/advanced.mjs",
|
|
23
|
+
"require": "./dist.commonjs/advanced.js"
|
|
31
24
|
},
|
|
32
25
|
"./advancedBarrel": {
|
|
33
|
-
"import": "./dist/advancedBarrel.
|
|
34
|
-
"require": "./dist.commonjs/advancedBarrel.js"
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
"import": "./dist/advancedBarrel.mjs",
|
|
27
|
+
"require": "./dist.commonjs/advancedBarrel.js"
|
|
28
|
+
},
|
|
29
|
+
"./barrel": {
|
|
30
|
+
"import": "./dist/barrel.mjs",
|
|
31
|
+
"require": "./dist.commonjs/barrel.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
37
34
|
},
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"@eslint/js": "^
|
|
40
|
-
"
|
|
41
|
-
"eslint": "^9.34.0",
|
|
36
|
+
"@eslint/js": "^10.0.1",
|
|
37
|
+
"eslint": "^10.5.0",
|
|
42
38
|
"eslint-config-prettier": "^10.1.8",
|
|
43
|
-
"eslint-plugin-prettier": "^5.5.
|
|
44
|
-
"prettier": "^3.
|
|
45
|
-
"prettier-plugin-organize-imports": "^4.
|
|
46
|
-
"
|
|
47
|
-
"typescript": "^
|
|
48
|
-
"typescript-eslint": "^8.41.0"
|
|
39
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
40
|
+
"prettier": "^3.8.4",
|
|
41
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"typescript-eslint": "^8.61.1"
|
|
49
44
|
},
|
|
50
45
|
"publishConfig": {
|
|
51
46
|
"access": "public"
|
|
52
47
|
},
|
|
53
48
|
"dependencies": {
|
|
54
|
-
"
|
|
49
|
+
"tsdown": "^0.22.3",
|
|
50
|
+
"@ckb-ccc/core": "1.14.0"
|
|
55
51
|
},
|
|
52
|
+
"types": "./dist.commonjs/index.d.ts",
|
|
56
53
|
"scripts": {
|
|
57
|
-
"build": "
|
|
54
|
+
"build": "tsdown",
|
|
58
55
|
"lint": "eslint ./src",
|
|
59
56
|
"format": "prettier --write . && eslint --fix ./src"
|
|
60
57
|
}
|
package/src/advancedBarrel.ts
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Interface representing a provider for interacting with accounts and signing messages.
|
|
3
5
|
*/
|
|
4
6
|
export interface Provider {
|
|
7
|
+
/**
|
|
8
|
+
* Signs a PSBT using UniSat wallet.
|
|
9
|
+
*
|
|
10
|
+
* @param psbtHex - The hex string of PSBT to sign
|
|
11
|
+
* @param options - Options for signing the PSBT
|
|
12
|
+
* @returns A promise that resolves to the signed PSBT hex string
|
|
13
|
+
*/
|
|
14
|
+
signPsbt(psbtHex: string, options?: ccc.SignPsbtOptionsLike): Promise<string>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Broadcasts a signed PSBT to the Bitcoin network.
|
|
18
|
+
*
|
|
19
|
+
* @param psbtHex - The hex string of the signed PSBT to broadcast.
|
|
20
|
+
* @returns A promise that resolves to the transaction ID.
|
|
21
|
+
*/
|
|
22
|
+
pushPsbt(psbtHex: string): Promise<string>;
|
|
23
|
+
|
|
5
24
|
/**
|
|
6
25
|
* Requests user accounts.
|
|
7
26
|
* @returns A promise that resolves to an array of account addresses.
|
package/src/signer.ts
CHANGED
|
@@ -150,4 +150,34 @@ export class Signer extends ccc.SignerBtc {
|
|
|
150
150
|
|
|
151
151
|
return this.provider.signMessage(challenge, "ecdsa");
|
|
152
152
|
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Signs a PSBT using UniSat wallet.
|
|
156
|
+
*
|
|
157
|
+
* @param psbtHex - The hex string of PSBT to sign.
|
|
158
|
+
* @param options - Options for signing the PSBT
|
|
159
|
+
* @returns A promise that resolves to the signed PSBT as a Hex string
|
|
160
|
+
*/
|
|
161
|
+
async signPsbt(
|
|
162
|
+
psbtHex: ccc.HexLike,
|
|
163
|
+
options?: ccc.SignPsbtOptionsLike,
|
|
164
|
+
): Promise<ccc.Hex> {
|
|
165
|
+
return ccc.hexFrom(
|
|
166
|
+
await this.provider.signPsbt(ccc.hexFrom(psbtHex).slice(2), options),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Broadcasts a signed PSBT to the Bitcoin network.
|
|
172
|
+
*
|
|
173
|
+
* @param psbtHex - The hex string of signed PSBT to broadcast.
|
|
174
|
+
* @returns A promise that resolves to the transaction ID as a Hex string
|
|
175
|
+
*/
|
|
176
|
+
async broadcastPsbt(
|
|
177
|
+
psbtHex: ccc.HexLike,
|
|
178
|
+
_options?: ccc.SignPsbtOptionsLike,
|
|
179
|
+
): Promise<ccc.Hex> {
|
|
180
|
+
const txid = await this.provider.pushPsbt(ccc.hexFrom(psbtHex).slice(2));
|
|
181
|
+
return ccc.hexFrom(txid);
|
|
182
|
+
}
|
|
153
183
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
const common = {
|
|
4
|
+
minify: true,
|
|
5
|
+
dts: true,
|
|
6
|
+
platform: "neutral" as const,
|
|
7
|
+
sourcemap: true,
|
|
8
|
+
exports: true,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const entry = {
|
|
12
|
+
index: "src/index.ts",
|
|
13
|
+
barrel: "src/barrel.ts",
|
|
14
|
+
advanced: "src/advanced.ts",
|
|
15
|
+
advancedBarrel: "src/advancedBarrel.ts",
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
const bundleDeps: string[] = [];
|
|
19
|
+
|
|
20
|
+
export default defineConfig(
|
|
21
|
+
(
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
entry,
|
|
25
|
+
deps: {
|
|
26
|
+
onlyBundle: [] as string[],
|
|
27
|
+
},
|
|
28
|
+
format: "esm",
|
|
29
|
+
copy: "./misc/basedirs/dist/*",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
entry,
|
|
33
|
+
deps: {
|
|
34
|
+
alwaysBundle: bundleDeps,
|
|
35
|
+
onlyBundle: bundleDeps,
|
|
36
|
+
},
|
|
37
|
+
format: "cjs",
|
|
38
|
+
outDir: "dist.commonjs",
|
|
39
|
+
copy: "./misc/basedirs/dist.commonjs/*",
|
|
40
|
+
},
|
|
41
|
+
] as const
|
|
42
|
+
).map((c) => ({ ...c, ...common })),
|
|
43
|
+
);
|
package/dist/advanced.d.ts
DELETED
package/dist/advanced.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
|
package/dist/advanced.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as UniSatA from "./advancedBarrel.js";
|
package/dist/advancedBarrel.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface representing a provider for interacting with accounts and signing messages.
|
|
3
|
-
*/
|
|
4
|
-
export interface Provider {
|
|
5
|
-
/**
|
|
6
|
-
* Requests user accounts.
|
|
7
|
-
* @returns A promise that resolves to an array of account addresses.
|
|
8
|
-
*/
|
|
9
|
-
requestAccounts(): Promise<string[]>;
|
|
10
|
-
/**
|
|
11
|
-
* Gets the current network.
|
|
12
|
-
* @returns current network.
|
|
13
|
-
*/
|
|
14
|
-
getNetwork(): Promise<"livenet" | "testnet">;
|
|
15
|
-
/**
|
|
16
|
-
* Switch the current network.
|
|
17
|
-
*/
|
|
18
|
-
switchNetwork(chain: "livenet" | "testnet"): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Gets the current chain.
|
|
21
|
-
* @returns current chain.
|
|
22
|
-
*/
|
|
23
|
-
getChain?(): Promise<{
|
|
24
|
-
enum: string;
|
|
25
|
-
name: string;
|
|
26
|
-
network: string;
|
|
27
|
-
}>;
|
|
28
|
-
/**
|
|
29
|
-
* Switch the current chain.
|
|
30
|
-
*/
|
|
31
|
-
switchChain?(chain: string): Promise<{
|
|
32
|
-
enum: string;
|
|
33
|
-
name: string;
|
|
34
|
-
network: string;
|
|
35
|
-
}>;
|
|
36
|
-
/**
|
|
37
|
-
* Gets the current accounts.
|
|
38
|
-
* @returns A promise that resolves to an array of account addresses.
|
|
39
|
-
*/
|
|
40
|
-
getAccounts(): Promise<string[]>;
|
|
41
|
-
/**
|
|
42
|
-
* Gets the public key of the account.
|
|
43
|
-
* @returns A promise that resolves to the public key.
|
|
44
|
-
*/
|
|
45
|
-
getPublicKey(): Promise<string>;
|
|
46
|
-
/**
|
|
47
|
-
* Signs a message with the specified type.
|
|
48
|
-
* @param msg - The message to sign.
|
|
49
|
-
* @param type - The type of signature.
|
|
50
|
-
* @returns A promise that resolves to the signed message.
|
|
51
|
-
*/
|
|
52
|
-
signMessage(msg: string, type: "ecdsa" | "bip322-simple"): Promise<string>;
|
|
53
|
-
/**
|
|
54
|
-
* Adds an event listener to the provider.
|
|
55
|
-
*/
|
|
56
|
-
on: OnMethod;
|
|
57
|
-
/**
|
|
58
|
-
* Removes an event listener from the provider.
|
|
59
|
-
* @param eventName - The name of the event to remove the listener from.
|
|
60
|
-
* @param listener - The listener function to remove.
|
|
61
|
-
* @returns The provider instance.
|
|
62
|
-
*/
|
|
63
|
-
removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Interface representing a method to add event listeners to the provider.
|
|
67
|
-
*/
|
|
68
|
-
export interface OnMethod {
|
|
69
|
-
/**
|
|
70
|
-
* Adds an event listener to the provider.
|
|
71
|
-
* @param eventName - The name of the event.
|
|
72
|
-
* @param listener - The listener function.
|
|
73
|
-
* @returns The provider instance.
|
|
74
|
-
*/
|
|
75
|
-
(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=advancedBarrel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAErC;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAE7C;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D;;;OAGG;IACH,QAAQ,CAAC,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEtE;;OAEG;IACH,WAAW,CAAC,CACV,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE5D;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEjC;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3E;;OAEG;IACH,EAAE,EAAE,QAAQ,CAAC;IAEb;;;;;OAKG;IACH,cAAc,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACxC,QAAQ,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,QAAQ,CAAC;CAC1E"}
|
package/dist/advancedBarrel.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/barrel.d.ts
DELETED
package/dist/barrel.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|
package/dist/barrel.js
DELETED
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as UniSat from "./barrel.js";
|
package/dist/signer.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { Provider } from "./advancedBarrel.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare class Signer extends ccc.SignerBtc {
|
|
8
|
-
readonly provider: Provider;
|
|
9
|
-
private readonly preferredNetworks;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of Signer.
|
|
12
|
-
* @param client - The client instance.
|
|
13
|
-
* @param provider - The provider instance.
|
|
14
|
-
*/
|
|
15
|
-
constructor(client: ccc.Client, provider: Provider, preferredNetworks?: ccc.NetworkPreference[]);
|
|
16
|
-
_getNetworkToChange(): Promise<string | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* Ensure the BTC network is the same as CKB network.
|
|
19
|
-
*/
|
|
20
|
-
ensureNetwork(): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Gets the Bitcoin account address.
|
|
23
|
-
* @returns A promise that resolves to the Bitcoin account address.
|
|
24
|
-
*/
|
|
25
|
-
getBtcAccount(): Promise<string>;
|
|
26
|
-
/**
|
|
27
|
-
* Gets the Bitcoin public key.
|
|
28
|
-
* @returns A promise that resolves to the Bitcoin public key.
|
|
29
|
-
*/
|
|
30
|
-
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
31
|
-
/**
|
|
32
|
-
* Connects to the provider by requesting accounts.
|
|
33
|
-
* @returns A promise that resolves when the connection is established.
|
|
34
|
-
*/
|
|
35
|
-
connect(): Promise<void>;
|
|
36
|
-
onReplaced(listener: () => void): () => void;
|
|
37
|
-
/**
|
|
38
|
-
* Checks if the signer is connected.
|
|
39
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
40
|
-
*/
|
|
41
|
-
isConnected(): Promise<boolean>;
|
|
42
|
-
/**
|
|
43
|
-
* Signs a raw message with the Bitcoin account.
|
|
44
|
-
* @param message - The message to sign.
|
|
45
|
-
* @returns A promise that resolves to the signed message.
|
|
46
|
-
*/
|
|
47
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=signer.d.ts.map
|
package/dist/signer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAQrB,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IARpC;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD;IAKG,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA0BxD;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAIzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiB5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAOrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAMvE"}
|
package/dist/signer.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Class representing a Bitcoin signer that extends SignerBtc
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export class Signer extends ccc.SignerBtc {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of Signer.
|
|
9
|
-
* @param client - The client instance.
|
|
10
|
-
* @param provider - The provider instance.
|
|
11
|
-
*/
|
|
12
|
-
constructor(client, provider, preferredNetworks = [
|
|
13
|
-
{
|
|
14
|
-
addressPrefix: "ckb",
|
|
15
|
-
signerType: ccc.SignerType.BTC,
|
|
16
|
-
network: "btc",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
addressPrefix: "ckt",
|
|
20
|
-
signerType: ccc.SignerType.BTC,
|
|
21
|
-
network: "btcTestnet",
|
|
22
|
-
},
|
|
23
|
-
]) {
|
|
24
|
-
super(client);
|
|
25
|
-
this.provider = provider;
|
|
26
|
-
this.preferredNetworks = preferredNetworks;
|
|
27
|
-
}
|
|
28
|
-
async _getNetworkToChange() {
|
|
29
|
-
const currentNetwork = await (async () => {
|
|
30
|
-
if (this.provider.getChain) {
|
|
31
|
-
return ({
|
|
32
|
-
BITCOIN_MAINNET: "btc",
|
|
33
|
-
BITCOIN_TESTNET: "btcTestnet",
|
|
34
|
-
FRACTAL_BITCOIN_MAINNET: "fractalBtc",
|
|
35
|
-
}[(await this.provider.getChain()).enum] ?? "");
|
|
36
|
-
}
|
|
37
|
-
return (await this.provider.getNetwork()) === "livenet"
|
|
38
|
-
? "btc"
|
|
39
|
-
: "btcTestnet";
|
|
40
|
-
})();
|
|
41
|
-
const { network } = this.matchNetworkPreference(this.preferredNetworks, currentNetwork) ?? { network: currentNetwork };
|
|
42
|
-
if (network === currentNetwork) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
return network;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Ensure the BTC network is the same as CKB network.
|
|
49
|
-
*/
|
|
50
|
-
async ensureNetwork() {
|
|
51
|
-
const network = await this._getNetworkToChange();
|
|
52
|
-
if (!network) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (this.provider.switchChain) {
|
|
56
|
-
const chain = {
|
|
57
|
-
btc: "BITCOIN_MAINNET",
|
|
58
|
-
btcTestnet: "BITCOIN_TESTNET",
|
|
59
|
-
fractalBtc: "FRACTAL_BITCOIN_MAINNET",
|
|
60
|
-
}[network];
|
|
61
|
-
if (chain) {
|
|
62
|
-
await this.provider.switchChain(chain);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else if (network === "btc" || network === "btcTestnet") {
|
|
67
|
-
await this.provider.switchNetwork(network === "btc" ? "livenet" : "testnet");
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
throw new Error(`UniSat wallet doesn't support the requested chain ${network}`);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Gets the Bitcoin account address.
|
|
74
|
-
* @returns A promise that resolves to the Bitcoin account address.
|
|
75
|
-
*/
|
|
76
|
-
async getBtcAccount() {
|
|
77
|
-
return (await this.provider.getAccounts())[0];
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Gets the Bitcoin public key.
|
|
81
|
-
* @returns A promise that resolves to the Bitcoin public key.
|
|
82
|
-
*/
|
|
83
|
-
async getBtcPublicKey() {
|
|
84
|
-
return ccc.hexFrom(await this.provider.getPublicKey());
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Connects to the provider by requesting accounts.
|
|
88
|
-
* @returns A promise that resolves when the connection is established.
|
|
89
|
-
*/
|
|
90
|
-
async connect() {
|
|
91
|
-
await this.provider.requestAccounts();
|
|
92
|
-
await this.ensureNetwork();
|
|
93
|
-
}
|
|
94
|
-
onReplaced(listener) {
|
|
95
|
-
const stop = [];
|
|
96
|
-
const replacer = async () => {
|
|
97
|
-
listener();
|
|
98
|
-
stop[0]?.();
|
|
99
|
-
};
|
|
100
|
-
stop.push(() => {
|
|
101
|
-
this.provider.removeListener("accountsChanged", replacer);
|
|
102
|
-
this.provider.removeListener("networkChanged", replacer);
|
|
103
|
-
});
|
|
104
|
-
this.provider.on("accountsChanged", replacer);
|
|
105
|
-
this.provider.on("networkChanged", replacer);
|
|
106
|
-
return stop[0];
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Checks if the signer is connected.
|
|
110
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
111
|
-
*/
|
|
112
|
-
async isConnected() {
|
|
113
|
-
if (await this._getNetworkToChange()) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
return (await this.provider.getAccounts()).length !== 0;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Signs a raw message with the Bitcoin account.
|
|
120
|
-
* @param message - The message to sign.
|
|
121
|
-
* @returns A promise that resolves to the signed message.
|
|
122
|
-
*/
|
|
123
|
-
async signMessageRaw(message) {
|
|
124
|
-
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
125
|
-
return this.provider.signMessage(challenge, "ecdsa");
|
|
126
|
-
}
|
|
127
|
-
}
|
package/dist/signersFactory.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves the UniSat signer if available.
|
|
4
|
-
* @public
|
|
5
|
-
*
|
|
6
|
-
* @param client - The client instance.
|
|
7
|
-
* @returns The Signer instance if the UniSat provider is available, otherwise undefined.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getUniSatSigners(client: ccc.Client, preferredNetworks?: ccc.NetworkPreference[]): ccc.SignerInfo[];
|
|
10
|
-
//# sourceMappingURL=signersFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signersFactory.d.ts","sourceRoot":"","sources":["../src/signersFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAC1C,GAAG,CAAC,UAAU,EAAE,CAalB"}
|
package/dist/signersFactory.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Signer } from "./signer.js";
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves the UniSat signer if available.
|
|
4
|
-
* @public
|
|
5
|
-
*
|
|
6
|
-
* @param client - The client instance.
|
|
7
|
-
* @returns The Signer instance if the UniSat provider is available, otherwise undefined.
|
|
8
|
-
*/
|
|
9
|
-
export function getUniSatSigners(client, preferredNetworks) {
|
|
10
|
-
const windowRef = window;
|
|
11
|
-
if (typeof windowRef.unisat === "undefined") {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
signer: new Signer(client, windowRef.unisat, preferredNetworks),
|
|
17
|
-
name: "BTC",
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAErC;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAE7C;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D;;;OAGG;IACH,QAAQ,CAAC,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEtE;;OAEG;IACH,WAAW,CAAC,CACV,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CA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