@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.
Files changed (88) hide show
  1. package/README.md +21 -0
  2. package/build/domains/abis/INoto.json +448 -0
  3. package/build/domains/abis/INotoPrivate.json +347 -0
  4. package/build/domains/abis/IZetoFungible.json +197 -0
  5. package/build/domains/abis/PentePrivacyGroup.json +613 -0
  6. package/build/domains/abis/Zeto_Anon.json +1263 -0
  7. package/build/domains/noto.d.ts +117 -0
  8. package/build/domains/noto.js +292 -0
  9. package/build/domains/pente.d.ts +84 -0
  10. package/build/domains/pente.js +191 -0
  11. package/build/domains/zeto.d.ts +83 -0
  12. package/build/domains/zeto.js +201 -0
  13. package/build/index.d.ts +9 -0
  14. package/build/index.js +28 -0
  15. package/build/interfaces/algorithms.d.ts +3 -0
  16. package/build/interfaces/algorithms.js +9 -0
  17. package/build/interfaces/blockchainevent.d.ts +15 -0
  18. package/build/interfaces/blockchainevent.js +2 -0
  19. package/build/interfaces/blockindex.d.ts +30 -0
  20. package/build/interfaces/blockindex.js +2 -0
  21. package/build/interfaces/domains.d.ts +9 -0
  22. package/build/interfaces/domains.js +2 -0
  23. package/build/interfaces/index.d.ts +15 -0
  24. package/build/interfaces/index.js +31 -0
  25. package/build/interfaces/keymanager.d.ts +32 -0
  26. package/build/interfaces/keymanager.js +2 -0
  27. package/build/interfaces/logger.d.ts +8 -0
  28. package/build/interfaces/logger.js +2 -0
  29. package/build/interfaces/paladin.d.ts +14 -0
  30. package/build/interfaces/paladin.js +2 -0
  31. package/build/interfaces/privacygroups.d.ts +76 -0
  32. package/build/interfaces/privacygroups.js +2 -0
  33. package/build/interfaces/query.d.ts +33 -0
  34. package/build/interfaces/query.js +2 -0
  35. package/build/interfaces/registry.d.ts +26 -0
  36. package/build/interfaces/registry.js +2 -0
  37. package/build/interfaces/states.d.ts +61 -0
  38. package/build/interfaces/states.js +2 -0
  39. package/build/interfaces/transaction.d.ts +159 -0
  40. package/build/interfaces/transaction.js +12 -0
  41. package/build/interfaces/transport.d.ts +32 -0
  42. package/build/interfaces/transport.js +2 -0
  43. package/build/interfaces/verifiers.d.ts +6 -0
  44. package/build/interfaces/verifiers.js +10 -0
  45. package/build/interfaces/websocket.d.ts +57 -0
  46. package/build/interfaces/websocket.js +2 -0
  47. package/build/paladin.d.ts +265 -0
  48. package/build/paladin.js +739 -0
  49. package/build/transaction.d.ts +8 -0
  50. package/build/transaction.js +17 -0
  51. package/build/utils.d.ts +5 -0
  52. package/build/utils.js +49 -0
  53. package/build/verifier.d.ts +16 -0
  54. package/build/verifier.js +24 -0
  55. package/build/websocket.d.ts +35 -0
  56. package/build/websocket.js +177 -0
  57. package/build.gradle +75 -0
  58. package/package.json +32 -0
  59. package/scripts/abi.mjs +19 -0
  60. package/scripts/contracts.mjs +20 -0
  61. package/scripts/download.mjs +27 -0
  62. package/scripts/util.mjs +42 -0
  63. package/src/domains/noto.ts +420 -0
  64. package/src/domains/pente.ts +287 -0
  65. package/src/domains/zeto.ts +282 -0
  66. package/src/index.ts +10 -0
  67. package/src/interfaces/algorithms.ts +6 -0
  68. package/src/interfaces/blockchainevent.ts +18 -0
  69. package/src/interfaces/blockindex.ts +33 -0
  70. package/src/interfaces/domains.ts +10 -0
  71. package/src/interfaces/index.ts +15 -0
  72. package/src/interfaces/keymanager.ts +35 -0
  73. package/src/interfaces/logger.ts +8 -0
  74. package/src/interfaces/paladin.ts +17 -0
  75. package/src/interfaces/privacygroups.ts +86 -0
  76. package/src/interfaces/query.ts +37 -0
  77. package/src/interfaces/registry.ts +27 -0
  78. package/src/interfaces/states.ts +77 -0
  79. package/src/interfaces/transaction.ts +179 -0
  80. package/src/interfaces/transport.ts +35 -0
  81. package/src/interfaces/verifiers.ts +6 -0
  82. package/src/interfaces/websocket.ts +67 -0
  83. package/src/paladin.ts +1295 -0
  84. package/src/transaction.ts +17 -0
  85. package/src/utils.ts +24 -0
  86. package/src/verifier.ts +27 -0
  87. package/src/websocket.ts +217 -0
  88. package/tsconfig.json +14 -0
