@ckb-ccc/utxo-global 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-C6-MvbTQ.d.mts +28 -0
- package/dist/advancedBarrel-C6-MvbTQ.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-B9Y4t3uV.mjs +2 -0
- package/dist/barrel-B9Y4t3uV.mjs.map +1 -0
- package/dist/barrel.d.mts +81 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +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-E-x_uQzK.d.ts +28 -0
- package/dist.commonjs/advancedBarrel-E-x_uQzK.d.ts.map +1 -0
- package/dist.commonjs/advancedBarrel.d.ts +2 -21
- package/dist.commonjs/advancedBarrel.js +2 -2
- package/dist.commonjs/advancedBarrel.js.map +1 -0
- package/dist.commonjs/barrel-6nvDT30n.js +2 -0
- package/dist.commonjs/barrel-6nvDT30n.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +80 -3
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +1 -19
- 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/btc/index.ts +28 -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 -21
- package/dist/advancedBarrel.d.ts.map +0 -1
- package/dist/advancedBarrel.js +0 -1
- package/dist/barrel.d.ts +0 -4
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -3
- package/dist/btc/index.d.ts +0 -23
- package/dist/btc/index.d.ts.map +0 -1
- package/dist/btc/index.js +0 -97
- package/dist/ckb/index.d.ts +0 -30
- package/dist/ckb/index.d.ts.map +0 -1
- package/dist/ckb/index.js +0 -92
- package/dist/doge/index.d.ts +0 -22
- package/dist/doge/index.d.ts.map +0 -1
- package/dist/doge/index.js +0 -84
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/signersFactory.d.ts +0 -6
- package/dist/signersFactory.d.ts.map +0 -1
- package/dist/signersFactory.js +0 -26
- package/dist.commonjs/advanced.d.ts.map +0 -1
- package/dist.commonjs/advancedBarrel.d.ts.map +0 -1
- package/dist.commonjs/btc/index.d.ts +0 -23
- package/dist.commonjs/btc/index.d.ts.map +0 -1
- package/dist.commonjs/btc/index.js +0 -101
- package/dist.commonjs/ckb/index.d.ts +0 -30
- package/dist.commonjs/ckb/index.d.ts.map +0 -1
- package/dist.commonjs/ckb/index.js +0 -96
- package/dist.commonjs/doge/index.d.ts +0 -22
- package/dist.commonjs/doge/index.d.ts.map +0 -1
- package/dist.commonjs/doge/index.js +0 -88
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/signersFactory.d.ts +0 -6
- package/dist.commonjs/signersFactory.d.ts.map +0 -1
- package/dist.commonjs/signersFactory.js +0 -29
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { Provider } from "../advancedBarrel.js";
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export declare class SignerBtc extends ccc.SignerBtc {
|
|
7
|
-
readonly provider: Provider;
|
|
8
|
-
private readonly preferredNetworks;
|
|
9
|
-
private accountCache;
|
|
10
|
-
constructor(client: ccc.Client, provider: Provider, preferredNetworks?: ccc.NetworkPreference[]);
|
|
11
|
-
getBtcAccount(): Promise<string>;
|
|
12
|
-
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
13
|
-
/**
|
|
14
|
-
* Ensure the BTC network is the same as CKB network.
|
|
15
|
-
*/
|
|
16
|
-
ensureNetwork(): Promise<void>;
|
|
17
|
-
_getNetworkToChange(): Promise<string | undefined>;
|
|
18
|
-
onReplaced(listener: () => void): () => void;
|
|
19
|
-
connect(): Promise<void>;
|
|
20
|
-
isConnected(): Promise<boolean>;
|
|
21
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;GAEG;AACH,qBAAa,SAAU,SAAQ,GAAG,CAAC,SAAS;aAKxB,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IALpC,OAAO,CAAC,YAAY,CAAqB;gBAGvC,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD;IAKG,aAAa;IAMb,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAYzC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB9B,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAmBxD,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiBtC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAQvE"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerBtc = void 0;
|
|
4
|
-
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class SignerBtc extends core_1.ccc.SignerBtc {
|
|
9
|
-
constructor(client, provider, preferredNetworks = [
|
|
10
|
-
{
|
|
11
|
-
addressPrefix: "ckb",
|
|
12
|
-
signerType: core_1.ccc.SignerType.BTC,
|
|
13
|
-
network: "btc",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
addressPrefix: "ckt",
|
|
17
|
-
signerType: core_1.ccc.SignerType.BTC,
|
|
18
|
-
network: "btcTestnet",
|
|
19
|
-
},
|
|
20
|
-
]) {
|
|
21
|
-
super(client);
|
|
22
|
-
this.provider = provider;
|
|
23
|
-
this.preferredNetworks = preferredNetworks;
|
|
24
|
-
}
|
|
25
|
-
async getBtcAccount() {
|
|
26
|
-
const accounts = await this.provider.getAccount();
|
|
27
|
-
this.accountCache = accounts[0];
|
|
28
|
-
return this.accountCache;
|
|
29
|
-
}
|
|
30
|
-
async getBtcPublicKey() {
|
|
31
|
-
const pubKeys = await this.provider.getPublicKey();
|
|
32
|
-
const account = await this.getBtcAccount();
|
|
33
|
-
const pubKey = pubKeys.find((p) => p.address === account);
|
|
34
|
-
if (!pubKey) {
|
|
35
|
-
throw new Error("pubKey not found");
|
|
36
|
-
}
|
|
37
|
-
return core_1.ccc.hexFrom(pubKey.publicKey);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Ensure the BTC network is the same as CKB network.
|
|
41
|
-
*/
|
|
42
|
-
async ensureNetwork() {
|
|
43
|
-
const network = await this._getNetworkToChange();
|
|
44
|
-
if (!network) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const chain = {
|
|
48
|
-
btc: "btc",
|
|
49
|
-
btcTestnet: "btc_testnet",
|
|
50
|
-
btcTestnet4: "btc_testnet_4",
|
|
51
|
-
btcSignet: "btc_signet",
|
|
52
|
-
}[network];
|
|
53
|
-
if (chain) {
|
|
54
|
-
await this.provider.switchNetwork(chain);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`UTXO Global wallet doesn't support the requested chain ${network}`);
|
|
58
|
-
}
|
|
59
|
-
async _getNetworkToChange() {
|
|
60
|
-
const currentNetwork = {
|
|
61
|
-
btc: "btc",
|
|
62
|
-
btc_testnet: "btcTestnet",
|
|
63
|
-
btc_testnet_4: "btcTestnet4",
|
|
64
|
-
btc_signet: "btcSignet",
|
|
65
|
-
}[await this.provider.getNetwork()];
|
|
66
|
-
const { network } = this.matchNetworkPreference(this.preferredNetworks, currentNetwork) ?? { network: currentNetwork };
|
|
67
|
-
if (network === currentNetwork) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
return network;
|
|
71
|
-
}
|
|
72
|
-
onReplaced(listener) {
|
|
73
|
-
const stop = [];
|
|
74
|
-
const replacer = async () => {
|
|
75
|
-
listener();
|
|
76
|
-
stop[0]?.();
|
|
77
|
-
};
|
|
78
|
-
stop.push(() => {
|
|
79
|
-
this.provider.removeListener("accountsChanged", replacer);
|
|
80
|
-
this.provider.removeListener("networkChanged", replacer);
|
|
81
|
-
});
|
|
82
|
-
this.provider.on("accountsChanged", replacer);
|
|
83
|
-
this.provider.on("networkChanged", replacer);
|
|
84
|
-
return stop[0];
|
|
85
|
-
}
|
|
86
|
-
async connect() {
|
|
87
|
-
await this.provider.connect();
|
|
88
|
-
await this.ensureNetwork();
|
|
89
|
-
}
|
|
90
|
-
async isConnected() {
|
|
91
|
-
if ((await this._getNetworkToChange()) !== undefined) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
return await this.provider.isConnected();
|
|
95
|
-
}
|
|
96
|
-
async signMessageRaw(message) {
|
|
97
|
-
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
98
|
-
return this.provider.signMessage(challenge, this.accountCache ?? (await this.getBtcAccount()));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.SignerBtc = SignerBtc;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { Provider } from "../advancedBarrel.js";
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export declare class SignerCkb extends ccc.Signer {
|
|
7
|
-
readonly provider: Provider;
|
|
8
|
-
private accountCache;
|
|
9
|
-
get type(): ccc.SignerType;
|
|
10
|
-
/**
|
|
11
|
-
* Gets the sign type.
|
|
12
|
-
* @returns The sign type.
|
|
13
|
-
*/
|
|
14
|
-
get signType(): ccc.SignerSignType;
|
|
15
|
-
constructor(client: ccc.Client, provider: Provider);
|
|
16
|
-
getInternalAddress(): Promise<string>;
|
|
17
|
-
getIdentity(): Promise<string>;
|
|
18
|
-
getAddressObj(): Promise<ccc.Address>;
|
|
19
|
-
getAddressObjs(): Promise<ccc.Address[]>;
|
|
20
|
-
getAccount(): Promise<string>;
|
|
21
|
-
getPublicKey(): Promise<ccc.Hex>;
|
|
22
|
-
get ckbNetwork(): string;
|
|
23
|
-
connect(): Promise<void>;
|
|
24
|
-
onReplaced(listener: () => void): () => void;
|
|
25
|
-
isConnected(): Promise<boolean>;
|
|
26
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
27
|
-
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
28
|
-
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;GAEG;AACH,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;aAgBrB,QAAQ,EAAE,QAAQ;IAfpC,OAAO,CAAC,YAAY,CAAqB;IACzC,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,CAEzB;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,GAAG,CAAC,cAAc,CAEjC;gBAGC,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAKpC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAKrC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAIxC,UAAU;IAMV,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAYtC,IAAI,UAAU,IAAI,MAAM,CAEvB;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiBtC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAUhE,mBAAmB,CACvB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAKrB,kBAAkB,CACtB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;CAW5B"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerCkb = void 0;
|
|
4
|
-
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class SignerCkb extends core_1.ccc.Signer {
|
|
9
|
-
get type() {
|
|
10
|
-
return core_1.ccc.SignerType.CKB;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Gets the sign type.
|
|
14
|
-
* @returns The sign type.
|
|
15
|
-
*/
|
|
16
|
-
get signType() {
|
|
17
|
-
return core_1.ccc.SignerSignType.CkbSecp256k1;
|
|
18
|
-
}
|
|
19
|
-
constructor(client, provider) {
|
|
20
|
-
super(client);
|
|
21
|
-
this.provider = provider;
|
|
22
|
-
}
|
|
23
|
-
getInternalAddress() {
|
|
24
|
-
return this.getAccount();
|
|
25
|
-
}
|
|
26
|
-
async getIdentity() {
|
|
27
|
-
return this.getPublicKey();
|
|
28
|
-
}
|
|
29
|
-
async getAddressObj() {
|
|
30
|
-
const address = await this.getInternalAddress();
|
|
31
|
-
return core_1.ccc.Address.fromString(address, this.client);
|
|
32
|
-
}
|
|
33
|
-
async getAddressObjs() {
|
|
34
|
-
return [await this.getAddressObj()];
|
|
35
|
-
}
|
|
36
|
-
async getAccount() {
|
|
37
|
-
const accounts = await this.provider.getAccount();
|
|
38
|
-
this.accountCache = accounts[0];
|
|
39
|
-
return this.accountCache;
|
|
40
|
-
}
|
|
41
|
-
async getPublicKey() {
|
|
42
|
-
const pubKeys = await this.provider.getPublicKey();
|
|
43
|
-
const account = await this.getAccount();
|
|
44
|
-
const pubKey = pubKeys.find((p) => p.address === account);
|
|
45
|
-
if (!pubKey) {
|
|
46
|
-
throw new Error("pubKey not found");
|
|
47
|
-
}
|
|
48
|
-
return core_1.ccc.hexFrom(pubKey.publicKey);
|
|
49
|
-
}
|
|
50
|
-
get ckbNetwork() {
|
|
51
|
-
return this.client.addressPrefix === "ckb" ? "nervos" : "nervos_testnet";
|
|
52
|
-
}
|
|
53
|
-
async connect() {
|
|
54
|
-
await this.provider.connect();
|
|
55
|
-
if (this.ckbNetwork === (await this.provider.getNetwork())) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
await this.provider.switchNetwork(this.ckbNetwork);
|
|
59
|
-
}
|
|
60
|
-
onReplaced(listener) {
|
|
61
|
-
const stop = [];
|
|
62
|
-
const replacer = async () => {
|
|
63
|
-
listener();
|
|
64
|
-
stop[0]?.();
|
|
65
|
-
};
|
|
66
|
-
stop.push(() => {
|
|
67
|
-
this.provider.removeListener("accountsChanged", replacer);
|
|
68
|
-
this.provider.removeListener("networkChanged", replacer);
|
|
69
|
-
});
|
|
70
|
-
this.provider.on("accountsChanged", replacer);
|
|
71
|
-
this.provider.on("networkChanged", replacer);
|
|
72
|
-
return stop[0];
|
|
73
|
-
}
|
|
74
|
-
async isConnected() {
|
|
75
|
-
if ((await this.provider.getNetwork()) !== this.ckbNetwork) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return await this.provider.isConnected();
|
|
79
|
-
}
|
|
80
|
-
async signMessageRaw(message) {
|
|
81
|
-
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
82
|
-
return this.provider.signMessage(challenge, this.accountCache ?? (await this.getAccount()));
|
|
83
|
-
}
|
|
84
|
-
async signOnlyTransaction(txLike) {
|
|
85
|
-
const txSigned = await this.provider.signTransaction(txLike);
|
|
86
|
-
return core_1.ccc.Transaction.from(txSigned);
|
|
87
|
-
}
|
|
88
|
-
async prepareTransaction(txLike) {
|
|
89
|
-
const tx = core_1.ccc.Transaction.from(txLike);
|
|
90
|
-
const { script } = await this.getAddressObj();
|
|
91
|
-
await tx.addCellDepsOfKnownScripts(this.client, core_1.ccc.KnownScript.Secp256k1Blake160);
|
|
92
|
-
await tx.prepareSighashAllWitness(script, 65, this.client);
|
|
93
|
-
return tx;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.SignerCkb = SignerCkb;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { Provider } from "../advancedBarrel.js";
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export declare class SignerDoge extends ccc.SignerDoge {
|
|
7
|
-
readonly provider: Provider;
|
|
8
|
-
private readonly preferredNetworks;
|
|
9
|
-
private accountCache;
|
|
10
|
-
constructor(client: ccc.Client, provider: Provider, preferredNetworks?: ccc.NetworkPreference[]);
|
|
11
|
-
getDogeAddress(): Promise<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Ensure the BTC network is the same as CKB network.
|
|
14
|
-
*/
|
|
15
|
-
ensureNetwork(): Promise<void>;
|
|
16
|
-
_getNetworkToChange(): Promise<string | undefined>;
|
|
17
|
-
onReplaced(listener: () => void): () => void;
|
|
18
|
-
connect(): Promise<void>;
|
|
19
|
-
isConnected(): Promise<boolean>;
|
|
20
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/doge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;GAEG;AACH,qBAAa,UAAW,SAAQ,GAAG,CAAC,UAAU;aAK1B,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IALpC,OAAO,CAAC,YAAY,CAAqB;gBAGvC,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ,EACjB,iBAAiB,GAAE,GAAG,CAAC,iBAAiB,EAWxD;IAKG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAMvC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB9B,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAiBxD,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiBtC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAQvE"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerDoge = void 0;
|
|
4
|
-
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class SignerDoge extends core_1.ccc.SignerDoge {
|
|
9
|
-
constructor(client, provider, preferredNetworks = [
|
|
10
|
-
{
|
|
11
|
-
addressPrefix: "ckb",
|
|
12
|
-
signerType: core_1.ccc.SignerType.Doge,
|
|
13
|
-
network: "doge",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
addressPrefix: "ckt",
|
|
17
|
-
signerType: core_1.ccc.SignerType.Doge,
|
|
18
|
-
network: "dogeTestnet",
|
|
19
|
-
},
|
|
20
|
-
]) {
|
|
21
|
-
super(client);
|
|
22
|
-
this.provider = provider;
|
|
23
|
-
this.preferredNetworks = preferredNetworks;
|
|
24
|
-
}
|
|
25
|
-
async getDogeAddress() {
|
|
26
|
-
const accounts = await this.provider.getAccount();
|
|
27
|
-
this.accountCache = accounts[0];
|
|
28
|
-
return this.accountCache;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Ensure the BTC network is the same as CKB network.
|
|
32
|
-
*/
|
|
33
|
-
async ensureNetwork() {
|
|
34
|
-
const network = await this._getNetworkToChange();
|
|
35
|
-
if (!network) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const chain = {
|
|
39
|
-
doge: "dogecoin",
|
|
40
|
-
dogeTestnet: "dogecoin_testnet",
|
|
41
|
-
}[network];
|
|
42
|
-
if (chain) {
|
|
43
|
-
await this.provider.switchNetwork(chain);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
throw new Error(`UTXO Global Doge wallet doesn't support the requested chain ${network}`);
|
|
47
|
-
}
|
|
48
|
-
async _getNetworkToChange() {
|
|
49
|
-
const currentNetwork = {
|
|
50
|
-
dogecoin: "doge",
|
|
51
|
-
dogecoin_testnet: "dogeTestnet",
|
|
52
|
-
}[await this.provider.getNetwork()];
|
|
53
|
-
const { network } = this.matchNetworkPreference(this.preferredNetworks, currentNetwork) ?? { network: currentNetwork };
|
|
54
|
-
if (network === currentNetwork) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
return network;
|
|
58
|
-
}
|
|
59
|
-
onReplaced(listener) {
|
|
60
|
-
const stop = [];
|
|
61
|
-
const replacer = async () => {
|
|
62
|
-
listener();
|
|
63
|
-
stop[0]?.();
|
|
64
|
-
};
|
|
65
|
-
stop.push(() => {
|
|
66
|
-
this.provider.removeListener("accountsChanged", replacer);
|
|
67
|
-
this.provider.removeListener("networkChanged", replacer);
|
|
68
|
-
});
|
|
69
|
-
this.provider.on("accountsChanged", replacer);
|
|
70
|
-
this.provider.on("networkChanged", replacer);
|
|
71
|
-
return stop[0];
|
|
72
|
-
}
|
|
73
|
-
async connect() {
|
|
74
|
-
await this.provider.connect();
|
|
75
|
-
await this.ensureNetwork();
|
|
76
|
-
}
|
|
77
|
-
async isConnected() {
|
|
78
|
-
if ((await this._getNetworkToChange()) !== undefined) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
return await this.provider.isConnected();
|
|
82
|
-
}
|
|
83
|
-
async signMessageRaw(message) {
|
|
84
|
-
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
85
|
-
return this.provider.signMessage(challenge, this.accountCache ?? (await this.getDogeAddress()));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.SignerDoge = SignerDoge;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC"}
|
|
@@ -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;AAMpC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,GAC1C,GAAG,CAAC,UAAU,EAAE,CAmClB"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUtxoGlobalSigners = getUtxoGlobalSigners;
|
|
4
|
-
const index_js_1 = require("./btc/index.js");
|
|
5
|
-
const index_js_2 = require("./ckb/index.js");
|
|
6
|
-
const index_js_3 = require("./doge/index.js");
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
function getUtxoGlobalSigners(client, preferredNetworks) {
|
|
11
|
-
const windowRef = window;
|
|
12
|
-
if (typeof windowRef.utxoGlobal === "undefined") {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
return [
|
|
16
|
-
{
|
|
17
|
-
name: "CKB",
|
|
18
|
-
signer: new index_js_2.SignerCkb(client, windowRef.utxoGlobal.ckbSigner),
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: "BTC",
|
|
22
|
-
signer: new index_js_1.SignerBtc(client, windowRef.utxoGlobal.bitcoinSigner, preferredNetworks),
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: "DOGE",
|
|
26
|
-
signer: new index_js_3.SignerDoge(client, windowRef.utxoGlobal.dogeSigner, preferredNetworks),
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
}
|