@ckb-ccc/eip6963 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 +23 -0
- package/dist/advanced.d.mts +2 -0
- package/dist/advanced.mjs +2 -0
- package/dist/advanced.mjs.map +1 -0
- package/dist/barrel.d.mts +67 -0
- package/dist/barrel.d.mts.map +1 -0
- package/dist/barrel.mjs +2 -0
- package/dist/barrel.mjs.map +1 -0
- package/dist/eip6963.advanced-C3p1YxLI.d.mts +128 -0
- package/dist/eip6963.advanced-C3p1YxLI.d.mts.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 -3
- package/dist.commonjs/advanced.js +2 -38
- package/dist.commonjs/advanced.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +66 -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/eip6963.advanced-BMWmWvgB.d.ts +128 -0
- package/dist.commonjs/eip6963.advanced-BMWmWvgB.d.ts.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 +24 -21
- package/tsdown.config.mts +42 -0
- package/dist/advanced.d.ts +0 -3
- package/dist/advanced.d.ts.map +0 -1
- package/dist/advanced.js +0 -2
- package/dist/barrel.d.ts +0 -3
- package/dist/barrel.d.ts.map +0 -1
- package/dist/barrel.js +0 -2
- package/dist/eip1193.advanced.d.ts +0 -75
- package/dist/eip1193.advanced.d.ts.map +0 -1
- package/dist/eip1193.advanced.js +0 -1
- package/dist/eip6963.advanced.d.ts +0 -45
- package/dist/eip6963.advanced.d.ts.map +0 -1
- package/dist/eip6963.advanced.js +0 -1
- 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 -39
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -66
- package/dist/signersFactory.d.ts +0 -23
- package/dist/signersFactory.d.ts.map +0 -1
- package/dist/signersFactory.js +0 -39
- package/dist.commonjs/advanced.d.ts.map +0 -1
- package/dist.commonjs/eip1193.advanced.d.ts +0 -75
- package/dist.commonjs/eip1193.advanced.d.ts.map +0 -1
- package/dist.commonjs/eip1193.advanced.js +0 -2
- package/dist.commonjs/eip6963.advanced.d.ts +0 -45
- package/dist.commonjs/eip6963.advanced.d.ts.map +0 -1
- package/dist.commonjs/eip6963.advanced.js +0 -2
- package/dist.commonjs/index.d.ts.map +0 -1
- package/dist.commonjs/signer.d.ts +0 -39
- package/dist.commonjs/signer.d.ts.map +0 -1
- package/dist.commonjs/signer.js +0 -70
- package/dist.commonjs/signersFactory.d.ts +0 -23
- package/dist.commonjs/signersFactory.d.ts.map +0 -1
- package/dist.commonjs/signersFactory.js +0 -43
package/dist.commonjs/signer.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Signer = void 0;
|
|
4
|
-
const core_1 = require("@ckb-ccc/core");
|
|
5
|
-
/**
|
|
6
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
class Signer extends core_1.ccc.SignerEvm {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of Signer.
|
|
12
|
-
* @param client - The client instance.
|
|
13
|
-
* @param provider - The provider.
|
|
14
|
-
*/
|
|
15
|
-
constructor(client, provider) {
|
|
16
|
-
super(client);
|
|
17
|
-
this.provider = provider;
|
|
18
|
-
this.accountCache = undefined;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Gets the EVM account address.
|
|
22
|
-
* @returns A promise that resolves to the EVM account address.
|
|
23
|
-
*/
|
|
24
|
-
async getEvmAccount() {
|
|
25
|
-
this.accountCache = (await this.provider.request({ method: "eth_accounts" }))[0];
|
|
26
|
-
return this.accountCache;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Connects to the provider by requesting accounts.
|
|
30
|
-
* @returns A promise that resolves when the connection is established.
|
|
31
|
-
*/
|
|
32
|
-
async connect() {
|
|
33
|
-
await this.provider.request({ method: "eth_requestAccounts" });
|
|
34
|
-
}
|
|
35
|
-
onReplaced(listener) {
|
|
36
|
-
const stop = [];
|
|
37
|
-
const replacer = async () => {
|
|
38
|
-
listener();
|
|
39
|
-
stop[0]?.();
|
|
40
|
-
};
|
|
41
|
-
stop.push(() => {
|
|
42
|
-
this.provider.removeListener("accountsChanged", replacer);
|
|
43
|
-
this.provider.removeListener("disconnect", replacer);
|
|
44
|
-
});
|
|
45
|
-
this.provider.on("accountsChanged", replacer);
|
|
46
|
-
this.provider.on("disconnect", replacer);
|
|
47
|
-
return stop[0];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Checks if the provider is connected.
|
|
51
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
52
|
-
*/
|
|
53
|
-
async isConnected() {
|
|
54
|
-
return ((await this.provider.request({ method: "eth_accounts" })).length !== 0);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Signs a raw message with the personal account.
|
|
58
|
-
* @param message - The message to sign.
|
|
59
|
-
* @returns A promise that resolves to the signed message.
|
|
60
|
-
*/
|
|
61
|
-
async signMessageRaw(message) {
|
|
62
|
-
const challenge = typeof message === "string" ? core_1.ccc.bytesFrom(message, "utf8") : message;
|
|
63
|
-
const account = this.accountCache ?? (await this.getEvmAccount());
|
|
64
|
-
return this.provider.request({
|
|
65
|
-
method: "personal_sign",
|
|
66
|
-
params: [core_1.ccc.hexFrom(challenge), account],
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.Signer = Signer;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { ProviderDetail } from "./eip6963.advanced.js";
|
|
3
|
-
import { Signer } from "./signer.js";
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a factory for creating and managing Signer instances.
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export declare class SignerFactory {
|
|
9
|
-
private readonly client;
|
|
10
|
-
private readonly existedUuids;
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of SignerFactory.
|
|
13
|
-
* @param client - The client instance.
|
|
14
|
-
*/
|
|
15
|
-
constructor(client: ccc.Client);
|
|
16
|
-
/**
|
|
17
|
-
* Subscribes to new signers and triggers a callback when a new signer is available.
|
|
18
|
-
* @param callback - The callback to trigger with the new signer.
|
|
19
|
-
* @returns A function to unsubscribe from the signer events.
|
|
20
|
-
*/
|
|
21
|
-
subscribeSigners(callback: (newSigner: Signer, detail?: ProviderDetail) => unknown): () => void;
|
|
22
|
-
}
|
|
23
|
-
//# 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;AAEpC,OAAO,EAEL,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;GAGG;AACH,qBAAa,aAAa;IAOZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IANnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;IAE7C;;;OAGG;gBAC0B,MAAM,EAAE,GAAG,CAAC,MAAM;IAE/C;;;;OAIG;IACH,gBAAgB,CACd,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,KAAK,OAAO,GAChE,MAAM,IAAI;CA0Bd"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerFactory = void 0;
|
|
4
|
-
const signer_js_1 = require("./signer.js");
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a factory for creating and managing Signer instances.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
class SignerFactory {
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of SignerFactory.
|
|
12
|
-
* @param client - The client instance.
|
|
13
|
-
*/
|
|
14
|
-
constructor(client) {
|
|
15
|
-
this.client = client;
|
|
16
|
-
this.existedUuids = [];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Subscribes to new signers and triggers a callback when a new signer is available.
|
|
20
|
-
* @param callback - The callback to trigger with the new signer.
|
|
21
|
-
* @returns A function to unsubscribe from the signer events.
|
|
22
|
-
*/
|
|
23
|
-
subscribeSigners(callback) {
|
|
24
|
-
const onNewProvider = (event) => {
|
|
25
|
-
const { detail } = event;
|
|
26
|
-
const { uuid } = detail.info;
|
|
27
|
-
if (this.existedUuids.includes(uuid)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.existedUuids.push(uuid);
|
|
31
|
-
const signer = new signer_js_1.Signer(this.client, detail.provider);
|
|
32
|
-
callback(signer, detail);
|
|
33
|
-
};
|
|
34
|
-
window.addEventListener("eip6963:announceProvider", onNewProvider);
|
|
35
|
-
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
36
|
-
const windowRef = window;
|
|
37
|
-
if (typeof windowRef.ethereum !== "undefined") {
|
|
38
|
-
callback(new signer_js_1.Signer(this.client, windowRef.ethereum));
|
|
39
|
-
}
|
|
40
|
-
return () => window.removeEventListener("eip6963:announceProvider", onNewProvider);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.SignerFactory = SignerFactory;
|