@polymeshassociation/polymesh-sdk 14.0.0-beta.11 → 14.0.0-beta.12

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 (77) hide show
  1. package/CHANGELOG.md +5 -2
  2. package/Claims.d.ts +60 -1
  3. package/Claims.d.ts.map +1 -1
  4. package/Claims.js +130 -3
  5. package/Claims.js.map +1 -1
  6. package/Network.d.ts +50 -0
  7. package/Network.d.ts.map +1 -1
  8. package/Network.js +106 -0
  9. package/Network.js.map +1 -1
  10. package/Polymesh.d.ts +1 -0
  11. package/Polymesh.d.ts.map +1 -1
  12. package/Polymesh.js +33 -28
  13. package/Polymesh.js.map +1 -1
  14. package/api/entities/Account.d.ts +22 -0
  15. package/api/entities/Account.d.ts.map +1 -1
  16. package/api/entities/Account.js +65 -0
  17. package/api/entities/Account.js.map +1 -1
  18. package/api/entities/Asset/index.d.ts +15 -0
  19. package/api/entities/Asset/index.d.ts.map +1 -1
  20. package/api/entities/Asset/index.js +38 -0
  21. package/api/entities/Asset/index.js.map +1 -1
  22. package/api/entities/CorporateActionBase/index.js +1 -1
  23. package/api/entities/CorporateActionBase/index.js.map +1 -1
  24. package/api/entities/DefaultTrustedClaimIssuer.d.ts +7 -0
  25. package/api/entities/DefaultTrustedClaimIssuer.d.ts.map +1 -1
  26. package/api/entities/DefaultTrustedClaimIssuer.js +17 -0
  27. package/api/entities/DefaultTrustedClaimIssuer.js.map +1 -1
  28. package/api/entities/DividendDistribution/index.d.ts +16 -0
  29. package/api/entities/DividendDistribution/index.d.ts.map +1 -1
  30. package/api/entities/DividendDistribution/index.js +69 -0
  31. package/api/entities/DividendDistribution/index.js.map +1 -1
  32. package/api/entities/Identity/AssetPermissions.d.ts +28 -0
  33. package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
  34. package/api/entities/Identity/AssetPermissions.js +53 -1
  35. package/api/entities/Identity/AssetPermissions.js.map +1 -1
  36. package/api/entities/Identity/index.d.ts +18 -0
  37. package/api/entities/Identity/index.d.ts.map +1 -1
  38. package/api/entities/Identity/index.js +36 -0
  39. package/api/entities/Identity/index.js.map +1 -1
  40. package/api/entities/Instruction/index.d.ts +11 -0
  41. package/api/entities/Instruction/index.d.ts.map +1 -1
  42. package/api/entities/Instruction/index.js +50 -0
  43. package/api/entities/Instruction/index.js.map +1 -1
  44. package/api/entities/NumberedPortfolio.d.ts +7 -0
  45. package/api/entities/NumberedPortfolio.d.ts.map +1 -1
  46. package/api/entities/NumberedPortfolio.js +17 -0
  47. package/api/entities/NumberedPortfolio.js.map +1 -1
  48. package/api/entities/Offering/index.d.ts +13 -0
  49. package/api/entities/Offering/index.d.ts.map +1 -1
  50. package/api/entities/Offering/index.js +32 -0
  51. package/api/entities/Offering/index.js.map +1 -1
  52. package/api/entities/Portfolio/index.d.ts +12 -0
  53. package/api/entities/Portfolio/index.d.ts.map +1 -1
  54. package/api/entities/Portfolio/index.js +94 -5
  55. package/api/entities/Portfolio/index.js.map +1 -1
  56. package/base/Context.d.ts +61 -0
  57. package/base/Context.d.ts.map +1 -1
  58. package/base/Context.js +149 -4
  59. package/base/Context.js.map +1 -1
  60. package/middleware/queriesV2.d.ts +143 -0
  61. package/middleware/queriesV2.d.ts.map +1 -0
  62. package/middleware/queriesV2.js +798 -0
  63. package/middleware/queriesV2.js.map +1 -0
  64. package/middleware/typesV2.d.ts +25495 -0
  65. package/middleware/typesV2.d.ts.map +1 -0
  66. package/middleware/typesV2.js +2013 -0
  67. package/middleware/typesV2.js.map +1 -0
  68. package/npm-package/polymeshassociation-polymesh-sdk-14.0.0-beta.12.tgz +0 -0
  69. package/package.json +2 -1
  70. package/types/utils/index.d.ts +10 -0
  71. package/types/utils/index.d.ts.map +1 -1
  72. package/types/utils/index.js.map +1 -1
  73. package/utils/conversion.d.ts +19 -2
  74. package/utils/conversion.d.ts.map +1 -1
  75. package/utils/conversion.js +59 -4
  76. package/utils/conversion.js.map +1 -1
  77. package/npm-package/polymeshassociation-polymesh-sdk-14.0.0-beta.11.tgz +0 -0
