@neuraiproject/neurai-key 2.8.0 → 2.8.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Neuraiproject
3
+ Copyright (c) 2022 Raven Rebels
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # neurai-key
1
+ # Neurai-key
2
2
 
3
3
  Generate Neurai addresses from a mnemonic phrase following the standards BIP32, BIP39, BIP44.
4
4
 
5
- That is, use your 12 words to get addresses for Neurai mainnet and testnet.
5
+ That is, use your 12 words to get addresses for Neurai mainnet.
6
6
 
7
7
 
8
8
  ## Example get external and internal (change) addresses by path
@@ -19,7 +19,7 @@ import NeuraiKey from "@neuraiproject/neurai-key";
19
19
  const mnemonic = NeuraiKey.generateMnemonic();
20
20
  const ACCOUNT = 0; //default is zero
21
21
  const POSITION = 0; //the first address for this wallet
22
- const network = "xna"; //or xna-test for testnet
22
+ const network = "xna"; //or rvn-test for testnet
23
23
  const addressPair = NeuraiKey.getAddressPair(
24
24
  network,
25
25
  mnemonic,
@@ -32,7 +32,7 @@ console.info("Mnemonic", mnemonic);
32
32
  console.log(addressPair);
33
33
  ```
34
34
 
35
- Outputs
35
+ Outputs (Old example but you get the point)
36
36
 
37
37
  ```
38
38
  Mnemonic wrong breeze brick wrestle exotic erode news clown copy install marble promote
@@ -66,7 +66,7 @@ import NeuraiKey from "@neuraiproject/neurai-key";
66
66
  const mnemonic =
67
67
  "Mnemonic erosion total live dial hamster helmet top response cash obey anger balcony";
68
68
  const path = "m/44'/175'/0'/0/0";
69
- const network = "xna"; //or xna-test for testnet
69
+ const network = "xna";
70
70
  const hdKey = NeuraiKey.getHDKey("xna", mnemonic);
71
71
 
72
72
  const address = NeuraiKey.getAddressByPath(network, hdKey, path);
@@ -75,7 +75,7 @@ console.log(address);
75
75
 
76
76
  ```
77
77
 
78
- Outputs
78
+ Outputs (Again another old example but you get the point)
79
79
 
80
80
  ```
81
81
  {
package/index.ts CHANGED
@@ -12,32 +12,35 @@ import HDKey from "hdkey";
12
12
  import { IAddressObject } from "./types";
13
13
 
14
14
  //Could not declare Network as enum, something wrong with parcel bundler
15
- export type Network = "xna" | "xna-test";
15
+ export type Network = "xna";
16
16
 
17
17
  function getNetwork(name: Network) {
18
- const c = name.toLowerCase(); //Just to be sure
19
- const map = {
20
- xna: chains.xna.main.versions,
21
- "xna-test": chains.xna.test.versions,
22
- };
23
-
24
- const network = map[c];
25
- if (!network) {
26
- throw new Error("network must be of value " + Object.keys(map).toString());
18
+ if (name !== "xna") {
19
+ throw new Error("network must be 'xna'");
27
20
  }
28
- return network;
21
+
22
+ return {
23
+ bip32: {
24
+ private: 0x0488ade4,
25
+ public: 0x0488b21e,
26
+ },
27
+ bip44: 0,
28
+ private: 0x80,
29
+ public: 0x35,
30
+ scripthash: 0x75,
31
+ };
29
32
  }
30
33
  /**
31
34
  *
32
35
  * @param network
33
- * @returns the coin type for the network (blockchain), for example Neurai has coin type 175
36
+ * @returns the coin type for the network (blockchain)
34
37
  */
35
38
  export function getCoinType(network: Network) {
36
39
  const chain = getNetwork(network);
37
40
  return chain.bip44;
38
41
  }
39
42
  /**
40
- * @param network - should have value "xna", "xna-test"
43
+ * @param network - should have value "xna"
41
44
  * @param mnemonic - your mnemonic
42
45
  * @param account - accounts in BIP44 starts from 0, 0 is the default account
43
46
  * @param position - starts from 0
@@ -113,7 +116,7 @@ export function isMnemonicValid(mnemonic: string) {
113
116
  /**
114
117
  *
115
118
  * @param privateKeyWIF
116
- * @param network should be "xna" or "xna-test"
119
+ * @param network should be "rvn" or "rvn-test"
117
120
  * @returns object {address, privateKey (hex), WIF}
118
121
  */
119
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuraiproject/neurai-key",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "Generate Neurai addresses from mnemonic code. BIP32, BIP39, BIP44",
5
5
  "source": "index.ts",
6
6
  "main": "dist/main.js",
@@ -20,7 +20,7 @@
20
20
  "BIP44",
21
21
  "BIP39"
22
22
  ],
23
- "author": "Raven Rebels / Dick Henrik Larsson",
23
+ "author": "Neurai Project / Zachary Price",
24
24
  "license": "MIT",
25
25
  "bugs": {
26
26
  "url": "https://github.com/neuraiproject/neurai-key/issues"
package/test.js CHANGED
@@ -10,15 +10,7 @@ test("Validate address on main-net", () => {
10
10
  const mnemonic =
11
11
  "orphan resemble brain dwarf bus fancy horn among cricket logic duty crater";
12
12
  const address = NeuraiKey.getAddressPair(network, mnemonic, 0, 1);
13
- expect(address.external.address).toBe("RKbP9SMo2KTKWsiTrEDhTWPuaTwfuPiN8G");
14
- });
15
-
16
- test("Validate address on test-net", () => {
17
- const network = "xna-test";
18
- const mnemonic =
19
- "orphan resemble brain dwarf bus fancy horn among cricket logic duty crater";
20
- const address = NeuraiKey.getAddressPair(network, mnemonic, 0, 1);
21
- expect(address.external.address).toBe("n1nUspcdAaDAMfx2ksZJ5cDa7UKVEGstrX");
13
+ expect(address.external.address).toBe("TxSKpGLR58VUFzBJ8pjkDgNnNKmvGyWL4t");
22
14
  });
23
15
 
24
16
  test("Validate Wallet Import Format (WIF) main-net ", () => {
@@ -27,29 +19,16 @@ test("Validate Wallet Import Format (WIF) main-net ", () => {
27
19
  "orphan resemble brain dwarf bus fancy horn among cricket logic duty crater";
28
20
  const address = NeuraiKey.getAddressPair(network, mnemonic, 0, 1);
29
21
 
30
- expect(address.internal.address).toBe("RLnvUoy29k3QiQgtR6PL416rSNfHTuwhyU");
31
- expect(address.external.WIF).toBe(
32
- "KyWuYcev1hJ7YJZTjWx8coXNRm4jRbMEhgVVVC8vDcTaKRCMASUE"
33
- );
22
+ expect(address.internal.address).toBe("Td8haX27FhJ1TeTdj9z1DX6296FCqaRRxF");
23
+ expect(address.external.WIF).toBe("KybNCdSZVUdqCdaq95mtcskGd4K2cWvnYNZcJ3mo1gDY9ZtySiR6");
34
24
  });
35
25
 
36
- test("Validate Wallet Import Format (WIF) test-net ", () => {
37
- const network = "xna-test";
38
- const mnemonic =
39
- "orphan resemble brain dwarf bus fancy horn among cricket logic duty crater";
40
- const address = NeuraiKey.getAddressPair(network, mnemonic, 0, 1);
41
-
42
- expect(address.external.WIF).toBe(
43
- "cPchRRmzZXtPeFLHfrh8qcwaRaziJCS4gcAMBVVQh1EiehNyBtKB"
44
- );
45
- });
46
-
47
- test("Validate get public address from Wallet Import Format (WIF) main-et ", () => {
26
+ test("Validate get public address from Wallet Import Format (WIF) main-net ", () => {
48
27
  const network = "xna";
49
- const WIF = "KyWuYcev1hJ7YJZTjWx8coXNRm4jRbMEhgVVVC8vDcTaKRCMASUE";
28
+ const WIF = "L1CQvWc2hCVdLNKYeWDrMDfWvzUhpxQDGRMHJTBmUc1LpjqFd3qf";
50
29
  const addressObject = NeuraiKey.getAddressByWIF(network, WIF);
51
30
 
52
- expect(addressObject.address).toBe("RKbP9SMo2KTKWsiTrEDhTWPuaTwfuPiN8G");
31
+ expect(addressObject.address).toBe("ThYNJX9F4xSdiZMBQXWCTMYLxqpAhrzYV3");
53
32
  });
54
33
 
55
34
  test("Valid bytes to mnemonic", () => {
@@ -69,3 +48,49 @@ test("Non valid bytes to mnemonic should fail", () => {
69
48
  "patient feed learn prison angle convince first napkin uncover track open theory"
70
49
  );
71
50
  });
51
+
52
+ describe("Validate diff languages", () => {
53
+ it("Should accept spanish mnemonic", () => {
54
+ const m =
55
+ "velero nuera pepino reír barro reforma negar rumbo atento separar pesa puma";
56
+ const valid = NeuraiKey.isMnemonicValid(m);
57
+ expect(valid).toBe(true);
58
+ });
59
+
60
+ it("Should accept French mnemonic", () => {
61
+ const m =
62
+ "vaseux mixte ozone quiétude besogne punaise membre réussir avarice samedi pantalon poney";
63
+ const valid = NeuraiKey.isMnemonicValid(m);
64
+ expect(valid).toBe(true);
65
+ });
66
+ });
67
+
68
+ it("Should accept Italian mnemonic", () => {
69
+ const m =
70
+ "veloce perforare recinto sciroppo bici scelto parabola sguardo avanzato sonnifero remoto rustico";
71
+ const valid = NeuraiKey.isMnemonicValid(m);
72
+ expect(valid).toBe(true);
73
+ });
74
+
75
+ describe("generateAddress", () => {
76
+ it("should generate an address with a mnemonic", () => {
77
+ const result = NeuraiKey.generateAddressObject();
78
+
79
+ expect(result).toHaveProperty("mnemonic");
80
+ expect(result.mnemonic).toBeDefined();
81
+ expect(result.network).toBe("xna");
82
+ expect(result).toHaveProperty("address");
83
+ });
84
+
85
+ // it("default network should be xna for Neurai", () => {
86
+ // const network = "xna-test";
87
+ // const result = NeuraiKey.generateAddressObject(network);
88
+ // expect(result.network).toBe(network);
89
+ // });
90
+
91
+ // it("Should handle xna", () => {
92
+ // const network = "xna-test";
93
+ // const result = NeuraiKey.generateAddressObject(network);
94
+ // expect(result.network).toBe(network);
95
+ // });
96
+ });