@neuraiproject/neurai-rpc 0.4.7 → 0.5.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.
- package/CHANGELOG.md +83 -0
- package/DEPIN_EXAMPLES.md +148 -220
- package/DEPIN_IMPLEMENTATION_GUIDE_EN.md +239 -70
- package/README.md +98 -46
- 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 +5251 -4941
- package/dist/{types.d.ts → index.d.cts} +10 -63
- package/dist/index.d.ts +200 -0
- package/dist/index.mjs +5224 -4933
- package/docs.json +187 -181
- package/docs.ts +686 -238
- package/index.ts +13 -9
- package/neurai_methods.md +656 -238
- 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;
|
|
@@ -187,67 +193,8 @@ interface IMethods {
|
|
|
187
193
|
viewmyrestrictedaddresses: string;
|
|
188
194
|
viewmytaggedaddresses: string;
|
|
189
195
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
* This module provides support for communicating with Neurai DePIN messaging
|
|
195
|
-
* on port 19002 using the challenge/response authentication protocol.
|
|
196
|
-
*/
|
|
197
|
-
export interface DePinAuthOptions {
|
|
198
|
-
/** DePIN token name (e.g., "MYTOKEN") */
|
|
199
|
-
token: string;
|
|
200
|
-
/** Neurai address that will sign challenges */
|
|
201
|
-
address: string;
|
|
202
|
-
/** Function to sign messages (must return base64 signature) */
|
|
203
|
-
signMessage: (message: string) => Promise<string>;
|
|
204
|
-
/** Operation mode: SEND or RECEIVE (default: RECEIVE) */
|
|
205
|
-
mode?: 'SEND' | 'RECEIVE';
|
|
206
|
-
}
|
|
207
|
-
export interface DePinChallenge {
|
|
208
|
-
/** Challenge string from server */
|
|
209
|
-
challenge: string;
|
|
210
|
-
/** Timeout in seconds */
|
|
211
|
-
timeout: number;
|
|
212
|
-
/** Complete message that needs to be signed */
|
|
213
|
-
messageToSign: string;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Create a DePIN RPC client with challenge/response authentication
|
|
217
|
-
*
|
|
218
|
-
* @param url DePIN server URL (e.g., "http://localhost:19002")
|
|
219
|
-
* @param authOptions Authentication options including token, address, and signing function
|
|
220
|
-
* @returns Async RPC function
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```typescript
|
|
224
|
-
* import { getDePinRPC } from "@neuraiproject/neurai-rpc";
|
|
225
|
-
*
|
|
226
|
-
* const depinRpc = getDePinRPC("http://localhost:19002", {
|
|
227
|
-
* token: "MYTOKEN",
|
|
228
|
-
* address: "NXmyaddress...",
|
|
229
|
-
* signMessage: async (msg) => {
|
|
230
|
-
* // Use your wallet to sign the message
|
|
231
|
-
* return await wallet.signMessage(msg);
|
|
232
|
-
* },
|
|
233
|
-
* mode: "SEND"
|
|
234
|
-
* });
|
|
235
|
-
*
|
|
236
|
-
* // Send a DePIN message
|
|
237
|
-
* const result = await depinRpc("depinsendmsg", [
|
|
238
|
-
* "MYTOKEN",
|
|
239
|
-
* "localhost",
|
|
240
|
-
* "Hello from DePIN!",
|
|
241
|
-
* "NXmyaddress..."
|
|
242
|
-
* ]);
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
export function getDePinRPC(url: string, authOptions: DePinAuthOptions): (method: string, params: any[]) => Promise<unknown>;
|
|
246
|
-
/**
|
|
247
|
-
* Helper function to request a challenge without making an RPC call
|
|
248
|
-
* Useful for testing or manual challenge handling
|
|
249
|
-
*/
|
|
250
|
-
export function requestDePinChallenge(url: string, authOptions: DePinAuthOptions): Promise<DePinChallenge>;
|
|
251
|
-
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>;
|
|
252
199
|
|
|
253
|
-
|
|
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 };
|