@ckb-ccc/eip6963 1.0.33 → 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 +13 -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckb-ccc/eip6963",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CCC - CKBer's Codebase. Common Chains Connector's support for EIP6963",
|
|
5
5
|
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,40 +11,43 @@
|
|
|
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"
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist.commonjs/index.js"
|
|
21
20
|
},
|
|
22
21
|
"./advanced": {
|
|
23
|
-
"import": "./dist/advanced.
|
|
24
|
-
"require": "./dist.commonjs/advanced.js"
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
"import": "./dist/advanced.mjs",
|
|
23
|
+
"require": "./dist.commonjs/advanced.js"
|
|
24
|
+
},
|
|
25
|
+
"./barrel": {
|
|
26
|
+
"import": "./dist/barrel.mjs",
|
|
27
|
+
"require": "./dist.commonjs/barrel.js"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"@eslint/js": "^
|
|
30
|
-
"
|
|
31
|
-
"eslint": "^9.34.0",
|
|
32
|
+
"@eslint/js": "^10.0.1",
|
|
33
|
+
"eslint": "^10.5.0",
|
|
32
34
|
"eslint-config-prettier": "^10.1.8",
|
|
33
|
-
"eslint-plugin-prettier": "^5.5.
|
|
34
|
-
"prettier": "^3.
|
|
35
|
-
"prettier-plugin-organize-imports": "^4.
|
|
36
|
-
"
|
|
37
|
-
"typescript": "^
|
|
38
|
-
"typescript-eslint": "^8.41.0"
|
|
35
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
36
|
+
"prettier": "^3.8.4",
|
|
37
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
38
|
+
"typescript": "^6.0.3",
|
|
39
|
+
"typescript-eslint": "^8.61.1"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
+
"tsdown": "^0.22.3",
|
|
46
|
+
"@ckb-ccc/core": "1.14.0"
|
|
45
47
|
},
|
|
48
|
+
"types": "./dist.commonjs/index.d.ts",
|
|
46
49
|
"scripts": {
|
|
47
|
-
"build": "
|
|
50
|
+
"build": "tsdown",
|
|
48
51
|
"lint": "eslint ./src",
|
|
49
52
|
"format": "prettier --write . && eslint --fix ./src"
|
|
50
53
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
const bundleDeps: string[] = [];
|
|
18
|
+
|
|
19
|
+
export default defineConfig(
|
|
20
|
+
(
|
|
21
|
+
[
|
|
22
|
+
{
|
|
23
|
+
entry,
|
|
24
|
+
deps: {
|
|
25
|
+
onlyBundle: [] as string[],
|
|
26
|
+
},
|
|
27
|
+
format: "esm",
|
|
28
|
+
copy: "./misc/basedirs/dist/*",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
entry,
|
|
32
|
+
deps: {
|
|
33
|
+
alwaysBundle: bundleDeps,
|
|
34
|
+
onlyBundle: bundleDeps,
|
|
35
|
+
},
|
|
36
|
+
format: "cjs",
|
|
37
|
+
outDir: "dist.commonjs",
|
|
38
|
+
copy: "./misc/basedirs/dist.commonjs/*",
|
|
39
|
+
},
|
|
40
|
+
] as const
|
|
41
|
+
).map((c) => ({ ...c, ...common })),
|
|
42
|
+
);
|
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,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC"}
|
package/dist/advanced.js
DELETED
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
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Hex } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing a provider for interacting with Ethereum-compatible wallets.
|
|
4
|
-
*/
|
|
5
|
-
export interface Provider {
|
|
6
|
-
/**
|
|
7
|
-
* Sends a request to the provider.
|
|
8
|
-
*/
|
|
9
|
-
request: RequestMethod;
|
|
10
|
-
/**
|
|
11
|
-
* Adds an event listener to the provider.
|
|
12
|
-
*/
|
|
13
|
-
on: OnMethod;
|
|
14
|
-
/**
|
|
15
|
-
* Removes an event listener from the provider.
|
|
16
|
-
* @param eventName - The name of the event to remove the listener from.
|
|
17
|
-
* @param listener - The listener function to remove.
|
|
18
|
-
* @returns The provider instance.
|
|
19
|
-
*/
|
|
20
|
-
removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Interface representing a method to send requests to the provider.
|
|
24
|
-
*/
|
|
25
|
-
export interface RequestMethod {
|
|
26
|
-
/**
|
|
27
|
-
* Signs a message with the personal account.
|
|
28
|
-
* @param request - The request object.
|
|
29
|
-
* @returns A promise that resolves to the signed message.
|
|
30
|
-
*/
|
|
31
|
-
(request: {
|
|
32
|
-
method: "personal_sign";
|
|
33
|
-
params: [string, Hex];
|
|
34
|
-
}): Promise<Hex>;
|
|
35
|
-
/**
|
|
36
|
-
* Requests the accounts from the provider.
|
|
37
|
-
* @param request - The request object.
|
|
38
|
-
* @returns A promise that resolves to an array of account addresses.
|
|
39
|
-
*/
|
|
40
|
-
(request: {
|
|
41
|
-
method: "eth_requestAccounts";
|
|
42
|
-
params?: undefined;
|
|
43
|
-
}): Promise<Hex[]>;
|
|
44
|
-
/**
|
|
45
|
-
* Gets the accounts from the provider.
|
|
46
|
-
* @param request - The request object.
|
|
47
|
-
* @returns A promise that resolves to an array of account addresses.
|
|
48
|
-
*/
|
|
49
|
-
(request: {
|
|
50
|
-
method: "eth_accounts";
|
|
51
|
-
params?: undefined;
|
|
52
|
-
}): Promise<Hex[]>;
|
|
53
|
-
/**
|
|
54
|
-
* Sends a generic request to the provider.
|
|
55
|
-
* @param request - The request object.
|
|
56
|
-
* @returns A promise that resolves to the response from the provider.
|
|
57
|
-
*/
|
|
58
|
-
(request: {
|
|
59
|
-
method: string;
|
|
60
|
-
params?: Array<unknown> | Record<string, unknown>;
|
|
61
|
-
}): Promise<unknown>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Interface representing a method to add event listeners to the provider.
|
|
65
|
-
*/
|
|
66
|
-
export interface OnMethod {
|
|
67
|
-
/**
|
|
68
|
-
* Adds an event listener to the provider.
|
|
69
|
-
* @param eventName - The name of the event.
|
|
70
|
-
* @param listener - The listener function.
|
|
71
|
-
* @returns The provider instance.
|
|
72
|
-
*/
|
|
73
|
-
(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=eip1193.advanced.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip1193.advanced.d.ts","sourceRoot":"","sources":["../src/eip1193.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;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,aAAa;IAC5B;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE5E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,qBAAqB,CAAC;QAC9B,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnB;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,MAAM,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE1E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnD,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;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/eip1193.advanced.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Provider as EIP1193Provider } from "./eip1193.advanced.js";
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing an event announcing a provider.
|
|
4
|
-
*/
|
|
5
|
-
export interface AnnounceProviderEvent {
|
|
6
|
-
/**
|
|
7
|
-
* The detail of the provider.
|
|
8
|
-
*/
|
|
9
|
-
detail: ProviderDetail;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Interface representing the details of a provider.
|
|
13
|
-
*/
|
|
14
|
-
export interface ProviderDetail {
|
|
15
|
-
/**
|
|
16
|
-
* The information about the provider.
|
|
17
|
-
*/
|
|
18
|
-
info: ProviderInfo;
|
|
19
|
-
/**
|
|
20
|
-
* The provider instance compliant with EIP-1193.
|
|
21
|
-
*/
|
|
22
|
-
provider: EIP1193Provider;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Interface representing information about a provider.
|
|
26
|
-
*/
|
|
27
|
-
export interface ProviderInfo {
|
|
28
|
-
/**
|
|
29
|
-
* The reverse DNS name of the provider.
|
|
30
|
-
*/
|
|
31
|
-
rdns: string;
|
|
32
|
-
/**
|
|
33
|
-
* The UUID of the provider.
|
|
34
|
-
*/
|
|
35
|
-
uuid: string;
|
|
36
|
-
/**
|
|
37
|
-
* The name of the provider.
|
|
38
|
-
*/
|
|
39
|
-
name: string;
|
|
40
|
-
/**
|
|
41
|
-
* The icon URL of the provider.
|
|
42
|
-
*/
|
|
43
|
-
icon: string;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=eip6963.advanced.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip6963.advanced.d.ts","sourceRoot":"","sources":["../src/eip6963.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/eip6963.advanced.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
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,OAAO,MAAM,aAAa,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as Eip6963 from "./barrel.js";
|
package/dist/signer.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { Provider } from "./eip1193.advanced.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare class Signer extends ccc.SignerEvm {
|
|
8
|
-
readonly provider: Provider;
|
|
9
|
-
private accountCache?;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of Signer.
|
|
12
|
-
* @param client - The client instance.
|
|
13
|
-
* @param provider - The provider.
|
|
14
|
-
*/
|
|
15
|
-
constructor(client: ccc.Client, provider: Provider);
|
|
16
|
-
/**
|
|
17
|
-
* Gets the EVM account address.
|
|
18
|
-
* @returns A promise that resolves to the EVM account address.
|
|
19
|
-
*/
|
|
20
|
-
getEvmAccount(): Promise<ccc.Hex>;
|
|
21
|
-
/**
|
|
22
|
-
* Connects to the provider by requesting accounts.
|
|
23
|
-
* @returns A promise that resolves when the connection is established.
|
|
24
|
-
*/
|
|
25
|
-
connect(): Promise<void>;
|
|
26
|
-
onReplaced(listener: () => void): () => void;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the provider is connected.
|
|
29
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
30
|
-
*/
|
|
31
|
-
isConnected(): Promise<boolean>;
|
|
32
|
-
/**
|
|
33
|
-
* Signs a raw message with the personal account.
|
|
34
|
-
* @param message - The message to sign.
|
|
35
|
-
* @returns A promise that resolves to the signed message.
|
|
36
|
-
*/
|
|
37
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
38
|
-
}
|
|
39
|
-
//# 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,uBAAuB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAUrB,QAAQ,EAAE,QAAQ;IATpC,OAAO,CAAC,YAAY,CAAC,CAAsB;IAE3C;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAKpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAOvC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiB5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAMrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAWxE"}
|
package/dist/signer.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export class Signer extends ccc.SignerEvm {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of Signer.
|
|
9
|
-
* @param client - The client instance.
|
|
10
|
-
* @param provider - The provider.
|
|
11
|
-
*/
|
|
12
|
-
constructor(client, provider) {
|
|
13
|
-
super(client);
|
|
14
|
-
this.provider = provider;
|
|
15
|
-
this.accountCache = undefined;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Gets the EVM account address.
|
|
19
|
-
* @returns A promise that resolves to the EVM account address.
|
|
20
|
-
*/
|
|
21
|
-
async getEvmAccount() {
|
|
22
|
-
this.accountCache = (await this.provider.request({ method: "eth_accounts" }))[0];
|
|
23
|
-
return this.accountCache;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Connects to the provider by requesting accounts.
|
|
27
|
-
* @returns A promise that resolves when the connection is established.
|
|
28
|
-
*/
|
|
29
|
-
async connect() {
|
|
30
|
-
await this.provider.request({ method: "eth_requestAccounts" });
|
|
31
|
-
}
|
|
32
|
-
onReplaced(listener) {
|
|
33
|
-
const stop = [];
|
|
34
|
-
const replacer = async () => {
|
|
35
|
-
listener();
|
|
36
|
-
stop[0]?.();
|
|
37
|
-
};
|
|
38
|
-
stop.push(() => {
|
|
39
|
-
this.provider.removeListener("accountsChanged", replacer);
|
|
40
|
-
this.provider.removeListener("disconnect", replacer);
|
|
41
|
-
});
|
|
42
|
-
this.provider.on("accountsChanged", replacer);
|
|
43
|
-
this.provider.on("disconnect", replacer);
|
|
44
|
-
return stop[0];
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Checks if the provider is connected.
|
|
48
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
49
|
-
*/
|
|
50
|
-
async isConnected() {
|
|
51
|
-
return ((await this.provider.request({ method: "eth_accounts" })).length !== 0);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Signs a raw message with the personal account.
|
|
55
|
-
* @param message - The message to sign.
|
|
56
|
-
* @returns A promise that resolves to the signed message.
|
|
57
|
-
*/
|
|
58
|
-
async signMessageRaw(message) {
|
|
59
|
-
const challenge = typeof message === "string" ? ccc.bytesFrom(message, "utf8") : message;
|
|
60
|
-
const account = this.accountCache ?? (await this.getEvmAccount());
|
|
61
|
-
return this.provider.request({
|
|
62
|
-
method: "personal_sign",
|
|
63
|
-
params: [ccc.hexFrom(challenge), account],
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
package/dist/signersFactory.d.ts
DELETED
|
@@ -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"}
|
package/dist/signersFactory.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Signer } from "./signer.js";
|
|
2
|
-
/**
|
|
3
|
-
* Class representing a factory for creating and managing Signer instances.
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
6
|
-
export class SignerFactory {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of SignerFactory.
|
|
9
|
-
* @param client - The client instance.
|
|
10
|
-
*/
|
|
11
|
-
constructor(client) {
|
|
12
|
-
this.client = client;
|
|
13
|
-
this.existedUuids = [];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Subscribes to new signers and triggers a callback when a new signer is available.
|
|
17
|
-
* @param callback - The callback to trigger with the new signer.
|
|
18
|
-
* @returns A function to unsubscribe from the signer events.
|
|
19
|
-
*/
|
|
20
|
-
subscribeSigners(callback) {
|
|
21
|
-
const onNewProvider = (event) => {
|
|
22
|
-
const { detail } = event;
|
|
23
|
-
const { uuid } = detail.info;
|
|
24
|
-
if (this.existedUuids.includes(uuid)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
this.existedUuids.push(uuid);
|
|
28
|
-
const signer = new Signer(this.client, detail.provider);
|
|
29
|
-
callback(signer, detail);
|
|
30
|
-
};
|
|
31
|
-
window.addEventListener("eip6963:announceProvider", onNewProvider);
|
|
32
|
-
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
33
|
-
const windowRef = window;
|
|
34
|
-
if (typeof windowRef.ethereum !== "undefined") {
|
|
35
|
-
callback(new Signer(this.client, windowRef.ethereum));
|
|
36
|
-
}
|
|
37
|
-
return () => window.removeEventListener("eip6963:announceProvider", onNewProvider);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Hex } from "@ckb-ccc/core";
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing a provider for interacting with Ethereum-compatible wallets.
|
|
4
|
-
*/
|
|
5
|
-
export interface Provider {
|
|
6
|
-
/**
|
|
7
|
-
* Sends a request to the provider.
|
|
8
|
-
*/
|
|
9
|
-
request: RequestMethod;
|
|
10
|
-
/**
|
|
11
|
-
* Adds an event listener to the provider.
|
|
12
|
-
*/
|
|
13
|
-
on: OnMethod;
|
|
14
|
-
/**
|
|
15
|
-
* Removes an event listener from the provider.
|
|
16
|
-
* @param eventName - The name of the event to remove the listener from.
|
|
17
|
-
* @param listener - The listener function to remove.
|
|
18
|
-
* @returns The provider instance.
|
|
19
|
-
*/
|
|
20
|
-
removeListener(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Interface representing a method to send requests to the provider.
|
|
24
|
-
*/
|
|
25
|
-
export interface RequestMethod {
|
|
26
|
-
/**
|
|
27
|
-
* Signs a message with the personal account.
|
|
28
|
-
* @param request - The request object.
|
|
29
|
-
* @returns A promise that resolves to the signed message.
|
|
30
|
-
*/
|
|
31
|
-
(request: {
|
|
32
|
-
method: "personal_sign";
|
|
33
|
-
params: [string, Hex];
|
|
34
|
-
}): Promise<Hex>;
|
|
35
|
-
/**
|
|
36
|
-
* Requests the accounts from the provider.
|
|
37
|
-
* @param request - The request object.
|
|
38
|
-
* @returns A promise that resolves to an array of account addresses.
|
|
39
|
-
*/
|
|
40
|
-
(request: {
|
|
41
|
-
method: "eth_requestAccounts";
|
|
42
|
-
params?: undefined;
|
|
43
|
-
}): Promise<Hex[]>;
|
|
44
|
-
/**
|
|
45
|
-
* Gets the accounts from the provider.
|
|
46
|
-
* @param request - The request object.
|
|
47
|
-
* @returns A promise that resolves to an array of account addresses.
|
|
48
|
-
*/
|
|
49
|
-
(request: {
|
|
50
|
-
method: "eth_accounts";
|
|
51
|
-
params?: undefined;
|
|
52
|
-
}): Promise<Hex[]>;
|
|
53
|
-
/**
|
|
54
|
-
* Sends a generic request to the provider.
|
|
55
|
-
* @param request - The request object.
|
|
56
|
-
* @returns A promise that resolves to the response from the provider.
|
|
57
|
-
*/
|
|
58
|
-
(request: {
|
|
59
|
-
method: string;
|
|
60
|
-
params?: Array<unknown> | Record<string, unknown>;
|
|
61
|
-
}): Promise<unknown>;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Interface representing a method to add event listeners to the provider.
|
|
65
|
-
*/
|
|
66
|
-
export interface OnMethod {
|
|
67
|
-
/**
|
|
68
|
-
* Adds an event listener to the provider.
|
|
69
|
-
* @param eventName - The name of the event.
|
|
70
|
-
* @param listener - The listener function.
|
|
71
|
-
* @returns The provider instance.
|
|
72
|
-
*/
|
|
73
|
-
(eventName: string, listener: (...args: unknown[]) => unknown): Provider;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=eip1193.advanced.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip1193.advanced.d.ts","sourceRoot":"","sources":["../src/eip1193.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;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,aAAa;IAC5B;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE5E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,qBAAqB,CAAC;QAC9B,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnB;;;;OAIG;IACH,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,cAAc,CAAC;QAAC,MAAM,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE1E;;;;OAIG;IACH,CAAC,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnD,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtB;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"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Provider as EIP1193Provider } from "./eip1193.advanced.js";
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing an event announcing a provider.
|
|
4
|
-
*/
|
|
5
|
-
export interface AnnounceProviderEvent {
|
|
6
|
-
/**
|
|
7
|
-
* The detail of the provider.
|
|
8
|
-
*/
|
|
9
|
-
detail: ProviderDetail;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Interface representing the details of a provider.
|
|
13
|
-
*/
|
|
14
|
-
export interface ProviderDetail {
|
|
15
|
-
/**
|
|
16
|
-
* The information about the provider.
|
|
17
|
-
*/
|
|
18
|
-
info: ProviderInfo;
|
|
19
|
-
/**
|
|
20
|
-
* The provider instance compliant with EIP-1193.
|
|
21
|
-
*/
|
|
22
|
-
provider: EIP1193Provider;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Interface representing information about a provider.
|
|
26
|
-
*/
|
|
27
|
-
export interface ProviderInfo {
|
|
28
|
-
/**
|
|
29
|
-
* The reverse DNS name of the provider.
|
|
30
|
-
*/
|
|
31
|
-
rdns: string;
|
|
32
|
-
/**
|
|
33
|
-
* The UUID of the provider.
|
|
34
|
-
*/
|
|
35
|
-
uuid: string;
|
|
36
|
-
/**
|
|
37
|
-
* The name of the provider.
|
|
38
|
-
*/
|
|
39
|
-
name: string;
|
|
40
|
-
/**
|
|
41
|
-
* The icon URL of the provider.
|
|
42
|
-
*/
|
|
43
|
-
icon: string;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=eip6963.advanced.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip6963.advanced.d.ts","sourceRoot":"","sources":["../src/eip6963.advanced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,aAAa,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ccc } from "@ckb-ccc/core";
|
|
2
|
-
import { Provider } from "./eip1193.advanced.js";
|
|
3
|
-
/**
|
|
4
|
-
* Class representing an EVM signer that extends SignerEvm
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare class Signer extends ccc.SignerEvm {
|
|
8
|
-
readonly provider: Provider;
|
|
9
|
-
private accountCache?;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of Signer.
|
|
12
|
-
* @param client - The client instance.
|
|
13
|
-
* @param provider - The provider.
|
|
14
|
-
*/
|
|
15
|
-
constructor(client: ccc.Client, provider: Provider);
|
|
16
|
-
/**
|
|
17
|
-
* Gets the EVM account address.
|
|
18
|
-
* @returns A promise that resolves to the EVM account address.
|
|
19
|
-
*/
|
|
20
|
-
getEvmAccount(): Promise<ccc.Hex>;
|
|
21
|
-
/**
|
|
22
|
-
* Connects to the provider by requesting accounts.
|
|
23
|
-
* @returns A promise that resolves when the connection is established.
|
|
24
|
-
*/
|
|
25
|
-
connect(): Promise<void>;
|
|
26
|
-
onReplaced(listener: () => void): () => void;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the provider is connected.
|
|
29
|
-
* @returns A promise that resolves to true if connected, false otherwise.
|
|
30
|
-
*/
|
|
31
|
-
isConnected(): Promise<boolean>;
|
|
32
|
-
/**
|
|
33
|
-
* Signs a raw message with the personal account.
|
|
34
|
-
* @param message - The message to sign.
|
|
35
|
-
* @returns A promise that resolves to the signed message.
|
|
36
|
-
*/
|
|
37
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -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,uBAAuB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,MAAO,SAAQ,GAAG,CAAC,SAAS;aAUrB,QAAQ,EAAE,QAAQ;IATpC,OAAO,CAAC,YAAY,CAAC,CAAsB;IAE3C;;;;OAIG;gBAED,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,QAAQ,EAAE,QAAQ;IAKpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAOvC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAiB5C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAMrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;CAWxE"}
|