@neuraiproject/neurai-rpc 0.4.6 → 0.5.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 +103 -20
- package/DEPIN_EXAMPLES.md +148 -220
- package/DEPIN_IMPLEMENTATION_GUIDE_EN.md +278 -80
- package/README.md +106 -40
- package/depin.ts +465 -214
- package/dist/depin.cjs +305 -0
- package/dist/depin.d.cts +96 -0
- package/dist/depin.d.ts +96 -0
- package/dist/depin.mjs +280 -0
- package/dist/index.cjs +5241 -4892
- package/dist/{types.d.ts → index.d.cts} +12 -63
- package/dist/index.d.ts +200 -0
- package/dist/index.mjs +5214 -4884
- package/docs.json +140 -132
- package/docs.ts +544 -43
- package/index.ts +13 -9
- package/neurai_methods.md +504 -43
- package/package.json +39 -11
- package/createDocs.mjs +0 -61
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/test-depin.ts +0 -187
- package/test.js +0 -56
- package/tsconfig.json +0 -26
|
@@ -22,20 +22,26 @@ interface IMethods {
|
|
|
22
22
|
decoderawtransaction: string;
|
|
23
23
|
decodescript: string;
|
|
24
24
|
depinclearmsg: string;
|
|
25
|
+
depingetancestorrecipients: string;
|
|
25
26
|
depingetmsg: string;
|
|
26
27
|
depingetmsginfo: string;
|
|
27
28
|
depingetpoolcontent: string;
|
|
29
|
+
depinlistsections: string;
|
|
28
30
|
depinmcpstatus: string;
|
|
31
|
+
depinpoolpkey: string;
|
|
29
32
|
depinpoolstats: string;
|
|
33
|
+
depinreceivemsg: string;
|
|
30
34
|
depinsendmsg: string;
|
|
31
35
|
depinsubmitmsg: string;
|
|
32
36
|
disconnectnode: string;
|
|
33
37
|
distributereward: string;
|
|
38
|
+
dumpextkeypq: string;
|
|
34
39
|
dumpprivkey: string;
|
|
35
40
|
dumpwallet: string;
|
|
36
41
|
encryptwallet: string;
|
|
37
42
|
estimatefee: string;
|
|
38
43
|
estimatesmartfee: string;
|
|
44
|
+
exportxpqpub: string;
|
|
39
45
|
freezeaddress: string;
|
|
40
46
|
freezedepin: string;
|
|
41
47
|
freezerestrictedasset: string;
|
|
@@ -121,10 +127,12 @@ interface IMethods {
|
|
|
121
127
|
listassetbalancesbyaddress: string;
|
|
122
128
|
listassets: string;
|
|
123
129
|
listbanned: string;
|
|
130
|
+
listdepinaddresses: string;
|
|
124
131
|
listdepinholders: string;
|
|
125
132
|
listglobalrestrictions: string;
|
|
126
133
|
listlockunspent: string;
|
|
127
134
|
listmyassets: string;
|
|
135
|
+
listpqaddresses: string;
|
|
128
136
|
listreceivedbyaccount: string;
|
|
129
137
|
listreceivedbyaddress: string;
|
|
130
138
|
listsinceblock: string;
|
|
@@ -185,67 +193,8 @@ interface IMethods {
|
|
|
185
193
|
viewmyrestrictedaddresses: string;
|
|
186
194
|
viewmytaggedaddresses: string;
|
|
187
195
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
*
|
|
192
|
-
* This module provides support for communicating with Neurai DePIN messaging
|
|
193
|
-
* on port 19002 using the challenge/response authentication protocol.
|
|
194
|
-
*/
|
|
195
|
-
export interface DePinAuthOptions {
|
|
196
|
-
/** DePIN token name (e.g., "MYTOKEN") */
|
|
197
|
-
token: string;
|
|
198
|
-
/** Neurai address that will sign challenges */
|
|
199
|
-
address: string;
|
|
200
|
-
/** Function to sign messages (must return base64 signature) */
|
|
201
|
-
signMessage: (message: string) => Promise<string>;
|
|
202
|
-
/** Operation mode: SEND or RECEIVE (default: RECEIVE) */
|
|
203
|
-
mode?: 'SEND' | 'RECEIVE';
|
|
204
|
-
}
|
|
205
|
-
export interface DePinChallenge {
|
|
206
|
-
/** Challenge string from server */
|
|
207
|
-
challenge: string;
|
|
208
|
-
/** Timeout in seconds */
|
|
209
|
-
timeout: number;
|
|
210
|
-
/** Complete message that needs to be signed */
|
|
211
|
-
messageToSign: string;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Create a DePIN RPC client with challenge/response authentication
|
|
215
|
-
*
|
|
216
|
-
* @param url DePIN server URL (e.g., "http://localhost:19002")
|
|
217
|
-
* @param authOptions Authentication options including token, address, and signing function
|
|
218
|
-
* @returns Async RPC function
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```typescript
|
|
222
|
-
* import { getDePinRPC } from "@neuraiproject/neurai-rpc";
|
|
223
|
-
*
|
|
224
|
-
* const depinRpc = getDePinRPC("http://localhost:19002", {
|
|
225
|
-
* token: "MYTOKEN",
|
|
226
|
-
* address: "NXmyaddress...",
|
|
227
|
-
* signMessage: async (msg) => {
|
|
228
|
-
* // Use your wallet to sign the message
|
|
229
|
-
* return await wallet.signMessage(msg);
|
|
230
|
-
* },
|
|
231
|
-
* mode: "SEND"
|
|
232
|
-
* });
|
|
233
|
-
*
|
|
234
|
-
* // Send a DePIN message
|
|
235
|
-
* const result = await depinRpc("depinsendmsg", [
|
|
236
|
-
* "MYTOKEN",
|
|
237
|
-
* "localhost",
|
|
238
|
-
* "Hello from DePIN!",
|
|
239
|
-
* "NXmyaddress..."
|
|
240
|
-
* ]);
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
export function getDePinRPC(url: string, authOptions: DePinAuthOptions): (method: string, params: any[]) => Promise<unknown>;
|
|
244
|
-
/**
|
|
245
|
-
* Helper function to request a challenge without making an RPC call
|
|
246
|
-
* Useful for testing or manual challenge handling
|
|
247
|
-
*/
|
|
248
|
-
export function requestDePinChallenge(url: string, authOptions: DePinAuthOptions): Promise<DePinChallenge>;
|
|
249
|
-
export function getRPC(username: string, password: string, URL: string): (method: string, params: any[]) => Promise<unknown>;
|
|
196
|
+
declare const methods: IMethods;
|
|
197
|
+
|
|
198
|
+
declare function getRPC(username: string, password: string, URL: string): (method: string, params: any[]) => Promise<unknown>;
|
|
250
199
|
|
|
251
|
-
|
|
200
|
+
export { getRPC, methods };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
interface IMethods {
|
|
2
|
+
abandontransaction: string;
|
|
3
|
+
abortrescan: string;
|
|
4
|
+
addmultisigaddress: string;
|
|
5
|
+
addnode: string;
|
|
6
|
+
addtagtoaddress: string;
|
|
7
|
+
addwitnessaddress: string;
|
|
8
|
+
backupwallet: string;
|
|
9
|
+
bumpfee: string;
|
|
10
|
+
cancelsnapshotrequest: string;
|
|
11
|
+
checkaddressrestriction: string;
|
|
12
|
+
checkaddresstag: string;
|
|
13
|
+
checkdepinvalidity: string;
|
|
14
|
+
checkglobalrestriction: string;
|
|
15
|
+
clearbanned: string;
|
|
16
|
+
clearmempool: string;
|
|
17
|
+
clearmessages: string;
|
|
18
|
+
combinerawtransaction: string;
|
|
19
|
+
createmultisig: string;
|
|
20
|
+
createrawtransaction: string;
|
|
21
|
+
decodeblock: string;
|
|
22
|
+
decoderawtransaction: string;
|
|
23
|
+
decodescript: string;
|
|
24
|
+
depinclearmsg: string;
|
|
25
|
+
depingetancestorrecipients: string;
|
|
26
|
+
depingetmsg: string;
|
|
27
|
+
depingetmsginfo: string;
|
|
28
|
+
depingetpoolcontent: string;
|
|
29
|
+
depinlistsections: string;
|
|
30
|
+
depinmcpstatus: string;
|
|
31
|
+
depinpoolpkey: string;
|
|
32
|
+
depinpoolstats: string;
|
|
33
|
+
depinreceivemsg: string;
|
|
34
|
+
depinsendmsg: string;
|
|
35
|
+
depinsubmitmsg: string;
|
|
36
|
+
disconnectnode: string;
|
|
37
|
+
distributereward: string;
|
|
38
|
+
dumpextkeypq: string;
|
|
39
|
+
dumpprivkey: string;
|
|
40
|
+
dumpwallet: string;
|
|
41
|
+
encryptwallet: string;
|
|
42
|
+
estimatefee: string;
|
|
43
|
+
estimatesmartfee: string;
|
|
44
|
+
exportxpqpub: string;
|
|
45
|
+
freezeaddress: string;
|
|
46
|
+
freezedepin: string;
|
|
47
|
+
freezerestrictedasset: string;
|
|
48
|
+
fundrawtransaction: string;
|
|
49
|
+
generate: string;
|
|
50
|
+
generatetoaddress: string;
|
|
51
|
+
getaccount: string;
|
|
52
|
+
getaccountaddress: string;
|
|
53
|
+
getaddednodeinfo: string;
|
|
54
|
+
getaddressbalance: string;
|
|
55
|
+
getaddressdeltas: string;
|
|
56
|
+
getaddressesbyaccount: string;
|
|
57
|
+
getaddressmempool: string;
|
|
58
|
+
getaddresstxids: string;
|
|
59
|
+
getaddressutxos: string;
|
|
60
|
+
getassetdata: string;
|
|
61
|
+
getbalance: string;
|
|
62
|
+
getbestblockhash: string;
|
|
63
|
+
getblock: string;
|
|
64
|
+
getblockchaininfo: string;
|
|
65
|
+
getblockcount: string;
|
|
66
|
+
getblockhash: string;
|
|
67
|
+
getblockhashes: string;
|
|
68
|
+
getblockheader: string;
|
|
69
|
+
getblocktemplate: string;
|
|
70
|
+
getcacheinfo: string;
|
|
71
|
+
getchaintips: string;
|
|
72
|
+
getchaintxstats: string;
|
|
73
|
+
getconnectioncount: string;
|
|
74
|
+
getdifficulty: string;
|
|
75
|
+
getdistributestatus: string;
|
|
76
|
+
getgenerate: string;
|
|
77
|
+
getinfo: string;
|
|
78
|
+
getkawpowhash: string;
|
|
79
|
+
getmasterkeyinfo: string;
|
|
80
|
+
getmemoryinfo: string;
|
|
81
|
+
getmempoolancestors: string;
|
|
82
|
+
getmempooldescendants: string;
|
|
83
|
+
getmempoolentry: string;
|
|
84
|
+
getmempoolinfo: string;
|
|
85
|
+
getmininginfo: string;
|
|
86
|
+
getmywords: string;
|
|
87
|
+
getnettotals: string;
|
|
88
|
+
getnetworkhashps: string;
|
|
89
|
+
getnetworkinfo: string;
|
|
90
|
+
getnewaddress: string;
|
|
91
|
+
getpeerinfo: string;
|
|
92
|
+
getpubkey: string;
|
|
93
|
+
getrawchangeaddress: string;
|
|
94
|
+
getrawmempool: string;
|
|
95
|
+
getrawtransaction: string;
|
|
96
|
+
getreceivedbyaccount: string;
|
|
97
|
+
getreceivedbyaddress: string;
|
|
98
|
+
getrpcinfo: string;
|
|
99
|
+
getsnapshot: string;
|
|
100
|
+
getsnapshotrequest: string;
|
|
101
|
+
getspentinfo: string;
|
|
102
|
+
gettransaction: string;
|
|
103
|
+
gettxout: string;
|
|
104
|
+
gettxoutproof: string;
|
|
105
|
+
gettxoutsetinfo: string;
|
|
106
|
+
getunconfirmedbalance: string;
|
|
107
|
+
getverifierstring: string;
|
|
108
|
+
getwalletinfo: string;
|
|
109
|
+
help: string;
|
|
110
|
+
importaddress: string;
|
|
111
|
+
importmulti: string;
|
|
112
|
+
importprivkey: string;
|
|
113
|
+
importprunedfunds: string;
|
|
114
|
+
importpubkey: string;
|
|
115
|
+
importwallet: string;
|
|
116
|
+
issue: string;
|
|
117
|
+
issuequalifierasset: string;
|
|
118
|
+
issuerestrictedasset: string;
|
|
119
|
+
issueunique: string;
|
|
120
|
+
isvalidverifierstring: string;
|
|
121
|
+
keypoolrefill: string;
|
|
122
|
+
listaccounts: string;
|
|
123
|
+
listaddressesbyasset: string;
|
|
124
|
+
listaddressesfortag: string;
|
|
125
|
+
listaddressgroupings: string;
|
|
126
|
+
listaddressrestrictions: string;
|
|
127
|
+
listassetbalancesbyaddress: string;
|
|
128
|
+
listassets: string;
|
|
129
|
+
listbanned: string;
|
|
130
|
+
listdepinaddresses: string;
|
|
131
|
+
listdepinholders: string;
|
|
132
|
+
listglobalrestrictions: string;
|
|
133
|
+
listlockunspent: string;
|
|
134
|
+
listmyassets: string;
|
|
135
|
+
listpqaddresses: string;
|
|
136
|
+
listreceivedbyaccount: string;
|
|
137
|
+
listreceivedbyaddress: string;
|
|
138
|
+
listsinceblock: string;
|
|
139
|
+
listsnapshotrequests: string;
|
|
140
|
+
listtagsforaddress: string;
|
|
141
|
+
listtransactions: string;
|
|
142
|
+
listunspent: string;
|
|
143
|
+
listwallets: string;
|
|
144
|
+
lockunspent: string;
|
|
145
|
+
move: string;
|
|
146
|
+
ping: string;
|
|
147
|
+
pprpcsb: string;
|
|
148
|
+
preciousblock: string;
|
|
149
|
+
prioritisetransaction: string;
|
|
150
|
+
pruneblockchain: string;
|
|
151
|
+
purgesnapshot: string;
|
|
152
|
+
reissue: string;
|
|
153
|
+
reissuerestrictedasset: string;
|
|
154
|
+
removeprunedfunds: string;
|
|
155
|
+
removetagfromaddress: string;
|
|
156
|
+
requestsnapshot: string;
|
|
157
|
+
rescanblockchain: string;
|
|
158
|
+
savemempool: string;
|
|
159
|
+
selfrevokedepin: string;
|
|
160
|
+
sendfrom: string;
|
|
161
|
+
sendfromaddress: string;
|
|
162
|
+
sendmany: string;
|
|
163
|
+
sendmessage: string;
|
|
164
|
+
sendrawtransaction: string;
|
|
165
|
+
sendtoaddress: string;
|
|
166
|
+
setaccount: string;
|
|
167
|
+
setban: string;
|
|
168
|
+
setgenerate: string;
|
|
169
|
+
setnetworkactive: string;
|
|
170
|
+
settxfee: string;
|
|
171
|
+
signmessage: string;
|
|
172
|
+
signmessagewithprivkey: string;
|
|
173
|
+
signrawtransaction: string;
|
|
174
|
+
stop: string;
|
|
175
|
+
submitblock: string;
|
|
176
|
+
subscribetochannel: string;
|
|
177
|
+
testmempoolaccept: string;
|
|
178
|
+
transfer: string;
|
|
179
|
+
transferfromaddress: string;
|
|
180
|
+
transferfromaddresses: string;
|
|
181
|
+
transferqualifier: string;
|
|
182
|
+
unfreezeaddress: string;
|
|
183
|
+
unfreezedepin: string;
|
|
184
|
+
unfreezerestrictedasset: string;
|
|
185
|
+
unsubscribefromchannel: string;
|
|
186
|
+
uptime: string;
|
|
187
|
+
validateaddress: string;
|
|
188
|
+
verifychain: string;
|
|
189
|
+
verifymessage: string;
|
|
190
|
+
verifytxoutproof: string;
|
|
191
|
+
viewallmessagechannels: string;
|
|
192
|
+
viewallmessages: string;
|
|
193
|
+
viewmyrestrictedaddresses: string;
|
|
194
|
+
viewmytaggedaddresses: string;
|
|
195
|
+
}
|
|
196
|
+
declare const methods: IMethods;
|
|
197
|
+
|
|
198
|
+
declare function getRPC(username: string, password: string, URL: string): (method: string, params: any[]) => Promise<unknown>;
|
|
199
|
+
|
|
200
|
+
export { getRPC, methods };
|