@ckb-ccc/eip6963 0.0.3-alpha.0 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/signer.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ProviderDetail as EIP6963ProviderDetail } from "./eip6963.advanced";
3
3
  export declare class Signer extends ccc.Signer {
4
4
  readonly detail: EIP6963ProviderDetail;
5
5
  constructor(client: ccc.Client, detail: EIP6963ProviderDetail);
6
- getEVMAccounts(): Promise<`0x${string}`[]>;
6
+ getEVMAccount(): Promise<`0x${string}`>;
7
7
  getInternalAddress(): Promise<string>;
8
8
  getAddressObjs(): Promise<ccc.Address[]>;
9
9
  connect(): Promise<void>;
@@ -1 +1 @@
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,cAAc,IAAI,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,qBAAa,MAAO,SAAQ,GAAG,CAAC,MAAM;aAGlB,MAAM,EAAE,qBAAqB;gBAD7C,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,MAAM,EAAE,qBAAqB;IAKzC,cAAc;IAId,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAaxC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAW9D,mBAAmB,CAAC,EAAE,EAAE,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;CA8BzE"}
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,cAAc,IAAI,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,qBAAa,MAAO,SAAQ,GAAG,CAAC,MAAM;aAGlB,MAAM,EAAE,qBAAqB;gBAD7C,MAAM,EAAE,GAAG,CAAC,MAAM,EACF,MAAM,EAAE,qBAAqB;IAKzC,aAAa;IAIb,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAWxC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAW9D,mBAAmB,CAAC,EAAE,EAAE,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;CA8BzE"}
package/dist/signer.js CHANGED
@@ -4,25 +4,27 @@ export class Signer extends ccc.Signer {
4
4
  super(client);
5
5
  this.detail = detail;
6
6
  }
7
- async getEVMAccounts() {
8
- return this.detail.provider.request({ method: "eth_accounts" });
7
+ async getEVMAccount() {
8
+ return (await this.detail.provider.request({ method: "eth_accounts" }))[0];
9
9
  }
10
10
  async getInternalAddress() {
11
- return (await this.getEVMAccounts())[0];
11
+ return this.getEVMAccount();
12
12
  }
13
13
  async getAddressObjs() {
14
- const accounts = await this.getEVMAccounts();
15
- return Promise.all(accounts.map((account) => ccc.Address.fromKnownScript(ccc.KnownScript.OmniLock, ccc.hexFrom([0x12, ...ccc.bytesFrom(account), 0x00]), this.client)));
14
+ const account = await this.getEVMAccount();
15
+ return [
16
+ await ccc.Address.fromKnownScript(ccc.KnownScript.OmniLock, ccc.hexFrom([0x12, ...ccc.bytesFrom(account), 0x00]), this.client),
17
+ ];
16
18
  }
17
19
  async connect() {
18
20
  await this.detail.provider.request({ method: "eth_requestAccounts" });
19
21
  }
20
22
  async signMessage(message) {
21
- const challenge = typeof message === "string" ? message : ccc.hexFrom(message);
22
- const [address] = await this.getEVMAccounts();
23
+ const challenge = typeof message === "string" ? ccc.bytesFrom(message, "utf8") : message;
24
+ const address = await this.getEVMAccount();
23
25
  return this.detail.provider.request({
24
26
  method: "personal_sign",
25
- params: [challenge, address],
27
+ params: [ccc.hexFrom(challenge), address],
26
28
  });
27
29
  }
28
30
  async signOnlyTransaction(tx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/eip6963",
3
- "version": "0.0.3-alpha.0",
3
+ "version": "0.0.3",
4
4
  "description": "Common Chains Connector's support for EIP6963",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@ckb-ccc/core": "0.0.3-alpha.0"
38
+ "@ckb-ccc/core": "0.0.3"
39
39
  },
40
- "gitHead": "4a995208e5135d11e9f72b9a9fd73174a3056fc7"
40
+ "gitHead": "9df1bbe0007136568914d8a73fe39f898d636a12"
41
41
  }
package/src/signer.ts CHANGED
@@ -9,25 +9,23 @@ export class Signer extends ccc.Signer {
9
9
  super(client);
10
10
  }
11
11
 
12
- async getEVMAccounts() {
13
- return this.detail.provider.request({ method: "eth_accounts" });
12
+ async getEVMAccount() {
13
+ return (await this.detail.provider.request({ method: "eth_accounts" }))[0];
14
14
  }
15
15
 
16
16
  async getInternalAddress(): Promise<string> {
17
- return (await this.getEVMAccounts())[0];
17
+ return this.getEVMAccount();
18
18
  }
19
19
 
20
20
  async getAddressObjs(): Promise<ccc.Address[]> {
21
- const accounts = await this.getEVMAccounts();
22
- return Promise.all(
23
- accounts.map((account) =>
24
- ccc.Address.fromKnownScript(
25
- ccc.KnownScript.OmniLock,
26
- ccc.hexFrom([0x12, ...ccc.bytesFrom(account), 0x00]),
27
- this.client,
28
- ),
21
+ const account = await this.getEVMAccount();
22
+ return [
23
+ await ccc.Address.fromKnownScript(
24
+ ccc.KnownScript.OmniLock,
25
+ ccc.hexFrom([0x12, ...ccc.bytesFrom(account), 0x00]),
26
+ this.client,
29
27
  ),
30
- );
28
+ ];
31
29
  }
32
30
 
33
31
  async connect(): Promise<void> {
@@ -36,12 +34,12 @@ export class Signer extends ccc.Signer {
36
34
 
37
35
  async signMessage(message: string | ccc.BytesLike): Promise<ccc.Hex> {
38
36
  const challenge =
39
- typeof message === "string" ? message : ccc.hexFrom(message);
40
- const [address] = await this.getEVMAccounts();
37
+ typeof message === "string" ? ccc.bytesFrom(message, "utf8") : message;
38
+ const address = await this.getEVMAccount();
41
39
 
42
40
  return this.detail.provider.request({
43
41
  method: "personal_sign",
44
- params: [challenge, address],
42
+ params: [ccc.hexFrom(challenge), address],
45
43
  });
46
44
  }
47
45