@@ -0,0 +1,798 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.portfolioMovementsQuery = exports.settlementsQuery = exports.assetHoldersQuery = exports.distributionPaymentsQuery = exports.distributionQuery = exports.tickerExternalAgentActionsQuery = exports.tickerExternalAgentHistoryQuery = exports.tickerExternalAgentsQuery = exports.assetQuery = exports.portfolioQuery = exports.trustingAssetsQuery = exports.trustedClaimIssuerQuery = exports.extrinsicsByArgs = exports.extrinsicByHash = exports.eventsByArgs = exports.instructionsQuery = exports.investmentsQuery = exports.claimsQuery = exports.claimsGroupingQuery = exports.heartbeatQuery = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ const typesV2_1 = require("./typesV2");
9
+ /**
10
+ * @hidden
11
+ *
12
+ * Middleware V2 heartbeat
13
+ */
14
+ function heartbeatQuery() {
15
+ const query = (0, graphql_tag_1.default) `
16
+ query {
17
+ block(id: "1") {
18
+ id
19
+ }
20
+ }
21
+ `;
22
+ return {
23
+ query,
24
+ variables: undefined,
25
+ };
26
+ }
27
+ exports.heartbeatQuery = heartbeatQuery;
28
+ /**
29
+ * @hidden
30
+ */
31
+ function createClaimsFilters(variables) {
32
+ const args = ['$size: Int, $start: Int'];
33
+ const filters = ['revokeDate: { isNull: true }'];
34
+ const { dids, claimTypes, trustedClaimIssuers, scope, includeExpired } = variables;
35
+ if (dids) {
36
+ args.push('$dids: [String!]');
37
+ filters.push('targetId: { in: $dids }');
38
+ }
39
+ if (claimTypes) {
40
+ args.push('$claimTypes: [String!]!');
41
+ filters.push('type: { in: $claimTypes }');
42
+ }
43
+ if (trustedClaimIssuers) {
44
+ args.push('$trustedClaimIssuers: [String!]');
45
+ filters.push('issuerId: { in: $trustedClaimIssuers }');
46
+ }
47
+ if (scope !== undefined) {
48
+ args.push('$scope: JSON!');
49
+ filters.push('scope: { contains: $scope }');
50
+ }
51
+ if (!includeExpired) {
52
+ args.push('$expiryTimestamp: BigFloat');
53
+ filters.push('filterExpiry: { lessThan: $expiryTimestamp }');
54
+ }
55
+ return {
56
+ args: `(${args.join()})`,
57
+ filter: `filter: { ${filters.join()} },`,
58
+ };
59
+ }
60
+ /**
61
+ * @hidden
62
+ *
63
+ * Get all dids with at least one claim for a given scope and from one of the given trusted claim issuers
64
+ */
65
+ function claimsGroupingQuery(variables, orderBy = typesV2_1.ClaimsOrderBy.TargetIdAsc, groupBy = typesV2_1.ClaimsGroupBy.TargetId) {
66
+ const { args, filter } = createClaimsFilters(variables);
67
+ const query = (0, graphql_tag_1.default) `
68
+ query claimsGroupingQuery
69
+ ${args}
70
+ {
71
+ claims(
72
+ ${filter}
73
+ orderBy: [${orderBy}]
74
+ first: $size
75
+ offset: $start
76
+ ) {
77
+ groupedAggregates(groupBy: [${groupBy}], having: {}) {
78
+ keys
79
+ }
80
+ }
81
+ }
82
+ `;
83
+ return {
84
+ query,
85
+ variables,
86
+ };
87
+ }
88
+ exports.claimsGroupingQuery = claimsGroupingQuery;
89
+ /**
90
+ * @hidden
91
+ *
92
+ * Get all claims that a given target DID has, with a given scope and from one of the given trustedClaimIssuers
93
+ */
94
+ function claimsQuery(filters, size, start) {
95
+ const { args, filter } = createClaimsFilters(filters);
96
+ const query = (0, graphql_tag_1.default) `
97
+ query ClaimsQuery
98
+ ${args}
99
+ {
100
+ claims(
101
+ ${filter}
102
+ orderBy: [${typesV2_1.ClaimsOrderBy.TargetIdAsc}, ${typesV2_1.ClaimsOrderBy.CreatedBlockIdAsc}, ${typesV2_1.ClaimsOrderBy.EventIdxAsc}]
103
+ first: $size
104
+ offset: $start
105
+ ) {
106
+ totalCount
107
+ nodes {
108
+ targetId
109
+ type
110
+ scope
111
+ cddId
112
+ issuerId
113
+ issuanceDate
114
+ lastUpdateDate
115
+ expiry
116
+ jurisdiction
117
+ }
118
+ }
119
+ }
120
+ `;
121
+ return {
122
+ query,
123
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
124
+ };
125
+ }
126
+ exports.claimsQuery = claimsQuery;
127
+ /**
128
+ * @hidden
129
+ *
130
+ * Get all investments for a given offering
131
+ */
132
+ function investmentsQuery(filters, size, start) {
133
+ const query = (0, graphql_tag_1.default) `
134
+ query InvestmentsQuery($stoId: Int!, $offeringToken: String!, $size: Int, $start: Int) {
135
+ investments(
136
+ filter: { stoId: { equalTo: $stoId }, offeringToken: { equalTo: $offeringToken } }
137
+ first: $size
138
+ offset: $start
139
+ orderBy: [${typesV2_1.InvestmentsOrderBy.CreatedBlockIdAsc}]
140
+ ) {
141
+ totalCount
142
+ nodes {
143
+ investorId
144
+ offeringToken
145
+ raiseToken
146
+ offeringTokenAmount
147
+ raiseTokenAmount
148
+ }
149
+ }
150
+ }
151
+ `;
152
+ return {
153
+ query,
154
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
155
+ };
156
+ }
157
+ exports.investmentsQuery = investmentsQuery;
158
+ /**
159
+ * @hidden
160
+ *
161
+ * Get a specific instruction within a venue for a specific event
162
+ */
163
+ function instructionsQuery(variables) {
164
+ const query = (0, graphql_tag_1.default) `
165
+ query InstructionsQuery($eventId: String!, $id: String!) {
166
+ instructions(
167
+ filter: { eventId: { equalTo: $eventId }, id: { equalTo: $id } }
168
+ first: 1
169
+ orderBy: [${typesV2_1.InstructionsOrderBy.IdDesc}]
170
+ ) {
171
+ nodes {
172
+ eventIdx
173
+ eventId
174
+ status
175
+ settlementType
176
+ updatedBlock {
177
+ blockId
178
+ hash
179
+ datetime
180
+ }
181
+ }
182
+ }
183
+ }
184
+ `;
185
+ return {
186
+ query,
187
+ variables,
188
+ };
189
+ }
190
+ exports.instructionsQuery = instructionsQuery;
191
+ /**
192
+ * @hidden
193
+ */
194
+ function createEventFilters(attributes) {
195
+ const args = ['$start: Int', '$size: Int'];
196
+ const filters = [];
197
+ Object.keys(attributes).forEach(attribute => {
198
+ if (attributes[attribute]) {
199
+ args.push(`$${attribute}: String!`);
200
+ filters.push(`${attribute}: { equalTo: $${attribute} }`);
201
+ }
202
+ });
203
+ return {
204
+ args: `(${args.join()})`,
205
+ filter: filters.length ? `filter: { ${filters.join()} }` : '',
206
+ };
207
+ }
208
+ /**
209
+ * @hidden
210
+ *
211
+ * Get a single event by any of its indexed arguments
212
+ */
213
+ function eventsByArgs(filters, size, start) {
214
+ const { args, filter } = createEventFilters(filters);
215
+ const query = (0, graphql_tag_1.default) `
216
+ query EventsQuery
217
+ ${args}
218
+ {
219
+ events(
220
+ ${filter}
221
+ orderBy: [${typesV2_1.EventsOrderBy.BlockIdAsc}]
222
+ first: $size
223
+ offset: $start
224
+ ) {
225
+ nodes {
226
+ eventIdx
227
+ block {
228
+ blockId
229
+ hash
230
+ datetime
231
+ }
232
+ }
233
+ }
234
+ }
235
+ `;
236
+ return {
237
+ query,
238
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
239
+ };
240
+ }
241
+ exports.eventsByArgs = eventsByArgs;
242
+ /**
243
+ * @hidden
244
+ *
245
+ * Get a transaction by hash
246
+ */
247
+ function extrinsicByHash(variables) {
248
+ const query = (0, graphql_tag_1.default) `
249
+ query TransactionByHashQuery($extrinsicHash: String!) {
250
+ extrinsics(filter: { extrinsicHash: { equalTo: $extrinsicHash } }) {
251
+ nodes {
252
+ extrinsicIdx
253
+ address
254
+ nonce
255
+ moduleId
256
+ callId
257
+ paramsTxt
258
+ success
259
+ specVersionId
260
+ extrinsicHash
261
+ block {
262
+ blockId
263
+ hash
264
+ datetime
265
+ }
266
+ }
267
+ }
268
+ }
269
+ `;
270
+ return {
271
+ query,
272
+ variables,
273
+ };
274
+ }
275
+ exports.extrinsicByHash = extrinsicByHash;
276
+ /**
277
+ * @hidden
278
+ */
279
+ function createExtrinsicFilters(attributes) {
280
+ const args = ['$start: Int', '$size: Int'];
281
+ const filters = [];
282
+ Object.keys(attributes).forEach(key => {
283
+ if (attributes[key]) {
284
+ if (key === 'success') {
285
+ args.push(`$${key}: Int!`);
286
+ }
287
+ else {
288
+ args.push(`$${key}: String!`);
289
+ }
290
+ filters.push(`${key}: { equalTo: $${key} }`);
291
+ }
292
+ });
293
+ return {
294
+ args: `(${args.join()})`,
295
+ filter: filters.length ? `filter: { ${filters.join()} },` : '',
296
+ };
297
+ }
298
+ /**
299
+ * @hidden
300
+ *
301
+ * Get transactions
302
+ */
303
+ function extrinsicsByArgs(filters, size, start, orderBy = typesV2_1.ExtrinsicsOrderBy.BlockIdAsc) {
304
+ const { args, filter } = createExtrinsicFilters(filters);
305
+ const query = (0, graphql_tag_1.default) `
306
+ query TransactionsQuery
307
+ ${args}
308
+ {
309
+ extrinsics(
310
+ ${filter}
311
+ orderBy: [${orderBy}]
312
+ first: $size
313
+ offset: $start
314
+ ) {
315
+ totalCount
316
+ nodes {
317
+ blockId
318
+ extrinsicIdx
319
+ address
320
+ nonce
321
+ moduleId
322
+ callId
323
+ paramsTxt
324
+ success
325
+ specVersionId
326
+ extrinsicHash
327
+ block {
328
+ hash
329
+ }
330
+ }
331
+ }
332
+ }
333
+ `;
334
+ return {
335
+ query,
336
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
337
+ };
338
+ }
339
+ exports.extrinsicsByArgs = extrinsicsByArgs;
340
+ /**
341
+ * @hidden
342
+ *
343
+ * Get an trusted claim issuer event for an asset and an issuer
344
+ */
345
+ function trustedClaimIssuerQuery(variables) {
346
+ const query = (0, graphql_tag_1.default) `
347
+ query TrustedClaimIssuerQuery($assetId: String!, $issuer: String!) {
348
+ trustedClaimIssuers(
349
+ filter: { assetId: { equalTo: $assetId }, issuer: { equalTo: $issuer } }
350
+ ) {
351
+ nodes {
352
+ eventIdx
353
+ createdBlock {
354
+ blockId
355
+ datetime
356
+ hash
357
+ }
358
+ }
359
+ }
360
+ }
361
+ `;
362
+ return {
363
+ query,
364
+ variables,
365
+ };
366
+ }
367
+ exports.trustedClaimIssuerQuery = trustedClaimIssuerQuery;
368
+ /**
369
+ * @hidden
370
+ *
371
+ * Get an trusted claim issuer event for an asset and an issuer
372
+ */
373
+ function trustingAssetsQuery(variables) {
374
+ const query = (0, graphql_tag_1.default) `
375
+ query TrustedClaimIssuerQuery($issuer: String!) {
376
+ trustedClaimIssuers(filter: { issuer: { equalTo: $issuer } }) {
377
+ nodes {
378
+ assetId
379
+ }
380
+ }
381
+ }
382
+ `;
383
+ return {
384
+ query,
385
+ variables,
386
+ };
387
+ }
388
+ exports.trustingAssetsQuery = trustingAssetsQuery;
389
+ /**
390
+ * @hidden
391
+ *
392
+ * Get portfolio details for a given DID and portfolio number
393
+ */
394
+ function portfolioQuery(variables) {
395
+ const query = (0, graphql_tag_1.default) `
396
+ query PortfolioQuery($identityId: String!, $number: Int!) {
397
+ portfolios(filter: { identityId: { equalTo: $identityId }, number: { equalTo: $number } }) {
398
+ nodes {
399
+ eventIdx
400
+ createdBlock {
401
+ blockId
402
+ datetime
403
+ hash
404
+ }
405
+ }
406
+ }
407
+ }
408
+ `;
409
+ return {
410
+ query,
411
+ variables,
412
+ };
413
+ }
414
+ exports.portfolioQuery = portfolioQuery;
415
+ /**
416
+ * @hidden
417
+ *
418
+ * Get Asset details for a given ticker
419
+ */
420
+ function assetQuery(variables) {
421
+ const query = (0, graphql_tag_1.default) `
422
+ query AssetQuery($ticker: String!) {
423
+ assets(filter: { ticker: { equalTo: $ticker } }) {
424
+ nodes {
425
+ eventIdx
426
+ createdBlock {
427
+ blockId
428
+ datetime
429
+ hash
430
+ }
431
+ }
432
+ }
433
+ }
434
+ `;
435
+ return {
436
+ query,
437
+ variables,
438
+ };
439
+ }
440
+ exports.assetQuery = assetQuery;
441
+ /**
442
+ * @hidden
443
+ *
444
+ * Get the event details when external agent added for a ticker
445
+ */
446
+ function tickerExternalAgentsQuery(variables) {
447
+ const query = (0, graphql_tag_1.default) `
448
+ query TickerExternalAgentQuery($assetId: String!) {
449
+ tickerExternalAgents(
450
+ filter: { assetId: { equalTo: $assetId } }
451
+ orderBy: [${typesV2_1.TickerExternalAgentsOrderBy.CreatedBlockIdDesc}]
452
+ first: 1
453
+ ) {
454
+ nodes {
455
+ eventIdx
456
+ createdBlock {
457
+ blockId
458
+ datetime
459
+ hash
460
+ }
461
+ }
462
+ }
463
+ }
464
+ `;
465
+ return {
466
+ query,
467
+ variables,
468
+ };
469
+ }
470
+ exports.tickerExternalAgentsQuery = tickerExternalAgentsQuery;
471
+ /**
472
+ * @hidden
473
+ *
474
+ * Get the transaction history of each external agent of an Asset
475
+ */
476
+ function tickerExternalAgentHistoryQuery(variables) {
477
+ const query = (0, graphql_tag_1.default) `
478
+ query TickerExternalAgentHistoryQuery($assetId: String!) {
479
+ tickerExternalAgentHistories(
480
+ filter: { assetId: { equalTo: $assetId } }
481
+ orderBy: [${typesV2_1.TickerExternalAgentHistoriesOrderBy.CreatedBlockIdAsc}]
482
+ ) {
483
+ nodes {
484
+ identityId
485
+ assetId
486
+ eventIdx
487
+ createdBlock {
488
+ blockId
489
+ hash
490
+ datetime
491
+ }
492
+ }
493
+ }
494
+ }
495
+ `;
496
+ return {
497
+ query,
498
+ variables,
499
+ };
500
+ }
501
+ exports.tickerExternalAgentHistoryQuery = tickerExternalAgentHistoryQuery;
502
+ /**
503
+ * @hidden
504
+ */
505
+ function createTickerExternalAgentActionFilters(attributes) {
506
+ const args = ['$start: Int', '$size: Int'];
507
+ const filters = [];
508
+ Object.keys(attributes).forEach(key => {
509
+ if (attributes[key]) {
510
+ args.push(`$${key}: String!`);
511
+ filters.push(`${key}: { equalTo: $${key} }`);
512
+ }
513
+ });
514
+ return {
515
+ args: `(${args.join()})`,
516
+ filter: filters.length ? `filter: { ${filters.join()} },` : '',
517
+ };
518
+ }
519
+ /**
520
+ * @hidden
521
+ *
522
+ * Get list of Events triggered by actions (from the set of actions that can only be performed by external agents) that have been performed on a specific Asset
523
+ */
524
+ function tickerExternalAgentActionsQuery(filters, size, start) {
525
+ const { args, filter } = createTickerExternalAgentActionFilters(filters);
526
+ const query = (0, graphql_tag_1.default) `
527
+ query TickerExternalAgentActionsQuery
528
+ ${args}
529
+ {
530
+ tickerExternalAgentActions(
531
+ ${filter}
532
+ first: $size
533
+ offset: $start
534
+ orderBy: [${typesV2_1.TickerExternalAgentActionsOrderBy.CreatedBlockIdDesc}]
535
+ ) {
536
+ totalCount
537
+ nodes {
538
+ eventIdx
539
+ palletName
540
+ eventId
541
+ callerId
542
+ createdBlock {
543
+ blockId
544
+ datetime
545
+ hash
546
+ }
547
+ }
548
+ }
549
+ }
550
+ `;
551
+ return {
552
+ query,
553
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
554
+ };
555
+ }
556
+ exports.tickerExternalAgentActionsQuery = tickerExternalAgentActionsQuery;
557
+ /**
558
+ * @hidden
559
+ *
560
+ * Get distribution details for a CAId
561
+ */
562
+ function distributionQuery(variables) {
563
+ const query = (0, graphql_tag_1.default) `
564
+ query DistributionQuery($id: String!) {
565
+ distribution(id: $id) {
566
+ taxes
567
+ }
568
+ }
569
+ `;
570
+ return {
571
+ query,
572
+ variables,
573
+ };
574
+ }
575
+ exports.distributionQuery = distributionQuery;
576
+ /**
577
+ * @hidden
578
+ *
579
+ * Get history of claims for a distribution
580
+ */
581
+ function distributionPaymentsQuery(filters, size, start) {
582
+ const query = (0, graphql_tag_1.default) `
583
+ query DistributionPaymentQuery($distributionId: String!, $size: Int, $start: Int) {
584
+ distributionPayments(
585
+ filter: { distributionId: { equalTo: $distributionId } }
586
+ first: $size
587
+ offset: $start
588
+ ) {
589
+ totalCount
590
+ nodes {
591
+ eventId
592
+ targetId
593
+ datetime
594
+ amount
595
+ tax
596
+ createdBlock {
597
+ blockId
598
+ hash
599
+ }
600
+ }
601
+ }
602
+ }
603
+ `;
604
+ return {
605
+ query,
606
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
607
+ };
608
+ }
609
+ exports.distributionPaymentsQuery = distributionPaymentsQuery;
610
+ /**
611
+ * @hidden
612
+ *
613
+ * Get asset held by a DID
614
+ */
615
+ function assetHoldersQuery(filters, size, start, orderBy = typesV2_1.AssetHoldersOrderBy.CreatedBlockIdAsc) {
616
+ const query = (0, graphql_tag_1.default) `
617
+ query AssetHoldersQuery($identityId: String!, $size: Int, $start: Int) {
618
+ assetHolders(
619
+ filter: { identityId: { equalTo: $identityId } }
620
+ first: $size
621
+ offset: $start
622
+ orderBy: [${orderBy}]
623
+ ) {
624
+ totalCount
625
+ nodes {
626
+ assetId
627
+ }
628
+ }
629
+ }
630
+ `;
631
+ return {
632
+ query,
633
+ variables: Object.assign(Object.assign({}, filters), { size: size === null || size === void 0 ? void 0 : size.toNumber(), start: start === null || start === void 0 ? void 0 : start.toNumber() }),
634
+ };
635
+ }
636
+ exports.assetHoldersQuery = assetHoldersQuery;
637
+ /**
638
+ * @hidden
639
+ */
640
+ function createLegFilters({ identityId, portfolioId, ticker, address }) {
641
+ const args = ['$fromId: String!, $toId: String!'];
642
+ const fromIdFilters = ['fromId: { equalTo: $fromId }'];
643
+ const toIdFilters = ['toId: { equalTo: $toId }'];
644
+ const portfolioNumber = portfolioId ? portfolioId.toNumber() : 0;
645
+ const variables = {
646
+ fromId: `${identityId}/${portfolioNumber}`,
647
+ toId: `${identityId}/${portfolioNumber}`,
648
+ };
649
+ if (ticker) {
650
+ variables.assetId = ticker;
651
+ args.push('$assetId: String!');
652
+ const assetIdFilter = 'assetId: { equalTo: $assetId }';
653
+ toIdFilters.push(assetIdFilter);
654
+ fromIdFilters.push(assetIdFilter);
655
+ }
656
+ if (address) {
657
+ variables.addresses = [address];
658
+ args.push('$addresses: [String!]!');
659
+ const addressFilter = 'addresses: { in: $addresses }';
660
+ toIdFilters.push(addressFilter);
661
+ fromIdFilters.push(addressFilter);
662
+ }
663
+ return {
664
+ args: `(${args.join()})`,
665
+ filter: `filter: { or: [{ ${fromIdFilters.join()} }, { ${toIdFilters.join()} } ] }`,
666
+ variables,
667
+ };
668
+ }
669
+ /**
670
+ * @hidden
671
+ *
672
+ * Get Settlements where a Portfolio is involved
673
+ */
674
+ function settlementsQuery(filters) {
675
+ const { args, filter, variables } = createLegFilters(filters);
676
+ const query = (0, graphql_tag_1.default) `
677
+ query SettlementsQuery
678
+ ${args}
679
+ {
680
+ legs(
681
+ ${filter}
682
+ orderBy: [${typesV2_1.LegsOrderBy.InstructionIdAsc}]
683
+ ) {
684
+ nodes {
685
+ settlement {
686
+ id
687
+ createdBlock {
688
+ blockId
689
+ datetime
690
+ hash
691
+ }
692
+ result
693
+ legs {
694
+ nodes {
695
+ fromId
696
+ from {
697
+ identityId
698
+ number
699
+ }
700
+ toId
701
+ to {
702
+ identityId
703
+ number
704
+ }
705
+ assetId
706
+ amount
707
+ addresses
708
+ }
709
+ }
710
+ }
711
+ }
712
+ }
713
+ }
714
+ `;
715
+ return {
716
+ query,
717
+ variables,
718
+ };
719
+ }
720
+ exports.settlementsQuery = settlementsQuery;
721
+ /**
722
+ * @hidden
723
+ */
724
+ function createPortfolioMovementFilters({ identityId, portfolioId, ticker, address, }) {
725
+ const args = ['$fromId: String!, $toId: String!'];
726
+ const fromIdFilters = ['fromId: { equalTo: $fromId }'];
727
+ const toIdFilters = ['toId: { equalTo: $toId }'];
728
+ const portfolioNumber = portfolioId ? portfolioId.toNumber() : 0;
729
+ const variables = {
730
+ fromId: `${identityId}/${portfolioNumber}`,
731
+ toId: `${identityId}/${portfolioNumber}`,
732
+ };
733
+ if (ticker) {
734
+ variables.assetId = ticker;
735
+ args.push('$assetId: String!');
736
+ const assetIdFilter = 'assetId: { equalTo: $assetId }';
737
+ toIdFilters.push(assetIdFilter);
738
+ fromIdFilters.push(assetIdFilter);
739
+ }
740
+ if (address) {
741
+ variables.address = address;
742
+ args.push('$address: String!');
743
+ const addressFilter = 'address: { in: $address }';
744
+ toIdFilters.push(addressFilter);
745
+ fromIdFilters.push(addressFilter);
746
+ }
747
+ return {
748
+ args: `(${args.join()})`,
749
+ filter: `filter: { or: [ { ${fromIdFilters.join()} }, { ${toIdFilters.join()} } ] }`,
750
+ variables,
751
+ };
752
+ }
753
+ /**
754
+ * @hidden
755
+ *
756
+ * Get Settlements where a Portfolio is involved
757
+ */
758
+ function portfolioMovementsQuery(filters) {
759
+ const { args, filter, variables } = createPortfolioMovementFilters(filters);
760
+ const query = (0, graphql_tag_1.default) `
761
+ query PortfolioMovementsQuery
762
+ ${args}
763
+ {
764
+ portfolioMovements(
765
+ ${filter}
766
+ orderBy: [${typesV2_1.PortfolioMovementsOrderBy.IdAsc}]
767
+ ) {
768
+ nodes {
769
+ id
770
+ fromId
771
+ from {
772
+ identityId
773
+ number
774
+ }
775
+ toId
776
+ to {
777
+ identityId
778
+ number
779
+ }
780
+ assetId
781
+ amount
782
+ address
783
+ createdBlock {
784
+ blockId
785
+ datetime
786
+ hash
787
+ }
788
+ }
789
+ }
790
+ }
791
+ `;
792
+ return {
793
+ query,
794
+ variables,
795
+ };
796
+ }
797
+ exports.portfolioMovementsQuery = portfolioMovementsQuery;
798
+ //# sourceMappingURL=queriesV2.js.map