@neuraiproject/neurai-rpc 0.2.7 → 0.4.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Raven Rebels
3
+ Copyright (c) 2025 Neuraiproject
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,19 +1,50 @@
1
1
  # neurai-rpc
2
2
 
3
- A package that will help you do RPC calls from Node.js to your Raven core node, that is your full Neurai node.
3
+ A package that will help you do RPC calls from Node.js to your Raven core node, that is your full Ravencoin node.
4
+
5
+ URLs for locally installed Ravencoin nodes.
6
+
7
+ - http://127.0.0.1:19001 for mainnet
8
+ - http://127.0.0.1:19101 for testnet
9
+
10
+ Ravencoin as a service, you don't need your own node
11
+
12
+ - https://rpc-main.neurai.org/rpc for mainnet
13
+ - https://rpc-testnet.neurai.org/rpc for testnet
4
14
 
5
15
  # Install
16
+
6
17
  ```
7
18
  npm install @neuraiproject/neurai-rpc
8
19
  ```
9
- # Example
20
+
21
+ # Example using ES modules
22
+
23
+ This example uses Ravencoin as a service from https://rpc-main.neurai.org.
24
+
25
+ In node.js you need to give the file the ending .mjs for modular JavaScript.
26
+ Like `example.mjs`
27
+
28
+ ```
29
+ import { getRPC, methods } from "@neuraiproject/neurai-rpc";
30
+
31
+ const username = "anonymous";
32
+ const password = "anonymous";
33
+ const URL = "https://rpc-main.neurai.org/rpc";
34
+ const rpc = getRPC(username, password, URL);
35
+
36
+ const params = [];
37
+ rpc(methods.getblockcount, params).then(console.log);
38
+ ```
39
+
40
+ # Example using CommonJS
10
41
 
11
42
  ```
12
43
 
13
44
  const { getRPC, methods } = require("@neuraiproject/neurai-rpc");
14
45
  //methods is a list of all available methods/functions/commands/procedures
15
46
 
16
- const rpc = getRPC("UsernameSecret", "PasswordSecret", "http://localhost:8766");
47
+ const rpc = getRPC("UsernameSecret", "PasswordSecret", "http://localhost:19001");
17
48
 
18
49
  const promise = rpc(methods.getassetdata, ["ELVIS"]);
19
50
  promise.catch((e) => {
@@ -32,9 +63,12 @@ will print out
32
63
  ```
33
64
  { name: 'ELVIS', amount: 1, units: 8, reissuable: 1, has_ipfs: 0 }
34
65
  ```
66
+
35
67
  ## Example list all generated addresses in a Wallet (Raven core)
68
+
36
69
  Use method `listreceivedbyaddress` to receive a list of all generated addresses.
37
70
  Write the result to a .json file
71
+
38
72
  ```
39
73
  const { getRPC, methods } = require("@neuraiproject/neurai-rpc");
40
74
  //methods is a list of all available methods/functions/commands/procedures
@@ -45,7 +79,7 @@ const includeEmpty = true;
45
79
 
46
80
  const params = [minConfirmations, includeEmpty];
47
81
 
48
- const rpc = getRPC("UsernameSecret", "PasswordSecret", "http://localhost:8766");
82
+ const rpc = getRPC("UsernameSecret", "PasswordSecret", "http://localhost:19001");
49
83
 
50
84
  const promise = rpc(method, params);
51
85
  promise.catch((e) => {
@@ -68,7 +102,9 @@ function writeToFile(list){
68
102
  }
69
103
 
70
104
  ```
105
+
71
106
  # Methods / commands / Procedure calls
107
+
72
108
  Here is a list of all method/commands [All methods](neurai_methods.md)
73
109
 
74
110
  In your local Raven core wallet, you can go to
@@ -279,4 +315,4 @@ setaccount "address" "account"
279
315
  settxfee amount
280
316
  signmessage "address" "message"
281
317
 
282
- ```
318
+ ```
@@ -1,12 +1,31 @@
1
- const docs = require("./docs.json");
1
+ import fs from "fs";
2
+
3
+ const docs = JSON.parse(fs.readFileSync("./docs.json"));
2
4
 
3
5
  const keys = Object.keys(docs).sort();
4
6
 
7
+ const methodsDefinition = [];
8
+ for (let key of keys) {
9
+ if (!key) {
10
+ continue;
11
+ }
12
+ methodsDefinition.push(key + ": string;");
13
+ }
14
+ console.log("Methods definition", methodsDefinition);
15
+
16
+ const theInterface = `
17
+ interface IMethods{
18
+ ${methodsDefinition.join("\n")}
19
+ }
20
+ `;
21
+
22
+ fs.writeFileSync("./docs.ts", theInterface);
23
+
5
24
  //Create docs.ts
6
25
  {
7
26
  const result = [];
8
27
  result.push(`
9
- export const methods ={
28
+ export const methods:IMethods ={
10
29
  `);
11
30
 
12
31
  for (let key of keys) {
@@ -21,13 +40,13 @@ export const methods ={
21
40
 
22
41
  result.push("\n}");
23
42
 
24
- require("fs").writeFileSync("./docs.ts", result.join(""));
43
+ fs.appendFileSync("./docs.ts", result.join(""));
25
44
  }
26
45
 
27
46
  //Create neurai_method.md
28
47
  {
29
48
  const result = [];
30
- result.push("# Neurai remote procedure calls/methods");
49
+ result.push("# Ravencoin remote procedure calls/methods");
31
50
  result.push("\r\n[Home](README.md)");
32
51
  for (let key of keys) {
33
52
  if (!key) {
@@ -38,5 +57,5 @@ export const methods ={
38
57
  result.push("\r\n## " + key);
39
58
  result.push(`\r\n&nbsp;<br/> ${doc} `);
40
59
  }
41
- require("fs").writeFileSync("./neurai_methods.md", result.join(""));
42
- }
60
+ fs.writeFileSync("./neurai_methods.md", result.join(""));
61
+ }