@suxinmin/plugin-casper 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/dist/client.js +6 -5
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -12,12 +12,13 @@ class CasperClient {
12
12
  */
13
13
  generateWallet() {
14
14
  const keyPair = casper_js_sdk_1.Keys.Ed25519.new();
15
- const publicKeyHex = Buffer.from(keyPair.publicKey).toString('hex');
15
+ // publicKey CLPublicKey 类型,使用 toHex() 方法
16
+ const publicKeyHex = keyPair.publicKey.toHex(false); // false 表示不使用校验和
16
17
  const privateKeyHex = Buffer.from(keyPair.privateKey).toString('hex');
17
- const accountHash = Buffer.from(keyPair.accountHash()).toString('hex');
18
+ const accountHash = keyPair.accountHex(false);
18
19
  const address = `account-hash-${accountHash}`;
19
20
  return {
20
- publicKey: `02${publicKeyHex}`,
21
+ publicKey: publicKeyHex,
21
22
  privateKey: privateKeyHex,
22
23
  address
23
24
  };
@@ -29,8 +30,8 @@ class CasperClient {
29
30
  const privateKeyBytes = Buffer.from(privateKeyHex, 'hex');
30
31
  const publicKeyBytes = casper_js_sdk_1.Keys.Ed25519.privateToPublicKey(privateKeyBytes);
31
32
  const keyPair = casper_js_sdk_1.Keys.Ed25519.parseKeyPair(publicKeyBytes, privateKeyBytes);
32
- const publicKey = `02${Buffer.from(keyPair.publicKey).toString('hex')}`;
33
- const accountHash = Buffer.from(keyPair.accountHash()).toString('hex');
33
+ const publicKey = keyPair.publicKey.toHex(false);
34
+ const accountHash = keyPair.accountHex(false);
34
35
  const address = `account-hash-${accountHash}`;
35
36
  return {
36
37
  publicKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suxinmin/plugin-casper",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Casper blockchain plugin for Eliza AI agent framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",