@@ -0,0 +1,739 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const axios_1 = __importStar(require("axios"));
27
+ const verifier_1 = require("./verifier");
28
+ const POLL_INTERVAL_MS = 100;
29
+ class PaladinClient {
30
+ constructor(options) {
31
+ this.keymgr = {
32
+ wallets: async () => {
33
+ const res = await this.post("keymgr_wallets", []);
34
+ return res.data.result;
35
+ },
36
+ resolveKey: async (identifier, algorithm, verifierType) => {
37
+ const res = await this.post("keymgr_resolveKey", [identifier, algorithm, verifierType]);
38
+ return res.data.result;
39
+ },
40
+ resolveEthAddress: async (identifier) => {
41
+ const res = await this.post("keymgr_resolveEthAddress", [identifier]);
42
+ return res.data.result;
43
+ },
44
+ reverseKeyLookup: async (algorithm, verifierType, verifier) => {
45
+ const res = await this.post("keymgr_reverseKeyLookup", [algorithm, verifierType, verifier]);
46
+ return res.data.result;
47
+ },
48
+ queryKeys: async (query) => {
49
+ const res = await this.post("keymgr_queryKeys", [query]);
50
+ return res.data.result;
51
+ },
52
+ };
53
+ this.ptx = {
54
+ sendTransaction: async (transaction) => {
55
+ const res = await this.post("ptx_sendTransaction", [transaction], undefined);
56
+ return res.data.result;
57
+ },
58
+ sendTransactions: async (transactions) => {
59
+ const res = await this.post("ptx_sendTransactions", [transactions], undefined);
60
+ return res.data.result;
61
+ },
62
+ prepareTransaction: async (transaction) => {
63
+ const res = await this.post("ptx_prepareTransaction", [transaction], undefined);
64
+ return res.data.result;
65
+ },
66
+ prepareTransactions: async (transactions) => {
67
+ const res = await this.post("ptx_prepareTransactions", [transactions], undefined);
68
+ return res.data.result;
69
+ },
70
+ updateTransaction: async (id, transaction) => {
71
+ const res = await this.post("ptx_updateTransaction", [id, transaction], undefined);
72
+ return res.data.result;
73
+ },
74
+ call: async (transaction) => {
75
+ const res = await this.post("ptx_call", [
76
+ transaction,
77
+ ]);
78
+ return res.data.result;
79
+ },
80
+ getTransaction: async (txID) => {
81
+ const res = await this.post("ptx_getTransaction", [txID], {
82
+ validateStatus: (status) => status < 300 || status === 404,
83
+ });
84
+ return res.status === 404 ? undefined : res.data.result;
85
+ },
86
+ getTransactionFull: async (txID) => {
87
+ const res = await this.post("ptx_getTransactionFull", [txID], {
88
+ validateStatus: (status) => status < 300 || status === 404,
89
+ });
90
+ return res.status === 404 ? undefined : res.data.result;
91
+ },
92
+ getTransactionByIdempotencyKey: async (idempotencyKey) => {
93
+ const res = await this.post("ptx_getTransactionByIdempotencyKey", [idempotencyKey], {
94
+ validateStatus: (status) => status < 300 || status === 404,
95
+ });
96
+ return res.status === 404 ? undefined : res.data.result;
97
+ },
98
+ queryTransactions: async (query) => {
99
+ const res = await this.post("ptx_queryTransactions", [query]);
100
+ return res.data.result;
101
+ },
102
+ queryTransactionsFull: async (query) => {
103
+ const res = await this.post("ptx_queryTransactionsFull", [query]);
104
+ return res.data.result;
105
+ },
106
+ queryPendingTransactions: async (query, full) => {
107
+ const res = await this.post("ptx_queryPendingTransactions", [query, full]);
108
+ return res.data.result;
109
+ },
110
+ getTransactionReceipt: async (txID) => {
111
+ const res = await this.post("ptx_getTransactionReceipt", [txID], {
112
+ validateStatus: (status) => status < 300 || status === 404,
113
+ });
114
+ return res.status === 404 ? undefined : res.data.result;
115
+ },
116
+ getTransactionReceiptFull: async (txID) => {
117
+ const res = await this.post("ptx_getTransactionReceiptFull", [txID], {
118
+ validateStatus: (status) => status < 300 || status === 404,
119
+ });
120
+ return res.status === 404 ? undefined : res.data.result;
121
+ },
122
+ getDomainReceipt: async (domain, txID) => {
123
+ const res = await this.post("ptx_getDomainReceipt", [domain, txID], {
124
+ validateStatus: (status) => status < 300 || status === 404,
125
+ });
126
+ return res.status === 404 ? undefined : res.data.result;
127
+ },
128
+ getStateReceipt: async (txID) => {
129
+ const res = await this.post("ptx_getStateReceipt", [txID], {
130
+ validateStatus: (status) => status < 300 || status === 404,
131
+ });
132
+ return res.status === 404 ? undefined : res.data.result;
133
+ },
134
+ queryTransactionReceipts: async (query) => {
135
+ const res = await this.post("ptx_queryTransactionReceipts", [query]);
136
+ return res.data.result;
137
+ },
138
+ getTransactionDependencies: async (txID) => {
139
+ const res = await this.post("ptx_getTransactionDependencies", [txID], {
140
+ validateStatus: (status) => status < 300 || status === 404,
141
+ });
142
+ return res.status === 404 ? undefined : res.data.result;
143
+ },
144
+ queryPublicTransactions: async (query) => {
145
+ const res = await this.post("ptx_queryPublicTransactions", [query]);
146
+ return res.data.result;
147
+ },
148
+ queryPendingPublicTransactions: async (query) => {
149
+ const res = await this.post("ptx_queryPendingPublicTransactions", [query]);
150
+ return res.data.result;
151
+ },
152
+ getPublicTransactionByNonce: async (from, nonce) => {
153
+ const res = await this.post("ptx_getPublicTransactionByNonce", [from, nonce], {
154
+ validateStatus: (status) => status < 300 || status === 404,
155
+ });
156
+ return res.status === 404 ? undefined : res.data.result;
157
+ },
158
+ getPublicTransactionByHash: async (hash) => {
159
+ const res = await this.post("ptx_getPublicTransactionByHash", [hash], {
160
+ validateStatus: (status) => status < 300 || status === 404,
161
+ });
162
+ return res.status === 404 ? undefined : res.data.result;
163
+ },
164
+ getPreparedTransaction: async (txID) => {
165
+ const res = await this.post("ptx_getPreparedTransaction", [txID], {
166
+ validateStatus: (status) => status < 300 || status === 404,
167
+ });
168
+ return res.status === 404 ? undefined : res.data.result;
169
+ },
170
+ queryPreparedTransactions: async (query) => {
171
+ const res = await this.post("ptx_queryPreparedTransactions", [query]);
172
+ return res.data.result;
173
+ },
174
+ storeABI: async (abi) => {
175
+ await this.post("ptx_storeABI", [abi]);
176
+ },
177
+ getStoredABI: async (hash) => {
178
+ const res = await this.post("ptx_getStoredABI", [hash]);
179
+ return res.data.result;
180
+ },
181
+ queryStoredABIs: async (query) => {
182
+ const res = await this.post("ptx_queryStoredABIs", [query]);
183
+ return res.data.result;
184
+ },
185
+ decodeCall: async (callData, dataFormat) => {
186
+ const res = await this.post("ptx_decodeCall", [callData, dataFormat]);
187
+ return res.data.result;
188
+ },
189
+ decodeEvent: async (topics, data) => {
190
+ try {
191
+ const res = await this.post("ptx_decodeEvent", [topics, data, ""]);
192
+ return res.data.result;
193
+ }
194
+ catch (err) {
195
+ const parsed = this.parseAxiosErrorMessage(err);
196
+ if (typeof parsed === "string" && parsed.indexOf("PD012229") >= 0) {
197
+ return undefined;
198
+ }
199
+ throw err;
200
+ }
201
+ },
202
+ decodeError: async (revertError, dataFormat) => {
203
+ const res = await this.post("ptx_decodeError", [revertError, dataFormat]);
204
+ return res.data.result;
205
+ },
206
+ resolveVerifier: async (lookup, algorithm, verifierType) => {
207
+ const res = await this.post("ptx_resolveVerifier", [lookup, algorithm, verifierType]);
208
+ return res.data.result;
209
+ },
210
+ createReceiptListener: async (listener) => {
211
+ const res = await this.post("ptx_createReceiptListener", [listener]);
212
+ return res.data.result;
213
+ },
214
+ queryReceiptListeners: async (query) => {
215
+ const res = await this.post("ptx_queryReceiptListeners", [query]);
216
+ return res.data.result;
217
+ },
218
+ getReceiptListener: async (name) => {
219
+ const res = await this.post("ptx_getReceiptListener", [name], { validateStatus: (status) => status < 300 || status === 404 });
220
+ return res.status === 404 ? undefined : res.data.result;
221
+ },
222
+ startReceiptListener: async (name) => {
223
+ const res = await this.post("ptx_startReceiptListener", [name]);
224
+ return res.data.result;
225
+ },
226
+ stopReceiptListener: async (name) => {
227
+ const res = await this.post("ptx_stopReceiptListener", [name]);
228
+ return res.data.result;
229
+ },
230
+ deleteReceiptListener: async (name) => {
231
+ const res = await this.post("ptx_deleteReceiptListener", [name]);
232
+ return res.data.result;
233
+ },
234
+ createBlockchainEventListener: async (listener) => {
235
+ const res = await this.post("ptx_createBlockchainEventListener", [listener]);
236
+ return res.data.result;
237
+ },
238
+ queryBlockchainEventListeners: async (query) => {
239
+ const res = await this.post("ptx_queryBlockchainEventListeners", [query]);
240
+ return res.data.result;
241
+ },
242
+ getBlockchainEventListener: async (name) => {
243
+ const res = await this.post("ptx_getBlockchainEventListener", [name], { validateStatus: (status) => status < 300 || status === 404 });
244
+ return res.status === 404 ? undefined : res.data.result;
245
+ },
246
+ startBlockchainEventListener: async (name) => {
247
+ const res = await this.post("ptx_startBlockchainEventListener", [name]);
248
+ return res.data.result;
249
+ },
250
+ stopBlockchainEventListener: async (name) => {
251
+ const res = await this.post("ptx_stopBlockchainEventListener", [name]);
252
+ return res.data.result;
253
+ },
254
+ deleteBlockchainEventListener: async (name) => {
255
+ const res = await this.post("ptx_deleteBlockchainEventListener", [name]);
256
+ return res.data.result;
257
+ },
258
+ getBlockchainEventListenerStatus: async (name) => {
259
+ const res = await this.post("ptx_getBlockchainEventListenerStatus", [name], { validateStatus: (status) => status < 300 || status === 404 });
260
+ return res.status === 404 ? undefined : res.data.result;
261
+ },
262
+ };
263
+ this.pstate = {
264
+ listSchemas: async (domain) => {
265
+ const res = await this.post("pstate_listSchemas", [domain]);
266
+ return res.data.result;
267
+ },
268
+ getSchemaById: async (domain, schemaId) => {
269
+ const res = await this.post("pstate_getSchemaById", [domain, schemaId], { validateStatus: (status) => status < 300 || status === 404 });
270
+ return res.status === 404 ? undefined : res.data.result;
271
+ },
272
+ storeState: async (domain, contractAddress, schema, data) => {
273
+ const res = await this.post("pstate_storeState", [
274
+ domain,
275
+ contractAddress,
276
+ schema,
277
+ data,
278
+ ]);
279
+ return res.data.result;
280
+ },
281
+ queryStates: async (domain, schema, query, status) => {
282
+ const res = await this.post("pstate_queryStates", [domain, schema, query, status]);
283
+ return res.data.result;
284
+ },
285
+ queryContractStates: async (domain, contractAddress, schema, query, status) => {
286
+ const res = await this.post("pstate_queryContractStates", [domain, contractAddress, schema, query, status]);
287
+ return res.data.result;
288
+ },
289
+ queryNullifiers: async (domain, schema, query, status) => {
290
+ const res = await this.post("pstate_queryNullifiers", [domain, schema, query, status]);
291
+ return res.data.result;
292
+ },
293
+ queryContractNullifiers: async (domain, contractAddress, schema, query, status) => {
294
+ const res = await this.post("pstate_queryContractNullifiers", [domain, contractAddress, schema, query, status]);
295
+ return res.data.result;
296
+ },
297
+ };
298
+ this.pgroup = {
299
+ createGroup: async (pgroup) => {
300
+ const res = await this.post("pgroup_createGroup", [pgroup]);
301
+ return res.data.result;
302
+ },
303
+ getGroupById: async (domainName, id) => {
304
+ const res = await this.post("pgroup_getGroupById", [domainName, id]);
305
+ return res.data.result;
306
+ },
307
+ getGroupByAddress: async (address) => {
308
+ const res = await this.post("pgroup_getGroupByAddress", [address]);
309
+ return res.data.result;
310
+ },
311
+ queryGroups: async (query) => {
312
+ const res = await this.post("pgroup_queryGroups", [query]);
313
+ return res.data.result;
314
+ },
315
+ queryGroupsWithMember: async (member, query) => {
316
+ const res = await this.post("pgroup_queryGroupsWithMember", [member, query]);
317
+ return res.data.result;
318
+ },
319
+ sendTransaction: async (txi) => {
320
+ const res = await this.post("pgroup_sendTransaction", [txi]);
321
+ return res.data.result;
322
+ },
323
+ call: async (txi) => {
324
+ const res = await this.post("pgroup_call", [txi]);
325
+ return res.data.result;
326
+ },
327
+ sendMessage: async (msg) => {
328
+ const res = await this.post("pgroup_sendMessage", [
329
+ msg,
330
+ ]);
331
+ return res.data.result;
332
+ },
333
+ getMessageById: async (id) => {
334
+ const res = await this.post("pgroup_getMessageById", [id], { validateStatus: (status) => status < 300 || status === 404 });
335
+ return res.status === 404 ? undefined : res.data.result;
336
+ },
337
+ queryMessages: async (query) => {
338
+ const res = await this.post("pgroup_queryMessages", [query]);
339
+ return res.data.result;
340
+ },
341
+ createMessageListener: async (listener) => {
342
+ const res = await this.post("pgroup_createMessageListener", [listener]);
343
+ return res.data.result;
344
+ },
345
+ queryMessageListeners: async (query) => {
346
+ const res = await this.post("pgroup_queryMessageListeners", [query]);
347
+ return res.data.result;
348
+ },
349
+ getMessageListener: async (name) => {
350
+ const res = await this.post("pgroup_getMessageListener", [name], { validateStatus: (status) => status < 300 || status === 404 });
351
+ return res.status === 404 ? undefined : res.data.result;
352
+ },
353
+ startMessageListener: async (name) => {
354
+ const res = await this.post("pgroup_startMessageListener", [name]);
355
+ return res.data.result;
356
+ },
357
+ stopMessageListener: async (name) => {
358
+ const res = await this.post("pgroup_stopMessageListener", [name]);
359
+ return res.data.result;
360
+ },
361
+ deleteMessageListener: async (name) => {
362
+ const res = await this.post("pgroup_deleteMessageListener", [name]);
363
+ return res.data.result;
364
+ },
365
+ };
366
+ this.transport = {
367
+ nodeName: async () => {
368
+ const res = await this.post("transport_nodeName", []);
369
+ return res.data.result;
370
+ },
371
+ localTransports: async () => {
372
+ const res = await this.post("transport_localTransports", []);
373
+ return res.data.result;
374
+ },
375
+ localTransportDetails: async (transportName) => {
376
+ const res = await this.post("transport_localTransportDetails", [transportName]);
377
+ return res.data.result;
378
+ },
379
+ peers: async () => {
380
+ const res = await this.post("transport_peers", []);
381
+ return res.data.result;
382
+ },
383
+ peerInfo: async (nodeName) => {
384
+ const res = await this.post("transport_peerInfo", [nodeName], { validateStatus: (status) => status < 300 || status === 404 });
385
+ return res.status === 404 ? undefined : res.data.result;
386
+ },
387
+ queryReliableMessages: async (query) => {
388
+ const res = await this.post("transport_queryReliableMessages", [query]);
389
+ return res.data.result;
390
+ },
391
+ queryReliableMessageAcks: async (query) => {
392
+ const res = await this.post("transport_queryReliableMessageAcks", [query]);
393
+ return res.data.result;
394
+ },
395
+ };
396
+ this.domain = {
397
+ listDomains: async () => {
398
+ const res = await this.post("domain_listDomains", []);
399
+ return res.data.result;
400
+ },
401
+ getDomain: async (name) => {
402
+ const res = await this.post("domain_getDomain", [name], { validateStatus: (status) => status < 300 || status === 404 });
403
+ return res.status === 404 ? undefined : res.data.result;
404
+ },
405
+ getDomainByAddress: async (address) => {
406
+ const res = await this.post("domain_getDomainByAddress", [address], { validateStatus: (status) => status < 300 || status === 404 });
407
+ return res.status === 404 ? undefined : res.data.result;
408
+ },
409
+ querySmartContracts: async (query) => {
410
+ const res = await this.post("domain_querySmartContracts", [query]);
411
+ return res.data.result;
412
+ },
413
+ getSmartContractByAddress: async (address) => {
414
+ const res = await this.post("domain_getSmartContractByAddress", [address], { validateStatus: (status) => status < 300 || status === 404 });
415
+ return res.status === 404 ? undefined : res.data.result;
416
+ },
417
+ };
418
+ this.bidx = {
419
+ getBlockByNumber: async (number) => {
420
+ const res = await this.post("bidx_getBlockByNumber", [number], { validateStatus: (status) => status < 300 || status === 404 });
421
+ return res.status === 404 ? undefined : res.data.result;
422
+ },
423
+ getTransactionByHash: async (hash) => {
424
+ const res = await this.post("bidx_getTransactionByHash", [hash], { validateStatus: (status) => status < 300 || status === 404 });
425
+ return res.status === 404 ? undefined : res.data.result;
426
+ },
427
+ getTransactionByNonce: async (from, nonce) => {
428
+ const res = await this.post("bidx_getTransactionByNonce", [from, nonce], { validateStatus: (status) => status < 300 || status === 404 });
429
+ return res.status === 404 ? undefined : res.data.result;
430
+ },
431
+ getBlockTransactionsByNumber: async (blockNumber) => {
432
+ const res = await this.post("bidx_getBlockTransactionsByNumber", [blockNumber]);
433
+ return res.data.result;
434
+ },
435
+ getTransactionEventsByHash: async (hash) => {
436
+ const res = await this.post("bidx_getTransactionEventsByHash", [hash]);
437
+ return res.data.result;
438
+ },
439
+ queryIndexedBlocks: async (query) => {
440
+ const res = await this.post("bidx_queryIndexedBlocks", [query]);
441
+ return res.data.result;
442
+ },
443
+ queryIndexedTransactions: async (query) => {
444
+ const res = await this.post("bidx_queryIndexedTransactions", [query]);
445
+ return res.data.result;
446
+ },
447
+ queryIndexedEvents: async (query) => {
448
+ const res = await this.post("bidx_queryIndexedEvents", [query]);
449
+ return res.data.result;
450
+ },
451
+ getConfirmedBlockHeight: async () => {
452
+ const res = await this.post("bidx_getConfirmedBlockHeight", []);
453
+ return res.data.result;
454
+ },
455
+ decodeTransactionEvents: async (transactionHash, abi, resultFormat) => {
456
+ const res = await this.post("bidx_decodeTransactionEvents", [transactionHash, abi, resultFormat]);
457
+ return res.data.result;
458
+ },
459
+ };
460
+ this.debug = {
461
+ getTransactionStatus: async (txID) => {
462
+ const res = await this.post("debug_getTransactionStatus", [txID], { validateStatus: (status) => status < 300 || status === 404 });
463
+ return res.status === 404 ? undefined : res.data.result;
464
+ },
465
+ };
466
+ this.reg = {
467
+ registries: async () => {
468
+ const res = await this.post("reg_registries", []);
469
+ return res.data.result;
470
+ },
471
+ queryEntries: async (registryName, query, activeFilter) => {
472
+ const res = await this.post("reg_queryEntries", [registryName, query, activeFilter]);
473
+ return res.data.result;
474
+ },
475
+ queryEntriesWithProps: async (registryName, query, activeFilter) => {
476
+ const res = await this.post("reg_queryEntriesWithProps", [registryName, query, activeFilter]);
477
+ return res.data.result;
478
+ },
479
+ getEntryProperties: async (registryName, entryId, activeFilter) => {
480
+ const res = await this.post("reg_getEntryProperties", [registryName, entryId, activeFilter]);
481
+ return res.data.result;
482
+ },
483
+ };
484
+ this.http = axios_1.default.create({
485
+ ...options.requestConfig,
486
+ baseURL: options.url,
487
+ });
488
+ this.logger = options.logger ?? console;
489
+ this.onError =
490
+ options.onError ??
491
+ ((method, err) => {
492
+ this.logger.error(`JSON-RPC error from ${method} (${err.response?.status} ${err.response?.statusText})`, this.parseAxiosErrorMessage(err));
493
+ });
494
+ }
495
+ getHttpInstance() {
496
+ return this.http;
497
+ }
498
+ defaultHeaders() {
499
+ return {
500
+ Accept: "application/json",
501
+ "Content-Type": "application/json",
502
+ };
503
+ }
504
+ defaultPayload() {
505
+ return {
506
+ jsonrpc: "2.0",
507
+ id: Date.now(),
508
+ };
509
+ }
510
+ getVerifiers(...lookups) {
511
+ return lookups.map((lookup) => new verifier_1.PaladinVerifier(this, lookup));
512
+ }
513
+ parseAxiosErrorMessage(err) {
514
+ if (err instanceof axios_1.AxiosError && err.response?.data?.error) {
515
+ return err.response.data.error?.message || err.response.data.error;
516
+ }
517
+ return `${err}`;
518
+ }
519
+ post(method, params, config) {
520
+ const res = this.http.post("/", { ...this.defaultPayload(), method, params }, { ...config, headers: this.defaultHeaders() });
521
+ res.catch((err) => this.onError(method, err));
522
+ return res;
523
+ }
524
+ async pollForReceipt(txID, waitMs, full) {
525
+ for (let i = 0; i < waitMs; i += POLL_INTERVAL_MS) {
526
+ var receipt = full
527
+ ? await this.ptx.getTransactionReceiptFull(txID)
528
+ : await this.ptx.getTransactionReceipt(txID);
529
+ if (receipt != undefined) {
530
+ return receipt;
531
+ }
532
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
533
+ }
534
+ this.logger.error(`Failed while waiting for receipt: ${txID}`);
535
+ return undefined;
536
+ }
537
+ async pollForPreparedTransaction(txID, waitMs) {
538
+ for (let i = 0; i < waitMs; i += POLL_INTERVAL_MS) {
539
+ var receipt = await this.ptx.getPreparedTransaction(txID);
540
+ if (receipt != undefined) {
541
+ return receipt;
542
+ }
543
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
544
+ }
545
+ this.logger.error(`Failed while waiting for prepare: ${txID}`);
546
+ return undefined;
547
+ }
548
+ /**
549
+ * @deprecated Use ptx.prepareTransaction instead
550
+ */
551
+ async prepareTransaction(transaction) {
552
+ return this.ptx.prepareTransaction(transaction);
553
+ }
554
+ /**
555
+ * @deprecated Use ptx.sendTransaction instead
556
+ */
557
+ async sendTransaction(transaction) {
558
+ return this.ptx.sendTransaction(transaction);
559
+ }
560
+ /**
561
+ * @deprecated Use ptx.call instead
562
+ */
563
+ async call(transaction) {
564
+ return this.ptx.call(transaction);
565
+ }
566
+ /**
567
+ * @deprecated Use ptx.queryTransactions instead
568
+ */
569
+ async queryTransactions(query) {
570
+ return this.ptx.queryTransactions(query);
571
+ }
572
+ /**
573
+ * @deprecated Use ptx.getTransaction or ptx.getTransactionFull instead
574
+ */
575
+ async getTransaction(txID, full) {
576
+ return full
577
+ ? this.ptx.getTransactionFull(txID)
578
+ : this.ptx.getTransaction(txID);
579
+ }
580
+ /**
581
+ * @deprecated Use ptx.getPreparedTransaction instead
582
+ */
583
+ async getPreparedTransaction(txID) {
584
+ return this.ptx.getPreparedTransaction(txID);
585
+ }
586
+ /**
587
+ * @deprecated Use ptx.queryTransactionReceipts instead
588
+ */
589
+ async queryTransactionReceipts(query) {
590
+ return this.ptx.queryTransactionReceipts(query);
591
+ }
592
+ /**
593
+ * @deprecated Use ptx.getTransactionReceipt or ptx.getTransactionReceiptFull instead
594
+ */
595
+ async getTransactionReceipt(txID, full) {
596
+ return full
597
+ ? this.ptx.getTransactionReceiptFull(txID)
598
+ : this.ptx.getTransactionReceipt(txID);
599
+ }
600
+ /**
601
+ * @deprecated Use ptx.getStateReceipt instead
602
+ */
603
+ async getStateReceipt(txID) {
604
+ return this.ptx.getStateReceipt(txID);
605
+ }
606
+ /**
607
+ * @deprecated Use ptx.getDomainReceipt instead
608
+ */
609
+ async getDomainReceipt(domain, txID) {
610
+ return this.ptx.getDomainReceipt(domain, txID);
611
+ }
612
+ /**
613
+ * @deprecated Use ptx.resolveVerifier instead
614
+ */
615
+ async resolveVerifier(lookup, algorithm, verifierType) {
616
+ return this.ptx.resolveVerifier(lookup, algorithm, verifierType);
617
+ }
618
+ /**
619
+ * @deprecated Use ptx.storeABI instead
620
+ */
621
+ async storeABI(abi) {
622
+ return this.ptx.storeABI(abi);
623
+ }
624
+ /**
625
+ * @deprecated Use ptx.getStoredABI instead
626
+ */
627
+ async getStoredABI(hash) {
628
+ return this.ptx.getStoredABI(hash);
629
+ }
630
+ /**
631
+ * @deprecated Use ptx.decodeCall instead
632
+ */
633
+ async decodeCall(callData, dataFormat) {
634
+ return this.ptx.decodeCall(callData, dataFormat);
635
+ }
636
+ /**
637
+ * @deprecated Use ptx.decodeEvent instead
638
+ */
639
+ async decodeEvent(topics, data) {
640
+ return this.ptx.decodeEvent(topics, data);
641
+ }
642
+ /**
643
+ * @deprecated Use ptx.decodeError instead
644
+ */
645
+ async decodeError(revertError, dataFormat) {
646
+ return this.ptx.decodeError(revertError, dataFormat);
647
+ }
648
+ /**
649
+ * @deprecated Use bidx.decodeTransactionEvents instead
650
+ */
651
+ async decodeTransactionEvents(transactionHash, abi, resultFormat) {
652
+ return this.bidx.decodeTransactionEvents(transactionHash, abi, resultFormat);
653
+ }
654
+ /**
655
+ * @deprecated Use pstate.listSchemas instead
656
+ */
657
+ async listSchemas(domain) {
658
+ return this.pstate.listSchemas(domain);
659
+ }
660
+ /**
661
+ * @deprecated Use pstate.queryStates instead
662
+ */
663
+ async queryStates(domain, schema, query, status) {
664
+ return this.pstate.queryStates(domain, schema, query, status);
665
+ }
666
+ /**
667
+ * @deprecated Use pstate.queryContractStates instead
668
+ */
669
+ async queryContractStates(domain, contractAddress, schema, query, status) {
670
+ return this.pstate.queryContractStates(domain, contractAddress, schema, query, status);
671
+ }
672
+ /**
673
+ * @deprecated Use pgroup.createGroup instead
674
+ */
675
+ async createPrivacyGroup(pgroup) {
676
+ return this.pgroup.createGroup(pgroup);
677
+ }
678
+ /**
679
+ * @deprecated Use pgroup.getGroupById instead
680
+ */
681
+ async getPrivacyGroupById(domainName, id) {
682
+ return this.pgroup.getGroupById(domainName, id);
683
+ }
684
+ /**
685
+ * @deprecated Use pgroup.getGroupByAddress instead
686
+ */
687
+ async getPrivacyGroupByAddress(address) {
688
+ return this.pgroup.getGroupByAddress(address);
689
+ }
690
+ /**
691
+ * @deprecated Use pgroup.sendTransaction instead
692
+ */
693
+ async sendPrivacyGroupTransaction(txi) {
694
+ return this.pgroup.sendTransaction(txi);
695
+ }
696
+ /**
697
+ * @deprecated Use pgroup.call instead
698
+ */
699
+ async callPrivacyGroup(txi) {
700
+ return this.pgroup.call(txi);
701
+ }
702
+ /**
703
+ * @deprecated Use ptx.createReceiptListener instead
704
+ */
705
+ async createReceiptListener(listener) {
706
+ return this.ptx.createReceiptListener(listener);
707
+ }
708
+ /**
709
+ * @deprecated Use ptx.deleteReceiptListener instead
710
+ */
711
+ async deleteReceiptListener(name) {
712
+ return this.ptx.deleteReceiptListener(name);
713
+ }
714
+ /**
715
+ * @deprecated Use ptx.getReceiptListener instead
716
+ */
717
+ async getReceiptListener(name) {
718
+ return this.ptx.getReceiptListener(name);
719
+ }
720
+ /**
721
+ * @deprecated Use ptx.createBlockchainEventListener instead
722
+ */
723
+ async createBlockchainEventListener(listener) {
724
+ return this.ptx.createBlockchainEventListener(listener);
725
+ }
726
+ /**
727
+ * @deprecated Use ptx.deleteBlockchainEventListener instead
728
+ */
729
+ async deleteBlockchainEventListener(name) {
730
+ return this.ptx.deleteBlockchainEventListener(name);
731
+ }
732
+ /**
733
+ * @deprecated Use ptx.getBlockchainEventListener instead
734
+ */
735
+ async getBlockchainEventListener(name) {
736
+ return this.ptx.getBlockchainEventListener(name);
737
+ }
738
+ }
739
+ exports.default = PaladinClient;