@lfdecentralizedtrust/paladin-sdk 0.13.0-rc.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/README.md +21 -0
- package/build/domains/abis/INoto.json +448 -0
- package/build/domains/abis/INotoPrivate.json +347 -0
- package/build/domains/abis/IZetoFungible.json +197 -0
- package/build/domains/abis/PentePrivacyGroup.json +613 -0
- package/build/domains/abis/Zeto_Anon.json +1263 -0
- package/build/domains/noto.d.ts +117 -0
- package/build/domains/noto.js +292 -0
- package/build/domains/pente.d.ts +84 -0
- package/build/domains/pente.js +191 -0
- package/build/domains/zeto.d.ts +83 -0
- package/build/domains/zeto.js +201 -0
- package/build/index.d.ts +9 -0
- package/build/index.js +28 -0
- package/build/interfaces/algorithms.d.ts +3 -0
- package/build/interfaces/algorithms.js +9 -0
- package/build/interfaces/blockchainevent.d.ts +15 -0
- package/build/interfaces/blockchainevent.js +2 -0
- package/build/interfaces/blockindex.d.ts +30 -0
- package/build/interfaces/blockindex.js +2 -0
- package/build/interfaces/domains.d.ts +9 -0
- package/build/interfaces/domains.js +2 -0
- package/build/interfaces/index.d.ts +15 -0
- package/build/interfaces/index.js +31 -0
- package/build/interfaces/keymanager.d.ts +32 -0
- package/build/interfaces/keymanager.js +2 -0
- package/build/interfaces/logger.d.ts +8 -0
- package/build/interfaces/logger.js +2 -0
- package/build/interfaces/paladin.d.ts +14 -0
- package/build/interfaces/paladin.js +2 -0
- package/build/interfaces/privacygroups.d.ts +76 -0
- package/build/interfaces/privacygroups.js +2 -0
- package/build/interfaces/query.d.ts +33 -0
- package/build/interfaces/query.js +2 -0
- package/build/interfaces/registry.d.ts +26 -0
- package/build/interfaces/registry.js +2 -0
- package/build/interfaces/states.d.ts +61 -0
- package/build/interfaces/states.js +2 -0
- package/build/interfaces/transaction.d.ts +159 -0
- package/build/interfaces/transaction.js +12 -0
- package/build/interfaces/transport.d.ts +32 -0
- package/build/interfaces/transport.js +2 -0
- package/build/interfaces/verifiers.d.ts +6 -0
- package/build/interfaces/verifiers.js +10 -0
- package/build/interfaces/websocket.d.ts +57 -0
- package/build/interfaces/websocket.js +2 -0
- package/build/paladin.d.ts +265 -0
- package/build/paladin.js +739 -0
- package/build/transaction.d.ts +8 -0
- package/build/transaction.js +17 -0
- package/build/utils.d.ts +5 -0
- package/build/utils.js +49 -0
- package/build/verifier.d.ts +16 -0
- package/build/verifier.js +24 -0
- package/build/websocket.d.ts +35 -0
- package/build/websocket.js +177 -0
- package/build.gradle +75 -0
- package/package.json +32 -0
- package/scripts/abi.mjs +19 -0
- package/scripts/contracts.mjs +20 -0
- package/scripts/download.mjs +27 -0
- package/scripts/util.mjs +42 -0
- package/src/domains/noto.ts +420 -0
- package/src/domains/pente.ts +287 -0
- package/src/domains/zeto.ts +282 -0
- package/src/index.ts +10 -0
- package/src/interfaces/algorithms.ts +6 -0
- package/src/interfaces/blockchainevent.ts +18 -0
- package/src/interfaces/blockindex.ts +33 -0
- package/src/interfaces/domains.ts +10 -0
- package/src/interfaces/index.ts +15 -0
- package/src/interfaces/keymanager.ts +35 -0
- package/src/interfaces/logger.ts +8 -0
- package/src/interfaces/paladin.ts +17 -0
- package/src/interfaces/privacygroups.ts +86 -0
- package/src/interfaces/query.ts +37 -0
- package/src/interfaces/registry.ts +27 -0
- package/src/interfaces/states.ts +77 -0
- package/src/interfaces/transaction.ts +179 -0
- package/src/interfaces/transport.ts +35 -0
- package/src/interfaces/verifiers.ts +6 -0
- package/src/interfaces/websocket.ts +67 -0
- package/src/paladin.ts +1295 -0
- package/src/transaction.ts +17 -0
- package/src/utils.ts +24 -0
- package/src/verifier.ts +27 -0
- package/src/websocket.ts +217 -0
- package/tsconfig.json +14 -0
package/src/paladin.ts
ADDED
|
@@ -0,0 +1,1295 @@
|
|
|
1
|
+
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
import { ethers, InterfaceAbi } from "ethers";
|
|
3
|
+
import {
|
|
4
|
+
ActiveFilter,
|
|
5
|
+
Algorithms,
|
|
6
|
+
IABIDecodedData,
|
|
7
|
+
IBlockchainEventListener,
|
|
8
|
+
IEthAddress,
|
|
9
|
+
IEventWithData,
|
|
10
|
+
IKeyMappingAndVerifier,
|
|
11
|
+
IKeyQueryEntry,
|
|
12
|
+
INotoDomainReceipt,
|
|
13
|
+
IPenteDomainReceipt,
|
|
14
|
+
IPreparedTransaction,
|
|
15
|
+
IPrivacyGroup,
|
|
16
|
+
IPrivacyGroupEVMCall,
|
|
17
|
+
IPrivacyGroupEVMTXInput,
|
|
18
|
+
IPrivacyGroupInput,
|
|
19
|
+
IPrivacyGroupMessageInput,
|
|
20
|
+
IPrivacyGroupMessageListener,
|
|
21
|
+
IQuery,
|
|
22
|
+
IRegistryEntry,
|
|
23
|
+
IRegistryEntryWithProperties,
|
|
24
|
+
IRegistryProperty,
|
|
25
|
+
ISchema,
|
|
26
|
+
IState,
|
|
27
|
+
IStoredABI,
|
|
28
|
+
ITransaction,
|
|
29
|
+
ITransactionCall,
|
|
30
|
+
ITransactionInput,
|
|
31
|
+
ITransactionReceipt,
|
|
32
|
+
ITransactionReceiptListener,
|
|
33
|
+
ITransactionStates,
|
|
34
|
+
IWalletInfo,
|
|
35
|
+
JsonRpcResult,
|
|
36
|
+
Logger,
|
|
37
|
+
PaladinConfig,
|
|
38
|
+
PaladinErrorHandler,
|
|
39
|
+
StateStatus,
|
|
40
|
+
Verifiers,
|
|
41
|
+
} from "./interfaces";
|
|
42
|
+
import { PaladinVerifier } from "./verifier";
|
|
43
|
+
|
|
44
|
+
const POLL_INTERVAL_MS = 100;
|
|
45
|
+
|
|
46
|
+
export default class PaladinClient {
|
|
47
|
+
protected http: AxiosInstance;
|
|
48
|
+
private logger: Logger;
|
|
49
|
+
private onError: PaladinErrorHandler;
|
|
50
|
+
|
|
51
|
+
constructor(options: PaladinConfig) {
|
|
52
|
+
this.http = axios.create({
|
|
53
|
+
...options.requestConfig,
|
|
54
|
+
baseURL: options.url,
|
|
55
|
+
});
|
|
56
|
+
this.logger = options.logger ?? console;
|
|
57
|
+
this.onError =
|
|
58
|
+
options.onError ??
|
|
59
|
+
((method: string, err: AxiosError) => {
|
|
60
|
+
this.logger.error(
|
|
61
|
+
`JSON-RPC error from ${method} (${err.response?.status} ${err.response?.statusText})`,
|
|
62
|
+
this.parseAxiosErrorMessage(err)
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getHttpInstance(): AxiosInstance {
|
|
68
|
+
return this.http;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected defaultHeaders() {
|
|
72
|
+
return {
|
|
73
|
+
Accept: "application/json",
|
|
74
|
+
"Content-Type": "application/json",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected defaultPayload() {
|
|
79
|
+
return {
|
|
80
|
+
jsonrpc: "2.0",
|
|
81
|
+
id: Date.now(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getVerifiers(...lookups: string[]) {
|
|
86
|
+
return lookups.map((lookup) => new PaladinVerifier(this, lookup));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
parseAxiosErrorMessage(err: any) {
|
|
90
|
+
if (err instanceof AxiosError && err.response?.data?.error) {
|
|
91
|
+
return err.response.data.error?.message || err.response.data.error;
|
|
92
|
+
}
|
|
93
|
+
return `${err}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private post<T>(method: string, params: any[], config?: AxiosRequestConfig) {
|
|
97
|
+
const res = this.http.post<T>(
|
|
98
|
+
"/",
|
|
99
|
+
{ ...this.defaultPayload(), method, params },
|
|
100
|
+
{ ...config, headers: this.defaultHeaders() }
|
|
101
|
+
);
|
|
102
|
+
res.catch((err: AxiosError) => this.onError(method, err));
|
|
103
|
+
return res;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async pollForReceipt(txID: string, waitMs: number, full?: boolean) {
|
|
107
|
+
for (let i = 0; i < waitMs; i += POLL_INTERVAL_MS) {
|
|
108
|
+
var receipt = full
|
|
109
|
+
? await this.ptx.getTransactionReceiptFull(txID)
|
|
110
|
+
: await this.ptx.getTransactionReceipt(txID);
|
|
111
|
+
if (receipt != undefined) {
|
|
112
|
+
return receipt;
|
|
113
|
+
}
|
|
114
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
115
|
+
}
|
|
116
|
+
this.logger.error(`Failed while waiting for receipt: ${txID}`);
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async pollForPreparedTransaction(txID: string, waitMs: number) {
|
|
121
|
+
for (let i = 0; i < waitMs; i += POLL_INTERVAL_MS) {
|
|
122
|
+
var receipt = await this.ptx.getPreparedTransaction(txID);
|
|
123
|
+
if (receipt != undefined) {
|
|
124
|
+
return receipt;
|
|
125
|
+
}
|
|
126
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
127
|
+
}
|
|
128
|
+
this.logger.error(`Failed while waiting for prepare: ${txID}`);
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated Use ptx.prepareTransaction instead
|
|
134
|
+
*/
|
|
135
|
+
async prepareTransaction(transaction: ITransactionInput) {
|
|
136
|
+
return this.ptx.prepareTransaction(transaction);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Use ptx.sendTransaction instead
|
|
141
|
+
*/
|
|
142
|
+
async sendTransaction(transaction: ITransactionInput) {
|
|
143
|
+
return this.ptx.sendTransaction(transaction);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @deprecated Use ptx.call instead
|
|
148
|
+
*/
|
|
149
|
+
async call(transaction: ITransactionCall) {
|
|
150
|
+
return this.ptx.call(transaction);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated Use ptx.queryTransactions instead
|
|
155
|
+
*/
|
|
156
|
+
async queryTransactions(query: IQuery) {
|
|
157
|
+
return this.ptx.queryTransactions(query);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated Use ptx.getTransaction or ptx.getTransactionFull instead
|
|
162
|
+
*/
|
|
163
|
+
async getTransaction(txID: string, full?: boolean) {
|
|
164
|
+
return full
|
|
165
|
+
? this.ptx.getTransactionFull(txID)
|
|
166
|
+
: this.ptx.getTransaction(txID);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated Use ptx.getPreparedTransaction instead
|
|
171
|
+
*/
|
|
172
|
+
async getPreparedTransaction(txID: string) {
|
|
173
|
+
return this.ptx.getPreparedTransaction(txID);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @deprecated Use ptx.queryTransactionReceipts instead
|
|
178
|
+
*/
|
|
179
|
+
async queryTransactionReceipts(query: IQuery) {
|
|
180
|
+
return this.ptx.queryTransactionReceipts(query);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated Use ptx.getTransactionReceipt or ptx.getTransactionReceiptFull instead
|
|
185
|
+
*/
|
|
186
|
+
async getTransactionReceipt(txID: string, full?: boolean) {
|
|
187
|
+
return full
|
|
188
|
+
? this.ptx.getTransactionReceiptFull(txID)
|
|
189
|
+
: this.ptx.getTransactionReceipt(txID);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated Use ptx.getStateReceipt instead
|
|
194
|
+
*/
|
|
195
|
+
async getStateReceipt(txID: string) {
|
|
196
|
+
return this.ptx.getStateReceipt(txID);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @deprecated Use ptx.getDomainReceipt instead
|
|
201
|
+
*/
|
|
202
|
+
async getDomainReceipt(domain: string, txID: string) {
|
|
203
|
+
return this.ptx.getDomainReceipt(domain, txID);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated Use ptx.resolveVerifier instead
|
|
208
|
+
*/
|
|
209
|
+
async resolveVerifier(
|
|
210
|
+
lookup: string,
|
|
211
|
+
algorithm: Algorithms | string,
|
|
212
|
+
verifierType: Verifiers | string
|
|
213
|
+
) {
|
|
214
|
+
return this.ptx.resolveVerifier(lookup, algorithm, verifierType);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated Use ptx.storeABI instead
|
|
219
|
+
*/
|
|
220
|
+
async storeABI(abi: ethers.InterfaceAbi) {
|
|
221
|
+
return this.ptx.storeABI(abi);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @deprecated Use ptx.getStoredABI instead
|
|
226
|
+
*/
|
|
227
|
+
async getStoredABI(hash: string) {
|
|
228
|
+
return this.ptx.getStoredABI(hash);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @deprecated Use ptx.decodeCall instead
|
|
233
|
+
*/
|
|
234
|
+
async decodeCall(callData: string, dataFormat: string) {
|
|
235
|
+
return this.ptx.decodeCall(callData, dataFormat);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Use ptx.decodeEvent instead
|
|
240
|
+
*/
|
|
241
|
+
async decodeEvent(topics: string[], data: string) {
|
|
242
|
+
return this.ptx.decodeEvent(topics, data);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @deprecated Use ptx.decodeError instead
|
|
247
|
+
*/
|
|
248
|
+
async decodeError(revertError: string, dataFormat: string) {
|
|
249
|
+
return this.ptx.decodeError(revertError, dataFormat);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated Use bidx.decodeTransactionEvents instead
|
|
254
|
+
*/
|
|
255
|
+
async decodeTransactionEvents(
|
|
256
|
+
transactionHash: string,
|
|
257
|
+
abi: InterfaceAbi,
|
|
258
|
+
resultFormat: string
|
|
259
|
+
) {
|
|
260
|
+
return this.bidx.decodeTransactionEvents(
|
|
261
|
+
transactionHash,
|
|
262
|
+
abi,
|
|
263
|
+
resultFormat
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated Use pstate.listSchemas instead
|
|
269
|
+
*/
|
|
270
|
+
async listSchemas(domain: string) {
|
|
271
|
+
return this.pstate.listSchemas(domain);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @deprecated Use pstate.queryStates instead
|
|
276
|
+
*/
|
|
277
|
+
async queryStates(
|
|
278
|
+
domain: string,
|
|
279
|
+
schema: string,
|
|
280
|
+
query: IQuery,
|
|
281
|
+
status: StateStatus
|
|
282
|
+
) {
|
|
283
|
+
return this.pstate.queryStates(domain, schema, query, status);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @deprecated Use pstate.queryContractStates instead
|
|
288
|
+
*/
|
|
289
|
+
async queryContractStates(
|
|
290
|
+
domain: string,
|
|
291
|
+
contractAddress: string,
|
|
292
|
+
schema: string,
|
|
293
|
+
query: IQuery,
|
|
294
|
+
status: StateStatus
|
|
295
|
+
) {
|
|
296
|
+
return this.pstate.queryContractStates(
|
|
297
|
+
domain,
|
|
298
|
+
contractAddress,
|
|
299
|
+
schema,
|
|
300
|
+
query,
|
|
301
|
+
status
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated Use pgroup.createGroup instead
|
|
307
|
+
*/
|
|
308
|
+
async createPrivacyGroup(pgroup: IPrivacyGroupInput) {
|
|
309
|
+
return this.pgroup.createGroup(pgroup);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated Use pgroup.getGroupById instead
|
|
314
|
+
*/
|
|
315
|
+
async getPrivacyGroupById(domainName: string, id: string) {
|
|
316
|
+
return this.pgroup.getGroupById(domainName, id);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @deprecated Use pgroup.getGroupByAddress instead
|
|
321
|
+
*/
|
|
322
|
+
async getPrivacyGroupByAddress(address: string) {
|
|
323
|
+
return this.pgroup.getGroupByAddress(address);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @deprecated Use pgroup.sendTransaction instead
|
|
328
|
+
*/
|
|
329
|
+
async sendPrivacyGroupTransaction(txi: IPrivacyGroupEVMTXInput) {
|
|
330
|
+
return this.pgroup.sendTransaction(txi);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @deprecated Use pgroup.call instead
|
|
335
|
+
*/
|
|
336
|
+
async callPrivacyGroup(txi: IPrivacyGroupEVMCall) {
|
|
337
|
+
return this.pgroup.call(txi);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @deprecated Use ptx.createReceiptListener instead
|
|
342
|
+
*/
|
|
343
|
+
async createReceiptListener(listener: ITransactionReceiptListener) {
|
|
344
|
+
return this.ptx.createReceiptListener(listener);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @deprecated Use ptx.deleteReceiptListener instead
|
|
349
|
+
*/
|
|
350
|
+
async deleteReceiptListener(name: string) {
|
|
351
|
+
return this.ptx.deleteReceiptListener(name);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @deprecated Use ptx.getReceiptListener instead
|
|
356
|
+
*/
|
|
357
|
+
async getReceiptListener(name: string) {
|
|
358
|
+
return this.ptx.getReceiptListener(name);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @deprecated Use ptx.createBlockchainEventListener instead
|
|
363
|
+
*/
|
|
364
|
+
async createBlockchainEventListener(listener: IBlockchainEventListener) {
|
|
365
|
+
return this.ptx.createBlockchainEventListener(listener);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @deprecated Use ptx.deleteBlockchainEventListener instead
|
|
370
|
+
*/
|
|
371
|
+
async deleteBlockchainEventListener(name: string) {
|
|
372
|
+
return this.ptx.deleteBlockchainEventListener(name);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @deprecated Use ptx.getBlockchainEventListener instead
|
|
377
|
+
*/
|
|
378
|
+
async getBlockchainEventListener(name: string) {
|
|
379
|
+
return this.ptx.getBlockchainEventListener(name);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
keymgr = {
|
|
383
|
+
wallets: async () => {
|
|
384
|
+
const res = await this.post<JsonRpcResult<IWalletInfo[]>>(
|
|
385
|
+
"keymgr_wallets",
|
|
386
|
+
[]
|
|
387
|
+
);
|
|
388
|
+
return res.data.result;
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
resolveKey: async (
|
|
392
|
+
identifier: string,
|
|
393
|
+
algorithm: string,
|
|
394
|
+
verifierType: string
|
|
395
|
+
) => {
|
|
396
|
+
const res = await this.post<JsonRpcResult<IKeyMappingAndVerifier>>(
|
|
397
|
+
"keymgr_resolveKey",
|
|
398
|
+
[identifier, algorithm, verifierType]
|
|
399
|
+
);
|
|
400
|
+
return res.data.result;
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
resolveEthAddress: async (identifier: string) => {
|
|
404
|
+
const res = await this.post<JsonRpcResult<IEthAddress>>(
|
|
405
|
+
"keymgr_resolveEthAddress",
|
|
406
|
+
[identifier]
|
|
407
|
+
);
|
|
408
|
+
return res.data.result;
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
reverseKeyLookup: async (
|
|
412
|
+
algorithm: string,
|
|
413
|
+
verifierType: string,
|
|
414
|
+
verifier: string
|
|
415
|
+
) => {
|
|
416
|
+
const res = await this.post<JsonRpcResult<IKeyMappingAndVerifier>>(
|
|
417
|
+
"keymgr_reverseKeyLookup",
|
|
418
|
+
[algorithm, verifierType, verifier]
|
|
419
|
+
);
|
|
420
|
+
return res.data.result;
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
queryKeys: async (query: IQuery) => {
|
|
424
|
+
const res = await this.post<JsonRpcResult<IKeyQueryEntry[]>>(
|
|
425
|
+
"keymgr_queryKeys",
|
|
426
|
+
[query]
|
|
427
|
+
);
|
|
428
|
+
return res.data.result;
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
ptx = {
|
|
433
|
+
sendTransaction: async (transaction: ITransactionInput) => {
|
|
434
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
435
|
+
"ptx_sendTransaction",
|
|
436
|
+
[transaction],
|
|
437
|
+
undefined
|
|
438
|
+
);
|
|
439
|
+
return res.data.result;
|
|
440
|
+
},
|
|
441
|
+
|
|
442
|
+
sendTransactions: async (transactions: ITransactionInput[]) => {
|
|
443
|
+
const res = await this.post<JsonRpcResult<string[]>>(
|
|
444
|
+
"ptx_sendTransactions",
|
|
445
|
+
[transactions],
|
|
446
|
+
undefined
|
|
447
|
+
);
|
|
448
|
+
return res.data.result;
|
|
449
|
+
},
|
|
450
|
+
|
|
451
|
+
prepareTransaction: async (transaction: ITransactionInput) => {
|
|
452
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
453
|
+
"ptx_prepareTransaction",
|
|
454
|
+
[transaction],
|
|
455
|
+
undefined
|
|
456
|
+
);
|
|
457
|
+
return res.data.result;
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
prepareTransactions: async (transactions: ITransactionInput[]) => {
|
|
461
|
+
const res = await this.post<JsonRpcResult<string[]>>(
|
|
462
|
+
"ptx_prepareTransactions",
|
|
463
|
+
[transactions],
|
|
464
|
+
undefined
|
|
465
|
+
);
|
|
466
|
+
return res.data.result;
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
updateTransaction: async (id: string, transaction: ITransactionInput) => {
|
|
470
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
471
|
+
"ptx_updateTransaction",
|
|
472
|
+
[id, transaction],
|
|
473
|
+
undefined
|
|
474
|
+
);
|
|
475
|
+
return res.data.result;
|
|
476
|
+
},
|
|
477
|
+
|
|
478
|
+
call: async (transaction: ITransactionCall) => {
|
|
479
|
+
const res = await this.post<JsonRpcResult<any>>("ptx_call", [
|
|
480
|
+
transaction,
|
|
481
|
+
]);
|
|
482
|
+
return res.data.result;
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
getTransaction: async (txID: string) => {
|
|
486
|
+
const res = await this.post<JsonRpcResult<ITransaction>>(
|
|
487
|
+
"ptx_getTransaction",
|
|
488
|
+
[txID],
|
|
489
|
+
{
|
|
490
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
494
|
+
},
|
|
495
|
+
|
|
496
|
+
getTransactionFull: async (txID: string) => {
|
|
497
|
+
const res = await this.post<JsonRpcResult<ITransaction>>(
|
|
498
|
+
"ptx_getTransactionFull",
|
|
499
|
+
[txID],
|
|
500
|
+
{
|
|
501
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
505
|
+
},
|
|
506
|
+
|
|
507
|
+
getTransactionByIdempotencyKey: async (idempotencyKey: string) => {
|
|
508
|
+
const res = await this.post<JsonRpcResult<ITransaction>>(
|
|
509
|
+
"ptx_getTransactionByIdempotencyKey",
|
|
510
|
+
[idempotencyKey],
|
|
511
|
+
{
|
|
512
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
513
|
+
}
|
|
514
|
+
);
|
|
515
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
516
|
+
},
|
|
517
|
+
|
|
518
|
+
queryTransactions: async (query: IQuery) => {
|
|
519
|
+
const res = await this.post<JsonRpcResult<ITransaction[]>>(
|
|
520
|
+
"ptx_queryTransactions",
|
|
521
|
+
[query]
|
|
522
|
+
);
|
|
523
|
+
return res.data.result;
|
|
524
|
+
},
|
|
525
|
+
|
|
526
|
+
queryTransactionsFull: async (query: IQuery) => {
|
|
527
|
+
const res = await this.post<JsonRpcResult<ITransaction[]>>(
|
|
528
|
+
"ptx_queryTransactionsFull",
|
|
529
|
+
[query]
|
|
530
|
+
);
|
|
531
|
+
return res.data.result;
|
|
532
|
+
},
|
|
533
|
+
|
|
534
|
+
queryPendingTransactions: async (query: IQuery, full?: boolean) => {
|
|
535
|
+
const res = await this.post<JsonRpcResult<ITransaction[]>>(
|
|
536
|
+
"ptx_queryPendingTransactions",
|
|
537
|
+
[query, full]
|
|
538
|
+
);
|
|
539
|
+
return res.data.result;
|
|
540
|
+
},
|
|
541
|
+
|
|
542
|
+
getTransactionReceipt: async (txID: string) => {
|
|
543
|
+
const res = await this.post<JsonRpcResult<ITransactionReceipt>>(
|
|
544
|
+
"ptx_getTransactionReceipt",
|
|
545
|
+
[txID],
|
|
546
|
+
{
|
|
547
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
551
|
+
},
|
|
552
|
+
|
|
553
|
+
getTransactionReceiptFull: async (txID: string) => {
|
|
554
|
+
const res = await this.post<JsonRpcResult<ITransactionReceipt>>(
|
|
555
|
+
"ptx_getTransactionReceiptFull",
|
|
556
|
+
[txID],
|
|
557
|
+
{
|
|
558
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
562
|
+
},
|
|
563
|
+
|
|
564
|
+
getDomainReceipt: async (domain: string, txID: string) => {
|
|
565
|
+
const res = await this.post<
|
|
566
|
+
JsonRpcResult<INotoDomainReceipt | IPenteDomainReceipt>
|
|
567
|
+
>("ptx_getDomainReceipt", [domain, txID], {
|
|
568
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
569
|
+
});
|
|
570
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
571
|
+
},
|
|
572
|
+
|
|
573
|
+
getStateReceipt: async (txID: string) => {
|
|
574
|
+
const res = await this.post<JsonRpcResult<ITransactionStates>>(
|
|
575
|
+
"ptx_getStateReceipt",
|
|
576
|
+
[txID],
|
|
577
|
+
{
|
|
578
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
582
|
+
},
|
|
583
|
+
|
|
584
|
+
queryTransactionReceipts: async (query: IQuery) => {
|
|
585
|
+
const res = await this.post<JsonRpcResult<ITransactionReceipt[]>>(
|
|
586
|
+
"ptx_queryTransactionReceipts",
|
|
587
|
+
[query]
|
|
588
|
+
);
|
|
589
|
+
return res.data.result;
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
getTransactionDependencies: async (txID: string) => {
|
|
593
|
+
const res = await this.post<JsonRpcResult<string[]>>(
|
|
594
|
+
"ptx_getTransactionDependencies",
|
|
595
|
+
[txID],
|
|
596
|
+
{
|
|
597
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
601
|
+
},
|
|
602
|
+
|
|
603
|
+
queryPublicTransactions: async (query: IQuery) => {
|
|
604
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
605
|
+
"ptx_queryPublicTransactions",
|
|
606
|
+
[query]
|
|
607
|
+
);
|
|
608
|
+
return res.data.result;
|
|
609
|
+
},
|
|
610
|
+
|
|
611
|
+
queryPendingPublicTransactions: async (query: IQuery) => {
|
|
612
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
613
|
+
"ptx_queryPendingPublicTransactions",
|
|
614
|
+
[query]
|
|
615
|
+
);
|
|
616
|
+
return res.data.result;
|
|
617
|
+
},
|
|
618
|
+
|
|
619
|
+
getPublicTransactionByNonce: async (from: string, nonce: number) => {
|
|
620
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
621
|
+
"ptx_getPublicTransactionByNonce",
|
|
622
|
+
[from, nonce],
|
|
623
|
+
{
|
|
624
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
628
|
+
},
|
|
629
|
+
|
|
630
|
+
getPublicTransactionByHash: async (hash: string) => {
|
|
631
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
632
|
+
"ptx_getPublicTransactionByHash",
|
|
633
|
+
[hash],
|
|
634
|
+
{
|
|
635
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
636
|
+
}
|
|
637
|
+
);
|
|
638
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
getPreparedTransaction: async (txID: string) => {
|
|
642
|
+
const res = await this.post<JsonRpcResult<IPreparedTransaction>>(
|
|
643
|
+
"ptx_getPreparedTransaction",
|
|
644
|
+
[txID],
|
|
645
|
+
{
|
|
646
|
+
validateStatus: (status) => status < 300 || status === 404,
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
650
|
+
},
|
|
651
|
+
|
|
652
|
+
queryPreparedTransactions: async (query: IQuery) => {
|
|
653
|
+
const res = await this.post<JsonRpcResult<IPreparedTransaction[]>>(
|
|
654
|
+
"ptx_queryPreparedTransactions",
|
|
655
|
+
[query]
|
|
656
|
+
);
|
|
657
|
+
return res.data.result;
|
|
658
|
+
},
|
|
659
|
+
|
|
660
|
+
storeABI: async (abi: ethers.InterfaceAbi) => {
|
|
661
|
+
await this.post("ptx_storeABI", [abi]);
|
|
662
|
+
},
|
|
663
|
+
|
|
664
|
+
getStoredABI: async (hash: string) => {
|
|
665
|
+
const res = await this.post<JsonRpcResult<IStoredABI>>(
|
|
666
|
+
"ptx_getStoredABI",
|
|
667
|
+
[hash]
|
|
668
|
+
);
|
|
669
|
+
return res.data.result;
|
|
670
|
+
},
|
|
671
|
+
|
|
672
|
+
queryStoredABIs: async (query: IQuery) => {
|
|
673
|
+
const res = await this.post<JsonRpcResult<IStoredABI[]>>(
|
|
674
|
+
"ptx_queryStoredABIs",
|
|
675
|
+
[query]
|
|
676
|
+
);
|
|
677
|
+
return res.data.result;
|
|
678
|
+
},
|
|
679
|
+
|
|
680
|
+
decodeCall: async (callData: string, dataFormat: string) => {
|
|
681
|
+
const res = await this.post<JsonRpcResult<IABIDecodedData>>(
|
|
682
|
+
"ptx_decodeCall",
|
|
683
|
+
[callData, dataFormat]
|
|
684
|
+
);
|
|
685
|
+
return res.data.result;
|
|
686
|
+
},
|
|
687
|
+
|
|
688
|
+
decodeEvent: async (topics: string[], data: string) => {
|
|
689
|
+
try {
|
|
690
|
+
const res = await this.post<JsonRpcResult<IABIDecodedData>>(
|
|
691
|
+
"ptx_decodeEvent",
|
|
692
|
+
[topics, data, ""]
|
|
693
|
+
);
|
|
694
|
+
return res.data.result;
|
|
695
|
+
} catch (err) {
|
|
696
|
+
const parsed = this.parseAxiosErrorMessage(err);
|
|
697
|
+
if (typeof parsed === "string" && parsed.indexOf("PD012229") >= 0) {
|
|
698
|
+
return undefined;
|
|
699
|
+
}
|
|
700
|
+
throw err;
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
|
|
704
|
+
decodeError: async (revertError: string, dataFormat: string) => {
|
|
705
|
+
const res = await this.post<JsonRpcResult<IABIDecodedData>>(
|
|
706
|
+
"ptx_decodeError",
|
|
707
|
+
[revertError, dataFormat]
|
|
708
|
+
);
|
|
709
|
+
return res.data.result;
|
|
710
|
+
},
|
|
711
|
+
|
|
712
|
+
resolveVerifier: async (
|
|
713
|
+
lookup: string,
|
|
714
|
+
algorithm: Algorithms | string,
|
|
715
|
+
verifierType: Verifiers | string
|
|
716
|
+
) => {
|
|
717
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
718
|
+
"ptx_resolveVerifier",
|
|
719
|
+
[lookup, algorithm, verifierType]
|
|
720
|
+
);
|
|
721
|
+
return res.data.result;
|
|
722
|
+
},
|
|
723
|
+
|
|
724
|
+
createReceiptListener: async (listener: ITransactionReceiptListener) => {
|
|
725
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
726
|
+
"ptx_createReceiptListener",
|
|
727
|
+
[listener]
|
|
728
|
+
);
|
|
729
|
+
return res.data.result;
|
|
730
|
+
},
|
|
731
|
+
|
|
732
|
+
queryReceiptListeners: async (query: IQuery) => {
|
|
733
|
+
const res = await this.post<JsonRpcResult<ITransactionReceiptListener[]>>(
|
|
734
|
+
"ptx_queryReceiptListeners",
|
|
735
|
+
[query]
|
|
736
|
+
);
|
|
737
|
+
return res.data.result;
|
|
738
|
+
},
|
|
739
|
+
|
|
740
|
+
getReceiptListener: async (name: string) => {
|
|
741
|
+
const res = await this.post<JsonRpcResult<ITransactionReceiptListener>>(
|
|
742
|
+
"ptx_getReceiptListener",
|
|
743
|
+
[name],
|
|
744
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
745
|
+
);
|
|
746
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
747
|
+
},
|
|
748
|
+
|
|
749
|
+
startReceiptListener: async (name: string) => {
|
|
750
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
751
|
+
"ptx_startReceiptListener",
|
|
752
|
+
[name]
|
|
753
|
+
);
|
|
754
|
+
return res.data.result;
|
|
755
|
+
},
|
|
756
|
+
|
|
757
|
+
stopReceiptListener: async (name: string) => {
|
|
758
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
759
|
+
"ptx_stopReceiptListener",
|
|
760
|
+
[name]
|
|
761
|
+
);
|
|
762
|
+
return res.data.result;
|
|
763
|
+
},
|
|
764
|
+
|
|
765
|
+
deleteReceiptListener: async (name: string) => {
|
|
766
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
767
|
+
"ptx_deleteReceiptListener",
|
|
768
|
+
[name]
|
|
769
|
+
);
|
|
770
|
+
return res.data.result;
|
|
771
|
+
},
|
|
772
|
+
|
|
773
|
+
createBlockchainEventListener: async (
|
|
774
|
+
listener: IBlockchainEventListener
|
|
775
|
+
) => {
|
|
776
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
777
|
+
"ptx_createBlockchainEventListener",
|
|
778
|
+
[listener]
|
|
779
|
+
);
|
|
780
|
+
return res.data.result;
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
queryBlockchainEventListeners: async (query: IQuery) => {
|
|
784
|
+
const res = await this.post<JsonRpcResult<IBlockchainEventListener[]>>(
|
|
785
|
+
"ptx_queryBlockchainEventListeners",
|
|
786
|
+
[query]
|
|
787
|
+
);
|
|
788
|
+
return res.data.result;
|
|
789
|
+
},
|
|
790
|
+
|
|
791
|
+
getBlockchainEventListener: async (name: string) => {
|
|
792
|
+
const res = await this.post<JsonRpcResult<IBlockchainEventListener>>(
|
|
793
|
+
"ptx_getBlockchainEventListener",
|
|
794
|
+
[name],
|
|
795
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
796
|
+
);
|
|
797
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
798
|
+
},
|
|
799
|
+
|
|
800
|
+
startBlockchainEventListener: async (name: string) => {
|
|
801
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
802
|
+
"ptx_startBlockchainEventListener",
|
|
803
|
+
[name]
|
|
804
|
+
);
|
|
805
|
+
return res.data.result;
|
|
806
|
+
},
|
|
807
|
+
|
|
808
|
+
stopBlockchainEventListener: async (name: string) => {
|
|
809
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
810
|
+
"ptx_stopBlockchainEventListener",
|
|
811
|
+
[name]
|
|
812
|
+
);
|
|
813
|
+
return res.data.result;
|
|
814
|
+
},
|
|
815
|
+
|
|
816
|
+
deleteBlockchainEventListener: async (name: string) => {
|
|
817
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
818
|
+
"ptx_deleteBlockchainEventListener",
|
|
819
|
+
[name]
|
|
820
|
+
);
|
|
821
|
+
return res.data.result;
|
|
822
|
+
},
|
|
823
|
+
|
|
824
|
+
getBlockchainEventListenerStatus: async (name: string) => {
|
|
825
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
826
|
+
"ptx_getBlockchainEventListenerStatus",
|
|
827
|
+
[name],
|
|
828
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
829
|
+
);
|
|
830
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
831
|
+
},
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
pstate = {
|
|
835
|
+
listSchemas: async (domain: string) => {
|
|
836
|
+
const res = await this.post<JsonRpcResult<ISchema[]>>(
|
|
837
|
+
"pstate_listSchemas",
|
|
838
|
+
[domain]
|
|
839
|
+
);
|
|
840
|
+
return res.data.result;
|
|
841
|
+
},
|
|
842
|
+
|
|
843
|
+
getSchemaById: async (domain: string, schemaId: string) => {
|
|
844
|
+
const res = await this.post<JsonRpcResult<ISchema>>(
|
|
845
|
+
"pstate_getSchemaById",
|
|
846
|
+
[domain, schemaId],
|
|
847
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
848
|
+
);
|
|
849
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
850
|
+
},
|
|
851
|
+
|
|
852
|
+
storeState: async (
|
|
853
|
+
domain: string,
|
|
854
|
+
contractAddress: string,
|
|
855
|
+
schema: string,
|
|
856
|
+
data: any
|
|
857
|
+
) => {
|
|
858
|
+
const res = await this.post<JsonRpcResult<IState>>("pstate_storeState", [
|
|
859
|
+
domain,
|
|
860
|
+
contractAddress,
|
|
861
|
+
schema,
|
|
862
|
+
data,
|
|
863
|
+
]);
|
|
864
|
+
return res.data.result;
|
|
865
|
+
},
|
|
866
|
+
|
|
867
|
+
queryStates: async (
|
|
868
|
+
domain: string,
|
|
869
|
+
schema: string,
|
|
870
|
+
query: IQuery,
|
|
871
|
+
status: StateStatus
|
|
872
|
+
) => {
|
|
873
|
+
const res = await this.post<JsonRpcResult<IState[]>>(
|
|
874
|
+
"pstate_queryStates",
|
|
875
|
+
[domain, schema, query, status]
|
|
876
|
+
);
|
|
877
|
+
return res.data.result;
|
|
878
|
+
},
|
|
879
|
+
|
|
880
|
+
queryContractStates: async (
|
|
881
|
+
domain: string,
|
|
882
|
+
contractAddress: string,
|
|
883
|
+
schema: string,
|
|
884
|
+
query: IQuery,
|
|
885
|
+
status: StateStatus
|
|
886
|
+
) => {
|
|
887
|
+
const res = await this.post<JsonRpcResult<IState[]>>(
|
|
888
|
+
"pstate_queryContractStates",
|
|
889
|
+
[domain, contractAddress, schema, query, status]
|
|
890
|
+
);
|
|
891
|
+
return res.data.result;
|
|
892
|
+
},
|
|
893
|
+
|
|
894
|
+
queryNullifiers: async (
|
|
895
|
+
domain: string,
|
|
896
|
+
schema: string,
|
|
897
|
+
query: IQuery,
|
|
898
|
+
status: StateStatus
|
|
899
|
+
) => {
|
|
900
|
+
const res = await this.post<JsonRpcResult<IState[]>>(
|
|
901
|
+
"pstate_queryNullifiers",
|
|
902
|
+
[domain, schema, query, status]
|
|
903
|
+
);
|
|
904
|
+
return res.data.result;
|
|
905
|
+
},
|
|
906
|
+
|
|
907
|
+
queryContractNullifiers: async (
|
|
908
|
+
domain: string,
|
|
909
|
+
contractAddress: string,
|
|
910
|
+
schema: string,
|
|
911
|
+
query: IQuery,
|
|
912
|
+
status: StateStatus
|
|
913
|
+
) => {
|
|
914
|
+
const res = await this.post<JsonRpcResult<IState[]>>(
|
|
915
|
+
"pstate_queryContractNullifiers",
|
|
916
|
+
[domain, contractAddress, schema, query, status]
|
|
917
|
+
);
|
|
918
|
+
return res.data.result;
|
|
919
|
+
},
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
pgroup = {
|
|
923
|
+
createGroup: async (pgroup: IPrivacyGroupInput) => {
|
|
924
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroup>>(
|
|
925
|
+
"pgroup_createGroup",
|
|
926
|
+
[pgroup]
|
|
927
|
+
);
|
|
928
|
+
return res.data.result;
|
|
929
|
+
},
|
|
930
|
+
|
|
931
|
+
getGroupById: async (domainName: string, id: string) => {
|
|
932
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroup>>(
|
|
933
|
+
"pgroup_getGroupById",
|
|
934
|
+
[domainName, id]
|
|
935
|
+
);
|
|
936
|
+
return res.data.result;
|
|
937
|
+
},
|
|
938
|
+
|
|
939
|
+
getGroupByAddress: async (address: string) => {
|
|
940
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroup>>(
|
|
941
|
+
"pgroup_getGroupByAddress",
|
|
942
|
+
[address]
|
|
943
|
+
);
|
|
944
|
+
return res.data.result;
|
|
945
|
+
},
|
|
946
|
+
|
|
947
|
+
queryGroups: async (query: IQuery) => {
|
|
948
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroup[]>>(
|
|
949
|
+
"pgroup_queryGroups",
|
|
950
|
+
[query]
|
|
951
|
+
);
|
|
952
|
+
return res.data.result;
|
|
953
|
+
},
|
|
954
|
+
|
|
955
|
+
queryGroupsWithMember: async (member: string, query: IQuery) => {
|
|
956
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroup[]>>(
|
|
957
|
+
"pgroup_queryGroupsWithMember",
|
|
958
|
+
[member, query]
|
|
959
|
+
);
|
|
960
|
+
return res.data.result;
|
|
961
|
+
},
|
|
962
|
+
|
|
963
|
+
sendTransaction: async (txi: IPrivacyGroupEVMTXInput) => {
|
|
964
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
965
|
+
"pgroup_sendTransaction",
|
|
966
|
+
[txi]
|
|
967
|
+
);
|
|
968
|
+
return res.data.result;
|
|
969
|
+
},
|
|
970
|
+
|
|
971
|
+
call: async (txi: IPrivacyGroupEVMCall) => {
|
|
972
|
+
const res = await this.post<JsonRpcResult<any>>("pgroup_call", [txi]);
|
|
973
|
+
return res.data.result;
|
|
974
|
+
},
|
|
975
|
+
|
|
976
|
+
sendMessage: async (msg: IPrivacyGroupMessageInput) => {
|
|
977
|
+
const res = await this.post<JsonRpcResult<string>>("pgroup_sendMessage", [
|
|
978
|
+
msg,
|
|
979
|
+
]);
|
|
980
|
+
return res.data.result;
|
|
981
|
+
},
|
|
982
|
+
|
|
983
|
+
getMessageById: async (id: string) => {
|
|
984
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
985
|
+
"pgroup_getMessageById",
|
|
986
|
+
[id],
|
|
987
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
988
|
+
);
|
|
989
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
990
|
+
},
|
|
991
|
+
|
|
992
|
+
queryMessages: async (query: IQuery) => {
|
|
993
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
994
|
+
"pgroup_queryMessages",
|
|
995
|
+
[query]
|
|
996
|
+
);
|
|
997
|
+
return res.data.result;
|
|
998
|
+
},
|
|
999
|
+
|
|
1000
|
+
createMessageListener: async (listener: IPrivacyGroupMessageListener) => {
|
|
1001
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
1002
|
+
"pgroup_createMessageListener",
|
|
1003
|
+
[listener]
|
|
1004
|
+
);
|
|
1005
|
+
return res.data.result;
|
|
1006
|
+
},
|
|
1007
|
+
|
|
1008
|
+
queryMessageListeners: async (query: IQuery) => {
|
|
1009
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroupMessageListener[]>>(
|
|
1010
|
+
"pgroup_queryMessageListeners",
|
|
1011
|
+
[query]
|
|
1012
|
+
);
|
|
1013
|
+
return res.data.result;
|
|
1014
|
+
},
|
|
1015
|
+
|
|
1016
|
+
getMessageListener: async (name: string) => {
|
|
1017
|
+
const res = await this.post<JsonRpcResult<IPrivacyGroupMessageListener>>(
|
|
1018
|
+
"pgroup_getMessageListener",
|
|
1019
|
+
[name],
|
|
1020
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1021
|
+
);
|
|
1022
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1023
|
+
},
|
|
1024
|
+
|
|
1025
|
+
startMessageListener: async (name: string) => {
|
|
1026
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
1027
|
+
"pgroup_startMessageListener",
|
|
1028
|
+
[name]
|
|
1029
|
+
);
|
|
1030
|
+
return res.data.result;
|
|
1031
|
+
},
|
|
1032
|
+
|
|
1033
|
+
stopMessageListener: async (name: string) => {
|
|
1034
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
1035
|
+
"pgroup_stopMessageListener",
|
|
1036
|
+
[name]
|
|
1037
|
+
);
|
|
1038
|
+
return res.data.result;
|
|
1039
|
+
},
|
|
1040
|
+
|
|
1041
|
+
deleteMessageListener: async (name: string) => {
|
|
1042
|
+
const res = await this.post<JsonRpcResult<boolean>>(
|
|
1043
|
+
"pgroup_deleteMessageListener",
|
|
1044
|
+
[name]
|
|
1045
|
+
);
|
|
1046
|
+
return res.data.result;
|
|
1047
|
+
},
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
transport = {
|
|
1051
|
+
nodeName: async () => {
|
|
1052
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
1053
|
+
"transport_nodeName",
|
|
1054
|
+
[]
|
|
1055
|
+
);
|
|
1056
|
+
return res.data.result;
|
|
1057
|
+
},
|
|
1058
|
+
|
|
1059
|
+
localTransports: async () => {
|
|
1060
|
+
const res = await this.post<JsonRpcResult<string[]>>(
|
|
1061
|
+
"transport_localTransports",
|
|
1062
|
+
[]
|
|
1063
|
+
);
|
|
1064
|
+
return res.data.result;
|
|
1065
|
+
},
|
|
1066
|
+
|
|
1067
|
+
localTransportDetails: async (transportName: string) => {
|
|
1068
|
+
const res = await this.post<JsonRpcResult<string>>(
|
|
1069
|
+
"transport_localTransportDetails",
|
|
1070
|
+
[transportName]
|
|
1071
|
+
);
|
|
1072
|
+
return res.data.result;
|
|
1073
|
+
},
|
|
1074
|
+
|
|
1075
|
+
peers: async () => {
|
|
1076
|
+
const res = await this.post<JsonRpcResult<any[]>>("transport_peers", []);
|
|
1077
|
+
return res.data.result;
|
|
1078
|
+
},
|
|
1079
|
+
|
|
1080
|
+
peerInfo: async (nodeName: string) => {
|
|
1081
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1082
|
+
"transport_peerInfo",
|
|
1083
|
+
[nodeName],
|
|
1084
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1085
|
+
);
|
|
1086
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1087
|
+
},
|
|
1088
|
+
|
|
1089
|
+
queryReliableMessages: async (query: IQuery) => {
|
|
1090
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1091
|
+
"transport_queryReliableMessages",
|
|
1092
|
+
[query]
|
|
1093
|
+
);
|
|
1094
|
+
return res.data.result;
|
|
1095
|
+
},
|
|
1096
|
+
|
|
1097
|
+
queryReliableMessageAcks: async (query: IQuery) => {
|
|
1098
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1099
|
+
"transport_queryReliableMessageAcks",
|
|
1100
|
+
[query]
|
|
1101
|
+
);
|
|
1102
|
+
return res.data.result;
|
|
1103
|
+
},
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
domain = {
|
|
1107
|
+
listDomains: async () => {
|
|
1108
|
+
const res = await this.post<JsonRpcResult<string[]>>(
|
|
1109
|
+
"domain_listDomains",
|
|
1110
|
+
[]
|
|
1111
|
+
);
|
|
1112
|
+
return res.data.result;
|
|
1113
|
+
},
|
|
1114
|
+
|
|
1115
|
+
getDomain: async (name: string) => {
|
|
1116
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1117
|
+
"domain_getDomain",
|
|
1118
|
+
[name],
|
|
1119
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1120
|
+
);
|
|
1121
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1122
|
+
},
|
|
1123
|
+
|
|
1124
|
+
getDomainByAddress: async (address: string) => {
|
|
1125
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1126
|
+
"domain_getDomainByAddress",
|
|
1127
|
+
[address],
|
|
1128
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1129
|
+
);
|
|
1130
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1131
|
+
},
|
|
1132
|
+
|
|
1133
|
+
querySmartContracts: async (query: IQuery) => {
|
|
1134
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1135
|
+
"domain_querySmartContracts",
|
|
1136
|
+
[query]
|
|
1137
|
+
);
|
|
1138
|
+
return res.data.result;
|
|
1139
|
+
},
|
|
1140
|
+
|
|
1141
|
+
getSmartContractByAddress: async (address: string) => {
|
|
1142
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1143
|
+
"domain_getSmartContractByAddress",
|
|
1144
|
+
[address],
|
|
1145
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1146
|
+
);
|
|
1147
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1148
|
+
},
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
bidx = {
|
|
1152
|
+
getBlockByNumber: async (number: number) => {
|
|
1153
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1154
|
+
"bidx_getBlockByNumber",
|
|
1155
|
+
[number],
|
|
1156
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1157
|
+
);
|
|
1158
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1159
|
+
},
|
|
1160
|
+
|
|
1161
|
+
getTransactionByHash: async (hash: string) => {
|
|
1162
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1163
|
+
"bidx_getTransactionByHash",
|
|
1164
|
+
[hash],
|
|
1165
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1166
|
+
);
|
|
1167
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1168
|
+
},
|
|
1169
|
+
|
|
1170
|
+
getTransactionByNonce: async (from: string, nonce: number) => {
|
|
1171
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1172
|
+
"bidx_getTransactionByNonce",
|
|
1173
|
+
[from, nonce],
|
|
1174
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1175
|
+
);
|
|
1176
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1177
|
+
},
|
|
1178
|
+
|
|
1179
|
+
getBlockTransactionsByNumber: async (blockNumber: number) => {
|
|
1180
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1181
|
+
"bidx_getBlockTransactionsByNumber",
|
|
1182
|
+
[blockNumber]
|
|
1183
|
+
);
|
|
1184
|
+
return res.data.result;
|
|
1185
|
+
},
|
|
1186
|
+
|
|
1187
|
+
getTransactionEventsByHash: async (hash: string) => {
|
|
1188
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1189
|
+
"bidx_getTransactionEventsByHash",
|
|
1190
|
+
[hash]
|
|
1191
|
+
);
|
|
1192
|
+
return res.data.result;
|
|
1193
|
+
},
|
|
1194
|
+
|
|
1195
|
+
queryIndexedBlocks: async (query: IQuery) => {
|
|
1196
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1197
|
+
"bidx_queryIndexedBlocks",
|
|
1198
|
+
[query]
|
|
1199
|
+
);
|
|
1200
|
+
return res.data.result;
|
|
1201
|
+
},
|
|
1202
|
+
|
|
1203
|
+
queryIndexedTransactions: async (query: IQuery) => {
|
|
1204
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1205
|
+
"bidx_queryIndexedTransactions",
|
|
1206
|
+
[query]
|
|
1207
|
+
);
|
|
1208
|
+
return res.data.result;
|
|
1209
|
+
},
|
|
1210
|
+
|
|
1211
|
+
queryIndexedEvents: async (query: IQuery) => {
|
|
1212
|
+
const res = await this.post<JsonRpcResult<any[]>>(
|
|
1213
|
+
"bidx_queryIndexedEvents",
|
|
1214
|
+
[query]
|
|
1215
|
+
);
|
|
1216
|
+
return res.data.result;
|
|
1217
|
+
},
|
|
1218
|
+
|
|
1219
|
+
getConfirmedBlockHeight: async () => {
|
|
1220
|
+
const res = await this.post<JsonRpcResult<number>>(
|
|
1221
|
+
"bidx_getConfirmedBlockHeight",
|
|
1222
|
+
[]
|
|
1223
|
+
);
|
|
1224
|
+
return res.data.result;
|
|
1225
|
+
},
|
|
1226
|
+
|
|
1227
|
+
decodeTransactionEvents: async (
|
|
1228
|
+
transactionHash: string,
|
|
1229
|
+
abi: InterfaceAbi,
|
|
1230
|
+
resultFormat: string
|
|
1231
|
+
) => {
|
|
1232
|
+
const res = await this.post<JsonRpcResult<IEventWithData[]>>(
|
|
1233
|
+
"bidx_decodeTransactionEvents",
|
|
1234
|
+
[transactionHash, abi, resultFormat]
|
|
1235
|
+
);
|
|
1236
|
+
return res.data.result;
|
|
1237
|
+
},
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
debug = {
|
|
1241
|
+
getTransactionStatus: async (txID: string) => {
|
|
1242
|
+
const res = await this.post<JsonRpcResult<any>>(
|
|
1243
|
+
"debug_getTransactionStatus",
|
|
1244
|
+
[txID],
|
|
1245
|
+
{ validateStatus: (status) => status < 300 || status === 404 }
|
|
1246
|
+
);
|
|
1247
|
+
return res.status === 404 ? undefined : res.data.result;
|
|
1248
|
+
},
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
reg = {
|
|
1252
|
+
registries: async () => {
|
|
1253
|
+
const res = await this.post<JsonRpcResult<string[]>>(
|
|
1254
|
+
"reg_registries",
|
|
1255
|
+
[]
|
|
1256
|
+
);
|
|
1257
|
+
return res.data.result;
|
|
1258
|
+
},
|
|
1259
|
+
|
|
1260
|
+
queryEntries: async (
|
|
1261
|
+
registryName: string,
|
|
1262
|
+
query: IQuery,
|
|
1263
|
+
activeFilter: ActiveFilter
|
|
1264
|
+
) => {
|
|
1265
|
+
const res = await this.post<JsonRpcResult<IRegistryEntry[]>>(
|
|
1266
|
+
"reg_queryEntries",
|
|
1267
|
+
[registryName, query, activeFilter]
|
|
1268
|
+
);
|
|
1269
|
+
return res.data.result;
|
|
1270
|
+
},
|
|
1271
|
+
|
|
1272
|
+
queryEntriesWithProps: async (
|
|
1273
|
+
registryName: string,
|
|
1274
|
+
query: IQuery,
|
|
1275
|
+
activeFilter: ActiveFilter
|
|
1276
|
+
) => {
|
|
1277
|
+
const res = await this.post<
|
|
1278
|
+
JsonRpcResult<IRegistryEntryWithProperties[]>
|
|
1279
|
+
>("reg_queryEntriesWithProps", [registryName, query, activeFilter]);
|
|
1280
|
+
return res.data.result;
|
|
1281
|
+
},
|
|
1282
|
+
|
|
1283
|
+
getEntryProperties: async (
|
|
1284
|
+
registryName: string,
|
|
1285
|
+
entryId: string,
|
|
1286
|
+
activeFilter: ActiveFilter
|
|
1287
|
+
) => {
|
|
1288
|
+
const res = await this.post<JsonRpcResult<IRegistryProperty[]>>(
|
|
1289
|
+
"reg_getEntryProperties",
|
|
1290
|
+
[registryName, entryId, activeFilter]
|
|
1291
|
+
);
|
|
1292
|
+
return res.data.result;
|
|
1293
|
+
},
|
|
1294
|
+
};
|
|
1295
|
+
}
|